@ssamurias/dsh-fish 1.1.2 → 1.1.4
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 +13 -7
- package/CHANGELOG.md +170 -0
- package/README.md +75 -4
- package/RELEASE-NOTES-1.1.3.md +89 -0
- package/RELEASE-NOTES-1.1.4.md +87 -0
- package/docs//350/256/244/344/272/272/345/210/244/346/215/256.md +4 -1
- package/lib/absence.js +1 -1
- package/lib/appoint.js +9 -1
- package/lib/ask.js +3 -3
- package/lib/backup.js +44 -1
- package/lib/basis.js +85 -0
- package/lib/capture.js +96 -4
- package/lib/claim.js +35 -0
- package/lib/client/01-state-load.js +41 -7
- package/lib/client/02-actions.js +27 -5
- package/lib/client/03-widgets-header.js +29 -1
- package/lib/client/04-pressure-lab.js +15 -0
- package/lib/client/09-tab-outing.js +88 -1
- package/lib/client/11-tab-data-frame.js +7 -3
- package/lib/client/12-pressure-chip-mount.js +14 -0
- package/lib/client.js +221 -17
- package/lib/comment.js +824 -823
- package/lib/compactionlog.js +181 -0
- package/lib/derive.js +290 -47
- package/lib/dream.js +3 -1
- package/lib/firstwake.js +6 -3
- package/lib/generator.js +4 -0
- package/lib/handoff.js +93 -8
- package/lib/health.js +4 -1
- package/lib/hear.js +67 -9
- package/lib/herpeople.js +28 -14
- package/lib/herperson.js +384 -0
- package/lib/home.js +8 -3
- package/lib/identity.js +100 -24
- package/lib/index.js +33 -2
- package/lib/letter.js +3 -1
- package/lib/mapserve.js +10 -0
- package/lib/match.js +3 -1
- package/lib/memorymap-html.js +1 -1
- package/lib/memorymap.js +22 -3
- package/lib/notice.js +60 -0
- package/lib/observe-bili.js +1 -1
- package/lib/observe-home.js +52 -7
- package/lib/observe-http.js +20 -1
- package/lib/observe-state.js +22 -3
- package/lib/observe-trip.js +1 -1
- package/lib/people.js +259 -22
- package/lib/peopledoc.js +1 -1
- package/lib/person.js +95 -0
- package/lib/persona.js +37 -24
- package/lib/proactive.js +1 -1
- package/lib/pronounask.js +2 -2
- package/lib/quota.js +34 -0
- package/lib/recall.js +267 -17
- package/lib/reset-pending.js +349 -0
- package/lib/reset.js +8 -4
- package/lib/restrict.js +1 -0
- package/lib/say.js +70 -10
- package/lib/scheduler.js +176 -28
- package/lib/schema.js +141 -2
- package/lib/selfdoc.js +13 -5
- package/lib/session-pressure-analysis.js +24 -4
- package/lib/session-pressure-data.js +5 -0
- package/lib/session-pressure.js +32 -6
- package/lib/settings.js +3 -2
- package/lib/sleepfact.js +9 -3
- package/lib/stance.js +56 -19
- package/lib/store.js +53 -5
- package/lib/talkmem.js +151 -21
- package/lib/turnexport.js +34 -5
- package/lib/turns.js +70 -9
- package/lib/types.d.ts +12 -2
- package/lib/unclaimed.js +102 -0
- package/lib/whatseen.js +17 -0
- package/lib/wiki.js +86 -1
- package/lib/works.js +2 -0
- package/package.json +1 -1
package/lib/memorymap.js
CHANGED
|
@@ -52,6 +52,7 @@ export function herNameOf(events) {
|
|
|
52
52
|
/** 图例里四个扇区的名字(2026-11-27 用户要求:「人」→「对人的了解」、「听说的」→「听说的事」)。 */
|
|
53
53
|
import { MEMORY_MAP_HTML_B64 } from './memorymap-html.js'
|
|
54
54
|
import { readEvents } from './store.js'
|
|
55
|
+
import { loadConfig } from './settings.js'
|
|
55
56
|
import { examine } from './health.js'
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -437,20 +438,38 @@ export function buildViewData(events, model, stances, now = Date.now()) {
|
|
|
437
438
|
return view
|
|
438
439
|
}
|
|
439
440
|
|
|
441
|
+
/**
|
|
442
|
+
* 嵌进 <script> 里的一段 JSON(2026-11-27):
|
|
443
|
+
* JSON.stringify 不会转义 `<`,她的发言里只要出现一个 `</script>`,这段数据就把
|
|
444
|
+
* <script> 提前关掉,后面的字直接变成 HTML/JS 执行——那是从「别人写的评论」
|
|
445
|
+
* 到她记忆页的一条注入路径。所以这里把 < > & 与行分隔符都写成 \u 形式:
|
|
446
|
+
* 解析出来完全一样,但字符串里不再有任何能闭合标签的字符。
|
|
447
|
+
* @param {any} v
|
|
448
|
+
*/
|
|
449
|
+
export function scriptJson(v) {
|
|
450
|
+
return JSON.stringify(v)
|
|
451
|
+
.replace(/</g, '\\u003c')
|
|
452
|
+
.replace(/>/g, '\\u003e')
|
|
453
|
+
.replace(/&/g, '\\u0026')
|
|
454
|
+
.replace(/\u2028/g, '\\u2028')
|
|
455
|
+
.replace(/\u2029/g, '\\u2029')
|
|
456
|
+
}
|
|
457
|
+
|
|
440
458
|
/**
|
|
441
459
|
* 拼出完整页面:模板(base64 内嵌)+ 实时数据(替换掉模板里那行 view.js 引用)。
|
|
442
460
|
* @param {string} root 插件数据家(~/.dsh-fish)
|
|
443
461
|
*/
|
|
444
462
|
export async function renderMemoryMapHtml(root) {
|
|
445
463
|
const { events } = await readEvents(root)
|
|
446
|
-
const
|
|
464
|
+
const { config } = await loadConfig(root).catch(() => ({ config: null }))
|
|
465
|
+
const model = deriveSelf(events, { growthDays: config?.growthDays ?? 30, owner: config?.owner })
|
|
447
466
|
const stances = buildStances(model)
|
|
448
467
|
const view = buildViewData(events, model, stances)
|
|
449
468
|
// 体检页要和图上用同一份 events,否则页面里的数字和图上的点对不上
|
|
450
469
|
const health = examine(events, { growthDays: 30 })
|
|
451
470
|
const html = Buffer.from(MEMORY_MAP_HTML_B64, 'base64').toString('utf8')
|
|
452
471
|
const data =
|
|
453
|
-
'<script>window.__VIEW__=' +
|
|
454
|
-
';window.__HEALTH__=' +
|
|
472
|
+
'<script>window.__VIEW__=' + scriptJson(view) +
|
|
473
|
+
';window.__HEALTH__=' + scriptJson(health) + ';</script>'
|
|
455
474
|
return html.replace('<script src="view.js"></script>', data)
|
|
456
475
|
}
|
package/lib/notice.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// 一次性提示(2026-11-29,用户 m04096 / m04349)。
|
|
2
|
+
//
|
|
3
|
+
// 只放「升级之后第一次打开才该看见一次」的话:不是设置项,也不是她读的东西。
|
|
4
|
+
// 已读标记单独落在 notice-seen.json,不进事件流、不进 state.json——那两份都有各自的
|
|
5
|
+
// 语义(事件是她的账,state 是她的状态),一条给用户看的提示不该混进去。
|
|
6
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
|
|
9
|
+
const NOTICES = [
|
|
10
|
+
{
|
|
11
|
+
id: 'bridge-dirs-1.1.4',
|
|
12
|
+
title: '注意:桥接插件可能兼容失效',
|
|
13
|
+
body: [
|
|
14
|
+
'最近几个版本的更新,调整了按会话 ID 认大肥鱼的机制,有部分桥接插件可能会兼容失效。如果失效,可能出现的情况包括不加说话次数、没记判断,影响成长等等。',
|
|
15
|
+
'请检查一下你的桥接插件是否有问题。已提供兼容接口,具体在「插件」页:对于起独立端口的桥接插件,给了一个自定义端口功能;对于起独立会话目录的桥接插件,给了一个自定义对话目录的功能。设置一次并重启即可生效。',
|
|
16
|
+
'谢谢!如果有问题也可以联系作者。',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
/** 当前这版要提示的全部条目(给测试与路由用)。 */
|
|
22
|
+
export function currentNotices() {
|
|
23
|
+
return NOTICES.map((n) => ({ id: n.id, title: n.title, body: [...n.body] }))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function seenFile(root) {
|
|
27
|
+
return join(root, 'notice-seen.json')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function readSeen(root) {
|
|
31
|
+
try {
|
|
32
|
+
const parsed = JSON.parse(readFileSync(seenFile(root), 'utf8'))
|
|
33
|
+
const seen = parsed?.seen
|
|
34
|
+
return seen && typeof seen === 'object' && !Array.isArray(seen) ? seen : {}
|
|
35
|
+
} catch {
|
|
36
|
+
// 读不出来就当没提示过:宁可再提示一次,也不要让一条提示永远不出现。
|
|
37
|
+
return {}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 还没点过「知道了」的条目。 */
|
|
42
|
+
export function listNotices(root) {
|
|
43
|
+
const seen = readSeen(root)
|
|
44
|
+
return NOTICES.filter((n) => !seen[n.id]).map((n) => ({ id: n.id, title: n.title, body: [...n.body] }))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 点过「知道了」:记下 id,返回剩下的条目。
|
|
49
|
+
* 不认识的 id 原样返回——前端传错不该把提示全清掉。
|
|
50
|
+
*/
|
|
51
|
+
export function dismissNotice(root, id) {
|
|
52
|
+
const want = String(id ?? '')
|
|
53
|
+
if (!NOTICES.some((n) => n.id === want)) return listNotices(root)
|
|
54
|
+
const seen = { ...readSeen(root), [want]: new Date().toISOString() }
|
|
55
|
+
mkdirSync(root, { recursive: true })
|
|
56
|
+
const tmp = `${seenFile(root)}.tmp`
|
|
57
|
+
writeFileSync(tmp, JSON.stringify({ version: 1, seen }, null, 2))
|
|
58
|
+
renameSync(tmp, seenFile(root))
|
|
59
|
+
return listNotices(root)
|
|
60
|
+
}
|
package/lib/observe-bili.js
CHANGED
|
@@ -192,7 +192,7 @@ export function buildBiliRoutes(env) {
|
|
|
192
192
|
const { events } = await readEvents(root)
|
|
193
193
|
const { config } = await loadConfig(root)
|
|
194
194
|
const dk = dateKey()
|
|
195
|
-
const model = deriveSelf(events, { growthDays: config?.growthDays })
|
|
195
|
+
const model = deriveSelf(events, { growthDays: config?.growthDays, owner: config?.owner })
|
|
196
196
|
const r = /** @type {any} */ (await quietBrowse(root, model, config, dk, { events, force: true }, (/** @type {string} */ k, /** @type {unknown} */ m) => logLine('info', [k, String(m ?? '')], root)))
|
|
197
197
|
const picks = r.picks ?? []
|
|
198
198
|
return send(res, r.ok ? 200 : 409, {
|
package/lib/observe-home.js
CHANGED
|
@@ -20,10 +20,11 @@ import { wakeNow } from './scheduler.js'
|
|
|
20
20
|
import { sayToHer } from './say.js'
|
|
21
21
|
import { readInbox, markRead, writeInboxFile } from './inbox.js'
|
|
22
22
|
import { avatarFile, avatarInfo, saveAvatar, removeAvatar } from './avatar.js'
|
|
23
|
-
import { describeState
|
|
23
|
+
import { describeState } from './reset.js'
|
|
24
|
+
import { armPending, attemptPending, cancelPending, clearPending, pendingSummary } from './reset-pending.js'
|
|
24
25
|
import { applyHandover, hasOwnStart, IMPORT_TEMPLATE } from './import.js'
|
|
25
26
|
import { bridgeUrl } from './bridgeserve.js'
|
|
26
|
-
import { readHomeRecord
|
|
27
|
+
import { readHomeRecord } from './retire.js'
|
|
27
28
|
import { bootstrapHome, homeStatus, wakeIfBlank, rotateTalkSession } from './home.js'
|
|
28
29
|
import { selfDocStatus, refreshSelfDoc } from './selfdoc.js'
|
|
29
30
|
import { ensureDataReadme } from './readme.js'
|
|
@@ -289,7 +290,7 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
289
290
|
const { events } = await readEvents(root).catch(() => ({ events: [] }))
|
|
290
291
|
const blocked = hasOwnStart(events)
|
|
291
292
|
const { config } = await loadConfig(root).catch(() => ({ config: null }))
|
|
292
|
-
const model = deriveSelf(events, { growthDays: config?.growthDays })
|
|
293
|
+
const model = deriveSelf(events, { growthDays: config?.growthDays, owner: config?.owner })
|
|
293
294
|
return send(res, 200, {
|
|
294
295
|
canImport: !blocked,
|
|
295
296
|
reason: blocked ? '她已经有自己的起点了。想换成别人养的那一位,先重置成新的一局。' : '',
|
|
@@ -328,7 +329,7 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
328
329
|
['/reset', async (req, res) => {
|
|
329
330
|
if (req.method === 'GET') {
|
|
330
331
|
const info = await describeState(root)
|
|
331
|
-
return send(res, 200, { ...info, root })
|
|
332
|
+
return send(res, 200, { ...info, root, pending: pendingSummary(root) })
|
|
332
333
|
}
|
|
333
334
|
if (req.method !== 'POST') return send(res, 405, { error: 'method not allowed' })
|
|
334
335
|
const body = await readBody(req)
|
|
@@ -336,12 +337,36 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
336
337
|
let b = {}
|
|
337
338
|
try { b = JSON.parse(body || '{}') } catch { return send(res, 400, { error: 'body 不是合法 JSON' }) }
|
|
338
339
|
if (b.confirm !== 'reset') return send(res, 400, { error: '要带 confirm:"reset"' })
|
|
340
|
+
// 2026-11-28(外部报告):先写意向书,再当场试搬。
|
|
341
|
+
// 为什么要先写:运行中插件的日志 / 压力缓存 / 心跳(instance.json)/ 自动备份
|
|
342
|
+
// 都可能正开着 root 里的文件,Windows 上父目录 rename 会 EPERM。意向书存在
|
|
343
|
+
// root 之外,搬不成也留着,下次 boot() 第一行兑现(那一刻没有写入者)。
|
|
344
|
+
// 旧会话的登记(home.json)就在 root 里,搬走之后读不到了一并记进意向书。
|
|
339
345
|
const home = await readHomeRecord(root)
|
|
340
|
-
const
|
|
341
|
-
|
|
346
|
+
const before = await describeState(root)
|
|
347
|
+
armPending({ root, expect: before, retire: home })
|
|
348
|
+
const r = /** @type {any} */ (await awayFromBeat(() => attemptPending({
|
|
349
|
+
root,
|
|
350
|
+
ctx,
|
|
351
|
+
log: flog('info'),
|
|
352
|
+
})))
|
|
353
|
+
if (!r.ok) {
|
|
354
|
+
// 失败三处都要留痕:日志(原来这里只 send,日志里一个字都没有)、
|
|
355
|
+
// 意向书(下次启动继续)、回执(界面把它显示在卡片里,不是页顶)。
|
|
356
|
+
flog('warn')(`重开没搬成(${r.code || '?'}):${r.why || ''};已排到下次启动,root=${root}`)
|
|
357
|
+
return send(res, 200, {
|
|
358
|
+
ok: false,
|
|
359
|
+
pending: true,
|
|
360
|
+
code: r.code || '',
|
|
361
|
+
error: r.why || '没搬成',
|
|
362
|
+
note: `这一刻有文件正被读写,没搬成${r.code ? `(${r.code})` : ''}。已经排好:下次启动 DSH 时会先搬。想现在生效,就完全退出 DSH 再打开。`,
|
|
363
|
+
pendingInfo: pendingSummary(root),
|
|
364
|
+
})
|
|
365
|
+
}
|
|
342
366
|
try { await fs.promises.mkdir(root, { recursive: true }) } catch { /* ignore */ }
|
|
343
367
|
await reclaimTenant()
|
|
344
|
-
|
|
368
|
+
// 旧会话已经由 attemptPending 归档(它拿的是意向书里的快照);这里不再重复调。
|
|
369
|
+
const retired = /** @type {any} */ (r.retired ?? { ok: true, archived: [], failed: [], why: '' })
|
|
345
370
|
const { config: cfg } = await loadConfig(root)
|
|
346
371
|
const fresh = /** @type {any} */ (await bootstrapHome(ctx, /** @type {any} */ ({
|
|
347
372
|
root,
|
|
@@ -352,6 +377,8 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
352
377
|
const woke = fresh.ok
|
|
353
378
|
? await wakeIfBlank(ctx, /** @type {any} */ ({ sessionId: fresh.sessionId, root, log: flog('info'), freshOnly: !fresh.reused, verify: true }))
|
|
354
379
|
: { woke: false }
|
|
380
|
+
// 搬完了:意向书收掉(boot 看到 done 也会收,这里收得更早一点)。
|
|
381
|
+
clearPending()
|
|
355
382
|
send(res, 200, {
|
|
356
383
|
ok: true,
|
|
357
384
|
movedTo: r.movedTo,
|
|
@@ -367,6 +394,24 @@ export function buildHomeRoutes(env, bridgeHandlers) {
|
|
|
367
394
|
})
|
|
368
395
|
}],
|
|
369
396
|
|
|
397
|
+
['/reset/cancel', async (req, res) => {
|
|
398
|
+
if (req.method !== 'POST') return send(res, 405, { error: 'method not allowed' })
|
|
399
|
+
const body = await readBody(req)
|
|
400
|
+
/** @type {Record<string, any>} */
|
|
401
|
+
let b = {}
|
|
402
|
+
try { b = JSON.parse(body || '{}') } catch { return send(res, 400, { error: 'body 不是合法 JSON' }) }
|
|
403
|
+
if (b.confirm !== 'reset') return send(res, 400, { error: '要带 confirm:"reset"' })
|
|
404
|
+
const out = cancelPending({ root })
|
|
405
|
+
if (!out.ok) return send(res, 409, { ok: false, error: out.why || '没取消成' })
|
|
406
|
+
flog('info')(`重开意向撤销(removed=${out.removed})`)
|
|
407
|
+
send(res, 200, {
|
|
408
|
+
ok: true,
|
|
409
|
+
removed: out.removed === true,
|
|
410
|
+
pending: pendingSummary(root),
|
|
411
|
+
note: out.removed ? '已取消,什么都没动。' : '没有排着的重开。',
|
|
412
|
+
})
|
|
413
|
+
}],
|
|
414
|
+
|
|
370
415
|
['/home/rebuild', async (req, res) => {
|
|
371
416
|
if (req.method !== 'POST') return send(res, 405, { error: 'method not allowed' })
|
|
372
417
|
const body = await readBody(req)
|
package/lib/observe-http.js
CHANGED
|
@@ -180,13 +180,25 @@ function rejectionMessage(rejection) {
|
|
|
180
180
|
return s || 'forbidden'
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* 路由慢过这个毫秒数就留一行日志(2026-11-29,issue #184)。
|
|
185
|
+
*
|
|
186
|
+
* 为什么要有它:`slowDeriveNote` 只挂在写身份文档那一处,设置页首屏那几条路由
|
|
187
|
+
* 跑 600ms 一个字都不会留——外部用户报「越用越慢」时,日志里只有五条来自
|
|
188
|
+
* 另一条路径的记录,真实的首屏成本完全看不见。闸门放在 `makeGuarded` 里,
|
|
189
|
+
* 一处就能覆盖全部路由,不必改几十个 handler。
|
|
190
|
+
*/
|
|
191
|
+
export const SLOW_ROUTE_MS = 1000
|
|
192
|
+
|
|
183
193
|
/**
|
|
184
194
|
* 信任栅栏:失败即拒绝(拿不到 connection 服务就 503,不放行)。
|
|
185
195
|
*
|
|
186
196
|
* @param {import('./types.js').HostContext} ctx
|
|
187
197
|
* @param {string} root
|
|
198
|
+
* @param {{ slowMs?: number }} [opts] 慢日志阈值,只有测试会改(默认 SLOW_ROUTE_MS)
|
|
188
199
|
*/
|
|
189
|
-
export function makeGuarded(ctx, root) {
|
|
200
|
+
export function makeGuarded(ctx, root, opts = {}) {
|
|
201
|
+
const slowMs = Number.isFinite(Number(opts.slowMs)) ? Number(opts.slowMs) : SLOW_ROUTE_MS
|
|
190
202
|
/**
|
|
191
203
|
* @param {(req: import('./types.js').HttpRequest, res: import('./types.js').HttpResponse) => Promise<any> | any} handler
|
|
192
204
|
*/
|
|
@@ -209,6 +221,8 @@ export function makeGuarded(ctx, root) {
|
|
|
209
221
|
], root)
|
|
210
222
|
return send(res, 503, { error: 'trust check failed' })
|
|
211
223
|
}
|
|
224
|
+
// 只量 handler 自己:信任校验是被挡掉的请求,和「这一页慢」是两件事。
|
|
225
|
+
const t0 = Date.now()
|
|
212
226
|
try {
|
|
213
227
|
await handler(req, res)
|
|
214
228
|
} catch (err) {
|
|
@@ -220,6 +234,11 @@ export function makeGuarded(ctx, root) {
|
|
|
220
234
|
String(/** @type {any} */ (err)?.message ?? err).slice(0, 200),
|
|
221
235
|
], root)
|
|
222
236
|
send(res, code, { error: String(/** @type {any} */ (err)?.message ?? err) })
|
|
237
|
+
} finally {
|
|
238
|
+
const ms = Date.now() - t0
|
|
239
|
+
if (ms >= slowMs) {
|
|
240
|
+
logLine('warn', ['route slow', `${req?.method ?? ''} ${req?.url ?? ''}`.trim(), { ms }], root)
|
|
241
|
+
}
|
|
223
242
|
}
|
|
224
243
|
}
|
|
225
244
|
}
|
package/lib/observe-state.js
CHANGED
|
@@ -26,6 +26,8 @@ import { selfDocStatus } from './selfdoc.js'
|
|
|
26
26
|
import { personaBudget, BELIEF_SHOWN, shownCount, keepCount } from './persona.js'
|
|
27
27
|
import { buildStances, gatesDone, stanceSummary } from './stance.js'
|
|
28
28
|
import { ruleById } from './rules.js'
|
|
29
|
+
import { listUnclaimed } from './unclaimed.js'
|
|
30
|
+
import { dismissNotice, listNotices } from './notice.js'
|
|
29
31
|
import { ruleStatus, pendingOffer, offerLimits, activeGrants } from './unlock.js'
|
|
30
32
|
import { deriveStatus } from './status.js'
|
|
31
33
|
import { normalizeVersion } from './update.js'
|
|
@@ -51,6 +53,21 @@ export function buildStateRoutes(env) {
|
|
|
51
53
|
const { root, deps, pressure, openFolder } = env
|
|
52
54
|
|
|
53
55
|
return [
|
|
56
|
+
// 1.1.4(用户 m04091):没被认领的会话,设置页拿来做提醒。
|
|
57
|
+
['/unclaimed', async (req, res) => {
|
|
58
|
+
if (req.method !== 'GET') return send(res, 405, { ok: false })
|
|
59
|
+
return send(res, 200, { ok: true, list: listUnclaimed(root) })
|
|
60
|
+
}],
|
|
61
|
+
// 1.1.4(用户 m04349):升级后第一次打开插件页看一次,点「知道了」不再出现。
|
|
62
|
+
['/notices', async (req, res) => {
|
|
63
|
+
if (req.method === 'POST') {
|
|
64
|
+
let body
|
|
65
|
+
try { body = JSON.parse(await readBody(req)) } catch { return send(res, 400, { ok: false }) }
|
|
66
|
+
return send(res, 200, { ok: true, list: dismissNotice(root, body?.id) })
|
|
67
|
+
}
|
|
68
|
+
if (req.method !== 'GET') return send(res, 405, { ok: false })
|
|
69
|
+
return send(res, 200, { ok: true, list: listNotices(root) })
|
|
70
|
+
}],
|
|
54
71
|
['/session-pressure', async (req, res) => {
|
|
55
72
|
if (req.method === 'POST') {
|
|
56
73
|
let body
|
|
@@ -88,7 +105,7 @@ export function buildStateRoutes(env) {
|
|
|
88
105
|
['/state', async (_req, res) => {
|
|
89
106
|
const { events, skipped } = await readEvents(root)
|
|
90
107
|
const { config, fresh, broken } = await loadConfig(root)
|
|
91
|
-
const m = deriveSelf(events, { growthDays: config.growthDays })
|
|
108
|
+
const m = deriveSelf(events, { growthDays: config.growthDays, owner: config.owner })
|
|
92
109
|
const need = gateNeed(m.growthDays)
|
|
93
110
|
/** @type {import('./types.js').ObserveStatePayload} */
|
|
94
111
|
const payload = {
|
|
@@ -237,7 +254,7 @@ export function buildStateRoutes(env) {
|
|
|
237
254
|
['/beliefs', async (_req, res) => {
|
|
238
255
|
const { events } = await readEvents(root)
|
|
239
256
|
const { config } = await loadConfig(root)
|
|
240
|
-
const m = deriveSelf(events, { growthDays: config.growthDays })
|
|
257
|
+
const m = deriveSelf(events, { growthDays: config.growthDays, owner: config.owner })
|
|
241
258
|
send(res, 200, {
|
|
242
259
|
active: m.beliefs.map((b) => ({ id: b.id, text: b.text, since: b.since, confidence: b.confidence })),
|
|
243
260
|
refuted: m.refuted,
|
|
@@ -317,7 +334,7 @@ export function buildStateRoutes(env) {
|
|
|
317
334
|
['/memory', async (_req, res) => {
|
|
318
335
|
const { config } = await loadConfig(root)
|
|
319
336
|
const { events } = await readEvents(root)
|
|
320
|
-
const model = deriveSelf(events, { growthDays: config.growthDays })
|
|
337
|
+
const model = deriveSelf(events, { growthDays: config.growthDays, owner: config.owner })
|
|
321
338
|
const doc = await selfDocStatus(root)
|
|
322
339
|
const h = await homeStatus(root)
|
|
323
340
|
const budget = Number(config?.memory?.docBudget ?? 3600)
|
|
@@ -435,3 +452,5 @@ export function buildStateRoutes(env) {
|
|
|
435
452
|
}],
|
|
436
453
|
]
|
|
437
454
|
}
|
|
455
|
+
|
|
456
|
+
|
package/lib/observe-trip.js
CHANGED
|
@@ -53,7 +53,7 @@ export async function appendIdMarks(root, prefix, ids) {
|
|
|
53
53
|
try {
|
|
54
54
|
const { events } = await readEvents(root)
|
|
55
55
|
const { config } = await loadConfig(root)
|
|
56
|
-
const m = deriveSelf(events, { growthDays: config.growthDays })
|
|
56
|
+
const m = deriveSelf(events, { growthDays: config.growthDays, owner: config.owner })
|
|
57
57
|
/** @type {import('./types.js').ValidateContext} */
|
|
58
58
|
const ectx = { day: m.day, stage: m.stage, source: 'system' }
|
|
59
59
|
for (const text of lines) {
|