dsh-fish-soul 0.13.1 → 0.13.2
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 +1 -1
- package/lib/index.js +17 -0
- package/lib/routes.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -535,11 +535,27 @@ async function startup(ctx, config, { log, gate }) {
|
|
|
535
535
|
return out;
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
+
/**
|
|
539
|
+
* #40 systemPrompt 只该注给鱼的会话:我们的网关会话(QQ / B站 / 抖音)、或 DSH 里认得出人的会话。
|
|
540
|
+
* 宿主自己的技术会话整块不给——以前全局注册把「此刻状态 + 人格」漏进所有对话,装了插件 DSH 就没法当技术助手用。
|
|
541
|
+
* 宿主没给会话 id 时按鱼的会话处理(别把鱼搞哑),给了但认不出 / 是匿名 dsh 会话就不注。
|
|
542
|
+
*/
|
|
543
|
+
function injectsFor(arg) {
|
|
544
|
+
const ids = [arg?.agent?.id, arg?.agent?.session?.id, arg?.scope?.id, arg?.session?.id, arg?.sessionId];
|
|
545
|
+
const found = ids.map((x) => String(x ?? '')).filter((x) => x !== '');
|
|
546
|
+
if (found.length === 0) return true;
|
|
547
|
+
return found.some((id) => {
|
|
548
|
+
const session = sessionFor(id);
|
|
549
|
+
return session !== undefined && (session.channel !== 'dsh' || (session.speakers ?? []).length > 0);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
|
|
538
553
|
/**
|
|
539
554
|
* 同步组装本轮瞬态块:BM25 当场算(本轮消息,零滞后),向量排名若已为同一 query 预取完成则一起融合。
|
|
540
555
|
* 多人合批时按人分别召回,token 预算平分。宿主传入 { agent, scope },按 agent.id 取本会话的上下文。
|
|
541
556
|
*/
|
|
542
557
|
function buildContextBlock(arg) {
|
|
558
|
+
if (injectsFor(arg) === false) return ''; // #40 不是鱼的会话:整块不给
|
|
543
559
|
const session = sessionFor(arg?.agent?.id ?? arg?.scope?.id ?? arg?.sessionId);
|
|
544
560
|
const lines = [stateLine()];
|
|
545
561
|
if (session === undefined) return lines.join('\n');
|
|
@@ -842,6 +858,7 @@ async function startup(ctx, config, { log, gate }) {
|
|
|
842
858
|
personaText: () => persona.staticText,
|
|
843
859
|
buildContextBlock,
|
|
844
860
|
noteInteraction,
|
|
861
|
+
isFishSession: injectsFor, // #40 不是鱼的会话不注人格 / 瞬态块
|
|
845
862
|
log
|
|
846
863
|
});
|
|
847
864
|
|
package/lib/routes.js
CHANGED
|
@@ -731,15 +731,16 @@ export function mountApiGate(ctx, log = () => {}) {
|
|
|
731
731
|
* (message.content 是块数组、message.source 是来源)。
|
|
732
732
|
*/
|
|
733
733
|
export function registerAgentHooks(ctx, deps) {
|
|
734
|
-
const { personaText, buildContextBlock, noteInteraction, log } = deps;
|
|
734
|
+
const { personaText, buildContextBlock, noteInteraction, isFishSession, log } = deps;
|
|
735
735
|
|
|
736
|
-
// 人格卡静态注入(KV Cache
|
|
736
|
+
// 人格卡静态注入(KV Cache 前缀)。#40:宿主把 text 回调在每个会话里都会调,
|
|
737
|
+
// 不是鱼的会话返回空串,别让「鱼」的人格污染用户自己的技术对话。
|
|
737
738
|
try {
|
|
738
739
|
ctx.effect(() => ctx.systemPrompt.section({
|
|
739
740
|
name: 'fish-soul-persona',
|
|
740
741
|
order: 89000, // 宿主自有段排到 ~10200,人格卡放其后、动态段之前
|
|
741
742
|
interpolate: false,
|
|
742
|
-
text: () => (typeof personaText === 'function' ? personaText() : personaText)
|
|
743
|
+
text: (arg) => (isFishSession(arg) === false ? '' : (typeof personaText === 'function' ? personaText() : personaText))
|
|
743
744
|
}), 'dsh-fish-soul: persona section');
|
|
744
745
|
} catch (error) {
|
|
745
746
|
log('error', `[fish-soul] persona section 挂不上:${String(error instanceof Error ? error.message : error)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-fish-soul",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记(DSH 插件,单角色 feiyu)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|