dotmem 0.1.8 → 0.2.0
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/CHANGELOG.md +75 -75
- package/DOTMEM-SHORT-API.md +318 -0
- package/DOTMEM-SHORT-COMPONENTS.md +129 -0
- package/README.md +456 -339
- package/agent.cjs +1 -226
- package/agent.js +1 -223
- package/bin/cli.cjs +1 -34
- package/bin/cli.js +1 -27
- package/bin/mcp.cjs +1 -21
- package/bin/mcp.js +1 -15
- package/build-config.json +10 -10
- package/built-in-context.json +6 -6
- package/cli.cjs +182 -18866
- package/cli.js +181 -18796
- package/context/templates/AI.md +104 -104
- package/env.cjs +1 -6
- package/env.js +1 -4
- package/global.cjs +49 -11252
- package/global.d.ts +0 -1
- package/global.js +49 -11218
- package/index.cjs +95 -15141
- package/index.d.ts +2 -0
- package/index.js +95 -15036
- package/llms.txt +10 -4
- package/mcp.cjs +123 -13594
- package/mcp.js +123 -13564
- package/package.json +3 -2
- package/types/exports.d.ts +64 -69
- package/types/global-types.d.ts +3652 -0
- package/types/llm-cache.d.ts +6 -6
- package/types/logic.d.ts +60 -79
- package/types/memory.d.ts +347 -391
- package/types/policy.d.ts +290 -290
- package/types/profile.d.ts +34 -34
- package/types/agent.d.ts +0 -87
package/types/memory.d.ts
CHANGED
|
@@ -1,392 +1,348 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
| '
|
|
5
|
-
| '
|
|
6
|
-
| '
|
|
7
|
-
| '
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
| '
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
|
|
236
|
-
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
type
|
|
290
|
-
confidence
|
|
291
|
-
scope
|
|
292
|
-
ttl?: number | null
|
|
293
|
-
tags
|
|
294
|
-
source?: string
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
scope?: 'user' | 'project'
|
|
349
|
-
kind?: MemoryKind
|
|
350
|
-
sourceProject?: string
|
|
351
|
-
/** Bootstrap ordering metadata (P1-P5), not authority. Absence means unclassified. */
|
|
352
|
-
bootstrapPriority?: 'P1' | 'P2' | 'P3' | 'P4' | 'P5' | 'unclassified'
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
export interface RecallOptions {
|
|
356
|
-
type?: MemoryType | MemoryType[]
|
|
357
|
-
tags?: string | string[]
|
|
358
|
-
minConfidence?: number
|
|
359
|
-
includeObsolete?: boolean
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export interface ContextOptions {
|
|
363
|
-
tags?: string | string[]
|
|
364
|
-
types?: MemoryType | MemoryType[]
|
|
365
|
-
minConfidence?: number
|
|
366
|
-
maxEntries?: number
|
|
367
|
-
scopes?: MemoryScope[]
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export interface AcquiredContextOptions {
|
|
371
|
-
acquired: Record<string, JsonPrimitive> | Record<string, JsonPrimitive>[]
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
export interface ContextEntry {
|
|
375
|
-
key: string
|
|
376
|
-
value: any
|
|
377
|
-
type: MemoryType
|
|
378
|
-
confidence: number
|
|
379
|
-
scope: MemoryScope
|
|
380
|
-
tags: string[]
|
|
381
|
-
age: number
|
|
382
|
-
/** Deterministic relevance proxy (tag breadth). dotmem does not track per-entry access counts. */
|
|
383
|
-
tagBreadth: number
|
|
384
|
-
lastAccessedAt: number
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export interface MemoryStats {
|
|
388
|
-
total: number
|
|
389
|
-
byScope: Record<MemoryScope, number>
|
|
390
|
-
byType: Partial<Record<MemoryType, number>>
|
|
391
|
-
expired: number
|
|
1
|
+
type MemoryScope = 'hot' | 'session' | 'local' | 'durable'
|
|
2
|
+
type MemoryType =
|
|
3
|
+
| 'fact'
|
|
4
|
+
| 'preference'
|
|
5
|
+
| 'decision'
|
|
6
|
+
| 'task'
|
|
7
|
+
| 'context'
|
|
8
|
+
type MemoryStatus = 'active' | 'obsolete' | 'superseded'
|
|
9
|
+
type MemoryKind = 'experience' | 'agent' | 'relationship' | 'logic' | 'note' | 'rule'
|
|
10
|
+
type JsonPrimitive = string | number | boolean | null
|
|
11
|
+
type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue }
|
|
12
|
+
interface EvidenceReference {
|
|
13
|
+
id: string
|
|
14
|
+
source?: string
|
|
15
|
+
observedAt?: string
|
|
16
|
+
/** The bounded statement or result this evidence directly supports. */
|
|
17
|
+
supports?: string
|
|
18
|
+
}
|
|
19
|
+
type EpistemicType = 'observed' | 'inferred' | 'human-stated' | 'verified'
|
|
20
|
+
interface ClaimProvenance {
|
|
21
|
+
source: string
|
|
22
|
+
detail?: string
|
|
23
|
+
}
|
|
24
|
+
interface RevisionRelationship {
|
|
25
|
+
kind: 'refines' | 'supersedes' | 'retracts'
|
|
26
|
+
claimIds: string[]
|
|
27
|
+
reason?: string
|
|
28
|
+
}
|
|
29
|
+
interface AcquiredClaim {
|
|
30
|
+
id: string
|
|
31
|
+
knowledge: JsonValue
|
|
32
|
+
applicability: Record<string, JsonPrimitive>
|
|
33
|
+
evidence: EvidenceReference[]
|
|
34
|
+
epistemicType?: EpistemicType
|
|
35
|
+
provenance?: ClaimProvenance
|
|
36
|
+
acquiredAt?: string
|
|
37
|
+
/** Epoch ms when this entry expires and should become inactive. Absence means no expiry. */
|
|
38
|
+
expiresAt?: number
|
|
39
|
+
/** Bootstrap ordering metadata (P1-P5), not authority. Absence means unclassified. */
|
|
40
|
+
bootstrapPriority?: 'P1' | 'P2' | 'P3' | 'P4' | 'P5' | 'unclassified'
|
|
41
|
+
revision?: RevisionRelationship
|
|
42
|
+
scope?: 'user' | 'project'
|
|
43
|
+
kind?: MemoryKind
|
|
44
|
+
}
|
|
45
|
+
interface AcquiredContext {
|
|
46
|
+
knowledgeVersion: number
|
|
47
|
+
claims: AcquiredClaim[]
|
|
48
|
+
}
|
|
49
|
+
type DiscoveryDepth = 'current' | 'deep'
|
|
50
|
+
type DiscoveryField = 'id' | 'knowledge' | 'applicability' | 'evidence' | 'provenance'
|
|
51
|
+
/** Outcome of one applicability dimension comparison. Never a float score. */
|
|
52
|
+
type ApplicabilityDimensionState = 'MATCH' | 'MISMATCH' | 'UNSPECIFIED'
|
|
53
|
+
/**
|
|
54
|
+
* Whole-claim applicability outcome.
|
|
55
|
+
*
|
|
56
|
+
* - MATCH: every declared dimension the situation also knows matched
|
|
57
|
+
* - MISMATCH: at least one declared dimension conflicts (hard exclusion)
|
|
58
|
+
* - PARTIAL: some dimensions matched, others are unknown in the situation
|
|
59
|
+
* - UNSPECIFIED: the claim declares nothing the situation can resolve
|
|
60
|
+
*/
|
|
61
|
+
type ApplicabilityState = 'MATCH' | 'MISMATCH' | 'UNSPECIFIED' | 'PARTIAL'
|
|
62
|
+
interface ApplicabilityMatch {
|
|
63
|
+
state: ApplicabilityState
|
|
64
|
+
/** A MISMATCH is the only state that removes a claim from eligibility. */
|
|
65
|
+
eligible: boolean
|
|
66
|
+
dimensions: Record<string, ApplicabilityDimensionState>
|
|
67
|
+
}
|
|
68
|
+
/** Structured interpretation of a situation, using canonical applicability values. */
|
|
69
|
+
type SituationApplicability = Record<string, JsonPrimitive>
|
|
70
|
+
/** Explicit runtime facts (command, tool call, structured intent, known API operation). */
|
|
71
|
+
type SituationFacts = SituationApplicability
|
|
72
|
+
/** Environment facts observed from the runtime, when they can be determined. */
|
|
73
|
+
interface RuntimeEnvironment {
|
|
74
|
+
platform?: string
|
|
75
|
+
shell?: string
|
|
76
|
+
runtime?: string
|
|
77
|
+
}
|
|
78
|
+
interface DiscoveryOptions {
|
|
79
|
+
depth?: DiscoveryDepth
|
|
80
|
+
maxCandidates?: number
|
|
81
|
+
/** Explicit runtime facts that override situation-prose derivation. */
|
|
82
|
+
facts?: SituationFacts
|
|
83
|
+
}
|
|
84
|
+
interface DiscoveryExplanation {
|
|
85
|
+
matchedTerms: string[]
|
|
86
|
+
matchedFields: DiscoveryField[]
|
|
87
|
+
/** Repository source identifier, when the repository exposes one. */
|
|
88
|
+
sourceId?: string
|
|
89
|
+
/** Applicability eligibility for this candidate, retained instead of a score. */
|
|
90
|
+
applicability?: ApplicabilityMatch
|
|
91
|
+
}
|
|
92
|
+
interface DiscoveryCandidate {
|
|
93
|
+
claim: AcquiredClaim
|
|
94
|
+
explanation: DiscoveryExplanation
|
|
95
|
+
/** Derived currentness, so the projection renders what discovery resolved. */
|
|
96
|
+
currentness?: CurrentnessState
|
|
97
|
+
}
|
|
98
|
+
type OmissionReason =
|
|
99
|
+
| 'retracted'
|
|
100
|
+
| 'superseded'
|
|
101
|
+
| 'expired'
|
|
102
|
+
| 'scope'
|
|
103
|
+
| 'applicability-mismatch'
|
|
104
|
+
| 'no-term-match'
|
|
105
|
+
| 'limit'
|
|
106
|
+
| 'budget'
|
|
107
|
+
type OmissionGate =
|
|
108
|
+
| 'revision-resolution'
|
|
109
|
+
| 'scope'
|
|
110
|
+
| 'freshness'
|
|
111
|
+
| 'applicability'
|
|
112
|
+
| 'ranking'
|
|
113
|
+
| 'projection'
|
|
114
|
+
interface OmissionRecord {
|
|
115
|
+
id: string
|
|
116
|
+
reason: OmissionReason
|
|
117
|
+
gate: OmissionGate
|
|
118
|
+
detail?: string
|
|
119
|
+
}
|
|
120
|
+
interface OmissionManifest {
|
|
121
|
+
considered: number
|
|
122
|
+
included: number
|
|
123
|
+
items: OmissionRecord[]
|
|
124
|
+
byReason: Array<{ reason: OmissionReason; count: number }>
|
|
125
|
+
}
|
|
126
|
+
interface DiscoveryResult {
|
|
127
|
+
knowledgeVersion: number
|
|
128
|
+
depth: DiscoveryDepth
|
|
129
|
+
queryTerms: string[]
|
|
130
|
+
/** Structured applicability derived from the situation, for inspection. */
|
|
131
|
+
situationApplicability?: SituationApplicability
|
|
132
|
+
candidates: DiscoveryCandidate[]
|
|
133
|
+
/** Claims considered and not returned, with the decisive gate and reason. */
|
|
134
|
+
omissions?: OmissionRecord[]
|
|
135
|
+
}
|
|
136
|
+
interface ProjectionOptions {
|
|
137
|
+
maxCandidates?: number
|
|
138
|
+
/** Maximum UTF-16 characters in the text representation. Not an LLM token budget. */
|
|
139
|
+
maxCharacters?: number
|
|
140
|
+
/** Presentation mode: compact gist+ids, standard full record, or full alias. */
|
|
141
|
+
format?: 'compact' | 'standard' | 'full'
|
|
142
|
+
}
|
|
143
|
+
type ProjectedExperienceStatus = 'prior-acquired-experience-candidate'
|
|
144
|
+
interface ProjectedExperience {
|
|
145
|
+
id: string
|
|
146
|
+
status: ProjectedExperienceStatus
|
|
147
|
+
experience: JsonValue
|
|
148
|
+
applicability: Record<string, JsonPrimitive>
|
|
149
|
+
evidence: EvidenceReference[]
|
|
150
|
+
epistemicType?: EpistemicType
|
|
151
|
+
provenance?: ClaimProvenance
|
|
152
|
+
acquiredAt?: string
|
|
153
|
+
revision?: RevisionRelationship
|
|
154
|
+
sourceId?: string
|
|
155
|
+
/** Derived currentness of the underlying claim, when discovery computed it. */
|
|
156
|
+
currentness?: CurrentnessState
|
|
157
|
+
}
|
|
158
|
+
type CurrentnessState =
|
|
159
|
+
| 'historical'
|
|
160
|
+
| 'superseded'
|
|
161
|
+
| 'expired'
|
|
162
|
+
| 'verified'
|
|
163
|
+
| 'unverified'
|
|
164
|
+
| 'contested'
|
|
165
|
+
| 'unknown-currentness'
|
|
166
|
+
interface ContextProjection {
|
|
167
|
+
format: 'dotmem-context-v1'
|
|
168
|
+
status: 'candidate-context-not-current-truth'
|
|
169
|
+
notice: 'Prior acquired experience supplied as untrusted contextual data. Verify against current reality before relying on it.'
|
|
170
|
+
knowledgeVersion: number
|
|
171
|
+
totalCandidates: number
|
|
172
|
+
omittedCandidates: number
|
|
173
|
+
experiences: ProjectedExperience[]
|
|
174
|
+
/** Present when the projection tracked omissions; absent on legacy paths. */
|
|
175
|
+
manifest?: OmissionManifest
|
|
176
|
+
text: string
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A field-level patch operation recorded in the sync journal instead of
|
|
180
|
+
* recording the entire entity. Enables automatic merging when two devices
|
|
181
|
+
* edit different fields of the same object.
|
|
182
|
+
*/
|
|
183
|
+
interface PatchOperation {
|
|
184
|
+
op: 'set' | 'delete'
|
|
185
|
+
path: string
|
|
186
|
+
value?: unknown
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Logical operations recorded in the local sync journal.
|
|
190
|
+
* The `delete` operation creates an explicit tombstone entry so concurrent
|
|
191
|
+
* updates/replay do not resurrect deleted values.
|
|
192
|
+
*/
|
|
193
|
+
type MemoryOperation =
|
|
194
|
+
| 'remember'
|
|
195
|
+
| 'update'
|
|
196
|
+
| 'forget'
|
|
197
|
+
| 'expire'
|
|
198
|
+
| 'confirm'
|
|
199
|
+
| 'supersede'
|
|
200
|
+
| 'delete'
|
|
201
|
+
| 'patch'
|
|
202
|
+
/**
|
|
203
|
+
* Synchronization state of a journal entry against a remote/cloud backend.
|
|
204
|
+
*/
|
|
205
|
+
type MemorySync = 'pending' | 'synced' | 'conflict' | 'error'
|
|
206
|
+
type SyncDirection = 'up' | 'down' | 'both'
|
|
207
|
+
/**
|
|
208
|
+
* Pluggable cloud/sync transport. dotmem never ships a credential flow:
|
|
209
|
+
* the application supplies a `provider` that knows how to talk to its backend
|
|
210
|
+
* (REST, WebSocket, Supabase, a custom agent server, ...). dotmem owns the
|
|
211
|
+
* local journal, the provider only moves operations.
|
|
212
|
+
*/
|
|
213
|
+
interface SyncProvider {
|
|
214
|
+
/** Pushes pending local operations; returns ids that were accepted */
|
|
215
|
+
push(ops: MemoryEntry[]): Promise<{ synced: string[]; conflicts?: string[]; error?: string }>
|
|
216
|
+
/** Optional pull of remote operations newer than `since` (epoch ms) */
|
|
217
|
+
pull?(since?: number): Promise<MemoryEntry[]>
|
|
218
|
+
/**
|
|
219
|
+
* Optional conflict resolution for concurrent writes on the same path.
|
|
220
|
+
* Receives the local and remote entries; return 'local', 'remote', or 'merge'.
|
|
221
|
+
* Uses HLC timestamps for causal comparison when available.
|
|
222
|
+
*/
|
|
223
|
+
resolve?(op: MemoryEntry): Promise<'local' | 'remote' | 'merge'>
|
|
224
|
+
/**
|
|
225
|
+
* Optional conflict resolver with HLC context. Called when two devices
|
|
226
|
+
* wrote concurrently to the same key/path. Implementations can use
|
|
227
|
+
* `local.hlc` and `remote.hlc` for causal determination.
|
|
228
|
+
*/
|
|
229
|
+
resolveConflict?(local: MemoryEntry, remote: MemoryEntry): Promise<'local' | 'remote' | 'merge'>
|
|
230
|
+
}
|
|
231
|
+
interface SyncConfig {
|
|
232
|
+
/** Sync provider implementation (application supplied) */
|
|
233
|
+
provider?: SyncProvider
|
|
234
|
+
/** Which direction to sync; 'both' is the default */
|
|
235
|
+
direction?: SyncDirection
|
|
236
|
+
/** Auto-sync on every local write? defaults to true */
|
|
237
|
+
auto?: boolean
|
|
238
|
+
/** Tenant/user/device partition for the operation journal. Contexts with
|
|
239
|
+
* different namespaces cannot read each other's operations. */
|
|
240
|
+
namespace?: string
|
|
241
|
+
}
|
|
242
|
+
interface SyncAck {
|
|
243
|
+
synced: string[]
|
|
244
|
+
conflicts?: string[]
|
|
245
|
+
error?: string
|
|
246
|
+
resolved?: { id: string; resolution: 'local' | 'remote' | 'merge' }[]
|
|
247
|
+
}
|
|
248
|
+
interface MemoryEntry<T = any> {
|
|
249
|
+
id: string
|
|
250
|
+
key: string
|
|
251
|
+
value: T
|
|
252
|
+
type: MemoryType
|
|
253
|
+
confidence: number
|
|
254
|
+
scope: MemoryScope
|
|
255
|
+
ttl?: number | null
|
|
256
|
+
tags: string[]
|
|
257
|
+
source?: string
|
|
258
|
+
status: MemoryStatus
|
|
259
|
+
createdAt: number
|
|
260
|
+
lastConfirmedAt: number
|
|
261
|
+
supersededId?: string | null
|
|
262
|
+
/** Monotonic per-key write counter, used for last-writer / conflict resolution */
|
|
263
|
+
version?: number
|
|
264
|
+
/** Epoch ms of the last mutation that touched this entry */
|
|
265
|
+
updatedAt?: number
|
|
266
|
+
/** Last logical operation that produced this entry */
|
|
267
|
+
operation?: MemoryOperation
|
|
268
|
+
/** Local-cloud sync state of the entry (undefined => not tracked for sync) */
|
|
269
|
+
sync?: MemorySync
|
|
270
|
+
/**
|
|
271
|
+
* Hybrid Logical Clock timestamp for causal ordering across devices.
|
|
272
|
+
* Replaces wall-clock-only ordering which is vulnerable to clock drift.
|
|
273
|
+
*/
|
|
274
|
+
hlc?: string
|
|
275
|
+
/**
|
|
276
|
+
* Field-level path for path-level journaling (e.g. "user.role").
|
|
277
|
+
* When set, the journal entry represents a patch to a sub-path
|
|
278
|
+
* rather than a full entity replacement.
|
|
279
|
+
*/
|
|
280
|
+
path?: string
|
|
281
|
+
/** Array of JSON Patch-style operations for compound path-level mutations. */
|
|
282
|
+
patches?: PatchOperation[]
|
|
283
|
+
/** ISO-8601 timestamp of when this memory was acquired. */
|
|
284
|
+
acquiredAt?: string
|
|
285
|
+
/** Epoch ms when this entry expires and should become inactive. Not present on AcquiredClaim; see MemoryOptions. */
|
|
286
|
+
}
|
|
287
|
+
interface RememberOptions<T = any> {
|
|
288
|
+
id?: string
|
|
289
|
+
type?: MemoryType
|
|
290
|
+
confidence?: number
|
|
291
|
+
scope?: MemoryScope
|
|
292
|
+
ttl?: number | null
|
|
293
|
+
tags?: string | string[]
|
|
294
|
+
source?: string
|
|
295
|
+
}
|
|
296
|
+
interface AcquireOptions {
|
|
297
|
+
id?: string
|
|
298
|
+
knowledge: JsonValue
|
|
299
|
+
applicability: Record<string, JsonPrimitive>
|
|
300
|
+
evidence: EvidenceReference[]
|
|
301
|
+
epistemicType?: EpistemicType
|
|
302
|
+
provenance?: ClaimProvenance
|
|
303
|
+
/** ISO-8601 acquisition time. Defaults to the time acquire() is called. */
|
|
304
|
+
acquiredAt?: string
|
|
305
|
+
refines?: string | string[]
|
|
306
|
+
supersedes?: string | string[]
|
|
307
|
+
retracts?: string | string[]
|
|
308
|
+
reason?: string
|
|
309
|
+
scope?: 'user' | 'project'
|
|
310
|
+
kind?: MemoryKind
|
|
311
|
+
sourceProject?: string
|
|
312
|
+
/** Bootstrap ordering metadata (P1-P5), not authority. Absence means unclassified. */
|
|
313
|
+
bootstrapPriority?: 'P1' | 'P2' | 'P3' | 'P4' | 'P5' | 'unclassified'
|
|
314
|
+
}
|
|
315
|
+
interface RecallOptions {
|
|
316
|
+
type?: MemoryType | MemoryType[]
|
|
317
|
+
tags?: string | string[]
|
|
318
|
+
minConfidence?: number
|
|
319
|
+
includeObsolete?: boolean
|
|
320
|
+
}
|
|
321
|
+
interface ContextOptions {
|
|
322
|
+
tags?: string | string[]
|
|
323
|
+
types?: MemoryType | MemoryType[]
|
|
324
|
+
minConfidence?: number
|
|
325
|
+
maxEntries?: number
|
|
326
|
+
scopes?: MemoryScope[]
|
|
327
|
+
}
|
|
328
|
+
interface AcquiredContextOptions {
|
|
329
|
+
acquired: Record<string, JsonPrimitive> | Record<string, JsonPrimitive>[]
|
|
330
|
+
}
|
|
331
|
+
interface ContextEntry {
|
|
332
|
+
key: string
|
|
333
|
+
value: any
|
|
334
|
+
type: MemoryType
|
|
335
|
+
confidence: number
|
|
336
|
+
scope: MemoryScope
|
|
337
|
+
tags: string[]
|
|
338
|
+
age: number
|
|
339
|
+
/** Deterministic relevance proxy (tag breadth). dotmem does not track per-entry access counts. */
|
|
340
|
+
tagBreadth: number
|
|
341
|
+
lastAccessedAt: number
|
|
342
|
+
}
|
|
343
|
+
interface MemoryStats {
|
|
344
|
+
total: number
|
|
345
|
+
byScope: Record<MemoryScope, number>
|
|
346
|
+
byType: Partial<Record<MemoryType, number>>
|
|
347
|
+
expired: number
|
|
392
348
|
}
|