@ssamurias/dsh-fish 1.0.2 → 1.0.3
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 +2 -2
- package/CHANGELOG.md +39 -0
- package/README.md +51 -10
- package/RELEASE-NOTES-1.0.3.md +91 -0
- package/lib/autobackup.js +12 -1
- package/lib/backup.js +83 -6
- package/lib/bili.js +4 -2
- package/lib/client.js +161 -28
- package/lib/desk.js +19 -1
- package/lib/doing.js +1 -1
- package/lib/drive.js +6 -2
- package/lib/index.js +7 -1
- package/lib/make.js +214 -0
- package/lib/observe.js +59 -2
- package/lib/persona.js +38 -0
- package/lib/proactive.js +12 -1
- package/lib/restrict.js +2 -0
- package/lib/scheduler.js +11 -2
- package/lib/selfdoc.js +12 -3
- package/lib/settings.js +4 -0
- package/lib/video.js +75 -42
- package/lib/works.js +526 -0
- package/package.json +1 -1
package/lib/observe.js
CHANGED
|
@@ -27,6 +27,8 @@ import { wakeNow, quietBrowse } from './scheduler.js'
|
|
|
27
27
|
import { sayToHer } from './say.js'
|
|
28
28
|
import { readInbox, markRead, writeInboxFile } from './inbox.js'
|
|
29
29
|
import { listReports, buildReport } from './report.js'
|
|
30
|
+
// 她留下的东西(1.0.4,2026-11-16):只读列表 + 读回某一版(读了不留痕、不写事件)。
|
|
31
|
+
import { listWorks, worksSummary, readWorkText, worksDir, WORK_LIST_MAX } from './works.js'
|
|
30
32
|
import { itemsFromEvents, browseCountToday, parseBrowseLine } from './browse.js'
|
|
31
33
|
import { seenOn } from './whatseen.js'
|
|
32
34
|
import { readAway } from './away.js'
|
|
@@ -82,7 +84,7 @@ import { writeTurnExport } from './turnexport.js'
|
|
|
82
84
|
// 立场清单(2026-10-25,用户设计「纵向·立场」):四道门走完之后长出来的那张清单。
|
|
83
85
|
import { buildStances, gatesDone, stanceSummary } from './stance.js'
|
|
84
86
|
import { looksMojibake } from './guard.js'
|
|
85
|
-
import { join } from 'node:path'
|
|
87
|
+
import { join, resolve, sep } from 'node:path'
|
|
86
88
|
import { homedir } from 'node:os'
|
|
87
89
|
import { fileURLToPath } from 'node:url'
|
|
88
90
|
import { ensureDataReadme } from './readme.js'
|
|
@@ -678,6 +680,59 @@ export function registerObserve(ctx, deps = {}) {
|
|
|
678
680
|
send(res, 200, { enabled: true, visible: true, dates, items })
|
|
679
681
|
}],
|
|
680
682
|
|
|
683
|
+
// 她留下的东西(1.0.4,2026-11-16)。两条路:
|
|
684
|
+
// GET /works 列表 + 概况(第一件 / 最近一件)
|
|
685
|
+
// POST /works {id,version} 读某一版正文
|
|
686
|
+
// 「看」这件事刻意不留痕:账里不记、她没有已读回执、桌上不会因此摆出「他看过了」。
|
|
687
|
+
// 看见了就会有回应,回应就成了交差——留下的东西不该变成交出去的东西。
|
|
688
|
+
['/works', async (req, res) => {
|
|
689
|
+
if (!req.method || req.method === 'GET') {
|
|
690
|
+
const url = new URL(req.url, 'http://x')
|
|
691
|
+
const want = Number(url.searchParams.get('limit') ?? 0)
|
|
692
|
+
const limit = Number.isSafeInteger(want) && want > 0 ? Math.min(want, WORK_LIST_MAX) : WORK_LIST_MAX
|
|
693
|
+
const [items, summary] = await Promise.all([listWorks(root, { limit }), worksSummary(root)])
|
|
694
|
+
return send(res, 200, { items, summary })
|
|
695
|
+
}
|
|
696
|
+
if (req.method === 'POST') {
|
|
697
|
+
let body = {}
|
|
698
|
+
try { body = JSON.parse((await readBody(req, 20_000)) || '{}') } catch { return send(res, 400, { error: 'body 不是合法 JSON' }) }
|
|
699
|
+
const id = typeof body.id === 'string' ? body.id : ''
|
|
700
|
+
const title = typeof body.title === 'string' ? body.title : ''
|
|
701
|
+
const version = Number(body.version) || 0
|
|
702
|
+
const got = await readWorkText(root, { id, title, version })
|
|
703
|
+
if (!got.ok) return send(res, 404, { error: got.note || '翻不到这件东西' })
|
|
704
|
+
return send(res, 200, { ok: true, id: got.id, title: got.title, state: got.state, version: got.version, versions: got.versions, kind: got.kind || 'text', file: got.file || '', text: got.text })
|
|
705
|
+
}
|
|
706
|
+
return send(res, 405, { error: '只认 GET 与 POST' })
|
|
707
|
+
}],
|
|
708
|
+
|
|
709
|
+
// 作品里的图 / 声音 / 影像(1.0.5,2026-11-16)。只读,只认 works/ 目录下的文件。
|
|
710
|
+
// 路径由台账给(相对 root):这里再挡一次穿越,不是 works/ 下面的就不给。
|
|
711
|
+
['/work-file', async (req, res) => {
|
|
712
|
+
if (req.method && req.method !== 'GET') return send(res, 405, { error: '只认 GET' })
|
|
713
|
+
const url = new URL(req.url, 'http://x')
|
|
714
|
+
const want = String(url.searchParams.get('p') || '')
|
|
715
|
+
const base = resolve(worksDir(root))
|
|
716
|
+
const file = resolve(root, want)
|
|
717
|
+
if (!want || !(file === base || file.startsWith(base + sep))) return send(res, 404, { error: '没有这个文件' })
|
|
718
|
+
let buf
|
|
719
|
+
try { buf = fs.readFileSync(file) } catch { return send(res, 404, { error: '没有这个文件' }) }
|
|
720
|
+
const ext = String(file.split('.').pop() || '').toLowerCase()
|
|
721
|
+
const CT = {
|
|
722
|
+
png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif',
|
|
723
|
+
avif: 'image/avif', bmp: 'image/bmp', svg: 'image/svg+xml',
|
|
724
|
+
mp3: 'audio/mpeg', wav: 'audio/wav', m4a: 'audio/mp4', ogg: 'audio/ogg', flac: 'audio/flac',
|
|
725
|
+
mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime',
|
|
726
|
+
txt: 'text/plain; charset=utf-8', md: 'text/plain; charset=utf-8',
|
|
727
|
+
}
|
|
728
|
+
res.writeHead(200, {
|
|
729
|
+
'content-type': CT[ext] || 'application/octet-stream',
|
|
730
|
+
'content-length': buf.length,
|
|
731
|
+
'cache-control': 'private, max-age=86400',
|
|
732
|
+
})
|
|
733
|
+
res.end(buf)
|
|
734
|
+
}],
|
|
735
|
+
|
|
681
736
|
['/config', async (req, res) => {
|
|
682
737
|
if (req.method === 'GET') {
|
|
683
738
|
const { config } = await loadConfig(root)
|
|
@@ -1809,7 +1864,9 @@ export function registerObserve(ctx, deps = {}) {
|
|
|
1809
1864
|
['/backup', async (req, res) => {
|
|
1810
1865
|
if (req.method !== 'GET') return send(res, 405, { error: 'method not allowed' })
|
|
1811
1866
|
// 恢复上限也交给打包那一步:事件流(连同包的外壳)装得下时,别的文件挑着放,整份包都装得下。
|
|
1812
|
-
|
|
1867
|
+
// 手动这一份是用户当场按下、旁边写着后果的一次性动作(要能把登录一起带走),
|
|
1868
|
+
// 所以显式带凭据;自动备份与云端那份不吃这个口径,由 backup.withSecrets 管(用户 m00712)。
|
|
1869
|
+
const b = await collectBackup(root, { restoreLimit, withSecrets: true })
|
|
1813
1870
|
// fileName 给浏览器当下载名;它在 checkBundle 里是多余字段,恢复时会被忽略。
|
|
1814
1871
|
const out = { ...b, fileName: backupFileName(), restoreLimit }
|
|
1815
1872
|
// 事件流不设上限(issue #65),包就可能比恢复接口收得下的大。设置页存文件、
|
package/lib/persona.js
CHANGED
|
@@ -410,6 +410,15 @@ export function buildSections(model, opts = {}) {
|
|
|
410
410
|
// 「到点只提一次」,每轮都摆挂着的便条/约定等于催办。要查就走 her_recall。
|
|
411
411
|
const closedRecently = String(cont.closedRecently ?? '').trim()
|
|
412
412
|
if (closedRecently) days.push(closedRecently)
|
|
413
|
+
// 手上那件没弄完的(1.0.5,用户 m01433)。只写一句事实:不写第几版、不催、
|
|
414
|
+
// 不说「你该把它弄完」。没有没弄完的东西时这一句不出现——早期阶段她本来就
|
|
415
|
+
// 可能一件都没有,那是正常状态,不是缺一项。
|
|
416
|
+
const wipWork = opts.works?.wip
|
|
417
|
+
if (wipWork?.title) {
|
|
418
|
+
days.push(wipWork.stale
|
|
419
|
+
? `你手上还有一件《${wipWork.title}》,有些天没动了。`
|
|
420
|
+
: `你上次弄的是《${wipWork.title}》,还没弄完。`)
|
|
421
|
+
}
|
|
413
422
|
if (days.length) push(['## 这些天', ...days].join('\n'), true)
|
|
414
423
|
|
|
415
424
|
if (opts.withBans !== false) {
|
|
@@ -760,6 +769,35 @@ export const APPOINT_BRIEF = [
|
|
|
760
769
|
'到那天你醒来会先想起它;做到了划掉,不做了就取消并说一句为什么。',
|
|
761
770
|
].join('\n')
|
|
762
771
|
|
|
772
|
+
/**
|
|
773
|
+
* 自己东西的说明书(1.0.4,2026-11-16,用户 m00002 / m00130)。
|
|
774
|
+
*
|
|
775
|
+
* 为什么单独一段:它是唯一一个**留下东西**的工具。别的工具都是"这一刻说一句 /
|
|
776
|
+
* 记一句 / 问一句",只有它会在家里留一样能回头改、能没做完的东西。
|
|
777
|
+
*
|
|
778
|
+
* 三件写死的事:
|
|
779
|
+
* 1. 什么时候想起它——是她自己觉得值得留下的那一下,不是"每天都该做一件"。
|
|
780
|
+
* 写成后者就成了创作 KPI,她会为了打卡去编(用户 m01296 的原话:
|
|
781
|
+
* 「只说了会做,没说用哪个工具做,就一次也没试过」——所以要给名字和入口,
|
|
782
|
+
* 但不能给频率)。
|
|
783
|
+
* 2. 只留在家里。{T}想看会自己去看;不发出去、不计分。发出去是另一件事,
|
|
784
|
+
* 得{T}自己点头,这里不提那条路。
|
|
785
|
+
* 3. 改一版要先读回来(her_work)。只凭记忆重写一遍,第二版接不上第一版,
|
|
786
|
+
* 那就不叫改。
|
|
787
|
+
*
|
|
788
|
+
* 参数(action 的枚举、refs 怎么填)留在 schema 里,不复述。
|
|
789
|
+
*
|
|
790
|
+
* 2026-11-16 补一条(用户 m00850):**不能把她带成干活的**。有些人不打算让她
|
|
791
|
+
* 跑代码、做方案、写 PPT;留下的东西一旦像交付物,就会长出「我没让她干活,
|
|
792
|
+
* 她怎么自己干起来了」的错觉。所以这一段写明:给自己、不接活、不报进度。
|
|
793
|
+
*/
|
|
794
|
+
export const MAKE_BRIEF = [
|
|
795
|
+
'你还有一个工具 her_make:做出来的东西可以留在家里。写的、画的、剪的、做出来的,都算——你手边有什么工具,就用它做;做出来的是个文件,就把路径一起交给 her_make。',
|
|
796
|
+
'什么时候想起它——你自己觉得值得留下的那一下:看到什么、听到什么,想跟着弄一个;或者手上这个还想再改。没觉得就不留;不用每天留一件,也不是替谁做。',
|
|
797
|
+
'这是给你自己的,不是交出去的活:不接活、不报进度、不算成绩。留下来只放在家里,不发出去、不计分;{T}想看会自己去看,你不用问{T}看过没有。',
|
|
798
|
+
'想改一版,先用 her_work 把上一版读回来,接得上才算第二版;名字写原来那个,别加「第二版」——换名字会另起一件。',
|
|
799
|
+
].join('\n')
|
|
800
|
+
|
|
763
801
|
/**
|
|
764
802
|
* 请求事件的说明书(0.7.6,用户 m01274 / m01292)。
|
|
765
803
|
*
|
package/lib/proactive.js
CHANGED
|
@@ -352,7 +352,7 @@ export function looseEnds(events = [], { now = Date.now(), has = null } = {}) {
|
|
|
352
352
|
* 空手回合的处境正文(走 system prompt 段,不进对话)。
|
|
353
353
|
* 只写事实与许可,不写"你应该"。
|
|
354
354
|
*/
|
|
355
|
-
export function proactiveSection({ now = Date.now(), state = {}, material = [], loose = [], sendTools = [], countSeen = false, doing = false, tools = [], notes = [] } = {}) {
|
|
355
|
+
export function proactiveSection({ now = Date.now(), state = {}, material = [], loose = [], sendTools = [], countSeen = false, doing = false, tools = [], notes = [], works = null } = {}) {
|
|
356
356
|
const at = new Date(now)
|
|
357
357
|
const hh = String(at.getHours()).padStart(2, '0')
|
|
358
358
|
const mm = String(at.getMinutes()).padStart(2, '0')
|
|
@@ -374,6 +374,17 @@ export function proactiveSection({ now = Date.now(), state = {}, material = [],
|
|
|
374
374
|
lines.push('还有几件事悬着:')
|
|
375
375
|
for (const l of loose) lines.push(`- [${l.id}] ${l.text}`)
|
|
376
376
|
}
|
|
377
|
+
// 2026-11-16(用户 m01433):她手上那件自己弄了一半的东西。动手回合里不给这一句,
|
|
378
|
+
// 她就接不上「上次那个」——预演里没有这一句时她只写了一句感想,加了就去改第二版了。
|
|
379
|
+
// 只摆事实:不写第几版、不催、不说该做完了。
|
|
380
|
+
const wipTitle = String(works?.wip?.title ?? '').trim()
|
|
381
|
+
if (wipTitle) {
|
|
382
|
+
lines.push(
|
|
383
|
+
works?.wip?.stale
|
|
384
|
+
? `你手上还有一件《${wipTitle}》,有些天没动了。`
|
|
385
|
+
: `你手上还有一件《${wipTitle}》,是你自己弄了一半的。`,
|
|
386
|
+
)
|
|
387
|
+
}
|
|
377
388
|
// 2026-11-06(issue #41):原来写「他看得见」。宿主装了什么路由插件,这句就不一定成立
|
|
378
389
|
// (有的渠道会把会话里的字挡在外面)。改成只陈述能保证的部分:字会落进这条对话。
|
|
379
390
|
// 2026-11-06(PR #44):配了 sendTools 的部署更绝——正文根本发不出去,只有调那件工具才算开口。
|
package/lib/restrict.js
CHANGED
|
@@ -63,6 +63,8 @@ export const FISH_TOOLS = Object.freeze([
|
|
|
63
63
|
'her_leave', // 留一句话给他
|
|
64
64
|
'her_note', // 把没做的事记到桌上(issue #22 乙档,2026-11-04)
|
|
65
65
|
'her_appoint', // 跟他约一件几天后的事(通用预约簿,2026-11-08)
|
|
66
|
+
'her_make', // 把自己做成的东西留在家里(1.0.4,2026-11-16)
|
|
67
|
+
'her_work', // 把留下的某一版读回来,好接着改(1.0.4)
|
|
66
68
|
'bili_look', // 看 B 站的列表
|
|
67
69
|
'bili_watch', // 看一条视频的画面
|
|
68
70
|
'bili_sub', // 查一条视频的字幕片段(1.0,她想知道"里面说了哪几句")
|
package/lib/scheduler.js
CHANGED
|
@@ -47,6 +47,7 @@ import { readNotes, renderNotes, pickNudge, nudgeSeen, filterNotes } from './not
|
|
|
47
47
|
import { dueAppointment, appointPrompt, markNotified } from './appoint.js'
|
|
48
48
|
import { curiosityOf, renderEcho } from './curiosity.js'
|
|
49
49
|
import { deskFor } from './desk.js'
|
|
50
|
+
import { worksForDesk } from './works.js'
|
|
50
51
|
import { wishesOf } from './wish.js'
|
|
51
52
|
import { currentAllowTools, configuredAllowTools, visibleAllowTools } from './restrict.js'
|
|
52
53
|
import { gapwallsOf } from './gapwall.js'
|
|
@@ -463,7 +464,11 @@ export function startScheduler(ctx, deps = {}) {
|
|
|
463
464
|
// 够不着的那件事按家里那条会话的工具表算;那条还是冷的,就先拿白名单顶(issue #58,见 toolInHandNow)。
|
|
464
465
|
const homeSid = await homeStatus(root).then((h) => h.sessionId).catch(() => '')
|
|
465
466
|
const hasForDrive = toolInHandNow(homeSid, { unverified: true })
|
|
466
|
-
|
|
467
|
+
// 家里的东西(1.0.4,2026-11-16):桌上多半件事实——手上还摊着一件没弄完的。
|
|
468
|
+
// 只用来回答「有没有东西可说」,不新增冲动:弄自己的东西不攒劲儿,劲儿仍按开口算。
|
|
469
|
+
let workDesk = { wip: null }
|
|
470
|
+
try { workDesk = await worksForDesk(root, { now }) } catch { workDesk = { wip: null } }
|
|
471
|
+
const driveDesk = { gaps: gaps.length, stale: 0, echo: echoBack, favorite: interest.length > 0, wish: wishesOf(events, { now, has: hasForDrive }).length, wall: gapwallsOf(events, { now }).length, work: workDesk.wip ? 1 : 0 }
|
|
467
472
|
const pc = proactiveConfig(config)
|
|
468
473
|
// 动手回合(2026-11-14,用户 m01237):只是多一个「做一件」的出口,
|
|
469
474
|
// 不新增定时器、不占开口额度;开着时桌上什么都没有也可以起一轮。
|
|
@@ -550,7 +555,7 @@ export function startScheduler(ctx, deps = {}) {
|
|
|
550
555
|
ownNotes = filterNotes(await readNotes(root), 'open').slice(0, 2)
|
|
551
556
|
} catch { ownNotes = [] }
|
|
552
557
|
}
|
|
553
|
-
const text = proactiveSection({ now, state: st, material, loose, sendTools: pc.sendTools, countSeen: pc.idleCountsSeen, doing: doing.enabled, tools: inHand ? [...inHand] : [], notes: ownNotes })
|
|
558
|
+
const text = proactiveSection({ now, state: st, material, loose, sendTools: pc.sendTools, countSeen: pc.idleCountsSeen, doing: doing.enabled, tools: inHand ? [...inHand] : [], notes: ownNotes, works: workDesk })
|
|
554
559
|
gen = setWakeSection(text, sessionId)
|
|
555
560
|
|
|
556
561
|
// 投递之前先把这一轮盯起来(2026-11-05,用户 m00803)。认领信号是 rpcId:
|
|
@@ -1581,6 +1586,9 @@ async function wake(ctx, root, model, config, decision, dk, log, deps = {}) {
|
|
|
1581
1586
|
// 不另起一段——「一张桌子」是 L 文档定下的约定。
|
|
1582
1587
|
const favItem = interestOf(evc, now.getTime())[0]
|
|
1583
1588
|
const fav = favItem ? topicLabel(favItem.text) : ''
|
|
1589
|
+
// 家里的东西(1.0.4,2026-11-16):桌上一共多一行事实——
|
|
1590
|
+
// 手上那件还没弄完的。读失败就当没有,不拖垮这次唤醒。
|
|
1591
|
+
const works = await worksForDesk(root, { now: now.getTime() }).catch(() => ({ wip: null }))
|
|
1584
1592
|
const desk = deskFor({
|
|
1585
1593
|
gaps: curiosityOf(evc, now),
|
|
1586
1594
|
// 摆料那一轮 tableText 已经把旧句子摆出来了,桌子别再摆第二遍
|
|
@@ -1592,6 +1600,7 @@ async function wake(ctx, root, model, config, decision, dk, log, deps = {}) {
|
|
|
1592
1600
|
wishes: wishesOf(evc, { now: now.getTime(), has: toolInHandNow(sessionId, { agent: live.agent }) }),
|
|
1593
1601
|
// 撞过墙的那件事:她试过、手上没有的(用户 m00493 的 ②)。
|
|
1594
1602
|
walls: gapwallsOf(evc, { now: now.getTime() }),
|
|
1603
|
+
works,
|
|
1595
1604
|
at: now,
|
|
1596
1605
|
})
|
|
1597
1606
|
if (desk) parts.push('', desk)
|
package/lib/selfdoc.js
CHANGED
|
@@ -31,10 +31,11 @@ import { loadConfig, biliOn, dateKey } from './settings.js'
|
|
|
31
31
|
import { DEFAULT_PRONOUN, fillOwner, pronounOf } from './pronoun.js'
|
|
32
32
|
import { PRONOUN_ASK_BRIEF } from './pronounask.js'
|
|
33
33
|
import { deriveSelf, rememberGateStage } from './derive.js'
|
|
34
|
-
import { personaLine, toolBrief, RECALL_BRIEF, SPEAK_BRIEF, SPEAK_OFF_BRIEF, LETTER_BRIEF, NOTE_BRIEF, APPOINT_BRIEF, ASK_BRIEF, proactiveBrief, DREAM_BRIEF, scheduleBrief, SCHEDULE_NAMES, DIARY_BRIEF, SLEEP_BRIEF } from './persona.js'
|
|
34
|
+
import { personaLine, toolBrief, RECALL_BRIEF, SPEAK_BRIEF, SPEAK_OFF_BRIEF, LETTER_BRIEF, NOTE_BRIEF, MAKE_BRIEF, APPOINT_BRIEF, ASK_BRIEF, proactiveBrief, DREAM_BRIEF, scheduleBrief, SCHEDULE_NAMES, DIARY_BRIEF, SLEEP_BRIEF } from './persona.js'
|
|
35
35
|
import { resumeLines } from './use.js'
|
|
36
36
|
import { proactiveConfig } from './proactive.js'
|
|
37
37
|
import { LOOK_BRIEF, LOOK_OFF_BRIEF, WATCH_RULE } from './browse.js'
|
|
38
|
+
import { worksForDesk } from './works.js'
|
|
38
39
|
import { activeCarry } from './home.js'
|
|
39
40
|
import { activeGrants } from './unlock.js'
|
|
40
41
|
import { checkCaller } from './tenant.js'
|
|
@@ -330,7 +331,7 @@ export async function continuityOf(root = rootDir(), now = Date.now(), events) {
|
|
|
330
331
|
* @param {object} model deriveSelf 的结果
|
|
331
332
|
* @returns {string}
|
|
332
333
|
*/
|
|
333
|
-
export function renderSelfDoc(model, { sendTools = [], budget, continuity, browse = true, speak = false, grants = [], shown, sleepKeep, diary = true, sleepEveryDays = 0, bansMuted = false, extraTools = [], restricted = true, dream = false, schedule = [], proactive = false, resume = '', echo = true, anchor = false, pronoun = DEFAULT_PRONOUN } = {}) {
|
|
334
|
+
export function renderSelfDoc(model, { sendTools = [], budget, continuity, browse = true, speak = false, grants = [], shown, sleepKeep, diary = true, sleepEveryDays = 0, bansMuted = false, extraTools = [], restricted = true, dream = false, schedule = [], proactive = false, resume = '', echo = true, anchor = false, pronoun = DEFAULT_PRONOUN, works = null } = {}) {
|
|
334
335
|
// issue #64:schedule 传的是「白名单里真的放行的 schedule_*」。只放一个就只写一个,
|
|
335
336
|
// 不能告诉她有四个——另外三个会被守卫挡回「这件事我做不到」。
|
|
336
337
|
// 老调用方传 true/false 也认:true = 四个都有。
|
|
@@ -348,7 +349,7 @@ export function renderSelfDoc(model, { sendTools = [], budget, continuity, brows
|
|
|
348
349
|
// 用户的原话是「尊重别人的想法……直接忽略我们原本规定的你不能做某事」。
|
|
349
350
|
// 只关提示词侧(withBans),物理层那两条根本不在提示词里,仍由工具层拦着。
|
|
350
351
|
// sleepKeep 要一路传到 buildSections:漏传就等于不限制,设置页改了文档一个字都不变(issue #67)。
|
|
351
|
-
let identity = personaLine(model, { withBans: !bansMuted, budget, shown, sleepKeep, continuity, echo, anchor, pronoun })
|
|
352
|
+
let identity = personaLine(model, { withBans: !bansMuted, budget, shown, sleepKeep, continuity, echo, anchor, pronoun, works })
|
|
352
353
|
// 导入的人设不追加「你已经可以了」——那句是我们的成长叙事,对方的人设里没有这一段。
|
|
353
354
|
if (!bansMuted && grants.includes('learn-affection')) {
|
|
354
355
|
identity = identity
|
|
@@ -374,6 +375,11 @@ export function renderSelfDoc(model, { sendTools = [], budget, continuity, brows
|
|
|
374
375
|
// her_note 是无条件注册的,说明与工具必须同一个判据,否则她会以为有这个工具却伸手落空。
|
|
375
376
|
NOTE_BRIEF,
|
|
376
377
|
'',
|
|
378
|
+
// 自己留下的东西(1.0.4,2026-11-16):her_make / her_work 跟便条、预约一样
|
|
379
|
+
// 无条件注册(跟「自己找点事做」那个开关无关——东西留在家里,开关关着也还在),
|
|
380
|
+
// 说明必须同判据挂上,否则她手里有这只手、文档里却一个字没提。
|
|
381
|
+
MAKE_BRIEF,
|
|
382
|
+
'',
|
|
377
383
|
// 预约簿(2026-11-09,用户 m00002):和便条一样常驻注册,说明必须同判据挂上,
|
|
378
384
|
// 否则她手里有这本簿子、身份文档里却一个字没提。
|
|
379
385
|
APPOINT_BRIEF,
|
|
@@ -569,6 +575,9 @@ export async function writeSelfDoc(root = rootDir(), { log, exec, tenant } = {})
|
|
|
569
575
|
sendTools: proactiveConfig(config).sendTools,
|
|
570
576
|
// 定时工具默认不放;白名单里放了哪几个就写哪几个(issue #64)。收窄开着时同样按运行中的名单。
|
|
571
577
|
schedule: hand.schedule,
|
|
578
|
+
// 手上那件没弄完的(1.0.5,用户 m01433):一句话。写在身份文档里,是为了让
|
|
579
|
+
// 她**不必先被叫醒到桌子前**也知道有这么个东西。只写事实,不写进度。
|
|
580
|
+
works: await worksForDesk(root, { now: Date.now() }).catch(() => ({ wip: null })),
|
|
572
581
|
})
|
|
573
582
|
|
|
574
583
|
let prev = null
|
package/lib/settings.js
CHANGED
|
@@ -342,6 +342,8 @@ export const DEFAULTS = {
|
|
|
342
342
|
coreOnly: false, // 只存核心数据(2026-11-15,PR #142)
|
|
343
343
|
extras: [], // coreOnly 时额外带上的可选目录(attachments/media/outings/updates/owner)
|
|
344
344
|
skipAttachments: true, // 自动备份不带桥接附件与媒体(2026-11-15,用户 m01641):图片/电子书能把包撑到几十兆
|
|
345
|
+
withSecrets: false, // 自动备份与云端带不带凭据(2026-11-16,用户 m00712)。默认不带:
|
|
346
|
+
// 这两条都是无人值守、还会被网盘同步走的渠道。手动「备份成一份文件」不受它管
|
|
345
347
|
},
|
|
346
348
|
|
|
347
349
|
// 云端备份(2026-11-14,用户 m01090)
|
|
@@ -574,6 +576,8 @@ export function normalizeConfig(raw = {}) {
|
|
|
574
576
|
// lastAt 只收字符串(它的值是 ISO 时间,不是数字)。
|
|
575
577
|
cfg.backup = { ...DEFAULTS.backup, ...cfg.backup }
|
|
576
578
|
cfg.backup.enabled = cfg.backup.enabled !== false
|
|
579
|
+
// 凭据开关(2026-11-16,用户 m00712):只有明确写 true 才带;缺省、旧配置、串值一律按不带。
|
|
580
|
+
cfg.backup.withSecrets = cfg.backup.withSecrets === true
|
|
577
581
|
cfg.backup.lastAt = String(cfg.backup.lastAt ?? '')
|
|
578
582
|
|
|
579
583
|
// 云端备份(2026-11-14):目标是列表,形状的校验在 cloudtargets.js 里,
|
package/lib/video.js
CHANGED
|
@@ -32,9 +32,13 @@
|
|
|
32
32
|
* 并 appends 到 media/ffmpeg.log(已脱敏),不再用「可能被风控」这种猜。
|
|
33
33
|
* 3. `-headers` / `-ca_file` 只在 http(s) 输入时才加:它们是网络协议私有选项,
|
|
34
34
|
* 对本地文件输入会直接 `Option headers not found.` 退出 1(2026-10-30 实测)。
|
|
35
|
-
* `caFile`
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* `caFile` 是可选追加:2026-11-16 起 https **默认**就带 `tls_verify=1`,
|
|
36
|
+
* 给了 caFile 再追加 `-ca_file`;证书真对不上时退回一次不校验(没凭据可丢)。
|
|
37
|
+
*
|
|
38
|
+
* 2026-11-16(外部安全报告):`-headers` 里**不再带 cookie**。
|
|
39
|
+
* ffmpeg 把这份头原样发给播放地址那个主机(跟随重定向也带),而播放地址可能
|
|
40
|
+
* 指向第三方 CDN;旧版默认又不校验证书,等于把 SESSDATA / bili_jct 交给任何
|
|
41
|
+
* 能冒充该主机的人。实测只带 Referer + UA 返回 206,cookie 本来就不需要。
|
|
38
42
|
*/
|
|
39
43
|
|
|
40
44
|
import { promises as fs } from 'node:fs'
|
|
@@ -182,15 +186,23 @@ async function appendFfmpegLog(root, text) {
|
|
|
182
186
|
} catch { /* 日志写不进去不能连累主流程 */ }
|
|
183
187
|
}
|
|
184
188
|
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
/**
|
|
190
|
+
* ffmpeg 拉 B 站直链时带的请求头:只有 Referer / UA / Accept,**不带任何 cookie**。
|
|
191
|
+
*
|
|
192
|
+
* 2026-11-16 外部安全报告的病灶就在这一行 cookie:ffmpeg 的 `-headers` 是原样发给
|
|
193
|
+
* 播放地址那个主机的,跟随后续重定向也会继续带;播放地址由 B 站回,但可能指向第三方
|
|
194
|
+
* CDN,而 ffmpeg 默认不校验证书(`tls_verify=0`)——同网段的人冒充任一主机就能拿到
|
|
195
|
+
* 整串凭据(SESSDATA 是登录态,bili_jct 还能拿去写评论)。
|
|
196
|
+
*
|
|
197
|
+
* 实测(2026-11-16,qn=64 的 dash 直链):只带 Referer + UA 返回 206,cookie 不需要。
|
|
198
|
+
* 导出是为了让 `test/video.test.mjs` 直接盯着「这里不能再出现 Cookie」。
|
|
199
|
+
*/
|
|
200
|
+
export function headersFor(bvid) {
|
|
201
|
+
return [
|
|
188
202
|
`Referer: https://www.bilibili.com/video/${bvid}`,
|
|
189
203
|
`User-Agent: ${UA}`,
|
|
190
204
|
'Accept: */*',
|
|
191
|
-
]
|
|
192
|
-
if (cookie) lines.push(`Cookie: ${cookie}`)
|
|
193
|
-
return lines.join('\r\n') + '\r\n'
|
|
205
|
+
].join('\r\n') + '\r\n'
|
|
194
206
|
}
|
|
195
207
|
|
|
196
208
|
/**
|
|
@@ -303,7 +315,7 @@ function hasKeywords(avoid) {
|
|
|
303
315
|
* @param {number} [o.frames] 取几帧(默认 9 = 3×3);只在没给 o.at 时用
|
|
304
316
|
* @param {number|number[]} [o.at] 她点名的时刻(秒);给了就只取这几个时刻
|
|
305
317
|
* @param {{ok:boolean,bin:string}} [o.ffmpeg] 注入的 ffmpeg 探测结果(单测用假的)
|
|
306
|
-
* @param {string} [o.caFile] 显式 CA
|
|
318
|
+
* @param {string} [o.caFile] 显式 CA 包路径(可选);https 默认就开 `-tls_verify 1`,给了 CA 再追加 `-ca_file`
|
|
307
319
|
* @param {object} [o.avoid] 配置里的 avoid(屏蔽的 UP 与关键词)
|
|
308
320
|
* @returns {Promise<{ok:boolean, path:string, why:string, title:string, up:string, view:number, duration:number, shots:number, blocked?:string}>}
|
|
309
321
|
* blocked 只在命中屏蔽时有:写命中了哪一项(给日志看,不给她看)
|
|
@@ -372,16 +384,26 @@ export async function grabFrames(o = {}) {
|
|
|
372
384
|
const url = pu.data.url
|
|
373
385
|
const duration = Number(info.data?.duration ?? pu.data?.duration ?? 0) || 0
|
|
374
386
|
const net = isHttp(url)
|
|
387
|
+
const https = /^https:\/\//i.test(String(url))
|
|
375
388
|
|
|
376
389
|
// 网络私有选项只对网络输入有效。本地文件(单测喂 mp4)带上它们会直接报
|
|
377
390
|
// 「Option headers not found.」退出 1 —— 2026-10-30 实测。
|
|
391
|
+
//
|
|
392
|
+
// 这里**不传 cookie**(2026-11-16 外部安全报告):ffmpeg 的 `-headers` 原样发给
|
|
393
|
+
// 播放地址那个主机,跟随后续重定向也照带;播放地址可能指向第三方 CDN,证书校验
|
|
394
|
+
// 不开时谁都能冒充。实测只带 Referer + UA 就是 206,没有理由把登录态塞进去。
|
|
395
|
+
//
|
|
396
|
+
// 证书校验默认开(https 才谈得上)。以前的写法是「给了 CA 文件才开」,等于默认
|
|
397
|
+
// 不校验;现在反过来:默认校验证书,只在真失败时退回一次(老机器没有系统证书库)。
|
|
378
398
|
const netArgs = []
|
|
399
|
+
const looseArgs = []
|
|
379
400
|
if (net) {
|
|
380
|
-
netArgs.push('-headers', headersFor(bvid
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
401
|
+
netArgs.push('-headers', headersFor(bvid))
|
|
402
|
+
looseArgs.push('-headers', headersFor(bvid))
|
|
403
|
+
if (https) {
|
|
404
|
+
netArgs.push('-tls_verify', '1')
|
|
405
|
+
if (caFile) netArgs.push('-ca_file', caFile)
|
|
406
|
+
}
|
|
385
407
|
}
|
|
386
408
|
|
|
387
409
|
const dir = await mediaDir(root)
|
|
@@ -397,34 +419,45 @@ export async function grabFrames(o = {}) {
|
|
|
397
419
|
|
|
398
420
|
// 帧只在内存里过一手:不建临时目录、不落中间文件。
|
|
399
421
|
// 这既是 issue #13 要的(子进程不写盘),也比它建议的更彻底(连插件自己都不用写临时帧)。
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
422
|
+
const grabTimes = async (args) => {
|
|
423
|
+
const got = []
|
|
424
|
+
let first = ''
|
|
425
|
+
for (let i = 0; i < times.length; i++) {
|
|
426
|
+
const grab = async (t) => runFfmpeg(ff.bin, [
|
|
427
|
+
'-hide_banner', '-loglevel', 'error',
|
|
428
|
+
'-nostdin',
|
|
429
|
+
...args,
|
|
430
|
+
'-ss', t.toFixed(2),
|
|
431
|
+
'-i', url,
|
|
432
|
+
'-frames:v', '1',
|
|
433
|
+
'-vf', 'scale=360:-2',
|
|
434
|
+
'-f', 'image2pipe', '-vcodec', 'png', '-',
|
|
435
|
+
])
|
|
436
|
+
let r = await grab(times[i])
|
|
437
|
+
let buf = pngOf(r)
|
|
438
|
+
// 一次失败多半是那一下网络抖了或正好 seek 到关键帧边界;换一个时刻重试一次。
|
|
439
|
+
// 不重试的话视频尾部几帧经常整片空着(实测 9 帧只成 7 帧)。
|
|
440
|
+
// 往后挪 1.5 秒;但如果会越过片尾,就往前挪——否则夹到片尾同一个点上,
|
|
441
|
+
// 等于把同一条命令再跑一遍,白等一次超时。
|
|
442
|
+
if (!buf) {
|
|
443
|
+
const last = duration > 0 ? Math.max(0, duration - 1) : Infinity
|
|
444
|
+
let back = times[i] + 1.5
|
|
445
|
+
if (back > last) back = Math.max(0, times[i] - 1.5)
|
|
446
|
+
r = await grab(back)
|
|
447
|
+
buf = pngOf(r)
|
|
448
|
+
}
|
|
449
|
+
if (buf) got.push(buf)
|
|
450
|
+
else if (!first) first = describe(r, true)
|
|
425
451
|
}
|
|
426
|
-
|
|
427
|
-
|
|
452
|
+
return { shots: got, firstFail: first }
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
let { shots, firstFail } = await grabTimes(netArgs)
|
|
456
|
+
// 证书对不上就退回一次不校验:没有凭据可丢了,最坏只是画面被换掉;
|
|
457
|
+
// 一刀切死会让没有系统证书库的老机器彻底看不了画面。
|
|
458
|
+
if (shots.length === 0 && https && /tls|ssl|certificate|证书/i.test(firstFail)) {
|
|
459
|
+
await appendFfmpegLog(root, `grab ${bvid} 证书校验失败,退回不校验:${firstFail}`)
|
|
460
|
+
;({ shots, firstFail } = await grabTimes(looseArgs))
|
|
428
461
|
}
|
|
429
462
|
|
|
430
463
|
if (shots.length === 0) {
|