dsh-world 0.7.1 → 0.7.3

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 (76) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/INSTALL.md +314 -314
  3. package/LICENSE +21 -21
  4. package/NOTES.md +34 -15
  5. package/README.md +22 -8
  6. package/client/index.js +85 -28
  7. package/cordis.patch.yml +6 -6
  8. package/lib/archiveSelection.d.ts +6 -2
  9. package/lib/archiveSelection.js +21 -12
  10. package/lib/compaction.d.ts +7 -0
  11. package/lib/compaction.js +16 -7
  12. package/lib/console/routes.d.ts +4 -3
  13. package/lib/console/routes.js +18 -12
  14. package/lib/console/snapshot.d.ts +3 -3
  15. package/lib/console/snapshot.js +1 -4
  16. package/lib/ecosystem/bridge/bridge.d.ts +5 -0
  17. package/lib/ecosystem/bridge/bridge.js +2 -1
  18. package/lib/ecosystem/bridge/route.d.ts +4 -6
  19. package/lib/ecosystem/bridge/route.js +34 -58
  20. package/lib/ecosystem/qq/panel.d.ts +0 -1
  21. package/lib/ecosystem/qq/route.d.ts +6 -7
  22. package/lib/ecosystem/qq/route.js +10 -10
  23. package/lib/ecosystem/qq/snowluma-start.d.ts +1 -0
  24. package/lib/ecosystem/qq/snowluma-start.js +41 -8
  25. package/lib/ecosystem/qq/supervisor.d.ts +1 -2
  26. package/lib/ecosystem/qq/supervisor.js +4 -2
  27. package/lib/ecosystem/qq-native/home.d.ts +1 -0
  28. package/lib/ecosystem/qq-native/home.js +10 -3
  29. package/lib/ecosystem/qq-native/index.js +19 -4
  30. package/lib/ecosystem/qq-native/native-bridge.d.ts +0 -1
  31. package/lib/ecosystem/qq-native/native-bridge.js +5 -4
  32. package/lib/ecosystem/qq-native/replies.d.ts +3 -2
  33. package/lib/ecosystem/qq-native/replies.js +15 -4
  34. package/lib/ecosystem/qq-native/snowluma.js +11 -2
  35. package/lib/ecosystem/shared/context.d.ts +5 -0
  36. package/lib/ecosystem/shared/context.js +5 -0
  37. package/lib/ecosystem/wechat/index.d.ts +0 -1
  38. package/lib/ecosystem/wechat/index.js +6 -5
  39. package/lib/hostContract.d.ts +17 -1
  40. package/lib/index.d.ts +1 -0
  41. package/lib/index.js +126 -47
  42. package/lib/life/toolRegistry.js +2 -2
  43. package/lib/memoryFiles.d.ts +0 -1
  44. package/lib/memoryStore.d.ts +0 -1
  45. package/lib/memoryStore.js +0 -1
  46. package/lib/memoryTools.d.ts +0 -1
  47. package/lib/memoryTools.js +2 -3
  48. package/lib/promptSection.d.ts +10 -7
  49. package/lib/promptSection.js +80 -33
  50. package/lib/runtime.d.ts +12 -3
  51. package/lib/runtime.js +150 -29
  52. package/lib/sourceArchive.d.ts +4 -2
  53. package/lib/sourceArchive.js +19 -5
  54. package/lib/store.js +2 -1
  55. package/lib/types.d.ts +1 -1
  56. package/lib/worldPrompt.d.ts +2 -3
  57. package/lib/worldPrompt.js +2 -3
  58. package/lib/worldRoutes.d.ts +9 -0
  59. package/lib/worldRoutes.js +29 -0
  60. package/lib/worldScope.d.ts +5 -5
  61. package/lib/worldScope.js +16 -7
  62. package/lib/worldSwitch.d.ts +7 -2
  63. package/lib/worldSwitch.js +11 -1
  64. package/package.json +17 -16
  65. package/scripts/compact-home.mjs +29 -29
  66. package/scripts/enable-tool-free-compaction.ps1 +33 -33
  67. package/scripts/import-stickers.mjs +17 -17
  68. package/scripts/update-world.mjs +2 -2
  69. package/src/ecosystem/README.md +1 -1
  70. package/src/ecosystem/wechat/windows/README.md +6 -4
  71. package/src/ecosystem/wechat/windows/adapter.py +4 -2
  72. package/src/ecosystem/wechat/windows/engine/NOTICE.md +6 -0
  73. package/src/ecosystem/wechat/windows/engine/profiles.json +142 -114
  74. package/src/ecosystem/wechat/windows/presence.py +109 -109
  75. package/templates/alarm.md +2 -2
  76. package/templates/world-prompt.md +8 -2
