fix(gateway): implement yuanbao channel with real app_key/app_secret protocol - #35
fix(gateway): implement yuanbao channel with real app_key/app_secret protocol#35huangcheng wants to merge 1 commit into
Conversation
…protocol harness-gateway 0.8.5 ships a broken YuanbaoConfig stub that requires token/bot_id and speaks a non-existent HTTP-callback protocol, so the yuanbao channel could never connect (probe failed with "missing Token, Bot ID"). Implement a working channel in Octop until upstream is fixed: - infra/gateway/channels/yuanbao.py: YuanbaoConfig(app_key, app_secret, api_domain, ws_url), hand-rolled protobuf codec (ConnMsg, auth-bind, ping, send_c2c/group_message, InboundMessagePush), HMAC-SHA256 sign-token with cached refresh, WSS client with heartbeat, push ACK, kickout handling and backoff reconnect. - gateway.py: register yuanbao via manager.add_channel(instance) and probe via real sign-token + auth-bind, bypassing the stub. - i18n: label app_key as "App Key" (was "Client ID"). - tests: 28 unit tests for codec, sign-token, parse_inbound and probe credential validation (no live network). Verified: make all green (1391 passed); live smoke test against bot.yuanbao.tencent.com with real credentials passes sign-token, auth-bind and heartbeat.
|
Hi huangcheng, Many thanks for your contribution. We also reviewed the issue you identified. We noticed that the PR was closed, but you are very welcome to continue participating in the Octop community. We are starting a channel support testing and contribution activity around harness-gateway and Octop/Orca, and we would be happy to have your help. The channel part is a good area to contribute: harness-gateway provides the unified BaseChannel / ChannelManager abstraction, while Octop/Orca integrates channels with agents, sessions, media, slash commands, HITL approvals, and proactive push. We plan to test the following aspects:
If you are interested, we can coordinate on one channel first and provide a concrete test checklist. we will open the harness-gateway in few weeks. Looking forward to your contribution. |
|
Hi @Pandakingxbc, Thanks a lot for the warm message — glad the review of the issue was useful. Quick note on the closure: it was accidental. My fork was deleted by mistake, which auto-closed this PR (closed PRs with a deleted head repo can't be reopened), so I've resubmitted the same change as #36 (same commit I'd love to join the channel testing and contribution activity. The 10 areas you listed line up well with what I ran into while implementing the yuanbao channel — credential probing, inbound/outbound routing, reconnect/token-refresh behavior, and media upload (which I intentionally left out) all seem like great candidates for a shared test checklist. Since yuanbao is the channel I know best right now (real app_key/app_secret sign-token + WSS protobuf protocol, verified end-to-end in production), I'd suggest we coordinate on it first — I can help write the concrete test checklist for it, and port the implementation upstream to Looking forward to collaborating! |
Problem
The Yuanbao (Tencent 元宝) channel was completely unusable: after configuring the correct App Key / App Secret, the channel probe failed with "credentials incomplete: missing Token, Bot ID".
Root cause
harness-gateway==0.8.5ships a placeholderYuanbaoConfigstub that:token/bot_id) — andChannelConfig.from_dictsilently drops the unknownapp_key/app_secretfields the dashboard persists, so the probe always reports missingToken/Bot ID.The real Tencent Yuanbao protocol is: exchange
app_key:app_secretfor a signed token via HMAC-SHA256 againstPOST /api/v5/robotLogic/sign-token, then connect towss://bot-wss.yuanbao.tencent.com/wss/connectionand speak a binary protobuf (ConnMsg) wire protocol.Fix
The upstream
harness-gatewayrepository is currently not publicly accessible, so this ships a working channel inside Octop for now. Once upstream publishes a real implementation this can be removed.infra/gateway/channels/yuanbao.py(new) — self-contained implementation:YuanbaoConfig(app_key, app_secret, api_domain, ws_url)withmissing_credentials()validation.ConnMsg,auth-bind,ping,send_c2c_message/send_group_message,InboundMessagePush).10099.auth-bind, heartbeat driven by the server-reportedPingRsp.heartInterval, push handling withPushAck, kickout handling, anti-loopback (skip own messages).[1,2,5,10,30,60]s); non-retryable close codes4012/4013/4014/4018/4019/4021; token refresh on auth codes41103/41104/41108.qq.py.gateway.py— registers the yuanbao channel viamanager.add_channel(instance)to bypass the broken stub, and probes via a real sign-token + auth-bind round trip. Missing credentials now correctly report "missing App Key / App Secret".app_keyas "App Key" (was "Client ID") in bothen.jsonandzh.json.parse_inbound, and the probe credential-validation path (no live network).Protocol details were reverse-engineered from the official
openclaw-plugin-yuanbao@2.17.0proto descriptors and client, and verified against production.Test plan
make all— 1391 passed, 2 skippedmake lint+make typecheck(mypy --strict, 334 files) cleanbot.yuanbao.tencent.com:probe_yuanbao()✅ →YuanbaoChannel.start()auth-bind success ✅ → heartbeat cycle ✅ → cleanstop()✅Follow-ups
TencentCloud/harness-gatewayrepository is accessible, this implementation ports almost verbatim into upstream (correctrequired_credentials+ relocate the channel class), at which point the Octop-side shim can be dropped.Changelog
Updated
CHANGELOG.mdunder[Unreleased].