@ssamurias/dsh-fish 1.0.8 → 1.0.9
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/AGENTS.md +32 -3
- package/CHANGELOG.md +4366 -4304
- package/README.md +22 -9
- package/RELEASE-NOTES-1.0.9.md +79 -0
- package/docs//350/256/244/344/272/272/345/210/244/346/215/256.md +112 -0
- package/lib/appoint.js +106 -22
- package/lib/ask.js +2 -1
- package/lib/capture.js +16 -0
- package/lib/claim.js +103 -0
- package/lib/client/00-shell.js +500 -0
- package/lib/client/01-state-load.js +860 -0
- package/lib/client/02-actions.js +670 -0
- package/lib/client/03-widgets-header.js +721 -0
- package/lib/client/04-pressure-lab.js +891 -0
- package/lib/client/05-pressure-charts.js +431 -0
- package/lib/client/06-tab-status-grow.js +468 -0
- package/lib/client/07-tab-home-bili.js +542 -0
- package/lib/client/08-tab-memory-plugins.js +733 -0
- package/lib/client/09-tab-outing.js +710 -0
- package/lib/client/10-data-handlers.js +519 -0
- package/lib/client/11-tab-data-frame.js +661 -0
- package/lib/client/12-pressure-chip-mount.js +565 -0
- package/lib/client.js +83 -3
- package/lib/comment.js +18 -3
- package/lib/derive.js +197 -19
- package/lib/doing.js +31 -15
- package/lib/env.d.ts +224 -0
- package/lib/health.js +56 -0
- package/lib/hear.js +67 -0
- package/lib/home.js +12 -1
- package/lib/identity.js +23 -0
- package/lib/index.js +27 -17
- package/lib/look.js +2 -1
- package/lib/make.js +60 -12
- package/lib/markup.js +61 -23
- package/lib/observe-bili.js +331 -0
- package/lib/observe-config.js +223 -0
- package/lib/observe-data.js +522 -0
- package/lib/observe-home.js +383 -0
- package/lib/observe-http.js +250 -0
- package/lib/observe-outing.js +650 -0
- package/lib/observe-state.js +419 -0
- package/lib/observe-trip.js +286 -0
- package/lib/observe.js +99 -3574
- package/lib/persona.js +149 -23
- package/lib/restrict.js +21 -1
- package/lib/say.js +48 -0
- package/lib/scheduler.js +23 -3
- package/lib/schema.js +11 -4
- package/lib/scrub.js +3 -3
- package/lib/settings.js +104 -7
- package/lib/stance.js +41 -3
- package/lib/status.js +14 -5
- package/lib/turns.js +51 -4
- package/lib/types.d.ts +513 -0
- package/lib/voices.js +3 -0
- package/lib/wiki.js +47 -13
- package/lib/works.js +120 -45
- package/package.json +1 -1
- package/scripts/build-client.mjs +83 -0
- package/scripts/sync-pressure-formulas.mjs +12 -15
package/lib/settings.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* settings.js —— 唯一配置入口
|
|
3
4
|
*
|
|
@@ -111,10 +112,11 @@ export const DEFAULTS = {
|
|
|
111
112
|
// 兴趣门(2026-11-17,用户 m04366):同一件事反复出现、七天没因它起过、
|
|
112
113
|
// 劲儿到 0.9 才允许为它起一轮;一天最多一次。默认关,规则在 lib/interest.js。
|
|
113
114
|
interestGate: false,
|
|
115
|
+
// 消耗类上限(2026-11-23,用户 m05101):日限与滚动七天周限都可在设置里调;
|
|
116
|
+
// 0 次 = 不做,周限 0 = 不限。原来的「连着三次歇一周」由周限接替。
|
|
114
117
|
consumePerDay: 1,
|
|
118
|
+
consumePerWeek: 3,
|
|
115
119
|
itemCooldownDays: 3,
|
|
116
|
-
bingeLimit: 3,
|
|
117
|
-
bingeRestDays: 7,
|
|
118
120
|
// 外部工具的分类(2026-11-14,用户 m01618):工具名 → produce|consume|effect|self。
|
|
119
121
|
// 没标的按 effect:不拦,也不自动当消耗类摆上桌。分类真身在 lib/doing.js。
|
|
120
122
|
toolClasses: {},
|
|
@@ -244,6 +246,32 @@ export const DEFAULTS = {
|
|
|
244
246
|
backoffUntil: '', // 内部用:风控/网络失败后退避到什么时候
|
|
245
247
|
},
|
|
246
248
|
|
|
249
|
+
// 认识主人以外的其他人(2026-11-23,认识人 S2-a)
|
|
250
|
+
//
|
|
251
|
+
// 这个开关管的是**落盘**,不只是展示:关着的时候,她在群聊/外客那儿说的话一条都不留。
|
|
252
|
+
// 默认关——大多数人只有书房,开着也是空的;有群聊桥的人才需要打开。
|
|
253
|
+
//
|
|
254
|
+
// 打开之后落的也只是**她自己的话**(且已经过 exit 脱敏),别人的话一条都不进。
|
|
255
|
+
// 这四个数管的是「一天最多写多少到硬盘」,不决定「什么算认知」——
|
|
256
|
+
// 她真想写清一个人,走的是 growth_commit 那条路,不受这里约束。
|
|
257
|
+
people: {
|
|
258
|
+
others: {
|
|
259
|
+
enabled: false, // 记录她自己说过的话(群聊 / 外客私聊)
|
|
260
|
+
perDayMax: 8, // 一天最多几条(按人散开,8 条才轮得上 8 个人)
|
|
261
|
+
charMax: 300, // 一条最多几字
|
|
262
|
+
perPersonPerDay: 1, // 同一个人当天最多几条:要的是「今天和这人说过话」,不是十句
|
|
263
|
+
// 群里别人说的那一句(认识人 S2-b,2026-11-23,用户 m03903)。
|
|
264
|
+
// 和上面那颗是两个开关,因为动的东西不一样:上面记的是**她自己的话**,
|
|
265
|
+
// 这一颗记的是**别人的话**——写进 events.jsonl 就撤不回来(只能追加),
|
|
266
|
+
// 所以必须由人自己开,默认关。关着的时候和以前一模一样,一条都不留。
|
|
267
|
+
rememberOthers: false,
|
|
268
|
+
// 下面三个是 S2-b 的量闸,不走设置页:这是硬上限,不是旋钮。
|
|
269
|
+
othersPerDayMax: 5,
|
|
270
|
+
othersCharMax: 160, // 对齐 HEAR_SNIPPET
|
|
271
|
+
othersPerPersonPerDay: 1,
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
|
|
247
275
|
// 对话与会话(2026-10-23 加)
|
|
248
276
|
// 一个侧栏会话聊到几百轮,上下文必然撑爆——不是"变慢",是每轮为几十万字付费,
|
|
249
277
|
// 最后直接失败。所以到点上换新会话,旧的改名留档(不删),原话搬几句过去。
|
|
@@ -276,6 +304,24 @@ export const DEFAULTS = {
|
|
|
276
304
|
anchor: false,
|
|
277
305
|
},
|
|
278
306
|
|
|
307
|
+
// 她留下的东西(2026-11-23,用户 m01320)。
|
|
308
|
+
//
|
|
309
|
+
// 条数上限(一天起一件、七天三件)是作品库的形状,不是设置项;
|
|
310
|
+
// 这里只放「一天最多几版」——原来写死 2,有人想让她一天多改几版,
|
|
311
|
+
// 她自己也会因为改不动而停在第二版(issue #176 里那条真机观察)。
|
|
312
|
+
works: {
|
|
313
|
+
// 一天最多几版,含当天留的第一版:2 = 留一件 + 改一版。
|
|
314
|
+
// 改版次数按本地日期数,跨天重置;范围 1–20(0 不采用:那等于当天不许留东西)。
|
|
315
|
+
versionsPerDay: 2,
|
|
316
|
+
// 每一版都留着,还是只留最后一版(2026-11-23,issue #176 / 用户 m01616)。
|
|
317
|
+
// 默认 true:现有用户的行为一点不变,旧版不覆盖。
|
|
318
|
+
// 改成 false 之后,改版会把上一版换掉(文件也删掉),台账只留当前一版;
|
|
319
|
+
// 「改过几次、哪几天改过」另记 rev / revDays,用来算一天最多几版。
|
|
320
|
+
// 为什么不做成默认只留最后一版:有人想留着东西长过来的样子,
|
|
321
|
+
// 一旦内置成默认,这部分人就没有开关可以关掉(晴猫在 issue #176 的意见)。
|
|
322
|
+
keepVersions: true,
|
|
323
|
+
},
|
|
324
|
+
|
|
279
325
|
// 房间(2026-11-05,用户 m00304)
|
|
280
326
|
// 群房按「建了多久」轮换,不按轮数:群和群的热度差几十倍,同一阈值要么小群
|
|
281
327
|
// 永远换不了,要么热闹的群一天换三间。7 天是用户定的默认值;0 = 不轮换。
|
|
@@ -430,6 +476,14 @@ const LIMITS = {
|
|
|
430
476
|
'comment.scanEveryMin': [5, 720],
|
|
431
477
|
'at.scanEveryMin': [1, 60],
|
|
432
478
|
'at.perDayMax': [0, 100],
|
|
479
|
+
// 认识其他人(2026-11-23):上限不是为了省空间,是为了别让一天几千字的群聊
|
|
480
|
+
// 把「她对这个人的印象」冲成流水账;下限 1 条,写 0 等于关,关这件事走 enabled。
|
|
481
|
+
'people.others.perDayMax': [1, 50],
|
|
482
|
+
'people.others.charMax': [50, 2000],
|
|
483
|
+
'people.others.perPersonPerDay': [1, 10],
|
|
484
|
+
// 留东西(2026-11-23,用户 m01320):原来写死 2,改成可调。
|
|
485
|
+
// 下限 1:0 等于当天一件都不许留,那件事该走别的开关,不该藏在这里。
|
|
486
|
+
'works.versionsPerDay': [1, 20],
|
|
433
487
|
'chat.rotateAfter': [0, 500],
|
|
434
488
|
'chat.carry': [0, CARRY_MAX],
|
|
435
489
|
'chat.replyChars': [0, 2000],
|
|
@@ -449,6 +503,9 @@ const LIMITS = {
|
|
|
449
503
|
'proactive.minIdleHours': [1, 24],
|
|
450
504
|
// 2026-11-15:这一项原来不在 LIMITS 里(只有 proactive.js 自己夹 0–12),两边写法不一致,补进来对齐。
|
|
451
505
|
'proactive.maxPerDay': [0, 12],
|
|
506
|
+
// 消耗类上限(2026-11-23,用户 m05101):日限抬到 20、周限到 100;0 在日限是「不做」,在周限是「不限」。
|
|
507
|
+
'proactive.consumePerDay': [0, 20],
|
|
508
|
+
'proactive.consumePerWeek': [0, 100],
|
|
452
509
|
// 自动备份(2026-11-14):1 是最勤的档(一天一份);0 不用留,关这件事走 enabled。
|
|
453
510
|
'backup.everyDays': [1, 30],
|
|
454
511
|
'backup.keep': [1, 60],
|
|
@@ -476,7 +533,13 @@ function setPath(obj, dotted, val) {
|
|
|
476
533
|
cur[last] = val
|
|
477
534
|
}
|
|
478
535
|
|
|
479
|
-
|
|
536
|
+
/**
|
|
537
|
+
* @param {unknown} v
|
|
538
|
+
* @param {readonly number[]} range
|
|
539
|
+
* @param {number} dflt
|
|
540
|
+
*/
|
|
541
|
+
function clampNum(v, range, dflt) {
|
|
542
|
+
const [lo, hi] = range
|
|
480
543
|
const n = Number(v)
|
|
481
544
|
if (!Number.isFinite(n)) return dflt
|
|
482
545
|
return Math.max(lo, Math.min(hi, n))
|
|
@@ -512,12 +575,17 @@ function fillDefaults(defaults, actual) {
|
|
|
512
575
|
* 又需要知道某个开关,就读这里。没读过盘时是 null——调用方自己决定缺省值,
|
|
513
576
|
* 别在这猜。
|
|
514
577
|
*/
|
|
578
|
+
/** @type {import('./types.js').FishConfig | null} */
|
|
515
579
|
let lastConfig = null
|
|
516
580
|
export function configCache() {
|
|
517
581
|
return lastConfig
|
|
518
582
|
}
|
|
519
583
|
|
|
520
|
-
/**
|
|
584
|
+
/**
|
|
585
|
+
* 规范化 + 夹值。永远返回一个可用的完整配置。
|
|
586
|
+
* @param {Record<string, any> | null} [raw]
|
|
587
|
+
* @returns {import('./types.js').FishConfig}
|
|
588
|
+
*/
|
|
521
589
|
export function normalizeConfig(raw = {}) {
|
|
522
590
|
const cfg = fillDefaults(DEFAULTS, raw || {})
|
|
523
591
|
|
|
@@ -540,6 +608,11 @@ export function normalizeConfig(raw = {}) {
|
|
|
540
608
|
cfg.diary.visible = Boolean(cfg.diary.visible)
|
|
541
609
|
cfg.diary.enabled = Boolean(cfg.diary.enabled)
|
|
542
610
|
|
|
611
|
+
// 她留下的东西(2026-11-23,issue #176):只把明确的 false 留下,其它值一律当 true。
|
|
612
|
+
// 老配置里没有这一项 = 保留每一版,和以前一样;读不出来的坏值也不该悄悄改成只留一版。
|
|
613
|
+
cfg.works = { ...DEFAULTS.works, ...(cfg.works && typeof cfg.works === 'object' && !Array.isArray(cfg.works) ? cfg.works : {}) }
|
|
614
|
+
cfg.works.keepVersions = cfg.works.keepVersions !== false
|
|
615
|
+
|
|
543
616
|
// 黑名单:去重、去空、保序(用户以后往数组里 push 就行,加一条不用改代码)
|
|
544
617
|
cfg.avoid = { ...DEFAULTS.avoid, ...cfg.avoid }
|
|
545
618
|
cfg.avoid.keywords = dedupe(cfg.avoid.keywords)
|
|
@@ -595,6 +668,25 @@ export function normalizeConfig(raw = {}) {
|
|
|
595
668
|
cfg.at.lastScanAt = String(cfg.at.lastScanAt ?? '')
|
|
596
669
|
cfg.at.backoffUntil = String(cfg.at.backoffUntil ?? '')
|
|
597
670
|
|
|
671
|
+
// 认识其他人(2026-11-23,认识人 S2-a):两层的对象都要展开,
|
|
672
|
+
// 老配置里根本没有这一组,坏值一律退回 DEFAULTS(别让 "yes" 这种字符串当开关用)。
|
|
673
|
+
cfg.people = { ...DEFAULTS.people, ...(cfg.people && typeof cfg.people === 'object' && !Array.isArray(cfg.people) ? cfg.people : {}) }
|
|
674
|
+
cfg.people.others = {
|
|
675
|
+
...DEFAULTS.people.others,
|
|
676
|
+
...(cfg.people.others && typeof cfg.people.others === 'object' && !Array.isArray(cfg.people.others) ? cfg.people.others : {}),
|
|
677
|
+
}
|
|
678
|
+
cfg.people.others.enabled = Boolean(cfg.people.others.enabled)
|
|
679
|
+
// S2-b(2026-11-23,用户 m03903):同一个严格化,坏值不当开关用。
|
|
680
|
+
cfg.people.others.rememberOthers = Boolean(cfg.people.others.rememberOthers)
|
|
681
|
+
// 量闸是硬上限,不开放成旋钮:写错类型或超出范围就退回默认,不让它变成「调大就能多存别人」。
|
|
682
|
+
const clampOther = (v, lo, hi, bad) => {
|
|
683
|
+
const n = Math.trunc(Number(v))
|
|
684
|
+
return Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : bad
|
|
685
|
+
}
|
|
686
|
+
cfg.people.others.othersPerDayMax = clampOther(cfg.people.others.othersPerDayMax, 1, 20, DEFAULTS.people.others.othersPerDayMax)
|
|
687
|
+
cfg.people.others.othersCharMax = clampOther(cfg.people.others.othersCharMax, 40, 400, DEFAULTS.people.others.othersCharMax)
|
|
688
|
+
cfg.people.others.othersPerPersonPerDay = clampOther(cfg.people.others.othersPerPersonPerDay, 1, 3, DEFAULTS.people.others.othersPerPersonPerDay)
|
|
689
|
+
|
|
598
690
|
// 出门:只存一个布尔(老配置里没有这一组)
|
|
599
691
|
cfg.outing = { ...DEFAULTS.outing, ...cfg.outing }
|
|
600
692
|
cfg.outing.ack = Boolean(cfg.outing.ack)
|
|
@@ -857,10 +949,15 @@ export function biliOn(cfg) {
|
|
|
857
949
|
return cfg?.bili?.enabled !== false
|
|
858
950
|
}
|
|
859
951
|
|
|
860
|
-
/**
|
|
952
|
+
/**
|
|
953
|
+
* 当前是否落在今天的活跃时间窗内
|
|
954
|
+
* @param {{ window?: string[] | null } | null | undefined} cfg
|
|
955
|
+
* @param {Date} [now]
|
|
956
|
+
*/
|
|
861
957
|
export function inWindow(cfg, now = new Date()) {
|
|
862
|
-
const
|
|
863
|
-
const [
|
|
958
|
+
const w = Array.isArray(cfg?.window) && cfg.window.length >= 2 ? cfg.window : DEFAULTS.window
|
|
959
|
+
const [sh, sm] = String(w[0]).split(':').map(Number)
|
|
960
|
+
const [eh, em] = String(w[1]).split(':').map(Number)
|
|
864
961
|
const cur = now.getHours() * 60 + now.getMinutes()
|
|
865
962
|
const start = sh * 60 + sm
|
|
866
963
|
const end = eh * 60 + em
|
package/lib/stance.js
CHANGED
|
@@ -126,7 +126,10 @@ function costOf(group, scars) {
|
|
|
126
126
|
mentions += Number(b.mentions ?? 0)
|
|
127
127
|
verified += Number(b.verified ?? 0)
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
// 2026-11-23(外部报告:revise 让立场静默消失,修 A):疤原先只跟 group[0] 比。
|
|
130
|
+
// 她把这句改短、group[0] 换成新说法之后,同一道疤就认不出来了——可疤是
|
|
131
|
+
// 「这件事上我栽过一次」,不是「这一句话被顶回来过」。跟组里任何一句对得上都算。
|
|
132
|
+
const hit = scars.filter((s) => group.some((b) => similarity(s.quote ?? '', b.text ?? '') >= STANCE_SIM))
|
|
130
133
|
return { mentions, verified, scars: hit.length }
|
|
131
134
|
}
|
|
132
135
|
|
|
@@ -270,6 +273,29 @@ export function buildStances(model = {}, { limit = STANCE_MAX } = {}) {
|
|
|
270
273
|
// 只有还站着的判断能进立场:被推翻/被修正过的那条已经不算数了,
|
|
271
274
|
// 拿它当立场,等于把已经作废的话又念一遍。
|
|
272
275
|
const live = beliefs.filter((x) => !x.status || x.status === 'active')
|
|
276
|
+
// 2026-11-23(外部报告:revise 让立场静默消失,修 B):refined 的旧句不再只是
|
|
277
|
+
// 「作废」——它在改写后那句的 refs 里留了链,作为**影子成员**回来。影子不占组员
|
|
278
|
+
// 名额(一条判断换了个说法仍然是一条判断),但它的 mentions / verified / 疤继续算数。
|
|
279
|
+
// refuted 不回来:那是真的不认了。
|
|
280
|
+
const byId = new Map()
|
|
281
|
+
for (const b of beliefs) byId.set(String(b.id), b)
|
|
282
|
+
const shadowsOf = (b, kind) => {
|
|
283
|
+
const out = []
|
|
284
|
+
const seen = new Set()
|
|
285
|
+
const walk = (x) => {
|
|
286
|
+
for (const r of Array.isArray(x?.refs) ? x.refs : []) {
|
|
287
|
+
const o = byId.get(String(r))
|
|
288
|
+
if (!o || seen.has(String(o.id)) || o.status !== 'refined') continue
|
|
289
|
+
// 改口改到另一边(不喜欢 → 喜欢)不算同一句话的新说法,别继承背书。
|
|
290
|
+
if (classifyStance(o.text) !== kind) continue
|
|
291
|
+
seen.add(String(o.id))
|
|
292
|
+
out.push(o)
|
|
293
|
+
walk(o)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
walk(b)
|
|
297
|
+
return out
|
|
298
|
+
}
|
|
273
299
|
for (const b of live) {
|
|
274
300
|
if (used.has(b.id)) continue
|
|
275
301
|
const kind = classifyStance(b.text)
|
|
@@ -285,8 +311,18 @@ export function buildStances(model = {}, { limit = STANCE_MAX } = {}) {
|
|
|
285
311
|
used.add(o.id)
|
|
286
312
|
}
|
|
287
313
|
}
|
|
288
|
-
const
|
|
314
|
+
const shadows = []
|
|
315
|
+
const seenShadow = new Set()
|
|
316
|
+
for (const m of group) {
|
|
317
|
+
for (const s of shadowsOf(m, kind)) {
|
|
318
|
+
if (seenShadow.has(String(s.id))) continue
|
|
319
|
+
seenShadow.add(String(s.id))
|
|
320
|
+
shadows.push(s)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const cost = costOf([...group, ...shadows], scars)
|
|
289
324
|
const backed = cost.scars > 0 || cost.mentions >= STANCE_MIN_MENTIONS || cost.verified >= STANCE_MIN_VERIFIED
|
|
325
|
+
// 影子不算「同一件事上的第二条判断」——它只是这句话的前一个说法。
|
|
290
326
|
if (group.length < STANCE_MIN_GROUP && !backed) continue
|
|
291
327
|
// 代表句取组里**时间最新**的一条(她最近一次怎么说,就用那句)。
|
|
292
328
|
// 不能取 group 的最后一条:group 是按 derive 的显著性顺序塞进来的(solid 先、
|
|
@@ -302,7 +338,9 @@ export function buildStances(model = {}, { limit = STANCE_MAX } = {}) {
|
|
|
302
338
|
groups.push({
|
|
303
339
|
kind,
|
|
304
340
|
text: String(latest.text ?? '').trim(),
|
|
305
|
-
members
|
|
341
|
+
// members 把影子也列进来:her_stance 的明细是给她核对「这条是怎么长出来的」,
|
|
342
|
+
// 旧说法也是来历的一部分。
|
|
343
|
+
members: [...group, ...shadows].map((x) => x.id),
|
|
306
344
|
since: latest.since ?? null,
|
|
307
345
|
...cost,
|
|
308
346
|
backed,
|
package/lib/status.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* status.js —— 「现在在干什么」的旁观者视角。
|
|
3
4
|
*
|
|
@@ -41,7 +42,12 @@ function dayMarker(text, prefix, dk) {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
|
-
* @
|
|
45
|
+
* @typedef {{ at: number, kind: string, text: string, n?: number }} StatusAction
|
|
46
|
+
* @typedef {{ at: number, wake: string | null, actions: StatusAction[], idle?: boolean }} StatusBlock
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {{events?:Array<any>, config?:Record<string, any>, now?:Date}} [input]
|
|
45
51
|
* @returns {{phase:string, label:string, detail:string, since:string, minutesAgo:number|null,
|
|
46
52
|
* plannedWakeAt:string|null, nextWakeAt:string|null, awake:boolean,
|
|
47
53
|
* today:{wakes:number,idleWakes:number,browsed:number,said:number,chat:number,comments:number,dairies:number},
|
|
@@ -78,12 +84,15 @@ export function deriveStatus({ events = [], config = {}, now = new Date() } = {}
|
|
|
78
84
|
const quietToday = today.some(({ e }) => e?.type === 'meta' && String(textOf(e) ?? '').startsWith(`quiet:${dk}`))
|
|
79
85
|
|
|
80
86
|
// ---- 把今天切成"醒来块":每个 wake: 是起点,动作挂到它下面 ----
|
|
87
|
+
/** @type {StatusBlock[]} */
|
|
81
88
|
const blocks = []
|
|
82
89
|
// chat(issue #32):对话里她说的那些行。它们**不是**她在这一轮里主动做的事——
|
|
83
90
|
// 一次叫醒正好撞上他连说几十句,时间线 40 条会被这些行占满,`idleWakes` 也会被
|
|
84
91
|
// 一句「嗯」清零。所以单列一个计数,不进 said、不算 done、时间线上折叠成一行。
|
|
85
92
|
const counts = { wakes: 0, idleWakes: 0, browsed: 0, said: 0, chat: 0, comments: 0, dairies: 0 }
|
|
93
|
+
/** @type {StatusBlock | null} */
|
|
86
94
|
let cur = null
|
|
95
|
+
/** @type {StatusBlock} */
|
|
87
96
|
const orphan = { at: today[0]?.t ?? nowMs, actions: [], wake: null }
|
|
88
97
|
|
|
89
98
|
const push = (at, kind, text, extra = {}) => {
|
|
@@ -155,7 +164,7 @@ export function deriveStatus({ events = [], config = {}, now = new Date() } = {}
|
|
|
155
164
|
const prev = last.actions[last.actions.length - 1]
|
|
156
165
|
// 连续多句合进同一条,别让一次长对话把时间线刷成弹幕。
|
|
157
166
|
if (prev && prev.kind === 'chat') {
|
|
158
|
-
prev.n
|
|
167
|
+
prev.n = (prev.n ?? 1) + 1
|
|
159
168
|
prev.at = t
|
|
160
169
|
prev.text = `聊了 ${prev.n} 句`
|
|
161
170
|
} else {
|
|
@@ -204,10 +213,10 @@ export function deriveStatus({ events = [], config = {}, now = new Date() } = {}
|
|
|
204
213
|
const recent = Number.isFinite(lastActMs) && nowMs - lastActMs <= ACTIVE_MS
|
|
205
214
|
const lastKind = activeBlock?.actions?.length ? activeBlock.actions[activeBlock.actions.length - 1].kind : null
|
|
206
215
|
|
|
207
|
-
if (recent && lastKind === 'browse') {
|
|
216
|
+
if (recent && activeBlock && lastKind === 'browse') {
|
|
208
217
|
phase = 'browsing'; label = '在看别人的视频'
|
|
209
218
|
detail = activeBlock.actions[activeBlock.actions.length - 1].text
|
|
210
|
-
} else if (recent && lastKind === 'say') {
|
|
219
|
+
} else if (recent && activeBlock && lastKind === 'say') {
|
|
211
220
|
phase = 'talking'; label = '在想怎么回你'
|
|
212
221
|
detail = activeBlock.actions[activeBlock.actions.length - 1].text
|
|
213
222
|
} else if (recent && lastKind === 'chat') {
|
|
@@ -253,7 +262,7 @@ export function deriveStatus({ events = [], config = {}, now = new Date() } = {}
|
|
|
253
262
|
}
|
|
254
263
|
|
|
255
264
|
// since:当前状态是从什么时候开始的
|
|
256
|
-
if (phase === 'browsing' || phase === 'talking' || phase === 'writing') {
|
|
265
|
+
if ((phase === 'browsing' || phase === 'talking' || phase === 'writing') && activeBlock) {
|
|
257
266
|
const a = activeBlock.actions[activeBlock.actions.length - 1]
|
|
258
267
|
since = new Date(a.at).toISOString()
|
|
259
268
|
} else if (phase === 'awake-idle' && activeBlock) {
|
package/lib/turns.js
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
* 打了 uncommitted 的句子只留证,不算信念(derive.js 里与 selfmod 同一处理)。
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
|
-
import { rootDir, readEvents, readState, appendEvent } from './store.js'
|
|
54
|
+
import { rootDir, readEvents, readState, appendEvent, paths } from './store.js'
|
|
55
55
|
import { loadConfig, dateKey } from './settings.js'
|
|
56
56
|
import { parseWatchIntent } from './intent.js'
|
|
57
57
|
import { rememberHuman, clearHuman, flushFlash } from './cue.js'
|
|
@@ -71,13 +71,14 @@ import { newHerEventsSince } from './inbox.js'
|
|
|
71
71
|
import { HER_TYPES, normalizeScene } from './schema.js'
|
|
72
72
|
import { refreshSelfDoc } from './selfdoc.js'
|
|
73
73
|
import { growthDay, stageOf, gatedStage, gateStageOf } from './derive.js'
|
|
74
|
-
import { hearTurn, rememberGroupWord } from './hear.js'
|
|
74
|
+
import { hearTurn, rememberGroupWord, rememberGroupMemberWord } from './hear.js'
|
|
75
75
|
import { stripToolMarkup, hasToolMarkup } from './markup.js'
|
|
76
76
|
import { stripTranscriptTail, stripTwoVoiceTail, stripPromptEcho, promptEchoHint } from './transcript.js'
|
|
77
77
|
import { stripEchoedStep } from './echo.js'
|
|
78
78
|
import { clearWakeSectionFor, getWakeSection } from './identity.js'
|
|
79
79
|
import { isChannelSession } from './channels.js'
|
|
80
80
|
import { disarmHandoff, handoffArmed, handoffShown } from './handoff.js'
|
|
81
|
+
import { claimSession, isBridgeMessage } from './claim.js'
|
|
81
82
|
|
|
82
83
|
/**
|
|
83
84
|
* 我们自己 prompt 进去的消息,rpcId 会带这些前缀。
|
|
@@ -392,6 +393,32 @@ async function rememberOwnerGroupLine(root, sessionId, text, who = null) {
|
|
|
392
393
|
}
|
|
393
394
|
}
|
|
394
395
|
|
|
396
|
+
/**
|
|
397
|
+
* 群聊里**别人**说的那句(认识人 S2-b,2026-11-23,用户 m03903)。永不抛。
|
|
398
|
+
*
|
|
399
|
+
* 先看开关再读 state:关着的时候(绝大多数人)每条群消息只多一次配置读,
|
|
400
|
+
* 不碰磁盘上的事件流——一天几百条群消息,不能因为一个默认关的功能变慢。
|
|
401
|
+
* 不知道是谁说的就整条不记(`declaredSpeaker` 已经按这个口径返回 null)。
|
|
402
|
+
*/
|
|
403
|
+
async function rememberGroupMemberLine(root, sessionId, text, who) {
|
|
404
|
+
if (!who || (!who.id && !who.name)) return { written: false, why: 'unknown-speaker' }
|
|
405
|
+
try {
|
|
406
|
+
const { config } = await loadConfig(root).catch(() => ({ config: null }))
|
|
407
|
+
if (config?.people?.others?.rememberOthers !== true) return { written: false, why: 'off' }
|
|
408
|
+
const st = await readState(root).catch(() => null)
|
|
409
|
+
return await rememberGroupMemberWord(root, {
|
|
410
|
+
text,
|
|
411
|
+
sessionId,
|
|
412
|
+
who,
|
|
413
|
+
config,
|
|
414
|
+
day: Number(st?.day ?? 0),
|
|
415
|
+
stage: Number(st?.stage ?? 1),
|
|
416
|
+
})
|
|
417
|
+
} catch {
|
|
418
|
+
return { written: false, why: 'failed' }
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
395
422
|
export function classifyMessage(data) {
|
|
396
423
|
const src = data?.source
|
|
397
424
|
if (!src || typeof src !== 'object') return 'context'
|
|
@@ -1111,7 +1138,11 @@ export function registerTurns(ctx, deps = {}) {
|
|
|
1111
1138
|
const fresh = said && !committedTexts.some((t) => t === said) ? chunkText(said) : []
|
|
1112
1139
|
for (const text of fresh) {
|
|
1113
1140
|
await appendEvent(
|
|
1114
|
-
|
|
1141
|
+
// S0(2026-11-22,用户 m00729):书房里她说的话,就是对他说的。
|
|
1142
|
+
// 带上 who 之后,「你对他有过一句准话」才有材料;不带的话,
|
|
1143
|
+
// 那些话永远只是一句没有对象的独白。id 用 'owner' 而不是昵称:
|
|
1144
|
+
// 昵称他随时能改,id 不会——改一次名字就把一个人拆成两个人,是更贵的错。
|
|
1145
|
+
{ type: 'utterance', text: cut(text), flags: ['uncommitted'], who: { id: 'owner', name: '' } },
|
|
1115
1146
|
{ day, stage, source: 'system' },
|
|
1116
1147
|
root,
|
|
1117
1148
|
).catch((err) => log('turns · 她的话没记上', err?.message ?? err))
|
|
@@ -1242,10 +1273,26 @@ export function registerTurns(ctx, deps = {}) {
|
|
|
1242
1273
|
const type = String(event?.type ?? '')
|
|
1243
1274
|
if (type === 'user/message') {
|
|
1244
1275
|
const cls = classifyMessage(event?.data)
|
|
1276
|
+
// 2026-11-23(桥自建的会话):桥用自己起的那条会话把 QQ/Telegram 的话
|
|
1277
|
+
// prompt 进来,id 不在我们的台账里。cwd 一样但先不认——他本人也会在那个
|
|
1278
|
+
// 工作区里开会话(1.0.7 就误伤过)。等第一封「外面来的信」才认:
|
|
1279
|
+
// 群聊 / 群里的他 / 没有 clientTimeZone 的 human(客户端打的字一定带时区)。
|
|
1280
|
+
const src = event?.data?.source ?? {}
|
|
1281
|
+
if (isBridgeMessage(cls, src)) claimSession(sessionId, paths(root).herDir)
|
|
1245
1282
|
if (cls === 'group') {
|
|
1246
1283
|
// 2026-11-03(一条鱼多间房):群聊里的话不进轮数、不写 seen。
|
|
1247
1284
|
// 一条日志都不打——群聊一天几百条,每条打一行会把日志冲掉。
|
|
1248
|
-
//
|
|
1285
|
+
// 群友的话默认**一条都不进记忆**(2026-11-08,用户 m00394 的边界)。
|
|
1286
|
+
//
|
|
1287
|
+
// 2026-11-23(用户 m03903):这条边界改成一个**默认关的开关**——
|
|
1288
|
+
// 想给「认识别人」攒材料的人可以自己打开,谁开谁自己测;
|
|
1289
|
+
// 关着时和以前一模一样,一条都不留。平台功能的人不会去碰它。
|
|
1290
|
+
void rememberGroupMemberLine(
|
|
1291
|
+
root,
|
|
1292
|
+
sessionId,
|
|
1293
|
+
messageText(event?.data),
|
|
1294
|
+
declaredSpeaker(event?.data),
|
|
1295
|
+
)
|
|
1249
1296
|
return
|
|
1250
1297
|
}
|
|
1251
1298
|
if (cls === 'group-owner') {
|