openclaw-weixin 2.4.6 → 3.0.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.
@@ -0,0 +1,199 @@
1
+ # Changelog
2
+
3
+ [简体中文](CHANGELOG.md)
4
+
5
+ This project follows the [Keep a Changelog](https://keepachangelog.com/) format.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [3.0.0] - 2026-07-31
10
+
11
+ ### Added
12
+
13
+ - Exec approval prompts now expose separate copy-friendly `/approve` code blocks:
14
+ forwarded prompts append each allowed short-ID action, while direct prompts
15
+ split each command under `Other options` into its own block.
16
+
17
+ ### Changed
18
+
19
+ - Set the community package and plugin version to `3.0.0` for the first release
20
+ after consolidating on the single `openclaw-weixin` identity.
21
+ - Standardized the repository, npm package, plugin, and channel name on
22
+ `openclaw-weixin`, and simplified releases to publish one package.
23
+ - Standardized the MIT license text and packaged an informational `NOTICE`
24
+ preserving Tencent's upstream attribution and the community modification
25
+ notice.
26
+ - Added a release metadata gate and idempotent release reconciliation after
27
+ successful `main` CI, with immutable transition-commit tagging and ordered npm
28
+ publication.
29
+ - Made Chinese the primary README and moved the English version to
30
+ `README_EN.md`, while retaining `README.zh_CN.md` as a compatibility link.
31
+ - Raised the minimum supported OpenClaw host to `2026.7.1` and aligned the
32
+ runtime guard, package metadata, development environment, and CI Node.js
33
+ floors with that release.
34
+ - Unified plugin installation and in-place Tencent-package replacement around
35
+ one `--force` command, with separate account setup, reload verification, and
36
+ agent guidance; moved detailed usage and protocol reference into the packaged
37
+ `docs/` directory.
38
+
39
+ ### Security
40
+
41
+ - Overrode vulnerable transitive development dependencies with patched versions
42
+ and added a moderate-or-higher dependency audit gate to CI and npm releases.
43
+
44
+ ## [2.4.6] - 2026-07-23
45
+
46
+ ### Changed
47
+
48
+ - Prepared the first community-maintained npm distribution as the unscoped
49
+ `openclaw-weixin` package, derived from Tencent's
50
+ `@tencent-weixin/openclaw-weixin`.
51
+ - Preserved the internal `openclaw-weixin` plugin/channel id, configuration
52
+ keys, and state paths for in-place migration.
53
+ - Added community repository metadata, package-content checks, and an
54
+ npm Trusted Publishing workflow.
55
+ - Aligned the runtime compatibility guard and documentation with OpenClaw
56
+ `>=2026.5.12` and Node.js `>=22`.
57
+
58
+ ## [2.4.5] - 2026-06-22
59
+
60
+ ### Added
61
+
62
+ - **`classifyFetchError` — network error classification:** New `classifyFetchError` utility in `src/api/api.ts` classifies fetch-level errors into `dns` / `tcp` / `tls` / `timeout` / `unknown`. `apiGetFetch` and `apiPostFetch` now log structured error details (type, description, code) on failure, making network troubleshooting significantly easier. Includes full test coverage for ENOTFOUND, ECONNREFUSED, ETIMEDOUT, SSL/TLS, AbortError, and more.
63
+ - **`sendMessage` response validation:** `sendMessage` now parses the server response (`SendMessageResp` with `ret` / `errmsg`) and throws on non-zero `ret`, preventing silent delivery failures.
64
+
65
+ ### Changed
66
+
67
+ - **`SESSION_EXPIRED_ERRCODE` → `STALE_TOKEN_ERRCODE`:** Renamed in `src/api/session-guard.ts` to more accurately describe the token-stale condition (the error code -14 indicates a stale/expired token, not a session expiry). All references in `monitor.ts` and tests updated.
68
+ - **Error logging improvements:**
69
+ - `getUpdates` errors in `monitor.ts` now include `classifyFetchError` classification (type, description, code).
70
+ - Removed duplicate `errLog` lines in `monitor.ts`; only `aLog.error` remains.
71
+ - CDN upload failure logs (`cdn-upload.ts`) now include redacted URL and error cause.
72
+ - `downloadRemoteImageToTemp` (`upload.ts`) now logs detailed fetch network errors with cause.
73
+ - API GET/POST fetch failures (`api.ts`) now log redacted URL, timeout, and error classification.
74
+ - **Minimum host version bumped:** `peerDependencies.openclaw` and `install.minHostVersion` raised from `>=2026.3.22` to `>=2026.5.12`.
75
+
76
+ ### Added (Dev/Engineering)
77
+
78
+ - **`outbound-hooks.test.ts`:** New test file covering `applyWeixinMessageSendingHook` (no hooks, content modification, cancellation, error recovery) and `emitWeixinMessageSent` (no hooks, success, failure with fire-and-forget) scenarios.
79
+
80
+ ### Fixed
81
+
82
+ - **`pairing.test.ts` mock path:** `vi.mock` target corrected from `"openclaw/plugin-sdk"` to `"openclaw/plugin-sdk/infra-runtime"`.
83
+ - **`api.test.ts` sendMessage mock response:** Success test case mock now returns `"{}"` instead of `""`, matching the updated `sendMessage` logic that parses the response body.
84
+
85
+ ## [2.4.4] - 2026-05-22
86
+
87
+ ### Added
88
+
89
+ - **Tool-call progress messages:** `WeixinReplyProgressSender` sends `TOOL_CALL_START` / `TOOL_CALL_RESULT` progress messages when the model executes tools. Configurable via the `replyProgressMessages` channel option (default: `true`).
90
+ - **Abort signal support for in-flight requests:** `apiPostFetch` / `getUpdates` now accept an external `AbortSignal`. When the gateway stops or hot-reloads a channel, the in-flight long-poll is cancelled immediately instead of waiting for the server-side timeout.
91
+
92
+ ## [2.4.3] - 2026-05-08
93
+
94
+ ### Fixed
95
+
96
+ - **`iLink-App-Id` / `iLink-App-ClientVersion` headers were empty / `0` in production.** `readPackageJson` resolved `package.json` via a fixed `../../` from `import.meta.url`, but the TypeScript build (with `index.ts` plus `src/**/*.ts` in `tsconfig.include`) emits `dist/src/api/api.js` (extra `src/` segment), so the resolved path landed on the non-existent `dist/package.json` and the catch returned `{}`. Replaced with a walk-up that searches for the plugin's own `package.json` (validated by `name` containing `openclaw-weixin` or by the presence of `ilink_appid`), tolerating both dev (`src/api/`) and built (`dist/src/api/`) layouts. Adds tests in `src/api/api.test.ts` covering the compiled layout, dev layout, nested `node_modules/<dep>/package.json` shadowing, missing manifest, and malformed manifest.
97
+ - **`openclaw channels login` exited non-zero when the bot was already bound to this OpenClaw**, which caused automated installers (e.g. `openclaw-weixin-installer`) to report a misleading "首次连接未完成" message and continue past a successful state. The QR poller now returns `alreadyConnected: true` for the server's `binded_redirect` status, and `auth.login` in `channel.ts` treats it as a successful no-op (no save, no throw) so the CLI exits cleanly.
98
+
99
+ ## [2.4.2] - 2026-05-07
100
+
101
+ ### Fixed
102
+
103
+ - **Node 24 / undici compatibility — `TypeError: fetch failed` on every request.** Drop the manually-set `Content-Length` header from `buildHeaders`. The bundled undici in Node 24 rejects pre-set `Content-Length` with `UND_ERR_INVALID_ARG: invalid content-length header`, breaking all CGI calls. Letting `fetch` compute it from the request body restores network calls on Node 24.
104
+ - **OpenClaw ≥ 2026.5.x — Weixin runtime initialization timeout restart loop.** Replace the module-scope `pluginRuntime` global (and remove `src/runtime.ts` along with it) with the `ctx.channelRuntime` injected by the gateway per call. The previous global was set during plugin registration, but newer hosts inject a per-call runtime surface, so the global was missing/stale at startup and the channel kept timing out and restarting.
105
+
106
+ ### Removed
107
+
108
+ - **Dead scripts and shims:** `scripts/test-full-upload.ts` / `scripts/test-upload-url.ts` debug scripts and the unused legacy `index.ts` re-exports. No behavior change for consumers.
109
+
110
+ ## [2.4.1] - 2026-05-04
111
+
112
+ ### Added
113
+
114
+ - **Ship compiled runtime in the npm tarball:** `dist/` is added to `files` and `package.json#openclaw.runtimeExtensions` is set to `["./dist/index.js"]`. The host loads the prebuilt JS entry directly instead of relying on source-only TypeScript at install time, which avoids the `requires compiled runtime output for TypeScript entry index.ts` error on stricter host versions.
115
+ - **`openclaw.plugin.json` channel config:** Declare `channels` and `channelConfigs` in `openclaw.plugin.json` so newer hosts (≥ 2026.4.x) can render the channel selection UI without falling back to `package.json#openclaw`.
116
+
117
+ ## [2.3.1] - 2026-04-28
118
+
119
+ ### Added
120
+
121
+ - **`bot_agent` request field:** Outgoing CGI requests now carry an upstream-app-supplied `bot_agent` (UA-style `name/version (comment)` grammar, multi-product allowed). Configurable per upstream app via channel config and sanitized by `sanitizeBotAgent` in `src/api/api.ts`; falls back to `OpenClaw` when missing or invalid.
122
+ - **`local_token_list` on QR fetch:** `fetchQRCode` now posts the most recent local `bot_token`s (up to 10), enabling the server to recognize already-bound bots and reply with `binded_redirect` instead of issuing a duplicate session.
123
+ - **Pair-code login flow:** Support entering a pair-code (`verify_code`) when the QR scan triggers a server-side challenge; `waitForWeixinLogin` handles `need_verifycode` / `verify_code_blocked` states with a stdin prompt and bounded retries.
124
+ - **`binded_redirect` handling:** New status branch in QR polling that prints `✅ 已连接过此 OpenClaw,无需重复连接。` and returns gracefully when the scanned bot is already bound to this OpenClaw.
125
+ - **Connection status notify (start/stop):** Emit `notifyStart` from `gateway.startAccount` (after the provider is announced) and `notifyStop` from a new `gateway.stopAccount` hook, so the upstream Weixin server can reconcile per-account online state.
126
+
127
+ ### Changed
128
+
129
+ - **QR login UX:** Reword the QR/scan prompts and remove the client-side timeout from `fetchQRCode` / `startWeixinLoginWithQr` — only server / stack limits now bound the long-poll.
130
+
131
+ ## [2.1.10] - 2026-04-24
132
+
133
+ ### Added
134
+
135
+ - **Connection status notify (start/stop) — initial introduction:** `notifyStart` on account startup and `notifyStop` on shutdown via the new `gateway.stopAccount` hook. (Carried into the 2.3.x line as well.)
136
+
137
+ ## [2.1.9] - 2026-04-20
138
+
139
+ ### Added
140
+
141
+ - **Outbound hook support:** Add `message_sending` (pre-send interception/modification) and `message_sent` (post-send notification) hook integration for all outbound paths — `sendText`, `sendMedia`, and the inbound-reply `deliver` in `process-message`. Hook logic is extracted into a shared `src/messaging/outbound-hooks.ts` module.
142
+
143
+ ### Changed
144
+
145
+ - **Cleanup:** Remove unused `mediaUrl` parameter from `sendWeixinOutbound` signature.
146
+
147
+ ## [2.1.8] - 2026-04-07
148
+
149
+ ### Changed
150
+
151
+ - **Markdown filter:** `StreamingMarkdownFilter` now preserves more Markdown constructs in outbound text.
152
+
153
+ ## [2.1.7] - 2026-04-07
154
+
155
+ ### Fixed
156
+
157
+ - **Plugin registration re-entrance:** Lazy-import `monitorWeixinProvider` inside `startAccount` in `channel.ts` to avoid pulling in the monitor → process-message → command-auth chain at plugin registration time, which could re-enter the plugin/provider registry before the account starts.
158
+ - **Initialization side effect:** Lazy-import `resolveSenderCommandAuthorizationWithRuntime` / `resolveDirectDmAuthorizationOutcome` in `process-message.ts` to prevent `ensureContextWindowCacheLoaded` from being triggered during module initialization, which caused `loadOpenClawPlugins` re-entrance.
159
+
160
+ ### Changed
161
+
162
+ - **Tool-call outbound path:** `sendWeixinOutbound` now applies `StreamingMarkdownFilter` to the outbound text, consistent with the model-output path in `process-message`.
163
+
164
+ ## [2.1.4] - 2026-04-03
165
+
166
+ ### Changed
167
+
168
+ - **QR login:** Remove client-side timeout for `get_bot_qrcode`; the request is no longer aborted on a fixed deadline (server / stack limits still apply).
169
+
170
+ ## [2.1.3] - 2026-04-02
171
+
172
+ ### Added
173
+
174
+ - **`StreamingMarkdownFilter`** (`src/messaging/markdown-filter.ts`): outbound text no longer runs through whole-string `markdownToPlainText` stripping; a streaming character filter replaces it, so Markdown goes from **effectively unsupported** to **partially supported**.
175
+
176
+ ### Changed
177
+
178
+ - **Outbound text path:** `process-message` uses `StreamingMarkdownFilter` (`feed` / `flush`) per deliver chunk instead of `markdownToPlainText`.
179
+
180
+ ### Removed
181
+
182
+ - **`markdownToPlainText`** from `src/messaging/send.ts` (and its tests from `send.test.ts`); coverage moves to `markdown-filter.test.ts`.
183
+
184
+ ## [2.1.2] - 2026-04-02
185
+
186
+ ### Changed
187
+
188
+ - **Config reload after login:** On each successful Weixin login, bump `channels.openclaw-weixin.channelConfigUpdatedAt` (ISO 8601) in `openclaw.json` so the gateway reloads config from disk, instead of writing an empty `accounts: {}` placeholder.
189
+ - **QR login:** Increase client timeout for `get_bot_qrcode` from 5s to 10s.
190
+ - **Docs:** Uninstall instructions now use `openclaw plugins uninstall @tencent-weixin/openclaw-weixin` (aligned with the plugins CLI).
191
+ - **Logging:** `debug-check` log line no longer includes `stateDir` / `OPENCLAW_STATE_DIR`.
192
+
193
+ ### Removed
194
+
195
+ - **`openclaw-weixin` CLI subcommands** (`src/weixin-cli.ts` and registration in `index.ts`). Use the host `openclaw plugins uninstall …` flow instead.
196
+
197
+ ### Fixed
198
+
199
+ - Resolves the **dangerous code pattern** warning when installing the plugin on **OpenClaw 2026.3.31+** (host plugin install / static checks).
package/LICENSE CHANGED
@@ -1,28 +1,22 @@
1
- Tencent is pleased to support the open source community by making openclaw-weixin available.
1
+ MIT License
2
2
 
3
- Copyright (C) 2026 Tencent. All rights reserved.
4
- Modifications Copyright (C) 2026 Contributors to NewFuture/openclaw-wexin.
3
+ Copyright (c) 2026 Tencent
4
+ Copyright (c) 2026 Contributors to NewFuture/openclaw-weixin
5
5
 
6
- openclaw-weixin is licensed under the MIT.
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
7
12
 
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
8
15
 
9
- Terms of the MIT:
10
- --------------------------------------------------------------------
11
- Permission is hereby granted, free of charge, to any person obtaining
12
- a copy of this software and associated documentation files (the
13
- "Software"), to deal in the Software without restriction, including
14
- without limitation the rights to use, copy, modify, merge, publish,
15
- distribute, sublicense, and/or sell copies of the Software, and to
16
- permit persons to whom the Software is furnished to do so, subject to
17
- the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be
20
- included in all copies or substantial portions of the Software.
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
26
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ This distribution contains software derived from Tencent/openclaw-weixin.
2
+ This notice is informational and adds no restrictions to the MIT License.
3
+
4
+ Tencent is pleased to support the open source community by making
5
+ openclaw-weixin available.
6
+
7
+ Copyright (C) 2026 Tencent. All rights reserved.
8
+
9
+ openclaw-weixin is licensed under the MIT.
10
+
11
+ Modifications Copyright (C) 2026 Contributors to NewFuture/openclaw-weixin.