@dingxiang-me/openclaw-wechat 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.en.md +181 -14
  3. package/README.md +201 -16
  4. package/docs/channels/wecom.md +137 -1
  5. package/openclaw.plugin.json +688 -6
  6. package/package.json +204 -4
  7. package/scripts/wecom-agent-selfcheck.mjs +775 -0
  8. package/scripts/wecom-bot-longconn-probe.mjs +582 -0
  9. package/scripts/wecom-bot-selfcheck.mjs +952 -0
  10. package/scripts/wecom-callback-matrix.mjs +224 -0
  11. package/scripts/wecom-doctor.mjs +1407 -0
  12. package/scripts/wecom-e2e-scenario.mjs +333 -0
  13. package/scripts/wecom-migrate.mjs +261 -0
  14. package/scripts/wecom-quickstart.mjs +1824 -0
  15. package/scripts/wecom-release-check.mjs +232 -0
  16. package/scripts/wecom-remote-e2e.mjs +310 -0
  17. package/scripts/wecom-selfcheck.mjs +1255 -0
  18. package/scripts/wecom-smoke.sh +74 -0
  19. package/src/core/delivery-router.js +21 -0
  20. package/src/core.js +619 -30
  21. package/src/wecom/account-config-core.js +27 -1
  22. package/src/wecom/account-config.js +19 -2
  23. package/src/wecom/agent-dispatch-executor.js +11 -0
  24. package/src/wecom/agent-dispatch-handlers.js +61 -8
  25. package/src/wecom/agent-inbound-guards.js +24 -0
  26. package/src/wecom/agent-inbound-processor.js +34 -2
  27. package/src/wecom/agent-late-reply-runtime.js +30 -2
  28. package/src/wecom/agent-text-sender.js +2 -0
  29. package/src/wecom/api-client-core.js +27 -19
  30. package/src/wecom/api-client-media.js +16 -7
  31. package/src/wecom/api-client-send-text.js +4 -0
  32. package/src/wecom/api-client-send-typed.js +4 -1
  33. package/src/wecom/api-client-senders.js +41 -3
  34. package/src/wecom/api-client.js +1 -0
  35. package/src/wecom/bot-dispatch-fallback.js +18 -3
  36. package/src/wecom/bot-dispatch-handlers.js +47 -10
  37. package/src/wecom/bot-inbound-dispatch-runtime.js +3 -0
  38. package/src/wecom/bot-inbound-executor-helpers.js +11 -1
  39. package/src/wecom/bot-inbound-executor.js +24 -0
  40. package/src/wecom/bot-inbound-guards.js +31 -1
  41. package/src/wecom/channel-config-schema.js +132 -0
  42. package/src/wecom/channel-plugin.js +348 -7
  43. package/src/wecom/command-handlers.js +102 -11
  44. package/src/wecom/command-status-text.js +206 -0
  45. package/src/wecom/doc-client.js +7 -1
  46. package/src/wecom/inbound-content-handler-file-video-link.js +4 -0
  47. package/src/wecom/inbound-content-handler-image-voice.js +6 -0
  48. package/src/wecom/inbound-content.js +5 -0
  49. package/src/wecom/installer-api.js +910 -0
  50. package/src/wecom/media-download.js +2 -2
  51. package/src/wecom/migration-diagnostics.js +816 -0
  52. package/src/wecom/network-config.js +91 -0
  53. package/src/wecom/observability-metrics.js +9 -3
  54. package/src/wecom/outbound-agent-delivery.js +313 -0
  55. package/src/wecom/outbound-agent-media-sender.js +37 -7
  56. package/src/wecom/outbound-agent-push.js +1 -0
  57. package/src/wecom/outbound-delivery.js +129 -12
  58. package/src/wecom/outbound-stream-msg-item.js +25 -2
  59. package/src/wecom/outbound-webhook-delivery.js +19 -0
  60. package/src/wecom/outbound-webhook-media.js +30 -6
  61. package/src/wecom/pending-reply-manager.js +143 -0
  62. package/src/wecom/plugin-account-policy-services.js +26 -0
  63. package/src/wecom/plugin-base-services.js +58 -0
  64. package/src/wecom/plugin-constants.js +1 -1
  65. package/src/wecom/plugin-delivery-inbound-services.js +25 -0
  66. package/src/wecom/plugin-processing-deps.js +7 -0
  67. package/src/wecom/plugin-route-runtime-deps.js +1 -0
  68. package/src/wecom/plugin-services.js +87 -0
  69. package/src/wecom/policy-resolvers.js +93 -20
  70. package/src/wecom/quickstart-metadata.js +1247 -0
  71. package/src/wecom/reasoning-visibility.js +104 -0
  72. package/src/wecom/register-runtime.js +10 -0
  73. package/src/wecom/reliable-delivery-persistence.js +138 -0
  74. package/src/wecom/reliable-delivery.js +642 -0
  75. package/src/wecom/reply-output-policy.js +171 -0
  76. package/src/wecom/text-inbound-scheduler.js +6 -1
  77. package/src/wecom/workspace-auto-sender.js +2 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,78 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [2.3.0] - 2026-03-15
