dsh-qqbot-muu 0.1.20 → 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 -154
- package/client/qqbot-settings.js +13401 -13380
- package/dist/config.js +573 -581
- package/dist/features/contextless-store.js +247 -247
- package/dist/features/four-source.js +338 -336
- package/dist/features/group-join-request.js +289 -287
- package/dist/features/local-models.js +1494 -1467
- package/dist/features/style-layer.js +501 -498
- package/dist/features/thinking-log.js +71 -69
- package/dist/gateway/bootstrap.js +1704 -1652
- package/dist/model/settings-reader.js +193 -102
- package/dist/shared/paths.js +128 -0
- package/dist/shared/settings-io.js +79 -83
- package/dshqqbot/.qqbot-extensions/inbound/00-vision.mjs +111 -0
- package/dshqqbot/.qqbot-extensions/inbound/aa-memory-recall.mjs +802 -794
- 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/local-llm.mjs +455 -444
- 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/scope-util.mjs +84 -0
- package/dshqqbot/.qqbot-extensions/outbound/aa-sanitize.mjs +158 -154
- package/dshqqbot/.qqbot-extensions/outbound/memory-agent.mjs +121 -130
- package/dshqqbot/.qqbot-extensions/outbound/turn-memory.mjs +92 -101
- package/dshqqbot/.qqbot-extensions/tools/memory.mjs +178 -120
- package/dshqqbot/.qqbot-extensions/vendor/abogus/test-abogus.mjs +128 -126
- package/package.json +119 -118
- 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/ai-toolkit.py +607 -478
- 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/episode.py +529 -0
- package/scripts/fan-curve.py +218 -0
- package/scripts/fan-guard.cmd +8 -0
- package/scripts/fan-mode.py +380 -263
- package/scripts/gen-image.py +420 -413
- package/scripts/gen-video.py +186 -178
- package/scripts/hw-profile.py +175 -0
- package/scripts/media-enhance.py +402 -0
- package/scripts/memory-audit.py +581 -0
- package/scripts/migrate-scope.mjs +140 -139
- 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-whitelist.py +71 -0
- package/scripts/release-all.mjs +636 -509
- package/scripts/release-check.mjs +244 -226
- package/scripts/secure-room/index.html +334 -0
- package/scripts/secure-room/server.py +582 -0
- package/scripts/stickers/auto-tag.mjs +161 -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/dist/_backup_ctx_20261125_183653/dist/config.d.ts +0 -473
- package/dist/_backup_ctx_20261125_183653/dist/config.js +0 -450
- package/dist/_backup_ctx_20261125_183653/dist/features/contextless-trim.js +0 -304
- package/dist/_backup_ctx_20261125_183653/dist/session/session-manager.js +0 -1588
- package/dist/_backup_ctx_20261125_183653/dist/transport/inbound.js +0 -1567
- package/dist/_backup_ctx_20261125_183653/dist/transport/outbound.js +0 -647
- package/scripts/__pycache__/ai-mode.cpython-311.pyc +0 -0
- package/scripts/__pycache__/ai-toolkit.cpython-311.pyc +0 -0
- package/scripts/__pycache__/comfy_gen.cpython-311.pyc +0 -0
- package/scripts/__pycache__/gen-image.cpython-311.pyc +0 -0
- package/scripts/__pycache__/gen-video.cpython-311.pyc +0 -0
- package/scripts/__pycache__/model-registry.cpython-311.pyc +0 -0
- package/scripts/__pycache__/purge-standby.cpython-311.pyc +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 00-vision.mjs — 图片先"看"再答:本地视觉模型把图转成一句话,喂给后面的链路
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有它(2026-12-02 主人反馈):
|
|
5
|
+
* 插件收到纯图片时,正文是空的,`local-answer` 只会记一条 `empty:media` 就交给云端;
|
|
6
|
+
* 而云端默认模型(deepseek-flash)**没有视觉**,于是"发了图它却答不上来/瞎猜"。
|
|
7
|
+
* 现在在最前面挂一跳:本地 qwen3-vl:8b 先看图,把描述以 `[看见]…[/看见]` 拼进 ctx.text,
|
|
8
|
+
* 后面的记忆召回、本地代答、云端上下文就都能"看见"这张图了。
|
|
9
|
+
*
|
|
10
|
+
* 只读、离线:图片只发到 127.0.0.1:11434,不写库、不落长期缓存(临时文件用完即删)。
|
|
11
|
+
* 配置:local-llm-config.json 里 `visionBridge: false` 可整关;`visionModel` 换模型。
|
|
12
|
+
*/
|
|
13
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { createHash } from 'node:crypto';
|
|
16
|
+
import { dataRootOf, loadConfig } from '../lib/local-llm.mjs';
|
|
17
|
+
|
|
18
|
+
export const name = 'vision-bridge';
|
|
19
|
+
|
|
20
|
+
const OLLAMA = 'http://127.0.0.1:11434';
|
|
21
|
+
const DEFAULT_MODEL = 'qwen3-vl:8b';
|
|
22
|
+
const PROMPT = '用中文一句话说清这张图里有什么(人物/场景/文字要点),不超过 60 字,不要客套。';
|
|
23
|
+
|
|
24
|
+
function attachmentsOf(ctx) {
|
|
25
|
+
return Array.isArray(ctx?.message?.attachments) ? ctx.message.attachments : [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function imageAtts(ctx) {
|
|
29
|
+
return attachmentsOf(ctx).filter((a) => /image/i.test(String(a?.contentType || a?.type || '')));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function tmpDir(root) {
|
|
33
|
+
const d = join(String(root || '.'), '.qqbot', 'vision-tmp');
|
|
34
|
+
try { mkdirSync(d, { recursive: true }); } catch { /* ignore */ }
|
|
35
|
+
return d;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 取图片的 base64:优先本地路径,其次下载;失败返回空串 */
|
|
39
|
+
async function imageToB64(att, root) {
|
|
40
|
+
const p = att?.localPath || att?.path || att?.filePath;
|
|
41
|
+
if (p) {
|
|
42
|
+
try { return Buffer.from(readFileSync(p)).toString('base64'); } catch { /* 继续走下载 */ }
|
|
43
|
+
}
|
|
44
|
+
const url = att?.url || att?.fileUrl || att?.src;
|
|
45
|
+
if (!url || !/^https?:/i.test(String(url))) return '';
|
|
46
|
+
try {
|
|
47
|
+
const r = await fetch(url, { signal: AbortSignal.timeout(15000) });
|
|
48
|
+
if (!r.ok) return '';
|
|
49
|
+
const buf = Buffer.from(await r.arrayBuffer());
|
|
50
|
+
if (buf.length < 256) return '';
|
|
51
|
+
const f = join(tmpDir(root), createHash('sha1').update(buf).digest('hex').slice(0, 16) + '.img');
|
|
52
|
+
try { writeFileSync(f, buf); } catch { /* 落不了盘也能直接送 */ }
|
|
53
|
+
return buf.toString('base64');
|
|
54
|
+
} catch {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function describe(b64, cfg) {
|
|
60
|
+
const model = String(cfg?.visionModel || DEFAULT_MODEL);
|
|
61
|
+
const body = {
|
|
62
|
+
model,
|
|
63
|
+
stream: false,
|
|
64
|
+
think: false,
|
|
65
|
+
messages: [{ role: 'user', content: PROMPT, images: [b64] }],
|
|
66
|
+
options: { temperature: 0.2, num_predict: 160 },
|
|
67
|
+
};
|
|
68
|
+
const r = await fetch(OLLAMA + '/api/chat', {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: { 'content-type': 'application/json' },
|
|
71
|
+
body: JSON.stringify(body),
|
|
72
|
+
signal: AbortSignal.timeout(Number(cfg?.visionTimeoutMs) || 45000),
|
|
73
|
+
});
|
|
74
|
+
if (!r.ok) return '';
|
|
75
|
+
const j = await r.json();
|
|
76
|
+
const text = String(j?.message?.content || j?.message?.thinking || '').trim();
|
|
77
|
+
return text.replace(/\s+/g, ' ').slice(0, 120);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function onInbound(ctx, next) {
|
|
81
|
+
try {
|
|
82
|
+
let cfg = loadConfig(dataRootOf({}));
|
|
83
|
+
cfg = loadConfig(dataRootOf(cfg));
|
|
84
|
+
if (cfg?.visionBridge === false) return next();
|
|
85
|
+
const imgs = imageAtts(ctx);
|
|
86
|
+
if (!imgs.length) return next();
|
|
87
|
+
const root = String(cfg?.dataRoot || dataRootOf(cfg));
|
|
88
|
+
const desc = [];
|
|
89
|
+
for (const a of imgs.slice(0, 2)) {
|
|
90
|
+
const b64 = await imageToB64(a, root);
|
|
91
|
+
if (!b64) continue;
|
|
92
|
+
const d = await describe(b64, cfg);
|
|
93
|
+
if (d) desc.push(d);
|
|
94
|
+
}
|
|
95
|
+
// 清掉临时文件(只留上下文里的描述)
|
|
96
|
+
try {
|
|
97
|
+
const d = tmpDir(root);
|
|
98
|
+
const fs = await import('node:fs');
|
|
99
|
+
for (const f of fs.readdirSync(d)) rmSync(join(d, f), { force: true });
|
|
100
|
+
} catch { /* ignore */ }
|
|
101
|
+
if (desc.length) {
|
|
102
|
+
const block = `[看见]${desc.join(';')}[/看见]`;
|
|
103
|
+
ctx.text = String(ctx.text || '') + '\n' + block;
|
|
104
|
+
try { (ctx.state || (ctx.state = {})).visionText = desc.join(';'); } catch { /* ignore */ }
|
|
105
|
+
ctx?.logger?.info?.('[vision] 已识图:' + desc.join(';'));
|
|
106
|
+
}
|
|
107
|
+
} catch (e) {
|
|
108
|
+
ctx?.logger?.debug?.('[vision] 跳过:' + (e instanceof Error ? e.message : String(e)));
|
|
109
|
+
}
|
|
110
|
+
return next();
|
|
111
|
+
}
|