feat(gateway): add WeChat adapter with iLink 2.1.x protocol#2502
Closed
linxule wants to merge 3 commits into
Closed
feat(gateway): add WeChat adapter with iLink 2.1.x protocol#2502linxule wants to merge 3 commits into
linxule wants to merge 3 commits into
Conversation
a8cd652 to
2eae331
Compare
19 tasks
…support 3-file architecture (adapter/transport/state) implementing the iLink Bot API protocol from openclaw-weixin SDK 2.1.7: - iLink-App-Id + iLink-App-ClientVersion headers on all API requests - IDC redirect (scaned_but_redirect) in QR login flow - Context token persistence with reload at startup and clear on session expiry - Referenced message (ref_msg) extraction for quoted replies - SILK voice transcoding with graceful fallback - CDN upload with upload_full_url priority and exponential backoff - CDN download with full_url forward-compatibility - Dynamic channel_version (not hardcoded) - AES-128-ECB media encryption with dual key format support Full platform integration: enum, env overrides, adapter factory, auth maps, toolsets, CLI setup wizard, status display, cron delivery, send_message tool, channel directory, prompt hints, env sanitizer keys, and login script. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comprehensive coverage of adapter, transport, and state modules: - Platform enum and config loading from env vars - iLink header encoding and presence verification - AES-128-ECB encrypt/decrypt round-trip with key parsing - Context token persistence (save/load/clear lifecycle) - Sync buffer persistence - Inbound message extraction (text, voice, media, ref_msg) - Media selection priority and CDN upload size guard - Markdown stripping, dedup, typing ticket TTL - Send behavior (context tokens, chunking, self-message filtering) - Source-level registration assertions (config, run, toolsets) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-Authored-By: OpenAI Codex <noreply@openai.com>
- New: website/docs/user-guide/messaging/wechat.md (full setup guide with env vars, feature matrix, architecture overview, troubleshooting) - Update messaging index with WeChat in architecture diagram, toolset table, and platform links - Add WECHAT_* env vars to environment-variables.md reference - Add WeChat to README.md platform mentions and AGENTS.md directory listing - Add wechat to website sidebar navigation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-Authored-By: OpenAI Codex <noreply@openai.com>
2eae331 to
6fb5307
Compare
Contributor
Author
|
Closing — WeChat support landed via #7166. Glad to see the feature ship. Will help test on Pi. |
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.
What does this PR do?
Adds WeChat as a supported messaging platform for the Hermes gateway, implementing the iLink Bot API protocol from the
@tencent-weixin/openclaw-weixinSDK 2.1.7. No external SDK dependency — pure Python port with SDK 2.1.7 protocol compliance.This is a complete rewrite of the original weixin adapter submission (March 22), upgraded to match the current SDK protocol, renamed for codebase consistency (
weixin→wechat), and restructured into a clean 3-file architecture.Related Issue
N/A — new platform adapter.
Type of Change
Changes Made
Core adapter (3-file architecture)
gateway/platforms/wechat.py(~870 lines) — adapter lifecycle, message routing, media handlinggateway/platforms/wechat_transport.py(~465 lines) — HTTP transport, CDN upload/download, AES-128-ECB cryptogateway/platforms/wechat_state.py(~105 lines) — context token and sync buffer disk persistenceProtocol compliance (openclaw-weixin SDK 2.1.7)
iLink-App-Id+iLink-App-ClientVersionheaders on all API requestsscaned_but_redirect) in QR login flowerrcode -14)ref_msg) extraction for quoted repliesupload_full_urlpriority + exponential backofffull_urlforward-compatibilitychannel_version(not hardcoded)lenfield uses plaintext size (not ciphertext — matches SDK)Platform integration (all 16 checklist items from
ADDING_A_PLATFORM.md)gateway/config.py—Platform.WECHATenum, env overrides, connection checkgateway/run.py— adapter factory, auth maps, update-allowed settoolsets.py—hermes-wechattoolset + gateway compositetools/send_message_tool.py— platform routing + standalone_send_wechat()hermes_cli/gateway.py— setup wizard entryhermes_cli/config.py— WECHAT env vars in_EXTRA_ENV_KEYShermes_cli/tools_config.py,skills_config.py,status.pycron/scheduler.py,gateway/channel_directory.pytools/cronjob_tools.py,agent/prompt_builder.pyLogin script
scripts/wechat_login.py— QR login with iLink headers, IDC redirect handling, auto-refreshTests
tests/gateway/test_wechat.py— 85 tests covering adapter, transport, state, protocol compliance, and source-level registration assertionsDocumentation
website/docs/user-guide/messaging/wechat.md— full setup guide with env vars, feature matrix, troubleshootingmessaging/index.md,environment-variables.md,sidebars.ts,README.md,AGENTS.mdHow to Test
httpxandcryptography(both already in Hermes[all]extras)python -m pytest tests/gateway/test_wechat.py -v(85 tests, all passing)python scripts/wechat_login.py(scan QR with WeChat)WECHAT_BOT_TOKENandWECHAT_ACCOUNT_IDfrom login outputhermes gateway start— verify WeChat adapter connectsChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings)cli-config.yaml.exampleif I added/changed config keys — N/A (env-var-only config)CONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflowsKnown Limitations
ffmpegandsilk-v3-decoderon PATH for native voice bubble playback; falls back to file attachment delivery when unavailable_send_wechat()in send_message_tool starts a poll loop during connect/disconnect — consistent with the WeCom adapter pattern but creates a brief race window with the main gateway's poll loopAcknowledgments
This adapter was developed collaboratively:
🤖 Generated with Claude Code