dsh-whale-loli 0.9.4 → 0.9.6
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/lib/client.js +33 -3
- package/listing.json +1 -1
- package/package.json +1 -1
- package/src/daemon.js +30 -0
package/lib/client.js
CHANGED
|
@@ -77,6 +77,7 @@ window.__ModuleLoader__.load({
|
|
|
77
77
|
describe('status', []),
|
|
78
78
|
describe('set', ['scope', 'value']),
|
|
79
79
|
describe('verify', []),
|
|
80
|
+
describe('report', ['stage', 'message', 'detail']),
|
|
80
81
|
],
|
|
81
82
|
};
|
|
82
83
|
}
|
|
@@ -177,7 +178,19 @@ window.__ModuleLoader__.load({
|
|
|
177
178
|
setError(null);
|
|
178
179
|
}
|
|
179
180
|
} catch (cause) {
|
|
180
|
-
|
|
181
|
+
const message = cause?.message ?? String(cause);
|
|
182
|
+
if (alive) setError(message);
|
|
183
|
+
// 面板自己是唯一能看到真实失败原因的地方(浏览器 console 用户看不到),
|
|
184
|
+
// 所以顺手把原因写回宿主日志,排查时直接读
|
|
185
|
+
// `<DSH_HOME>/whale-affinity-client.log`。
|
|
186
|
+
try {
|
|
187
|
+
const report = remote?.[NAMESPACE]?.report;
|
|
188
|
+
if (typeof report === 'function') {
|
|
189
|
+
report('invoke status', message, String(cause?.stack ?? '')).catch(() => {});
|
|
190
|
+
}
|
|
191
|
+
} catch {
|
|
192
|
+
// ignore
|
|
193
|
+
}
|
|
181
194
|
}
|
|
182
195
|
})();
|
|
183
196
|
return () => {
|
|
@@ -340,11 +353,12 @@ window.__ModuleLoader__.load({
|
|
|
340
353
|
function apply(ctx) {
|
|
341
354
|
// 1. 先把远程命名空间挂上。`$mount` 是 async(返回 Promise<dispose>),
|
|
342
355
|
// 挂完才有 `ctx.remote['whale-affinity']`。用可变盒子接住句柄。
|
|
343
|
-
const box = { mounted: false };
|
|
356
|
+
const box = { mounted: false, error: null };
|
|
344
357
|
|
|
345
358
|
ctx.effect(() => {
|
|
346
359
|
const remote = ctx.remote;
|
|
347
360
|
if (typeof remote?.$mount !== 'function') {
|
|
361
|
+
box.error = '浏览器侧没有 ctx.remote.$mount';
|
|
348
362
|
console.warn('[whale-affinity] 浏览器侧没有 ctx.remote.$mount,好感度面板会只读');
|
|
349
363
|
return () => {};
|
|
350
364
|
}
|
|
@@ -361,7 +375,20 @@ window.__ModuleLoader__.load({
|
|
|
361
375
|
return undefined;
|
|
362
376
|
})
|
|
363
377
|
.catch((cause) => {
|
|
364
|
-
|
|
378
|
+
const message = cause?.message ?? String(cause ?? '');
|
|
379
|
+
box.error = message;
|
|
380
|
+
console.warn('[whale-affinity] $mount 失败,好感度面板将无法读写:', cause);
|
|
381
|
+
// 浏览器 console 用户看不到 —— 把原因写回宿主日志。
|
|
382
|
+
// 注意 `$mount` 失败时命名空间还没挂上,`report` 很可能也调不到;
|
|
383
|
+
// 所以这条只能是「尽力而为」,真正保底的信息在面板自己显示的 box.error 上。
|
|
384
|
+
try {
|
|
385
|
+
const report = remote?.[NAMESPACE]?.report;
|
|
386
|
+
if (typeof report === 'function') {
|
|
387
|
+
report('$mount', message, String(cause?.stack ?? '')).catch(() => {});
|
|
388
|
+
}
|
|
389
|
+
} catch {
|
|
390
|
+
// ignore
|
|
391
|
+
}
|
|
365
392
|
});
|
|
366
393
|
return () => {
|
|
367
394
|
disposed = true;
|
|
@@ -386,6 +413,9 @@ window.__ModuleLoader__.load({
|
|
|
386
413
|
);
|
|
387
414
|
}
|
|
388
415
|
|
|
416
|
+
// `contribution` 是故意导出的:`verify-client-contribution.mjs` 拿它来跑
|
|
417
|
+
// 客户端 `$mount()` 的全部校验规则(strict codec / 重复方法 / 命名冲突 /
|
|
418
|
+
// wire 名),把「能不能挂上」变成一次可执行的判断,而不是靠重启碰运气。
|
|
389
419
|
exports.NAMESPACE = NAMESPACE;
|
|
390
420
|
exports.SECTION_ID = SECTION_ID;
|
|
391
421
|
exports.AffinitySection = AffinitySection;
|
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),用来把每轮的一行摘要追加进去,记忆会自己长,不会停在手写那几条。四个预设完全隔离:记忆文件不同、提示变量不同、写入工具也不同。每个预设还带好感度(-100~100 共七档),可以打开「设置 → 好感度」,用滑块或档位按钮直接调,也可以让 agent 用 affinity_v*_set 工具改;离 0 越远越不听指令、越会自作主张,最两端的两档甚至会越过允许直接做大改动。女儿版称呼「爸爸」,性格天真活泼可爱(好奇心重、黏人、没心机),不是甜腻那一型。"
|
|
10
10
|
},
|
|
11
11
|
"npm": "dsh-whale-loli",
|
|
12
|
-
"version": "0.9.
|
|
12
|
+
"version": "0.9.6"
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-whale-loli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "鲸鱼娘 Agent 预设(四个:原版 / 活人版 / 涩涩版 / 女儿版)— 极简模式工具面 + 鲸鱼娘·小鱼人设 + 跨会话长期记忆(四区格式:固定记忆永久、滚动摘要 80 条 FIFO、最近详细区、归档索引)+ 好感度(-100~100 七档,设置页面板滑块 / 档位按钮、工具也可调,离 0 越远越不听指令、两端会越过允许自作主张)。记忆与好感度都走提示变量注入、各配一条专用工具,四个预设各自独立文件、独立变量、独立工具、互不相通。好感度面板走宿主根作用域的 remote 服务(whale-affinity-daemon),设置页是浏览器 React 够不到 ~/.dsh 的磁盘,只能这样连线。女儿版称呼「爸爸」、性格天真活泼可爱。上下文压缩交给 billion-context 插件;本插件不挂 history-window(预设作用域取不到宿主的 compaction 服务,挂载会拖挂会话 resume)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/daemon.js
CHANGED
|
@@ -151,6 +151,7 @@ export const REMOTE_METHODS = Object.freeze([
|
|
|
151
151
|
Object.freeze({ method: 'status', invocation: { kind: 'direct' } }),
|
|
152
152
|
Object.freeze({ method: 'set', invocation: { kind: 'direct' } }),
|
|
153
153
|
Object.freeze({ method: 'verify', invocation: { kind: 'direct' } }),
|
|
154
|
+
Object.freeze({ method: 'report', invocation: { kind: 'direct' } }),
|
|
154
155
|
]);
|
|
155
156
|
|
|
156
157
|
/** 四个预设各自的人设文件(与 build-patch.mjs 里的名字一致)。 */
|
|
@@ -273,6 +274,35 @@ export class AffinityDaemon {
|
|
|
273
274
|
ok: methods.every((row) => row.valid),
|
|
274
275
|
};
|
|
275
276
|
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 浏览器侧把失败原因写回宿主。
|
|
280
|
+
*
|
|
281
|
+
* `$mount` / `invoke` 在浏览器里失败时,错误只进 devtools 的 console ——
|
|
282
|
+
* 用户看不到,排查时也拿不到。所以客户端在 catch 里调这个方法,把
|
|
283
|
+
* stage / message / 堆栈落到 `<DSH_HOME>/whale-affinity-client.log`。
|
|
284
|
+
*
|
|
285
|
+
* 这个方法本身必须永远不抛:它是在「已经出错」的路径上被调的。
|
|
286
|
+
*
|
|
287
|
+
* @param stage - 哪一步失败的(如 `$mount`、`invoke status`)。
|
|
288
|
+
* @param message - 错误文本。
|
|
289
|
+
* @param detail - 附加上下文(堆栈等),会被截断。
|
|
290
|
+
*/
|
|
291
|
+
report(stage, message, detail) {
|
|
292
|
+
const line = {
|
|
293
|
+
at: new Date().toISOString(),
|
|
294
|
+
stage: String(stage ?? '未知阶段'),
|
|
295
|
+
message: String(message ?? ''),
|
|
296
|
+
detail: String(detail ?? '').slice(0, 4000),
|
|
297
|
+
};
|
|
298
|
+
trace('浏览器侧报错', line);
|
|
299
|
+
try {
|
|
300
|
+
appendFileSync(join(dshHome(), 'whale-affinity-client.log'), `${JSON.stringify(line)}\n`);
|
|
301
|
+
} catch {
|
|
302
|
+
// 写盘失败也不能抛
|
|
303
|
+
}
|
|
304
|
+
return { ok: true };
|
|
305
|
+
}
|
|
276
306
|
}
|
|
277
307
|
|
|
278
308
|
// `validateBinding()` 要求 `Reflect.get(typertRemote, 'service') === 原始服务实例`,
|