dsh-qqbot-muu 0.1.15 → 0.1.21
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/CHANGELOG.md +168 -85
- package/client/qqbot-settings.js +13401 -12024
- package/config/modules.json +212 -0
- package/dist/channel-tools.js +21 -10
- package/dist/config.d.ts +14 -0
- package/dist/config.js +573 -449
- package/dist/features/contextless-store.js +247 -247
- package/dist/features/contextless-trim.js +455 -34
- package/dist/features/four-source.js +338 -336
- package/dist/features/group-join-request.js +289 -287
- package/dist/features/local-models.js +1494 -0
- package/dist/features/rotate-summarizer.js +438 -0
- package/dist/features/scenario-detect.js +321 -0
- package/dist/features/scheduler.js +8 -1
- package/dist/features/session-rotate.js +499 -0
- package/dist/features/session-title.js +199 -0
- package/dist/features/style-layer.js +501 -0
- package/dist/features/thinking-log.js +71 -69
- package/dist/gateway/bootstrap.js +1704 -1388
- package/dist/gateway/data-root.js +77 -3
- package/dist/gateway/middleware-setup.js +6 -3
- package/dist/index.js +4 -2
- package/dist/model/settings-reader.js +193 -102
- package/dist/session/session-manager.js +1730 -1587
- package/dist/shared/paths.js +128 -0
- package/dist/shared/settings-io.js +79 -0
- package/dist/transport/inbound.js +20 -1
- package/dist/transport/outbound.js +56 -4
- package/docs/RELEASE_CHECKLIST.md +24 -2
- package/dshqqbot/.qqbot-extensions/hooks/interview-panel.mjs +41 -1
- package/dshqqbot/.qqbot-extensions/inbound/00-vision.mjs +111 -0
- package/dshqqbot/.qqbot-extensions/inbound/aa-memory-recall.mjs +802 -689
- package/dshqqbot/.qqbot-extensions/inbound/ac-image-see.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/inbound/az-feedback.mjs +113 -115
- package/dshqqbot/.qqbot-extensions/inbound/local-answer.mjs +689 -568
- package/dshqqbot/.qqbot-extensions/lib/.pet-form.json +1 -1
- package/dshqqbot/.qqbot-extensions/lib/draw-core.mjs +238 -7
- package/dshqqbot/.qqbot-extensions/lib/local-llm.mjs +455 -394
- package/dshqqbot/.qqbot-extensions/lib/memory-agent.mjs +930 -928
- package/dshqqbot/.qqbot-extensions/lib/memory-core.mjs +537 -537
- package/dshqqbot/.qqbot-extensions/lib/memory-db.mjs +2476 -2245
- package/dshqqbot/.qqbot-extensions/lib/memory-hippo.mjs +18 -0
- package/dshqqbot/.qqbot-extensions/lib/memory.mjs +191 -186
- package/dshqqbot/.qqbot-extensions/lib/plugin-dir.mjs +14 -4
- package/dshqqbot/.qqbot-extensions/lib/scope-util.mjs +84 -0
- package/dshqqbot/.qqbot-extensions/lib/vision.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/outbound/aa-sanitize.mjs +158 -154
- package/dshqqbot/.qqbot-extensions/outbound/ac-media-fix.mjs +5 -1
- package/dshqqbot/.qqbot-extensions/outbound/memory-agent.mjs +121 -130
- package/dshqqbot/.qqbot-extensions/outbound/split-reply.mjs +18 -2
- package/dshqqbot/.qqbot-extensions/outbound/turn-memory.mjs +92 -101
- package/dshqqbot/.qqbot-extensions/tools/draw.mjs +22 -1
- package/dshqqbot/.qqbot-extensions/tools/memory.mjs +178 -120
- package/dshqqbot/.qqbot-extensions/tools/pet_card.mjs +3 -2
- package/dshqqbot/.qqbot-extensions/tools/storyboard.mjs +3 -1
- package/dshqqbot/.qqbot-extensions/vendor/abogus/test-abogus.mjs +128 -126
- package/package.json +119 -111
- package/scripts/__pycache__/fan-mode.cpython-311.pyc +0 -0
- package/scripts/__pycache__/memory-audit.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-ip-sync.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-whitelist.cpython-311.pyc +0 -0
- package/scripts/_add_maintenance_cfg.py +20 -0
- package/scripts/_bench_keeplease.sh +10 -0
- package/scripts/_dbg_purge.py +15 -0
- package/scripts/_elev.sh +6 -0
- package/scripts/_fix_all_admin.cmd +16 -0
- package/scripts/_livecheck-image.mjs +33 -0
- package/scripts/_livecheck-llm.mjs +34 -0
- package/scripts/_livecheck-tts.mjs +37 -0
- package/scripts/_patch_curve.py +88 -0
- package/scripts/_patch_fan_thermal.py +24 -0
- package/scripts/_tag_tmp.py +13 -0
- package/scripts/adb-broker-client.mjs +87 -0
- package/scripts/adb-broker.mjs +205 -0
- package/scripts/ai-mode.cmd +6 -0
- package/scripts/ai-mode.py +387 -0
- package/scripts/ai-toolkit.py +607 -0
- package/scripts/apply-fan-gpu45.py +51 -0
- package/scripts/bench-fans.py +515 -0
- package/scripts/bench-load-direct.py +63 -0
- package/scripts/boot-tasks-hidden.vbs +20 -0
- package/scripts/boot-tasks.cmd +277 -0
- package/scripts/chat-archive/__pycache__/build-sft-v4.cpython-311.pyc +0 -0
- package/scripts/chat-archive/__pycache__/build-sft.cpython-311.pyc +0 -0
- package/scripts/chat-archive/build-sft-v4.py +566 -0
- package/scripts/chat-archive/build-sft.py +390 -0
- package/scripts/chat-archive/eval-sft.py +155 -0
- package/scripts/chat-archive/extract-memory.py +143 -0
- package/scripts/chat-archive/inventory.py +182 -0
- package/scripts/chat-archive/merge-sft.py +114 -0
- package/scripts/chat-archive/qce-pull.py +217 -0
- package/scripts/chat-archive/qqheader.py +110 -0
- package/scripts/chat-archive/qqkey2.py +113 -0
- package/scripts/chat-archive/qqprobe.py +153 -0
- package/scripts/chat-archive/screen-collect.py +163 -0
- package/scripts/chat-archive/sqlcipher_probe.py +444 -0
- package/scripts/comfy_gen.py +209 -0
- package/scripts/compose-video.py +168 -0
- package/scripts/dl_models.py +45 -0
- package/scripts/draw-now.cmd +18 -0
- package/scripts/dsh-instance-guard.mjs +20 -2
- package/scripts/elev-extra.cmd +25 -0
- package/scripts/episode.py +529 -0
- package/scripts/fan-curve.py +218 -0
- package/scripts/fan-guard.cmd +8 -0
- package/scripts/fan-mode.py +380 -0
- package/scripts/fan_manual_safe.py +33 -0
- package/scripts/fan_restore_manual.py +46 -0
- package/scripts/fc_curves.py +359 -0
- package/scripts/fix-fan-and-timers.cmd +39 -0
- package/scripts/fix_admin_all.py +94 -0
- package/scripts/flows.mjs +224 -0
- package/scripts/gateway.cmd +126 -0
- package/scripts/gen-image.py +420 -0
- package/scripts/gen-video.py +186 -0
- package/scripts/git-askpass.cmd +2 -2
- package/scripts/gpu-mode.py +195 -0
- package/scripts/hw-profile.py +175 -0
- package/scripts/install-schedule.cmd +37 -0
- package/scripts/install-watch.cmd +29 -0
- package/scripts/matte-cutout.py +106 -0
- package/scripts/media-enhance.py +402 -0
- package/scripts/memory-audit.py +581 -0
- package/scripts/migrate-scope.mjs +140 -139
- package/scripts/model-registry.py +519 -0
- package/scripts/openid-audit.mjs +219 -0
- package/scripts/pull-gguf.py +127 -0
- package/scripts/purge-standby.py +151 -0
- package/scripts/qq-connect-login.py +133 -0
- package/scripts/qq-ip-sync-hidden.vbs +5 -0
- package/scripts/qq-ip-sync.py +300 -0
- package/scripts/qq-login-once.cmd +20 -0
- package/scripts/qq-login-qr.py +72 -0
- package/scripts/qq-whitelist-fix.cmd +27 -0
- package/scripts/qq-whitelist-login.cmd +26 -0
- package/scripts/qq-whitelist.cmd +12 -0
- package/scripts/qq-whitelist.py +1452 -0
- package/scripts/quality-compare.py +134 -0
- package/scripts/release-all.mjs +636 -430
- package/scripts/release-check.mjs +244 -226
- package/scripts/resume-coder.cmd +38 -0
- package/scripts/secure-room/index.html +334 -0
- package/scripts/secure-room/server.py +582 -0
- package/scripts/security-check.mjs +164 -0
- package/scripts/selftest-local-llm.mjs +20 -0
- package/scripts/selftest-local-models.mjs +754 -0
- package/scripts/selftest-rotate-style.mjs +308 -0
- package/scripts/shutdown-s5-optional.cmd +21 -0
- package/scripts/sleep-2325.cmd +75 -0
- package/scripts/start-comfyui.cmd +5 -0
- package/scripts/start-strata.cmd +17 -0
- package/scripts/start-strata.vbs +11 -0
- package/scripts/start-watch-hidden.vbs +3 -0
- package/scripts/stickers/auto-tag.mjs +161 -0
- package/scripts/storage.mjs +236 -0
- package/scripts/sync-plugin-copies.mjs +98 -23
- package/scripts/tests/test-qq-whitelist.py +192 -0
- package/scripts/train/__pycache__/train-lora.cpython-311.pyc +0 -0
- package/scripts/train/gguf-quantize.py +92 -0
- package/scripts/train/gguf-to-hf.py +112 -0
- package/scripts/train/merge-lora.py +51 -0
- package/scripts/train/probe-mirrors.sh +12 -0
- package/scripts/train/probe-mirrors2.sh +20 -0
- package/scripts/train/setup-wsl.sh +23 -0
- package/scripts/train/setup-wsl2.sh +25 -0
- package/scripts/train/setup-wsl3.sh +22 -0
- package/scripts/train/setup-wsl4.sh +22 -0
- package/scripts/train/train-lora.py +319 -0
- package/scripts/vram-free.py +104 -0
- package/scripts/wechat-full-pull.mjs +1 -1
- package/settings-host.js +1047 -12
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session-title.js — QQ 会话命名(2026-11-30)
|
|
3
|
+
*
|
|
4
|
+
* 问题:dsh 侧边栏里的 QQ 会话标题全是自动生成的模糊短句(取第一条消息),
|
|
5
|
+
* 同一个人的私聊/同一个群换档后出现多个窗口,人根本分不清谁是谁。
|
|
6
|
+
*
|
|
7
|
+
* 做法:会话创建后调宿主 `sessionTitle` 服务 rename 成固定格式:
|
|
8
|
+
* · 群聊:`群·<群名> 会话N`
|
|
9
|
+
* · 私聊:`私聊·<昵称> 会话N`
|
|
10
|
+
* · 拿不到名字时退化成 id 尾号(`群·…a1b2 会话1`),绝不写空标题。
|
|
11
|
+
*
|
|
12
|
+
* 名字来源(只读本地台账,不联网):
|
|
13
|
+
* · 群名:{dataRoot}/.qqbot/groups.json(群注册表,和 AI 寻址共用同一份)
|
|
14
|
+
* · 私聊昵称:{dataRoot}/.qqbot/known-chats.jsonl(chat-ledger 写的台账,取最近一次昵称)
|
|
15
|
+
*
|
|
16
|
+
* 兼容:
|
|
17
|
+
* · 宿主没有 sessionTitle 服务 / 会话不是 live / 标题非法 → 全程 try/catch,绝不影响入站;
|
|
18
|
+
* · 只在**新建会话**时命名;resume 的旧会话只在标题为空时补一次,不覆盖人手动改过的标题。
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
|
|
23
|
+
const SEQ_VERSION = 1;
|
|
24
|
+
const NAME_MAX = 24;
|
|
25
|
+
|
|
26
|
+
function seqPathOf(dataRoot) {
|
|
27
|
+
return join(String(dataRoot || '.'), '.qqbot', 'session-title-seq.json');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function loadSeq(dataRoot) {
|
|
31
|
+
try {
|
|
32
|
+
const p = seqPathOf(dataRoot);
|
|
33
|
+
if (!existsSync(p)) return { v: SEQ_VERSION, peers: {} };
|
|
34
|
+
const raw = JSON.parse(readFileSync(p, 'utf8'));
|
|
35
|
+
return { v: SEQ_VERSION, peers: (raw && typeof raw.peers === 'object' && raw.peers) || {} };
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return { v: SEQ_VERSION, peers: {} };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function saveSeq(dataRoot, state) {
|
|
43
|
+
try {
|
|
44
|
+
const p = seqPathOf(dataRoot);
|
|
45
|
+
mkdirSync(join(String(dataRoot || '.'), '.qqbot'), { recursive: true });
|
|
46
|
+
const body = JSON.stringify({ v: SEQ_VERSION, peers: state.peers }, null, 1);
|
|
47
|
+
const tmp = p + '.tmp';
|
|
48
|
+
writeFileSync(tmp, body, 'utf8');
|
|
49
|
+
try { renameSync(tmp, p); }
|
|
50
|
+
catch { writeFileSync(p, body, 'utf8'); }
|
|
51
|
+
}
|
|
52
|
+
catch { /* 序号记不下就退化成 1,不影响主链 */ }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 台账/群注册表缓存(按 mtime+size 失效,避免每条消息重读) */
|
|
56
|
+
const _namesCache = new Map(); // file → { key, map }
|
|
57
|
+
function readJsonMap(file) {
|
|
58
|
+
let key = 'missing';
|
|
59
|
+
try {
|
|
60
|
+
const st = statSync(file);
|
|
61
|
+
key = `${st.mtimeMs}:${st.size}`;
|
|
62
|
+
}
|
|
63
|
+
catch { /* 文件还没有 */ }
|
|
64
|
+
const hit = _namesCache.get(file);
|
|
65
|
+
if (hit && hit.key === key) return hit.map;
|
|
66
|
+
const map = new Map();
|
|
67
|
+
try {
|
|
68
|
+
const raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
69
|
+
for (const [id, v] of Object.entries(raw || {})) {
|
|
70
|
+
const name = typeof v === 'string' ? v : (v && (v.name || v.groupName || v.group_name));
|
|
71
|
+
if (typeof name === 'string' && name.trim()) map.set(String(id), name.trim());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { /* 读不出就当空 */ }
|
|
75
|
+
_namesCache.set(file, { key, map });
|
|
76
|
+
return map;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** known-chats.jsonl → scope:id → 最近一次昵称 */
|
|
80
|
+
function readLedgerNames(file) {
|
|
81
|
+
let key = 'missing';
|
|
82
|
+
try {
|
|
83
|
+
const st = statSync(file);
|
|
84
|
+
key = `${st.mtimeMs}:${st.size}`;
|
|
85
|
+
}
|
|
86
|
+
catch { /* 还没有台账 */ }
|
|
87
|
+
const hit = _namesCache.get(file);
|
|
88
|
+
if (hit && hit.key === key) return hit.map;
|
|
89
|
+
const map = new Map();
|
|
90
|
+
try {
|
|
91
|
+
const raw = readFileSync(file, 'utf8');
|
|
92
|
+
for (const line of raw.split('\n')) {
|
|
93
|
+
const t = line.trim();
|
|
94
|
+
if (!t) continue;
|
|
95
|
+
try {
|
|
96
|
+
const o = JSON.parse(t);
|
|
97
|
+
if (!o || typeof o.id !== 'string' || !o.id) continue;
|
|
98
|
+
const name = typeof o.name === 'string' ? o.name.trim() : '';
|
|
99
|
+
if (!name) continue;
|
|
100
|
+
map.set(String(o.scope || '') + ':' + o.id, name);
|
|
101
|
+
}
|
|
102
|
+
catch { /* 坏行跳过 */ }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch { /* 台账读不出就当空 */ }
|
|
106
|
+
_namesCache.set(file, { key, map });
|
|
107
|
+
return map;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function cleanName(raw) {
|
|
111
|
+
const s = String(raw || '')
|
|
112
|
+
.replace(/[\r\n\t]+/g, ' ')
|
|
113
|
+
.replace(/[\\/:*?"<>|]/g, '')
|
|
114
|
+
.replace(/\s+/g, ' ')
|
|
115
|
+
.trim();
|
|
116
|
+
if (!s) return '';
|
|
117
|
+
return s.length > NAME_MAX ? s.slice(0, NAME_MAX - 1) + '…' : s;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** 这个 peer 显示名(群名 / 私聊昵称);找不到给 id 尾号 */
|
|
121
|
+
export function peerDisplayName(dataRoot, scope, peerId) {
|
|
122
|
+
const id = String(peerId || '');
|
|
123
|
+
const root = String(dataRoot || '');
|
|
124
|
+
if (!id) return '';
|
|
125
|
+
try {
|
|
126
|
+
if (scope === 'group') {
|
|
127
|
+
const reg = readJsonMap(join(root, '.qqbot', 'groups.json'));
|
|
128
|
+
const nm = cleanName(reg.get(id));
|
|
129
|
+
if (nm) return nm;
|
|
130
|
+
}
|
|
131
|
+
const ledger = readLedgerNames(join(root, '.qqbot', 'known-chats.jsonl'));
|
|
132
|
+
const nm2 = cleanName(ledger.get(String(scope || '') + ':' + id));
|
|
133
|
+
if (nm2) return nm2;
|
|
134
|
+
}
|
|
135
|
+
catch { /* 名字读不到就走尾号 */ }
|
|
136
|
+
return '…' + id.slice(-4);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** 标题前缀:群 / 私聊 */
|
|
140
|
+
export function titlePrefixOf(scope) {
|
|
141
|
+
return scope === 'group' ? '群' : '私聊';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** 当前序号(不递增) */
|
|
145
|
+
export function peekSessionTitle({ dataRoot, scope, peerId } = {}) {
|
|
146
|
+
const st = loadSeq(dataRoot);
|
|
147
|
+
const n = Number(st.peers[String(scope) + ':' + String(peerId)]) || 0;
|
|
148
|
+
return `${titlePrefixOf(scope)}·${peerDisplayName(dataRoot, scope, peerId)} 会话${Math.max(1, n)}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** 新建会话时取下一个序号并落盘 */
|
|
152
|
+
export function nextSessionTitle({ dataRoot, scope, peerId } = {}) {
|
|
153
|
+
const st = loadSeq(dataRoot);
|
|
154
|
+
const key = String(scope) + ':' + String(peerId);
|
|
155
|
+
const n = (Number(st.peers[key]) || 0) + 1;
|
|
156
|
+
st.peers[key] = n;
|
|
157
|
+
saveSeq(dataRoot, st);
|
|
158
|
+
return `${titlePrefixOf(scope)}·${peerDisplayName(dataRoot, scope, peerId)} 会话${n}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function titleServiceOf(ctx) {
|
|
162
|
+
try {
|
|
163
|
+
const svc = typeof ctx?.get === 'function' ? ctx.get('sessionTitle') : null;
|
|
164
|
+
return svc && typeof svc.rename === 'function' ? svc : null;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 给一个 live 会话命名。
|
|
173
|
+
* @param {object} opts
|
|
174
|
+
* @param {object} opts.ctx 插件 cordis ctx(取宿主 sessionTitle 服务)
|
|
175
|
+
* @param {object} opts.session agent.session(必须是 live)
|
|
176
|
+
* @param {boolean} opts.fresh true=新建会话(递增序号);false=resume(标题为空才补)
|
|
177
|
+
* @returns {string} 实际写入的标题(没写就是空串)
|
|
178
|
+
*/
|
|
179
|
+
export function nameSession({ ctx, session, dataRoot, scope, peerId, fresh = false, logger } = {}) {
|
|
180
|
+
try {
|
|
181
|
+
if (!session) return '';
|
|
182
|
+
const svc = titleServiceOf(ctx);
|
|
183
|
+
if (!svc) return '';
|
|
184
|
+
let current = '';
|
|
185
|
+
try { current = String(svc.get?.(session)?.title || ''); }
|
|
186
|
+
catch { current = ''; }
|
|
187
|
+
if (!fresh && current) return ''; // 旧会话已有标题(人改的 / 上次命名的)→ 不动
|
|
188
|
+
const title = fresh
|
|
189
|
+
? nextSessionTitle({ dataRoot, scope, peerId })
|
|
190
|
+
: peekSessionTitle({ dataRoot, scope, peerId });
|
|
191
|
+
svc.rename(session, title);
|
|
192
|
+
logger?.debug?.(`[title] 会话命名: ${title}`);
|
|
193
|
+
return title;
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
logger?.debug?.(`[title] 命名失败(已忽略): ${err instanceof Error ? err.message : String(err)}`);
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
}
|