dsh-onebot-genji 0.12.1 → 0.13.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.
package/README.md CHANGED
@@ -4,15 +4,21 @@
4
4
 
5
5
  本分叉由 **InsaneGenji** 维护,在上游基础上加自己需要的东西;想装上游原版请去 https://github.com/mario841859784/dsh-onebot ,上游完整文档见 [`README.upstream.md`](./README.upstream.md)。
6
6
 
7
- ## 这个分叉打算加什么
8
-
9
- - 回合形式掷骰:每个回合按概率决定这一轮是回文字、语音条还是表情包,概率做成设置项
10
- - 双发闸:一个回合里工具已经发过文本,回合末的正文不再重复发一遍
11
- - 引用的合并转发展开:被引消息本身是合并转发时展开成可读内容,而不是只剩 `[合并转发]` 占位
12
- - 正文气泡切分:长回复按换行和句子切成多条独立消息,而不是一堵墙
13
- - 自带语音转写桥:`lib/stt_cli.py` 打进包里,`sttEngine: auto` 探不到 whisper 时自动用它(只要求 Python + `faster-whisper`),不用用户自己配脚本
14
-
15
- > 自带语音转写桥已经合入代码;其余几项还在做。
7
+ ## 和原版(dsh-onebot-qq)的区别
8
+
9
+ 只列本分叉**新加**的功能;安装、配置、连接 NapCat 的方式跟原版完全一致,见 [`README.upstream.md`](./README.upstream.md)。
10
+
11
+ | 功能 | 说明 |
12
+ | --- | --- |
13
+ | **自带语音转写桥** | `lib/stt_cli.py` 打进包里,`sttEngine: auto` 探不到 whisper 时自动用它(只要 Python + `faster-whisper`),不用自己配脚本 |
14
+ | **表情包库** | 收到的新图自动进「未审核」;设置页「表情包」页签里看图、审核、撤回、删除、多选上传。审核时才让模型看图写描述和标签,不点不跑、不占显存 |
15
+ | **主动搭话** | 内置在插件里(`lib/proactive.js`),按空闲时长、间隔、每日上限、安静时段自己找话题,聊完还能补一句;开关和阈值全在设置页「行为 → 私聊」,生成走当前会话模型 |
16
+ | **回合形式掷骰** | 每个回合按概率决定这一轮用文字、语音条还是表情包;语音/表情的开关与概率都是设置项(默认 10% / 39%) |
17
+ | **群聊上下文** | 被 @ 或叫到唤醒词时,自动带上群里最近 N 条消息(「参考上下文条数」,默认 3,0 = 不带),被门控挡下的消息不会丢 |
18
+ | **唤醒词合并** | 原版分「用户唤醒词 / 他人唤醒词」两套名单,这里合成一个「唤醒词」列表:群里任何人命中都算叫到机器人 |
19
+ | **引用合并转发展开** | 被引的消息本身是合并转发时展开成可读内容,而不是只剩 `[合并转发]` 占位 |
20
+ | **会话恢复重试** | 插件热重载时原版会「恢复失败 → 退休旧会话 → 新建」,一个聊天裂成两个会话;这里带 0.7s / 1.5s / 3s 三次重试,等旧会话把手上那轮收完 |
21
+ | **设置页重做** | 中文标签 + 分组分区(连接 / 权限 / 行为 / 表情包 / 会话 / 媒体 / 诊断),数字项统一「≥0 的整数」校验,用不到的项(旁观、强制会话 ID、新会话智能体预设等)已隐藏 |
16
22
 
17
23
  ## 安装与配置
18
24
 