@@ -1,10 +1,12 @@
1
1
  import { createUserMessage } from '@deepseek-ai/dsh-llm';
2
2
  import { identityPrefix, speakerIdentity } from "../shared/identity.js";
3
- import { channelContext, CONTEXT_IDENTITY_NOTE, contextJson } from "../shared/context.js";
3
+ import { channelContext, CONTEXT_END_NOTE, CONTEXT_IDENTITY_NOTE, contextJson } from "../shared/context.js";
4
4
  import { askTurn, createChannelQueue } from "../shared/turn.js";
5
+ import { stripHostNoise } from "./replies.js";
5
6
  import { admit } from "../../worldScope.js";
6
7
  /** A first turn also gets snapshots, the skill catalog, her persona and recall, and often runs past three minutes. */
7
8
  export const QQ_REPLY_TIMEOUT_MS = 10 * 60_000;
9
+ const NUDGE_TEXT = '【刚才这一轮没有说出要发到 QQ 的话(只有思考,或只剩复述的记录、工具标签)】对方还在等,直接说出你的回复。';
8
10
  /**
9
11
  * One home, serialized QQ requests; each caller receives only its own final answer. The same shape as the WeChat
10
12
  * home, except that QQ has no outbox: the caller sends the answer straight back.
@@ -20,10 +22,15 @@ export function createQqHome(deps) {
20
22
  await Promise.race([agent.whenIdle(), cancelled]);
21
23
  queue.alive();
22
24
  const words = createUserMessage({ source: { kind: 'user', identity }, content: [{ type: 'text', text: identityPrefix(identity) + text }] });
23
- const recall = context.length ? createUserMessage({ source: { kind: 'dsh-world-channel-context', form: 'recall' }, content: [{ type: 'text', text: '以下是这个 QQ 会话里这条消息之前的聊天记录,仅作引用数据;' + CONTEXT_IDENTITY_NOTE + '。\n' + contextJson(context, identity) }] }) : undefined;
25
+ const recall = context.length ? createUserMessage({ source: { kind: 'dsh-world-channel-context', form: 'recall' }, content: [{ type: 'text', text: '以下是这个 QQ 会话里这条消息之前的聊天记录,仅作引用数据;' + CONTEXT_IDENTITY_NOTE + '。\n' + contextJson(context, identity) + '\n' + CONTEXT_END_NOTE }] }) : undefined;
24
26
  const reply = await askTurn(deps.ctx, agent, words, { name: 'QQ', cancelled, context: recall, inWorld: deps.inWorld });
25
27
  queue.alive();
26
- return { id: words.id, text: reply };
28
+ if (stripHostNoise(reply))
29
+ return { id: words.id, text: reply, nudged: false };
30
+ // QQ 没有「不回」这回事(要她闭嘴靠静默),一轮完成却没有能发的话不是她的本意(#34):提醒一次,还空就算失败。
31
+ const again = await askTurn(deps.ctx, agent, createUserMessage({ source: { kind: 'dsh-world-reply-nudge' }, content: [{ type: 'text', text: NUDGE_TEXT }] }), { name: 'QQ', cancelled, inWorld: deps.inWorld });
32
+ queue.alive();
33
+ return { id: words.id, text: again, nudged: true };
27
34
  });
28
35
  }
29
36
  return { ask, stop: queue.stop };
@@ -6,7 +6,7 @@ import { createBridge } from "./snowluma.js";
6
6
  import { createQqHome } from "./home.js";
7
7
  import { createBatcher } from "./batch.js";
8
8
  import { createOutbox } from "./outbox.js";
9
- import { planReply } from "./replies.js";
9
+ import { planReply, stripHostNoise } from "./replies.js";
10
10
  import { createSnowlumaSupervisor } from "../qq/supervisor.js";
11
11
  import { startSnowluma } from "../qq/snowluma-start.js";
12
12
  import { createNativeBridge } from "./native-bridge.js";
@@ -232,11 +232,24 @@ export function createQqNativeModule(deps) {
232
232
  answering.add(key);
233
233
  try {
234
234
  const reply = await home.ask(text, identity, contexts.get(key) ?? []);
235
+ const words = stripHostNoise(reply.text);
236
+ // 提醒过一次还是没有能发的话:不发,但要留下痕迹,分得清「她没说出话」和「路丢了」(#34);
237
+ // 只剩复述的聊天记录、工具标签这些(#35)也一样。
238
+ if (!words) {
239
+ stats.failed += 1;
240
+ stats.lastError = reply.text.trim()
241
+ ? '回复只有复述的聊天记录、来源头或工具标签,提醒过一次,过滤后仍没有能发的正文'
242
+ : '回复为空:提醒过一次,仍没有说出正文(可能只有思考)';
243
+ deps.logger.warn(`QQ 回复 ${key} ${reply.text.trim() ? '过滤后为空' : '为空'},提醒过一次,没有投递`);
244
+ return;
245
+ }
246
+ if (reply.nudged)
247
+ deps.logger.info(`QQ 回复 ${key} 第一次没有能发的话,提醒后说出了`);
235
248
  // 她那句话记成她自己说的:不然后面拿这段上下文问她「刚才聊到哪了」时,她说过的会被当成对方说的。
249
+ // 记过滤后的:复述的记录若回到上下文里,下一轮她更容易接着念。
236
250
  const herIdentity = speakerIdentity({ channel: 'qq', accountId: identity.accountId, speakerId: `qq:${identity.accountId}`, conversationId: identity.conversationId, conversationType: identity.conversationType });
237
- pushContext(key, { id: reply.id, occurredAt: new Date().toISOString(), text: reply.text, identity: herIdentity }, config.contextMessages);
238
- if (reply.text.trim())
239
- await say(isGroup ? 'group' : 'private', identity.conversationId, reply.text.trim());
251
+ pushContext(key, { id: reply.id, occurredAt: new Date().toISOString(), text: words, identity: herIdentity }, config.contextMessages);
252
+ await say(isGroup ? 'group' : 'private', identity.conversationId, words);
240
253
  }
241
254
  catch (error) {
242
255
  stats.failed += 1;
@@ -407,6 +420,8 @@ export function createQqNativeModule(deps) {
407
420
  startBridge(config);
408
421
  disposers.push(forwardOwnTurns());
409
422
  client.start().catch((error) => {
423
+ if (stopped)
424
+ return;
410
425
  stats.lastError = errorText(error);
411
426
  deps.logger.warn('QQ 原生通道首次连接失败:', stats.lastError);
412
427
  });
@@ -11,7 +11,6 @@ export interface BridgeConfig {
11
11
  title: string;
12
12
  contextMessages: number;
13
13
  }
14
- export declare const DEFAULT_BRIDGE_PORT = 0;
15
14
  export interface BridgeStatus {
16
15
  serving: boolean;
17
16
  port: number;
@@ -4,7 +4,9 @@ import { join } from 'node:path';
4
4
  import { WebSocketServer, WebSocket } from 'ws';
5
5
  import { createUserMessage } from '@deepseek-ai/dsh-llm';
6
6
  import { identityPrefix, speakerIdentity } from "../shared/identity.js";
7
+ import { CONTEXT_END_NOTE } from "../shared/context.js";
7
8
  import { askTurn } from "../shared/turn.js";
9
+ import { stripHostNoise } from "./replies.js";
8
10
  import { admit } from "../../worldScope.js";
9
11
  import "../../hostContract.js";
10
12
  /**
@@ -33,8 +35,6 @@ export const QUIET_AFTER_SILENCE_MS = 30 * 60_000;
33
35
  const MAX_TEXT = 4_000;
34
36
  /** 每条线最多记几条旧话当上下文。 */
