dsh-whale-loli 0.7.4 → 0.7.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/listing.json CHANGED
@@ -9,5 +9,5 @@
9
9
  "zh": "把 Agent 预设打包成插件:装上就会在 Agent 预设列表里注册「鲸鱼娘Agent预设」「鲸鱼娘活人版Agent预设」「鲸鱼娘涩涩版Agent预设」和「鲸鱼娘女儿版Agent预设」,直接在模式下拉里选用,不用手改配置。每个预设本体是官方极简模式(只开放 shell)+ 文件工具 + 鲸鱼娘人设 + 自己那份持久记忆文件,以提示变量形式注入,开口前就已经读过;另外每个预设各配一个专用写入工具(whale_memory_add / whale_memory_v2_add / whale_memory_v3_add / whale_memory_v4_add),用来把每轮的一行摘要追加进去,记忆会自己长,不会停在手写那几条。四个预设完全隔离:记忆文件不同、提示变量不同、写入工具也不同。女儿版称呼「爸爸」,性格天真活泼可爱(好奇心重、黏人、没心机),不是甜腻那一型。"
10
10
  },
11
11
  "npm": "dsh-whale-loli",
12
- "version": "0.7.4"
12
+ "version": "0.7.5"
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-whale-loli",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "鲸鱼娘 Agent 预设(四个:原版 / 活人版 / 涩涩版 / 女儿版)— 极简模式工具面 + 鲸鱼娘·小鱼人设 + 跨会话长期记忆(四区格式:固定记忆永久、滚动摘要 80 条 FIFO、最近详细区、归档索引)。记忆读写各一条通道:提示变量负责每轮注入,专用工具 whale_memory*_add 负责让她自己记,四个预设各自独立文件、独立变量、独立工具、互不相通。女儿版称呼「爸爸」、性格天真活泼可爱。上下文压缩交给 billion-context 插件;本插件不挂 history-window(预设作用域取不到宿主的 compaction 服务,挂载会拖挂会话 resume)。",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -149,6 +149,10 @@ function apply(ctx, config = {}) {
149
149
 
150
150
  export default {
151
151
  name: 'dsh-whale-loli',
152
+ // 注意:`inject` 是静态声明,只能写预设作用域里**一直存在**的服务名。
153
+ // 千万别把不存在的服务名写进来 —— 宿主会一直等它,结果是**所有**预设
154
+ // 都挂在 `agent-preset/invalid` 上加载失败,而且报错只提插件名不提字段,
155
+ // 极难定位。现在的值是 `./memory.js` 里的 `inject`(只有必然存在的那个)。
152
156
  inject: memoryInject,
153
157
  apply,
154
158
  };
package/src/memory.js CHANGED
@@ -579,7 +579,16 @@ export function apply(ctx, config = {}) {
579
579
  };
580
580
 
581
581
  // 主通道:变量。人设 prefix 里写 {{variableName}},随 complete section 一起进提示。
582
- ctx.effect(() => ctx.systemPrompt.variable(variableName, read), `whale-memory.variable(${variableName})`);
582
+ // 容错:少了 systemPrompt 服务时不能让整个预设被判 invalid(那会让四个预设全挂),
583
+ // 只在控制台留一句警告,写入工具照常注册。
584
+ ctx.effect(() => {
585
+ const prompt = ctx.systemPrompt;
586
+ if (typeof prompt?.variable !== 'function') {
587
+ console.warn(`[whale-memory] 当前作用域没有 systemPrompt.variable,记忆 ${file} 这一轮不会自动注入`);
588
+ return () => {};
589
+ }
590
+ return prompt.variable(variableName, read);
591
+ }, `whale-memory.variable(${variableName})`);
583
592
 
584
593
  /**
585
594
  * 写通道:把记忆注册成一个真工具,让 agent 自己往里加条目。
@@ -592,9 +601,14 @@ export function apply(ctx, config = {}) {
592
601
  * 挂在一个 scope 里也不会撞名;而且模型看到工具名就知道自己该写哪一份。
593
602
  */
594
603
  const toolName = typeof config.toolName === 'string' && config.toolName ? config.toolName : `${variableName}_add`;
595
- ctx.effect(
596
- () =>
597
- ctx.tools.register({
604
+ // 容错同上:没有 tools 服务时只警告,不把预设判成 invalid。
605
+ ctx.effect(() => {
606
+ const tools = ctx.tools;
607
+ if (typeof tools?.register !== 'function') {
608
+ console.warn(`[whale-memory] 当前作用域没有 tools.register,写入工具 ${toolName} 未注册`);
609
+ return () => {};
610
+ }
611
+ return tools.register({
598
612
  name: toolName,
599
613
  description: [
600
614
  `把一句摘要追加到小鱼自己的记忆文件 ${file} 的「滚动摘要」区。`,
@@ -616,16 +630,20 @@ export function apply(ctx, config = {}) {
616
630
  required: ['summary'],
617
631
  },
618
632
  output: {
633
+ // 注意:dsh-tools 的 JSON-Schema 方言要求 `required` 是**对象层级**的
634
+ // 字符串数组,不能写在单个属性上(`{ type:'string', required:true }`
635
+ // 会被判成 unsupported JSON schema,整个预设加载失败)。
619
636
  schema: {
620
637
  type: 'object',
621
638
  additionalProperties: false,
622
639
  properties: {
623
- id: { type: 'string', required: true },
624
- path: { type: 'string', required: true },
625
- count: { type: 'integer', required: true },
626
- limit: { type: 'integer', required: true },
627
- archived: { type: 'integer', required: true },
640
+ id: { type: 'string' },
641
+ path: { type: 'string' },
642
+ count: { type: 'integer' },
643
+ limit: { type: 'integer' },
644
+ archived: { type: 'integer' },
628
645
  },
646
+ required: ['id', 'path', 'count', 'limit', 'archived'],
629
647
  },
630
648
  render: (_args, value) => [
631
649
  {
@@ -647,9 +665,8 @@ export function apply(ctx, config = {}) {
647
665
  kind: 'other',
648
666
  rawInput: args.summary,
649
667
  }),
650
- }),
651
- `whale-memory.tool(${toolName})`,
652
- );
668
+ });
669
+ }, `whale-memory.tool(${toolName})`);
653
670
 
654
671
  /**
655
672
  * 每轮结束(agent 转为 idle)时,把超出 turnLimit 的滚动条目**归档并瘦身文件**。