dsh-onebot-genji 0.12.2 → 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 +15 -9
- package/lib/client.js +1 -1
- package/lib/index.js +1 -1
- package/lib/registry.js +36 -1
- package/lib/settings-remote.js +1 -1
- package/lib/types/registry.d.ts +8 -0
- package/package.json +1 -1
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
|
-
|
|
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
|
@@ -250,7 +250,7 @@ window.__ModuleLoader__.load({
|
|
|
250
250
|
forceSessionId: "",
|
|
251
251
|
dmPromptFile: "", // T4 拍板默认关(贡献者默认 ~/.dsh 路径不收)
|
|
252
252
|
groupPromptFile: "", // 同上
|
|
253
|
-
groupContextLines:
|
|
253
|
+
groupContextLines: 3, // 本地加(2026-11-18):被 @ 时带上的群聊上下文条数;默认 3
|
|
254
254
|
requireMention: true,
|
|
255
255
|
memberTools: "none",
|
|
256
256
|
bystanderEnabled: false,
|
package/lib/index.js
CHANGED
|
@@ -252,7 +252,7 @@ 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(
|
|
255
|
+
groupContextLines: z.number().min(0).max(200).default(3)
|
|
256
256
|
.description('群聊参考上下文条数(本地加 2026-11-18):被 @ 时把群里最近 N 条消息拼进上下文;0 = 不参考'),
|
|
257
257
|
memoryFilesEnabled: z.boolean().default(false)
|
|
258
258
|
.description('记忆文件开关(T4 PR 移植):开启后把 memoryFiles 列表里的文件内容注入私聊会话 system prompt 的「我的记忆」段(单文件 8000 字符、总量 12000 字符截断;群聊不喂记忆);默认关'),
|
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.
|
|
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
|
package/lib/settings-remote.js
CHANGED
|
@@ -101,7 +101,7 @@ export const SCHEMA_DEFAULTS = {
|
|
|
101
101
|
dmPromptFile: '',
|
|
102
102
|
groupPromptFile: '',
|
|
103
103
|
// 本地加(2026-11-18):被 @ 时带上的群聊上下文条数(schema 默认 0)。
|
|
104
|
-
groupContextLines:
|
|
104
|
+
groupContextLines: 3,
|
|
105
105
|
// T5 翻转:下载 SSRF 防护逃生门(原 false)。
|
|
106
106
|
allowPrivateHosts: true,
|
|
107
107
|
ignoreSelf: true,
|
package/lib/types/registry.d.ts
CHANGED
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-onebot-genji",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
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
5
|
"keywords": [
|
|
6
6
|
"dsh",
|