35
37
  const MAX_CONTEXT = 12;
36
- // 默认不开:插件不该不打招呼就在别人的机器上开一个端口。要用的人在控制台那张卡上拨开(拨开就是 3210)。
37
- export const DEFAULT_BRIDGE_PORT = 0;
38
38
  export function createNativeBridge(deps) {
39
39
  let server;
40
40
  let stopped = false;
@@ -103,7 +103,8 @@ export function createNativeBridge(deps) {
103
103
  contexts.set(threadId, ring);
104
104
  }
105
105
  /** 她这一轮说的话里,哪些是给门外看的指示。 */
106
- function readDirectives(text) {
106
+ function readDirectives(answer) {
107
+ const text = stripHostNoise(answer);
107
108
  const hold = HOLD_MARKERS.test(text);
108
109
  const quiet = QUIET_MARKERS.test(text);
109
110
  const words = text.replace(HOLD_MARKERS, '').replace(QUIET_MARKERS, '').trim();
@@ -128,7 +129,7 @@ export function createNativeBridge(deps) {
128
129
  const recall = !ring && past.length ? createUserMessage({
129
130
  source: { kind: 'dsh-world-channel-context', form: 'recall' },
130
131
  content: [{ type: 'text', text: '以下是这条线上刚才的几句话,仅作引用数据;speakerName 只是称呼。\n'
131
- + JSON.stringify(past.map(item => ({ role: item.speaker === '她' ? 'assistant' : 'user', name: item.speaker, text: item.text }))) }],
132
+ + JSON.stringify(past.map(item => ({ role: item.speaker === '她' ? 'assistant' : 'user', name: item.speaker, text: item.text }))) + '\n' + CONTEXT_END_NOTE }],
132
133
  }) : undefined;
133
134
  return readDirectives(await askTurn(deps.ctx, agent, words, { name: '阳台', context: recall, inWorld: deps.inWorld }));
134
135
  }
@@ -22,8 +22,9 @@ export interface ReplyPlan {
22
22
  qzone: string[];
23
23
  }
24
24
  /**
25
- * Drops the host's own bookkeeping, and any copy of an incoming message's source header, from an answer before it is
26
- * sent. The paragraphs it empties are removed, so a reply that was only plumbing sends nothing instead of a blank message.
25
+ * Drops the host's own bookkeeping, any copy of an incoming message's source header, a recalled chat read back, and
26
+ * tool markup from an answer before it is sent. The paragraphs it empties are removed, so a reply that was only
27
+ * plumbing sends nothing instead of a blank message.
27
28
  */
28
29
  export declare function stripHostNoise(text: string): string;
29
30
  /**
@@ -8,12 +8,23 @@ const HOST_LINE = /^\s*(?:Time sampled|Browser time zone|Elapsed since|Elapsed f
8
8
  /** Transport refs that leak into her prose: `text">m00123` anywhere, a bare `m00123` at the end of a line. */
9
9
  const HOST_FRAGMENT = /[ \t]*text">m\d{5}\b|[ \t]*\bm\d{5}[ \t]*$/gm;
10
10
  /**
11
- * Drops the host's own bookkeeping, and any copy of an incoming message's source header, from an answer before it is
12
- * sent. The paragraphs it empties are removed, so a reply that was only plumbing sends nothing instead of a blank message.
11
+ * A tool call the model wrote out as text instead of calling (DeepSeek's `<|DSML|…>` markup). Everything from the
12
+ * first tag on is that call, not speech (#35).
13
+ */
14
+ const TOOL_MARKUP = /<\/?[||]+\s*DSML\s*[||]+[\s\S]*$/;
15
+ /**
16
+ * The plugin's own recalled chat read back aloud (#35): a framing line (each carries 仅作引用数据), a line that is the
17
+ * recalled JSON (a role or a speakerId inside brackets), or a bare transcript role label.
18
+ */
19
+ const RECALL_LINE = /仅作引用数据|^\s*[[{].*"(?:role|speakerId)"\s*:.*[}\]]\s*$|^\s*(?:user|assistant)\s*$/;
20
+ /**
21
+ * Drops the host's own bookkeeping, any copy of an incoming message's source header, a recalled chat read back, and
22
+ * tool markup from an answer before it is sent. The paragraphs it empties are removed, so a reply that was only
23
+ * plumbing sends nothing instead of a blank message.
13
24
  */
14
25
  export function stripHostNoise(text) {
15
- const kept = text.replace(/\r\n/g, '\n').replace(HOST_FRAGMENT, '').split('\n')
16
- .filter(line => !HOST_LINE.test(line) && !IDENTITY_HEADER_LINE.test(line.trim()));
26
+ const kept = text.replace(/\r\n/g, '\n').replace(TOOL_MARKUP, '').replace(HOST_FRAGMENT, '').split('\n')
27
+ .filter(line => !HOST_LINE.test(line) && !IDENTITY_HEADER_LINE.test(line.trim()) && !RECALL_LINE.test(line));
17
28
  return kept.join('\n').replace(/\n{3,}/g, '\n\n').trim();
18
29
  }
19
30
  /**
@@ -100,6 +100,14 @@
100
100
  /** @typedef {'connecting'|'online'|'closed'} BridgeState */
101
101
  import { SnowLumaTimeoutError, SnowLumaWebSocketClient, chain, parseSegments, } from '@snowluma/sdk';
102
102
  import WebSocket from 'ws';
103
+ class SnowlumaSocket extends WebSocket {
104
+ close(code, reason) {
105
+ // The SDK removes its error listener before closing, but ws emits an error when a handshake is cancelled.
106
+ if (this.readyState === WebSocket.CONNECTING)
107
+ this.once('error', () => { });
108
+ super.close(code, reason);
109
+ }
110
+ }
103
111
  // ── 常量 ──────────────────────────────────────────────────────
104
112
  const SEND_TIMEOUT_MS = 15000; // 单次发送的外层超时(切片第 6 节:SEND_TIMEOUT_MS = 15000)
105
113
  const DEFAULT_SEND_DELAY_MS = 500; // 串行发送间隔的默认值(见实现说明⑤)
@@ -504,7 +512,7 @@ export function createBridge(options) {
504
512
  const bot = new SnowLumaWebSocketClient({
505
513
  url: opts.wsUrl || DEFAULT_WS_URL,
506
514
  // Node 22's built-in WebSocket can error without close; ws lets the SDK settle failed connects.
507
- webSocket: WebSocket,
515
+ webSocket: SnowlumaSocket,
508
516
  // 空串会让鉴权头变成 `Bearer `,某些网关直接 401 —— 必须 || undefined(切片第 1 节)
509
517
  accessToken: opts.accessToken || undefined,
510
518
  requestTimeoutMs: 30000,
@@ -560,7 +568,8 @@ export function createBridge(options) {
560
568
  catch (error) {
561
569
  // 首连失败按契约 reject 得清楚;客户端保留,SDK reconnect 会按退避自动重试
562
570
  // (closed-before-opening 属于「非用户主动关闭」,重连条件成立),状态保持 connecting
563
- log('error', `首次连接失败: ${error?.message ?? error}(SDK 将按退避自动重连)`);
571
+ if (client === bot)
572
+ log('error', `首次连接失败: ${error?.message ?? error}(SDK 将按退避自动重连)`);
564
573
  throw error;
565
574
  }
566
575
  },
@@ -26,4 +26,9 @@ export declare function channelContext(value: unknown, current: SpeakerIdentity,
26
26
  export declare function channelMedia(value: unknown, current: SpeakerIdentity): ChannelContextMessage[];
27
27
  /** Tells the model how to read `contextJson`; shared by every channel that renders it. */
28
28
  export declare const CONTEXT_IDENTITY_NOTE = "identity \u53EA\u5217\u51FA\u6BCF\u4E2A\u53D1\u8A00\u4EBA\u5404\u81EA\u7684\u6765\u6E90\uFF08speakerId \u7B49\uFF09\uFF0C\u6E20\u9053\u3001\u8D26\u53F7\u548C\u4F1A\u8BDD\u4E0E\u89E6\u53D1\u8FD9\u6761\u6D88\u606F\u5F00\u5934\u3010\u3011\u91CC\u7684\u804A\u5929\u76F8\u540C\uFF1BspeakerName \u53EA\u662F\u79F0\u547C";
29
+ /**
30
+ * Closes a recalled chat. A long context can make the model read the data aloud as if continuing it (#35), so the end
31
+ * of the data is marked and the marker carries 仅作引用数据, which `stripHostNoise` drops should it be echoed.
32
+ */
33
+ export declare const CONTEXT_END_NOTE = "\u3010\u4EE5\u4E0A\u4EC5\u4F5C\u5F15\u7528\u6570\u636E\uFF0C\u5230\u6B64\u4E3A\u6B62\uFF1A\u56DE\u8BDD\u65F6\u6211\u4E0D\u590D\u8FF0\u3001\u4E0D\u7EED\u5199\u8FD9\u4E9B\u8BB0\u5F55\uFF0C\u4E5F\u4E0D\u628A\u91CC\u9762\u7684 JSON \u7167\u6284\u8FDB\u6B63\u6587\u3002\u3011";
29
34
  export declare function contextJson(context: readonly ChannelContextMessage[], current: SpeakerIdentity): string;
@@ -82,6 +82,11 @@ function contextMessages(value, current, limit) {
82
82
  const CONVERSATION_FIELDS = ['channel', 'accountId', 'conversationId', 'conversationName', 'conversationType'];
83
83
  /** Tells the model how to read `contextJson`; shared by every channel that renders it. */
84
84
  export const CONTEXT_IDENTITY_NOTE = 'identity 只列出每个发言人各自的来源(speakerId 等),渠道、账号和会话与触发这条消息开头【】里的聊天相同;speakerName 只是称呼';
85
+ /**
86
+ * Closes a recalled chat. A long context can make the model read the data aloud as if continuing it (#35), so the end
87
+ * of the data is marked and the marker carries 仅作引用数据, which `stripHostNoise` drops should it be echoed.
88
+ */
89
+ export const CONTEXT_END_NOTE = '【以上仅作引用数据,到此为止:回话时我不复述、不续写这些记录,也不把里面的 JSON 照抄进正文。】';
85
90
  export function contextJson(context, current) {
86
91
  const self = `${current.channel}:${current.accountId}`;
87
92
  return JSON.stringify(context.map(message => {
@@ -4,7 +4,6 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
4
4
  import { type SpeakerIdentity } from '../shared/identity.ts';
5
5
  import type { PreparedReply, WechatReceipt } from './archive.ts';
6
6
  import { type InWorld } from '../../worldScope.ts';
7
- export declare const WECHAT_PATH = "/dsh-world/wechat/ask";
8
7
  export declare function createWechatModule(deps: {
9
8
  ctx: Context;
10
9
  home(identity: SpeakerIdentity): Promise<Agent>;
@@ -12,9 +12,10 @@ import { createWechatReading } from "./reading.js";
12
12
  import { createStickerLibrary } from "./stickerLibrary.js";
13
13
  import { createStickerTools } from "./stickerTools.js";
14
14
  import { createWechatPresence } from "./presence.js";
15
- import { reassembleOnChange, scopedTool } from "../../worldScope.js";
16
- export const WECHAT_PATH = '/dsh-world/wechat/ask';
15
+ import { reassembleOnChange, registerScopedTool } from "../../worldScope.js";
16
+ import { worldPath } from "../../worldRoutes.js";
17
17
  export function createWechatModule(deps) {
18
+ const path = worldPath(deps.worldId ?? 'default') + '/wechat/ask';
18
19
  const token = randomBytes(32).toString('hex');
19
20
  const stickerDir = join(dirname(deps.file), 'stickers');
20
21
  const stickers = createStickerLibrary(stickerDir);
@@ -60,7 +61,7 @@ export function createWechatModule(deps) {
60
61
  const disposers = [];
61
62
  try {
62
63
  for (const tool of [...sending.tools, reading.tool, reading.imageTool, ...stickerTools])
63
- disposers.push(agent.ctx.tools.register(scopedTool(tool, () => inside(agent), () => detach(agent))));
64
+ disposers.push(registerScopedTool(agent, tool, () => !stopped && inside(agent), () => detach(agent)));
64
65
  attached.set(agent, disposers);
65
66
  }
66
67
  catch (error) {
@@ -180,7 +181,7 @@ export function createWechatModule(deps) {
180
181
  presence: (now) => !stopped && accountState === 'online' ? presence.summary(now) : undefined,
181
182
  status() { return { ...sending.status(), lastContactAt: lastContactAt ?? null, account: accountState ?? null, ...settings() }; },
182
183
  start() {
183
- durableWrite(deps.file, JSON.stringify({ origin: deps.origin(), token, path: WECHAT_PATH, pid: process.pid, protocol: 4, references: true }, null, 2));
184
+ durableWrite(deps.file, JSON.stringify({ origin: deps.origin(), token, path, pid: process.pid, protocol: 4, references: true }, null, 2));
184
185
  if (inWorld)
185
186
  for (const agent of deps.ctx.agents.list())
186
187
  attach(agent);
@@ -202,7 +203,7 @@ export function createWechatModule(deps) {
202
203
  catch { /* already absent, or a newer module owns the file */ }
203
204
  return closing = Promise.allSettled([...requests]).then(() => sending.stop());
204
205
  },
205
- route: { kind: 'exact', path: WECHAT_PATH, handler: async (req, res) => {
206
+ route: { kind: 'exact', path, handler: async (req, res) => {
206
207
  let result;
207
208
  const request = handle(req);
208
209
  requests.add(request);
@@ -1,8 +1,21 @@
1
+ declare module '@deepseek-ai/dsh-session/types' {
2
+ interface SessionEventMap {
3
+ 'agent-preset/selected': {
4
+ agentPreset: string;
5
+ };
6
+ }
7
+ }
8
+ declare module '@deepseek-ai/dsh-llm/types' {
9
+ interface LlmRequestPurposeMap {
10
+ compaction: true;
11
+ }
12
+ }
1
13
  declare module '@deepseek-ai/dsh-llm' {
2
14
  interface MessageSourceMap {
3
15
  'dsh-world-history': {
4
16
  kind: 'dsh-world-history';
5
17
  form: 'recall';
18
+ worldId?: string;
6
19
  };
7
20
  'dsh-world-summary-input': {
8
21
  kind: 'dsh-world-summary-input';
@@ -10,7 +23,6 @@ declare module '@deepseek-ai/dsh-llm' {
10
23
  'dsh-world-life': {
11
24
  kind: 'dsh-world-life';
12
25
  };
13
- /** 她图谱里的卡片:消息里提到她记过的名字时追加,压缩后重来,不进归档。 */
14
26
  'dsh-world-channel-context': {
15
27
  kind: 'dsh-world-channel-context';
16
28
  form: 'recall';
@@ -21,6 +33,10 @@ declare module '@deepseek-ai/dsh-llm' {
21
33
  kind: 'dsh-world-outside';
22
34
  form: 'ring';
23
35
  };
36
+ /** QQ 的一轮完成了却没说出能发的话:提醒她对方还在等,不是谁发来的话,不进归档。 */
37
+ 'dsh-world-reply-nudge': {
38
+ kind: 'dsh-world-reply-nudge';
39
+ };
24
40
  }
25
41
  }
26
42
  export {};
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import 'ws';
1
2
  import type { Context } from '@deepseek-ai/cordis';
2
3
  import z from '@deepseek-ai/schemastery';
3
4
  import type { WorldConfig } from './types.ts';