dsh-fish-soul 0.14.1 → 0.15.1
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 +4 -2
- package/lib/client.behavior.js +5 -5
- package/lib/client.js +76 -26
- package/lib/client.models.js +4 -4
- package/lib/client.persona.js +6 -9
- package/lib/client.soul.js +42 -27
- package/lib/config-schema.js +4 -1
- package/lib/gateway-util.js +17 -1
- package/lib/gateway.js +32 -3
- package/lib/index.js +4 -0
- package/lib/panel.css +218 -110
- package/lib/routes.js +52 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
|
|
4
4
|
|
|
5
|
-
DSH 插件(单角色 `feiyu`)。版本 **0.
|
|
5
|
+
DSH 插件(单角色 `feiyu`)。版本 **0.15.1**。
|
|
6
|
+
|
|
7
|
+
QQ 交流群:**1125962189**
|
|
6
8
|
|
|
7
9
|
## 能力
|
|
8
10
|
|
|
@@ -33,7 +35,7 @@ dsh plugin --profile desktop add dsh-fish-soul
|
|
|
33
35
|
|
|
34
36
|
手工等价:profile 的 `package.json` 把 `dsh-fish-soul` 加进 `dsh.profile.bundles`,并在 `dependencies` 里写 `dsh-fish-soul` 的版本(本地源码则用 `link:` 路径),然后 `pnpm install`。
|
|
35
37
|
|
|
36
|
-
插件注入 `webServer / tools / systemPrompt / llm / agents / workspaceRegistry
|
|
38
|
+
插件注入 `webServer / tools / systemPrompt / llm / agents / workspaceRegistry`。在支持主面板的 DSH 版本中,左侧栏「鱼」可打开独立工作台;设置页入口也保留。旧宿主若不提供侧栏面板插槽,仍可从设置页打开(「人格 / 记忆 / QQ / B站 / 抖音 / 自走 / 模型 / 习惯 / 动态」)。
|
|
37
39
|
|
|
38
40
|
已在 DSH **0.2.1-rc.5** 上验证;更早的 rc 版本未逐一验证,遇到问题请先升级复测。
|
|
39
41
|
|
package/lib/client.behavior.js
CHANGED
|
@@ -59,7 +59,7 @@ window.__ModuleLoader__.load({
|
|
|
59
59
|
Group({ title: "QQ 小习惯" },
|
|
60
60
|
Row({ title: "看合并转发", desc: "展开一层,最多看前几条" },
|
|
61
61
|
h(Switch, { label: "看合并转发", checked: cfg.forward.enabled, onChange: (v) => save({ forward: { enabled: v } }) })),
|
|
62
|
-
Row({ title: "被戳了戳回去", desc:
|
|
62
|
+
Row({ title: "被戳了戳回去", desc: "SnowLuma 不支持时不会戳回" },
|
|
63
63
|
ia.pokeBack ? h(NumField, { ui, value: pct(ia.pokeBackChance), min: 0, max: 100, step: 10, label: "戳回去的概率", onSave: (n) => save({ interactions: { pokeBackChance: n / 100 } }) }) : null,
|
|
64
64
|
ia.pokeBack ? Muted("%") : null,
|
|
65
65
|
h(Switch, { label: "被戳了戳回去", checked: ia.pokeBack, onChange: (v) => save({ interactions: { pokeBack: v } }) })),
|
|
@@ -87,8 +87,8 @@ window.__ModuleLoader__.load({
|
|
|
87
87
|
}
|
|
88
88
|
const [label, tone] = HEAT[g.heat?.state] ?? HEAT.off;
|
|
89
89
|
return h("div", { className: "fs-row stack", key: g.groupId },
|
|
90
|
-
h("div", { className: "fs-row-title" }, h("span", null, g.title),
|
|
91
|
-
h("span", { className: "fs-
|
|
90
|
+
h("div", { className: "fs-row-title" }, h("div", { className: "fs-group-note-title" }, h("span", null, g.title),
|
|
91
|
+
h("span", { className: "fs-unit" }, Tag(label, tone), g.heat && g.heat.count > 0 ? Muted(` 最近 ${g.heat.count} 条 · ${g.heat.speakers} 人`) : null))),
|
|
92
92
|
h("div", { className: "fs-ctl" }, Area({ value: text, rows: 2, maxLength: 500, "aria-label": `${g.title} 的群设定`,
|
|
93
93
|
placeholder: "你在这个群是什么身份、气氛和忌讳(只在这个群里给她看),比如:考研群,你是过来人学姐,大家叫你鱼老师;别聊游戏",
|
|
94
94
|
onChange: (e) => setText(e.target.value), onBlur: save })));
|
|
@@ -115,10 +115,10 @@ window.__ModuleLoader__.load({
|
|
|
115
115
|
const hostText = host ? `跟 DSH 默认(${host.model})` : "跟 DSH 默认";
|
|
116
116
|
const cfg = cm.config ?? {};
|
|
117
117
|
const chats = cm.chats ?? [];
|
|
118
|
-
return Group({ title: "聊天用哪个模型",
|
|
118
|
+
return Group({ title: "聊天用哪个模型", tip: "单个聊天 → 私聊 / 群聊默认 → DSH 默认" },
|
|
119
119
|
Row({ title: "私聊默认", desc: "QQ / B站 / 抖音私信" }, Select({ value: val(cfg.private), "aria-label": "私聊默认", onChange: (e) => post({ private: parse(e.target.value) }) }, ...options(cfg.private, hostText))),
|
|
120
120
|
Row({ title: "群聊默认" }, Select({ value: val(cfg.group), "aria-label": "群聊默认", onChange: (e) => post({ group: parse(e.target.value) }) }, ...options(cfg.group, hostText))),
|
|
121
|
-
...chats.map((c) => Row({ title: c.title, key: c.channelId,
|
|
121
|
+
...chats.map((c) => Row({ title: c.title, key: c.channelId, meta: c.override ? undefined : c.resolved ? `现在用 ${c.resolved.model}` : undefined },
|
|
122
122
|
Select({ value: val(c.override), "aria-label": `${c.title} 用的模型`, onChange: (e) => post({ channelId: c.channelId, selection: parse(e.target.value) }) },
|
|
123
123
|
...options(c.override, c.channelId.startsWith("group:") ? "跟群聊默认" : "跟私聊默认")))));
|
|
124
124
|
}
|
package/lib/client.js
CHANGED
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 宿主契约:
|
|
7
7
|
* - window.__ModuleLoader__.load({ id, factory }),exports.apply / inject;inject: ["slots"]
|
|
8
|
-
* -
|
|
8
|
+
* - 通过 settings.section 保留设置入口;在宿主支持时通过 main + sidebar.panellist 注册独立页;样式随组件挂载 / 卸载
|
|
9
9
|
* - 不 require 任何 Harness Client 包:下面的 Switch / Button / Input / Seg / Tabs / Dot / Tag 照抄
|
|
10
10
|
* @deepseek-ai/dsh-client-ui-primitives 的结构、无障碍语义与样式(lib/panel.css,fs- 前缀,只用 --dsw-alias-* 令牌)
|
|
11
11
|
*
|
|
12
12
|
* 设计信条:Avoid unnecessary secondary labels and descriptions. Let the layout do the explaining.
|
|
13
|
-
* -
|
|
13
|
+
* - DeepSeek Harness 工作台骨架:可折叠侧栏(导航 + 版本)| 居中主任务流 | 按需展开的详情面板;记忆调试是一体化底部输入舱
|
|
14
|
+
* - 动态 / 整理记录渲染成单行步骤胶囊(<details>),默认收起,点开看原因与想起的记忆
|
|
15
|
+
* - 平铺紧凑行(标题左 / 控件右),1px 低对比分隔;Row 的 desc 只作悬停提示,meta(实时状态)用等宽小字
|
|
14
16
|
* - 状态 = 一颗 StateDot + 一个短句;只在出问题时多说一句
|
|
15
17
|
* - 依赖总开关的设置,总开关关着就不显示
|
|
18
|
+
* - 只改视图层:状态、事件、接口调用保持原样
|
|
16
19
|
*/
|
|
17
20
|
window.__ModuleLoader__.load({
|
|
18
21
|
id: "dsh-fish-soul",
|
|
@@ -88,7 +91,9 @@ window.__ModuleLoader__.load({
|
|
|
88
91
|
close: "M7 7l10 10M17 7 7 17",
|
|
89
92
|
refresh: "M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6",
|
|
90
93
|
chevron: "m7 10 5 5 5-5",
|
|
91
|
-
edit: "M4 20h4L18.5 9.5a2.1 2.1 0 0 0-4-4L4 16v4Z M13.5 6.5l4 4"
|
|
94
|
+
edit: "M4 20h4L18.5 9.5a2.1 2.1 0 0 0-4-4L4 16v4Z M13.5 6.5l4 4",
|
|
95
|
+
sidebar: "M4 5h16v14H4Z M9 5v14",
|
|
96
|
+
info: "M12 8h.01 M11 12h1v5h1 M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z"
|
|
92
97
|
};
|
|
93
98
|
const Icon = (name, size = 16) => h("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
|
|
94
99
|
h("path", { d: ICONS[name] }));
|
|
@@ -114,19 +119,18 @@ window.__ModuleLoader__.load({
|
|
|
114
119
|
const index = Math.max(0, items.findIndex(([v]) => v === value));
|
|
115
120
|
const onKeyDown = (event, i) => {
|
|
116
121
|
const n = items.length;
|
|
117
|
-
const next = event.key === "ArrowLeft" ? (i + n - 1) % n : event.key === "ArrowRight" ? (i + 1) % n
|
|
122
|
+
const next = event.key === "ArrowLeft" || event.key === "ArrowUp" ? (i + n - 1) % n : event.key === "ArrowRight" || event.key === "ArrowDown" ? (i + 1) % n
|
|
118
123
|
: event.key === "Home" ? 0 : event.key === "End" ? n - 1 : -1;
|
|
119
124
|
if (next < 0) return;
|
|
120
125
|
event.preventDefault();
|
|
121
126
|
event.currentTarget.parentElement?.querySelectorAll('[role="tab"]').item(next)?.focus();
|
|
122
127
|
onChange(items[next][0]);
|
|
123
128
|
};
|
|
124
|
-
return h("
|
|
125
|
-
h("span", { className: "fs-tabs-ind", "aria-hidden": true }),
|
|
129
|
+
return h("nav", { className: "fs-nav", role: "tablist", "aria-label": "鱼", "aria-orientation": "vertical", style: { "--n": items.length, "--i": index } },
|
|
126
130
|
items.map(([v, label], i) => h("button", {
|
|
127
131
|
type: "button", key: v, role: "tab", id: `fs-tab-${v}`, "aria-selected": v === value, "aria-controls": "fs-tabpanel",
|
|
128
132
|
tabIndex: v === value ? 0 : -1, className: "fs-tab", title: label, onClick: () => onChange(v), onKeyDown: (e) => onKeyDown(e, i)
|
|
129
|
-
}, label)));
|
|
133
|
+
}, h("span", { className: "fs-tab-key", "aria-hidden": true }, TAB_KEYS[v] ?? label.slice(0, 1)), h("span", { className: "fs-tab-label" }, label))));
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
/** StateDot:done / warning / error / idle 是圆点,ongoing 是转圈。 */
|
|
@@ -138,14 +142,20 @@ window.__ModuleLoader__.load({
|
|
|
138
142
|
const Tag = (text, tone, extra, ...kids) => h("span", { className: "fs-tag", "data-tone": tone, ...extra }, text, ...kids);
|
|
139
143
|
const Muted = (text, extra) => h("span", { className: "fs-unit", ...extra }, text);
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
// 行:标题左 / 控件右。desc(解释性文字)不占版面,只作悬停提示;meta(实时状态)以等宽小字跟在标题下
|
|
146
|
+
/** @param {{ title: any, desc?: any, meta?: any, stack?: boolean }} props @param {...any} kids */
|
|
147
|
+
function Row({ title, desc, meta, stack }, ...kids) {
|
|
148
|
+
const tip = typeof desc === "string" ? desc : undefined;
|
|
142
149
|
return h("div", { className: cx("fs-row", stack && "stack") },
|
|
143
|
-
h("div", { className: "fs-row-title" },
|
|
150
|
+
h("div", { className: "fs-row-title" },
|
|
151
|
+
h("span", { className: cx("fs-row-label", tip && "has-tip"), title: tip }, title),
|
|
152
|
+
meta ? h("span", { className: "fs-row-meta" }, meta) : null),
|
|
144
153
|
h("div", { className: "fs-ctl" }, ...kids));
|
|
145
154
|
}
|
|
146
|
-
|
|
155
|
+
/** @param {{ title?: any, aside?: any, tip?: string }} props @param {...any} kids */
|
|
156
|
+
function Group({ title, aside, tip }, ...kids) {
|
|
147
157
|
return h("section", { className: "fs-group" },
|
|
148
|
-
title ? h("h3", { className: "fs-group-head" }, h("span", null, title), aside ?? null) : null, ...kids);
|
|
158
|
+
title ? h("h3", { className: "fs-group-head", title: tip }, h("span", null, title), aside ?? null) : null, ...kids);
|
|
149
159
|
}
|
|
150
160
|
const Input = (props) => h("input", { className: "fs-input", spellCheck: false, autoComplete: "off", ...props, className: cx("fs-input", props.className) });
|
|
151
161
|
const Num = (props) => h("input", { type: "number", inputMode: "numeric", ...props, className: "fs-input num" });
|
|
@@ -272,7 +282,7 @@ window.__ModuleLoader__.load({
|
|
|
272
282
|
h(Switch, { label: "自动整理", checked: d.autoExtract, onChange: (v) => save({ autoExtract: v }) })),
|
|
273
283
|
d.autoExtract ? Row({ title: "空多久整理" },
|
|
274
284
|
Num({ min: 1, max: 240, value: idle, onChange: (e) => setIdle(e.target.value), onBlur: () => { const n = Number(idle); if (n >= 1 && n !== d.idleMinutes) save({ idleMinutes: n }); } }), Muted("分钟")) : null,
|
|
275
|
-
Row({ title: "上次",
|
|
285
|
+
Row({ title: "上次", meta: lastText },
|
|
276
286
|
Button({ disabled: busy || d.running || d.pending === 0, onClick: now }, busy ? "整理中…" : "现在整理")));
|
|
277
287
|
}
|
|
278
288
|
|
|
@@ -608,6 +618,7 @@ window.__ModuleLoader__.load({
|
|
|
608
618
|
}
|
|
609
619
|
|
|
610
620
|
// ── 面板根组件:页签 + 数据装载 + 轮询 ──
|
|
621
|
+
const TAB_KEYS = { retrieval: "索", persona: "人", life: "自", inspector: "忆", activity: "动", behavior: "习", models: "模", qq: "Q", bili: "B", douyin: "抖" };
|
|
611
622
|
const TABS = [["retrieval", "记忆检索"], ["persona", "人格"], ["life", "自走"], ["inspector", "记忆检视"], ["activity", "动态"], ["behavior", "习惯"], ["models", "模型"], ["qq", "QQ"], ["bili", "B站"], ["douyin", "抖音"]];
|
|
612
623
|
|
|
613
624
|
// ── 首次引导:没点「不再显示」就在页签上面列一张清单 ──
|
|
@@ -621,16 +632,16 @@ window.__ModuleLoader__.load({
|
|
|
621
632
|
if (r?.ok) setData({ ...data, dismissed: true }); else notify(r?.error ?? "操作失败");
|
|
622
633
|
}
|
|
623
634
|
const left = data.steps.filter((x) => !x.done && !x.optional).length;
|
|
624
|
-
return Group({ title: left === 0 ? "
|
|
635
|
+
return Group({ title: left === 0 ? "就绪" : `开始 · ${data.steps.length - left}/${data.steps.length}`, aside: IconButton("close", "不再显示", dismiss) },
|
|
625
636
|
h("div", { className: "fs-list" }, data.steps.map((x) => h("div", { className: "fs-item", key: x.id },
|
|
626
637
|
h("span", { className: "fs-dot", "data-state": x.done ? "done" : x.optional ? "idle" : "warning", "aria-hidden": true }),
|
|
627
638
|
h("span", { className: cx("fs-item-main", x.done && "fs-muted") }, x.title),
|
|
628
639
|
h("span", { className: "fs-item-meta" },
|
|
629
640
|
x.optional && !x.done ? Tag("可选", "outline") : null,
|
|
630
|
-
x.done ?
|
|
641
|
+
x.done ? null : x.tab ? Button({ variant: "ghost", onClick: () => onGo(x.tab) }, "去设置") : null)))));
|
|
631
642
|
}
|
|
632
643
|
// 版本与更新:显示当前版本,自动 / 手动去 npm(不通再 GitHub)看有没有新版;只提示,不替你装
|
|
633
|
-
function UpdateBar({ notify }) {
|
|
644
|
+
function UpdateBar({ notify, compact, onOpen }) {
|
|
634
645
|
const [data, setData] = react.useState(null);
|
|
635
646
|
const [busy, setBusy] = react.useState(false);
|
|
636
647
|
const load = react.useCallback(async () => { const r = await api("GET", "/update/state"); if (r?.ok) setData(r); }, []);
|
|
@@ -650,20 +661,23 @@ window.__ModuleLoader__.load({
|
|
|
650
661
|
async function copy() {
|
|
651
662
|
try { await navigator.clipboard.writeText(data.command); notify("已复制更新命令"); } catch { notify("复制失败,手动选中复制"); }
|
|
652
663
|
}
|
|
664
|
+
if (compact) return h("button", { type: "button", className: "fs-ver", onClick: onOpen, title: data.hasUpdate ? `v${data.latest}` : undefined, "aria-label": "版本" },
|
|
665
|
+
h("span", { className: "fs-dot", "data-state": data.hasUpdate ? "warning" : data.latest ? "done" : "idle", "aria-hidden": true }),
|
|
666
|
+
h("span", { className: "fs-tab-label num" }, `v${data.current}`));
|
|
653
667
|
const when = data.checkedAt ? new Date(data.checkedAt).toLocaleString("zh-CN", { hour12: false }) : "";
|
|
654
668
|
const status = data.hasUpdate ? Tag(`有新版本 v${data.latest}`, "warning")
|
|
655
669
|
: data.latest ? Tag("已是最新", "success")
|
|
656
670
|
: data.error ? Tag("没查成", "outline", { title: data.error }) : Tag("还没检查", "outline");
|
|
657
671
|
// Group / Row 是普通函数(第二个参数起是子元素),不能当组件(createElement)用:
|
|
658
672
|
// 宿主的 React 会把 legacy context({})当第二个参数传进来,变成一个对象子元素,整个面板崩成空白
|
|
659
|
-
return Group({ title: "版本", aside: h("span", { className: "fs-unit" }, `v${data.current}`) },
|
|
660
|
-
Row({ title:
|
|
673
|
+
return Group({ title: "版本", aside: h("span", { className: "fs-unit num" }, `v${data.current}`) },
|
|
674
|
+
Row({ title: status, meta: when ? `${when}${data.source ? ` · ${data.source}` : ""}` : undefined, desc: "每 12 小时自动看一次 npm / GitHub" },
|
|
661
675
|
Button({ onClick: check, disabled: busy || data.checking }, busy || data.checking ? "检查中…" : "检查更新"),
|
|
662
676
|
data.hasUpdate ? Button({ onClick: () => window.open(data.notesUrl, "_blank", "noopener") }, "更新说明") : null,
|
|
663
677
|
data.hasUpdate && data.command ? Button({ variant: "primary", onClick: copy, title: data.command }, "复制更新命令") : null),
|
|
664
|
-
data.hasUpdate ? (data.notes ? h("pre", { className: "fs-
|
|
665
|
-
: h("p", { className: "fs-row-
|
|
666
|
-
h("a", { href: data.notesUrl, target: "_blank", rel: "noopener noreferrer" }, "
|
|
678
|
+
data.hasUpdate ? (data.notes ? h("pre", { className: "fs-report" }, data.notes)
|
|
679
|
+
: h("p", { className: "fs-row-meta" },
|
|
680
|
+
h("a", { href: data.notesUrl, target: "_blank", rel: "noopener noreferrer" }, "GitHub Releases"))) : null,
|
|
667
681
|
Row({ title: "自动检查更新", desc: "只提示,不会自动安装;更新后重启 DSH 生效" },
|
|
668
682
|
h(Switch, { checked: data.autoCheck !== false, onChange: toggle, label: "自动检查更新" })));
|
|
669
683
|
}
|
|
@@ -687,6 +701,8 @@ window.__ModuleLoader__.load({
|
|
|
687
701
|
const [life, setLife] = react.useState(null);
|
|
688
702
|
const [channels, setChannels] = react.useState(null);
|
|
689
703
|
const [toast, setToast] = react.useState(null);
|
|
704
|
+
const [navOpen, setNavOpen] = react.useState(true);
|
|
705
|
+
const [detail, setDetail] = react.useState(null);
|
|
690
706
|
const notify = react.useCallback((text) => setToast({ key: Date.now(), text }), []);
|
|
691
707
|
|
|
692
708
|
react.useEffect(() => {
|
|
@@ -728,13 +744,35 @@ window.__ModuleLoader__.load({
|
|
|
728
744
|
: tab === "bili" ? h(BiliPane, { data: channels, refresh: loadChannels, notify })
|
|
729
745
|
: h(ChunkTab, { file: "client.douyin.js", pick: (m) => m.DouyinPane, failText: "抖音页加载失败", data: channels, refresh: loadChannels, notify });
|
|
730
746
|
|
|
731
|
-
|
|
747
|
+
// 工作台骨架:可折叠侧栏(导航 + 版本)| 主任务流(引导 + 当前页)| 按需展开的详情面板(版本与更新)
|
|
748
|
+
const label = TABS.find(([v]) => v === tab)?.[1] ?? "";
|
|
749
|
+
return h("div", { className: "fs-host" }, h("div", { className: cx("fs", navOpen ? null : "nav-collapsed", detail ? "has-detail" : null) },
|
|
732
750
|
css === "" ? null : h("style", { "data-plugin-css": `${PLUGIN_ID}/panel.css` }, css),
|
|
733
|
-
h(
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
751
|
+
h("aside", { className: "fs-side" }, h("div", { className: "fs-side-inner" },
|
|
752
|
+
h("div", { className: "fs-side-head" },
|
|
753
|
+
h("span", { className: "fs-tab-label fs-brand" }, "鱼"),
|
|
754
|
+
IconButton("sidebar", navOpen ? "收起侧栏" : "展开侧栏", () => setNavOpen(!navOpen), { "aria-expanded": navOpen })),
|
|
755
|
+
h(Tabs, { items: TABS, value: tab, onChange: setTab }),
|
|
756
|
+
h("div", { className: "fs-side-foot" }, h(Boundary, { name: "版本" }, h(UpdateBar, { notify, compact: true, onOpen: () => setDetail(detail === "version" ? null : "version") }))))),
|
|
757
|
+
h("main", { className: "fs-main" },
|
|
758
|
+
h("header", { className: "fs-main-head" }, h("h2", { className: "fs-main-title" }, label)),
|
|
759
|
+
h(Boundary, { name: "引导" }, h(Onboarding, { onGo: setTab, notify })),
|
|
760
|
+
h("div", { className: "fs-pane", role: "tabpanel", id: "fs-tabpanel", "aria-labelledby": `fs-tab-${tab}`, key: tab }, h(Boundary, { name: "这一页" }, pane))),
|
|
761
|
+
detail === "version" ? h("aside", { className: "fs-detail", "aria-label": "版本" }, h("div", { className: "fs-detail-inner" },
|
|
762
|
+
h("div", { className: "fs-detail-head" }, h("span", null, "版本"), IconButton("close", "关闭", () => setDetail(null))),
|
|
763
|
+
h(Boundary, { name: "版本" }, h(UpdateBar, { notify })))) : null,
|
|
764
|
+
toast === null ? null : h("div", { className: "fs-toast", role: "status", key: toast.key }, toast.text)));
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// 同一组件可在设置弹窗或宿主主面板内渲染;只改变承载容器。
|
|
768
|
+
function FishSoulPage() {
|
|
769
|
+
return h("div", { className: "fs-page-shell" },
|
|
770
|
+
h("div", { className: "fs-page-scroll" }, h(FishSoulSection)));
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function FishSoulPanelIcon({ size = 16 } = {}) {
|
|
774
|
+
return h("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
|
|
775
|
+
h("path", { d: "M3 12c3-5 9-7 14-3l4-3v12l-4-3c-5 4-11 2-14-3Z M14 11h.01 M7 12h.01" }));
|
|
738
776
|
}
|
|
739
777
|
|
|
740
778
|
function apply(ctx) {
|
|
@@ -744,6 +782,18 @@ window.__ModuleLoader__.load({
|
|
|
744
782
|
order: 60,
|
|
745
783
|
label: () => "鱼 · 记忆与自走"
|
|
746
784
|
}, FishSoulSection)), `${PLUGIN_ID}: panel`);
|
|
785
|
+
// main 先于入口注册;主面板不存在的旧宿主只保留设置页。
|
|
786
|
+
ctx.effect(() => ctx.slots.inject("main", function* () {
|
|
787
|
+
yield ctx.slots.register({ name: "main", key: PLUGIN_ID }, FishSoulPage);
|
|
788
|
+
yield ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
789
|
+
name: "sidebar.panellist", id: PLUGIN_ID, order: 2, label: () => "鱼"
|
|
790
|
+
}, FishSoulPanelIcon));
|
|
791
|
+
// 卸载当前页前回到会话;layout 为可选服务,不阻塞旧宿主。
|
|
792
|
+
yield () => {
|
|
793
|
+
const layout = typeof ctx.get === "function" ? ctx.get("layout") : null;
|
|
794
|
+
if (layout?.panelInfo?.getSnapshot()?.activePanelId === PLUGIN_ID) layout.selectPanel(null);
|
|
795
|
+
};
|
|
796
|
+
}), `${PLUGIN_ID}: main panel`);
|
|
747
797
|
}
|
|
748
798
|
|
|
749
799
|
exports.apply = apply;
|
package/lib/client.models.js
CHANGED
|
@@ -47,7 +47,7 @@ window.__ModuleLoader__.load({
|
|
|
47
47
|
return Group({ title: "按功能选模型", aside: host ? Muted(`DSH 默认:${providerName(host.provider)} · ${host.model}`) : null },
|
|
48
48
|
providers.length === 0 && !host ? Row({ title: "可用模型" }, State("warning", "DSH 里还没配模型")) : null,
|
|
49
49
|
data.lastError ? Row({ title: "上次调用" }, State("error", data.lastError)) : null,
|
|
50
|
-
...(data.features ?? []).map((f) => Row({ title: f.label, key: f.id,
|
|
50
|
+
...(data.features ?? []).map((f) => Row({ title: f.label, key: f.id, meta: f.resolved ? (f.selection ? undefined : `现在用 ${f.resolved.model}`) : "没有可用的模型" },
|
|
51
51
|
Select({ value: f.selection ? `${f.selection.provider}${SEP}${f.selection.model}` : "", "aria-label": f.label, onChange: (e) => pick(f.id, e.target.value) }, ...options(f.selection)))));
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -73,7 +73,7 @@ window.__ModuleLoader__.load({
|
|
|
73
73
|
const t = u.total ?? { calls: 0, in: 0, out: 0, cost: 0 };
|
|
74
74
|
return h(react.Fragment, null,
|
|
75
75
|
Group({ title: "用量", aside: h(Seg, { label: "时间范围", value: range, onChange: setRange, options: [{ value: "7", label: "7 天" }, { value: "30", label: "30 天" }] }) },
|
|
76
|
-
Row({ title: "合计",
|
|
76
|
+
Row({ title: "合计", meta: estimated ? "有的模型没报用量,按字数估的" : undefined },
|
|
77
77
|
Muted(`${t.calls} 次 · 输入 ${fmtTok(t.in)} · 输出 ${fmtTok(t.out)} token`), anyPrice ? Tag(`约 ${fmtCost(t.cost)}`, "info") : null),
|
|
78
78
|
features.length === 0 ? Empty("这段时间还没调用过模型") : h("div", { className: "fs-list" }, features.map(([id, f]) => h("div", { className: "fs-item", key: id },
|
|
79
79
|
h("span", { className: "fs-item-main" }, labels[id] ?? id),
|
|
@@ -120,7 +120,7 @@ window.__ModuleLoader__.load({
|
|
|
120
120
|
const own = cur.id !== "host";
|
|
121
121
|
const why = cur.id === "host" ? "DSH 里没有联网搜索工具(web_search),可以换成自己的搜索服务" : cur.needsBaseURL ? "先填 SearXNG 地址" : "先填 API Key";
|
|
122
122
|
return Group({ title: "上网查" },
|
|
123
|
-
Row({ title: "聊天时可以上网查",
|
|
123
|
+
Row({ title: "聊天时可以上网查", meta: w.available ? undefined : why },
|
|
124
124
|
w.enabled && w.available ? State(w.usedToday >= w.perDay ? "warning" : "done", `今天 ${w.usedToday}/${w.perDay}`) : null,
|
|
125
125
|
h(Switch, { label: "聊天时可以上网查", checked: w.enabled === true, disabled: !w.available && !w.enabled, onChange: (v) => save({ enabled: v }) })),
|
|
126
126
|
Row({ title: "聊天会话能用哪些工具", desc: "只放记忆和上网最安全;「只对主人放开」是主人的私聊会话放开宿主全部工具(其他人不变),「全放开」是所有聊天会话都放。放开后已开着的会话要在 DSH 里重开一次才生效。run_code 始终不放行" },
|
|
@@ -135,7 +135,7 @@ window.__ModuleLoader__.load({
|
|
|
135
135
|
h(Secret, { label: "API Key", value: key, placeholder: w.hasApiKey ? w.apiKeyMasked : "粘贴 key", onChange: (e) => setKey(e.target.value), onBlur: () => { if (key.trim() !== "") save({ apiKey: key.trim() }); } })) : null,
|
|
136
136
|
own && cur.needsBaseURL ? Row({ title: "SearXNG 地址" },
|
|
137
137
|
Input({ value: baseURL, placeholder: "http://127.0.0.1:8080", "aria-label": "SearXNG 地址", onChange: (e) => setBaseURL(e.target.value), onBlur: () => { if (baseURL !== (w.baseURL ?? "")) save({ baseURL }); } })) : null,
|
|
138
|
-
own && w.available ? Row({ title: "测一下",
|
|
138
|
+
own && w.available ? Row({ title: "测一下", meta: result ? `搜到 ${result.count} 条 · ${(result.latencyMs / 1000).toFixed(1)} 秒${result.results?.[0] ? ` · 第一条:${result.results[0].title}` : ""}` : undefined, desc: "搜一次「今天有什么新闻」,不算今天的次数" },
|
|
139
139
|
Button({ disabled: busy, onClick: test }, busy ? "搜索中" : "测一下")) : null,
|
|
140
140
|
w.enabled ? Row({ title: "每天最多" }, Num({ min: 0, max: 500, value: perDay, "aria-label": "每天最多", onChange: (e) => setPerDay(e.target.value), onBlur: () => save({}) }), Muted("次")) : null);
|
|
141
141
|
}
|
package/lib/client.persona.js
CHANGED
|
@@ -64,8 +64,7 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
return h("div", { className: "fs-persona" },
|
|
65
65
|
h("div", { className: "fs-persona-head" },
|
|
66
66
|
h("div", { className: "fs-persona-title" },
|
|
67
|
-
h("b", null, t.title), current ? Tag("在用", "info") : null,
|
|
68
|
-
h("span", { className: "fs-row-desc" }, t.tagline)),
|
|
67
|
+
h("b", null, t.title), current ? Tag("在用", "info") : null),
|
|
69
68
|
h("div", { className: "fs-ctl" },
|
|
70
69
|
Button({ variant: "ghost", onClick: onOpen, "aria-expanded": open }, open ? "收起" : "看看"),
|
|
71
70
|
confirm
|
|
@@ -104,7 +103,7 @@ window.__ModuleLoader__.load({
|
|
|
104
103
|
}) };
|
|
105
104
|
return { spec: "chara_card_v2", spec_version: "2.0", data };
|
|
106
105
|
}
|
|
107
|
-
return Group({ title: "编辑人格",
|
|
106
|
+
return Group({ title: "编辑人格", tip: "记忆和关系不变,换的是她是谁、怎么说话" },
|
|
108
107
|
...FIELDS.map((x) => Row({ key: x.key, title: x.title, desc: x.desc, stack: Boolean(x.area || x.stack) },
|
|
109
108
|
x.area ? Area({ rows: x.area, value: form[x.key], maxLength: x.max, "aria-label": x.title, onChange: (e) => set(x.key, e.target.value) })
|
|
110
109
|
: Input({ value: form[x.key], maxLength: x.max, "aria-label": x.title, onChange: (e) => set(x.key, e.target.value) }))),
|
|
@@ -138,7 +137,7 @@ window.__ModuleLoader__.load({
|
|
|
138
137
|
cfg.enabled ? Row({ title: "证据够了直接生效", desc: cfg.autoApply ? "关掉的话,先放在这里等你确认" : "证据够了也先等你确认" },
|
|
139
138
|
h(Switch, { label: "证据够了直接生效", checked: cfg.autoApply, onChange: (v) => post({ autoApply: v }, "已保存") })) : null,
|
|
140
139
|
list.length === 0 ? Row({ title: "还没有" }, Muted("聊得多了才会慢慢有;也可以自己加一条")) : null,
|
|
141
|
-
...list.map((i) => Row({ key: i.id, title: i.text,
|
|
140
|
+
...list.map((i) => Row({ key: i.id, title: i.text, meta: `${i.label} · ${evid(i)}${i.retiredReason ? ` · ${i.retiredReason}` : ""}` },
|
|
142
141
|
Tag(...(STATUS[i.status] ?? STATUS.candidate)),
|
|
143
142
|
i.status === "pending" || i.status === "candidate" ? Button({ variant: "ghost", disabled: busy, onClick: () => post({ action: "approve", id: i.id }, "已生效") }, "就这样") : null,
|
|
144
143
|
IconButton("close", "删掉这条", () => post({ action: "remove", id: i.id }, "已删掉")))),
|
|
@@ -266,11 +265,9 @@ window.__ModuleLoader__.load({
|
|
|
266
265
|
Group({ title: "现在的人格", aside: data.canUndo ? Button({ variant: "ghost", disabled: busy, onClick: undo }, "撤销上次更换") : null },
|
|
267
266
|
Row({ title: "名字", desc: cur.source === "persona.png" ? "从 persona.png 读的;在这里改了会另存成 persona.json" : undefined },
|
|
268
267
|
h("b", null, cur.name), Tag(SOURCE[cur.source] ?? cur.source, cur.source === "builtin" ? "outline" : undefined)),
|
|
269
|
-
cur.source
|
|
270
|
-
? Row({ title: "设定" }, Muted("只有一句话,挑个模板或者导入自己的角色卡会像真人很多"))
|
|
271
|
-
: Row({ title: "一句话人设", stack: true }, h("p", { className: "fs-persona-desc" }, cur.anchor || "没写(会用性格那一栏顶上)")),
|
|
268
|
+
cur.source !== "builtin" ? Row({ title: "一句话人设", stack: true }, h("p", { className: "fs-persona-desc" }, cur.anchor || "没写(会用性格那一栏顶上)")) : null,
|
|
272
269
|
cur.source !== "builtin" && (cur.perspective ?? []).length > 0 ? Row({ title: "看事情的方式", stack: true }, h("p", { className: "fs-persona-desc" }, cur.perspective.join(";"))) : null,
|
|
273
|
-
cur.source !== "builtin" ? Row({ title: "作息",
|
|
270
|
+
cur.source !== "builtin" ? Row({ title: "作息", meta: cur.routine ? undefined : "没写:排日程时只能按设定猜", stack: Boolean(cur.routine) }, cur.routine ? h("p", { className: "fs-persona-desc" }, cur.routine) : null) : null,
|
|
274
271
|
Row({ title: "改人格" },
|
|
275
272
|
Button({ onClick: () => setEditing(cur.card ?? blank) }, cur.card ? "编辑" : "从空白写"),
|
|
276
273
|
Button({ onClick: () => fileRef.current?.click(), disabled: busy }, "导入角色卡"),
|
|
@@ -278,7 +275,7 @@ window.__ModuleLoader__.load({
|
|
|
278
275
|
h("input", { ref: fileRef, type: "file", accept: ".json,.png,application/json,image/png", hidden: true, onChange: pickFile })),
|
|
279
276
|
Row({ title: "正在聊的也马上换", desc: freshOn ? "下一条消息起开新会话,旧聊天的口吻不带过来;记忆和关系都还在" : "沿用旧会话:新人格下一轮生效,但口吻可能要几轮才转过来" },
|
|
280
277
|
h(Switch, { label: "正在聊的也马上换", checked: freshOn, onChange: toggleFresh }))),
|
|
281
|
-
Group({ title: "人格模板"
|
|
278
|
+
Group({ title: "人格模板" },
|
|
282
279
|
...(data.templates ?? []).map((t) => h(Template, {
|
|
283
280
|
key: t.id, t, h, ui, open: open === t.id, current: cur.template === t.id && cur.source === "persona.json",
|
|
284
281
|
onOpen: () => setOpen(open === t.id ? null : t.id),
|
package/lib/client.soul.js
CHANGED
|
@@ -119,7 +119,7 @@ window.__ModuleLoader__.load({
|
|
|
119
119
|
p.stageLocked && p.canonicalId !== "master" ? Button({ variant: "ghost", disabled: busy, onClick: () => save({ stageLocked: false }, "关系交还给好感了") }, "改回自动") : null,
|
|
120
120
|
Select({ value: p.relationStage, disabled: busy, "aria-label": "关系", onChange: (e) => save({ relationStage: e.target.value }, `关系改成「${stageLabel(e.target.value)}」`) },
|
|
121
121
|
...STAGES.map(([k, v]) => h("option", { key: k, value: k }, v)))),
|
|
122
|
-
Row({ title: "好感",
|
|
122
|
+
Row({ title: "好感", meta: mood ? `她现在有点${mood.label}${mood.reason ? `(${mood.reason})` : ""}` : undefined },
|
|
123
123
|
h("div", { className: "fs-track", role: "meter", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": p.affinity ?? 0, "aria-label": "好感" },
|
|
124
124
|
h("div", { className: "fs-fill", style: { width: `${Math.max(0, Math.min(100, p.affinity ?? 0))}%` } })),
|
|
125
125
|
Muted(String(Math.round(p.affinity ?? 0)), { className: "fs-unit num" })),
|
|
@@ -127,7 +127,7 @@ window.__ModuleLoader__.load({
|
|
|
127
127
|
lockedF.has(f.id) ? Tag("手写", "info", { title: "主人写的,Dream 不改;清空就交还" }) : null,
|
|
128
128
|
Input({ value: form.fields[f.id] ?? "", placeholder: "还不知道", "aria-label": f.label, disabled: busy,
|
|
129
129
|
onChange: (e) => setForm({ ...form, fields: { ...form.fields, [f.id]: e.target.value } }), onBlur: () => saveField(f.id) })))) : null,
|
|
130
|
-
form && !legacy ? Row({ title: "印象",
|
|
130
|
+
form && !legacy ? Row({ title: "印象", meta: prof ? `${prof.by === "user" ? "改过" : "Dream 整理"} · ${fmtDay(prof.updatedAt)}` : undefined },
|
|
131
131
|
Button({ variant: "ghost", disabled: busy, onClick: dream }, "现在整理一次")) : null,
|
|
132
132
|
form && legacy ? Row({ title: "印象", stack: true },
|
|
133
133
|
Area({ value: form.profile, rows: 3, placeholder: "还没有印象:聊得多了 Dream 会写,也可以自己写", "aria-label": "印象", onChange: (e) => setForm({ ...form, profile: e.target.value }) }),
|
|
@@ -252,14 +252,14 @@ window.__ModuleLoader__.load({
|
|
|
252
252
|
Button({ disabled: busy || dbPath.trim() === "", onClick: () => preview({ dbPath }) }, "读聊天记录"),
|
|
253
253
|
Button({ variant: "ghost", disabled: busy || dbPath.trim() === "", onClick: previewExtras, title: "表情包 → _stickers;表达方式 / 黑话 → 学到的说法" }, "读表情和说法")) : null,
|
|
254
254
|
mx && showDb && !running ? h(react.Fragment, null,
|
|
255
|
-
Row({ title: `表情包 ${mx.emojis.count} 张`,
|
|
255
|
+
Row({ title: `表情包 ${mx.emojis.count} 张`, meta: mx.emojis.sample.length ? `比如:${mx.emojis.sample.join("、")}。按麦麦里用得多的挑;她每轮只看得到 _stickers 里前 40 张` : "没找到能用的表情(被禁用 / 未注册 / 图片文件不在的跳过)" },
|
|
256
256
|
Num({ min: 0, max: 100, value: mxOpts.maxEmojis, "aria-label": "最多导入几张", onChange: (e) => setMxOpts({ ...mxOpts, maxEmojis: e.target.value }) }), Muted("张"),
|
|
257
257
|
h(Switch, { label: "导入表情包", checked: mxOpts.emojis && mx.emojis.count > 0, disabled: mx.emojis.count === 0, onChange: (v) => setMxOpts({ ...mxOpts, emojis: v }) })),
|
|
258
|
-
Row({ title: `表达方式 ${mx.expressions.count} 条`,
|
|
258
|
+
Row({ title: `表达方式 ${mx.expressions.count} 条`, meta: mx.expressions.sample.join(";") || undefined },
|
|
259
259
|
h(Switch, { label: "导入表达方式", checked: mxOpts.expressions && mx.expressions.count > 0, disabled: mx.expressions.count === 0, onChange: (v) => setMxOpts({ ...mxOpts, expressions: v }) })),
|
|
260
|
-
Row({ title: `黑话 ${mx.jargons.count} 个`,
|
|
260
|
+
Row({ title: `黑话 ${mx.jargons.count} 个`, meta: mx.jargons.sample.join(";") || undefined },
|
|
261
261
|
h(Switch, { label: "导入黑话", checked: mxOpts.jargons && mx.jargons.count > 0, disabled: mx.jargons.count === 0, onChange: (v) => setMxOpts({ ...mxOpts, jargons: v }) })),
|
|
262
|
-
Row({ title: "分到这些聊天",
|
|
262
|
+
Row({ title: "分到这些聊天", meta: mx.chats.map((c) => `${c.title}(${c.expressions} / ${c.jargons})`).join("、") + "。每个聊天最多留 60 种说话方式、40 个梗,按次数留" },
|
|
263
263
|
...(mx.warnings ?? []).map((w, i) => Tag(w, "warning", { key: i })),
|
|
264
264
|
Button({ variant: "ghost", onClick: () => setMx(null) }, "取消"),
|
|
265
265
|
Button({ variant: "primary", disabled: busy, onClick: applyExtras }, "导入"))) : null,
|
|
@@ -277,27 +277,27 @@ window.__ModuleLoader__.load({
|
|
|
277
277
|
onChange: (e) => setOpts({ ...opts, qq: { ...opts.qq, [s.key]: e.target.value } }) }))))) : null,
|
|
278
278
|
pv.coverage && pv.coverage.droppedChunks > 0 ? Row({
|
|
279
279
|
title: `${pv.coverage.truncatedPersons} 个人的较早聊天按时间段总结`,
|
|
280
|
-
|
|
280
|
+
meta: `每人最近 ${pv.coverage.chunksPerPerson} 段(每段约 ${pv.coverage.chunkChars} 字)逐段提炼;更早的 ${pv.coverage.droppedChunks} 段、约 ${Math.round(pv.coverage.droppedChars / 1000) / 10} 万字` +
|
|
281
281
|
(pv.coverage.droppedFromMs ? `(最早到 ${new Date(pv.coverage.droppedFromMs).toLocaleDateString()})` : "") +
|
|
282
282
|
`压成 ${pv.coverage.eraChunks ?? 0} 个时间段总结(每人最多 ${pv.coverage.maxEras ?? 4} 段,聊天太多时只看抽样,细节会丢)。` +
|
|
283
283
|
(pv.coverage.topTruncated ?? []).map((t) => `${t.name}:${t.droppedChunks} 段压成总结${t.keptFromMs ? `,${new Date(t.keptFromMs).toLocaleDateString()} 之后逐段` : ""}`).join(";")
|
|
284
284
|
}, Tag("早期压缩", "warning")) : null,
|
|
285
285
|
pv.coverage && Number(opts.maxCalls) < pv.coverage.keptChunks ? Row({
|
|
286
286
|
title: `调用上限 ${opts.maxCalls} 次,还有 ${pv.coverage.keptChunks - Number(opts.maxCalls)} 段会跳过`,
|
|
287
|
-
|
|
287
|
+
meta: `要全部导入需要 ${pv.coverage.keptChunks} 次(最多 500);不够时每人从最近的往前轮流分,时间段总结最先砍`
|
|
288
288
|
}, Tag("额度不够", "warning")) : null,
|
|
289
|
-
Row({ title: "最多调用模型",
|
|
289
|
+
Row({ title: "最多调用模型", meta: pv.memoryCount && !pv.messageCount ? undefined : `${mapped} 个人能导入;没填 QQ 号的人跳过` },
|
|
290
290
|
Num({ min: 0, max: 500, value: opts.maxCalls, "aria-label": "最多调用模型", onChange: (e) => setOpts({ ...opts, maxCalls: e.target.value }) }), Muted("次"),
|
|
291
291
|
Button({ variant: "ghost", onClick: () => { setPv(null); setOpts(null); } }, "取消"),
|
|
292
292
|
Button({ variant: "primary", disabled: running || (mapped === 0 && !pv.memoryCount), onClick: start }, "开始导入"))) : null),
|
|
293
293
|
Group({ title: "备份" },
|
|
294
294
|
Row({ title: "每天自动备份" }, bk?.lastAt ? Muted(`上次 ${relTime(bk.lastAt, Date.now())}`) : null, h(Switch, { label: "每天自动备份", checked: bk?.auto !== false, onChange: setAuto })),
|
|
295
|
-
Row({ title: "备份",
|
|
295
|
+
Row({ title: "备份", meta: bk?.dir ? `${bk.dir}(每天一份,留最近 ${bk.keep ?? 7} 份)` : undefined },
|
|
296
296
|
Button({ disabled: busy, onClick: backupNow }, "立刻备份"),
|
|
297
297
|
h("a", { className: "fs-btn ghost", href: "/api/plugins/fish-soul/export/memories", download: "" }, "导出记忆")),
|
|
298
|
-
bk?.pendingRestore ? Row({ title: `重启 DSH 后恢复到 ${bk.pendingRestore.file}`,
|
|
298
|
+
bk?.pendingRestore ? Row({ title: `重启 DSH 后恢复到 ${bk.pendingRestore.file}`, meta: `这份有 ${bk.pendingRestore.memories} 条记忆、${bk.pendingRestore.persons} 个人;现在的库会先另存` },
|
|
299
299
|
Tag("等重启", "warning"), Button({ variant: "ghost", onClick: cancelRestore }, "不恢复了")) : null,
|
|
300
|
-
bk?.lastRestored ? Row({ title: `上次从 ${bk.lastRestored.file} 恢复`,
|
|
300
|
+
bk?.lastRestored ? Row({ title: `上次从 ${bk.lastRestored.file} 恢复`, meta: bk.lastRestored.safety ? `恢复前的库另存为 ${bk.lastRestored.safety},恢复错了可以在下面换回去` : undefined }, Muted(relTime(bk.lastRestored.at, Date.now()))) : null,
|
|
301
301
|
[...(bk?.list ?? []), ...(bk?.preRestore ?? [])].length > 0 ? h("div", { className: "fs-list" }, [...(bk?.list ?? []), ...(bk?.preRestore ?? [])].map((f) => h("div", { className: "fs-item", key: f.file },
|
|
302
302
|
f.preRestore ? Tag("恢复前另存", "outline") : null,
|
|
303
303
|
h("span", { className: "fs-item-main" }, f.file),
|
|
@@ -327,9 +327,9 @@ window.__ModuleLoader__.load({
|
|
|
327
327
|
m.when ? h("span", null, m.when) : null,
|
|
328
328
|
Muted(m.why)));
|
|
329
329
|
return Group({ title: "记忆调试", aside: res ? Tag(res.vector ? "关键词 + 意思" : "只有关键词", "outline", { title: res.vector ? "向量检索参与了" : "向量没开或还没算好,只按关键词" }) : null },
|
|
330
|
-
h("div", { className: "fs-
|
|
331
|
-
Input({ value: text, className: "wide", placeholder: "
|
|
332
|
-
h("span", { className: "fs-unit", title: "群里不会想起私聊说的事" }, "
|
|
330
|
+
h("div", { className: "fs-dock" },
|
|
331
|
+
Input({ value: text, className: "wide", placeholder: "假如他说……", "aria-label": "记忆调试", onChange: (e) => setText(e.target.value), onKeyDown: (e) => { if (e.key === "Enter" && text.trim()) run(); } }),
|
|
332
|
+
h("span", { className: "fs-unit", title: "群里不会想起私聊说的事" }, "群"),
|
|
333
333
|
h(Switch, { label: "在群里", checked: inGroup, onChange: setInGroup }),
|
|
334
334
|
Button({ disabled: busy || text.trim() === "", onClick: run }, busy ? "想…" : "试一下")),
|
|
335
335
|
res === null ? null : h("div", { className: "fs-list" },
|
|
@@ -468,7 +468,7 @@ window.__ModuleLoader__.load({
|
|
|
468
468
|
const add = () => { if (term.trim() && meaning.trim()) { edit({ add: { term, meaning } }, "加上了"); setTerm(""); setMeaning(""); } };
|
|
469
469
|
const addWay = () => { if (when.trim() && how.trim()) { edit({ addExpression: { situation: when, style: how } }, "加上了"); setWhen(""); setHow(""); } };
|
|
470
470
|
const ways = g.expressions ?? [];
|
|
471
|
-
return Group({ title: isGlobal ? "所有聊天都能用的说法(导入的)" : `${isGroup ? "群里的说法" : "私聊学到的"} · ${g.title || g.channelId}`,
|
|
471
|
+
return Group({ title: isGlobal ? "所有聊天都能用的说法(导入的)" : `${isGroup ? "群里的说法" : "私聊学到的"} · ${g.title || g.channelId}`, tip: isGlobal ? "排在每个聊天自己学的后面" : undefined, aside: isGlobal ? null : h("span", { className: "fs-group-aside" },
|
|
472
472
|
Muted(`${g.learnedAt ? `${relTime(g.learnedAt, Date.now())}学的` : "还没学过"} · 攒了 ${g.lines} 句`),
|
|
473
473
|
Button({ variant: "ghost", disabled: busy, onClick: learn }, busy ? "学习中" : "现在学一次")) },
|
|
474
474
|
isGlobal ? null : Row({ title: "说话风格", desc: g.styleByUser ? "你改过,不会被覆盖" : undefined },
|
|
@@ -516,22 +516,37 @@ window.__ModuleLoader__.load({
|
|
|
516
516
|
h("span", { className: "fs-item-meta" }, h("span", null, p.until ? `到 ${fmtClock(p.until)}` : "一直"),
|
|
517
517
|
Button({ variant: "ghost", onClick: () => resume(p.channelId) }, "恢复")))))),
|
|
518
518
|
Group({ title: "最近", aside: Tag(String(decisions.length), "outline") },
|
|
519
|
-
h("div", { className: "fs-
|
|
519
|
+
h("div", { className: "fs-steps" }, decisions.length === 0 ? Empty("还没有动静") : decisions.map((d, i) => {
|
|
520
520
|
const [label, tone] = KINDS[d.kind] ?? [d.kind, "outline"];
|
|
521
521
|
const body = d.text ? [d.who && `${d.who}:`, d.text].filter(Boolean).join("") : d.who;
|
|
522
522
|
const tip = [d.title, body, d.reason, d.memories?.length ? `想起了:\n${d.memories.join("\n")}` : ""].filter(Boolean).join("\n");
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
h("span", { className: "fs-
|
|
526
|
-
h("span", { className: "fs-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
h("span", null,
|
|
523
|
+
const more = Boolean((body && body.length > 36) || d.reason || d.memories?.length);
|
|
524
|
+
const head = [
|
|
525
|
+
h("span", { className: "fs-step-dot", "data-tone": tone, key: "d", "aria-hidden": true }),
|
|
526
|
+
h("span", { className: "fs-step-kind", key: "k" }, label),
|
|
527
|
+
h("span", { className: "fs-item-main", key: "m", title: tip }, h("b", { className: "fs-strong" }, d.title), body ? ` ${body}` : ""),
|
|
528
|
+
h("span", { className: "fs-item-meta", key: "t" },
|
|
529
|
+
d.memories?.length ? h("span", null, `想起 ${d.memories.length}`) : null,
|
|
530
|
+
h("span", { className: "num" }, relTime(d.at, now)))];
|
|
531
|
+
if (!more) return h("div", { className: "fs-step", key: `${d.at}-${i}` }, h("div", { className: "fs-step-head" }, ...head));
|
|
532
|
+
return h("details", { className: "fs-step", key: `${d.at}-${i}` },
|
|
533
|
+
h("summary", { className: "fs-step-head" }, ...head, ui.Icon("chevron", 12)),
|
|
534
|
+
h("div", { className: "fs-step-body" },
|
|
535
|
+
body && body.length > 36 ? h("p", null, body) : null,
|
|
536
|
+
d.reason ? h("p", { className: "fs-muted" }, d.reason) : null,
|
|
537
|
+
d.memories?.length ? h("ul", null, d.memories.map((m, j) => h("li", { key: j }, m))) : null));
|
|
530
538
|
}))),
|
|
531
539
|
(data.dreamLog ?? []).length === 0 ? null : Group({ title: "整理记录" },
|
|
532
|
-
h("div", { className: "fs-
|
|
533
|
-
|
|
534
|
-
|
|
540
|
+
h("div", { className: "fs-steps" }, data.dreamLog.map((x, i) => {
|
|
541
|
+
const head = [
|
|
542
|
+
h("span", { className: "fs-step-dot", "data-tone": "success", key: "d", "aria-hidden": true }),
|
|
543
|
+
h("span", { className: "fs-item-main", key: "m" }, `${x.name}:${[x.profile ? "更新了印象" : "", x.outdated?.length ? `${x.outdated.length} 条记忆判为过时` : ""].filter(Boolean).join(",")}`),
|
|
544
|
+
h("span", { className: "fs-item-meta", key: "t" }, h("span", { className: "num" }, relTime(x.at, now)))];
|
|
545
|
+
if (!(x.outdated ?? []).length) return h("div", { className: "fs-step", key: i }, h("div", { className: "fs-step-head" }, ...head));
|
|
546
|
+
return h("details", { className: "fs-step", key: i },
|
|
547
|
+
h("summary", { className: "fs-step-head" }, ...head, ui.Icon("chevron", 12)),
|
|
548
|
+
h("div", { className: "fs-step-body" }, h("ul", null, x.outdated.map((o) => h("li", { key: o.id }, `#${o.id}「${o.content}」→ #${o.by}:${o.reason}`)))));
|
|
549
|
+
}))),
|
|
535
550
|
h(StickerShelf, { api, apiBase, notify, relTime, ui }),
|
|
536
551
|
h(SlangShelf, { api, notify, relTime, ui }));
|
|
537
552
|
}
|
package/lib/config-schema.js
CHANGED
|
@@ -13,6 +13,7 @@ export function fishSoulConfigSchema(z) {
|
|
|
13
13
|
allGroups: z.boolean().default(false), // 显式放开:true = 所有群(仍然只听点名)
|
|
14
14
|
followUpCount: z.number().default(3),
|
|
15
15
|
followUpSeconds: z.number().default(120),
|
|
16
|
+
followUpSmart: z.boolean().default(false), // #59 她自己说"这轮聊完了"就不接着听(默认关)
|
|
16
17
|
batchMs: z.number().default(3000),
|
|
17
18
|
replyWindowMinutes: z.number().default(10),
|
|
18
19
|
callNames: z.array(z.string()).default([]), // 叫这些名字也算点名;空 = 人格卡名字(≥2 个字才算)
|
|
@@ -21,7 +22,9 @@ export function fishSoulConfigSchema(z) {
|
|
|
21
22
|
chance: z.number().default(0.05),
|
|
22
23
|
cooldownMinutes: z.number().default(15),
|
|
23
24
|
maxPerHour: z.number().default(3),
|
|
24
|
-
keywords: z.array(z.string()).default([])
|
|
25
|
+
keywords: z.array(z.string()).default([]),
|
|
26
|
+
masterQuiet: z.boolean().default(true), // #59 主人在跟她聊时少插话(默认开)
|
|
27
|
+
masterQuietMinutes: z.number().default(5) // 主人多久内说过话算"在聊"
|
|
25
28
|
}).default({})
|
|
26
29
|
}).default({}),
|
|
27
30
|
attachments: z.object({ // QQ 附件:txt/md 这类直接读进提示词;pdf/docx 存到插件数据目录再报路径
|
package/lib/gateway-util.js
CHANGED
|
@@ -73,6 +73,19 @@ export async function fetchImageBytes(img) {
|
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/** 对话收尾标记:她觉得这一轮聊完了,就在回复最后单独一行写这个(发出去之前要剥掉)。 */
|
|
77
|
+
export const CLOSING_MARK = '【收尾】';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 剥掉收尾标记:返回剥干净的正文 + 有没有标记。
|
|
81
|
+
* 标记是内部控制符,永远不发给群里;留不留空行由这里收尾。
|
|
82
|
+
*/
|
|
83
|
+
export function parseClosing(text) {
|
|
84
|
+
const raw = String(text ?? '');
|
|
85
|
+
if (!raw.includes(CLOSING_MARK)) return { text: raw, closing: false };
|
|
86
|
+
return { text: raw.split(CLOSING_MARK).join('').replace(/\n{3,}/g, '\n\n').trim(), closing: true };
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
/** 设置里的 qq.interject → 规整后的插话参数(默认关)。 */
|
|
77
90
|
export function interjectConfig(raw) {
|
|
78
91
|
const v = raw ?? {};
|
|
@@ -82,7 +95,10 @@ export function interjectConfig(raw) {
|
|
|
82
95
|
chance: num(v.chance, 0.05, 0, 1),
|
|
83
96
|
cooldownMinutes: num(v.cooldownMinutes, 15, 0, 1440),
|
|
84
97
|
maxPerHour: Math.floor(num(v.maxPerHour, 3, 0, 30)),
|
|
85
|
-
keywords: Array.isArray(v.keywords) ? v.keywords.map((x) => String(x).trim()).filter(Boolean).slice(0, 50) : []
|
|
98
|
+
keywords: Array.isArray(v.keywords) ? v.keywords.map((x) => String(x).trim()).filter(Boolean).slice(0, 50) : [],
|
|
99
|
+
// #59 主人在聊的闸门:默认开,主人最近 masterQuietMinutes 分钟内跟她说过话就少插话
|
|
100
|
+
masterQuiet: v.masterQuiet !== false,
|
|
101
|
+
masterQuietMinutes: num(v.masterQuietMinutes, 5, 0, 1440)
|
|
86
102
|
};
|
|
87
103
|
}
|
|
88
104
|
|