8
+
9
+ ### Added
10
+ - 文档与发布说明已收口为插件侧接入路径:默认推荐 `installer / quickstart / doctor`,`openclaw channels add --channel wecom --use-env` 仅保留为高级 env-backed 初始化路径
11
+ - 新增官方 / sunnoy 风格配置兼容:支持顶层与账户级 `botId`、`secret`、`network.egressProxyUrl`、`network.apiBaseUrl`
12
+ - `wecom:migrate` 现在会识别 flat `botId/secret` 与 `network.*`,并生成归一化到 `bot.longConnection.*`、`outboundProxy`、`apiBaseUrl` 的 patch
13
+ - `wecom:migrate` / `wecom:doctor` 新增 `migrationSource`,可区分 `official-wecom / sunnoy-wecom / legacy-openclaw-wechat / mixed-source`
14
+ - `wecom:doctor` 新增 `--fix / --confirm-fix`,可先应用本地可落盘的 migration/plugin patch,再用修正后的配置重跑 doctor
15
+ - `openclaw.plugin.json` schema 新增上述兼容字段声明,避免被严格校验误判成 inline 账户
16
+ - `delivery.reasoning.mode/title/maxChars`,可控制 WeCom `<think>` / reasoning 内容分离显示、合并到最终回复或隐藏
17
+ - `delivery.replyFormat`,支持 `auto / text / markdown`,可按链路保留 markdown 或自动回退纯文本
18
+ - 最终回复支持 `MEDIA:` / `FILE:` 指令;Bot / Agent 会自动隐藏指令行并回传对应媒体
19
+ - Pending Reply 新增可选持久化,支持把可靠投递状态落盘并在 gateway 重启后恢复
20
+ - `wecom:selfcheck`、`wecom:agent:selfcheck`、`wecom:bot:selfcheck` 新增 persistence / reasoning 摘要
21
+ - channel metadata 新增结构化 quickstart modes,可直接暴露 `bot_long_connection / agent_callback / hybrid` 三种 starter config
22
+ - 新增 `npm run wecom:quickstart`,可打印或合并写入 starter config,并自动备份原 `openclaw.json`
23
+ - quickstart 新增群策略模板:`inherit / mention_only / open_direct / allowlist_template / deny`,支持用 `--group-profile` 直接生成常见群策略配置
24
+ - 新增显式群聊准入策略:`groupPolicy`、`groupChat.policy`、`groups.<chatId>.policy`,支持 `open / allowlist / deny`
25
+ - `/status` 与 selfcheck 新增群策略诊断摘要,直接显示当前命中的群规则来源、触发模式和白名单是否处于生效状态
26
+ - quickstart 新增 setup plan:可直接产出 `placeholders / setupChecklist / warnings`,并通过 runtime metadata 暴露 `supportsSetupPlan / setupCommand / writeCommand`
27
+ - quickstart 新增 `--wizard` 交互式向导,可逐步选择 mode / dm / group profile,并在最后确认是否写入配置
28
+ - quickstart 新增 `--run-checks / --force-checks`,可直接串起推荐 selfcheck,并在 JSON 输出里返回 `postcheck` 摘要
29
+ - quickstart `postcheck` 新增 remediation 归纳,会把常见失败信号翻译成下一步修复建议
30
+ - quickstart `postcheck` 新增 `repairArtifacts`,可直接产出最小 `configPatch` 与 `.env` 模板,减少手工补配置
31
+ - quickstart 新增 `--repair-dir`,可把 `repairArtifacts` 直接落盘为 `wecom.config-patch.json`、`wecom.account-patch.json`、`wecom.env.template`
32
+ - quickstart 新增 `--apply-repair`,可把生成的 repair patch 直接 merge 到目标 `openclaw.json` 并保留备份
33
+ - quickstart 新增 `--confirm-repair`,可先预览将要变更的字段,再确认是否真正应用 repair patch
34
+ - quickstart setup plan / `--json` 新增 `actions`、`installState`、`migrationState`,便于 CLI / UI 直接消费接入闭环动作
35
+ - quickstart `postcheck` 新增 `repairPlan`,会结构化列出 repair 的配置变更、env 变更和预计文件输出
36
+ - `repairApply` / starter `write` 新增 `changedPaths`,可直接看到真实落盘的字段
37
+ - 新增 `npm run wecom:migrate`,可独立盘点 `legacy_config / mixed_layout / stale_package` 并生成迁移 patch 与 env 模板
38
+ - 新增 `npm run wecom:doctor`,可统一聚合 migration、自检、Agent/Bot E2E、Bot 长连接探针和公网回调矩阵
39
+ - 新增单独安装器包 `@dingxiang-me/openclaw-wecom-cli`,支持 `npx -y @dingxiang-me/openclaw-wecom-cli install`
40
+ - 外部安装器 `install --json` 现在会输出 `migration.guide`、legacy 字段路径和回滚命令,并支持 `--confirm-doctor-fix / --no-doctor-fix / --yes`
41
+ - 外部安装器 `install --json` 新增结构化 `actions`,可直接消费来源审阅、迁移 patch、回滚和重跑 doctor 的动作列表
42
+ - 外部安装器在未显式传 `--mode` 时,会按来源和当前配置能力自动选择 `bot_long_connection / agent_callback / hybrid`,并在 `sourceProfile` 里解释决策
43
+ - 外部安装器 `sourceProfile` 新增来源专属 `checkOrder / repairDefaults`;官方 / legacy 来源默认自动附带 `doctor --fix`,sunnoy / mixed-source 默认先给修复建议
44
+ - quickstart `--json` 新增 `sourcePlaybook`,会按当前来源返回推荐检查顺序、占位项提示和默认 repair 策略
45
+ - quickstart metadata 新增 `supportsActions / supportsMigration / supportsRepairPlan / supportsConfirmRepair / migrationCommand`
46
+ - 新增 `npm run test:e2e:local`,黑盒验证本地 `install -> doctor -> fix -> rerun` 闭环
47
+ - 新增 `npm run test:release`,统一检查 root 包、installer CLI、manifest、运行时版本常量和 `npm pack --dry-run` 产物
48
+ - CI 新增 `Onboarding E2E` 与 `Release Check` 两条门禁;tag 发布新增 release workflow,顺序发布插件包与 installer CLI
49
+ - WeCom 插件新增 `setup.applyAccountConfig / applyAccountName / validateInput`,`openclaw channels add --channel wecom --use-env` 现在可用
50
+ - `channels add` 文档补充为 env-backed WeCom 初始化路径,并明确剩余限制来自 OpenClaw core 当前通用参数集合
51
+
52
+ ### Changed
53
+ - WeCom API token / send / media / doc 链路现在统一支持自定义 `apiBaseUrl`
54
+ - `wecom:selfcheck`、`wecom:agent:selfcheck`、`wecom:bot:selfcheck` 已补齐这些兼容字段的识别,不再把它们误判成 legacy inline 账号
55
+ - Bot fallback、Agent 最终回复和 `/status` 现在都会按 reasoning 策略统一处理可见文本与思考内容
56
+ - 可靠投递状态存储支持导出/恢复,Pending Reply 不再局限于纯内存生命周期
57
+ - package.json / openclaw.plugin.json / runtime channel meta 的接入元数据已同步,便于 installer / quickstart / doctor 和后续集成入口直接消费
58
+ - package.json / openclaw.plugin.json / runtime channel meta 现在会同时暴露 `supportsDoctor / doctorCommand`
59
+ - package metadata / runtime quickstart 现在会同时暴露 `supportsExternalInstaller / installerSpec / installerCommand`
60
+ - 群聊发送者校验不再只依赖 `allowFrom` 是否非空推断;`/status`、manifest、UI schema 与运行时现在统一展示显式 `groupPolicy`
61
+ - selfcheck 的 legacy inline 账号发现保留字同步补齐 `groupPolicy/groupAllowFrom/groups`,避免把群策略字段误判成账号 ID
62
+ - `wecom:selfcheck` 现在会直接显示 install / migration 状态,并在检测到 legacy 布局时指向 `npm run wecom:migrate -- --json`
63
+ - 版本一致性回归不再硬编码具体版本号,改为强校验 root 包、CLI 包、manifest 与运行时常量同步
64
+
65
+ ## [2.2.0] - 2026-03-14
66
+
67
+ ### Added
68
+ - 新增 WeCom 可靠投递状态跟踪,统一记录 `24h` 回复窗口、主动发送额度和当前会话/账户的 Pending Reply 数量
69
+ - 新增 Pending Reply 队列与重试管理器,支持失败最终回复的定时补发和“下次入站优先补发”
70
+ - `/status` 新增可靠投递摘要,直接展示窗口状态、额度状态和最近失败原因
71
+ - `wecom:selfcheck`、`wecom:agent:selfcheck`、`wecom:bot:selfcheck` 新增 `reliable-delivery` 摘要
72
+
73
+ ### Changed
74
+ - WeCom Bot delivery router 现在会输出标准化 `deliveryStatus`,区分 `delivered / rejected_window / rejected_quota / rejected_transport / rejected_target / rejected_unknown`
75
+ - Agent 最终文本回复和超时后的 late reply / timeout fallback 统一接入可靠投递链路
76
+ - 配置 schema 新增 `channels.wecom.delivery.pendingReply.*` 与 `channels.wecom.delivery.quotaTracking.enabled`
77
+ - 仓库、manifest 与运行时版本号统一升级到 `2.2.0`
78
+
7
79
  ## [2.1.0] - 2026-03-14
