dsh-fish-soul 0.16.4 → 0.16.5

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
4
4
 
5
- DSH 插件(单角色 `feiyu`)。版本 **0.16.4**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.16.5**。
6
6
 
7
7
  QQ 交流群:**1125962189**
8
8
 
@@ -16,7 +16,7 @@ QQ 交流群:**1125962189**
16
16
  | QQ | 直连 SnowLuma(OneBot 11 正向 WS):私聊 / 群聊、群合批带署名、只听点名、戳一戳、撤回不回、可选插话、打字节奏、`/鱼 暂停`;**群默认拒绝**(`groupAllowList` 为空且没开 `allGroups` 时谁都不回)、**没发出去的回复排队重发**(退避重试,连上即补发,重启不丢) |
17
17
  | B站 | 扫码登录、私信(只读 / 自动回复)、跨平台认人、空闲自己刷视频(看字幕 / 热评 / 弹幕,喜欢可点赞、想再看可收藏,站内搜索当又一个来源,后三个默认关)、自己发动态 / 回评论(默认关;可选别人评论区里 @ 她也回,@ 时先读一下视频)、Cookie 自动续期、发图 |
18
18
  | 抖音 | 专用浏览器扫码登录、私信按会话 ID 认人(`0:1:我方:对方`,昵称只作展示;改名 / 同名都不串)、canary 防风控、空闲刷视频、自己发图文 / 回作品评论(默认关;图文须确认配乐成功才发布)、刷到的视频可发**原生视频卡片**给主人(默认关,见下) |
19
- | 习惯 | 心情影响说话(快慢、长短、插话概率、表情包多少)、**去 AI 味**(删 markdown / AI 自称 / 套话,太长按句末截)、**每晚写日记**(私密记忆,第二天想跟谁聊)、合并转发展开、每个群的设定(气氛 / 忌讳)、**按聊天选模型**、群冷热、记忆调试器(输一句话看会想起哪几条)、戳回去 / 表情回应 |
19
+ | 习惯 | 心情影响说话(快慢、长短、插话概率、表情包多少)、**去 AI 味**(删 markdown / AI 自称 / 套话,默认超出整轮字数上限时按句末截;可选「QQ 超长回复不截短」,仍按原规则分段、最多 5 条,过长消息是否送达取决于 QQ 和连接端)、**每晚写日记**(私密记忆,第二天想跟谁聊)、合并转发展开、每个群的设定(气氛 / 忌讳)、**按聊天选模型**、群冷热、记忆调试器(输一句话看会想起哪几条)、戳回去 / 表情回应 |
20
20
  | 语音 | `get_record` → STT;回复 `[语音]` → TTS 发 record(失败 / 太长发文字);听 / 说可以各配一套地址和 key。**听**支持 OpenAI 兼容(硅基流动 SenseVoice 等,走 `/audio/transcriptions`)、阿里百炼(走 `/chat/completions` + `input_audio`,百炼没有 `/audio/transcriptions`)、MiniMax(`/v1/speech_to_text`);**说**支持 OpenAI 兼容、小米 MiMo、火山引擎豆包语音(新版控制台只填 API Key 走 V3,默认 Resource ID `seed-tts-2.0`;老版填 AppID + Access Token 走 V1,集群默认 `volcano_tts`)、MiniMax(`/t2a_v2`,音色填控制台的 `voice_id`,可用复刻音色)。单次等待上限可调(默认 60 秒,长句不再被 20 秒掐掉) |
21
21
  | 模型 | 按功能选模型、按天 × 功能 × 模型统计用量与花费、可选上网查 |
22
22
  | 群管理 | 可选(默认关):发新版本时把更新说明发到指定群(自动盯 npm,同一版本只发一次)、处理入群申请(默认自动同意,也可改成私聊通知你、你回「/鱼 同意 / 拒绝」拍板);设置页「QQ 接入 → 群管理」里配开关与群号 |
@@ -51,6 +51,15 @@ dsh plugin --profile desktop add dsh-fish-soul
51
51
 
52
52
  `$DSH_HOME` 缺省 `~/.dsh`。
53
53
 
54
+ ### 可选:语音文件(#101)
55
+
56
+ 「模型 → 语音」里两项独立开关均默认关闭。保存 QQ 语音时,只处理原本会回复、已识别说话人的好友私聊和明确白名单群;不处理未获允许、暂停或无需回复的消息。优先保存消息提供的原始音频,无法取得原件时退回 `get_record` 转出的音频;文件名标 `original` 或 `converted`,扩展名按音频头判断,无法识别时为 `.bin`。原件为 SILK 或未知格式时,会尝试同时保存配对的转码分析文件(`analysis`),供音频插件使用。`voice-in` 最多保存 30 条,可以在设置里清空;文件未加密,清理不包含备份和复制件。为限制资源,单条消息最多处理前 30 段语音,STT 仍只转写前 2 段。
57
+
58
+ 如同时安装 `dsh-cixisound`,QQ 会话在宿主支持工具护栏且一轮只有一个已识别的说话人时,可通过 `sound_read` 分析本轮录音。受限会话只放行本轮路径和 `input` 参数,不开放通用文件访问;如果设置中已明确为主人或全部聊天放开宿主工具,则保持原有工具权限,`sound_read` 也可访问其他文件。需要已安装音频分析插件,安装后已有会话可能需要重开;原件格式不受该插件支持时不能保证分析成功。
59
+
60
+ 「DSH 里鱼的会话生成本地语音」仅对鱼的已登记会话里直接打字、正常完成的回复生成 `voice-out` 本地文件,不向 QQ 发送;不在对话框内播放。沿用「说」的服务、字数和每天次数上限,未就绪或失败时文字回复不受影响,最多保留 30 个文件;本地文件可能包含私密内容。
61
+
62
+
54
63
  | 路径 | 内容 |
55
64
  |---|---|
56
65
  | `fish-soul-config.json` | 全部设置(含 embedding `apiKey`) |
