@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
@@ -51,6 +51,128 @@ npm run wecom:bot:longconn:probe -- --json
51
51
  - Bot timeout tuning: supported (`channels.wecom.bot.replyTimeoutMs`, `lateReplyWatchMs`, `lateReplyPollMs`)
52
52
  - Observability counters: supported (`channels.wecom.observability.*`, visible in `/status`)
53
53
 
54
+ ## Quickstart Modes
55
+
56
+ The channel metadata now exposes three machine-readable onboarding modes for installer / quickstart / doctor flows and future integrations:
57
+
58
+ 1. `bot_long_connection`
59
+ - Recommended default
60
+ - No public webhook required
61
+ - Best for the fastest first reply loop
62
+ 2. `agent_callback`
63
+ - Requires a stable public callback URL
64
+ - Best when you need proactive send, app menu, and Agent API capabilities
65
+ 3. `hybrid`
66
+ - Bot long connection for conversation
67
+ - Agent callback for proactive send and app capabilities
68
+
69
+ Runtime helper:
70
+
71
+ ```js
72
+ plugin.quickstart.listModes()
73
+ plugin.quickstart.listGroupProfiles()
74
+ plugin.quickstart.buildSetupPlan({ mode: "hybrid", groupProfile: "allowlist_template" })
75
+ plugin.quickstart.buildStarterConfig({ mode: "bot_long_connection", groupProfile: "mention_only" })
76
+ ```
77
+
78
+ CLI helper:
79
+
80
+ ```bash
81
+ npx -y @dingxiang-me/openclaw-wecom-cli install
82
+ npm run wecom:quickstart -- --mode bot_long_connection
83
+ npm run wecom:doctor -- --json
84
+ npm run wecom:quickstart -- --wizard
85
+ npm run wecom:quickstart -- --run-checks
86
+ npm run wecom:quickstart -- --run-checks --repair-dir ./.wecom-repair
87
+ npm run wecom:quickstart -- --run-checks --apply-repair
88
+ npm run wecom:quickstart -- --run-checks --confirm-repair
89
+ npm run wecom:migrate -- --json
90
+ npm run wecom:doctor -- --json
91
+ npm run wecom:doctor -- --fix --skip-network --json
92
+ npm run wecom:doctor -- --confirm-fix --skip-network --json
93
+ npm run test:e2e:local
94
+ npm run test:release
95
+ npm run wecom:quickstart -- --mode hybrid --group-profile allowlist_template --group-chat-id wr-ops-room --group-allow ops_lead,oncall_user
96
+ npm run wecom:quickstart -- --mode hybrid --write
97
+ openclaw channels add --channel wecom --use-env
98
+ ```
99
+
100
+ `npx -y @dingxiang-me/openclaw-wecom-cli install` 会先尝试执行 `openclaw plugins install @dingxiang-me/openclaw-wechat`,然后写入 starter config,并可选继续跑本地 doctor。
101
+ `npm run wecom:quickstart` 和 `npm run wecom:doctor` 是仓库内的主推荐路径,默认文档、排障和迁移说明都围绕这两条命令展开。
102
+ `openclaw channels add --channel wecom --use-env` 现在也能走通,但它是高级兼容路径,只适合 env-backed 初始化:先把 `WECOM_*` / `WECOM_BOT_*` 环境变量准备好,再让插件暴露的 `setup.applyAccountConfig` 把它们落进 `openclaw.json`。这条路径不需要任何 OpenClaw core 补丁。
103
+ 如果安装器识别到官方 / sunnoy / legacy-openclaw-wechat 风格来源,`--json` 里会直接带出 `migration.guide`、legacy 字段路径和回滚命令。
104
+ 要在安装流里手工确认是否附带 `doctor --fix`,可加 `--confirm-doctor-fix`;若明确不希望附带修复,使用 `--no-doctor-fix`。
105
+ 同一份 `--json` 结果还会带 `actions`,方便把来源审阅、迁移、回滚和重跑体检串成更完整的安装向导。
106
+ 如果没显式传 `--mode`,安装器会结合来源和现有能力自动选 `bot_long_connection / agent_callback / hybrid`,并把决策原因写进 `sourceProfile`。
107
+ `sourceProfile` 现在还会带来源专属 `checkOrder` 和 `repairDefaults`。官方 / legacy 来源默认允许自动附带 `doctor --fix`,sunnoy / mixed-source 默认先保守输出修复建议。
108
+
109
+ 如果你只想使用仓库内脚本:
110
+
111
+ ```bash
112
+ npm run wecom:quickstart -- --mode bot_long_connection
113
+ npm run wecom:quickstart -- --wizard
114
+ npm run wecom:quickstart -- --run-checks
115
+ npm run wecom:quickstart -- --run-checks --repair-dir ./.wecom-repair
116
+ npm run wecom:quickstart -- --run-checks --apply-repair
117
+ npm run wecom:quickstart -- --run-checks --confirm-repair
118
+ npm run wecom:migrate -- --json
119
+ npm run wecom:doctor -- --json
120
+ npm run wecom:quickstart -- --mode hybrid --group-profile allowlist_template --group-chat-id wr-ops-room --group-allow ops_lead,oncall_user
121
+ npm run wecom:quickstart -- --mode hybrid --write
122
+ ```
123
+
124
+ `buildSetupPlan()` / `--json` 会一起返回:
125
+
126
+ - `placeholders`
127
+ - `setupChecklist`
128
+ - `actions`
129
+ - `installState / migrationState`
130
+ - `migrationSource / migrationSourceSummary`
131
+ - `sourcePlaybook`
132
+ - `fix`
133
+ - `warnings`
134
+ - `postcheck.remediation`
135
+ - `postcheck.repairArtifacts`
136
+ - `postcheck.repairPlan`
137
+ - `migration.configPatch / migration.envTemplate`
138
+
139
+ `--wizard` 会把现有 CLI 参数当默认值逐步提问,并在结束时确认是否写入配置文件。
140
+ `--run-checks` 会执行当前 mode 推荐的 selfcheck;如模板仍有占位项,默认会阻止执行,除非加 `--force-checks`。
141
+ `--repair-dir` 会把 `postcheck.repairArtifacts` 直接写成补配置用的文件。
142
+ `--apply-repair` 会把 `postcheck.repairArtifacts.configPatch` 直接 merge 到目标配置文件,并自动备份原文件。
143
+ `--confirm-repair` 会先展示将要修改的字段,再确认是否真正应用 repair patch。
144
+ `npm run wecom:migrate -- --json` 只盘点当前安装状态和 legacy 布局,不生成 starter config;同时会输出 `migrationSource`,区分 `official-wecom / sunnoy-wecom / legacy-openclaw-wechat / mixed-source`。
145
+ `npm run wecom:doctor -- --json` 会把 migration、自检、Agent/Bot E2E、长连接探针和公网回调矩阵收口成一份统一报告;如果你只想先看本地安装 / 迁移问题,可以加 `--skip-network`。
146
+ `npm run wecom:doctor -- --fix --skip-network --json` 会先应用本地可落盘的 fix patch,再在修正后的配置上重跑 doctor。
147
+ `npm run wecom:doctor -- --confirm-fix --skip-network --json` 会先预览将要修改的字段,再确认是否真正写回。
148
+ `npm run wecom:quickstart -- --json` 现在也会返回 `sourcePlaybook`,把当前来源推荐的检查顺序、占位项提示和默认 repair 策略一起输出。
149
+ `npm run test:e2e:local` 会黑盒验证本地 `install -> doctor -> fix -> rerun` 闭环。
150
+ `npm run test:release` 会校验插件包、installer CLI、manifest、版本常量和 `npm pack --dry-run` 产物。
151
+ 仓库 CI 现在会把这两条链单独作为 `Onboarding E2E` 和 `Release Check` 门禁;tag 发布则走独立 release workflow,顺序发布两个 npm 包。
152
+
153
+ Default recommended starter:
154
+
155
+ ```json
156
+ {
157
+ "channels": {
158
+ "wecom": {
159
+ "enabled": true,
160
+ "dm": {
161
+ "mode": "pairing"
162
+ },
163
+ "bot": {
164
+ "enabled": true,
165
+ "longConnection": {
166
+ "enabled": true,
167
+ "botId": "your-bot-id",
168
+ "secret": "your-bot-secret"
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }
174
+ ```
175
+
54
176
  ## Callback URL