8
80
 
9
81
  ### Added
package/README.en.md CHANGED
@@ -10,7 +10,7 @@ OpenClaw-Wechat is an OpenClaw channel plugin for Enterprise WeChat (WeCom), wit
10
10
 
11
11
  ## Table of Contents
12
12
 
13
- - [Onboarding Update (v2.1.0)](#onboarding-update-v210)
13
+ - [Reliable Delivery Update (v2.2.0)](#reliable-delivery-update-v220)
14
14
  - [Highlights](#highlights)
15
15
  - [Mode Comparison](#mode-comparison)
16
16
  - [5-Minute Quick Start](#5-minute-quick-start)
@@ -28,27 +28,29 @@ OpenClaw-Wechat is an OpenClaw channel plugin for Enterprise WeChat (WeCom), wit
28
28
  - [Development](#development)
29
29
  - [FAQ](#faq)
30
30
 
31
- ## Onboarding Update (v2.1.0)
31
+ ## Reliable Delivery Update (v2.2.0)
32
32
 
33
- This release focuses on setup quality, not feature sprawl. The goal is to make `OpenClaw-Wechat` behave more like a native OpenClaw channel during install and first-run.
33
+ This release focuses on reply reliability rather than new surface area. The goal is to make WeCom delivery visible, retryable, and diagnosable.
34
34
 
35
35
  ### What changed
36
36
 
37
37
  | Item | Result |
38
38
  |---|---|
39
- | DM pairing approval | Added `dm.mode=pairing`, backed by OpenClaw native pairing flow |
40
- | Quickstart metadata | Added `detailLabel`, `systemImage`, and `quickstartAllowFrom` |
41
- | `/status` readability | Status now leads with `receive / reply / send / media / voice / doc` readiness |
42
- | Selfcheck summaries | `wecom:selfcheck`, `wecom:agent:selfcheck`, and `wecom:bot:selfcheck` now print `readiness` and `routing` summaries |
43
- | Route visibility | Status and selfcheck now show whether routing comes from `bindings` or `dynamicAgent` |
44
- | Long-connection log noise | Normal connect / opened / subscribed logs moved to `debug` |
39
+ | Reliable-delivery status | `/status` now shows `24h window / proactive quota / Pending Reply` summary |
40
+ | Pending Reply | final replies that fail to deliver are queued for retry and next-inbound replay |
41
+ | Failure classification | delivery now distinguishes `window expired / quota exhausted / transport failure / invalid target` |
42
+ | Selfcheck summaries | `wecom:selfcheck`, `wecom:agent:selfcheck`, and `wecom:bot:selfcheck` now print `reliable-delivery` summaries |
43
+ | Group-policy diagnostics | `/status` and selfcheck now show group rule source, access mode, and whether allowlists are actually active |
44
+ | Bot/Agent convergence | bot fallback and agent final reply now share the same reliable-delivery tracking |
45
+ | Long-connection log noise | normal connect / opened / subscribed logs stay at `debug` |
45
46
 
46
47
  ### Practical impact
47
48
 
48
- - New users can start from the smallest working config, then add multi-account or dynamic routing later.
49
- - Teams that want controlled DM access can now use `pairing` instead of maintaining `allowFrom` only.
50
- - `/status` and selfcheck answer “can it receive, reply, and send?” before lower-level transport details.
51
- - Bot long-connection is quieter by default while still keeping useful warnings and errors.
49
+ - You can now see whether the current session is still inside the 24-hour reply window.
50
+ - Group-chat policy no longer requires log forensics: `/status` and selfcheck explain which group rule is active and whether an allowlist is currently enforced.
51
+ - Failed final replies no longer disappear into timeout-only fallbacks; they move into Pending Reply retry flow.
52
+ - Selfcheck now tells you whether reliable-delivery tracking is enabled, not just whether tokens and webhook paths exist.
53
+ - Bot long-connection stays quiet by default while keeping warnings and errors visible.
52
54
 
53
55
  ## Highlights
54
56
 
@@ -85,11 +87,39 @@ This release focuses on setup quality, not feature sprawl. The goal is to make `
85
87
 
86
88
  ### 1) Install plugin
87
89
 
90
+ Fastest path:
91
+
92
+ ```bash
93
+ npx -y @dingxiang-me/openclaw-wecom-cli install
94
+ ```
95
+
96
+ This wraps the same quickstart / migrate / doctor flow and turns plugin install + starter config write into one command.
97
+
98
+ If you want to stay inside this repo, run the same flow with:
99
+
100
+ ```bash
101
+ npm run wecom:quickstart -- --mode bot_long_connection
102
+ npm run wecom:doctor -- --json
103
+ ```
104
+
105
+ If you already have `WECOM_*` / `WECOM_BOT_*` env vars prepared, WeCom also supports an env-backed `channels add` flow:
106
+
107
+ ```bash
108
+ export WECOM_BOT_LONG_CONNECTION_BOT_ID=your-bot-id
109
+ export WECOM_BOT_LONG_CONNECTION_SECRET=your-bot-secret
110
+ openclaw channels add --channel wecom --use-env
111
+ ```
112
+
113
+ This works without any OpenClaw core patch because the plugin exposes `setup.applyAccountConfig` for WeCom. It can persist Agent/Bot settings discovered from env vars into `openclaw.json`.
114
+ Treat it as an advanced env-backed compatibility path, not the primary onboarding flow. For full setup, migration, and repair, the external installer remains the recommended path.
115
+
116
+ If you only want the plugin package itself:
117
+
88
118
  ```bash
89
119
  openclaw plugins install @dingxiang-me/openclaw-wechat
90
120
  ```
91
121
 
92
- Recommended minimum package version: `2.1.0`. If `plugins.installs.openclaw-wechat` in `openclaw.json` still reports `1.7.x`, upgrade or reinstall first; those older npm packages do not expose the current WeCom channel metadata.
122
+ Recommended minimum package version: `2.3.0`. If `plugins.installs.openclaw-wechat` in `openclaw.json` still reports `1.7.x`, upgrade or reinstall first; those older npm packages do not expose the current WeCom onboarding, migration, or reliable-delivery capabilities.
93
123
 
94
124
  For local development or direct source-path loading, use:
95
125
 
@@ -318,13 +348,132 @@ When multi-account is enabled, each account can override Bot callback credential
318
348
  | Direct-message policy | `dm.mode`, `dm.allowFrom`, `dm.rejectMessage` (`open / allowlist / pairing / deny`) |
319
349
  | Event policy | `events.enabled`, `events.enterAgentWelcomeEnabled`, `events.enterAgentWelcomeText` |
320
350
  | Group trigger | `groupChat.enabled`, `groupChat.triggerMode`, `groupChat.mentionPatterns`, `groupChat.triggerKeywords` |
351
+ | Group policy | `groupPolicy`, `groupChat.policy`, `groups.<chatId>.policy` (`open / allowlist / deny`) |
352
+ | Group member ACL | `groupAllowFrom`, `groups.<chatId>.allowFrom` (used with `allowlist`) |
321
353
  | Dynamic route | `dynamicAgent.*` (compatible with `dynamicAgents.*`, `dm.createAgentOnFirstMessage`) |
322
354
  | Debounce | `debounce.enabled`, `debounce.windowMs`, `debounce.maxBatch` |
323
355
  | Agent streaming | `streaming.enabled`, `streaming.minChars`, `streaming.minIntervalMs` |
356
+ | Pending Reply persistence | `delivery.pendingReply.persist`, `delivery.pendingReply.storeFile` |
357
+ | Reasoning visibility | `delivery.reasoning.mode`, `delivery.reasoning.title`, `delivery.reasoning.maxChars` |
358
+ | Final reply format | `delivery.replyFormat` (`auto / text / markdown`) |
324
359
  | Observability | `observability.enabled`, `observability.logPayloadMeta` |
325
360
 
326
361
  ### OpenClaw bindings for account-level routing
327
362
 
363
+ Package metadata, plugin manifest, and runtime channel meta now expose the same quickstart modes so the installer, quickstart, doctor, and future integrations can consume the same starter config and setup checklist.
364
+
365
+ Fastest entry:
366
+
367
+ ```bash
368
+ npx -y @dingxiang-me/openclaw-wecom-cli install
369
+ ```
370
+
371
+ If you prefer the repo-local scripts, you can still generate a starter config immediately:
372
+
373
+ ```bash
374
+ npm run wecom:quickstart -- --mode bot_long_connection
375
+ ```
376
+
377
+ If you prefer an interactive wizard:
378
+
379
+ ```bash
380
+ npm run wecom:quickstart -- --wizard
381
+ ```
382
+
383
+ Common examples:
384
+
385
+ ```bash
386
+ # Recommended default mode
387
+ npm run wecom:quickstart -- --json
388
+
389
+ # Walk through mode / dm / group-policy choices interactively
390
+ npm run wecom:quickstart -- --wizard
391
+
392
+ # Run the recommended selfchecks for the selected mode
393
+ npm run wecom:quickstart -- --run-checks
394
+
395
+ # Force those checks even if starter placeholders are still present
396
+ npm run wecom:quickstart -- --run-checks --force-checks
397
+
398
+ # Write a ready-to-apply config patch and .env template to disk
399
+ npm run wecom:quickstart -- --run-checks --repair-dir ./.wecom-repair
400
+
401
+ # Merge the generated repair configPatch directly into the target openclaw.json
402
+ npm run wecom:quickstart -- --run-checks --apply-repair
403
+
404
+ # Preview the fields that would change, then confirm before applying the repair patch
405
+ npm run wecom:quickstart -- --run-checks --confirm-repair
406
+
407
+ # Inspect legacy / mixed-layout config and generate a migration patch
408
+ npm run wecom:migrate -- --json
409
+
410
+ # Aggregate migration, selfchecks, E2E checks, long-connection probe, and callback matrix
411
+ npm run wecom:doctor -- --json
412
+
413
+ # Run the local black-box onboarding flow: install -> doctor -> fix -> rerun
414
+ npm run test:e2e:local
415
+
416
+ # Verify version sync and npm pack outputs for both packages
417
+ npm run test:release
418
+
419
+ # Scaffold an account-scoped Agent callback setup
420
+ npm run wecom:quickstart -- --mode agent_callback --account sales --dm-mode allowlist
421
+
422
+ # Add a ready-to-edit group allowlist template
423
+ npm run wecom:quickstart -- --mode hybrid --group-profile allowlist_template --group-chat-id wr-ops-room --group-allow ops_lead,oncall_user
424
+
425
+ # Merge into openclaw.json and create a backup first
426
+ npm run wecom:quickstart -- --mode hybrid --write
427
+ ```
428
+
429
+ Supported `--group-profile` values: `inherit`, `mention_only`, `open_direct`, `allowlist_template`, `deny`.
430
+ `--wizard` treats any CLI flags you already passed as defaults, then walks through the remaining choices and write confirmation.
431
+ `--run-checks` executes the recommended post-setup selfchecks for the selected mode; if placeholders are still present, execution is blocked unless you explicitly pass `--force-checks`.
432
+ `--apply-repair` merges `postcheck.repairArtifacts.configPatch` directly into the `--config` file and creates a backup first.
433
+ `--confirm-repair` prints the exact fields that would change, then asks before performing `--apply-repair`; the prompt stays on `stderr` so `--json` output remains machine-readable.
434
+ `npm run wecom:migrate -- --json` skips starter generation and audits only the current install / migration state, which is useful for `legacy_config / mixed_layout / stale_package`.
435
+ `npm run wecom:migrate -- --json` and `npm run wecom:doctor -- --json` now also report `migrationSource`, so you can tell whether the current layout looks closer to `official-wecom`, `sunnoy-wecom`, `legacy-openclaw-wechat`, or `mixed-source`.
436
+ `npm run wecom:doctor -- --json` aggregates `migration + selfcheck + agent/bot e2e + longconn probe + callback matrix` into one report; add `--skip-network` if you want to inspect local install / migration issues first.
437
+ `npm run wecom:doctor -- --fix --skip-network --json` applies the current local fix patch first, then reruns doctor on the merged config.
438
+ `npm run wecom:doctor -- --confirm-fix --skip-network --json` previews the exact fields first, then asks before writing the patch.
439
+ `npm run wecom:quickstart -- --json` now also returns `sourcePlaybook`, so the quickstart report itself can expose source-specific check order, placeholder guidance, and default repair behavior.
440
+ `npx -y @dingxiang-me/openclaw-wecom-cli install` first tries `openclaw plugins install @dingxiang-me/openclaw-wechat`, then writes starter config and can continue with a local doctor pass.
441
+ `npm run test:e2e:local` black-boxes the local `install -> doctor -> fix -> rerun` flow without relying on a live WeCom network.
442
+ `npm run test:release` verifies root package, installer CLI, manifest, runtime version constants, and `npm pack --dry-run` outputs before a release.
443
+ If the current layout looks closer to the official plugin, sunnoy, or legacy OpenClaw-Wechat, the `--json` report now includes `migration.guide`, source-specific notes, legacy field paths, and a rollback command.
444
+ Use `--confirm-doctor-fix` if you want the installer to ask before appending `doctor --fix`; use `--no-doctor-fix` to suppress it entirely, or `--yes` to auto-confirm prompts.
445
+ The installer `--json` report now also includes structured `actions`, so a CLI/UI layer can consume source review, migration, rollback, and rerun-doctor steps directly.
446
+ If you do not pass `--mode`, the installer can now auto-pick `bot_long_connection / agent_callback / hybrid` from the detected source plus current capabilities, and explains that decision in `sourceProfile`.
447
+ The repo now also ships two CI gates: `Onboarding E2E` for the local install loop, and `Release Check` for version/pack consistency; tag releases run a dedicated workflow that publishes both the plugin package and installer CLI in sequence.
448
+ `sourceProfile` now also exposes source-specific `checkOrder` and `repairDefaults`. Official / legacy sources still default to auto-appending `doctor --fix`, while sunnoy / mixed-source defaults stay advisory until you confirm repair explicitly.
449
+
450
+ The `--json` report now also includes:
451
+
452
+ - `placeholders`: starter-template values you still need to replace
453
+ - `setupChecklist`: the next admin/selfcheck steps to run
454
+ - `actions`: structured setup actions that CLI / UI can consume directly
455
+ - `installState / migrationState`: whether the current layout is fresh, legacy_config, stale_package, mixed_layout, or ready
456
+ - `migrationSource / migrationSourceSummary`: whether the current layout looks closer to the official plugin, sunnoy compatibility layout, legacy-openclaw-wechat, or a mixed-source config
457
+ - `fix`: whether doctor `--fix` prompted, confirmed, and wrote a local patch, plus the real `changedPaths`
458
+ - `sourcePlaybook`: the quickstart-side source-specific check order, placeholder guidance, and repair defaults
459
+ - `sourceProfile.checkOrder / sourceProfile.repairDefaults`: the source-specific validation order plus the installer's default repair strategy
460
+ - `warnings`: mode/profile-specific caveats that still need confirmation
461
+ - `postcheck`: recommended selfcheck execution status, blockage reason, or summary
462
+ - `postcheck.remediation`: actionable fix hints derived from failed checks
463
+ - `postcheck.repairArtifacts`: a minimal `configPatch` plus `.env` template you can apply directly to fix the detected setup gaps
464
+ - `postcheck.repairPlan`: itemized repair changes, env updates, and file writes
465
+ - `migration.configPatch / migration.envTemplate`: suggested normalized layout for the current legacy config
466
+
467
+ If you also pass `--repair-dir <path>`, quickstart will materialize those artifacts as:
468
+
469
+ - `wecom.config-patch.json`
470
+ - `wecom.account-patch.json`
471
+ - `wecom.env.template`
472
+ - `README.txt`
473
+
474
+ If you pass `--apply-repair`, the report will also include `repairApply` so you can see whether the repair patch was actually merged into the target config.
475
+ If you pass `--confirm-repair`, `repairApply` also includes `prompted/confirmed` so you can tell whether the patch was declined or auto-applied; actual writes are listed in `repairApply.changedPaths`.
476
+
328
477
  Use OpenClaw core `bindings` for stable account-to-agent routing. The plugin exposes `channel=wecom` and `accountId=<id>` to the core router.
329
478
 
330
479
  ```json
@@ -799,6 +948,24 @@ Set:
799
948
  }
800
949
  ```
801
950
 
951
+ If you also need to limit which members can trigger the bot in a group, add a group member ACL:
952
+
953
+ ```json
954
+ {
955
+ "channels": {
956
+ "wecom": {
957
+ "groupAllowFrom": ["alice", "bob"],
958
+ "groups": {
959
+ "wr9N1x...": {
960
+ "allowFrom": ["ops_lead"],
961
+ "rejectMessage": "Only the on-duty team can trigger this bot in the group."
962
+ }
963
+ }
964
+ }
965
+ }
966
+ }
967
+ ```
968
+
802
969
  And verify WeCom-side prerequisites:
803
970
  1. App callback is enabled and URL verification succeeded.
804
971
  2. App visibility includes group members.
package/README.md CHANGED
@@ -12,7 +12,7 @@ OpenClaw-Wechat 是一个面向 OpenClaw 的企业微信渠道插件,支持两
12
12
 
13
13
  ## 目录
14
14
 
15
- - [接入更新(v2.1.0)](#接入更新v210)
15
+ - [可靠投递更新(v2.2.0)](#可靠投递更新v220)
16
16
  - [功能概览](#功能概览)
17
17
  - [模式对比](#模式对比)
18
18
  - [5 分钟极速上手](#5-分钟极速上手)
@@ -33,30 +33,38 @@ OpenClaw-Wechat 是一个面向 OpenClaw 的企业微信渠道插件,支持两
33
33
  - [FAQ](#faq)
34
34
  - [版本与贡献](#版本与贡献)
35
35
 
36
- ## 接入更新(v2.1.0)
36
+ ## 可靠投递更新(v2.2.0)
37
37
 
38
- 这版不是继续堆新平台能力,而是把接入体验收口到“更像 OpenClaw 原生渠道”的状态。
38
+ 这版重点不在接入元信息,而是把 WeCom 回复链路补成“可感知、可补发、可诊断”的可靠投递。
39
39
 
40
40
  ### 这版新增了什么
41
41
 
42
42
  | 项目 | 结果 |
43
43
  |---|---|
44
- | 私聊配对审批 | 新增 `dm.mode=pairing`,首次私聊会生成 OpenClaw 原生配对审批 |
45
- | Quickstart 元信息 | 渠道 metadata 补齐 `detailLabel`、`systemImage`、`quickstartAllowFrom` |
46
- | `/status` 可读性 | 优先展示 `收消息 / 回消息 / 主动发送 / 媒体 / 语音 / 文档` 准备情况 |
47
- | Selfcheck 摘要 | `wecom:selfcheck` / `wecom:agent:selfcheck` / `wecom:bot:selfcheck` 新增 `readiness` 与 `routing` 摘要 |
48
- | 路由可见性 | 明确显示当前是否命中 `bindings` `dynamicAgent` |
49
- | 长连接日志降噪 | 正常的 connect / opened / subscribed 改为 `debug`,减少默认噪音 |
44
+ | 可靠投递状态 | `/status` 新增 `24h 窗口 / 主动发送额度 / Pending Reply` 摘要 |
45
+ | Pending Reply | 最终回复投递失败后自动入队,支持定时重试和下次入站补发 |
46
+ | Pending Reply 持久化 | 可选落盘,gateway 重启后继续补发未送达的最终回复 |
47
+ | 配额感知 | 统一区分 `窗口过期 / 额度不足 / 传输失败 / 目标无效` |
48
+ | 推理展示策略 | `delivery.reasoning` 可控制 `<think>` 内容分离显示、合并到最终回复或隐藏 |
49
+ | Selfcheck 摘要 | `wecom:selfcheck` / `wecom:agent:selfcheck` / `wecom:bot:selfcheck` 增加 `reliable-delivery` 摘要 |
50
+ | 群策略诊断 | `/status` 与 selfcheck 会显示当前群规则来源、准入模式以及白名单是否生效 |
51
+ | 最终回复格式 | `delivery.replyFormat` 支持 `auto / text / markdown`,会按链路选择纯文本或 markdown 能力 |
52
+ | 媒体指令 | 模型最终回复支持 `MEDIA:` / `FILE:` 指令,自动回传图片/文件并隐藏指令行 |
53
+ | Bot/Agent 收口 | Bot fallback 与 Agent 最终回复统一纳入可靠投递跟踪 |
54
+ | 长连接日志降噪 | 正常的 connect / opened / subscribed 继续保持 `debug`,默认日志更安静 |
50
55
 
51
56
  ### 这版对接入有什么实际影响
52
57
 
53
- - 新用户现在可以按最小配置先跑通,再决定是否启用多账号、动态路由和文档工具。
54
- - 需要私聊审批时,不再只能靠手写 `allowFrom`,可以直接用 `pairing` 模式接到 OpenClaw 审批流。
55
- - `/status` 和 selfcheck 先回答“能不能收、能不能回、能不能发”,再展开工程细节。
56
- - Bot 长连接默认日志更安静,排障时再开 `debug` 看正常心跳和订阅细节。
58
+ - 现在能直接看出当前会话是否仍在 `24h` 回复窗口内,以及是否存在待补发的最终回复。
59
+ - Bot / Agent 不再只是超时兜底,而是会把失败结果分类并进入 Pending Reply 重试。
60
+ - selfcheck 会明确告诉你可靠投递追踪是否打开、是否持久化,以及当前推理展示模式。
61
+ - 群聊策略不再只能靠日志反推,`/status` selfcheck 会直接说明当前命中的群规则来源与白名单是否真的在限制触发。
62
+ - Bot 长连接默认日志仍然更安静,排障时再开 `debug` 看正常心跳和订阅细节。
57
63
 
58
64
  ### 当前推荐的接入顺序
59
65
 
66
+ 现在 package / manifest / runtime channel meta 都会暴露同一套 quickstart metadata,便于 installer、quickstart、doctor 和后续集成入口读取同一份推荐模式、starter config 和 setup checklist。
67
+
60
68
  1. 先选一个主入口:
61
69
  - Bot 长连接:适合最快跑通对话
62
70
  - Agent:适合需要主动发送、菜单、自建应用能力
@@ -68,7 +76,133 @@ OpenClaw-Wechat 是一个面向 OpenClaw 的企业微信渠道插件,支持两
68
76
  - `bindings`
69
77
  - `dynamicAgent`
70
78
  - `wecom_doc`
71
- - 本地语音转写
79
+
80
+ ### Quickstart 命令
81
+
82
+ 推荐入口:
83
+
84
+ ```bash
85
+ npx -y @dingxiang-me/openclaw-wecom-cli install
86
+ ```
87
+
88
+ 如果你更想留在仓库内执行同一套流程:
89
+
90
+ ```bash
91
+ npm run wecom:quickstart -- --mode bot_long_connection
92
+ npm run wecom:doctor -- --json
93
+ ```
94
+
95
+ 如果你想走交互式向导:
96
+
97
+ ```bash
98
+ npm run wecom:quickstart -- --wizard
99
+ ```
100
+
101
+ 如果你已经准备好了 `WECOM_*` / `WECOM_BOT_*` 环境变量,也可以使用兼容性的 env-backed 初始化路径:
102
+
103
+ ```bash
104
+ export WECOM_BOT_LONG_CONNECTION_BOT_ID=your-bot-id
105
+ export WECOM_BOT_LONG_CONNECTION_SECRET=your-bot-secret
106
+ openclaw channels add --channel wecom --use-env
107
+ ```
108
+
109
+ 这条 `channels add --use-env` 路径不需要任何 OpenClaw core 补丁,但它只适合 env-backed 初始化。
110
+ 日常文档、排障和安装说明都默认以 `installer / quickstart / doctor` 为主路径;如果你需要完整接入和迁移闭环,仍然优先用 `npx -y @dingxiang-me/openclaw-wecom-cli install`。
111
+
112
+ 常见用法:
113
+
114
+ ```bash
115
+ # 默认推荐模式:Bot 长连接
116
+ npm run wecom:quickstart -- --json
117
+
118
+ # 交互式选择 mode / dm / 群策略,并决定是否直接写入配置
119
+ npm run wecom:quickstart -- --wizard
120
+
121
+ # 把推荐 selfcheck 也串起来跑;如仍有占位项,默认会先阻止执行
122
+ npm run wecom:quickstart -- --run-checks
123
+
124
+ # 即使还没填完占位项,也强制执行推荐检查
125
+ npm run wecom:quickstart -- --run-checks --force-checks
126
+
127
+ # 把修复用的 configPatch 和 .env 模板直接写到目录里
128
+ npm run wecom:quickstart -- --run-checks --repair-dir ./.wecom-repair
129
+
130
+ # 直接把生成的 repair configPatch 合并进目标 openclaw.json
131
+ npm run wecom:quickstart -- --run-checks --apply-repair
132
+
133
+ # 先预览将要修改的字段,再确认是否真的应用 repair patch
134
+ npm run wecom:quickstart -- --run-checks --confirm-repair
135
+
136
+ # 单独盘点当前配置里的 legacy / mixed-layout 问题,并生成迁移 patch
137
+ npm run wecom:migrate -- --json
138
+
139
+ # 一次性聚合安装状态、迁移状态、自检、长连接探针和回调矩阵
140
+ npm run wecom:doctor -- --json
141
+
142
+ # 跑本地黑盒 onboarding E2E:install -> doctor -> fix -> rerun
143
+ npm run test:e2e:local
144
+
145
+ # 检查 root 包、installer CLI、manifest 和 npm pack 产物是否一致
146
+ npm run test:release
147
+
148
+ # 生成 sales 账号的 Agent 回调模板
149
+ npm run wecom:quickstart -- --mode agent_callback --account sales --dm-mode allowlist
150
+
151
+ # 直接带一份群白名单模板(值班群/运营群)
152
+ npm run wecom:quickstart -- --mode hybrid --group-profile allowlist_template --group-chat-id wr-ops-room --group-allow ops_lead,oncall_user
153
+
154
+ # 直接合并写入 openclaw.json,并自动备份原文件
155
+ npm run wecom:quickstart -- --mode hybrid --write
156
+ ```
157
+
158
+ `--group-profile` 可选值有:`inherit`、`mention_only`、`open_direct`、`allowlist_template`、`deny`。
159
+ 默认行为只打印 starter config 和检查清单;只有显式传 `--write` 才会写文件。
160
+ `--wizard` 会把当前 CLI 参数当作默认值,然后逐步提问,最后再确认是否写入 `openclaw.json`。
161
+ `--run-checks` 会按当前 mode 的推荐命令执行自检;若 starter config 里还有占位项,默认会阻止执行,除非显式传 `--force-checks`。
162
+ `--apply-repair` 会把 `postcheck.repairArtifacts.configPatch` 直接 merge 到 `--config` 指向的配置文件,并自动备份原文件。
163
+ `--confirm-repair` 会先打印将要修改的字段,再询问是否真正执行 `--apply-repair`;交互提示走 `stderr`,不会污染 `--json` 的机器输出。
164
+ `npm run wecom:migrate -- --json` 不再生成 starter config,只做当前安装 / 迁移状态盘点,适合排查 `legacy_config / mixed_layout / stale_package`。
165
+ `npm run wecom:migrate -- --json` 和 `npm run wecom:doctor -- --json` 现在还会给出 `migrationSource`,直接区分 `official-wecom / sunnoy-wecom / legacy-openclaw-wechat / mixed-source`。
166
+ `npm run wecom:doctor -- --json` 会把 `migration + selfcheck + agent/bot e2e + longconn probe + callback matrix` 聚合成一份报告;可以加 `--skip-network` 先只看本地安装 / 迁移问题。
167
+ `npm run wecom:doctor -- --fix --skip-network --json` 会先应用当前可落盘的本地 fix patch(例如 migration patch、`plugins.allow/entries`),再用修正后的配置重跑 doctor。
168
+ `npm run wecom:doctor -- --confirm-fix --skip-network --json` 会先预览将要修改的字段,再确认是否真正写回。
169
+ `npm run wecom:quickstart -- --json` 现在也会带 `sourcePlaybook`,把当前来源推荐的检查顺序、占位项提示和默认 repair 策略一起返回。
170
+ `npx -y @dingxiang-me/openclaw-wecom-cli install` 会先尝试执行 `openclaw plugins install @dingxiang-me/openclaw-wechat`,再写入 starter config,并可选继续跑本地 doctor。
171
+ `npm run test:e2e:local` 会黑盒验证 `install -> doctor -> fix -> rerun` 这条本地闭环,不依赖真实企微网络。
172
+ `npm run test:release` 会校验 root 包、installer CLI、manifest、运行时版本常量和 `npm pack --dry-run` 产物,适合作为发版前门禁。
173
+ 如果当前配置更像官方插件 / sunnoy / 旧版 OpenClaw-Wechat,安装器会在 `--json` 输出里直接给出 `migration.guide`、来源说明、legacy 字段路径和回滚命令。
174
+ 如果你想人工确认是否附带执行 `doctor --fix`,可以加 `--confirm-doctor-fix`;要强制不附带 `--fix`,可加 `--no-doctor-fix`,自动确认则用 `--yes`。
175
+ 安装器的 `--json` 现在还会直接输出 `actions`,把来源审阅、迁移 patch、回滚和重跑 doctor 这些步骤结构化暴露出来。
176
+ 如果你没有显式传 `--mode`,安装器还会按来源和现有能力自动选择 `bot_long_connection / agent_callback / hybrid`,并在 `sourceProfile` 里说明为什么这么选。
177
+ `sourceProfile` 现在还会给出来源专属 `checkOrder` 和 `repairDefaults`。例如官方 / legacy 来源默认允许自动附带 `doctor --fix`,而 sunnoy / mixed-source 来源默认只给修复建议,不会直接附带 `--fix`。
178
+ 仓库现在也自带两条 GitHub Actions 门禁:`Onboarding E2E` 跑本地安装闭环,`Release Check` 跑版本/打包一致性;tag 发布会走独立 release workflow,顺序发布插件包和 installer CLI。
179
+
180
+ `--json` 输出会额外给出:
181
+
182
+ - `placeholders`:还有哪些模板占位项没替换
183
+ - `setupChecklist`:下一步应该执行的管理台配置和自检命令
184
+ - `actions`:可被 CLI / UI 直接消费的结构化 setup flow
185
+ - `installState / migrationState`:当前是 fresh、legacy_config、stale_package、mixed_layout 还是 ready
186
+ - `migrationSource / migrationSourceSummary`:当前更接近官方插件、sunnoy 配置、legacy-openclaw-wechat,还是 mixed-source
187
+ - `fix`:doctor `--fix` 是否已提示、确认、落盘,以及真实 `changedPaths`
188
+ - `sourcePlaybook`:quickstart 基于当前来源生成的推荐检查顺序、占位提示和 repair 默认值
189
+ - `sourceProfile.checkOrder / sourceProfile.repairDefaults`:当前来源推荐的检查顺序,以及 installer 默认采用的修复策略
190
+ - `warnings`:当前 mode / group profile 下仍需确认的风险点
191
+ - `postcheck`:推荐 selfcheck 的执行结果、阻塞原因或汇总状态
192
+ - `postcheck.remediation`:把失败检查翻译成可执行的修复建议
193
+ - `postcheck.repairArtifacts`:自动生成最小 `configPatch` 和 `.env` 模板,便于直接修复当前检查暴露的问题
194
+ - `postcheck.repairPlan`:按项列出 repair patch 的配置变更、env 变更和会写出的文件
195
+ - `migration.configPatch / migration.envTemplate`:当前 legacy 配置可直接迁移到的新布局建议
196
+
197
+ 如果再加 `--repair-dir <path>`,quickstart 还会把这些修复产物直接落盘成:
198
+
199
+ - `wecom.config-patch.json`
200
+ - `wecom.account-patch.json`
201
+ - `wecom.env.template`
202
+ - `README.txt`
203
+
204
+ 如果加的是 `--apply-repair`,则会在输出中额外看到 `repairApply`,说明 repair patch 是否已实际写入目标配置。
205
+ 如果加的是 `--confirm-repair`,`repairApply` 里还会带 `prompted/confirmed`,方便区分“用户拒绝”与“自动执行”;真正写入的字段会出现在 `repairApply.changedPaths`。
72
206
 
73
207
  ## 5 分钟极速上手
74
208
 
@@ -76,11 +210,21 @@ OpenClaw-Wechat 是一个面向 OpenClaw 的企业微信渠道插件,支持两
76
210
 
77
211
  ### Step 1. 安装插件
78
212
 
213
+ 最快入口:
214
+
215
+ ```bash
216
+ npx -y @dingxiang-me/openclaw-wecom-cli install
217
+ ```
218
+
219
+ 它会复用仓库内的 quickstart / migrate / doctor 能力,把“安装插件 + 写 starter config + 跑本地体检”串成一次执行。
220
+
221
+ 如果你只想单独安装插件包:
222
+
79
223
  ```bash
80
224
  openclaw plugins install @dingxiang-me/openclaw-wechat
81
225
  ```
82
226
 
83
- > 最低建议版本:`2.1.0`。如果 `openclaw.json` 里的 `plugins.installs.openclaw-wechat` 仍显示 `1.7.x`,请先升级或重装;旧包不会正确注册 `wecom` channel 元数据。
227
+ > 最低建议版本:`2.3.0`。如果 `openclaw.json` 里的 `plugins.installs.openclaw-wechat` 仍显示 `1.7.x`,请先升级或重装;旧包不会正确注册 `wecom` channel 元数据,也不包含当前这套接入、迁移与可靠投递能力。
84
228
 
85
229
  如果你是在本地开发或要直接跑仓库源码,再用下面这套:
86
230
 
@@ -554,12 +698,13 @@ node ./scripts/wecom-bot-selfcheck.mjs --help
554
698
  | `webhookPath` | string | `/wecom/callback` | Agent 回调路径(非 default 账户未配置时自动生成 `/wecom/<accountId>/callback`) |
555
699
  | `agent` | object | - | 兼容旧配置:`agent.corpId/corpSecret/agentId`(与顶层 Agent 字段等价) |
556
700
  | `outboundProxy` | string | - | WeCom 出站代理 |
701
+ | `apiBaseUrl` | string | `https://qyapi.weixin.qq.com` | 可选:覆盖默认 WeCom API Base URL |
557
702
  | `defaultAccount` | string | - | 多账号下的默认账号 ID(文档工具等优先使用) |
558
703
  | `tools.doc` | boolean | `true` | 是否启用 `wecom_doc` 文档工具 |
559
704
  | `webhooks` | object | - | 命名 Webhook 目标映射(如 `{ "ops": "https://...key=xxx" }`) |
560
705
  | `accounts` | object | - | 多账户配置(支持 `accounts.<id>.bot` 独立 Bot 配置) |
561
706
 
562
- 兼容说明:支持旧字段与旧结构迁移:`name`、`token` / `encodingAesKey`、`agent.*`、`dynamicAgents.*`、`dm.createAgentOnFirstMessage`、`dm.allowFrom`、`workspaceTemplate`、`commandAllowlist/commandBlockMessage`、`commands.blockMessage`、以及 inline 账户写法 `channels.wecom.<accountId>`。新配置建议优先使用 `accounts.<id>`、`callbackToken/callbackAesKey`、`commands.*` 与 `dynamicAgent.*`。
707
+ 兼容说明:支持旧字段与旧结构迁移:`name`、`token` / `encodingAesKey`、`agent.*`、`dynamicAgents.*`、`dm.createAgentOnFirstMessage`、`dm.allowFrom`、`workspaceTemplate`、`commandAllowlist/commandBlockMessage`、`commands.blockMessage`、inline 账户写法 `channels.wecom.<accountId>`,以及官方 / sunnoy 风格的 `botId`、`secret`、`network.egressProxyUrl`、`network.apiBaseUrl`。新配置建议优先使用 `accounts.<id>`、`callbackToken/callbackAesKey`、`bot.longConnection.*`、`outboundProxy/apiBaseUrl`、`commands.*` 与 `dynamicAgent.*`。
563
708
 
564
709
  提示:`accounts.<id>` 现在支持 Bot-only 账号(仅配置 `bot.*`),不再强制要求 `corpId/corpSecret/agentId`。
565
710
  兼容提示:当使用默认新路径时会自动附加 legacy alias,便于旧回调地址平滑迁移:Agent 默认路径会附加 `/webhooks/app`(多账号为 `/webhooks/app/<id>`),Bot 默认路径会附加 `/webhooks/wecom`(多账号为 `/webhooks/wecom/<id>`)。若 alias 与另一类路由冲突会自动跳过并告警。
@@ -633,6 +778,8 @@ node ./scripts/wecom-bot-selfcheck.mjs --help
633
778
  | `longConnection` | object | - | 该账户专用长连接配置(覆盖全局 `bot.longConnection`) |
634
779
  | `card` | object | - | 该账户专用卡片回包配置(覆盖全局 `bot.card`) |
635
780
 
781
+ 兼容提示:如果你是从官方插件或 sunnoy 配置直接迁移,也可以先保留 `channels.wecom.botId/secret` 或 `accounts.<id>.botId/secret`,以及 `network.egressProxyUrl/apiBaseUrl`;插件会在运行时兼容读取,`npm run wecom:migrate -- --json` 会给出归一化 patch。
782
+
636
783
  ### 多账户文档工具覆盖(`channels.wecom.accounts.<id>.tools`)
637
784
 
638
785
  | 键 | 类型 | 默认 | 说明 |
@@ -651,6 +798,8 @@ node ./scripts/wecom-bot-selfcheck.mjs --help
651
798
  | 私聊策略 | `dm.mode` + `dm.allowFrom` + `dm.rejectMessage` | 控制私聊开放/白名单/配对审批/拒绝 |
652
799
  | 事件策略 | `events.enabled` + `events.enterAgentWelcomeEnabled` + `events.enterAgentWelcomeText` | 控制事件处理与 enter_agent 欢迎语 |
653
800
  | 群聊触发 | `groupChat.enabled` + `triggerMode` + `mentionPatterns` + `triggerKeywords` | 控制群消息触发条件(自建应用支持 `direct/mention/keyword`;Bot 模式按平台限制固定 `mention`) |
801
+ | 群聊准入策略 | `groupPolicy` + `groupChat.policy` + `groups.<chatId>.policy` | 显式控制 `open / allowlist / deny`;支持账户级覆盖与按群覆盖 |
802
+ | 群聊成员授权 | `groupAllowFrom` + `groups.<chatId>.allowFrom` | 与 `allowlist` 搭配使用,控制哪些群成员可以触发机器人;支持账户级覆盖与按群覆盖 |
654
803
  | 动态路由 | `dynamicAgent.*`(兼容 `dynamicAgents.*`、`dm.createAgentOnFirstMessage`) | 动态 Agent + workspace bootstrap 播种 |
655
804
 
656
805
  ### 吞吐与稳定性
@@ -660,6 +809,9 @@ node ./scripts/wecom-bot-selfcheck.mjs --help
660
809
  | 文本防抖 | `debounce.enabled/windowMs/maxBatch` | 合并短时间多条文本 |
661
810
  | Agent 增量回包 | `streaming.enabled/minChars/minIntervalMs` | 多消息模拟流式 |
662
811
  | 异步补发 | `WECOM_LATE_REPLY_WATCH_MS/POLL_MS` | dispatch 超时后补发最终回复 |
812
+ | Pending Reply 持久化 | `delivery.pendingReply.persist/storeFile` | 重启后恢复未送达最终回复;未指定 `storeFile` 时自动写入 OpenClaw state 目录 |
813
+ | 推理展示 | `delivery.reasoning.mode/title/maxChars` | 控制 `<think>` / reasoning 分离显示、附加到最终回复,或完全隐藏 |
814
+ | 最终回复格式 | `delivery.replyFormat` | `auto / text / markdown`;优先在支持的 WeCom 链路上保留 markdown,其余链路自动回退纯文本 |
663
815
  | 观测统计 | `observability.enabled/logPayloadMeta` | 记录入站/回包/错误并在 `/status` 展示 |
664
816
 
665
817
  ### 语音转写(本地)
@@ -1223,6 +1375,7 @@ npm run wecom:bot:selfcheck -- --all-accounts
1223
1375
  {
1224
1376
  "channels": {
1225
1377
  "wecom": {
1378
+ "groupPolicy": "open",
1226
1379
  "groupChat": {
1227
1380
  "enabled": true,
1228
1381
  "triggerMode": "direct"
@@ -1232,6 +1385,38 @@ npm run wecom:bot:selfcheck -- --all-accounts
1232
1385
  }
1233
1386
  ```
1234
1387
 
1388
+ 如果还要限制“只有指定群成员能触发”,可以再加一层群聊成员授权:
1389
+
1390
+ ```json
1391
+ {
1392
+ "channels": {
1393
+ "wecom": {
1394
+ "groupPolicy": "allowlist",
1395
+ "groupAllowFrom": ["alice", "bob"],
1396
+ "groups": {
1397
+ "wr9N1x...": {
1398
+ "policy": "allowlist",
1399
+ "allowFrom": ["ops_lead"],
1400
+ "rejectMessage": "当前群仅限值班同学触发。"
1401
+ }
1402
+ }
1403
+ }
1404
+ }
1405
+ }
1406
+ ```
1407
+
1408
+ 如果你要“一刀切关闭群聊处理”,直接用:
1409
+
1410
+ ```json
1411
+ {
1412
+ "channels": {
1413
+ "wecom": {
1414
+ "groupPolicy": "deny"
1415
+ }
1416
+ }
1417
+ }
1418
+ ```
1419
+
1235
1420
  同时确认企业微信侧前提:
1236
1421
  1. 自建应用已开启“接收消息”并完成 URL 验证
1237
1422
  2. 应用可见范围包含该群成员