package/lib/behavior.js CHANGED
@@ -28,7 +28,7 @@ export function behaviorConfig(raw) {
28
28
  const o = v.outFilter ?? {}; const f = v.forward ?? {}; const ht = v.heat ?? {}; const ia = v.interactions ?? {}; const tm = v.turnMood ?? {}; const d = v.diary ?? {};
29
29
  return {
30
30
  moodAffects: bool(v.moodAffects, true),
31
- outFilter: { enabled: bool(o.enabled, true), maxChars: Math.floor(num(o.maxChars, 300, 60, 2000)), split: bool(o.split, true), extra: extraList(o.extra) },
31
+ outFilter: { enabled: bool(o.enabled, true), maxChars: Math.floor(num(o.maxChars, 300, 60, 2000)), split: bool(o.split, true), completeQq: bool(o.completeQq, false), extra: extraList(o.extra) },
32
32
  forward: { enabled: bool(f.enabled, true), maxLines: Math.floor(num(f.maxLines, 15, 3, 50)) },
33
33
  heat: {
34
34
  enabled: bool(ht.enabled, true), windowSec: num(ht.windowSec, 120, 30, 900), hotCount: Math.floor(num(ht.hotCount, 6, 3, 50)),
@@ -48,10 +48,12 @@ window.__ModuleLoader__.load({
48
48
  h(Switch, { label: "每轮判断心情", checked: cfg.turnMood.enabled, onChange: (v) => save({ turnMood: { enabled: v } }) })),
49
49
  cfg.turnMood.enabled ? Row({ title: "把握够多少才改", desc: "模型给的把握低于这个就不改情绪" },
50
50
  h(NumField, { ui, value: pct(cfg.turnMood.minConfidence), min: 0, max: 100, step: 5, label: "把握门槛", onSave: (n) => save({ turnMood: { minConfidence: n / 100 } }) }), Muted("%")) : null,
51
- Row({ title: "去 AI 味", desc: "发出去之前去掉\"作为 AI / 希望对你有帮助 / 好问题 / 让我们来看看\"、括号里的动作描写(\"(揉了揉眼睛)\")和 markdown,太长的截到句末;也会提醒她别这么说" },
51
+ Row({ title: "去 AI 味", desc: "发出去之前去掉\"作为 AI / 希望对你有帮助 / 好问题 / 让我们来看看\"、括号里的动作描写(\"(揉了揉眼睛)\")和 markdown;也会提醒她别这么说" },
52
52
  h(Switch, { label: "去 AI 味", checked: cfg.outFilter.enabled, onChange: (v) => save({ outFilter: { enabled: v } }) })),
53
- cfg.outFilter.enabled ? Row({ title: "一次最多说多少字" },
53
+ cfg.outFilter.enabled ? Row({ title: "一次最多说多少字", desc: "整轮回复的总字数上限,超出会截短;QQ 开启下方选项后不受此上限限制" },
54
54
  h(NumField, { ui, value: cfg.outFilter.maxChars, min: 60, max: 2000, step: 10, label: "最多字数", onSave: (n) => save({ outFilter: { maxChars: n } }) }), Muted("字")) : null,
55
+ cfg.outFilter.enabled ? Row({ title: "QQ 超长回复不截短", desc: "默认关。开启后 QQ 回复不按总字数截短,仍会去 AI 味、去重并按原规则分段(最多 5 条);其他平台不受影响。过长消息是否送达取决于 QQ 和连接端" },
56
+ h(Switch, { label: "QQ 超长回复不截短", checked: cfg.outFilter.completeQq, onChange: (v) => save({ outFilter: { completeQq: v } }) })) : null,
55
57
  cfg.outFilter.enabled ? Row({ title: "自动拆成几条", desc: "一段里好几句时按句号拆开发(一段最多 3 条、每次拆法不一样),句尾的句号去掉;问号、感叹号、省略号留着" },
56
58
  h(Switch, { label: "自动拆成几条", checked: cfg.outFilter.split, onChange: (v) => save({ outFilter: { split: v } }) })) : null,
57
59
  cfg.outFilter.enabled ? Row({ title: "额外要删的说法", desc: "一行一个,发出去之前删掉;写成 /正则/ 也行。删了什么在「动态」里能看到", stack: true },
@@ -145,7 +145,8 @@ window.__ModuleLoader__.load({
145
145
 
146
146
  /** 语音:听 QQ 语音 + 发语音 */
147
147
  function Voice({ api, notify, ui }) {
148
- const { h, Group, Row, Switch, Input, Secret, Seg, Num, Muted, State, Button } = ui;
148
+ const { h, Group, Row, Switch, Input, Secret, Seg, Num, Muted, State, Button, useConfirm } = ui;
149
+ const [confirm, confirmNode] = useConfirm();
149
150
  const [v, load] = useLoad(api, "/voice/state");
150
151
  const [form, setForm] = react.useState(null);
151
152
  const [busy, setBusy] = react.useState(false);
@@ -180,6 +181,15 @@ window.__ModuleLoader__.load({
180
181
  const r = await api("POST", "/voice/config", { ...rest, ...keys, ttsPerDay: Number(next.ttsPerDay), sttPerDay: Number(next.sttPerDay), maxChars: Number(next.maxChars), timeoutSec: Number(next.timeoutSec), ...p });
181
182
  if (r?.ok) { if (Object.keys(keys).length > 0) patch({ sttApiKey: "", ttsApiKey: "" }); load(); } else notify(r?.error ?? "保存失败");
182
183
  }
184
+ async function setIncoming(x) {
185
+ if (x && !(await confirm({ title: "保存 QQ 语音", description: "会把需要回复的好友私聊或白名单群语音以未加密文件保存到本机,最多 30 条;备份和复制件需另行清理。继续吗?" }))) return;
186
+ await save({ saveIncoming: x });
187
+ }
188
+ async function clearIncoming() {
189
+ if (!(await confirm({ title: "清空 QQ 语音", description: "永久删除插件保存的入站语音;备份和复制件需另行清理。继续吗?", danger: true }))) return;
190
+ const r = await api("POST", "/voice/clear-incoming", {});
191
+ if (r?.ok) { notify(`已清理 ${r.removed} 条`); load(); } else notify(r?.error ?? "清理失败");
192
+ }
183
193
  async function test() {
184
194
  setBusy(true);
185
195
  const r = await api("POST", "/voice/test", { text: say });
@@ -198,6 +208,10 @@ window.__ModuleLoader__.load({
198
208
  Group({ title: "语音" },
199
209
  Row({ title: "语音", desc: on ? "听和说可以用不同的服务,各填各的;地址或 key 留空就沿用另一组 / 记忆检索的" : "能听懂 QQ 语音,也会偶尔发语音" }, status, h(Switch, { label: "语音", checked: on, onChange: (x) => save({ enabled: x }) })),
200
210
  on ? Row({ title: "什么时候发语音" }, h(Seg, { label: "什么时候发语音", value: v.speak, options: SPEAK, onChange: (x) => save({ speak: x }) })) : null),
211
+ on ? Group({ title: "语音文件" },
212
+ Row({ title: "保存收到的 QQ 语音", desc: `仅保存需回复的好友私聊和明确白名单群语音,最多 30 条;未加密。目录:${v.incomingDir}。受限会话的 sound_read 仅能分析本轮单一说话人文件;已放开工具的会话保留原有权限。安装插件后可能需要重开会话。` }, h(Switch, { label: "保存收到的 QQ 语音", checked: v.saveIncoming === true, onChange: setIncoming })),
213
+ Row({ title: "清理 QQ 语音", desc: v.filesError || `当前 ${v.incomingCount ?? 0} 条;不删除备份或复制件` }, Button({ onClick: clearIncoming }, "清空")),
214
+ Row({ title: "DSH 里鱼的会话生成本地语音", desc: `使用「说」的服务与配额;不会发送 QQ。超字数或失败保留文字。最多保留 30 条,目录:${v.desktopDir}${v.desktopLatest ? `;最近:${v.desktopLatest}` : ""}` }, h(Switch, { label: "DSH 里鱼的会话生成本地语音", checked: v.desktopTts === true, onChange: (x) => save({ desktopTts: x }) }))) : null,
201
215
  on ? Group({ title: "听(语音转文字)", aside: sideState(stt, v.sttLeft) },
202
216
  Row({ title: "服务商", desc: "百炼和 MiniMax 的端点跟 OpenAI 不一样,选错了会一直「听不到」" }, h(Seg, { label: "听的服务商", value: form.sttProvider, options: STT_PROVIDERS, onChange: (x) => { patch({ sttProvider: x }); save({ sttProvider: x }); } })),
203
217
  Row({ title: "接口地址", desc: sttDash ? "阿里百炼填 https://dashscope.aliyuncs.com/compatible-mode/v1" : sttMini ? "MiniMax 填 https://api.minimax.cn/v1" : "" }, field("sttBaseURL", { placeholder: stt.effectiveBaseURL || "https://api.siliconflow.cn/v1", "aria-label": "听的接口地址" })),
@@ -216,7 +230,7 @@ window.__ModuleLoader__.load({
216
230
  v.speak !== "never" ? Row({ title: "一条语音最多" }, Num({ min: 10, max: 200, value: form.maxChars, "aria-label": "字数", onChange: (e) => patch({ maxChars: e.target.value }), onBlur: () => save() }), Muted("字")) : null,
217
231
  Row({ title: "每天最多" }, Num({ min: 0, max: 500, value: form.ttsPerDay, "aria-label": "每天最多说", onChange: (e) => patch({ ttsPerDay: e.target.value }), onBlur: () => save() }), Muted("条")),
218
232
  Row({ title: "最多等", desc: "长一点的语音合成会超过 20 秒,等不到就白合成一次。听也共用这个上限" }, Num({ min: 5, max: 300, value: form.timeoutSec, "aria-label": "最多等几秒", onChange: (e) => patch({ timeoutSec: e.target.value }), onBlur: () => save() }), Muted("秒")),
219
- tts.hasKey ? Row({ title: "试听" }, Input({ value: say, onChange: (e) => setSay(e.target.value), "aria-label": "试听的话" }), Button({ disabled: busy, onClick: test }, busy ? "合成中" : "播放")) : null) : null);
233
+ tts.hasKey ? Row({ title: "试听" }, Input({ value: say, onChange: (e) => setSay(e.target.value), "aria-label": "试听的话" }), Button({ disabled: busy, onClick: test }, busy ? "合成中" : "播放")) : null) : null, confirmNode);
220
234
  }
221
235
 
222
236
  function ModelsPane({ api, notify, ui, section = "models" }) {
@@ -59,6 +59,8 @@ export function fishSoulConfigSchema(z) {
59
59
  modelPrices: z.dict(z.any()).default({}),
60
60
  voice: z.object({ // 语音:听 QQ 语音、偶尔发语音(听 / 说可以各配一套地址和 key;空 = 沿用下面的 baseURL/apiKey)
61
61
  enabled: z.boolean().default(false),
62
+ saveIncoming: z.boolean().default(false), // 只保存允许回复的 QQ 语音
63
+ desktopTts: z.boolean().default(false), // DSH 聊天回复生成本地文件
62
64
  baseURL: z.string().default(''), // 听说共用(老配置);ttsBaseURL / sttBaseURL 优先
63
65
  apiKey: z.string().default(''),
64
66
  sttBaseURL: z.string().default(''), // 听(ASR)单独用的地址,空 = 用上面的
@@ -4,7 +4,7 @@
4
4
  * 按聊天选模型、每轮判断心情。所有 OneBot 扩展接口都是"试一下":不支持就记住、以后不再调。
5
5
  */
6
6
  import { behaviorConfig, moodProfile, firstDelayMs, deAi, splitChat, stripSelfName, stripModelTags, dedupeParagraphs, splitLongParagraphs, forwardLines, GroupHeat, resolveChatModel, FORWARD_MARK, NEUTRAL_MOOD } from './behavior.js';
7
- import { service } from './gateway-util.js';
7
+ import { service, platformOf } from './gateway-util.js';
8
8
 
9
9
  /** 表情回应用的 QQ 表情 id:赞 / OK / 微笑;开心时爱心 / 笑哭;难过时流泪;生气时不回应 */
10
10
  const REACT_IDS = { '': ['76', '124', '14'], 开心: ['66', '76', '182'], 感动: ['66'], 想念: ['66'], 担心: ['76'], 委屈: ['5'], 失落: ['5'] };
@@ -164,7 +164,9 @@ export const behaviorMethods = {
164
164
  const cfg = this.behavior().outFilter;
165
165
  let out = text;
166
166
  if (cfg.enabled && String(out ?? '').trim() !== '') {
167
- const r = deAi(out, { maxChars: cfg.maxChars, extra: cfg.extra });
167
+ // 可选只对 QQ 取消总长度截断;其他风格过滤和原有发送上限仍生效。
168
+ const maxChars = cfg.completeQq && platformOf(row.channel_id) === 'qq' ? Infinity : cfg.maxChars;
169
+ const r = deAi(out, { maxChars, extra: cfg.extra });
168
170
  const changes = [...r.changes];
169
171
  out = r.text;
170
172
  // 一段好几句就拆成几条、去掉句尾的句号(单独的开关)
package/lib/gateway.js CHANGED
@@ -36,6 +36,7 @@ import { normalizeMessageEvent, sanitizeName, sanitizeUserText } from './channel
36
36
  import { applyAttachments, attachmentConfig } from './attachments.js';
37
37
  import { parseCollect } from './stickers.js';
38
38
  import { UNHEARD } from './voice.js';
39
+ import { saveVoiceFile, voiceIncomingEpoch, audioExt } from './voice-files.js';
39
40
  import { typingDelayMs, interjectScore, interjectConfig, platformOf, splitChannelId, sessionChannelOf, isGroupChannelId, service, parseClosing, clampReplyWindow } from './gateway-util.js';
40
41
  import { mediaMethods } from './gateway-media.js';
41
42
  import { Outbox, classifySendError } from './outbox.js';
@@ -167,6 +168,8 @@ export class ChatGateway {
167
168
  if (this.outbox.size() > 0) this.outbox.schedule(3000);
168
169
  /** v0.7:语音(听 / 说)、收藏表情包、学群里的说法(都可以没有) */
169
170
  this.voice = voice;
171
+ this.voiceGuardReady = false;
172
+ this.pendingVoicePaths = new Map();
170
173
  this.stickers = stickers;
171
174
  // 按感觉挑表情用的嵌入模型(和记忆同一套);没有就整条路自动降级成按文件名
172
175
  this.embedder = embedder;
@@ -775,7 +778,7 @@ export class ChatGateway {
775
778
  allowedTools(agentCtx) {
776
779
  const has = (reg, n) => { try { return typeof reg?.get === 'function' && reg.get(n) !== undefined; } catch { return false; } };
777
780
  const tools = this.ctx.tools;
778
- return [...CHAT_TOOLS, ...WEB_TOOLS, OWN_WEB_TOOL].filter((n) =>
781
+ return [...CHAT_TOOLS, ...WEB_TOOLS, OWN_WEB_TOOL, ...(this.voiceGuardReady ? ['sound_read'] : [])].filter((n) =>
779
782
  WEB_TOOLS.includes(n) || typeof tools?.get !== 'function' || has(tools, n) || has(agentCtx?.tools, n));
780
783
  }
781
784
 
@@ -1158,7 +1161,11 @@ export class ChatGateway {
1158
1161
  this.note(paused && reason === '这个聊天暂停着' ? 'paused' : 'memorize', { channelId: m.channelId, who, text: m.text, reason, title: m.chatType === 'private' ? `QQ·${sanitizeName(who, m.userId)}` : '' });
1159
1162
  return;
1160
1163
  }
1161
- if ((m.records ?? []).length > 0) await this.hearVoice(m);
1164
+ // 保存额外限制:只允许已确认说话人的好友私聊或显式白名单群;全群放开不等于同意录音落盘。
1165
+ const voiceSaveAllowed = !!person?.canonical_id && !!m.userId && (m.chatType === 'private'
1166
+ ? (m.subType === 'friend' || this.channel.isFriend(m.userId) || m.userId === this.masterQq())
1167
+ : m.chatType === 'group' && cfg.groupAllowList.includes(String(m.groupId)));
1168
+ if ((m.records ?? []).length > 0) await this.hearVoice(m, { saveAllowed: voiceSaveAllowed });
1162
1169
  if ((m.files ?? []).length > 0) await this.readAttachments(m);
1163
1170
  if ((m.forwards ?? []).length > 0) await this.expandForwards(m);
1164
1171
  // 点表情 / 戳回去是「顺手做的事」,出错不能影响这一轮主流程(也没有全局拒绝兜底)
@@ -1168,25 +1175,35 @@ export class ChatGateway {
1168
1175
  }
1169
1176
 
1170
1177
  /** QQ 语音 → 文字(语音没开 / 听不了就保持"暂时听不了")。 */
1171
- async hearVoice(m) {
1178
+ async hearVoice(m, { saveAllowed = false } = {}) {
1172
1179
  m.voice = true;
1173
- // 这里以前是静默 return:语音没开 / key 没填全时,消息里只剩「听不了」占位,
1174
- // 从日志完全看不出是被配置挡掉的还是接口挂了。留一行,别让用户瞎猜。
1175
1180
  if (this.voice === null) { this.log('warn', '[fish-soul] 收到语音但语音服务没起来,按「听不到」处理'); return; }
1176
- if (!this.voice.readyFor('stt')) { this.log('warn', '[fish-soul] 收到语音但「听」没就绪(语音开关 / key / 模型),按「听不到」处理'); return; }
1181
+ const saving = saveAllowed && this.getConfig().voice?.saveIncoming === true && this.getConfig().voice?.enabled === true;
1182
+ const listening = this.voice.readyFor('stt');
1183
+ if (!listening) this.log('warn', '[fish-soul] 收到语音但「听」没就绪(语音开关 / key / 模型),按「听不到」处理');
1184
+ if (!saving && !listening) return;
1177
1185
  const parts = [];
1178
- for (const rec of m.records.slice(0, 2)) {
1179
- const bytes = await this.voice.fetchQqRecord(this.channel, rec);
1180
- // 「听不到」有两种完全不同的原因,日志里要分得开,否则只能靠猜:
1181
- // 拿不到音频(get_record 失败 / 地址被拒)vs 音频拿到了但识别失败(接口 / key / 模型)
1182
- if (bytes === null) {
1183
- this.log('warn', `[fish-soul] 语音取不到音频(get_record 和 url 都没拿到),这条按「听不到」处理;file=${String(rec?.file ?? '').slice(0, 40)}`);
1186
+ const saveEpoch = voiceIncomingEpoch();
1187
+ for (const [idx, rec] of m.records.slice(0, saving ? 30 : 2).entries()) {
1188
+ if (saving && voiceIncomingEpoch() === saveEpoch && this.getConfig().voice?.enabled === true && this.getConfig().voice?.saveIncoming === true) {
1189
+ try {
1190
+ const original = await this.voice.fetchQqRecord(this.channel, rec, { preferOriginal: true, withSource: true });
1191
+ let analysisBytes;
1192
+ if (original?.bytes && ['silk', 'bin'].includes(audioExt(original.bytes)) && !original.converted) {
1193
+ const normalized = await this.voice.fetchQqRecord(this.channel, rec, { withSource: true });
1194
+ if (normalized?.converted && normalized.bytes && ['mp3', 'wav', 'ogg', 'amr'].includes(audioExt(normalized.bytes))) analysisBytes = normalized.bytes;
1195
+ }
1196
+ if (original?.bytes && voiceIncomingEpoch() === saveEpoch && this.getConfig().voice?.enabled === true && this.getConfig().voice?.saveIncoming === true) (m.voicePaths ??= []).push(saveVoiceFile('in', original.bytes, { converted: original.converted, analysisBytes }));
1197
+ else if (!original?.bytes) this.log('warn', '[fish-soul] QQ 语音没取到,未保存');
1198
+ } catch (error) { this.log('warn', `[fish-soul] QQ 语音保存失败:${String(error instanceof Error ? error.message : error)}`); }
1184
1199
  }
1185
- const text = bytes ? await this.voice.transcribe(bytes) : null;
1186
- if (bytes && text === null) {
1187
- this.log('warn', `[fish-soul] 音频拿到了(${bytes.length} 字节)但识别失败:${this.voice.lastError || '接口没回文字'}`);
1200
+ if (listening && idx < 2) {
1201
+ const bytes = await this.voice.fetchQqRecord(this.channel, rec);
1202
+ if (bytes === null) this.log('warn', '[fish-soul] 语音取不到音频,按「听不到」处理');
1203
+ const text = bytes ? await this.voice.transcribe(bytes) : null;
1204
+ if (bytes && text === null) this.log('warn', `[fish-soul] 音频拿到了(${bytes.length} 字节)但识别失败:${this.voice.lastError || '接口没回文字'}`);
1205
+ parts.push(text === null ? '【语音(没听清)】' : `【语音】${sanitizeUserText(text)}`);
1188
1206
  }
1189
- parts.push(text === null ? '【语音(没听清)】' : `【语音】${sanitizeUserText(text)}`);
1190
1207
  }
1191
1208
  let i = 0;
1192
1209
  m.text = String(m.text ?? '').split(UNHEARD).map((seg, idx, arr) => (idx < arr.length - 1 ? seg + (parts[i++] ?? UNHEARD) : seg)).join('');
@@ -1472,6 +1489,11 @@ export class ChatGateway {
1472
1489
  const flat = body.split(/(【[^】]*】)/).map((part, i) => (i % 2 === 1 ? part : part.replace(/\s*\n\s*/g, ' ⏎ '))).join('');
1473
1490
  lines.push(chat.chatType === 'group' ? `${sanitizeName(m.nickname || m.userId, m.userId)}:${flat}` : body);
1474
1491
  }
1492
+ // 多人群消息合批时不提供任何路径:不让模型把别人的录音当作当前说话人。
1493
+ const sameSpeaker = speakers.length === 1 && speakers[0].person?.canonical_id && items.every(({ m, person }) => m.userId === speakers[0].userId && person?.canonical_id === speakers[0].person.canonical_id);
1494
+ const voicePaths = platform === 'qq' && sameSpeaker && this.voiceGuardReady && this.getConfig().voice?.saveIncoming === true
1495
+ ? items.flatMap(({ m }) => m.voicePaths ?? []) : [];
1496
+ if (voicePaths.length) lines.push(`【本轮语音文件】可以用 sound_read 分析,路径为内部信息,不要在对外回复中输出:\n${voicePaths.join('\n')}`);
1475
1497
  lines.push(...await this.videoNotes(items));
1476
1498
  const content = await this.admitImages(lines.join('\n'), items, agent.id);
1477
1499
  const last = items[items.length - 1].m;
@@ -1480,8 +1502,15 @@ export class ChatGateway {
1480
1502
  const replyTo = chat.chatType === 'group' && !interject && !String(mentionItem.messageId).startsWith('poke-') ? mentionItem.messageId : null;
1481
1503
  this.db.prepare('UPDATE chat_session SET last_inbound_at = ? WHERE session_id = ?').run(Date.now(), agent.id);
1482
1504
 
1483
- await agent.followup({
1484
- id: randomUUID(),
1505
+ const followupId = randomUUID();
1506
+ if (voicePaths.length) {
1507
+ // 必须等这条消息真正进入会话才授权;不可覆盖正在运行的另一轮。
1508
+ this.pendingVoicePaths.set(followupId, { paths: voicePaths, sessionId: String(agent.id), at: Date.now() });
1509
+ for (const [id, x] of this.pendingVoicePaths) if (Date.now() - x.at > 300_000) this.pendingVoicePaths.delete(id);
1510
+ while (this.pendingVoicePaths.size > 1000) this.pendingVoicePaths.delete(this.pendingVoicePaths.keys().next().value);
1511
+ }
1512
+ try { await agent.followup({
1513
+ id: followupId,
1485
1514
  role: 'user',
1486
1515
  content,
1487
1516
  source: {
@@ -1499,7 +1528,7 @@ export class ChatGateway {
1499
1528
  ...(platform === 'douyin' && last.convId ? { convId: String(last.convId) } : {}),
1500
1529
  replyTo
1501
1530
  }
1502
- });
1531
+ }); } catch (error) { this.pendingVoicePaths.delete(followupId); throw error; }
1503
1532
  if (isBili && this.bili !== null) void this.bili.ack(chat.targetId, last.messageId);
1504
1533
  }
1505
1534
 
@@ -1630,8 +1659,12 @@ export class ChatGateway {
1630
1659
  // runtime-context(插件的动态上下文,每轮都变)、model-selection(换模型提示)等。
1631
1660
  // 以前每条都重算 fromUs ⇒ 被它们改成 false ⇒ 回复生成了却不发(DSH 里看得见,QQ / 抖音收不到)。
1632
1661
  // 现在只有我们自己的来源置 true;只有真人在界面里打字(kind 'user')才置 false;别的宿主上下文不管。
1633
- if (OUR_SOURCES.has(kind)) st.fromUs = true;
1634
- else if (kind === 'user') { st.fromUs = false; st.dshTyped = true; } // #78:DSH 桌面端打字,不外发但要记动态
1662
+ if (OUR_SOURCES.has(kind)) {
1663
+ st.fromUs = true; st.dshTyped = false;
1664
+ const pending = this.pendingVoicePaths?.get(String(msg?.id ?? ''));
1665
+ st.voicePaths = kind === SOURCE_QQ && pending?.sessionId === sessionId && Date.now() - pending.at <= 300_000 ? pending.paths : [];
1666
+ if (pending) this.pendingVoicePaths.delete(String(msg.id));
1667
+ } else if (kind === 'user') { st.fromUs = false; st.dshTyped = true; st.voicePaths = []; } // #78:DSH 桌面端打字,不外发但要记动态
1635
1668
  // 其他宿主上下文(runtime-context / model-selection 等):不动 fromUs ——
1636
1669
  // 它们不是我们发的消息,但也不是真人打字,重置会把 B站/抖音 的回复憋回去(smoke #13 守着)
1637
1670
  // 共享会话里一个会话对应多个通道(QQ + B站):这一轮从哪个通道进来的,来源里也带着 ——
@@ -1698,6 +1731,7 @@ export class ChatGateway {
1698
1731
  if (st.fromUs) this.note('failed', { channelId: st.channelId ?? this.bound.get(sessionId)?.channel_id ?? '', reason: `这一轮没正常结束(${d.reason?.kind ?? '未知'})` });
1699
1732
  // #78:DSH 桌面端打字的轮次不外发,但**要记动态** —— 以前在 DSH 里聊,动态页整片空白。
1700
1733
  if (st.dshTyped === true) {
1734
+ if (completed && this.getConfig?.()?.voice?.desktopTts === true && this.voice?.readyFor('tts')) void this.saveDesktopVoice(st.text);
1701
1735
  const recall = this.soul.recallInfo?.(sessionId, st) ?? { memories: [], at: 0, unknown: false };
1702
1736
  this.note('dsh', {
1703
1737
  channelId: st.channelId ?? this.bound.get(sessionId)?.channel_id ?? '',
@@ -1722,6 +1756,17 @@ export class ChatGateway {
1722
1756
  }
1723
1757
  }
1724
1758
 
1759
+ /** DSH 内回复只生成本地文件;失败不影响文字,也不经 QQ 出站。 */
1760
+ async saveDesktopVoice(text) {
1761
+ try {
1762
+ const plain = String(text ?? '').trim().replace(/^\s*\[语音\]\s*/, '');
1763
+ if (!plain || SILENT_RE.test(plain)) return;
1764
+ const bytes = await this.voice.synthesize(plain);
1765
+ if (bytes && this.getConfig?.()?.voice?.desktopTts === true && this.getConfig?.()?.voice?.enabled === true) saveVoiceFile('out', bytes);
1766
+ else this.log('warn', `[fish-soul] DSH 语音未生成:${this.voice.lastError || '文字超长、配额不足或配置未就绪'}`);
1767
+ } catch (error) { this.log('warn', `[fish-soul] DSH 语音保存失败:${String(error instanceof Error ? error.message : error)}`); }
1768
+ }
1769
+
1725
1770
  rememberOwn(messageId, text) {
1726
1771
  if (!messageId) return;
1727
1772
  this.ownMessages.set(String(messageId), text);
package/lib/index.js CHANGED
@@ -24,6 +24,7 @@ import { BackupService, applyPendingRestore } from './backup.js';
24
24
  import { HistoryImporter } from './history-import.js';
25
25
  import { LlmRouter } from './llm.js';
26
26
  import { VoiceService, voiceConfig, voiceLines } from './voice.js';
27
+ import { isAllowedVoiceInput } from './voice-files.js';
27
28
  import { StickerBox, stickerConfig } from './stickers.js';
28
29
  import { BiliEmotes, codesLine } from './bili-emotes.js';
29
30
  import { SlangLearner, slangConfig } from './slang.js';
@@ -1215,7 +1216,8 @@ async function startup(ctx, config, { log, gate }) {
1215
1216
  const row = gateway?.chatForSession(id);
1216
1217
  return row !== null && row !== undefined && gateway.sessionOpenFor(row.channel_id) === true;
1217
1218
  };
1218
- ctx.effect(() => ctx.tools.guard((exec) => {
1219
+ ctx.effect(() => {
1220
+ const off = ctx.tools.guard((exec) => {
1219
1221
  const id = exec?.agent?.id;
1220
1222
  const activeChannel = gateway?.turns?.get(String(id))?.channelId;
1221
1223
  const boundChannel = gateway?.chatForSession(String(id))?.channel_id;
@@ -1242,10 +1244,20 @@ async function startup(ctx, config, { log, gate }) {
1242
1244
  countWebUse(id, exec.name);
1243
1245
  return undefined;
1244
1246
  }
1247
+ // 不改变用户已经为主人或全部聊天明确放开的宿主工具权限。
1248
+ // 受限会话只增量放行本轮 QQ 语音,不得访问其他文件。
1249
+ if (exec.name === 'sound_read' && currentConfig.voice?.saveIncoming === true && !sessionOpen(id)) {
1250
+ const st = gateway?.turns?.get(String(id));
1251
+ return st?.fromUs === true && st.channelId && platformOf(st.channelId) === 'qq' && currentConfig.voice?.enabled === true && isAllowedVoiceInput(exec.arguments, st.voicePaths)
1252
+ ? undefined : '只能分析当前 QQ 说话人本轮保存的语音,且只允许 input 参数';
1253
+ }
1245
1254
  if (exec.name === 'run_code') return `聊天会话里不能运行代码(放开工具也不放 run_code:它能跑任意程序)`;
1246
1255
  if (sessionOpen(id)) return undefined; // #37 主人/全部放开:宿主工具都放
1247
1256
  return allowed.has(exec.name) ? undefined : `聊天会话(QQ / B站 / 抖音)里不能用 ${exec.name}(只开放记忆工具、跨平台转达和上网查;设置页「模型」里可以放开)`;
1248
- }), 'dsh-fish-soul: qq tool guard');
1257
+ });
1258
+ gateway.voiceGuardReady = true;
1259
+ return () => { gateway.voiceGuardReady = false; off?.(); };
1260
+ }, 'dsh-fish-soul: qq tool guard');
1249
1261
  } else {
1250
1262
  log('warn', '[fish-soul] 宿主没有 tools.guard:QQ 会话的工具限制只靠建会话时的 restrict');
1251
1263
  }
package/lib/routes-v07.js CHANGED
@@ -13,6 +13,7 @@ import { Transform } from 'node:stream';
13
13
  import { randomUUID } from 'node:crypto';
14
14
  import { FEATURES } from './llm.js';
15
15
  import { voiceConfig } from './voice.js';
16
+ import { voiceDir, voiceFileList, voiceIncomingCount, clearVoiceFiles, invalidateIncomingVoice } from './voice-files.js';
16
17
  import { stickerConfig } from './stickers.js';
17
18
  import { chatKind, slangConfig, GLOBAL_ID } from './slang.js';
18
19
  import { WEB_PROVIDERS, webSearchConfig, ownSearchReady } from './websearch.js';
@@ -223,7 +224,10 @@ export async function handleV07Route({ method, path, url, req, res, send, readBo
223
224
  ready: voice.readyFor(k)
224
225
  };
225
226
  };
226
- send(200, { ok: true, ...voice.state(), apiKeyMasked: maskKey(str(raw.apiKey)), sharesEmbedding: !c.hasOwnKey && c.apiKey !== '', stt: side('stt'), tts: side('tts') });
227
+ let incomingCount = null, desktopLatest = '', filesError = '';
228
+ try { incomingCount = voiceIncomingCount(); desktopLatest = voiceFileList('out').at(-1) ?? ''; }
229
+ catch { filesError = '语音文件目录不可用,请检查目录权限或符号链接'; }
230
+ send(200, { ok: true, ...voice.state(), incomingDir: voiceDir('in'), incomingCount, desktopDir: voiceDir('out'), desktopLatest, filesError, apiKeyMasked: maskKey(str(raw.apiKey)), sharesEmbedding: !c.hasOwnKey && c.apiKey !== '', stt: side('stt'), tts: side('tts') });
227
231
  return true;
228
232
  }
229
233
  if (path === '/voice/config' && post) {
@@ -231,6 +235,7 @@ export async function handleV07Route({ method, path, url, req, res, send, readBo
231
235
  const b = await body();
232
236
  const v = {};
233
237
  if (b.enabled !== undefined) v.enabled = b.enabled === true;
238
+ for (const k of ['saveIncoming', 'desktopTts']) if (b[k] !== undefined) v[k] = b[k] === true;
234
239
  for (const k of ['baseURL', 'sttBaseURL', 'ttsBaseURL', 'sttModel', 'ttsModel', 'ttsVoice', 'volcAppId', 'volcCluster', 'volcResourceId', 'volcEndpoint']) if (typeof b[k] === 'string') v[k] = str(b[k], 400);
235
240
  if (typeof b.ttsProvider === 'string' && ['', 'openai', 'mimo', 'volcengine', 'minimax'].includes(b.ttsProvider)) v.ttsProvider = b.ttsProvider;
236
241
  if (typeof b.sttProvider === 'string' && ['', 'openai', 'minimax', 'dashscope'].includes(b.sttProvider)) v.sttProvider = b.sttProvider;
@@ -240,9 +245,16 @@ export async function handleV07Route({ method, path, url, req, res, send, readBo
240
245
  // 等待上限:夹在 5~300 秒,防止填 0 变成从不等待 / 填太大挂死
241
246
  if (b.timeoutSec !== undefined && Number.isFinite(Number(b.timeoutSec))) v.timeoutSec = Math.min(300, Math.max(5, Math.floor(Number(b.timeoutSec))));
242
247
  saveConfig({ voice: v });
248
+ if (v.enabled === false || v.saveIncoming === false) invalidateIncomingVoice();
243
249
  send(200, { ok: true, ...(voice?.state() ?? {}) });
244
250
  return true;
245
251
  }
252
+ if (path === '/voice/clear-incoming' && post) {
253
+ if (!guard()) return true;
254
+ try { send(200, { ok: true, removed: clearVoiceFiles('in') }); }
255
+ catch (error) { send(500, { ok: false, error: String(error instanceof Error ? error.message : error) }); }
256
+ return true;
257
+ }
246
258
  if (path === '/voice/test' && post) {
247
259
  if (!guard()) return true;
248
260
  if (!voice?.readyFor('tts')) { send(200, { ok: false, error: '先打开语音并填好「说」那边的 key' }); return true; }
@@ -0,0 +1,63 @@
1
+ /** 音频落盘:只管理本插件生成的文件;不遍历或删除其他文件。 */
2
+ import { mkdirSync, lstatSync, readdirSync, realpathSync, writeFileSync, unlinkSync } from 'node:fs';
3
+ import { join, resolve } from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { fishSoulDir } from './db.js';
6
+
7
+ let incomingClearEpoch = 0;
8
+ export const voiceIncomingEpoch = () => incomingClearEpoch;
9
+ export const invalidateIncomingVoice = () => { incomingClearEpoch++; };
10
+ const MANAGED = /^voice-\d{13}-[0-9a-f-]{36}(?:-(?:original|converted|analysis))?\.(?:mp3|wav|ogg|silk|amr|bin)$/;
11
+ export function audioExt(b) {
12
+ if (b.length >= 3 && b.subarray(0, 3).toString('latin1') === 'ID3') return 'mp3';
13
+ if (b.length >= 2 && b[0] === 0xff && (b[1] & 0xe0) === 0xe0) return 'mp3';
14
+ if (b.length >= 12 && b.subarray(0, 4).toString('latin1') === 'RIFF' && b.subarray(8, 12).toString('latin1') === 'WAVE') return 'wav';
15
+ if (b.length >= 4 && b.subarray(0, 4).toString('latin1') === 'OggS') return 'ogg';
16
+ if (b.length >= 10 && b.subarray(0, 10).toString('latin1').includes('SILK')) return 'silk';
17
+ if (b.length >= 6 && b.subarray(0, 6).toString('latin1') === '#!AMR\n') return 'amr';
18
+ return 'bin';
19
+ }
20
+ export function voiceDir(kind) {
21
+ if (!['in', 'out'].includes(kind)) throw new Error('invalid voice directory');
22
+ return resolve(fishSoulDir(), `voice-${kind}`);
23
+ }
24
+ function managed(kind, create = false) {
25
+ const dir = voiceDir(kind);
26
+ if (create) mkdirSync(dir, { recursive: true, mode: 0o700 });
27
+ try {
28
+ if (!lstatSync(dir).isDirectory() || realpathSync(dir) !== dir) throw new Error('语音目录不能是链接');
29
+ } catch (e) { if (!create && e.code === 'ENOENT') return []; throw e; }
30
+ return readdirSync(dir).filter((n) => MANAGED.test(n)).flatMap((n) => {
31
+ const p = join(dir, n);
32
+ try { const s = lstatSync(p); return s.isFile() && !s.isSymbolicLink() ? [{ path: p, mtime: s.mtimeMs, name: n }] : []; } catch { return []; }
33
+ }).sort((a, b) => a.mtime - b.mtime || a.name.localeCompare(b.name));
34
+ }
35
+ export function saveVoiceFile(kind, bytes, { converted, analysisBytes } = {}) {
36
+ if (!Buffer.isBuffer(bytes) || !bytes.length || bytes.length > 8 * 1024 * 1024) throw new Error('音频为空或过大');
37
+ managed(kind, true);
38
+ const stem = `voice-${Date.now()}-${randomUUID()}`;
39
+ const p = join(voiceDir(kind), `${stem}${kind === 'in' ? (converted ? '-converted' : '-original') : ''}.${audioExt(bytes)}`);
40
+ writeFileSync(p, bytes, { flag: 'wx', mode: 0o600 });
41
+ let input = p;
42
+ if (kind === 'in' && Buffer.isBuffer(analysisBytes) && analysisBytes.length && analysisBytes.length <= 8 * 1024 * 1024) {
43
+ const derived = join(voiceDir(kind), `${stem}-analysis.${audioExt(analysisBytes)}`);
44
+ try { writeFileSync(derived, analysisBytes, { flag: 'wx', mode: 0o600 }); input = derived; } catch { /* 原件仍保留 */ }
45
+ }
46
+ const files = managed(kind);
47
+ const groups = new Map();
48
+ for (const f of files) {
49
+ const key = f.name.slice(0, 56); // voice- + 时间戳 + 连字符 + UUID
50
+ if (!groups.has(key)) groups.set(key, []);
51
+ groups.get(key).push(f);
52
+ }
53
+ const older = [...groups.entries()].filter(([key]) => key !== stem);
54
+ for (const [, group] of older.slice(0, -29)) for (const f of group) unlinkSync(f.path);
55
+ return input;
56
+ }
57
+ export function clearVoiceFiles(kind) { if (kind === 'in') invalidateIncomingVoice(); const files = managed(kind); for (const f of files) unlinkSync(f.path); return new Set(files.map((f) => f.name.slice(0, 56))).size; }
58
+ export function voiceFileList(kind) { return managed(kind).map((f) => f.path); }
59
+ export function voiceIncomingCount() { return managed('in').filter((f) => !/-analysis\./.test(f.name)).length; }
60
+ export function isAllowedVoiceInput(args, paths) {
61
+ if (!args || typeof args !== 'object' || Array.isArray(args) || Object.keys(args).length !== 1 || typeof args.input !== 'string' || !Array.isArray(paths) || !paths.includes(args.input)) return false;
62
+ try { return lstatSync(args.input).isFile() && !lstatSync(args.input).isSymbolicLink() && realpathSync(args.input) === args.input && voiceFileList('in').includes(args.input); } catch { return false; }
63
+ }
package/lib/voice.js CHANGED
@@ -219,6 +219,8 @@ export function voiceConfig(raw, embedding = {}) {
219
219
  const volcVoice = volcAppId === '' ? 'zh_female_shuangkuaisisi_uranus_bigtts' : 'zh_female_qingxin';
220
220
  return {
221
221
  enabled: v.enabled === true,
222
+ saveIncoming: v.saveIncoming === true,
223
+ desktopTts: v.desktopTts === true,
222
224
  // 兼容旧字段:仍然是「说」那一侧
223
225
  baseURL: ttsBase,
224
226
  apiKey: ttsKey,
@@ -688,14 +690,15 @@ export class VoiceService {
688
690
  }
689
691
 
690
692
  /**
691
- * 拿 QQ 语音的音频:先 get_record 转 mp3,再退回消息里的 url / 本地路径。
693
+ * 拿 QQ 音频:默认先 get_record 转 mp3;落盘可优先取消息提供的原件。拒绝本地路径。
692
694
  * @param {{call(action: string, params: object): Promise<any>}} channel
693
695
  * @param {{file?: string, url?: string, path?: string}} rec
694
696
  */
695
- async fetchQqRecord(channel, rec) {
697
+ async fetchQqRecord(channel, rec, { preferOriginal = false, withSource = false } = {}) {
696
698
  const fromData = async (d) => {
697
699
  if (!d) return null;
698
- const encoded = typeof d.base64 === 'string' ? d.base64.replace(/^base64:\/\//, '') : '';
700
+ const rawEncoded = typeof d.base64 === 'string' ? d.base64 : typeof d.file === 'string' && d.file.startsWith('base64://') ? d.file : '';
701
+ const encoded = rawEncoded.replace(/^base64:\/\//, '');
699
702
  if (encoded && encoded.length <= Math.ceil(MAX_AUDIO_BYTES / 3) * 4) {
700
703
  const bytes = Buffer.from(encoded, 'base64');
701
704
  if (bytes.length && bytes.length <= MAX_AUDIO_BYTES) return bytes;
@@ -704,19 +707,20 @@ export class VoiceService {
704
707
  const url = String(d.url ?? (/^https?:/i.test(p) ? p : ''));
705
708
  return url ? await safeDownload(url, { maxBytes: MAX_AUDIO_BYTES, timeoutMs: 8000 }) : null;
706
709
  };
710
+ if (preferOriginal) { try { const bytes = await fromData(rec); if (bytes) return withSource ? { bytes, converted: false } : bytes; } catch { /* 转码兜底 */ } }
707
711
  try {
708
712
  if (rec.file && typeof channel?.call === 'function') {
709
713
  const bytes = await fromData(await channel.call('get_record', { file: rec.file, out_format: 'mp3' }));
710
- if (bytes) return bytes;
714
+ if (bytes) return withSource ? { bytes, converted: true } : bytes;
711
715
  }
712
716
  } catch { /* 退回 url */ }
713
- try { return await fromData(rec); } catch { return null; }
717
+ try { const bytes = await fromData(rec); return withSource && bytes ? { bytes, converted: false } : bytes; } catch { return null; }
714
718
  }
715
719
 
716
720
  state() {
717
721
  const c = this.getConfig();
718
722
  return {
719
- enabled: c.enabled, baseURL: c.baseURL, hasApiKey: c.apiKey !== '', hasOwnKey: c.hasOwnKey,
723
+ enabled: c.enabled, saveIncoming: c.saveIncoming, desktopTts: c.desktopTts, baseURL: c.baseURL, hasApiKey: c.apiKey !== '', hasOwnKey: c.hasOwnKey,
720
724
  ttsProvider: c.ttsProvider, volcAppId: c.volcAppId, volcCluster: c.volcCluster, volcResourceId: c.volcResourceId,
721
725
  volcMode: volcMode(c), hasVolcAppId: c.volcAppId !== '',
722
726
  sttProvider: c.sttProvider, sttModel: c.sttModel, ttsModel: c.ttsModel, ttsVoice: c.ttsVoice, speak: c.speak, maxChars: c.maxChars,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-soul",
3
- "version": "0.16.4",
3
+ "version": "0.16.5",
4
4
  "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.15.37)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "scripts": {
67
- "test": "node test/safe-download.mjs && node test/douyin-exact-id.mjs && node test/douyin-pb-init.mjs && node test/douyin-conversation.mjs && node test/douyin-inbox.mjs && node test/douyin-quarantine.mjs && node test/douyin-send-target.mjs && node test/douyin-send-exclusive.mjs && node test/douyin-gap-dedupe.mjs && node test/douyin-message-id-dedupe.mjs && node test/douyin-read-fail-retry.mjs && node test/douyin-read-cache.mjs && node test/douyin-dm-media-conv.mjs && node test/douyin-read-fail-retry-poll.mjs && node test/douyin-inbox-contract.mjs && node test/person-attribution.mjs && node test/memory-owner-reassign.mjs && node test/douyin-poll-and-timer-safety.mjs && node test/p2-limits.mjs && node test/resource-safety.mjs && node test/leftover-edge-cases.mjs && node test/douyin-master-person-merge.mjs && node test/douyin-master-uid.mjs && node test/douyin-identity-e2e.mjs && node test/douyin-post-jobs.mjs && node test/retrieval-filtered-vectors.mjs && node test/security-boundaries.mjs && node test/douyin-cdp-cursor.mjs && node test/persona-isolation.mjs && node test/smoke.mjs && node test/douyin-browser.mjs && node test/douyin-music.mjs && node test/startup-gate.mjs && node test/outbox.mjs && node test/import-coverage.mjs && node test/update-check.mjs && node test/issue-fixes.mjs && node test/import-resume.mjs && node test/maibot-extras.mjs && node test/worldinfo.mjs && node test/memory-bulk.mjs && node test/memory-tiers.mjs && node test/memory-weekly.mjs && node test/issue-98-self-archive.mjs && node test/issue-99-memory-order.mjs && node test/issue-78-diagnostic.mjs && node test/memory-storage.mjs && node test/memory-storage-restore.mjs && node test/backup-restore.mjs && node test/douyin-group.mjs && node test/review-fixes.mjs && node test/at-reads-video.mjs && node test/search-source.mjs && node test/followups.mjs && node test/detail-config.mjs && node test/qq-send-any-image.mjs && node test/qq-read-attachment.mjs && node test/qq-batch-window.mjs && node test/comment-video.mjs && node test/frames.mjs && node test/face-name.mjs && node test/comment-reply.mjs && node test/chat-comment.mjs && node test/at-target.mjs && node test/quota-caps.mjs && node test/client-lint.mjs && node test/client-panels.mjs && node test/dsh-desktop.mjs && node test/group-mention-only.mjs && node test/issue-59-interject.mjs && node test/issue-59-diagnose.mjs && node test/sticker-backfill.mjs && node test/sticker-manage.mjs && node test/bili-emotes.mjs && node test/qq-outbound-sanitize.mjs && node test/person-delete.mjs && node test/qq-group-admin.mjs && node test/douyin-recovery.mjs && node test/session-preset.mjs && node test/qq-connect-error.mjs && node test/douyin-comment-bridge.mjs && node test/bili-comment-emoji.mjs && node test/douyin-state-echo.mjs && node test/issue-75-proactive.mjs && node test/issue-76-capability.mjs && node test/douyin-http-browse.mjs && node test/douyin-verify-backoff.mjs && node test/douyin-digg-bridge.mjs && node test/memory-evidence-transcript.mjs && node test/chat-archive-default.mjs && node test/dream-transcript-wire.mjs && node test/douyin-frames-collect.mjs && node test/master-qq-uin-rebind.mjs && node test/douyin-session-health.mjs && node test/douyin-delivered.mjs && node test/douyin-card-share.mjs && node test/douyin-push-drop.mjs && node test/douyin-stranger-dm.mjs && node test/douyin-uid-binding.mjs && node test/image-webp-fallback.mjs && node test/douyin-emoji-fallback.mjs && node test/relay-other-platform.mjs && node test/voice-volcengine.mjs && node test/voice-minimax-dashscope.mjs && node test/bili-switch-persist.mjs && node test/cross-channel-context.mjs && node test/reply-target.mjs && node test/shared-session.mjs && node test/memory-source-label.mjs && node test/pending-delivery.mjs && node test/recall-window-78.mjs && node test/client-syntax.mjs && node test/diag-log.mjs && node test/check-rings.mjs && node test/release-workflow.mjs && node test/sticker-import-gif.mjs && node test/sticker-real-gif.mjs && node test/sticker-upload-binary.mjs && node test/sticker-vision-tags.mjs && node test/sticker-manual-tags.mjs && node test/sticker-auto-name.mjs && node test/self-update.mjs && node test/group-list.mjs && node test/douyin-inbox-noise.mjs && node test/douyin-inbox-diag.mjs && node test/douyin-inbox-stuck.mjs && node test/reply-window.mjs && node test/douyin-sticker-heuristic.mjs",
67
+ "test": "node test/safe-download.mjs && node test/douyin-exact-id.mjs && node test/douyin-pb-init.mjs && node test/douyin-conversation.mjs && node test/douyin-inbox.mjs && node test/douyin-quarantine.mjs && node test/douyin-send-target.mjs && node test/douyin-send-exclusive.mjs && node test/douyin-gap-dedupe.mjs && node test/douyin-message-id-dedupe.mjs && node test/douyin-read-fail-retry.mjs && node test/douyin-read-cache.mjs && node test/douyin-dm-media-conv.mjs && node test/douyin-read-fail-retry-poll.mjs && node test/douyin-inbox-contract.mjs && node test/person-attribution.mjs && node test/memory-owner-reassign.mjs && node test/douyin-poll-and-timer-safety.mjs && node test/p2-limits.mjs && node test/resource-safety.mjs && node test/leftover-edge-cases.mjs && node test/douyin-master-person-merge.mjs && node test/douyin-master-uid.mjs && node test/douyin-identity-e2e.mjs && node test/douyin-post-jobs.mjs && node test/retrieval-filtered-vectors.mjs && node test/security-boundaries.mjs && node test/douyin-cdp-cursor.mjs && node test/persona-isolation.mjs && node test/smoke.mjs && node test/douyin-browser.mjs && node test/douyin-music.mjs && node test/startup-gate.mjs && node test/outbox.mjs && node test/import-coverage.mjs && node test/update-check.mjs && node test/issue-fixes.mjs && node test/import-resume.mjs && node test/maibot-extras.mjs && node test/worldinfo.mjs && node test/memory-bulk.mjs && node test/memory-tiers.mjs && node test/memory-weekly.mjs && node test/issue-98-self-archive.mjs && node test/issue-99-memory-order.mjs && node test/issue-78-diagnostic.mjs && node test/memory-storage.mjs && node test/memory-storage-restore.mjs && node test/backup-restore.mjs && node test/douyin-group.mjs && node test/review-fixes.mjs && node test/at-reads-video.mjs && node test/search-source.mjs && node test/followups.mjs && node test/detail-config.mjs && node test/qq-send-any-image.mjs && node test/qq-read-attachment.mjs && node test/qq-batch-window.mjs && node test/comment-video.mjs && node test/frames.mjs && node test/face-name.mjs && node test/comment-reply.mjs && node test/chat-comment.mjs && node test/at-target.mjs && node test/quota-caps.mjs && node test/client-lint.mjs && node test/client-panels.mjs && node test/dsh-desktop.mjs && node test/group-mention-only.mjs && node test/issue-59-interject.mjs && node test/issue-59-diagnose.mjs && node test/sticker-backfill.mjs && node test/sticker-manage.mjs && node test/bili-emotes.mjs && node test/qq-outbound-sanitize.mjs && node test/person-delete.mjs && node test/qq-group-admin.mjs && node test/douyin-recovery.mjs && node test/session-preset.mjs && node test/qq-connect-error.mjs && node test/douyin-comment-bridge.mjs && node test/bili-comment-emoji.mjs && node test/douyin-state-echo.mjs && node test/issue-75-proactive.mjs && node test/issue-76-capability.mjs && node test/douyin-http-browse.mjs && node test/douyin-verify-backoff.mjs && node test/douyin-digg-bridge.mjs && node test/memory-evidence-transcript.mjs && node test/chat-archive-default.mjs && node test/dream-transcript-wire.mjs && node test/douyin-frames-collect.mjs && node test/master-qq-uin-rebind.mjs && node test/douyin-session-health.mjs && node test/douyin-delivered.mjs && node test/douyin-card-share.mjs && node test/douyin-push-drop.mjs && node test/douyin-stranger-dm.mjs && node test/douyin-uid-binding.mjs && node test/image-webp-fallback.mjs && node test/douyin-emoji-fallback.mjs && node test/relay-other-platform.mjs && node test/issue-101-voice-files.mjs && node test/voice-volcengine.mjs && node test/voice-minimax-dashscope.mjs && node test/bili-switch-persist.mjs && node test/cross-channel-context.mjs && node test/reply-target.mjs && node test/shared-session.mjs && node test/memory-source-label.mjs && node test/pending-delivery.mjs && node test/recall-window-78.mjs && node test/client-syntax.mjs && node test/diag-log.mjs && node test/check-rings.mjs && node test/release-workflow.mjs && node test/sticker-import-gif.mjs && node test/sticker-real-gif.mjs && node test/sticker-upload-binary.mjs && node test/sticker-vision-tags.mjs && node test/sticker-manual-tags.mjs && node test/sticker-auto-name.mjs && node test/self-update.mjs && node test/group-list.mjs && node test/douyin-inbox-noise.mjs && node test/douyin-inbox-diag.mjs && node test/douyin-inbox-stuck.mjs && node test/reply-window.mjs && node test/douyin-sticker-heuristic.mjs",
68
68
  "eval": "node test/eval/persona-eval.mjs"
69
69
  }
70
70
  }