@dingxiang-me/openclaw-wechat 2.0.1 → 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 (79) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.en.md +204 -32
  3. package/README.md +234 -63
  4. package/docs/channels/wecom.md +137 -1
  5. package/openclaw.plugin.json +694 -10
  6. package/package.json +207 -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 +631 -34
  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 +63 -16
  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 +25 -1
  40. package/src/wecom/bot-inbound-guards.js +78 -23
  41. package/src/wecom/bot-long-connection-manager.js +4 -4
  42. package/src/wecom/channel-config-schema.js +132 -0
  43. package/src/wecom/channel-plugin.js +370 -7
  44. package/src/wecom/command-handlers.js +107 -10
  45. package/src/wecom/command-status-text.js +275 -1
  46. package/src/wecom/doc-client.js +7 -1
  47. package/src/wecom/inbound-content-handler-file-video-link.js +4 -0
  48. package/src/wecom/inbound-content-handler-image-voice.js +6 -0
  49. package/src/wecom/inbound-content.js +5 -0
  50. package/src/wecom/installer-api.js +910 -0
  51. package/src/wecom/media-download.js +2 -2
  52. package/src/wecom/migration-diagnostics.js +816 -0
  53. package/src/wecom/network-config.js +91 -0
  54. package/src/wecom/observability-metrics.js +9 -3
  55. package/src/wecom/outbound-agent-delivery.js +313 -0
  56. package/src/wecom/outbound-agent-media-sender.js +37 -7
  57. package/src/wecom/outbound-agent-push.js +1 -0
  58. package/src/wecom/outbound-delivery.js +129 -12
  59. package/src/wecom/outbound-stream-msg-item.js +25 -2
  60. package/src/wecom/outbound-webhook-delivery.js +19 -0
  61. package/src/wecom/outbound-webhook-media.js +30 -6
  62. package/src/wecom/pairing.js +188 -0
  63. package/src/wecom/pending-reply-manager.js +143 -0
  64. package/src/wecom/plugin-account-policy-services.js +26 -0
  65. package/src/wecom/plugin-base-services.js +58 -0
  66. package/src/wecom/plugin-constants.js +1 -1
  67. package/src/wecom/plugin-delivery-inbound-services.js +25 -0
  68. package/src/wecom/plugin-processing-deps.js +7 -0
  69. package/src/wecom/plugin-route-runtime-deps.js +1 -0
  70. package/src/wecom/plugin-services.js +87 -0
  71. package/src/wecom/policy-resolvers.js +93 -20
  72. package/src/wecom/quickstart-metadata.js +1247 -0
  73. package/src/wecom/reasoning-visibility.js +104 -0
  74. package/src/wecom/register-runtime.js +10 -0
  75. package/src/wecom/reliable-delivery-persistence.js +138 -0
  76. package/src/wecom/reliable-delivery.js +642 -0
  77. package/src/wecom/reply-output-policy.js +171 -0
  78. package/src/wecom/text-inbound-scheduler.js +6 -1
  79. package/src/wecom/workspace-auto-sender.js +2 -0
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
5
+ cd "$ROOT_DIR"
6
+
7
+ WITH_BOT_E2E=false
8
+ SELF_CHECK_ARGS=()
9
+
10
+ print_help() {
11
+ cat <<'EOF'
12
+ OpenClaw-Wechat smoke check
13
+
14
+ Usage:
15
+ npm run wecom:smoke -- [options]
16
+
17
+ Options:
18
+ --with-bot-e2e Also run Bot E2E selfcheck (signature/encryption/stream-refresh)
19
+ -h, --help Show this help
20
+
21
+ Other options are forwarded to:
22
+ npm run wecom:selfcheck -- --all-accounts ...
23
+ EOF
24
+ }
25
+
26
+ while [[ $# -gt 0 ]]; do
27
+ case "$1" in
28
+ --with-bot-e2e)
29
+ WITH_BOT_E2E=true
30
+ shift
31
+ ;;
32
+ -h|--help)
33
+ print_help
34
+ exit 0
35
+ ;;
36
+ *)
37
+ SELF_CHECK_ARGS+=("$1")
38
+ shift
39
+ ;;
40
+ esac
41
+ done
42
+
43
+ TOTAL_STEPS=5
44
+ if [[ "$WITH_BOT_E2E" == "true" ]]; then
45
+ TOTAL_STEPS=6
46
+ fi
47
+ STEP=1
48
+
49
+ echo "[$STEP/$TOTAL_STEPS] Syntax check"
50
+ npm run test:syntax
51
+ STEP=$((STEP + 1))
52
+
53
+ echo "[$STEP/$TOTAL_STEPS] Unit tests"
54
+ npm test
55
+ STEP=$((STEP + 1))
56
+
57
+ echo "[$STEP/$TOTAL_STEPS] WeCom selfcheck (all discovered accounts)"
58
+ npm run wecom:selfcheck -- --all-accounts "${SELF_CHECK_ARGS[@]}"
59
+ STEP=$((STEP + 1))
60
+
61
+ if [[ "$WITH_BOT_E2E" == "true" ]]; then
62
+ echo "[$STEP/$TOTAL_STEPS] WeCom Bot E2E selfcheck"
63
+ npm run wecom:bot:selfcheck --
64
+ STEP=$((STEP + 1))
65
+ fi
66
+
67
+ echo "[$STEP/$TOTAL_STEPS] Gateway health"
68
+ openclaw gateway health
69
+ STEP=$((STEP + 1))
70
+
71
+ echo "[$STEP/$TOTAL_STEPS] OpenClaw status (summary)"
72
+ openclaw status --all | sed -n '1,120p'
73
+
74
+ echo "Smoke check completed."
@@ -1,3 +1,5 @@
1
+ import { inferWecomDeliveryStatus, normalizeWecomDeliveryStatus } from "../wecom/reliable-delivery.js";
2
+
1
3
  const DEFAULT_FALLBACK_ORDER = Object.freeze([
2
4
  "long_connection",
3
5
  "active_stream",
@@ -124,6 +126,7 @@ export function createWecomDeliveryRouter({
124
126
  layer,
125
127
  ok: true,
126
128
  status: "ok",
129
+ deliveryStatus: "delivered",
127
130
  meta: result?.meta ?? {},
128
131
  durationMs: Math.max(0, layerEndedAt - layerStartedAt),
129
132
  startedAt: layerStartedAt,
@@ -141,6 +144,7 @@ export function createWecomDeliveryRouter({
141
144
  layer,
142
145
  deliveryPath: layer,
143
146
  finalStatus: attempts.length > 1 ? "degraded" : "ok",
147
+ deliveryStatus: "delivered",
144
148
  attempts,
145
149
  totalDurationMs: Math.max(0, layerEndedAt - deliverStartedAt),
146
150
  };
@@ -150,6 +154,14 @@ export function createWecomDeliveryRouter({
150
154
  ok: false,
151
155
  status: "miss",
152
156
  reason: String(result?.reason ?? "rejected"),
157
+ deliveryStatus:
158
+ normalizeWecomDeliveryStatus(result?.deliveryStatus, "") ||
159
+ inferWecomDeliveryStatus({
160
+ reason: String(result?.reason ?? "rejected"),
161
+ layer,
162
+ meta: result?.meta ?? {},
163
+ errcode: result?.meta?.errcode ?? result?.errcode ?? null,
164
+ }),
153
165
  meta: result?.meta ?? {},
154
166
  durationMs: Math.max(0, layerEndedAt - layerStartedAt),
155
167
  startedAt: layerStartedAt,
@@ -168,6 +180,10 @@ export function createWecomDeliveryRouter({
168
180
  ok: false,
169
181
  status: "error",
170
182
  reason: safeErrorMessage(err),
183
+ deliveryStatus: inferWecomDeliveryStatus({
184
+ reason: safeErrorMessage(err),
185
+ layer,
186
+ }),
171
187
  durationMs: Math.max(0, layerEndedAt - layerStartedAt),
172
188
  startedAt: layerStartedAt,
173
189
  endedAt: layerEndedAt,
@@ -191,6 +207,11 @@ export function createWecomDeliveryRouter({
191
207
  layer: null,
192
208
  deliveryPath: null,
193
209
  finalStatus: "failed",
210
+ deliveryStatus:
211
+ attempts
212
+ .slice()
213
+ .reverse()
214
+ .find((attempt) => attempt?.deliveryStatus)?.deliveryStatus || "rejected_unknown",
194
215
  attempts,
195
216
  error: "all-layers-failed",
196
217
  totalDurationMs: Math.max(0, Date.now() - deliverStartedAt),