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.
Files changed (167) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +32 -0
  3. package/README.md +324 -0
  4. package/README.zh.md +192 -0
  5. package/cordis.patch.yml +23 -0
  6. package/lib/approvals.d.ts +29 -0
  7. package/lib/approvals.d.ts.map +1 -0
  8. package/lib/approvals.js +86 -0
  9. package/lib/approvals.js.map +1 -0
  10. package/lib/bridge.d.ts +281 -0
  11. package/lib/bridge.d.ts.map +1 -0
  12. package/lib/bridge.js +827 -0
  13. package/lib/bridge.js.map +1 -0
  14. package/lib/claude-peer.d.ts +44 -0
  15. package/lib/claude-peer.d.ts.map +1 -0
  16. package/lib/claude-peer.js +515 -0
  17. package/lib/claude-peer.js.map +1 -0
  18. package/lib/cli.d.ts +3 -0
  19. package/lib/cli.d.ts.map +1 -0
  20. package/lib/cli.js +128 -0
  21. package/lib/cli.js.map +1 -0
  22. package/lib/client.js +597 -0
  23. package/lib/config.d.ts +160 -0
  24. package/lib/config.d.ts.map +1 -0
  25. package/lib/config.js +187 -0
  26. package/lib/config.js.map +1 -0
  27. package/lib/emoji.d.ts +26 -0
  28. package/lib/emoji.d.ts.map +1 -0
  29. package/lib/emoji.js +54 -0
  30. package/lib/emoji.js.map +1 -0
  31. package/lib/ilink/api/api.d.ts +134 -0
  32. package/lib/ilink/api/api.d.ts.map +1 -0
  33. package/lib/ilink/api/api.js +507 -0
  34. package/lib/ilink/api/api.js.map +1 -0
  35. package/lib/ilink/api/session-guard.d.ts +16 -0
  36. package/lib/ilink/api/session-guard.d.ts.map +1 -0
  37. package/lib/ilink/api/session-guard.js +49 -0
  38. package/lib/ilink/api/session-guard.js.map +1 -0
  39. package/lib/ilink/api/types.d.ts +251 -0
  40. package/lib/ilink/api/types.d.ts.map +1 -0
  41. package/lib/ilink/api/types.js +37 -0
  42. package/lib/ilink/api/types.js.map +1 -0
  43. package/lib/ilink/auth/accounts.d.ts +67 -0
  44. package/lib/ilink/auth/accounts.d.ts.map +1 -0
  45. package/lib/ilink/auth/accounts.js +190 -0
  46. package/lib/ilink/auth/accounts.js.map +1 -0
  47. package/lib/ilink/auth/login-qr.d.ts +43 -0
  48. package/lib/ilink/auth/login-qr.d.ts.map +1 -0
  49. package/lib/ilink/auth/login-qr.js +333 -0
  50. package/lib/ilink/auth/login-qr.js.map +1 -0
  51. package/lib/ilink/cdn/aes-ecb.d.ts +7 -0
  52. package/lib/ilink/cdn/aes-ecb.d.ts.map +1 -0
  53. package/lib/ilink/cdn/aes-ecb.js +19 -0
  54. package/lib/ilink/cdn/aes-ecb.js.map +1 -0
  55. package/lib/ilink/cdn/cdn-upload.d.ts +18 -0
  56. package/lib/ilink/cdn/cdn-upload.d.ts.map +1 -0
  57. package/lib/ilink/cdn/cdn-upload.js +90 -0
  58. package/lib/ilink/cdn/cdn-upload.js.map +1 -0
  59. package/lib/ilink/cdn/cdn-url.d.ts +14 -0
  60. package/lib/ilink/cdn/cdn-url.d.ts.map +1 -0
  61. package/lib/ilink/cdn/cdn-url.js +14 -0
  62. package/lib/ilink/cdn/cdn-url.js.map +1 -0
  63. package/lib/ilink/cdn/pic-decrypt.d.ts +10 -0
  64. package/lib/ilink/cdn/pic-decrypt.d.ts.map +1 -0
  65. package/lib/ilink/cdn/pic-decrypt.js +89 -0
  66. package/lib/ilink/cdn/pic-decrypt.js.map +1 -0
  67. package/lib/ilink/cdn/upload.d.ts +43 -0
  68. package/lib/ilink/cdn/upload.d.ts.map +1 -0
  69. package/lib/ilink/cdn/upload.js +115 -0
  70. package/lib/ilink/cdn/upload.js.map +1 -0
  71. package/lib/ilink/media/mime.d.ts +7 -0
  72. package/lib/ilink/media/mime.d.ts.map +1 -0
  73. package/lib/ilink/media/mime.js +73 -0
  74. package/lib/ilink/media/mime.js.map +1 -0
  75. package/lib/ilink/messaging/send-media.d.ts +23 -0
  76. package/lib/ilink/messaging/send-media.d.ts.map +1 -0
  77. package/lib/ilink/messaging/send-media.js +71 -0
  78. package/lib/ilink/messaging/send-media.js.map +1 -0
  79. package/lib/ilink/messaging/send.d.ts +55 -0
  80. package/lib/ilink/messaging/send.d.ts.map +1 -0
  81. package/lib/ilink/messaging/send.js +182 -0
  82. package/lib/ilink/messaging/send.js.map +1 -0
  83. package/lib/ilink/storage/state-dir.d.ts +14 -0
  84. package/lib/ilink/storage/state-dir.d.ts.map +1 -0
  85. package/lib/ilink/storage/state-dir.js +22 -0
  86. package/lib/ilink/storage/state-dir.js.map +1 -0
  87. package/lib/ilink/storage/sync-buf.d.ts +21 -0
  88. package/lib/ilink/storage/sync-buf.d.ts.map +1 -0
  89. package/lib/ilink/storage/sync-buf.js +64 -0
  90. package/lib/ilink/storage/sync-buf.js.map +1 -0
  91. package/lib/ilink/util/logger.d.ts +20 -0
  92. package/lib/ilink/util/logger.d.ts.map +1 -0
  93. package/lib/ilink/util/logger.js +73 -0
  94. package/lib/ilink/util/logger.js.map +1 -0
  95. package/lib/ilink/util/random.d.ts +11 -0
  96. package/lib/ilink/util/random.d.ts.map +1 -0
  97. package/lib/ilink/util/random.js +16 -0
  98. package/lib/ilink/util/random.js.map +1 -0
  99. package/lib/ilink/util/redact.d.ts +21 -0
  100. package/lib/ilink/util/redact.d.ts.map +1 -0
  101. package/lib/ilink/util/redact.js +54 -0
  102. package/lib/ilink/util/redact.js.map +1 -0
  103. package/lib/image-compress.d.ts +38 -0
  104. package/lib/image-compress.d.ts.map +1 -0
  105. package/lib/image-compress.js +184 -0
  106. package/lib/image-compress.js.map +1 -0
  107. package/lib/inbound-media.d.ts +17 -0
  108. package/lib/inbound-media.d.ts.map +1 -0
  109. package/lib/inbound-media.js +96 -0
  110. package/lib/inbound-media.js.map +1 -0
  111. package/lib/inbound.d.ts +28 -0
  112. package/lib/inbound.d.ts.map +1 -0
  113. package/lib/inbound.js +265 -0
  114. package/lib/inbound.js.map +1 -0
  115. package/lib/index.d.ts +23 -0
  116. package/lib/index.d.ts.map +1 -0
  117. package/lib/index.js +321 -0
  118. package/lib/index.js.map +1 -0
  119. package/lib/mcp-route.d.ts +33 -0
  120. package/lib/mcp-route.d.ts.map +1 -0
  121. package/lib/mcp-route.js +422 -0
  122. package/lib/mcp-route.js.map +1 -0
  123. package/lib/memory-auto.d.ts +22 -0
  124. package/lib/memory-auto.d.ts.map +1 -0
  125. package/lib/memory-auto.js +144 -0
  126. package/lib/memory-auto.js.map +1 -0
  127. package/lib/memory.d.ts +26 -0
  128. package/lib/memory.d.ts.map +1 -0
  129. package/lib/memory.js +168 -0
  130. package/lib/memory.js.map +1 -0
  131. package/lib/models-route.d.ts +24 -0
  132. package/lib/models-route.d.ts.map +1 -0
  133. package/lib/models-route.js +84 -0
  134. package/lib/models-route.js.map +1 -0
  135. package/lib/monitor.d.ts +13 -0
  136. package/lib/monitor.d.ts.map +1 -0
  137. package/lib/monitor.js +116 -0
  138. package/lib/monitor.js.map +1 -0
  139. package/lib/pending.d.ts +23 -0
  140. package/lib/pending.d.ts.map +1 -0
  141. package/lib/pending.js +38 -0
  142. package/lib/pending.js.map +1 -0
  143. package/lib/prompt.d.ts +36 -0
  144. package/lib/prompt.d.ts.map +1 -0
  145. package/lib/prompt.js +246 -0
  146. package/lib/prompt.js.map +1 -0
  147. package/lib/questions.d.ts +21 -0
  148. package/lib/questions.d.ts.map +1 -0
  149. package/lib/questions.js +116 -0
  150. package/lib/questions.js.map +1 -0
  151. package/lib/quote-history.d.ts +18 -0
  152. package/lib/quote-history.d.ts.map +1 -0
  153. package/lib/quote-history.js +96 -0
  154. package/lib/quote-history.js.map +1 -0
  155. package/lib/state.d.ts +27 -0
  156. package/lib/state.d.ts.map +1 -0
  157. package/lib/state.js +154 -0
  158. package/lib/state.js.map +1 -0
  159. package/lib/subagent-model.d.ts +26 -0
  160. package/lib/subagent-model.d.ts.map +1 -0
  161. package/lib/subagent-model.js +30 -0
  162. package/lib/subagent-model.js.map +1 -0
  163. package/lib/tool.d.ts +14 -0
  164. package/lib/tool.d.ts.map +1 -0
  165. package/lib/tool.js +518 -0
  166. package/lib/tool.js.map +1 -0
  167. package/package.json +94 -0
