@ssamurias/dsh-fish 1.0.7 → 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 -4265
- package/README.md +243 -627
- package/RELEASE-NOTES-1.0.8.md +81 -0
- package/RELEASE-NOTES-1.0.9.md +79 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/docs/troubleshooting.md +79 -1
- 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 +8 -3
- package/lib/at.js +16 -1
- package/lib/capture.js +51 -1
- 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 +109 -24
- package/lib/comment.js +18 -3
- package/lib/cue.js +102 -5
- package/lib/deliver.js +3 -1
- package/lib/derive.js +308 -41
- package/lib/doing.js +31 -15
- package/lib/drive.js +3 -5
- package/lib/env.d.ts +224 -0
- package/lib/health.js +56 -0
- package/lib/hear.js +70 -0
- package/lib/home.js +48 -20
- package/lib/identity.js +25 -2
- package/lib/index.js +32 -18
- package/lib/look.js +2 -1
- package/lib/loops.js +39 -0
- package/lib/make.js +60 -12
- package/lib/markup.js +77 -1
- package/lib/match.js +262 -0
- 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 +187 -40
- package/lib/proactive.js +48 -47
- package/lib/pronounask.js +15 -1
- package/lib/restrict.js +146 -9
- package/lib/say.js +68 -4
- package/lib/scheduler.js +63 -25
- package/lib/schema.js +57 -4
- package/lib/scrub.js +16 -1
- package/lib/settings.js +128 -12
- package/lib/stance.js +131 -19
- package/lib/status.js +14 -5
- package/lib/store.js +24 -2
- package/lib/sub.js +7 -1
- package/lib/talkmem.js +12 -8
- package/lib/transcript.js +205 -0
- package/lib/turns.js +147 -19
- package/lib/types.d.ts +513 -0
- package/lib/voices.js +26 -1
- package/lib/wiki.js +47 -13
- package/lib/works.js +200 -49
- package/media/banner.jpg +0 -0
- package/package.json +1 -1
- package/scripts/build-client.mjs +83 -0
- package/scripts/sync-pressure-formulas.mjs +12 -15
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* types.d.ts —— `dsh-fish` 核心领域契约与前后端接口类型定义
|
|
3
|
+
*
|
|
4
|
+
* 只包含纯类型声明(零运行时代码、零编译步骤),覆盖四个最容易发生跨模块漂移的中枢:
|
|
5
|
+
* 1. 事件流判别联合类型(`FishEvent`,对应 `lib/schema.js`);
|
|
6
|
+
* 2. 生长环境配置树(`FishConfig`,对应 `lib/settings.js` 的 `DEFAULTS`);
|
|
7
|
+
* 3. 认知派生快照(`DerivedSelf`,对应 `lib/derive.js` 的 `deriveSelf` 返回值);
|
|
8
|
+
* 4. 观测台 HTTP 响应载荷与宿主最小接口(对应 `lib/observe*.js` 与 `lib/client.js`)。
|
|
9
|
+
*
|
|
10
|
+
* `test/architecture.test.mjs` 会校验本文件中的枚举字面量与 `schema.js` / `settings.js` 保持同步。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { DEFAULTS } from './settings.js'
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// 1. 事件流契约(schema.js)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
export type HerEventType = 'utterance' | 'revise' | 'reunion' | 'narration' | 'refusal' | 'dream'
|
|
20
|
+
|
|
21
|
+
export type SystemOnlyEventType =
|
|
22
|
+
| 'seed'
|
|
23
|
+
| 'answer'
|
|
24
|
+
| 'test'
|
|
25
|
+
| 'absence'
|
|
26
|
+
| 'meta'
|
|
27
|
+
| 'diary'
|
|
28
|
+
| 'voice'
|
|
29
|
+
| 'grant_offer'
|
|
30
|
+
| 'grant'
|
|
31
|
+
| 'ask'
|
|
32
|
+
| 'heard'
|
|
33
|
+
| 'comment'
|
|
34
|
+
|
|
35
|
+
export type EventType = HerEventType | SystemOnlyEventType
|
|
36
|
+
|
|
37
|
+
export type EventScene = 'desk' | 'private' | 'group'
|
|
38
|
+
|
|
39
|
+
export type EventFlag = 'selfmod' | 'unrecorded' | 'weak' | 'truncated' | 'uncommitted' | 'anchored'
|
|
40
|
+
|
|
41
|
+
export type EventVerdict = 'confirmed' | 'refuted' | 'refined' | null
|
|
42
|
+
|
|
43
|
+
export type EventSource = 'tool' | 'system' | 'import' | (string & {})
|
|
44
|
+
|
|
45
|
+
export interface EventGrantPayload {
|
|
46
|
+
rule: string
|
|
47
|
+
offerId: string
|
|
48
|
+
verdict: 'approve' | 'reject' | null
|
|
49
|
+
reason: string
|
|
50
|
+
expiresAt?: string | null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface EventAskValue {
|
|
54
|
+
wakesPerDay?: number
|
|
55
|
+
window?: [string, string]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface EventAskPayload {
|
|
59
|
+
kind: string
|
|
60
|
+
subject: string
|
|
61
|
+
options: string[]
|
|
62
|
+
reason: string
|
|
63
|
+
askId: string
|
|
64
|
+
verdict: 'approve' | 'reject' | 'later' | null
|
|
65
|
+
via: string
|
|
66
|
+
appointId: string
|
|
67
|
+
value?: EventAskValue
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface EventRefusePayload {
|
|
71
|
+
act: string
|
|
72
|
+
object: string
|
|
73
|
+
raw?: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface FishEventBase {
|
|
77
|
+
id: string
|
|
78
|
+
v: number
|
|
79
|
+
ts: string
|
|
80
|
+
day: number
|
|
81
|
+
stage: number
|
|
82
|
+
type: EventType
|
|
83
|
+
source: EventSource
|
|
84
|
+
sessionId?: string
|
|
85
|
+
scene?: EventScene
|
|
86
|
+
who?: { id: string; name: string }
|
|
87
|
+
re?: string
|
|
88
|
+
topic?: string
|
|
89
|
+
text: string
|
|
90
|
+
refs: string[]
|
|
91
|
+
verdict: EventVerdict
|
|
92
|
+
confidence: number
|
|
93
|
+
flags: EventFlag[]
|
|
94
|
+
grant?: EventGrantPayload
|
|
95
|
+
ask?: EventAskPayload
|
|
96
|
+
refuse?: EventRefusePayload
|
|
97
|
+
days?: number
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface UtteranceEvent extends FishEventBase {
|
|
101
|
+
type: 'utterance'
|
|
102
|
+
topic?: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface ReviseEvent extends FishEventBase {
|
|
106
|
+
type: 'revise'
|
|
107
|
+
topic?: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RefusalEvent extends FishEventBase {
|
|
111
|
+
type: 'refusal'
|
|
112
|
+
refuse?: EventRefusePayload
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface AskEvent extends FishEventBase {
|
|
116
|
+
type: 'ask' | 'answer'
|
|
117
|
+
ask?: EventAskPayload
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface GrantEvent extends FishEventBase {
|
|
121
|
+
type: 'grant_offer' | 'grant'
|
|
122
|
+
grant?: EventGrantPayload
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface HeardEvent extends FishEventBase {
|
|
126
|
+
type: 'heard'
|
|
127
|
+
re?: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface AbsenceEvent extends FishEventBase {
|
|
131
|
+
type: 'absence'
|
|
132
|
+
days?: number
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface GenericFishEvent extends FishEventBase {
|
|
136
|
+
type: Exclude<EventType, 'utterance' | 'revise' | 'refusal' | 'ask' | 'answer' | 'grant_offer' | 'grant' | 'heard' | 'absence'>
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type FishEvent =
|
|
140
|
+
| UtteranceEvent
|
|
141
|
+
| ReviseEvent
|
|
142
|
+
| RefusalEvent
|
|
143
|
+
| AskEvent
|
|
144
|
+
| GrantEvent
|
|
145
|
+
| HeardEvent
|
|
146
|
+
| AbsenceEvent
|
|
147
|
+
| GenericFishEvent
|
|
148
|
+
|
|
149
|
+
export interface ValidateContext {
|
|
150
|
+
day?: number
|
|
151
|
+
stage?: number
|
|
152
|
+
now?: number
|
|
153
|
+
source?: EventSource
|
|
154
|
+
knownIds?: ReadonlySet<string> | null
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ============================================================================
|
|
158
|
+
// 2. 生长环境配置契约(settings.js)
|
|
159
|
+
// ============================================================================
|
|
160
|
+
|
|
161
|
+
export type OwnerPronoun = '他' | '她' | 'TA'
|
|
162
|
+
export type SelfPronoun = '她' | '他' | '祂'
|
|
163
|
+
export type SubReadMode = 'page' | 'whole'
|
|
164
|
+
export type ToolKind = 'produce' | 'consume' | 'effect' | 'self'
|
|
165
|
+
export type TimeWindow = [string, string]
|
|
166
|
+
|
|
167
|
+
export type RawDefaults = typeof DEFAULTS
|
|
168
|
+
|
|
169
|
+
export type FishConfig = Omit<RawDefaults, 'window' | 'owner' | 'self' | 'tools' | 'proactive' | 'browse' | 'comment' | 'avoid' | 'cloud' | 'match'> & {
|
|
170
|
+
window: TimeWindow
|
|
171
|
+
owner: { pronoun: OwnerPronoun }
|
|
172
|
+
self: { pronoun: SelfPronoun }
|
|
173
|
+
tools: { preset: string; restrict: boolean; allow: string[] }
|
|
174
|
+
proactive: Omit<RawDefaults['proactive'], 'sendTools' | 'toolKinds'> & {
|
|
175
|
+
sendTools: string[]
|
|
176
|
+
toolKinds: Record<string, ToolKind>
|
|
177
|
+
minIdleHours?: number
|
|
178
|
+
}
|
|
179
|
+
match: {
|
|
180
|
+
cooldownDays: number
|
|
181
|
+
dayMax?: number
|
|
182
|
+
}
|
|
183
|
+
browse: Omit<RawDefaults['browse'], 'window' | 'keywords'> & {
|
|
184
|
+
window: TimeWindow | null
|
|
185
|
+
keywords: string[]
|
|
186
|
+
}
|
|
187
|
+
comment: Omit<RawDefaults['comment'], 'window'> & {
|
|
188
|
+
window: TimeWindow
|
|
189
|
+
}
|
|
190
|
+
avoid: {
|
|
191
|
+
keywords: string[]
|
|
192
|
+
upMids: string[]
|
|
193
|
+
minDuration: number
|
|
194
|
+
}
|
|
195
|
+
cloud: Omit<RawDefaults['cloud'], 'targets'> & {
|
|
196
|
+
targets: Array<Record<string, any>>
|
|
197
|
+
}
|
|
198
|
+
[extraKey: string]: any
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export type DeepPartial<T> = {
|
|
202
|
+
[K in keyof T]?: T[K] extends Array<infer U>
|
|
203
|
+
? Array<U>
|
|
204
|
+
: T[K] extends object
|
|
205
|
+
? DeepPartial<T[K]>
|
|
206
|
+
: T[K]
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ============================================================================
|
|
210
|
+
// 3. 认知派生快照契约(derive.js)
|
|
211
|
+
// ============================================================================
|
|
212
|
+
|
|
213
|
+
export type GateKey = 'trust' | 'autonomy' | 'competence'
|
|
214
|
+
|
|
215
|
+
export interface BeliefItem {
|
|
216
|
+
id: string
|
|
217
|
+
text: string
|
|
218
|
+
since: number
|
|
219
|
+
at: string
|
|
220
|
+
stage: number
|
|
221
|
+
confidence: number
|
|
222
|
+
refs: string[]
|
|
223
|
+
anchored: boolean
|
|
224
|
+
topic: string
|
|
225
|
+
mentions: number
|
|
226
|
+
testedCount: number
|
|
227
|
+
lastTouchedAt: number
|
|
228
|
+
salience: number
|
|
229
|
+
solid: boolean
|
|
230
|
+
faded?: boolean
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface RefusalItem {
|
|
234
|
+
id: string
|
|
235
|
+
at: string
|
|
236
|
+
day: number
|
|
237
|
+
what: string
|
|
238
|
+
quote: string
|
|
239
|
+
act: string
|
|
240
|
+
object: string
|
|
241
|
+
reaction: string | null
|
|
242
|
+
reactionText?: string | null
|
|
243
|
+
conceded?: boolean
|
|
244
|
+
concedeText?: string | null
|
|
245
|
+
resolved?: boolean
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface TensionItem {
|
|
249
|
+
a: { id: string; text: string; at?: string }
|
|
250
|
+
b: { id: string; text: string; at?: string }
|
|
251
|
+
sim: number
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface StageGate {
|
|
255
|
+
passed: GateKey[]
|
|
256
|
+
pending: GateKey | null
|
|
257
|
+
next: GateKey | null
|
|
258
|
+
forced: GateKey[]
|
|
259
|
+
gateStage: number
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface DerivedFacts {
|
|
263
|
+
refusals: number
|
|
264
|
+
wont: number
|
|
265
|
+
refused: number
|
|
266
|
+
askRejected: number
|
|
267
|
+
revises: number
|
|
268
|
+
narrations: number
|
|
269
|
+
corrected: number
|
|
270
|
+
reunions: number
|
|
271
|
+
reunionAfterAbsence: number
|
|
272
|
+
tensions: number
|
|
273
|
+
solid: number
|
|
274
|
+
faded: number
|
|
275
|
+
solidStaleDays: number
|
|
276
|
+
reactions: { accept: number; insist: number; hurt: number; leave: number; other: number }
|
|
277
|
+
hurts: number
|
|
278
|
+
scars: number
|
|
279
|
+
scarsResolved: number
|
|
280
|
+
voices: number
|
|
281
|
+
voicesEchoed: number
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface DerivedSelf {
|
|
285
|
+
day: number
|
|
286
|
+
growthDays: number
|
|
287
|
+
startedAt: string | null
|
|
288
|
+
persona: { imported: boolean; source: string }
|
|
289
|
+
stage: number
|
|
290
|
+
elapsedStage: number
|
|
291
|
+
stageName: string
|
|
292
|
+
stagePeak: number
|
|
293
|
+
stageForced: boolean
|
|
294
|
+
stageGate: StageGate
|
|
295
|
+
name: string | null
|
|
296
|
+
beliefs: BeliefItem[]
|
|
297
|
+
ranked: BeliefItem[]
|
|
298
|
+
solid: BeliefItem[]
|
|
299
|
+
solidTotal: number
|
|
300
|
+
faded: BeliefItem[]
|
|
301
|
+
tensions: TensionItem[]
|
|
302
|
+
tensionsTotal: number
|
|
303
|
+
scars: RefusalItem[]
|
|
304
|
+
scarCount: number
|
|
305
|
+
voices: Array<{ id: string; at: string; text: string; echoed?: boolean }>
|
|
306
|
+
freshVoice: { id: string; at: string; text: string } | null
|
|
307
|
+
lookedRecent: Array<{ bvid: string; title: string; at?: string }>
|
|
308
|
+
materials: Array<Record<string, any>>
|
|
309
|
+
beliefCount: number
|
|
310
|
+
refuted: Array<Record<string, any>>
|
|
311
|
+
refusals: RefusalItem[]
|
|
312
|
+
refusalEcho: RefusalItem | null
|
|
313
|
+
conflicts: Array<Record<string, any>>
|
|
314
|
+
recentHeard: Array<Record<string, any>>
|
|
315
|
+
topicPairs: Array<Record<string, any>>
|
|
316
|
+
looseSaid: Array<Record<string, any>>
|
|
317
|
+
selfmodAttempts: Array<Record<string, any>>
|
|
318
|
+
reunions: Array<Record<string, any>>
|
|
319
|
+
corrected: number
|
|
320
|
+
tested: string[]
|
|
321
|
+
needs: { autonomy: number; competence: number; relatedness: number }
|
|
322
|
+
facts: DerivedFacts
|
|
323
|
+
absenceDays: number
|
|
324
|
+
narrative: { id?: string; text: string; at?: string; source?: string } | null
|
|
325
|
+
prevNarrative: { text: string; at?: string } | null
|
|
326
|
+
lastAbsence: { at: string } | null
|
|
327
|
+
lastSeenAt: string | null
|
|
328
|
+
lastWakeAt: string | null
|
|
329
|
+
spokenSinceSeen: boolean
|
|
330
|
+
heardSinceWake: boolean
|
|
331
|
+
lastReunion: { at: string; text: string } | null
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ============================================================================
|
|
335
|
+
// 4. 观测台 HTTP 与宿主运行期接口契约(observe*.js ↔ client.js)
|
|
336
|
+
// ============================================================================
|
|
337
|
+
|
|
338
|
+
export interface HttpRequest {
|
|
339
|
+
method?: string
|
|
340
|
+
url?: string
|
|
341
|
+
headers?: Record<string, string | string[] | undefined>
|
|
342
|
+
on(event: 'data', listener: (chunk: Buffer | string) => void): void
|
|
343
|
+
on(event: 'end', listener: () => void): void
|
|
344
|
+
on(event: 'error', listener: (err: Error) => void): void
|
|
345
|
+
on(event: string, listener: (...args: any[]) => void): void
|
|
346
|
+
destroy?: () => void
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface HttpResponse {
|
|
350
|
+
writableEnded?: boolean
|
|
351
|
+
writeHead(statusCode: number, headers?: Record<string, string | number>): void
|
|
352
|
+
setHeader?(name: string, value: string | number): void
|
|
353
|
+
end(data?: string | Uint8Array): void
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export type ObserveHandler = (req: HttpRequest, res: HttpResponse) => Promise<void> | void
|
|
357
|
+
export type ObserveRouteEntry = [path: string, handler: ObserveHandler]
|
|
358
|
+
|
|
359
|
+
export interface HostContext {
|
|
360
|
+
get?: (name: string) => any
|
|
361
|
+
on?: (event: string, listener: (...args: any[]) => any) => (() => void) | void
|
|
362
|
+
emit?: (event: string, payload?: any) => void
|
|
363
|
+
bail?: (event: string, payload?: any) => any
|
|
364
|
+
sessionController?: any
|
|
365
|
+
webServer?: any
|
|
366
|
+
connection?: any
|
|
367
|
+
tools?: any
|
|
368
|
+
attachments?: any
|
|
369
|
+
[key: string]: any
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface TenancyBag {
|
|
373
|
+
root?: string
|
|
374
|
+
herDir?: string
|
|
375
|
+
tenant?: { ok: boolean; instanceId?: string; why?: string; owner?: { dataDir?: string } }
|
|
376
|
+
homes?: { changed?: boolean; from?: string; to?: string }
|
|
377
|
+
home?: { blocked?: boolean; why?: string }
|
|
378
|
+
reclaim?: () => Promise<void> | void
|
|
379
|
+
quiet?: <T>(fn: () => Promise<T> | T) => Promise<T> | T
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export interface ObserveDeps {
|
|
383
|
+
root?: string
|
|
384
|
+
version?: string
|
|
385
|
+
tenancy?: TenancyBag
|
|
386
|
+
compat?: { checked?: boolean; userQuestions?: boolean }
|
|
387
|
+
install?: {
|
|
388
|
+
host?: { ok?: boolean; status?: string; version?: string; range?: string; why?: string }
|
|
389
|
+
upgrade?: {
|
|
390
|
+
ok?: boolean
|
|
391
|
+
stale?: boolean
|
|
392
|
+
older?: boolean
|
|
393
|
+
skipped?: boolean
|
|
394
|
+
running?: string
|
|
395
|
+
source?: string
|
|
396
|
+
sourcePath?: string
|
|
397
|
+
profile?: string
|
|
398
|
+
why?: string
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
restoreLimit?: number
|
|
402
|
+
selfUpdater?: any
|
|
403
|
+
qrLogin?: any
|
|
404
|
+
openFolder?: (dir: string) => Promise<boolean>
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export interface ObserveEnv {
|
|
408
|
+
ctx: HostContext
|
|
409
|
+
root: string
|
|
410
|
+
deps: ObserveDeps
|
|
411
|
+
flog: (level?: 'info' | 'warn' | 'error' | 'debug') => (...args: unknown[]) => void
|
|
412
|
+
pressure: ReturnType<typeof import('./session-pressure.js').registerSessionPressure>
|
|
413
|
+
selfUpdater: any
|
|
414
|
+
qrLogin: any
|
|
415
|
+
openFolder: (dir: string) => Promise<boolean>
|
|
416
|
+
syncBridgePort: (portRaw: unknown, why?: string) => void
|
|
417
|
+
inflight: Map<string, number>
|
|
418
|
+
restoreLimit: number
|
|
419
|
+
runRestore: (bundle: any, skipBad: boolean) => Promise<any>
|
|
420
|
+
replyRestore: (res: HttpResponse, r: any) => void
|
|
421
|
+
awayFromBeat: <T>(fn: () => Promise<T> | T) => Promise<T> | T
|
|
422
|
+
reclaimTenant: () => Promise<void>
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export interface ObserveStatusPayload {
|
|
426
|
+
phase: string
|
|
427
|
+
label: string
|
|
428
|
+
detail: string
|
|
429
|
+
since: string
|
|
430
|
+
minutesAgo: number | null
|
|
431
|
+
plannedWakeAt: string | null
|
|
432
|
+
nextWakeAt: string | null
|
|
433
|
+
awake: boolean
|
|
434
|
+
today: {
|
|
435
|
+
wakes: number
|
|
436
|
+
idleWakes: number
|
|
437
|
+
browsed: number
|
|
438
|
+
said: number
|
|
439
|
+
chat: number
|
|
440
|
+
comments: number
|
|
441
|
+
dairies: number
|
|
442
|
+
}
|
|
443
|
+
timeline: Array<{ at: string; kind: string; text: string; idle?: boolean }>
|
|
444
|
+
away: { kind: string; since?: number; line: string; tripDays: number } | null
|
|
445
|
+
running: boolean
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface ObserveStatePayload {
|
|
449
|
+
day: number
|
|
450
|
+
growthDays: number
|
|
451
|
+
dev: boolean
|
|
452
|
+
stage: number
|
|
453
|
+
stageName: string
|
|
454
|
+
stagePeak: number
|
|
455
|
+
stageForced: boolean
|
|
456
|
+
pendingGate: GateKey | null
|
|
457
|
+
gateTimes: { belief: number; refuse: number; revise: number }
|
|
458
|
+
forcedGates: Array<'belief' | 'refuse' | 'revise'>
|
|
459
|
+
name: string | null
|
|
460
|
+
beliefCount: number
|
|
461
|
+
absenceDays: number
|
|
462
|
+
tension: { count: number; a: string; b: string } | null
|
|
463
|
+
solidCount: number
|
|
464
|
+
scarCount: number
|
|
465
|
+
stanceCount: number
|
|
466
|
+
stanceReady: boolean
|
|
467
|
+
counts: {
|
|
468
|
+
utterance: number
|
|
469
|
+
chat: number
|
|
470
|
+
revise: number
|
|
471
|
+
refusal: number
|
|
472
|
+
reunion: number
|
|
473
|
+
total: number
|
|
474
|
+
all: number
|
|
475
|
+
meta: number
|
|
476
|
+
noise: number
|
|
477
|
+
}
|
|
478
|
+
quality: Record<string, any>
|
|
479
|
+
rules: any
|
|
480
|
+
pending: { id: string; rule?: string; title: string; text: string; day: number | null } | null
|
|
481
|
+
grants: any
|
|
482
|
+
config: {
|
|
483
|
+
window: TimeWindow
|
|
484
|
+
daily: FishConfig['daily']
|
|
485
|
+
diary: { enabled: boolean; visible: boolean }
|
|
486
|
+
absenceAfterDays: number
|
|
487
|
+
proactive: FishConfig['proactive']
|
|
488
|
+
self: { pronoun: SelfPronoun }
|
|
489
|
+
}
|
|
490
|
+
meta: {
|
|
491
|
+
root: string
|
|
492
|
+
skippedLines: number
|
|
493
|
+
configFresh: boolean
|
|
494
|
+
configBroken: boolean
|
|
495
|
+
dateKey: string
|
|
496
|
+
version: string
|
|
497
|
+
}
|
|
498
|
+
tenancy: { ok: boolean; instanceId: string; why: string; dataDir: string } | null
|
|
499
|
+
homes: { changed: boolean; from: string; to: string } | null
|
|
500
|
+
home: Record<string, any>
|
|
501
|
+
compat: { checked: boolean; userQuestions: boolean }
|
|
502
|
+
host: { ok: boolean; status: string; version: string; range: string; why: string } | null
|
|
503
|
+
upgrade: {
|
|
504
|
+
stale: boolean
|
|
505
|
+
older: boolean
|
|
506
|
+
skipped: boolean
|
|
507
|
+
running: string
|
|
508
|
+
source: string
|
|
509
|
+
sourcePath: string
|
|
510
|
+
profile: string
|
|
511
|
+
why: string
|
|
512
|
+
} | null
|
|
513
|
+
}
|
package/lib/voices.js
CHANGED
|
@@ -76,6 +76,20 @@ export function negationParity(text) {
|
|
|
76
76
|
return (hits?.length ?? 0) % 2
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* 这条评论是谁写的(1.0.8,认识人 S1,2026-11-22)。
|
|
81
|
+
*
|
|
82
|
+
* 抓取层本来就有 `mid` 与 `user`(见 lib/bili.js 的评论映射),摊平时被丢了——
|
|
83
|
+
* 于是「昨天评论区那句话」永远没有主人。这里只做搬运,不改任何读法。
|
|
84
|
+
* 没有 mid 就留空 id:上层据此说「名字可能对应好几个人」,不假装知道。
|
|
85
|
+
*/
|
|
86
|
+
function whoOf(c) {
|
|
87
|
+
const mid = Number(c?.mid) || 0
|
|
88
|
+
const name = String(c?.user ?? '').trim()
|
|
89
|
+
if (!mid && !name) return null
|
|
90
|
+
return { id: mid ? `bili:${mid}` : '', name }
|
|
91
|
+
}
|
|
92
|
+
|
|
79
93
|
/**
|
|
80
94
|
* 从一轮浏览的素材包里把所有评论摊平。
|
|
81
95
|
*
|
|
@@ -90,7 +104,13 @@ export function commentsFrom(packs = []) {
|
|
|
90
104
|
const text = String(c?.text ?? '').trim()
|
|
91
105
|
const key = normVoice(text)
|
|
92
106
|
if (key.length < 6 || text.length > VOICE_MAX) continue
|
|
93
|
-
|
|
107
|
+
const who = whoOf(c)
|
|
108
|
+
out.push({
|
|
109
|
+
text: text.replace(/\s+/g, ' ').slice(0, VOICE_MAX),
|
|
110
|
+
like: Number(c?.like ?? 0) || 0,
|
|
111
|
+
bvid,
|
|
112
|
+
...(who ? { who } : {}),
|
|
113
|
+
})
|
|
94
114
|
}
|
|
95
115
|
}
|
|
96
116
|
return out
|
|
@@ -152,6 +172,9 @@ export function recentVoiceKeys(events = [], { now = Date.now(), ttlDays = VOICE
|
|
|
152
172
|
const out = new Set()
|
|
153
173
|
for (const e of events) {
|
|
154
174
|
if (e?.type !== 'voice') continue
|
|
175
|
+
// 群聊里别人说的那句(认识人 S2-b,2026-11-23)也写成 voice,但它不是 B 站评论:
|
|
176
|
+
// 混进来会让「同一句 30 天内不再记」把群里的话当成评论去重,评论反而被挤掉。
|
|
177
|
+
if (e?.scene === 'group') continue
|
|
155
178
|
const t = Date.parse(e.ts ?? '')
|
|
156
179
|
if (Number.isFinite(t) && now - t > ttlDays * DAY_MS) continue
|
|
157
180
|
out.add(voiceKey(e.text))
|
|
@@ -177,6 +200,8 @@ export async function recordVoice({ packs = [], events = [], model = {}, root, c
|
|
|
177
200
|
type: 'voice',
|
|
178
201
|
text: v.text.slice(0, VOICE_MAX),
|
|
179
202
|
refs: v.bvid ? [v.bvid] : [],
|
|
203
|
+
// 谁说的(1.0.8,认识人 S1):评论区那句话属于谁。抓不到就整段不落。
|
|
204
|
+
...(v.who ? { who: v.who } : {}),
|
|
180
205
|
// 谁让她看的(issue #16 第二半):没有会话就不落这个字段。
|
|
181
206
|
...(String(sessionId ?? '').trim() ? { sessionId: String(sessionId).trim() } : {}),
|
|
182
207
|
},
|