feat: Add Feishu WebSocket long connection support#297
Open
eathard wants to merge 5 commits intoRightNow-AI:mainfrom
Open
feat: Add Feishu WebSocket long connection support#297eathard wants to merge 5 commits intoRightNow-AI:mainfrom
eathard wants to merge 5 commits intoRightNow-AI:mainfrom
Conversation
This commit implements WebSocket long connection mode for Feishu/Lark integration, allowing OpenFang to receive messages from local environments without requiring public IP or port forwarding. ## Key Changes ### Core Implementation - **feishu.rs**: Add WebSocket connection support with protobuf message handling - Implement Feishu WebSocket protocol (wss://msg-frontier.feishu.cn/ws/v2) - Add manual protobuf encoding/decoding (no external proto files) - Implement ping/pong keepalive mechanism - Add message fragmentation handling for large payloads - Support both webhook and WebSocket connection modes ### Configuration - **config.rs**: Add `FeishuConnectionMode` enum (websocket/webhook) - **Cargo.toml**: Add required dependencies (tokio-tungstenite, prost, flate2) - **channel_bridge.rs**: Update to support new connection mode parameter ### Bug Fixes - Fix `receive_id` error by using `chat_id` instead of `sender_id` - Change log levels from `trace!` to `info!` for better visibility ### Documentation - Add FEISHU_WEBSOCKET_README.md with setup and usage instructions ## Technical Details - Protocol: Custom protobuf over WebSocket - Authentication: Dynamic ticket-based handshake - Compression: Gzip for message payloads - Frame: SeqID, LogID, service, method, headers, payload Resolves: #S143 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix panic when logging shell commands containing multi-byte UTF-8 characters (e.g., Chinese characters). The previous code used byte indexing to truncate strings, which could panic when truncating at a byte that fell in the middle of a multi-byte character. Error: byte index 100 is not a char boundary; it is inside '统' (bytes 98..101) Solution: Use char_indices() for safe character-boundary string truncation. Fixes: #issue
Author
Additional Bug Fix IncludedThis PR now also includes a critical bug fix for UTF-8 character handling: Fix: UTF-8 character boundary panic in subprocess_sandbox.rs
This fix ensures that OpenFang can safely handle shell commands with international characters, making it more robust for global users. |
Resolve Cargo.lock conflicts by updating dependencies to latest compatible versions. Updated openfang workspace packages from v0.3.12 to v0.3.17.
egargale
pushed a commit
to egargale/openfang
that referenced
this pull request
Mar 5, 2026
* test: deepen coverage for health doctor provider and tunnels * test: add broad trait and module re-export coverage
Sync with latest main (v0.3.20) and resolve Cargo.lock conflicts. Updated workspace dependencies from v0.3.17 to v0.3.20. All conflicts resolved, PR ready for merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Feishu WebSocket Long Connection Support
Summary
Implements WebSocket long connection mode for Feishu/Lark integration, enabling OpenFang to receive messages from local environments without requiring public IP or port forwarding.
Changes
FeishuConnectionModeenum (websocket/webhook).protofilesreceive_iderror by usingchat_idinstead ofsender_idFiles Modified
crates/openfang-channels/src/feishu.rs(+998 lines)crates/openfang-types/src/config.rs(+22 lines)crates/openfang-channels/Cargo.toml(+4 dependencies)Cargo.lock(dependency updates)crates/openfang-api/src/channel_bridge.rs(minor update)Dependencies Added
tokio-tungstenite- WebSocket clientprost&prost-types- Protobuf encodingflate2- Gzip decompressionTesting
✅ WebSocket connection established successfully
✅ Message reception verified with test messages
✅ Protobuf frame decoding functional
✅ Ping/pong keepalive working (90s interval)
✅ Event payload parsing correct
Configuration Example
Documentation
FEISHU_WEBSOCKET_README.mdwith setup instructionsCHANGELOG.mdfor v0.3.13RELEASE_NOTES_v0.3.13.mdwith detailed release notesBreaking Changes
FeishuAdapter::new()now requiresconnection_modeinstead ofwebhook_portBefore:
After:
Checklist
Related Issues
Resolves: #S143 (Feishu WebSocket Long Connection Implementation)
Additional Notes
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com