whale-memory-core 0.14.0 → 0.18.2
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/README.md +14 -0
- package/bin/whale-memory-mcp.mjs +276 -0
- package/demo.mjs +44 -33
- package/index.d.ts +16 -13
- package/index.js +18 -15
- package/lib/archive.d.ts +22 -0
- package/lib/archive.js +171 -0
- package/lib/as-of.d.ts +5 -5
- package/lib/as-of.js +32 -32
- package/lib/book.d.ts +4 -4
- package/lib/book.js +75 -75
- package/lib/chapter-events.d.ts +39 -39
- package/lib/chapter-events.js +89 -89
- package/lib/detail-recall.d.ts +15 -0
- package/lib/detail-recall.js +174 -0
- package/lib/event-log.d.ts +10 -10
- package/lib/event-log.js +61 -61
- package/lib/evidence-from-experience.d.ts +8 -8
- package/lib/evidence-from-experience.js +62 -62
- package/lib/evidence-policy.js +2 -2
- package/lib/fact-timeline-contract.d.ts +73 -0
- package/lib/fact-timeline-contract.js +226 -0
- package/lib/fact-timeline-query.d.ts +29 -0
- package/lib/fact-timeline-query.js +97 -0
- package/lib/file-lock.js +1 -1
- package/lib/later-events.d.ts +21 -21
- package/lib/later-events.js +80 -80
- package/lib/link-events.d.ts +15 -15
- package/lib/link-events.js +33 -33
- package/lib/query-match.js +55 -0
- package/lib/recall-events.d.ts +24 -24
- package/lib/recall-events.js +97 -97
- package/lib/recap.d.ts +23 -23
- package/lib/recap.js +79 -79
- package/lib/seal-events.d.ts +25 -25
- package/lib/seal-events.js +82 -82
- package/lib/self-experience.d.ts +180 -175
- package/lib/self-experience.js +624 -560
- package/lib/self-memory.js +70 -68
- package/lib/self-prompt.js +8 -4
- package/lib/self-settings.js +2 -2
- package/lib/unfinished-events.d.ts +26 -26
- package/lib/unfinished-events.js +105 -105
- package/lib/unsaid.d.ts +28 -0
- package/lib/unsaid.js +105 -0
- package/lib/waking.d.ts +1 -1
- package/lib/waking.js +99 -92
- package/package.json +127 -105
package/lib/self-experience.d.ts
CHANGED
|
@@ -1,176 +1,181 @@
|
|
|
1
|
-
export type Weight = 'important' | 'normal' | 'minor'
|
|
2
|
-
|
|
3
|
-
export interface Quote {
|
|
4
|
-
text: string
|
|
5
|
-
source?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface LaterEntry {
|
|
9
|
-
at: string
|
|
10
|
-
day?: string
|
|
11
|
-
thought: string
|
|
12
|
-
reason?: string
|
|
13
|
-
/** 她后来再想起时的感觉(0.12 起);当时的感觉在 then.feeling 里,永远不动 */
|
|
14
|
-
feeling?: string[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** 出处 / 反向引用里的一条:指路用的一句话摘要 */
|
|
18
|
-
export interface ExperienceBrief {
|
|
19
|
-
id: string
|
|
20
|
-
day?: string
|
|
21
|
-
text?: string
|
|
22
|
-
/** 出处指向的经历找不到了(例如只恢复了部分文件) */
|
|
23
|
-
missing?: boolean
|
|
24
|
-
/** 那条经历她封存了:不给摘要 */
|
|
25
|
-
sealed?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** 「翻回那天的自己」:2026-11-15(截到那天本地时间的最后一刻)、完整 ISO 时间或 Date */
|
|
29
|
-
export type AsOf = string | Date | null
|
|
30
|
-
|
|
31
|
-
export interface Experience {
|
|
32
|
-
id: string
|
|
33
|
-
at: string
|
|
34
|
-
day: string
|
|
35
|
-
author?: string
|
|
36
|
-
source?: string
|
|
37
|
-
kind: string
|
|
38
|
-
weight: Weight
|
|
39
|
-
then: {
|
|
40
|
-
text: string
|
|
41
|
-
scene?: string
|
|
42
|
-
feeling?: string[]
|
|
43
|
-
thought?: string
|
|
44
|
-
unfinished?: string
|
|
45
|
-
quote?: Quote | null
|
|
46
|
-
state?: Record<string, unknown> | null
|
|
47
|
-
/** 这条是从哪几件事想到的(经历 id,写入时校验过存在) */
|
|
48
|
-
refs?: string[]
|
|
49
|
-
}
|
|
50
|
-
later: LaterEntry[]
|
|
51
|
-
/** 由 then.refs 派生:出处的摘要 */
|
|
52
|
-
refsInfo?: ExperienceBrief[]
|
|
53
|
-
/** 反向引用:后来有哪些回想把这条写进了出处 */
|
|
54
|
-
citedBy?: ExperienceBrief[]
|
|
55
|
-
/** 用 asOf 读出来时,截到的那一刻(ISO) */
|
|
56
|
-
viewAsOf?: string
|
|
57
|
-
/** 她封存了这件事(0.13 起):不会被召回、不进醒来块,但还在 */
|
|
58
|
-
sealed?: { at: string; day: string; note: string }
|
|
59
|
-
/** 事后联想(0.14 起):她亲手连起来的另一件事,两头都能看到 */
|
|
60
|
-
links?: Array<ExperienceBrief & { reason: string; linkDay: string }>
|
|
61
|
-
/** 这一天落在她起过名字的哪段日子里(0.14 起) */
|
|
62
|
-
chapters?: Array<{ id: string; name: string }>
|
|
63
|
-
recalls?: number
|
|
64
|
-
lastRecalledAt?: string
|
|
65
|
-
matchedIn?: Array<'then' | 'quote' | 'later'>
|
|
66
|
-
/** 没弄完的事后来怎么样了:done=想通,shelved=先放下,reopen=又接着想 */
|
|
67
|
-
unfinishedState?: {
|
|
68
|
-
id: string
|
|
69
|
-
at: string
|
|
70
|
-
day: string
|
|
71
|
-
choice: 'done' | 'shelved' | 'reopen'
|
|
72
|
-
note: string
|
|
73
|
-
/** 完整的选择历史,按追加顺序 */
|
|
74
|
-
history: Array<'done' | 'shelved' | 'reopen'>
|
|
75
|
-
}
|
|
76
|
-
/** recall 返回:是哪几条后记让这条被想起 */
|
|
77
|
-
matchedLater?: LaterEntry[]
|
|
78
|
-
/** 0.10.0 之前的旧 id(只在唯一对应时出现);用它也能 revise / currentView */
|
|
79
|
-
formerId?: string
|
|
80
|
-
status?: string
|
|
81
|
-
legacy?: boolean
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const LIMITS: Record<string, number>
|
|
85
|
-
|
|
86
|
-
export function loadAll(dir: string, opts?: { asOf?: AsOf }): Experience[]
|
|
87
|
-
|
|
88
|
-
export function addExperience(dir: string, opts: {
|
|
89
|
-
text: string
|
|
90
|
-
scene?: string
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
id: string
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
1
|
+
export type Weight = 'important' | 'normal' | 'minor'
|
|
2
|
+
|
|
3
|
+
export interface Quote {
|
|
4
|
+
text: string
|
|
5
|
+
source?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface LaterEntry {
|
|
9
|
+
at: string
|
|
10
|
+
day?: string
|
|
11
|
+
thought: string
|
|
12
|
+
reason?: string
|
|
13
|
+
/** 她后来再想起时的感觉(0.12 起);当时的感觉在 then.feeling 里,永远不动 */
|
|
14
|
+
feeling?: string[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** 出处 / 反向引用里的一条:指路用的一句话摘要 */
|
|
18
|
+
export interface ExperienceBrief {
|
|
19
|
+
id: string
|
|
20
|
+
day?: string
|
|
21
|
+
text?: string
|
|
22
|
+
/** 出处指向的经历找不到了(例如只恢复了部分文件) */
|
|
23
|
+
missing?: boolean
|
|
24
|
+
/** 那条经历她封存了:不给摘要 */
|
|
25
|
+
sealed?: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 「翻回那天的自己」:2026-11-15(截到那天本地时间的最后一刻)、完整 ISO 时间或 Date */
|
|
29
|
+
export type AsOf = string | Date | null
|
|
30
|
+
|
|
31
|
+
export interface Experience {
|
|
32
|
+
id: string
|
|
33
|
+
at: string
|
|
34
|
+
day: string
|
|
35
|
+
author?: string
|
|
36
|
+
source?: string
|
|
37
|
+
kind: string
|
|
38
|
+
weight: Weight
|
|
39
|
+
then: {
|
|
40
|
+
text: string
|
|
41
|
+
scene?: string
|
|
42
|
+
feeling?: string[]
|
|
43
|
+
thought?: string
|
|
44
|
+
unfinished?: string
|
|
45
|
+
quote?: Quote | null
|
|
46
|
+
state?: Record<string, unknown> | null
|
|
47
|
+
/** 这条是从哪几件事想到的(经历 id,写入时校验过存在) */
|
|
48
|
+
refs?: string[]
|
|
49
|
+
}
|
|
50
|
+
later: LaterEntry[]
|
|
51
|
+
/** 由 then.refs 派生:出处的摘要 */
|
|
52
|
+
refsInfo?: ExperienceBrief[]
|
|
53
|
+
/** 反向引用:后来有哪些回想把这条写进了出处 */
|
|
54
|
+
citedBy?: ExperienceBrief[]
|
|
55
|
+
/** 用 asOf 读出来时,截到的那一刻(ISO) */
|
|
56
|
+
viewAsOf?: string
|
|
57
|
+
/** 她封存了这件事(0.13 起):不会被召回、不进醒来块,但还在 */
|
|
58
|
+
sealed?: { at: string; day: string; note: string }
|
|
59
|
+
/** 事后联想(0.14 起):她亲手连起来的另一件事,两头都能看到 */
|
|
60
|
+
links?: Array<ExperienceBrief & { reason: string; linkDay: string }>
|
|
61
|
+
/** 这一天落在她起过名字的哪段日子里(0.14 起) */
|
|
62
|
+
chapters?: Array<{ id: string; name: string }>
|
|
63
|
+
recalls?: number
|
|
64
|
+
lastRecalledAt?: string
|
|
65
|
+
matchedIn?: Array<'then' | 'quote' | 'later'>
|
|
66
|
+
/** 没弄完的事后来怎么样了:done=想通,shelved=先放下,reopen=又接着想 */
|
|
67
|
+
unfinishedState?: {
|
|
68
|
+
id: string
|
|
69
|
+
at: string
|
|
70
|
+
day: string
|
|
71
|
+
choice: 'done' | 'shelved' | 'reopen'
|
|
72
|
+
note: string
|
|
73
|
+
/** 完整的选择历史,按追加顺序 */
|
|
74
|
+
history: Array<'done' | 'shelved' | 'reopen'>
|
|
75
|
+
}
|
|
76
|
+
/** recall 返回:是哪几条后记让这条被想起 */
|
|
77
|
+
matchedLater?: LaterEntry[]
|
|
78
|
+
/** 0.10.0 之前的旧 id(只在唯一对应时出现);用它也能 revise / currentView */
|
|
79
|
+
formerId?: string
|
|
80
|
+
status?: string
|
|
81
|
+
legacy?: boolean
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const LIMITS: Record<string, number>
|
|
85
|
+
|
|
86
|
+
export function loadAll(dir: string, opts?: { asOf?: AsOf }): Experience[]
|
|
87
|
+
|
|
88
|
+
export function addExperience(dir: string, opts: {
|
|
89
|
+
text: string
|
|
90
|
+
scene?: string
|
|
91
|
+
/** 数组,或逗号分隔的字符串(, , 、);去空白、去重 */
|
|
92
|
+
feeling?: string[] | string
|
|
93
|
+
thought?: string
|
|
94
|
+
unfinished?: string
|
|
95
|
+
quote?: Quote | null
|
|
96
|
+
weight?: Weight
|
|
97
|
+
kind?: string
|
|
98
|
+
state?: Record<string, unknown> | null
|
|
99
|
+
source?: string
|
|
100
|
+
/** 出处:数组,或逗号分隔的字符串;引用不存在的经历会抛错,整条不写 */
|
|
101
|
+
refs?: string[] | string
|
|
102
|
+
}): Experience
|
|
103
|
+
|
|
104
|
+
export function reviseExperience(dir: string, opts: { id: string; thought: string; reason?: string; feeling?: string[] | string }): {
|
|
105
|
+
ok: boolean
|
|
106
|
+
id?: string
|
|
107
|
+
at?: string
|
|
108
|
+
feeling?: string[]
|
|
109
|
+
error?: string
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function markRecalled(dir: string, id: string): boolean
|
|
113
|
+
|
|
114
|
+
export function currentView(dir: string, id: string, opts?: { asOf?: AsOf }): Experience | null
|
|
115
|
+
|
|
116
|
+
export function recall(dir: string, query: string, opts?: {
|
|
117
|
+
limit?: number
|
|
118
|
+
minOverlap?: number
|
|
119
|
+
mark?: boolean
|
|
120
|
+
minRatio?: number
|
|
121
|
+
mode?: 'strict' | 'loose'
|
|
122
|
+
/** 在那天的自己里找;不能和 mark 一起用 */
|
|
123
|
+
asOf?: AsOf
|
|
124
|
+
/** 默认不召回她封存了的经历;只在"她自己要翻"时打开 */
|
|
125
|
+
includeSealed?: boolean
|
|
126
|
+
/** strict 用哪套门槛:cover(默认,0.17 起)或 legacy(0.16 及以前,结果逐条一致) */
|
|
127
|
+
gate?: 'cover' | 'legacy'
|
|
128
|
+
}): Experience[]
|
|
129
|
+
|
|
130
|
+
/** 事后联想:两条都必须存在、必须写理由;同一对(不分方向)只连一次 */
|
|
131
|
+
export function linkExperiences(dir: string, opts: { from: string; to: string; reason: string }): {
|
|
132
|
+
ok: boolean
|
|
133
|
+
from?: string
|
|
134
|
+
to?: string
|
|
135
|
+
noop?: boolean
|
|
136
|
+
at?: string
|
|
137
|
+
error?: string
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** 封存 / 解封:不删除任何东西;重复同一个动作是 noop */
|
|
141
|
+
export function setSealed(dir: string, opts: { id: string; sealed?: boolean; note?: string }): {
|
|
142
|
+
ok: boolean
|
|
143
|
+
id?: string
|
|
144
|
+
sealed?: boolean
|
|
145
|
+
at?: string
|
|
146
|
+
noop?: boolean
|
|
147
|
+
error?: string
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** lang:'zh'(默认)或 'en',只换标签,她写下的内容原样 */
|
|
151
|
+
export function renderTwoPart(entry: Experience, opts?: { now?: Date; lang?: 'zh' | 'en' }): string
|
|
152
|
+
|
|
153
|
+
export interface PendingLegacyEvents {
|
|
154
|
+
/** 几条旧经历共用的旧 id */
|
|
155
|
+
id: string
|
|
156
|
+
/** 可能的归属(当前 id) */
|
|
157
|
+
candidates: string[]
|
|
158
|
+
later: number
|
|
159
|
+
recalls: number
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function pendingLegacyEvents(dir: string): PendingLegacyEvents[]
|
|
163
|
+
|
|
164
|
+
export function setUnfinishedState(
|
|
165
|
+
dir: string,
|
|
166
|
+
opts: { id: string; choice: 'done' | 'shelved' | 'reopen'; note?: string }
|
|
167
|
+
): { ok: boolean; id?: string; at?: string; choice?: string; noop?: boolean; error?: string }
|
|
168
|
+
|
|
169
|
+
export interface RecallContextItem {
|
|
170
|
+
id: string
|
|
171
|
+
day: string
|
|
172
|
+
text: string
|
|
173
|
+
thought: string
|
|
174
|
+
weight: Weight
|
|
175
|
+
raw: Experience
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 宿主拿用户原话自动召回用;默认 gate 为 legacy,升级不改变自动递回的行为 */
|
|
179
|
+
export function recallForContext(dir: string, query: string, opts?: { max?: number; gate?: 'cover' | 'legacy' }): RecallContextItem[]
|
|
180
|
+
|
|
176
181
|
export const internals: { WEIGHTS: Set<Weight>; FILE: string }
|