wechat-clawbot 0.9.1
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.
- package/LICENSE +21 -0
- package/NOTICE +32 -0
- package/README.md +324 -0
- package/README.zh.md +192 -0
- package/cordis.patch.yml +23 -0
- package/lib/approvals.d.ts +29 -0
- package/lib/approvals.d.ts.map +1 -0
- package/lib/approvals.js +86 -0
- package/lib/approvals.js.map +1 -0
- package/lib/bridge.d.ts +281 -0
- package/lib/bridge.d.ts.map +1 -0
- package/lib/bridge.js +827 -0
- package/lib/bridge.js.map +1 -0
- package/lib/claude-peer.d.ts +44 -0
- package/lib/claude-peer.d.ts.map +1 -0
- package/lib/claude-peer.js +515 -0
- package/lib/claude-peer.js.map +1 -0
- package/lib/cli.d.ts +3 -0
- package/lib/cli.d.ts.map +1 -0
- package/lib/cli.js +128 -0
- package/lib/cli.js.map +1 -0
- package/lib/client.js +597 -0
- package/lib/config.d.ts +160 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +187 -0
- package/lib/config.js.map +1 -0
- package/lib/emoji.d.ts +26 -0
- package/lib/emoji.d.ts.map +1 -0
- package/lib/emoji.js +54 -0
- package/lib/emoji.js.map +1 -0
- package/lib/ilink/api/api.d.ts +134 -0
- package/lib/ilink/api/api.d.ts.map +1 -0
- package/lib/ilink/api/api.js +507 -0
- package/lib/ilink/api/api.js.map +1 -0
- package/lib/ilink/api/session-guard.d.ts +16 -0
- package/lib/ilink/api/session-guard.d.ts.map +1 -0
- package/lib/ilink/api/session-guard.js +49 -0
- package/lib/ilink/api/session-guard.js.map +1 -0
- package/lib/ilink/api/types.d.ts +251 -0
- package/lib/ilink/api/types.d.ts.map +1 -0
- package/lib/ilink/api/types.js +37 -0
- package/lib/ilink/api/types.js.map +1 -0
- package/lib/ilink/auth/accounts.d.ts +67 -0
- package/lib/ilink/auth/accounts.d.ts.map +1 -0
- package/lib/ilink/auth/accounts.js +190 -0
- package/lib/ilink/auth/accounts.js.map +1 -0
- package/lib/ilink/auth/login-qr.d.ts +43 -0
- package/lib/ilink/auth/login-qr.d.ts.map +1 -0
- package/lib/ilink/auth/login-qr.js +333 -0
- package/lib/ilink/auth/login-qr.js.map +1 -0
- package/lib/ilink/cdn/aes-ecb.d.ts +7 -0
- package/lib/ilink/cdn/aes-ecb.d.ts.map +1 -0
- package/lib/ilink/cdn/aes-ecb.js +19 -0
- package/lib/ilink/cdn/aes-ecb.js.map +1 -0
- package/lib/ilink/cdn/cdn-upload.d.ts +18 -0
- package/lib/ilink/cdn/cdn-upload.d.ts.map +1 -0
- package/lib/ilink/cdn/cdn-upload.js +90 -0
- package/lib/ilink/cdn/cdn-upload.js.map +1 -0
- package/lib/ilink/cdn/cdn-url.d.ts +14 -0
- package/lib/ilink/cdn/cdn-url.d.ts.map +1 -0
- package/lib/ilink/cdn/cdn-url.js +14 -0
- package/lib/ilink/cdn/cdn-url.js.map +1 -0
- package/lib/ilink/cdn/pic-decrypt.d.ts +10 -0
- package/lib/ilink/cdn/pic-decrypt.d.ts.map +1 -0
- package/lib/ilink/cdn/pic-decrypt.js +89 -0
- package/lib/ilink/cdn/pic-decrypt.js.map +1 -0
- package/lib/ilink/cdn/upload.d.ts +43 -0
- package/lib/ilink/cdn/upload.d.ts.map +1 -0
- package/lib/ilink/cdn/upload.js +115 -0
- package/lib/ilink/cdn/upload.js.map +1 -0
- package/lib/ilink/media/mime.d.ts +7 -0
- package/lib/ilink/media/mime.d.ts.map +1 -0
- package/lib/ilink/media/mime.js +73 -0
- package/lib/ilink/media/mime.js.map +1 -0
- package/lib/ilink/messaging/send-media.d.ts +23 -0
- package/lib/ilink/messaging/send-media.d.ts.map +1 -0
- package/lib/ilink/messaging/send-media.js +71 -0
- package/lib/ilink/messaging/send-media.js.map +1 -0
- package/lib/ilink/messaging/send.d.ts +55 -0
- package/lib/ilink/messaging/send.d.ts.map +1 -0
- package/lib/ilink/messaging/send.js +182 -0
- package/lib/ilink/messaging/send.js.map +1 -0
- package/lib/ilink/storage/state-dir.d.ts +14 -0
- package/lib/ilink/storage/state-dir.d.ts.map +1 -0
- package/lib/ilink/storage/state-dir.js +22 -0
- package/lib/ilink/storage/state-dir.js.map +1 -0
- package/lib/ilink/storage/sync-buf.d.ts +21 -0
- package/lib/ilink/storage/sync-buf.d.ts.map +1 -0
- package/lib/ilink/storage/sync-buf.js +64 -0
- package/lib/ilink/storage/sync-buf.js.map +1 -0
- package/lib/ilink/util/logger.d.ts +20 -0
- package/lib/ilink/util/logger.d.ts.map +1 -0
- package/lib/ilink/util/logger.js +73 -0
- package/lib/ilink/util/logger.js.map +1 -0
- package/lib/ilink/util/random.d.ts +11 -0
- package/lib/ilink/util/random.d.ts.map +1 -0
- package/lib/ilink/util/random.js +16 -0
- package/lib/ilink/util/random.js.map +1 -0
- package/lib/ilink/util/redact.d.ts +21 -0
- package/lib/ilink/util/redact.d.ts.map +1 -0
- package/lib/ilink/util/redact.js +54 -0
- package/lib/ilink/util/redact.js.map +1 -0
- package/lib/image-compress.d.ts +38 -0
- package/lib/image-compress.d.ts.map +1 -0
- package/lib/image-compress.js +184 -0
- package/lib/image-compress.js.map +1 -0
- package/lib/inbound-media.d.ts +17 -0
- package/lib/inbound-media.d.ts.map +1 -0
- package/lib/inbound-media.js +96 -0
- package/lib/inbound-media.js.map +1 -0
- package/lib/inbound.d.ts +28 -0
- package/lib/inbound.d.ts.map +1 -0
- package/lib/inbound.js +265 -0
- package/lib/inbound.js.map +1 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +321 -0
- package/lib/index.js.map +1 -0
- package/lib/mcp-route.d.ts +33 -0
- package/lib/mcp-route.d.ts.map +1 -0
- package/lib/mcp-route.js +422 -0
- package/lib/mcp-route.js.map +1 -0
- package/lib/memory-auto.d.ts +22 -0
- package/lib/memory-auto.d.ts.map +1 -0
- package/lib/memory-auto.js +144 -0
- package/lib/memory-auto.js.map +1 -0
- package/lib/memory.d.ts +26 -0
- package/lib/memory.d.ts.map +1 -0
- package/lib/memory.js +168 -0
- package/lib/memory.js.map +1 -0
- package/lib/models-route.d.ts +24 -0
- package/lib/models-route.d.ts.map +1 -0
- package/lib/models-route.js +84 -0
- package/lib/models-route.js.map +1 -0
- package/lib/monitor.d.ts +13 -0
- package/lib/monitor.d.ts.map +1 -0
- package/lib/monitor.js +116 -0
- package/lib/monitor.js.map +1 -0
- package/lib/pending.d.ts +23 -0
- package/lib/pending.d.ts.map +1 -0
- package/lib/pending.js +38 -0
- package/lib/pending.js.map +1 -0
- package/lib/prompt.d.ts +36 -0
- package/lib/prompt.d.ts.map +1 -0
- package/lib/prompt.js +246 -0
- package/lib/prompt.js.map +1 -0
- package/lib/questions.d.ts +21 -0
- package/lib/questions.d.ts.map +1 -0
- package/lib/questions.js +116 -0
- package/lib/questions.js.map +1 -0
- package/lib/quote-history.d.ts +18 -0
- package/lib/quote-history.d.ts.map +1 -0
- package/lib/quote-history.js +96 -0
- package/lib/quote-history.js.map +1 -0
- package/lib/state.d.ts +27 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +154 -0
- package/lib/state.js.map +1 -0
- package/lib/subagent-model.d.ts +26 -0
- package/lib/subagent-model.d.ts.map +1 -0
- package/lib/subagent-model.js +30 -0
- package/lib/subagent-model.js.map +1 -0
- package/lib/tool.d.ts +14 -0
- package/lib/tool.d.ts.map +1 -0
- package/lib/tool.js +518 -0
- package/lib/tool.js.map +1 -0
- package/package.json +94 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wechat-clawbot contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
NOTICE
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
This project contains code vendored from
|
|
5
|
+
[`@tencent-weixin/openclaw-weixin`](https://www.npmjs.com/package/@tencent-weixin/openclaw-weixin)
|
|
6
|
+
(OpenClaw Weixin channel, Copyright (c) Tencent), licensed under the MIT
|
|
7
|
+
License. The vendored files live under `src/ilink/` and are adapted where
|
|
8
|
+
noted in each file's header comment (OpenClaw-specific integration code was
|
|
9
|
+
replaced by DeepSeek Harness integration). The original MIT license text is
|
|
10
|
+
reproduced below.
|
|
11
|
+
|
|
12
|
+
MIT License
|
|
13
|
+
|
|
14
|
+
Copyright (c) Tencent
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# wechat-clawbot
|
|
2
|
+
|
|
3
|
+
Connect a [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) profile to your WeChat through the official **WeChat ClawBot** bridge (Tencent iLink API). Once bound, you can message your DSH agent from WeChat while you are away from the computer — ask it to look at files, edit them, run commands — and it replies (including permission/approval questions) in the WeChat conversation.
|
|
4
|
+
|
|
5
|
+
> **Status: v0.9.0** — text messages both ways; **native vision** (an inbound photo rides in the model's own message, and `look_at_image` hands a local one to it directly — no separate vision model, no second round trip); agent → WeChat file/image delivery; quoted (引用) message resolution; long-term memory; scheduled reminders; a **settings card** on 设置 → 插件 whose fields apply live; and a per-plugin model pin so the web UI's model picker no longer moves the bot. Group chats are not supported.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Phone WeChat ──► Tencent iLink cloud ──► this plugin (long-poll monitor)
|
|
11
|
+
◄──────────────────────────────── (text replies, approval questions)
|
|
12
|
+
│
|
|
13
|
+
▼
|
|
14
|
+
one fixed DSH agent session ("wechat-main")
|
|
15
|
+
(persisted, auto-compacted like any DSH session)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- The plugin reuses the protocol client from the official, MIT-licensed
|
|
19
|
+
[`@tencent-weixin/openclaw-weixin`](https://www.npmjs.com/package/@tencent-weixin/openclaw-weixin)
|
|
20
|
+
package (see [`NOTICE`](NOTICE)); only the OpenClaw integration layer was
|
|
21
|
+
replaced with a DeepSeek Harness integration.
|
|
22
|
+
- The WeChat conversation maps to **one fixed session id** (default
|
|
23
|
+
`wechat-main`), so context is shared, history survives restarts, and
|
|
24
|
+
automatic context compaction keeps token usage low.
|
|
25
|
+
- The WeChat session's approval policy is forced to `ask`: permission
|
|
26
|
+
requests (file access, command execution, sandbox escalation) are forwarded
|
|
27
|
+
to WeChat and you answer with `同意` / `拒绝` (or `yes` / `no`).
|
|
28
|
+
- **File/image delivery**: the WeChat agent has a `send_wechat_file` tool —
|
|
29
|
+
just ask it (e.g. *"把 README.md 发给我"* or *"生成一张图表发给我"*). Files
|
|
30
|
+
travel through Tencent's CDN with the official AES-128-ECB encrypted upload
|
|
31
|
+
pipeline; images, PDFs, Office documents, archives etc. are supported.
|
|
32
|
+
- The plugin runs **inside the profile process**: as long as the profile is
|
|
33
|
+
running, the bridge is up. Login is manual (scan a QR code), once per
|
|
34
|
+
binding; the token is stored under `$DSH_HOME/clawbot` and reused on
|
|
35
|
+
restart.
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
- Node.js >= 22
|
|
40
|
+
- A DSH profile (e.g. the `web` profile) with a configured model provider
|
|
41
|
+
- The WeChat mobile app with the official **微信ClawBot** plugin available
|
|
42
|
+
(设置 → 插件; WeChat may prompt you to update the app the first time you scan)
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 1. Install the plugin into a profile (pnpm is required)
|
|
48
|
+
dsh plugin --profile web add wechat-clawbot
|
|
49
|
+
|
|
50
|
+
# 2. Restart the profile
|
|
51
|
+
# (stop `dsh web`, then start it again)
|
|
52
|
+
dsh web
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The plugin starts automatically at boot (`autoStart: true`). To change its
|
|
56
|
+
configuration, add a `clawbot` row to the profile's `cordis.patch.yml`:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
- id: clawbot
|
|
60
|
+
config:
|
|
61
|
+
allowFrom: [] # allowlist of WeChat user ids; [] = only the binder
|
|
62
|
+
sessionId: wechat-main # the fixed DSH session for all WeChat messages
|
|
63
|
+
forwardQuestions: false
|
|
64
|
+
approvalTimeoutMs: 0 # 0 = wait indefinitely for approval answers
|
|
65
|
+
logLevel: info
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Connect (one-time, manual)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# From the profile directory (or anywhere; the state dir is shared):
|
|
72
|
+
clawbot login
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
A QR code is printed in the terminal. Scan it with **WeChat → 扫一扫** and
|
|
76
|
+
confirm. Afterwards:
|
|
77
|
+
|
|
78
|
+
- WeChat shows a new contact **「微信ClawBot」** — open it and start chatting.
|
|
79
|
+
- The running profile picks up the credentials automatically within a second
|
|
80
|
+
(it watches the state directory) — no restart needed.
|
|
81
|
+
|
|
82
|
+
Other commands:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
clawbot status # show the bound account
|
|
86
|
+
clawbot logout # unbind and delete credentials
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Environment:
|
|
90
|
+
|
|
91
|
+
| Variable | Default | Meaning |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `CLAWBOT_STATE_DIR` | `$DSH_HOME/clawbot` | credential/state directory |
|
|
94
|
+
| `CLAWBOT_LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` |
|
|
95
|
+
|
|
96
|
+
## Security
|
|
97
|
+
|
|
98
|
+
- **Allowlist**: by default only the WeChat user who scanned the QR code may
|
|
99
|
+
message the agent. Add more users via `allowFrom` (their WeChat user ids
|
|
100
|
+
appear in the logs / `clawbot status`).
|
|
101
|
+
- **Approvals**: the WeChat session runs with approval policy `ask`, so
|
|
102
|
+
sensitive operations still require your explicit reply in WeChat. Other
|
|
103
|
+
sessions (e.g. the local web GUI) keep their own policy.
|
|
104
|
+
- Unknown senders are ignored silently.
|
|
105
|
+
|
|
106
|
+
## Configuration reference
|
|
107
|
+
|
|
108
|
+
| Key | Type | Default | Meaning |
|
|
109
|
+
|---|---|---|---|
|
|
110
|
+
| `autoStart` | boolean | `true` | start the monitor at boot when a bound account exists |
|
|
111
|
+
| `allowFrom` | string[] | `[]` | allowed sender ids; empty = binder only |
|
|
112
|
+
| `sessionId` | string | `wechat-main` | fixed DSH session for all WeChat traffic |
|
|
113
|
+
| `cwd` | string | `process.cwd()` | workspace for a freshly created session |
|
|
114
|
+
| `forwardQuestions` | boolean | `false` | forward `ask_user_question` / plan-review to WeChat (see note) |
|
|
115
|
+
| `approvalTimeoutMs` | number | `0` | approval answer timeout; `0` = wait forever |
|
|
116
|
+
| `botAgent` | string | `DSH-ClawBot/0.1.0 …` | `bot_agent` reported to iLink |
|
|
117
|
+
| `maxImageEdge` | number | `2048` | long-edge pixel cap for compressed images |
|
|
118
|
+
| `imageQuality` | number | `80` | JPEG quality for compressed images |
|
|
119
|
+
| `compressThresholdBytes` | number | `1048576` | only compress images larger than this |
|
|
120
|
+
| `apiBaseUrl` | string | `https://ilinkai.weixin.qq.com` | iLink API base (override for testing) |
|
|
121
|
+
| `logLevel` | `debug\|info\|warn\|error` | `info` | protocol log level |
|
|
122
|
+
| `stripEmoji` | boolean | `true` | strip Unicode emoji from outbound text |
|
|
123
|
+
| `noticeMinBytes` | number | `2097152` | announce a file before upload only above this size; `0` = always |
|
|
124
|
+
| `attachImages` | boolean | `true` | give images to the model directly when the route accepts them |
|
|
125
|
+
| `provider` | string | — | pin this session's provider; empty = follow the deployment default |
|
|
126
|
+
| `model` | string | — | pin the model; empty = follow the deployment default |
|
|
127
|
+
| `reasoningEffort` | string | — | pin the effort; empty = the model's own default |
|
|
128
|
+
| `mcpBridge` | boolean | `true` | answer the `/plugins/clawbot/mcp/*` routes (see **The Claude bridge**) |
|
|
129
|
+
|
|
130
|
+
> `forwardQuestions`: only one `userQuestions` provider can exist per DSH
|
|
131
|
+
> context. The Web UI registers one while a browser is attached, so this
|
|
132
|
+
> option only takes effect in deployments without an active Web provider.
|
|
133
|
+
> Approval forwarding (`approval/request`) is independent and always on for
|
|
134
|
+
> the WeChat session.
|
|
135
|
+
|
|
136
|
+
## Settings
|
|
137
|
+
|
|
138
|
+
Most of the table above is editable at **设置 → 插件 → 微信 Bot**, and a change
|
|
139
|
+
lands on the next message with no restart and no dropped WeChat connection: the
|
|
140
|
+
plugin diffs the committed settings and copies the *hot* fields into its live
|
|
141
|
+
config, which every collaborator holds by reference and reads at the moment it
|
|
142
|
+
is used.
|
|
143
|
+
|
|
144
|
+
The card writes into the settings document's `clawbot` section, which is an
|
|
145
|
+
**override layer over the plugin's cordis row** — `cordis.patch.yml` stays the
|
|
146
|
+
default, and the file only ever stores fields you actually changed. Each row
|
|
147
|
+
shows a 已覆盖 badge with a 重置 that drops back to the composed value.
|
|
148
|
+
|
|
149
|
+
Cold fields (`sessionId`, `autoStart`, `forwardQuestions`, `botAgent`,
|
|
150
|
+
`apiBaseUrl`, `cwd`) are deliberately **absent from the card**. They are stored
|
|
151
|
+
but not applied in place — `apiBaseUrl` would redirect a connected client
|
|
152
|
+
mid-flight and `sessionId` would point the bridge at a session it is not bound
|
|
153
|
+
to — so they live in `cordis.patch.yml`, where changing them already means a
|
|
154
|
+
reload.
|
|
155
|
+
|
|
156
|
+
### Pinning the model
|
|
157
|
+
|
|
158
|
+
Leaving `provider`/`model` empty means the session follows the deployment
|
|
159
|
+
default, which is also why picking a model in the web UI used to move the bot:
|
|
160
|
+
that picker writes through to the global `agent-default-model`. Setting them
|
|
161
|
+
here breaks the coupling. A model id that will not resolve is refused rather
|
|
162
|
+
than applied, so a typo cannot brick the next message.
|
|
163
|
+
|
|
164
|
+
## The Claude bridge
|
|
165
|
+
|
|
166
|
+
Two directions, and they are separate mechanisms with separate failure modes.
|
|
167
|
+
|
|
168
|
+
### Outward: `/plugins/clawbot/mcp/*` — Claude Code drives DSH
|
|
169
|
+
|
|
170
|
+
Four routes, consumed by [dsh-mcp-bridge](../dsh-mcp-bridge) (an MCP server, not
|
|
171
|
+
a DSH plugin), which is what gives a Claude Code session tools to list/read/drive
|
|
172
|
+
DSH sessions and to reach the owner on WeChat.
|
|
173
|
+
|
|
174
|
+
| Route | Method | Does |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `mcp/sessions` | GET | list sessions: id, title, cwd, live, running |
|
|
177
|
+
| `mcp/read` | POST | tail one session's user/assistant turns |
|
|
178
|
+
| `mcp/send` | POST | steer or follow up a **live** agent |
|
|
179
|
+
| `mcp/notify` | POST | one WeChat message to the owner |
|
|
180
|
+
| `mcp/status` | GET | is the bridge on, has anything called it |
|
|
181
|
+
|
|
182
|
+
The privileged half lives here rather than in the MCP server for a concrete
|
|
183
|
+
reason: `ctx.agents` holds the live agent objects, and `steer()`/`followup()` are
|
|
184
|
+
in-memory methods an out-of-process caller cannot reach. The WeChat send needs
|
|
185
|
+
the account token plus per-peer context tokens, so duplicating it outside would
|
|
186
|
+
mean a second copy of the credential handling.
|
|
187
|
+
|
|
188
|
+
Three properties are load-bearing and covered by tests:
|
|
189
|
+
|
|
190
|
+
- **`notify` takes no recipient.** It sends to `account.userId` — the id linked by
|
|
191
|
+
QR login — so messaging anyone but the owner is *unrepresentable*, not merely
|
|
192
|
+
discouraged.
|
|
193
|
+
- **`send` does not reach WeChat.** Injected messages carry source plugin
|
|
194
|
+
`clawbot-mcp`, and the bridge's session listener treats any non-`schedule`
|
|
195
|
+
plugin turn as GUI-only (leaves `currentSender` unset). So a message pushed
|
|
196
|
+
into `wechat-main` is answered in the web UI only. `notify` is the sole route
|
|
197
|
+
to the phone. **Changing that source string breaks the isolation.**
|
|
198
|
+
- **Auth.** Every route needs `Authorization: Bearer <token>` from
|
|
199
|
+
`<state>/mcp-token` (0600, minted on first boot). `mcp/status` is deliberately
|
|
200
|
+
unauthenticated — a browser page cannot hold a secret — so it reports the
|
|
201
|
+
token's *path*, never its value.
|
|
202
|
+
|
|
203
|
+
`mcpBridge: false` makes all four return 403 while leaving them registered: the
|
|
204
|
+
flag is read per request, so it is a live kill switch in both directions.
|
|
205
|
+
|
|
206
|
+
### Inward: three tools — DSH sees and steers Claude Code
|
|
207
|
+
|
|
208
|
+
Registered on the WeChat agent (`restrictTools` is a **deny** list, so they need
|
|
209
|
+
no allowlisting): `list_claude_sessions`, `read_claude_session`,
|
|
210
|
+
`send_to_claude_session`.
|
|
211
|
+
|
|
212
|
+
Listing and reading go straight to files, which is the stable half:
|
|
213
|
+
`~/.claude/sessions/<pid>.json` is world-readable, and
|
|
214
|
+
`~/.claude/projects/<slug>/<sessionId>.jsonl` is the transcript (found by
|
|
215
|
+
globbing for the id — deriving the directory name flattens both separators *and*
|
|
216
|
+
dots, which is easy to get subtly wrong).
|
|
217
|
+
|
|
218
|
+
Sending is the interesting half. There is **no documented CLI** for reaching a
|
|
219
|
+
live session: `claude` has no send/message subcommand, and `--resume -p` starts a
|
|
220
|
+
new run from history instead of the session the user is watching. The real
|
|
221
|
+
mechanism is `peerProtocol 1` over `/tmp/cc-socks/<pid>.sock` with a 0600 key,
|
|
222
|
+
and `claude.exe` is a native binary. So rather than reverse-engineer it, this
|
|
223
|
+
shells out to a short-lived
|
|
224
|
+
|
|
225
|
+
```sh
|
|
226
|
+
claude -p "<deliver X to session Y>" --allowed-tools ListAgents,SendMessage --model haiku
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
and lets Claude Code do the socket work with its own implementation — protocol
|
|
230
|
+
changes stay Anthropic's to keep working. Verified end to end.
|
|
231
|
+
|
|
232
|
+
Four things learned the hard way, all of them now pinned by tests:
|
|
233
|
+
|
|
234
|
+
- **Session names drift.** One session was observed renaming itself
|
|
235
|
+
`harvard-96` → `harvard-35` → `harvard-ef` inside a day. So the name is
|
|
236
|
+
resolved fresh on every send, never cached, and an ambiguous handle is an
|
|
237
|
+
error rather than a guess.
|
|
238
|
+
- **Success needs an anchored match.** A bare `/sent/i` scores Claude Code's own
|
|
239
|
+
"Session X is not reachable" and the plausible "was not sent" as a delivery.
|
|
240
|
+
- **State the run state and the queue explicitly, including when zero.** The
|
|
241
|
+
first version omitted both, and the bot answered 「都没有正在运行的任务」about a
|
|
242
|
+
session that was mid-tool-call. An absent field does not read as *unknown* to a
|
|
243
|
+
model — it reads as *nothing*, and the gap gets filled by invention.
|
|
244
|
+
- **Queue accounting has three operations, not two.** `enqueue` adds, `dequeue`
|
|
245
|
+
delivers the head, and `remove` withdraws a specific item **by content**. A
|
|
246
|
+
real session measured 15/9/6 — counting only enqueue/dequeue calls that 6
|
|
247
|
+
pending when it is 0.
|
|
248
|
+
|
|
249
|
+
Run state is an *inference*: a turn is in flight when the newest main-thread
|
|
250
|
+
entry is an assistant message holding a `tool_use`, or a user entry that is
|
|
251
|
+
nothing but `tool_result`. Gated on a 180s freshness window, because a session
|
|
252
|
+
killed mid-tool-call keeps an unfinished last entry forever.
|
|
253
|
+
|
|
254
|
+
Known limit: a message **currently waiting** in the queue does not appear in the
|
|
255
|
+
transcript. Verified, not assumed — a session had one queued while
|
|
256
|
+
enqueue/dequeue/remove balanced to zero, with the file 7s fresh and writes shown
|
|
257
|
+
to be prompt. A live answer would need the peer socket.
|
|
258
|
+
|
|
259
|
+
> Timestamps in the transcript are **UTC**. Render them through
|
|
260
|
+
> `toLocaleTimeString`, never by slicing the ISO string — `"…T20:33:05Z"
|
|
261
|
+
> .slice(11,16)` reported a 16:33 message as 20:33.
|
|
262
|
+
|
|
263
|
+
## Limitations
|
|
264
|
+
|
|
265
|
+
- Group chats are not supported (official channel behaviour).
|
|
266
|
+
- Voice messages require a silk transcoder and are not supported.
|
|
267
|
+
- One bound WeChat account per state directory. Multiple accounts are tracked
|
|
268
|
+
in the store but only the first is monitored.
|
|
269
|
+
- Scheduled reminders are session-local: one that comes due while the profile
|
|
270
|
+
is not running is delivered, late, at the next start.
|
|
271
|
+
- The bridge runs only while the DSH profile process is running. For 24/7
|
|
272
|
+
operation keep `dsh web` up (a login item or launchd unit).
|
|
273
|
+
- WeChat's own bracket emoji codes (`[捂脸]`) are stripped unconditionally from
|
|
274
|
+
outbound text: they are WeChat-internal notation and arrive through this
|
|
275
|
+
bridge as literal brackets.
|
|
276
|
+
|
|
277
|
+
## Development
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
npm install
|
|
281
|
+
npm run typecheck # tsc --noEmit
|
|
282
|
+
npm run build # tsc → lib/, then copies src/client.js → lib/client.js
|
|
283
|
+
|
|
284
|
+
node test/regression.mjs # 55 offline checks, no model calls, no WeChat
|
|
285
|
+
node test/claude-peer.mjs # 29 checks against the real ~/.claude
|
|
286
|
+
node scripts/bot-sim.mjs # reply-style harness against the real prompt
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Both suites are offline and cost nothing: no model calls, no network, no WeChat.
|
|
290
|
+
They exit non-zero, so either can gate a build.
|
|
291
|
+
|
|
292
|
+
`test/regression.mjs` covers the things that used to fail silently: a strip rule
|
|
293
|
+
that ate a markdown link, a settings field declared "hot" but only read at boot,
|
|
294
|
+
an output schema that rejects a field the attachment store just started
|
|
295
|
+
returning, and the bridge invariants above (that `notify` reads no recipient,
|
|
296
|
+
that injected messages keep the `clawbot-mcp` source tag, that `mcp/status`
|
|
297
|
+
never echoes the token).
|
|
298
|
+
|
|
299
|
+
**A hot field must appear as `config.X` in one of the source files that suite
|
|
300
|
+
greps** — a field only read inside `apply()` is not hot, whatever `HOT_FIELDS`
|
|
301
|
+
claims, and the check enforces that. When adding a source file that reads
|
|
302
|
+
settings, add it to that list too.
|
|
303
|
+
|
|
304
|
+
`test/claude-peer.mjs` runs the peer tools against the real `~/.claude`, because
|
|
305
|
+
the failure mode there is not "it crashed" but "it silently returned nothing" —
|
|
306
|
+
a renamed registry key, a changed transcript shape, a stale pid counted as live.
|
|
307
|
+
Queue accounting, the idle path and the clock are asserted against a *synthetic*
|
|
308
|
+
transcript with known answers, so they do not depend on what the machine happens
|
|
309
|
+
to be doing. `send_to_claude_session` is registered but never invoked by the
|
|
310
|
+
suite: it spawns a process and delivers into a real live session.
|
|
311
|
+
|
|
312
|
+
`scripts/bot-sim.mjs` drives the **real** system prompt and tool list against
|
|
313
|
+
scripted turns and prints what WeChat would have received — so a prompt change
|
|
314
|
+
can be judged without messaging yourself and without a session reset. It flags
|
|
315
|
+
empty-response endings, stacked vision calls, and bracket emoji codes. Add
|
|
316
|
+
`--allow-emoji` to exercise the `stripEmoji: false` branch.
|
|
317
|
+
|
|
318
|
+
The vendored iLink protocol layer lives in `src/ilink/` (MIT, Tencent); the
|
|
319
|
+
DSH integration is `src/bridge.ts`, `src/inbound.ts`, `src/approvals.ts`,
|
|
320
|
+
`src/monitor.ts`, `src/questions.ts`, `src/index.ts`.
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
MIT. The vendored iLink client is MIT © Tencent — see [`NOTICE`](NOTICE).
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# wechat-clawbot
|
|
2
|
+
|
|
3
|
+
把 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)profile 通过微信官方 **微信ClawBot**(腾讯 iLink API)接入你的微信。绑定后,你可以在外面用微信给 DSH agent 发消息——让它查看电脑上的文件、帮你编辑、执行命令——agent 会把结果(包括权限确认问题)直接回发到微信对话里。
|
|
4
|
+
|
|
5
|
+
> **状态:v0.5.0** — 文本消息 + **agent → 微信 文件/图片发送**(`send_wechat_file`,发原图)+ **微信图片/文件入站**(解密落盘、可识图)+ **引用消息解析** + 识图前自动预览加速 + 微信对话规范 prompt(先确认、结尾一次归纳)。群聊暂不支持。
|
|
6
|
+
|
|
7
|
+
## 工作原理
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
手机微信 ──► 腾讯 iLink 云 ──► 本插件(长轮询监控)
|
|
11
|
+
◄──────────────────────── (文本回复、审批提问)
|
|
12
|
+
│
|
|
13
|
+
▼
|
|
14
|
+
一个固定的 DSH agent 会话("wechat-main")
|
|
15
|
+
(持久化、自动压缩,与普通 DSH 会话相同)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- 协议客户端复用官方 MIT 许可的
|
|
19
|
+
[`@tencent-weixin/openclaw-weixin`](https://www.npmjs.com/package/@tencent-weixin/openclaw-weixin)
|
|
20
|
+
包(见 [`NOTICE`](NOTICE)),只把 OpenClaw 集成层替换成了 DeepSeek Harness 集成。
|
|
21
|
+
- 微信对话映射到**一个固定会话**(默认 `wechat-main`):上下文共享、重启后历史保留、
|
|
22
|
+
自动上下文压缩控制 token 消耗。
|
|
23
|
+
- 微信会话的审批策略强制为 `ask`:权限请求(文件访问、命令执行、沙箱升级)会转发到
|
|
24
|
+
微信,你回复 `同意` / `拒绝`(或 `yes` / `no`)即可。
|
|
25
|
+
- **文件/图片发送**:微信 agent 自带 `send_wechat_file` 工具——直接说
|
|
26
|
+
(例如"把 README.md 发给我"或"生成一张图表发给我")。文件走腾讯 CDN +
|
|
27
|
+
官方 AES-128-ECB 加密上传链路;支持图片、PDF、Office 文档、压缩包等。
|
|
28
|
+
- 插件运行在 **profile 进程内部**:只要 profile 在运行,桥接就在线。连接方式为手动扫码
|
|
29
|
+
(每次绑定一次即可),token 存在 `$DSH_HOME/clawbot`,重启后自动复用。
|
|
30
|
+
|
|
31
|
+
## 环境要求
|
|
32
|
+
|
|
33
|
+
- Node.js >= 22
|
|
34
|
+
- 一个 DSH profile(如 `web` profile),已配置模型 provider
|
|
35
|
+
- 手机微信,且可用官方**微信ClawBot**插件(设置 → 插件;首次扫码时微信可能提示升级版本)
|
|
36
|
+
|
|
37
|
+
## 安装
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# 1. 把插件装进 profile(需要 pnpm)
|
|
41
|
+
dsh plugin --profile web add wechat-clawbot
|
|
42
|
+
|
|
43
|
+
# 2. 重启 profile
|
|
44
|
+
# (先停掉 `dsh web`,再重新启动)
|
|
45
|
+
dsh web
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
插件默认随 profile 启动(`autoStart: true`)。如需改配置,在 profile 的
|
|
49
|
+
`cordis.patch.yml` 里加一个 `clawbot` 行:
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
- id: clawbot
|
|
53
|
+
config:
|
|
54
|
+
allowFrom: [] # 微信用户 id 白名单;[] = 仅绑定者本人
|
|
55
|
+
sessionId: wechat-main # 微信消息对应的固定 DSH 会话
|
|
56
|
+
forwardQuestions: false
|
|
57
|
+
approvalTimeoutMs: 0 # 0 = 审批等待无限期
|
|
58
|
+
logLevel: info
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 连接(一次性,手动)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 在任意目录执行(状态目录全局共享):
|
|
65
|
+
clawbot login
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
终端会打印二维码,用 **微信 → 扫一扫** 扫描并确认。之后:
|
|
69
|
+
|
|
70
|
+
- 微信通讯录出现新联系人 **「微信ClawBot」**,打开即可对话。
|
|
71
|
+
- 正在运行的 profile 会在 1 秒内自动发现凭据并启动监控——**无需重启**。
|
|
72
|
+
|
|
73
|
+
其他命令:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
clawbot status # 查看当前绑定账号
|
|
77
|
+
clawbot logout # 解除绑定并删除凭据
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
环境变量:
|
|
81
|
+
|
|
82
|
+
| 变量 | 默认值 | 含义 |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `CLAWBOT_STATE_DIR` | `$DSH_HOME/clawbot` | 凭据/状态目录 |
|
|
85
|
+
| `CLAWBOT_LOG_LEVEL` | `info` | `debug` / `info` / `warn` / `error` |
|
|
86
|
+
|
|
87
|
+
## 安全
|
|
88
|
+
|
|
89
|
+
- **白名单**:默认只有扫码绑定者本人能向 agent 发消息;如需加人,用 `allowFrom`
|
|
90
|
+
配置(用户 id 见日志或 `clawbot status`)。
|
|
91
|
+
- **审批**:微信会话审批策略为 `ask`,敏感操作仍需你在微信里明确回复。其他会话
|
|
92
|
+
(如本机 Web GUI)保持各自的策略。
|
|
93
|
+
- 陌生人的消息会被静默忽略。
|
|
94
|
+
|
|
95
|
+
## 配置项
|
|
96
|
+
|
|
97
|
+
| 键 | 类型 | 默认 | 含义 |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| `autoStart` | boolean | `true` | 启动时若有已绑定账号则自动开始监控 |
|
|
100
|
+
| `allowFrom` | string[] | `[]` | 允许发消息的用户 id;空 = 仅绑定者 |
|
|
101
|
+
| `sessionId` | string | `wechat-main` | 微信流量对应的固定 DSH 会话 |
|
|
102
|
+
| `cwd` | string | `process.cwd()` | 新建会话的工作目录 |
|
|
103
|
+
| `forwardQuestions` | boolean | `false` | 把 `ask_user_question`/plan review 转发到微信(见下) |
|
|
104
|
+
| `approvalTimeoutMs` | number | `0` | 审批等待超时;`0` = 无限期 |
|
|
105
|
+
| `botAgent` | string | `DSH-ClawBot/0.1.0 …` | 上报给 iLink 的 `bot_agent` |
|
|
106
|
+
| `compressImages` | boolean | `true` | 大图发送前自动压缩(macOS `sips`) |
|
|
107
|
+
| `maxImageEdge` | number | `2048` | 压缩图长边像素上限 |
|
|
108
|
+
| `imageQuality` | number | `80` | 压缩 JPEG 质量 |
|
|
109
|
+
| `compressThresholdBytes` | number | `1048576` | 超过此大小才压缩 |
|
|
110
|
+
| `apiBaseUrl` | string | `https://ilinkai.weixin.qq.com` | iLink API 地址(测试用) |
|
|
111
|
+
| `logLevel` | `debug\|info\|warn\|error` | `info` | 协议层日志级别 |
|
|
112
|
+
|
|
113
|
+
> `forwardQuestions`:每个 DSH 上下文只能有一个 `userQuestions` provider。
|
|
114
|
+
> Web UI 在浏览器连接时会注册自己的 provider,所以此选项只在没有 Web provider
|
|
115
|
+
> 的部署中生效。审批转发(`approval/request`)与它无关,对微信会话始终开启。
|
|
116
|
+
|
|
117
|
+
## Claude 桥(双向)
|
|
118
|
+
|
|
119
|
+
两个方向,机制不同、失效方式也不同。完整说明见 [README.md](README.md) 的
|
|
120
|
+
「The Claude bridge」,这里只放最容易踩的几条。
|
|
121
|
+
|
|
122
|
+
**出站 —— Claude Code 驱动 DSH**:`/plugins/clawbot/mcp/{sessions,read,send,notify,status}`,
|
|
123
|
+
由 [dsh-mcp-bridge](../dsh-mcp-bridge)(一个 MCP server,不是 DSH 插件)调用。
|
|
124
|
+
|
|
125
|
+
- `notify` **没有收件人参数**,只发 `account.userId`(扫码绑定的那个 id)——
|
|
126
|
+
「发给别人」在结构上无法表达。
|
|
127
|
+
- `send` **到不了微信**。注入的消息来源标 `clawbot-mcp`,会话监听把非
|
|
128
|
+
`schedule` 的插件轮次一律当 GUI-only。**改这个字符串就破掉隔离。**
|
|
129
|
+
- 每个路由都要 bearer token(`<state>/mcp-token`,0600)。只有 `status` 不要,
|
|
130
|
+
因为浏览器页面存不住密钥——所以它只报 token 的**路径**,绝不报值。
|
|
131
|
+
- `mcpBridge: false` 让四个路由都返回 403,路由仍注册着。标志位每请求现读,
|
|
132
|
+
所以开关**两个方向都不用重启**。
|
|
133
|
+
|
|
134
|
+
**入站 —— DSH 看见并驱动 Claude Code**:三个工具
|
|
135
|
+
`list_claude_sessions` / `read_claude_session` / `send_to_claude_session`。
|
|
136
|
+
|
|
137
|
+
- 列表和读取直接走文件(`~/.claude/sessions/*.json` + `projects/*/<id>.jsonl`),
|
|
138
|
+
这是稳定的那一半。
|
|
139
|
+
- 投递没有官方 CLI,真机制是 `/tmp/cc-socks/<pid>.sock` 上的 `peerProtocol 1`。
|
|
140
|
+
这里**不逆它**,而是拉起一个短命的
|
|
141
|
+
`claude -p … --allowed-tools ListAgents,SendMessage --model haiku`,
|
|
142
|
+
让 Claude Code 用自己的实现去走那个 socket。
|
|
143
|
+
- **会话名会漂移**(实测一天内 `harvard-96` → `harvard-35` → `harvard-ef`)。
|
|
144
|
+
所以每次发送都重新解析,从不缓存;对不上就报错,不猜。
|
|
145
|
+
- **运行态和队列必须显式说出来,哪怕是零。** 少了这个字段,模型会**编**一句
|
|
146
|
+
「都没有正在运行的任务」——字段缺失在模型眼里不读作「未知」,读作「没有」。
|
|
147
|
+
- **队列有三种操作**:`enqueue` / `dequeue` / `remove`(按内容撤回)。只数前两个
|
|
148
|
+
会把撤回的算成在排(实测 15/9/6,真实待处理是 0)。
|
|
149
|
+
- transcript 里的时间是 **UTC**。用 `toLocaleTimeString`,别切 ISO 字符串——
|
|
150
|
+
切出来会把 16:33 的消息报成 20:33。
|
|
151
|
+
|
|
152
|
+
## 已知限制
|
|
153
|
+
|
|
154
|
+
- 语音消息需要 silk 转码,暂不支持。
|
|
155
|
+
- 队列里**正在等**的那条消息看不到(transcript 里不记录未投递项)。要拿到活的
|
|
156
|
+
答案只能讲 peer socket,本插件刻意不讲。
|
|
157
|
+
- 一个状态目录绑定一个微信账号(只监控第一个账号)。
|
|
158
|
+
- 不支持群聊(官方渠道行为)。
|
|
159
|
+
- 只有 DSH profile 进程运行时桥接才在线。需要 7×24 小时可用的话,请保持
|
|
160
|
+
`dsh web` 常驻(如 launchd / systemd 服务)。
|
|
161
|
+
|
|
162
|
+
## 开发
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm install
|
|
166
|
+
npm run typecheck # tsc --noEmit
|
|
167
|
+
npm run build # tsc → lib/,并把 src/client.js 拷成 lib/client.js
|
|
168
|
+
|
|
169
|
+
node test/regression.mjs # 55 项离线检查
|
|
170
|
+
node test/claude-peer.mjs # 29 项,真读 ~/.claude
|
|
171
|
+
node scripts/bot-sim.mjs # 用真实提示词跑回复风格,不碰真微信
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
两个测试套件都是离线的:不调模型、不联网、不碰微信,失败返回非零,可以用来
|
|
175
|
+
把关构建。
|
|
176
|
+
|
|
177
|
+
**加了新的「热」配置项时注意**:`regression.mjs` 会 grep 源文件里有没有
|
|
178
|
+
`config.X` 这样的读法。只在 `apply()` 里读一次的字段**不是热的**,不管
|
|
179
|
+
`HOT_FIELDS` 里怎么写——这条检查就是拦这个的。新增会读设置的源文件,记得同时
|
|
180
|
+
加进那个文件列表。
|
|
181
|
+
|
|
182
|
+
`claude-peer.mjs` 里队列记账、空闲判断和时区都是对着**合成的** transcript 断言的
|
|
183
|
+
(已知答案),不依赖机器此刻在干什么。`send_to_claude_session` 只注册、**从不
|
|
184
|
+
调用**——它会拉起进程并把消息投进一个真会话。
|
|
185
|
+
|
|
186
|
+
移植的 iLink 协议层在 `src/ilink/`(MIT,腾讯);DSH 集成代码为
|
|
187
|
+
`src/bridge.ts`、`src/inbound.ts`、`src/approvals.ts`、`src/monitor.ts`、
|
|
188
|
+
`src/questions.ts`、`src/index.ts`。
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT。移植的 iLink 客户端为 MIT © Tencent——见 [`NOTICE`](NOTICE)。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# wechat-clawbot bundle patch: inserts the WeChat ClawBot channel row.
|
|
2
|
+
#
|
|
3
|
+
# Applied after dsh-base/dsh-web-app bundle layers. Users may override every
|
|
4
|
+
# key below from their profile's own cordis.patch.yml (same `id: clawbot`).
|
|
5
|
+
- insert:
|
|
6
|
+
- id: clawbot
|
|
7
|
+
name: 'wechat-clawbot'
|
|
8
|
+
config:
|
|
9
|
+
autoStart: true
|
|
10
|
+
allowFrom: []
|
|
11
|
+
sessionId: 'wechat-main'
|
|
12
|
+
forwardQuestions: false
|
|
13
|
+
approvalTimeoutMs: 0
|
|
14
|
+
logLevel: 'info'
|
|
15
|
+
|
|
16
|
+
# dsh-schedule: the DSH official reminder plugin. The WeChat agent uses
|
|
17
|
+
# its schedule_create/list/delete tools for timed reminders, and the
|
|
18
|
+
# bridge delivers the injected reminders back to WeChat. Bundled here so
|
|
19
|
+
# installing this plugin brings the reminder feature automatically —
|
|
20
|
+
# no profile-level patch needed. (Reminders persist in the session log,
|
|
21
|
+
# so a session reset clears them; they survive GUI restarts.)
|
|
22
|
+
- id: schedule
|
|
23
|
+
name: '@deepseek-ai/dsh-schedule'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval relay: forwards `approval/request` questions for WeChat-owned
|
|
3
|
+
* agents into WeChat and maps the user's reply back to an approval outcome.
|
|
4
|
+
*
|
|
5
|
+
* Follows the ACP-bridge pattern: the listener only answers requests whose
|
|
6
|
+
* agent belongs to the WeChat session and delegates everything else with
|
|
7
|
+
* `next()`.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
10
|
+
import type { ClawbotConfig } from "./config.js";
|
|
11
|
+
import type { WechatBridge } from "./bridge.js";
|
|
12
|
+
import { PendingRegistry } from "./pending.js";
|
|
13
|
+
export declare class ApprovalRelay {
|
|
14
|
+
private readonly config;
|
|
15
|
+
private readonly getBridge;
|
|
16
|
+
private readonly pending;
|
|
17
|
+
private readonly sendText;
|
|
18
|
+
constructor(deps: {
|
|
19
|
+
config: ClawbotConfig;
|
|
20
|
+
/** Returns the live bridge, or null while the monitor is not running. */
|
|
21
|
+
getBridge: () => WechatBridge | null;
|
|
22
|
+
pending: PendingRegistry;
|
|
23
|
+
sendText: (to: string, text: string) => Promise<void>;
|
|
24
|
+
});
|
|
25
|
+
/** Register the `approval/request` waterfall listener on the root context. */
|
|
26
|
+
register(ctx: Context): void;
|
|
27
|
+
private answer;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=approvals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiB/C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8C;gBAE3D,IAAI,EAAE;QAChB,MAAM,EAAE,aAAa,CAAC;QACtB,yEAAyE;QACzE,SAAS,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;QACrC,OAAO,EAAE,eAAe,CAAC;QACzB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACvD;IAOD,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;YAMd,MAAM;CAkErB"}
|