package/lib/index.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * wechat-clawbot — DeepSeek Harness ⇄ WeChat (official ClawBot bridge).
3
+ *
4
+ * A DSH plugin bundle that connects a profile to the user's WeChat through
5
+ * Tencent's iLink API (the same protocol the official WeChat ClawBot channel
6
+ * uses). Inbound WeChat messages are routed into one fixed agent session;
7
+ * assistant replies and approval requests are sent back to WeChat.
8
+ *
9
+ * @module wechat-clawbot
10
+ */
11
+ import type { Context } from "@deepseek-ai/cordis";
12
+ import { type ClawbotConfig } from "./config.js";
13
+ /** Stable Cordis plugin name for the clawbot row. */
14
+ export declare const name = "clawbot";
15
+ /**
16
+ * Services the plugin uses directly. `agentPresets` and `userQuestions` are
17
+ * deliberately NOT listed: they are optional (agent-presets only ships with
18
+ * web/headless bundles) and are accessed defensively instead.
19
+ */
20
+ export declare const inject: string[];
21
+ export { Config } from "./config.js";
22
+ export declare function apply(ctx: Context, rawConfig?: Partial<ClawbotConfig>): () => Promise<void>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,EAAuC,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAuBtF,qDAAqD;AACrD,eAAO,MAAM,IAAI,YAAY,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAAkD,CAAC;AAKtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CA4S3F"}
package/lib/index.js ADDED
@@ -0,0 +1,321 @@
1
+ import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
2
+ import { Config, normalizeConfig, HOT_FIELDS } from "./config.js";
3
+ import { WechatBridge } from "./bridge.js";
4
+ import { InboundRouter } from "./inbound.js";
5
+ import { ApprovalRelay } from "./approvals.js";
6
+ import { tryRegisterQuestionProvider } from "./questions.js";
7
+ import { runMonitor } from "./monitor.js";
8
+ import { PendingRegistry } from "./pending.js";
9
+ import { watchAccountStore } from "./state.js";
10
+ import { registerWechatGuidanceGlobal } from "./prompt.js";
11
+ import { registerSubagentModelPolicy } from "./subagent-model.js";
12
+ import { registerModelsRoute } from "./models-route.js";
13
+ import { registerMcpRoutes } from "./mcp-route.js";
14
+ import { ensureMemoryFile } from "./memory.js";
15
+ import { resolveWeixinAccount, setBotAgent, listIndexedWeixinAccountIds, } from "./ilink/auth/accounts.js";
16
+ import { sendMessageWeixin } from "./ilink/messaging/send.js";
17
+ import { stripEmoji, stripWechatCodes } from "./emoji.js";
18
+ import { setLogLevel, logger } from "./ilink/util/logger.js";
19
+ /** Stable Cordis plugin name for the clawbot row. */
20
+ export const name = "clawbot";
21
+ /**
22
+ * Services the plugin uses directly. `agentPresets` and `userQuestions` are
23
+ * deliberately NOT listed: they are optional (agent-presets only ships with
24
+ * web/headless bundles) and are accessed defensively instead.
25
+ */
26
+ export const inject = ["agents", "sessions", "tools", "systemPrompt"];
27
+ // Re-exported so cordis finds the schema on the plugin module: it is what the
28
+ // settings page renders as a form, and what validates a change before the
29
+ // update hook below ever sees it.
30
+ export { Config } from "./config.js";
31
+ export function apply(ctx, rawConfig) {
32
+ const config = normalizeConfig(rawConfig);
33
+ setLogLevel(config.logLevel);
34
+ setBotAgent(config.botAgent);
35
+ // Put this plugin's config on the settings page, and adopt what can be
36
+ // adopted without tearing anything down.
37
+ //
38
+ // `installSettingsSection` is the sanctioned wiring for an OPTIONAL settings
39
+ // service: it registers the namespace with this plugin's cordis row as the
40
+ // `base` layer (so `cordis.patch.yml` stays the composition default and the
41
+ // settings document only carries overrides), points a thunk at whichever of
42
+ // the two is currently authoritative, and calls `onChange` after every
43
+ // committed change. Where no settings service is mounted, none of it runs and
44
+ // the plugin behaves exactly as composed.
45
+ //
46
+ // Not `internal/update`: that fires for cordis-level config edits, which
47
+ // restart the fiber by design. This is the live surface.
48
+ //
49
+ // Mutating `config` in place is what makes adoption work at all: bridge,
50
+ // inbound, approvals and the tools each hold a reference to this same object
51
+ // and read the field at the moment they use it. Replacing the reference would
52
+ // update nobody.
53
+ // The base layer must be an IMMUTABLE snapshot of the cordis row, never the
54
+ // live `config` object. Passing the live one makes hot-apply mutate the base
55
+ // as a side effect: clearing an override in the UI then "resets" to whatever
56
+ // was last applied instead of to what the profile composed. (Observed: set
57
+ // quality to 85, clear the field, and it fell back to 85.)
58
+ const composed = normalizeConfig(rawConfig);
59
+ let readSettings;
60
+ const adoptSettings = () => {
61
+ if (readSettings === undefined)
62
+ return;
63
+ const incoming = normalizeConfig(readSettings());
64
+ const changed = Object.keys(incoming)
65
+ .filter((key) => JSON.stringify(incoming[key]) !== JSON.stringify(config[key]));
66
+ if (changed.length === 0)
67
+ return;
68
+ const hot = changed.filter((key) => HOT_FIELDS.has(key));
69
+ const cold = changed.filter((key) => !HOT_FIELDS.has(key));
70
+ // Copy the HOT fields only, one by one — never `Object.assign` the whole
71
+ // incoming object. A cold field taking effect the instant it is typed is
72
+ // exactly what this design promises not to do: `apiBaseUrl` would redirect
73
+ // a connected client mid-flight, `sessionId` would point the bridge at a
74
+ // session it is not bound to. They are stored, and the next start reads them.
75
+ //
76
+ // Cold fields are also deliberately not auto-restarted: reloading this fiber
77
+ // from inside its own change hook is a re-entrancy hazard, and a WeChat
78
+ // monitor that drops itself as each keystroke lands is worse than one that
79
+ // waits to be told. The card says so, and /restart applies them.
80
+ for (const key of hot)
81
+ config[key] = incoming[key];
82
+ // The one hot field with a side effect beyond the config object: the logger
83
+ // captured its level at startup, so an in-place change is invisible.
84
+ if (hot.includes("logLevel"))
85
+ setLogLevel(config.logLevel);
86
+ if (hot.length > 0)
87
+ logger.info(`设置已即时生效 [${hot.join(", ")}](没有重启,微信监听未中断)`);
88
+ // Re-point the live model selection. Separate from the field copy above
89
+ // because it validates the model id before switching — a typo in the
90
+ // settings box must not brick the next message.
91
+ if (hot.some((key) => key === "provider" || key === "model" || key === "reasoningEffort")) {
92
+ void bridge?.refreshSelection().catch((err) => {
93
+ logger.warn(`refreshSelection 失败: ${String(err)}`);
94
+ });
95
+ }
96
+ if (cold.length > 0)
97
+ logger.info(`设置已保存 [${cold.join(", ")}],但要等重启才生效(/restart 或小鲸鱼的重启按钮)`);
98
+ };
99
+ // Put this plugin's config on the settings page, and adopt what can be
100
+ // adopted without tearing anything down.
101
+ //
102
+ // `installSettingsSection` is the sanctioned wiring for an OPTIONAL settings
103
+ // service: it registers the namespace with the composed cordis row as the
104
+ // `base` layer (so `cordis.patch.yml` stays the default and the settings
105
+ // document carries only overrides), points a thunk at whichever of the two is
106
+ // authoritative, and calls `onChange` after every committed change. Where no
107
+ // settings service is mounted, none of it runs and the plugin behaves exactly
108
+ // as composed.
109
+ //
110
+ // Adopting from BOTH hooks is belt-and-braces. `setSource` runs when the
111
+ // authoritative source changes (scope attaches or detaches), `onChange` after
112
+ // a committed change; in practice attach pairs the two, so a value already in
113
+ // settings.yaml is picked up at startup either way. Nothing here depends on
114
+ // that pairing holding, and adoption is idempotent — a redundant call costs
115
+ // one no-op diff.
116
+ //
117
+ // Not `internal/update`: that fires for cordis-level config edits, which
118
+ // restart the fiber by design. This is the live surface.
119
+ installSettingsSection(ctx, settingsNamespace("clawbot"), Config, composed, {
120
+ setSource(current) {
121
+ readSettings = current;
122
+ adoptSettings();
123
+ },
124
+ onChange() {
125
+ adoptSettings();
126
+ },
127
+ });
128
+ // Register the WeChat conversation guidance GLOBALLY with a dynamic text
129
+ // provider: it yields the rules ONLY for the WeChat session (by session id),
130
+ // and an empty string for every other DSH conversation, so unrelated GUI
131
+ // sessions are never affected. This covers agents that the harness resumes
132
+ // directly from GUI messages without running the bridge's agent setup.
133
+ try {
134
+ registerWechatGuidanceGlobal(ctx, config.sessionId, config);
135
+ logger.info(`clawbot: wechat guidance registered globally (session=${config.sessionId})`);
136
+ }
137
+ catch (err) {
138
+ logger.warn(`clawbot: global guidance registration failed: ${String(err)}`);
139
+ }
140
+ // The settings card's dropdowns need a model catalogue; publish one.
141
+ registerModelsRoute(ctx);
142
+ // Long-term user memory (Claude-Desktop style): seed the memory file so the
143
+ // dynamic memory section (registered above, order 79) has content to inject.
144
+ ensureMemoryFile();
145
+ // Subagents delegated from the WeChat session run with max thinking:
146
+ // the main conversation is reasoningEffort=off for fast replies, but deep
147
+ // delegated tasks get full reasoning on the same v4-flash model.
148
+ try {
149
+ registerSubagentModelPolicy(ctx, {
150
+ sessionId: config.sessionId,
151
+ provider: "deepseek-official",
152
+ model: "deepseek-v4-flash",
153
+ reasoningEffort: "max",
154
+ });
155
+ logger.info(`clawbot: subagent max-thinking policy registered (parent=${config.sessionId})`);
156
+ }
157
+ catch (err) {
158
+ logger.warn(`clawbot: subagent model policy registration failed: ${String(err)}`);
159
+ }
160
+ const pending = new PendingRegistry();
161
+ let bridge = null;
162
+ let router = null;
163
+ let monitorTask = null;
164
+ let currentAccount = null;
165
+ /** Fresh per monitor start (an aborted controller cannot be reused). */
166
+ let abort = new AbortController();
167
+ // Session event feed: assistant replies for the WeChat session. Attached
168
+ // once for the plugin lifetime; the bridge is looked up per event.
169
+ ctx.on("session/event", (session, event) => {
170
+ bridge?.onSessionEvent(session, event);
171
+ });
172
+ /** Send a text message back to one WeChat user through the bound account. */
173
+ const sendText = async (to, text) => {
174
+ if (!currentAccount?.configured)
175
+ throw new Error("no bound WeChat account");
176
+ // Bracket codes go either way — see src/emoji.ts.
177
+ const finalText = config.stripEmoji ? stripEmoji(text) : stripWechatCodes(text);
178
+ if (!finalText)
179
+ return;
180
+ await sendMessageWeixin({
181
+ to,
182
+ text: finalText,
183
+ opts: {
184
+ baseUrl: currentAccount.baseUrl,
185
+ token: currentAccount.token,
186
+ contextToken: router?.contextTokenFor(to) ?? undefined,
187
+ timeoutMs: 15_000,
188
+ },
189
+ });
190
+ };
191
+ // Bridge routes for the local MCP server: list/read/drive sessions, and push
192
+ // one WeChat message to the owner. Registered here rather than beside
193
+ // registerModelsRoute because it needs `sendText` and the account getter,
194
+ // both defined just above.
195
+ registerMcpRoutes(ctx, { config, sendText, getAccount: () => currentAccount });
196
+ /** Pick the first bound account (v1 supports a single account). */
197
+ const pickAccount = () => {
198
+ const ids = listIndexedWeixinAccountIds();
199
+ if (ids.length === 0)
200
+ return null;
201
+ try {
202
+ return resolveWeixinAccount(ids[0]);
203
+ }
204
+ catch (err) {
205
+ logger.warn(`pickAccount: ${String(err)}`);
206
+ return null;
207
+ }
208
+ };
209
+ /** Start the monitor for the current account (idempotent). */
210
+ const startMonitor = () => {
211
+ if (monitorTask)
212
+ return;
213
+ const account = pickAccount();
214
+ if (!account) {
215
+ logger.info("startMonitor: no bound account; waiting for `clawbot login`");
216
+ return;
217
+ }
218
+ if (!account.configured) {
219
+ logger.info("startMonitor: account not configured (no token)");
220
+ return;
221
+ }
222
+ currentAccount = account;
223
+ bridge = new WechatBridge(ctx, config, sendText, {
224
+ getAccount: () => currentAccount,
225
+ getContextToken: (sender) => router?.contextTokenFor(sender) ?? "",
226
+ pending,
227
+ });
228
+ router = new InboundRouter({
229
+ config,
230
+ account,
231
+ bridge,
232
+ pending,
233
+ sendText,
234
+ });
235
+ abort = new AbortController();
236
+ const signal = abort.signal;
237
+ monitorTask = runMonitor({
238
+ account,
239
+ signal,
240
+ onMessage: (msg) => router.handle(msg),
241
+ onStop: (reason) => {
242
+ logger.warn(`monitor stopped: ${reason}`);
243
+ void stopMonitor(reason);
244
+ },
245
+ });
246
+ monitorTask.catch((err) => {
247
+ logger.error(`monitor crashed: ${String(err)}`);
248
+ void stopMonitor(`monitor crashed: ${String(err)}`);
249
+ });
250
+ // 可选服务只能这样拿:回调只在真有这些服务的组合里触发,不会变成硬依赖。
251
+ const boundBridge = bridge;
252
+ if (boundBridge) {
253
+ ctx.inject(["llm", "attachments"], (scoped) => { boundBridge.useVisionServices(scoped); });
254
+ }
255
+ logger.info(`startMonitor: monitoring account=${account.accountId}`);
256
+ // 定时提醒是 session-local 的:dsh-schedule 的定时器只在这个会话的 agent
257
+ // 活着的时候存在。而 agent 过去是懒创建的 —— 只有收到微信消息才建。于是
258
+ // 每次重启都会静默解除所有待触发的提醒,直到下一条消息进来才重新武装:
259
+ // 2026-08-21 那条设在 09:00 的提醒,因为 07:43 重启、而下一条消息是 11:03,
260
+ // 就迟了两个多小时才以"逾期"的形式补发。
261
+ // 所以启动时就把 agent 预热出来,让待触发的提醒从开机起就是武装状态。
262
+ void bridge?.ensureAgent().then(async () => {
263
+ logger.info("startMonitor: agent warmed at startup (pending reminders armed)");
264
+ // 现在 installSelection() 已经跑过,路由才是真的,自检结果才可信。
265
+ await boundBridge?.reportVisionReadiness();
266
+ }, (err) => logger.warn(`startMonitor: agent warm-up failed: ${String(err)}`));
267
+ };
268
+ /** Stop the monitor and release the agent handle (idempotent). */
269
+ const stopMonitor = async (reason) => {
270
+ if (!monitorTask)
271
+ return;
272
+ logger.info(`stopMonitor: ${reason}`);
273
+ abort.abort();
274
+ try {
275
+ await monitorTask;
276
+ }
277
+ catch (err) {
278
+ logger.warn(`stopMonitor: task error ${String(err)}`);
279
+ }
280
+ monitorTask = null;
281
+ await bridge?.dispose();
282
+ bridge = null;
283
+ router = null;
284
+ currentAccount = null;
285
+ pending.abortAll();
286
+ };
287
+ // Approval questions for WeChat sessions arrive in WeChat.
288
+ const relay = new ApprovalRelay({
289
+ config,
290
+ getBridge: () => bridge,
291
+ pending,
292
+ sendText,
293
+ });
294
+ relay.register(ctx);
295
+ // Optional ask_user_question / plan-review forwarding.
296
+ tryRegisterQuestionProvider({
297
+ ctx,
298
+ config,
299
+ pending,
300
+ sendText,
301
+ primaryUser: () => currentAccount?.userId,
302
+ });
303
+ // React to `clawbot login` / `clawbot logout` while the profile is running.
304
+ const watcher = watchAccountStore(() => {
305
+ const ids = listIndexedWeixinAccountIds();
306
+ if (ids.length === 0) {
307
+ void stopMonitor("account removed (logout)");
308
+ }
309
+ else if (!monitorTask) {
310
+ startMonitor();
311
+ }
312
+ });
313
+ if (config.autoStart)
314
+ startMonitor();
315
+ return async () => {
316
+ logger.info("plugin unload: stopping clawbot");
317
+ watcher.close();
318
+ await stopMonitor("plugin unload");
319
+ };
320
+ }
321
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAqB,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO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O,EAAE,CAAC;QACxB,MAAM,GAAG,IAAI,CAAC;QACd,MAAM,GAAG,IAAI,CAAC;QACd,cAAc,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC,CAAC;IAEF,2DAA2D;IAC3D,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC;QAC9B,MAAM;QACN,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;IACH,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEpB,uDAAuD;IACvD,2BAA2B,CAAC;QAC1B,GAAG;QACH,MAAM;QACN,OAAO;QACP,QAAQ;QACR,WAAW,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,MAAM;KAC1C,CAAC,CAAC;IAEH,4EAA4E;IAC5E,MAAM,OAAO,GAAiB,iBAAiB,CAAC,GAAG,EAAE;QACnD,MAAM,GAAG,GAAG,2BAA2B,EAAE,CAAC;QAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,KAAK,WAAW,CAAC,0BAA0B,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACxB,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,SAAS;QAAE,YAAY,EAAE,CAAC;IAErC,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { ResolvedWeixinAccount } from "./ilink/auth/accounts.js";
3
+ /** What the route module needs from the plugin body. */
4
+ export type McpRouteDeps = {
5
+ /**
6
+ * The LIVE config object, held by reference so `mcpBridge` can be flipped
7
+ * from the settings page without a restart. Read at request time, never
8
+ * snapshotted here.
9
+ */
10
+ config: {
11
+ mcpBridge: boolean;
12
+ };
13
+ /** Send one plain-text WeChat message (applies the emoji policy). */
14
+ sendText: (to: string, text: string) => Promise<void>;
15
+ /** The currently bound account, or null before `clawbot login`. */
16
+ getAccount: () => ResolvedWeixinAccount | null;
17
+ };
18
+ /**
19
+ * Read the shared secret, generating it on first use.
20
+ *
21
+ * `mode` on `writeFileSync` only applies when the file is created, so the
22
+ * chmod is unconditional — a token file left at 0644 by an earlier build would
23
+ * otherwise stay world-readable forever.
24
+ */
25
+ export declare function ensureMcpToken(): string;
26
+ /**
27
+ * Register the four routes.
28
+ *
29
+ * `webServer` goes through `ctx.inject` so a headless composition without it
30
+ * simply has no bridge, rather than failing the whole plugin tree.
31
+ */
32
+ export declare function registerMcpRoutes(ctx: Context, deps: McpRouteDeps): void;
33
+ //# sourceMappingURL=mcp-route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-route.d.ts","sourceRoot":"","sources":["../src/mcp-route.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAatE,wDAAwD;AACxD,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,MAAM,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAC/B,qEAAqE;IACrE,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,mEAAmE;IACnE,UAAU,EAAE,MAAM,qBAAqB,GAAG,IAAI,CAAC;CAChD,CAAC;AAiBF;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAiBvC;AA4SD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CA4FxE"}