package/lib/client.js CHANGED
@@ -131,7 +131,7 @@ window.__ModuleLoader__.load({
131
131
  sections: [
132
132
  { id: "common", title: "通用", keys: ["adminUsers", "sensitivePatterns"] },
133
133
  { id: "dm", title: "私聊", keys: ["dmPolicy", "allowFrom"] },
134
- { id: "group", title: "群聊", keys: ["requireMention", "memberTools", "groupPolicy", "groupAllowFrom", "wakeNamesAdmin", "wakeNamesMember", "atAllCountsAsMention", "pokeEnabled"] },
134
+ { id: "group", title: "群聊", keys: ["groupPolicy", "groupAllowFrom", "memberTools", "groupContextLines", "wakeNamesAdmin", "requireMention", "pokeEnabled", "atAllCountsAsMention"] },
135
135
  ],
136
136
  fields: [
137
137
  { key: "requireMention", label: "群聊必须 @ 机器人", type: "boolean" },
@@ -141,10 +141,10 @@ window.__ModuleLoader__.load({
141
141
  { key: "groupPolicy", label: "群聊策略", type: "enum", options: ["open", "allowlist", "disabled"], optionLabels: { open: "开放", allowlist: "白名单", disabled: "禁用" } },
142
142
  { key: "allowFrom", label: "私聊白名单", showIf: { key: "dmPolicy", value: "allowlist" }, type: "stringArray" },
143
143
  { key: "groupAllowFrom", label: "群聊白名单", showIf: { key: "groupPolicy", value: "allowlist" }, type: "stringArray" },
144
- { key: "wakeNamesAdmin", label: "用户唤醒词", type: "stringArray" },
145
- { key: "wakeNamesMember", label: "他人唤醒词", type: "stringArray" },
144
+ { key: "wakeNamesAdmin", label: "唤醒词", type: "stringArray", hint: "群里任何人说了这些词就当我被叫到" },
146
145
  { key: "atAllCountsAsMention", label: "@全体唤醒", type: "boolean", hint: "@全体成员也算叫我" },
147
146
  { key: "pokeEnabled", label: "戳一戳叫醒", type: "boolean" },
147
+ { key: "groupContextLines", label: "参考上下文条数", type: "number", pattern: "^[0-9]+$", patternHint: "≥0 的整数", hint: "被 @ 或叫到唤醒词时先带上群里最近这么多条消息;0 = 不参考" },
148
148
  { key: "sensitivePatterns", label: "出站敏感词正则", type: "stringArray", placeholder: "正则,一行一个;留空用内置" },
149
149
  ],
150
150
  },
@@ -250,6 +250,7 @@ window.__ModuleLoader__.load({
250
250
  forceSessionId: "",
251
251
  dmPromptFile: "", // T4 拍板默认关(贡献者默认 ~/.dsh 路径不收)
252
252
  groupPromptFile: "", // 同上
253
+ groupContextLines: 3, // 本地加(2026-11-18):被 @ 时带上的群聊上下文条数;默认 3
253
254
  requireMention: true,
254
255
  memberTools: "none",
255
256
  bystanderEnabled: false,
@@ -470,6 +471,7 @@ window.__ModuleLoader__.load({
470
471
  forceSessionId: vString(0, 256),
471
472
  dmPromptFile: vString(0, 1024),
472
473
  groupPromptFile: vString(0, 1024),
474
+ groupContextLines: vNumber(),
473
475
  requireMention: vBoolean(),
474
476
  memberTools: vEnum(["none", "send", "all"]),
475
477
  bystanderEnabled: vBoolean(),
@@ -866,10 +868,10 @@ window.__ModuleLoader__.load({
866
868
  allowAllUsers: { label: "Allow all users" },
867
869
  allowFrom: { label: "DM allowlist" },
868
870
  groupAllowFrom: { label: "Group allowlist" },
869
- wakeNamesAdmin: { label: "User wake names" },
870
- wakeNamesMember: { label: "Member wake names" },
871
+ wakeNamesAdmin: { label: "Wake names", hint: "Anyone in the group saying one of these counts as calling the bot" },
871
872
  atAllCountsAsMention: { label: "@-all wakes", hint: "@-ing everyone also counts as a wake" },
872
873
  pokeEnabled: { label: "Poke wakes" },
874
+ groupContextLines: { label: "Group context lines", hint: "Include the last N group messages when @-mentioned; 0 = off" },
873
875
  sensitivePatterns: { label: "Outbound sensitive-word regexes", placeholder: "One regex per line; empty = built-in list" },
874
876
  },
875
877
  },
@@ -1212,6 +1214,7 @@ window.__ModuleLoader__.load({
1212
1214
  */
1213
1215
  var NUMBER_RANGE = {
1214
1216
  port: [1, 65535],
1217
+ groupContextLines: [0, 200],
1215
1218
  rateLimitPerMinute: [0, undefined],
1216
1219
  interimRecallMs: [0, undefined],
1217
1220
  inboxQueueDelayMs: [0, undefined],
@@ -1721,13 +1724,17 @@ window.__ModuleLoader__.load({
1721
1724
  return null;
1722
1725
  return node;
1723
1726
  });
1724
- fieldNodes = fieldNodes.concat(noticeRows).concat(tailFieldNodes);
1727
+ var extraNodes = noticeRows.concat(tailFieldNodes);
1728
+ fieldNodes = fieldNodes.concat(extraNodes);
1725
1729
  // 本地加:组内分区(如权限的私聊/群聊)——按 keys 顺序取已渲染的字段节点,
1726
1730
  // 每块前面插一个小标题(标题走词条,zh 源 = GROUPS.sections.title 自动灌入)。
1727
1731
  if (Array.isArray(group.sections) && group.sections.length > 0) {
1728
1732
  var byKey = {};
1733
+ // 本地改(2026-11-18):sections 重排后 fieldNodes 长度已变(通知行/尾部字段
1734
+ // 追加在后面),所以索引只按前 group.fields.length 项取。
1729
1735
  group.fields.forEach(function (field, index) { byKey[field.key] = fieldNodes[index]; });
1730
- var sectioned = [];
1736
+ var looseNodes = [];
1737
+ var sectionNodes = [];
1731
1738
  // 本地加:没归进任何分区的字段先渲染 —— 落在组标题下、第一个分区标题之上
1732
1739
  //(如权限组的「管理员用户列表」)。
1733
1740
  var claimedBySection = {};
@@ -1737,16 +1744,17 @@ window.__ModuleLoader__.load({
1737
1744
  }
1738
1745
  for (var looseField of group.fields) {
1739
1746
  if (claimedBySection[looseField.key] !== true && byKey[looseField.key] != null)
1740
- sectioned.push(byKey[looseField.key]);
1747
+ looseNodes.push(byKey[looseField.key]);
1741
1748
  }
1742
1749
  for (var section of group.sections) {
1743
- sectioned.push(h(ReactImpl, "h4", { className: "obx-subgroup-title", key: "sec-" + section.id }, tr("group." + group.id + ".section." + section.id, section.title)));
1750
+ sectionNodes.push(h(ReactImpl, "h4", { className: "obx-subgroup-title", key: "sec-" + section.id }, tr("group." + group.id + ".section." + section.id, section.title)));
1744
1751
  for (var sectionKey of section.keys) {
1745
1752
  if (byKey[sectionKey] != null)
1746
- sectioned.push(byKey[sectionKey]);
1753
+ sectionNodes.push(byKey[sectionKey]);
1747
1754
  }
1748
1755
  }
1749
- fieldNodes = sectioned;
1756
+ // 本地改(2026-11-18):分区块排在通知段之后、尾部字段(发送错误通知)之前。
1757
+ fieldNodes = looseNodes.concat(noticeRows).concat(sectionNodes).concat(tailFieldNodes);
1750
1758
  }
1751
1759
  // 组标题 + 一句人话描述(经 opts.groupDesc 传入;缺省不渲染)。标题走词条
1752
1760
  //(zh 源 = GROUPS.title 自动灌入)。
package/lib/inbound.js CHANGED
@@ -142,10 +142,9 @@ export class InboundPipeline {
142
142
  // 置回 false。角色档取管理员/成员各自的唤醒词表。
143
143
  let wakeNameHit = false;
144
144
  if (kind === 'group' && !mentioned) {
145
- const role = classifyUserRole(userId, policy.adminUsers);
146
- const wakeNames = role === 'admin'
147
- ? this.ctx.config.wakeNamesAdmin ?? []
148
- : this.ctx.config.wakeNamesMember ?? [];
145
+ // 2026-11-18 本地改:用户唤醒词 / 他人唤醒词合并成一张「唤醒词」表,
146
+ // 群里任何人(不管是不是管理员)说了都算叫到我。
147
+ const wakeNames = [...(this.ctx.config.wakeNamesAdmin ?? []), ...(this.ctx.config.wakeNamesMember ?? [])];
149
148
  if (wakeNames.length > 0) {
150
149
  const text = segmentText(inbound.segments, inbound.raw);
151
150
  if (detectWakeName(text, wakeNames)) {
@@ -154,7 +153,7 @@ export class InboundPipeline {
154
153
  currentTrace()?.emit('mention', {
155
154
  ok: true,
156
155
  reason: TRACE_REASONS.inboundWakeName,
157
- data: { names: [...wakeNames], textLen: text.length, preview: text.slice(0, 40), role },
156
+ data: { names: [...wakeNames], textLen: text.length, preview: text.slice(0, 40) },
158
157
  });
159
158
  }
160
159
  }
package/lib/index.js CHANGED
@@ -252,6 +252,8 @@ export const Config = z.object({
252
252
  .description('私聊附加设定文件路径(T4 PR 移植):支持 ~/ 展开;文件内容(剥行首尾空白)注入私聊会话 system prompt 的「本会话附加设定」段,文件编辑后即时生效(mtime 缓存失效);留空 = 不注入(默认)'),
253
253
  groupPromptFile: z.string().default('')
254
254
  .description('群聊附加设定文件路径(T4 PR 移植):同 dmPromptFile,只对群聊(group:)会话生效;留空 = 不注入(默认)'),
255
+ groupContextLines: z.number().min(0).max(200).default(3)
256
+ .description('群聊参考上下文条数(本地加 2026-11-18):被 @ 时把群里最近 N 条消息拼进上下文;0 = 不参考'),
255
257
  memoryFilesEnabled: z.boolean().default(false)
256
258
  .description('记忆文件开关(T4 PR 移植):开启后把 memoryFiles 列表里的文件内容注入私聊会话 system prompt 的「我的记忆」段(单文件 8000 字符、总量 12000 字符截断;群聊不喂记忆);默认关'),
257
259
  memoryFiles: z.array(z.string()).default([])
@@ -559,6 +561,7 @@ export function apply(ctx, config) {
559
561
  startupResumeEnabled: config.startupResumeEnabled,
560
562
  dmPromptFile: config.dmPromptFile,
561
563
  groupPromptFile: config.groupPromptFile,
564
+ groupContextLines: config.groupContextLines,
562
565
  memoryFilesEnabled: config.memoryFilesEnabled,
563
566
  memoryFiles: config.memoryFiles,
564
567
  chatTailsEnabled: config.chatTailsEnabled,
package/lib/prompt.js CHANGED
@@ -67,6 +67,8 @@ export function buildPlatformPrompt(restrictedMembers, extra = '', memoryText =
67
67
  text += '- QQ 不渲染 Markdown:请输出纯文本。用「1. 2. 3.」编号或「- 」列表;行内代码用反引号包住即可(会原样显示)。\n';
68
68
  text += '- 需要发送图片时用 qq_send_image(本地路径或 URL);文件用 qq_send_file;语音 qq_send_voice;视频 qq_send_video。\n';
69
69
  text += '- 想以「合并转发」卡片展示多条消息(代码+说明、分步报告)时,用 qq_send_forward。\n';
70
+ // 本地加(2026-11-18):要「先吱一声」的场合统一走 qq_send_segments。
71
+ text += '- 要「先吱一声」的时候(发图、出视频、点歌、发语音之前先说一句),那句招呼用 qq_send_segments 发。\n';
70
72
  text += '- 用户发来的图片/语音/视频在消息文本里以 [图片]/[语音]/[视频] 占位,图片/视频解析成功后替换为带本地路径的标注(如 [图片:路径]),语音保持 [语音](转写另行附上);如需查看图片内容,请使用当前可用的图像查看/描述工具;若没有可用工具,则如实告诉用户当前无法直接查看图片。\n';
71
73
  text += '- 群聊消息带 [HH:MM 昵称(QQ)·档位] 前缀(档位:管理员/成员,由插件标注发言者权限),被 @ 时带 [@我];私聊只带 [HH:MM] 时间戳前缀,没有昵称与档位。\n';
72
74
  text += '- 私聊消息的信封带 mid="…":那是这条消息的 id(纯数字,可能是负数),需要用某条消息做指代时原样抄,不要改写、补零或加引号。\n';
package/lib/registry.js CHANGED
@@ -13,6 +13,14 @@ const RETIRED_FILE = 'retired-sessions.json';
13
13
  const SWITCHABLE_FILE = 'switchable-sessions.json';
14
14
  /** Per-chat cap of the switchable list (hard-wired; no config surface). */
15
15
  const SWITCHABLE_CAP = 20;
16
+ /** 本地加(2026-11-19):恢复会话失败时的重试间隔(毫秒)。插件热重载/重启
17
+ * 那一下,旧 agent 可能还在优雅收尾(dispose 要等当前 step 跑完),此时
18
+ * resume 会失败;以前直接 retire + 新建,一个聊天就分家成两个会话
19
+ * (2026-11-19 01:13 事故)。现在先按这几个间隔重试,全失败才走原流程。
20
+ * 总等待 ≈ 5.2 秒,最坏情况下用户那条消息晚响应这么久。 */
21
+ const RESUME_RETRY_DELAYS_MS = [700, 1500, 3000];
22
+ /** 这些错误重试也没用(日志不存在/结构坏了),直接放弃重试。 */
23
+ const RESUME_RETRY_SKIP = /ENOENT|not found|not persisted|does not exist|corrupt|unparsable|invalid session/i;
16
24
  /** D4b: build one mapping entry — a bare session id when the chat carries no
17
25
  * persisted settings (byte-identical to the legacy format), else an object
18
26
  * with the optional mode/goal/workspace/silence fields. An empty
@@ -284,7 +292,7 @@ export class ChatRegistry {
284
292
  }
285
293
  else {
286
294
  try {
287
- const resumed = await this.resumeChat(chatId, evicted.session);
295
+ const resumed = await this.resumeChatWithWait(chatId, evicted.session);
288
296
  // D4b/T3: the evicted chat's persisted mode/goal/workspace come back with it.
289
297
  this.restoreEvictedSettings(chatId, evicted);
290
298
  this.evictedChats.delete(chatId);
@@ -628,6 +636,33 @@ export class ChatRegistry {
628
636
  this.bySession.set(handle.agent.session.id, chatId);
629
637
  return chat;
630
638
  }
639
+ /** 本地加(2026-11-19):带等待的 resume。恢复失败时先等旧 agent 释放
640
+ * (热重载瞬间它可能正跑着一轮),按 RESUME_RETRY_DELAYS_MS 重试;只有全
641
+ * 都失败才把错误抛给调用方走退休流程。遇到 RESUME_RETRY_SKIP 里的错误
642
+ * (日志没了/坏了)不浪费时间去重试。 */
643
+ async resumeChatWithWait(chatId, sessionId) {
644
+ const delays = this.deps.resumeRetryDelaysMs ?? RESUME_RETRY_DELAYS_MS;
645
+ let lastError;
646
+ for (let attempt = 0; attempt <= delays.length; attempt += 1) {
647
+ if (this.deps.isStopping())
648
+ throw new Error('bridge is stopping');
649
+ try {
650
+ const chat = await this.resumeChat(chatId, sessionId);
651
+ if (attempt > 0)
652
+ this.deps.log('info', 'resume recovered after ' + attempt + ' retr(ies) for ' + chatId + ' @ ' + sessionId);
653
+ return chat;
654
+ }
655
+ catch (error) {
656
+ lastError = error;
657
+ const message = describeError(error);
658
+ if (attempt >= delays.length || RESUME_RETRY_SKIP.test(message))
659
+ break;
660
+ this.deps.log('warn', 'resume failed for ' + chatId + ' @ ' + sessionId + ' (retry ' + (attempt + 1) + '/' + delays.length + ' in ' + delays[attempt] + 'ms): ' + message);
661
+ await new Promise((resolve) => { setTimeout(resolve, delays[attempt]); });
662
+ }
663
+ }
664
+ throw lastError;
665
+ }
631
666
  mappingPath() {
632
667
  return this.deps.config.mediaDir.endsWith('/') || this.deps.config.mediaDir.endsWith('\\')
633
668
  ? this.deps.config.mediaDir + MAPPING_FILE
@@ -70,7 +70,7 @@ export const SETTINGS_GROUPS = {
70
70
  connection: ['mode', 'host', 'port', 'url', 'accessToken', 'botQQ'],
71
71
  // 2026-11-18:allowAllUsers 从权限组摘掉——dmPolicy=open 现在就是对所有人开放,
72
72
  // 这个开关不再有界面入口(schema 与 BOOLEAN_KEYS 保留,老配置里的键照样能读)。
73
- permissions: ['requireMention', 'memberTools', 'adminUsers', 'dmPolicy', 'groupPolicy', 'allowFrom', 'groupAllowFrom', 'wakeNamesAdmin', 'wakeNamesMember', 'replyCountsAsMention', 'atAllCountsAsMention', 'reactionOnMention', 'reactionEmoji', 'faceStyle', 'pokeEnabled', 'restrictedMemberPrefix', 'sensitivePatterns'],
73
+ permissions: ['requireMention', 'memberTools', 'adminUsers', 'dmPolicy', 'groupPolicy', 'allowFrom', 'groupAllowFrom', 'wakeNamesAdmin', 'wakeNamesMember', 'replyCountsAsMention', 'atAllCountsAsMention', 'reactionOnMention', 'reactionEmoji', 'faceStyle', 'pokeEnabled', 'restrictedMemberPrefix', 'sensitivePatterns', 'groupContextLines'],
74
74
  behavior: ['interimMessages', 'interimRecall', 'interimRecallMs', 'sendErrorNotice', 'unknownCommand', 'rateLimitPerMinute', 'newMessagePolicy', 'autoSteerPolicy', 'deferredTimeoutMs', 'inboxQueueEnabled', 'inboxQueueDelayMs', 'titleSyncEnabled', 'ignoreSelf', 'sidebarEntryEnabled'],
75
75
  // #58 群聊旁观:默认全关/空(enabled=false 时其余四键零行为)。
76
76
  session: ['titleSyncEnabled', 'startupResumeEnabled', 'newSessionGreeting', 'memoryFilesEnabled', 'memoryFiles', 'agentPreset', 'workspacePath', 'groupWorkspacePath', 'forceSessionId', 'dmPromptFile', 'groupPromptFile'],
@@ -100,6 +100,8 @@ export const SCHEMA_DEFAULTS = {
100
100
  // PENDING:私聊/群聊提示词文件(贡献者默认 ~/.dsh 路径;本仓 T4 拍板默认关 = '')。
101
101
  dmPromptFile: '',
102
102
  groupPromptFile: '',
103
+ // 本地加(2026-11-18):被 @ 时带上的群聊上下文条数(schema 默认 0)。
104
+ groupContextLines: 3,
103
105
  // T5 翻转:下载 SSRF 防护逃生门(原 false)。
104
106
  allowPrivateHosts: true,
105
107
  ignoreSelf: true,
@@ -216,7 +218,7 @@ const ENUM_KEYS = {
216
218
  logLevel: ['debug', 'info', 'warn', 'error'],
217
219
  sttEngine: ['auto', 'openai', 'whisper-cpp', 'custom'],
218
220
  };
219
- const NUMBER_KEYS = ['port', 'interimRecallMs', 'rateLimitPerMinute', 'deferredTimeoutMs', 'textImageThreshold', 'chatIdleEvictDays', 'outboundImageMaxBytes', 'maxVoiceBytes', 'maxFileBytes', 'inboundImageMaxPx', 'inboundFileMaxBytes', 'inboxQueueDelayMs', 'bystanderCapacity', 'bystanderCooldownMinutes', 'bystanderDailyLimit', 'reactionEmoji'];
221
+ const NUMBER_KEYS = ['port', 'interimRecallMs', 'rateLimitPerMinute', 'deferredTimeoutMs', 'textImageThreshold', 'chatIdleEvictDays', 'outboundImageMaxBytes', 'maxVoiceBytes', 'maxFileBytes', 'inboundImageMaxPx', 'inboundFileMaxBytes', 'inboxQueueDelayMs', 'groupContextLines', 'bystanderCapacity', 'bystanderCooldownMinutes', 'bystanderDailyLimit', 'reactionEmoji'];
220
222
  /** 数字键取值范围(评审 B4:port 1–65535、时长/频控 ≥0;越界在 Remote 层拒绝,不再只依赖宿主回滚兜底)。 */
221
223
  const NUMBER_RANGE = {
222
224
  port: [1, 65535],
@@ -232,6 +234,8 @@ const NUMBER_RANGE = {
232
234
  inboundFileMaxBytes: [0, undefined],
233
235
  // T7:合并窗口毫秒数(≥0;0=立即投递,等同关闭合并但串行链仍生效)。
234
236
  inboxQueueDelayMs: [0, undefined],
237
+ // 本地加(2026-11-18):群聊上下文条数(0 = 不参考,上限 200 条)。
238
+ groupContextLines: [0, 200],
235
239
  // #58 旁观:容量条数 / 冷却分钟 / 每日上限。
236
240
  bystanderCapacity: [5, 500],
237
241
  bystanderCooldownMinutes: [5, 1440],
@@ -148,6 +148,8 @@ export interface BridgeConfig {
148
148
  dmPromptFile?: string;
149
149
  /** T4 (PR port 提示词文件):群聊(group:)会话的附加设定文件路径;absent/空 = 不注入。 */
150
150
  groupPromptFile?: string;
151
+ /** 本地加(2026-11-18):被 @ 时带上的群聊上下文条数(0/absent = 不参考,上限 200)。 */
152
+ groupContextLines?: number;
151
153
  /** T4 (PR port 记忆文件):记忆文件开关(默认关,裁定口径);只对私聊生效。 */
152
154
  memoryFilesEnabled?: boolean;
153
155
  /** T4 (PR port 记忆文件):记忆文件路径列表(~/ 展开;单文件 8000 字符、
@@ -264,6 +264,7 @@ export interface Config {
264
264
  dmPromptFile: string;
265
265
  /** T4 (PR port 提示词文件):群聊(group:)会话的附加设定文件路径;空 = 不注入(默认)。 */
266
266
  groupPromptFile: string;
267
+ groupContextLines: number;
267
268
  /** T4 (PR port 记忆文件):记忆文件开关(默认关;只喂私聊)。 */
268
269
  memoryFilesEnabled: boolean;
269
270
  /** T4 (PR port 记忆文件):记忆文件路径列表。 */
@@ -168,6 +168,9 @@ export interface RegistryDeps {
168
168
  log(level: 'info' | 'warn' | 'error' | 'debug', message: string): void;
169
169
  /** Bridge stop flag (guards the resume loop). */
170
170
  isStopping(): boolean;
171
+ /** 本地加(2026-11-19):恢复会话失败时的重试间隔(毫秒)覆盖;缺省用
172
+ * RESUME_RETRY_DELAYS_MS。测试传短间隔,生产不传。 */
173
+ resumeRetryDelaysMs?: readonly number[];
171
174
  /** Bridge-owned chat runtime teardown when a chat leaves the registry:
172
175
  * stop the typing indicator. Interim recall timers are cleared by the
173
176
  * registry itself (ChatAgent state), keeping the reset/heal semantics
@@ -289,6 +292,11 @@ export declare class ChatRegistry {
289
292
  /** Resume one persisted chat from its recorded session id (shared by
290
293
  * loadMapping and the B8c evicted-chat resume). */
291
294
  private resumeChat;
295
+ /** 本地加(2026-11-19):带等待的 resume。恢复失败时先等旧 agent 释放
296
+ * (热重载瞬间它可能正跑着一轮),按 RESUME_RETRY_DELAYS_MS 重试;只有全
297
+ * 都失败才把错误抛给调用方走退休流程。遇到 RESUME_RETRY_SKIP 里的错误
298
+ * (日志没了/坏了)不浪费时间去重试。 */
299
+ private resumeChatWithWait;
292
300
  private mappingPath;
293
301
  /** T3 (hole C): make a just-set /workspace override durable even when the
294
302
  * chat is not live (before its first message, or after a failed resume).
package/package.json CHANGED
@@ -1,110 +1,110 @@
1
- {
2
- "name": "dsh-onebot-genji",
3
- "version": "0.12.1",
4
- "description": "由 InsaneGenji 维护的 QQ 通道分叉(fork 自 dsh-onebot-qq@0.11.0):在 OneBot 11 / NapCat 通道基础上加了回合形式掷骰(语音条、表情包概率)、双发闸、引用的合并转发展开、正文气泡切分。仓库 github.com/InsaneGenji/dsh-onebot-genji,上游 github.com/mario841859784/dsh-onebot .",
5
- "keywords": [
6
- "dsh",
7
- "onebot",
8
- "onebot11",
9
- "qq",
10
- "qq-bot",
11
- "qqbot",
12
- "napcat",
13
- "lagrange",
14
- "llonebot",
15
- "go-cqhttp",
16
- "deepseek",
17
- "deepseek-harness",
18
- "harness",
19
- "bridge",
20
- "chatbot"
21
- ],
22
- "private": false,
23
- "type": "module",
24
- "main": "lib/index.js",
25
- "types": "lib/types/index.d.ts",
26
- "exports": {
27
- ".": {
28
- "types": "./lib/types/index.d.ts",
29
- "default": "./lib/index.js"
30
- },
31
- "./client": "./lib/client.js",
32
- "./settings-remote": "./lib/settings-remote.js",
33
- "./package.json": "./package.json"
34
- },
35
- "files": [
36
- "lib",
37
- "!lib/*.bak-*",
38
- "cordis.patch.yml"
39
- ],
40
- "license": "BSD-3-Clause",
41
- "repository": {
42
- "type": "git",
43
- "url": "git+https://github.com/InsaneGenji/dsh-onebot-genji.git"
44
- },
45
- "homepage": "https://github.com/InsaneGenji/dsh-onebot-genji#readme",
46
- "bugs": {
47
- "url": "https://github.com/InsaneGenji/dsh-onebot-genji/issues"
48
- },
49
- "engines": {
50
- "dsh": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0 || >=0.2.1-0 <0.3.0-0 || >=0.2.2-0 <0.2.3-0",
51
- "node": ">=22"
52
- },
53
- "dsh": {
54
- "bundle": {
55
- "patch": "./cordis.patch.yml"
56
- },
57
- "client": {
58
- "platform": "web"
59
- }
60
- },
61
- "dshx": {
62
- "contributes": {
63
- "tools": [
64
- "qq_send_image",
65
- "qq_send_voice",
66
- "qq_send_video",
67
- "qq_send_file",
68
- "qq_send_forward",
69
- "qq_napcat_api",
70
- "qq_group_history"
71
- ],
72
- "skills": []
73
- }
74
- },
75
- "peerDependencies": {
76
- "@deepseek-ai/cordis": "^4.0.2",
77
- "@deepseek-ai/dsh-agent": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0 || >=0.2.2-0 <0.2.3-0",
78
- "@deepseek-ai/dsh-llm": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
79
- "@deepseek-ai/dsh-session": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
80
- "@deepseek-ai/dsh-system-prompt": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
81
- "@deepseek-ai/dsh-tools": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
82
- "@deepseek-ai/dsh-typert-protocol": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
83
- "@deepseek-ai/dsh-util-values": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
84
- "@deepseek-ai/schemastery": "^3.18.0 || >=3.18.6-alpha.1 <3.19.0-0",
85
- "schemastery": "^3.18.0"
86
- },
87
- "dependencies": {
88
- "@napi-rs/canvas": "^1.0.6",
89
- "fontkit": "^2.0.4",
90
- "schemastery": "^3.18.0",
91
- "silk-wasm": "^3.7.1",
92
- "ws": "^8.18.0"
93
- },
94
- "optionalDependencies": {
95
- "gifuct-js": "^2.1.2"
96
- },
97
- "devDependencies": {
98
- "@types/node": "^24.0.0",
99
- "@types/ws": "^8.5.12",
100
- "typescript": "^5.9.0",
101
- "vitest": "^3.2.0"
102
- },
103
- "scripts": {
104
- "build": "./scripts/build.sh",
105
- "test": "vitest run",
106
- "replay": "node scripts/replay.mjs",
107
- "verify:injected-context": "node scripts/verify-injected-context.mjs",
108
- "verify:lan-management": "node scripts/verify-lan-management.mjs"
109
- }
110
- }
1
+ {
2
+ "name": "dsh-onebot-genji",
3
+ "version": "0.13.0",
4
+ "description": "由 InsaneGenji 维护的 QQ 通道分叉(fork 自 dsh-onebot-qq@0.11.0):在 OneBot 11 / NapCat 通道基础上加了回合形式掷骰(语音条、表情包概率)、双发闸、引用的合并转发展开、正文气泡切分。仓库 github.com/InsaneGenji/dsh-onebot-genji,上游 github.com/mario841859784/dsh-onebot .",
5
+ "keywords": [
6
+ "dsh",
7
+ "onebot",
8
+ "onebot11",
9
+ "qq",
10
+ "qq-bot",
11
+ "qqbot",
12
+ "napcat",
13
+ "lagrange",
14
+ "llonebot",
15
+ "go-cqhttp",
16
+ "deepseek",
17
+ "deepseek-harness",
18
+ "harness",
19
+ "bridge",
20
+ "chatbot"
21
+ ],
22
+ "private": false,
23
+ "type": "module",
24
+ "main": "lib/index.js",
25
+ "types": "lib/types/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./lib/types/index.d.ts",
29
+ "default": "./lib/index.js"
30
+ },
31
+ "./client": "./lib/client.js",
32
+ "./settings-remote": "./lib/settings-remote.js",
33
+ "./package.json": "./package.json"
34
+ },
35
+ "files": [
36
+ "lib",
37
+ "!lib/*.bak-*",
38
+ "cordis.patch.yml"
39
+ ],
40
+ "license": "BSD-3-Clause",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/InsaneGenji/dsh-onebot-genji.git"
44
+ },
45
+ "homepage": "https://github.com/InsaneGenji/dsh-onebot-genji#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/InsaneGenji/dsh-onebot-genji/issues"
48
+ },
49
+ "engines": {
50
+ "dsh": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0 || >=0.2.1-0 <0.3.0-0 || >=0.2.2-0 <0.2.3-0",
51
+ "node": ">=22"
52
+ },
53
+ "dsh": {
54
+ "bundle": {
55
+ "patch": "./cordis.patch.yml"
56
+ },
57
+ "client": {
58
+ "platform": "web"
59
+ }
60
+ },
61
+ "dshx": {
62
+ "contributes": {
63
+ "tools": [
64
+ "qq_send_image",
65
+ "qq_send_voice",
66
+ "qq_send_video",
67
+ "qq_send_file",
68
+ "qq_send_forward",
69
+ "qq_napcat_api",
70
+ "qq_group_history"
71
+ ],
72
+ "skills": []
73
+ }
74
+ },
75
+ "peerDependencies": {
76
+ "@deepseek-ai/cordis": "^4.0.2",
77
+ "@deepseek-ai/dsh-agent": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0 || >=0.2.2-0 <0.2.3-0",
78
+ "@deepseek-ai/dsh-llm": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
79
+ "@deepseek-ai/dsh-session": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
80
+ "@deepseek-ai/dsh-system-prompt": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
81
+ "@deepseek-ai/dsh-tools": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
82
+ "@deepseek-ai/dsh-typert-protocol": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
83
+ "@deepseek-ai/dsh-util-values": ">=0.1.5-rc.1 <0.1.6-0 || >=0.1.6-alpha.1 <0.1.7-0 || >=0.1.7-alpha.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0",
84
+ "@deepseek-ai/schemastery": "^3.18.0 || >=3.18.6-alpha.1 <3.19.0-0",
85
+ "schemastery": "^3.18.0"
86
+ },
87
+ "dependencies": {
88
+ "@napi-rs/canvas": "^1.0.6",
89
+ "fontkit": "^2.0.4",
90
+ "schemastery": "^3.18.0",
91
+ "silk-wasm": "^3.7.1",
92
+ "ws": "^8.18.0"
93
+ },
94
+ "optionalDependencies": {
95
+ "gifuct-js": "^2.1.2"
96
+ },
97
+ "devDependencies": {
98
+ "@types/node": "^24.0.0",
99
+ "@types/ws": "^8.5.12",
100
+ "typescript": "^5.9.0",
101
+ "vitest": "^3.2.0"
102
+ },
103
+ "scripts": {
104
+ "build": "./scripts/build.sh",
105
+ "test": "vitest run",
106
+ "replay": "node scripts/replay.mjs",
107
+ "verify:injected-context": "node scripts/verify-injected-context.mjs",
108
+ "verify:lan-management": "node scripts/verify-lan-management.mjs"
109
+ }
110
+ }