refactor(reply): migrate public inbound SDK with legacy compatibility - #102
Merged
Merged
Conversation
Share the inbound context and transport pipeline across routed and legacy public dispatch. Keep the 2026.6.1 floor, preserve admission and progress callbacks, and settle message hooks once. Refs #98 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve each text-send account once, share the public inbound request shape, and remove unused pre-builder context assignments while preserving dispatch and hook ownership. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The high-risk host hook and deferred-turn lifecycle migration still awaits the required human whole-system validation.
Pull request overview
Migrates inbound reply handling to public OpenClaw APIs while retaining legacy host compatibility and preserving lifecycle, account, and hook behavior.
Changes:
- Adds routed/legacy inbound dispatch adaptation.
- Centralizes legacy reply hooks and transport message IDs.
- Expands lifecycle, transport, compatibility, and documentation coverage.
File summaries
| File | Description |
|---|---|
test/helpers/channel-runtime.ts |
Supports both runtime contracts. |
src/monitor/monitor.ts |
Updates dispatch documentation. |
src/monitor/monitor.test.ts |
Tests replay scheduling after failure. |
src/messaging/process-message.ts |
Uses public context and turn dispatch. |
src/messaging/process-message.test.ts |
Covers dispatch, hooks, media, and lifecycle. |
src/messaging/outbound-hooks.ts |
Centralizes local hook settlement. |
src/messaging/outbound-hooks.test.ts |
Tests cancellation and settlement. |
src/messaging/inbound.ts |
Updates session-key documentation. |
src/messaging/inbound-turn.ts |
Adds modern/legacy compatibility adapter. |
src/messaging/inbound-turn.test.ts |
Tests both public contracts. |
src/channel.ts |
Removes duplicate outbound hooks. |
src/channel.test.ts |
Verifies host-owned outbound hooks. |
docs/zh-CN/architecture.md |
Documents the new architecture in Chinese. |
docs/en/architecture.md |
Documents the new architecture in English. |
CHANGELOG.md |
Adds Chinese release notes. |
CHANGELOG_EN.md |
Adds English release notes. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
变更说明
Closes #98。
从 Tencent/openclaw-weixin#251 拆出入站派发与消息 hook 迁移,采用 issue 中确认的兼容方案:保留 OpenClaw
>=2026.6.1,按注入 runtime 的能力选择两种公开契约。inbound.buildContext、微信文本/媒体传输和进度逻辑;一个inbound-turn.ts适配现代inbound.dispatch与旧版inbound.dispatchReply。已基于包含 #101 的
main重放提交,保留双方变更日志。后续简化去掉单次使用的文本发送包装、重复账号解析、重复请求类型和无效 context 赋值,净减少 28 行生产代码。完整 SDK/CLI 验证驱动保留在会话资料中,未放入本 PR。验收标准
非目标与替代方案
不提高最低宿主、不升级依赖或插件版本,不改微信协议、账号/状态格式、授权策略、文件锁、配置写入或已有分块设置。CI、贡献指南和兼容检查驱动相对
main无差异。提高最低宿主可换取单一路径,但不符合保留 6.1 的要求。当前仅保留一个旧版公开契约适配,不保留第二套消息处理器,也不采用失败后回退重试。
关联任务与风险
关联 #98(
agent:ready、risk:privileged)。最高风险是宿主 hook 归属与延后回复生命周期。旧版 identitybeforeDeliver显式替换 SDK 的默认文本修改 hook,避免本地再次修改;reply_payload_sending仍由宿主处理。实际模型排队/接管、停止重载和微信客户端展示仍待人工整机验证,故保留 draft。合成 resolver 与回调测试不被当作真实排队运行的证明。
既有边界不在本 PR 修复:独立冷进程发送需要账号启动时恢复 context token;
2026.6.34回移了 channel 别名能力,现有按日期判断的别名检查会误报。风险与不变量
openclaw-weixin身份、最低宿主、Node.js 要求、凭据、context token、轮询游标和去重状态格式均不变。稳定别名用于路由,主账号继续拥有状态及传输凭据。旧版载荷准备留在 provider 投递内部,避免替换宿主持有的载荷元数据。错误继续脱敏;不增加全局账号兜底或跨契约重发。自动化测试用例
npm run check:通过兼容性验证
最低宿主仍为
2026.6.1,lockfile/current 为2026.8.2。以下为实施期间的隔离验证记录(Windows),不是仅凭 CI 配置或 mock 推断:每个版本均在可丢弃目录安装精确 SDK,断言安装版本,再执行
npm run typecheck、npm run build和无 Vitest mock 的编译产物验证。真实 SDK 使用合成replyResolver,真实宿主主动发送使用 HTTP/CDN 拦截;均无微信网络访问。验证驱动按范围收敛要求保存在会话资料中,不纳入本 PR。根目录依赖保持 lockfile 版本。基于 #101 的后续简化已重新覆盖 minimum/current/beta;
inbound-turn.ts的类型合并未改变其编译后 JavaScript(字节级比较一致)。没有新增宿主接口或放宽回退规则。整机实测结果
eafa36c28d41ef42b4104703c7587a418a17e5d5脱敏关键日志
无人工整机日志。自动化原始日志、配置、状态及私有数据均未附加。
其他验证命令
npm run test:unit -- src/channel.test.ts src/auth/account-store.test.ts src/messaging/inbound-turn.test.ts src/messaging/process-message.test.ts:通过,136 个用例。npm run check:通过,49 个文件、826 个用例,未降低覆盖率阈值。npm run pack:check:通过,98 个发布文件。npm test --prefix docs/site:通过,46 个用例;npm run build --prefix docs/site:通过。后续简化未修改文档。git diff --check:通过。初始差异的只读审查未发现显著问题。检查清单
npm run check。