55
177
 
56
178
  Recommended for Agent / Bot webhook mode:
@@ -211,7 +333,7 @@ WeCom has two different integration shapes:
211
333
 
212
334
  To enable direct group trigger (`triggerMode=direct`) for self-built app callback, ensure:
213
335
 
214
- 1. Plugin config uses `channels.wecom.groupChat.enabled=true` and `triggerMode=direct`.
336
+ 1. Plugin config uses `channels.wecom.groupPolicy=open` (or leaves it unset) and `groupChat.enabled=true` with `triggerMode=direct`.
215
337
  2. WeCom app callback is enabled and URL verification succeeded.
216
338
  3. App visibility scope includes members in that group context.
217
339
  4. Runtime logs show `chatId=...` for inbound messages.
@@ -221,8 +343,21 @@ In that case, use **Webhook Bot mode** for regular group chat scenarios.
221
343
 
222
344
  Note: In Bot mode, `groupChat.triggerMode=direct/keyword` is normalized to `mention` by the plugin to avoid misleading config.
223
345
 
346
+ If you want explicit group ACL behavior instead of implicit `allowFrom` inference:
347
+
348
+ - Use `groupPolicy=open` to allow all group members.
349
+ - Use `groupPolicy=allowlist` together with `groupAllowFrom` or `groups.<chatId>.allowFrom`.
350
+ - Use `groupPolicy=deny` to disable group handling entirely.
351
+
224
352
  ## Selfcheck
225
353
 
354
+ The selfcheck summaries now also print a `group-policy` line. It shows:
355
+
356
+ - the effective mode (`open / allowlist / deny`)
357
+ - the effective trigger mode
358
+ - whether the configured group member allowlist is active or currently ignored by `groupPolicy=open`
359
+ - where the rule came from (account override, global default, or env)
360
+
226
361
  Run:
227
362
 
228
363
  ```bash
@@ -252,6 +387,7 @@ Thinking mode:
252
387
 
253
388
  - Bot replies now recognize `<think>...</think>` / `<thinking>...</thinking>` / `<thought>...</thought>` and send the reasoning via native `thinking_content`.
254
389
  - Think tags inside fenced code blocks and inline code are ignored.
390
+ - Final replies now support `MEDIA:` / `FILE:` directives. Directive lines are stripped from visible text, and matching workspace/URL targets are sent as media attachments.
255
391
 
256
392
  Remote matrix E2E (against public callback URLs):
257
393