@astratra/memory 0.1.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/LICENSE +21 -0
- package/README.md +239 -0
- package/package.json +39 -0
- package/src/consolidation.js +64 -0
- package/src/handlers.js +84 -0
- package/src/index.d.ts +398 -0
- package/src/index.js +10 -0
- package/src/memory.js +672 -0
- package/src/memoryStore.js +181 -0
- package/src/ranking.js +74 -0
- package/src/rules.js +153 -0
- package/src/testing/storeContract.js +194 -0
- package/src/tools.js +172 -0
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
type Awaitable<T> = T | Promise<T>;
|
|
2
|
+
|
|
3
|
+
/** Where a memory lives: one person, in one partition chosen by the consumer ('' for none). */
|
|
4
|
+
export interface MemoryWhere {
|
|
5
|
+
ownerId: string;
|
|
6
|
+
scope?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** A place as the store receives it: always both fields. */
|
|
10
|
+
export interface MemoryPlace {
|
|
11
|
+
ownerId: string;
|
|
12
|
+
scope: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type MemoryChannel = 'explicit' | 'auto' | 'background';
|
|
16
|
+
|
|
17
|
+
export interface MemorySource {
|
|
18
|
+
channel?: MemoryChannel | string;
|
|
19
|
+
ref?: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** What the store holds. `text` is ciphertext when a cipher is configured. */
|
|
24
|
+
export interface MemoryRecord {
|
|
25
|
+
id: string;
|
|
26
|
+
ownerId: string;
|
|
27
|
+
scope: string;
|
|
28
|
+
role: string | null;
|
|
29
|
+
text: string;
|
|
30
|
+
kind: string;
|
|
31
|
+
importance: number;
|
|
32
|
+
source: MemorySource;
|
|
33
|
+
vector: number[] | null;
|
|
34
|
+
vectorSource: string | null;
|
|
35
|
+
supersededBy: string | null;
|
|
36
|
+
seenAt: Date | null;
|
|
37
|
+
lastUsedAt: Date | null;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
updatedAt: Date;
|
|
40
|
+
/** Set by search() only. */
|
|
41
|
+
score?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What leaves the package: clear text, never the vector. */
|
|
45
|
+
export interface Memory {
|
|
46
|
+
id: string;
|
|
47
|
+
ownerId: string;
|
|
48
|
+
scope: string;
|
|
49
|
+
role: string | null;
|
|
50
|
+
text: string;
|
|
51
|
+
kind: string;
|
|
52
|
+
importance: number;
|
|
53
|
+
source: MemorySource;
|
|
54
|
+
supersededBy: string | null;
|
|
55
|
+
seenAt: Date | null;
|
|
56
|
+
lastUsedAt: Date | null;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
hasVector: boolean;
|
|
60
|
+
score?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface MemoryListFilter {
|
|
64
|
+
/** Default 'active' (not superseded). */
|
|
65
|
+
state?: 'active' | 'superseded' | 'all';
|
|
66
|
+
supersededBy?: string;
|
|
67
|
+
kinds?: string[];
|
|
68
|
+
channel?: string;
|
|
69
|
+
seen?: boolean;
|
|
70
|
+
createdAfter?: Date | null;
|
|
71
|
+
createdBefore?: Date | null;
|
|
72
|
+
limit?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface MemorySearchInput {
|
|
76
|
+
text: string;
|
|
77
|
+
vector: number[] | null;
|
|
78
|
+
vectorSource: string | null;
|
|
79
|
+
kinds?: string[];
|
|
80
|
+
createdAfter?: Date | null;
|
|
81
|
+
createdBefore?: Date | null;
|
|
82
|
+
limit?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The storage contract. Every method but purgeOwner and listNeedingVector
|
|
87
|
+
* is bound to one place and must never read or write outside it. Returned
|
|
88
|
+
* records are copies. Prove an adapter with runStoreContract().
|
|
89
|
+
*/
|
|
90
|
+
export interface MemoryStore {
|
|
91
|
+
insert(record: MemoryRecord): Awaitable<MemoryRecord>;
|
|
92
|
+
/** Any state, superseded included; null outside the place. */
|
|
93
|
+
get(where: MemoryPlace, id: string): Awaitable<MemoryRecord | null>;
|
|
94
|
+
/** Newest first by createdAt. */
|
|
95
|
+
list(where: MemoryPlace, filter?: MemoryListFilter): Awaitable<MemoryRecord[]>;
|
|
96
|
+
/** Never changes id, ownerId or scope. With onlyActive, null when the record is superseded (compare-and-set). */
|
|
97
|
+
update(where: MemoryPlace, id: string, patch: Partial<MemoryRecord>, options?: { onlyActive?: boolean }): Awaitable<MemoryRecord | null>;
|
|
98
|
+
remove(where: MemoryPlace, ids: string[]): Awaitable<number>;
|
|
99
|
+
removeAll(where: MemoryPlace): Awaitable<number>;
|
|
100
|
+
/** Every scope of one owner: memories, settings and consolidation marks. */
|
|
101
|
+
purgeOwner(ownerId: string): Awaitable<{ memories: number; settings: number; refs?: number }>;
|
|
102
|
+
getSettings(where: MemoryPlace): Awaitable<{ paused: boolean; [key: string]: unknown }>;
|
|
103
|
+
setSettings(where: MemoryPlace, patch: { paused?: boolean; [key: string]: unknown }): Awaitable<{ paused: boolean; [key: string]: unknown }>;
|
|
104
|
+
/** Optional: true the first time a ref is claimed in a place. */
|
|
105
|
+
claimRef?(where: MemoryPlace, ref: string): Awaitable<boolean>;
|
|
106
|
+
releaseRef?(where: MemoryPlace, ref: string): Awaitable<void>;
|
|
107
|
+
/** Optional: ranked candidates, active only; semantic compares vectors of `vectorSource` only. Ignored when a cipher is set. */
|
|
108
|
+
search?(where: MemoryPlace, input: MemorySearchInput): Awaitable<{ semantic: MemoryRecord[]; lexical: MemoryRecord[] }>;
|
|
109
|
+
/** Optional, every owner: active records without a vector, or (with source) from another source. */
|
|
110
|
+
listNeedingVector?(options: { limit?: number; source?: string }): Awaitable<MemoryRecord[]>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface Candidate {
|
|
114
|
+
text: string;
|
|
115
|
+
kind: string | null;
|
|
116
|
+
importance: number;
|
|
117
|
+
role: string | null;
|
|
118
|
+
explicit: boolean;
|
|
119
|
+
personName: string;
|
|
120
|
+
alreadyPresent?: string;
|
|
121
|
+
names?: string[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Returns a refusal code, or null/undefined to let the memory through. */
|
|
125
|
+
export type MemoryRule = (candidate: Candidate) => Awaitable<string | null | undefined>;
|
|
126
|
+
|
|
127
|
+
export type EmbedFunction = (
|
|
128
|
+
text: string,
|
|
129
|
+
options: { purpose: 'passage' | 'query'; source?: string }
|
|
130
|
+
) => Awaitable<number[] | { vector: number[]; source?: string }>;
|
|
131
|
+
|
|
132
|
+
export interface ConsolidationRequest {
|
|
133
|
+
system: string;
|
|
134
|
+
prompt: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type LlmFunction = (request: ConsolidationRequest & { purpose: string; where: MemoryPlace }) => Awaitable<string | Record<string, unknown>>;
|
|
138
|
+
|
|
139
|
+
export interface MemoryLogger {
|
|
140
|
+
info?(message: string): void;
|
|
141
|
+
warn?(message: string): void;
|
|
142
|
+
error?(message: string): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type TranscriptTurn = { role?: string; text?: string; content?: string };
|
|
146
|
+
|
|
147
|
+
export interface MemoryOptions {
|
|
148
|
+
store: MemoryStore;
|
|
149
|
+
/** Allowed kinds. Default DEFAULT_KINDS. */
|
|
150
|
+
kinds?: string[];
|
|
151
|
+
/** Other words a model may use for a kind: { alias: kind }. Folded (case, accents). */
|
|
152
|
+
kindAliases?: Record<string, string>;
|
|
153
|
+
/** Kind given to an unknown kind. Default null: refused with 'invalid_kind'. */
|
|
154
|
+
defaultKind?: string | null;
|
|
155
|
+
/** Kinds each role may keep; a role absent here may keep every kind. */
|
|
156
|
+
roleKinds?: Record<string, string[]>;
|
|
157
|
+
/** Content rules, in order, after the structural checks. */
|
|
158
|
+
rules?: MemoryRule[];
|
|
159
|
+
/** Names of other people that must not be written into this person's memories. */
|
|
160
|
+
namesOf?: (where: MemoryPlace, ctx?: unknown) => Awaitable<string[]>;
|
|
161
|
+
embed?: EmbedFunction;
|
|
162
|
+
/** Applied to every text sent to embed or to the model. Default identity. */
|
|
163
|
+
mask?: (text: string, where: MemoryPlace) => Awaitable<string>;
|
|
164
|
+
llm?: LlmFunction;
|
|
165
|
+
cipher?: { encrypt(text: string): Awaitable<string>; decrypt(value: string): Awaitable<string> };
|
|
166
|
+
now?: () => Date;
|
|
167
|
+
generateId?: () => string;
|
|
168
|
+
logger?: MemoryLogger;
|
|
169
|
+
/** Serialise writes for one place. Default: an in-process queue. */
|
|
170
|
+
withLock?: <T>(where: MemoryPlace, fn: () => Promise<T>) => Promise<T>;
|
|
171
|
+
/** Default 500. */
|
|
172
|
+
maxTextLength?: number;
|
|
173
|
+
/** Active memories per place. Default 300; 0 or null for no cap. */
|
|
174
|
+
maxActive?: number | null;
|
|
175
|
+
/** Cosine at or above which a new memory replaces an old one. Default 0.92. */
|
|
176
|
+
duplicateThreshold?: number;
|
|
177
|
+
/** Cosine below which a meaning match is dropped from recall. Default null (none). */
|
|
178
|
+
minSimilarity?: number | null;
|
|
179
|
+
consolidationPrompt?: (input: { kinds: string[]; known: Array<{ id: string; text: string }>; transcript: string; language?: string; role?: string }) => ConsolidationRequest;
|
|
180
|
+
/** The person asked for this fact to be remembered (lets rules with allowWhenExplicit pass). */
|
|
181
|
+
isExplicitFact?: (fact: { text: string; kind?: unknown; importance?: unknown }, transcript: unknown, where: MemoryPlace) => Awaitable<boolean>;
|
|
182
|
+
/** Known memories shown to the model. Default 60. */
|
|
183
|
+
knownForConsolidation?: number;
|
|
184
|
+
/** Characters of each known memory shown. Default 240. */
|
|
185
|
+
knownTextMax?: number;
|
|
186
|
+
/** Characters of transcript sent. Default 40000. */
|
|
187
|
+
transcriptMax?: number;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type Refusal = { ok: false; reason: string };
|
|
191
|
+
|
|
192
|
+
export interface RememberInput {
|
|
193
|
+
text: string;
|
|
194
|
+
kind: string;
|
|
195
|
+
importance?: number | string;
|
|
196
|
+
role?: string | null;
|
|
197
|
+
explicit?: boolean;
|
|
198
|
+
personName?: string;
|
|
199
|
+
channel?: MemoryChannel;
|
|
200
|
+
source?: Record<string, unknown>;
|
|
201
|
+
ctx?: unknown;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface RecallInput {
|
|
205
|
+
query: string;
|
|
206
|
+
kinds?: string[];
|
|
207
|
+
after?: string | Date;
|
|
208
|
+
before?: string | Date;
|
|
209
|
+
limit?: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface ConsolidateInput {
|
|
213
|
+
transcript: string | TranscriptTurn[];
|
|
214
|
+
ref?: string;
|
|
215
|
+
role?: string;
|
|
216
|
+
personName?: string;
|
|
217
|
+
language?: string;
|
|
218
|
+
source?: Record<string, unknown>;
|
|
219
|
+
ctx?: unknown;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface ConsolidateResult {
|
|
223
|
+
status: 'done' | 'already' | 'paused' | 'empty' | 'unavailable' | 'failed';
|
|
224
|
+
added: number;
|
|
225
|
+
corrected: number;
|
|
226
|
+
refused: number;
|
|
227
|
+
summary: string | null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface MemoryService {
|
|
231
|
+
remember(where: MemoryWhere, input: RememberInput): Promise<{ ok: true; memory: Memory; supersededId: string | null } | Refusal>;
|
|
232
|
+
recall(where: MemoryWhere, input: RecallInput | string): Promise<Memory[]>;
|
|
233
|
+
update(
|
|
234
|
+
where: MemoryWhere,
|
|
235
|
+
id: string,
|
|
236
|
+
changes: { text?: string; kind?: string; importance?: number | string },
|
|
237
|
+
options?: { personName?: string; explicit?: boolean; source?: Record<string, unknown>; ctx?: unknown }
|
|
238
|
+
): Promise<{ ok: true; memory: Memory; supersededId: string | null; unchanged?: boolean } | Refusal>;
|
|
239
|
+
undo(where: MemoryWhere, id: string): Promise<boolean>;
|
|
240
|
+
forget(where: MemoryWhere, id: string): Promise<boolean>;
|
|
241
|
+
eraseAll(where: MemoryWhere): Promise<number>;
|
|
242
|
+
purgeOwner(ownerId: string): Promise<{ memories: number; settings: number; refs?: number }>;
|
|
243
|
+
get(where: MemoryWhere, id: string): Promise<Memory | null>;
|
|
244
|
+
list(where: MemoryWhere, filter?: { kinds?: string[]; limit?: number }): Promise<Memory[]>;
|
|
245
|
+
listUnseen(where: MemoryWhere): Promise<Memory[]>;
|
|
246
|
+
markSeen(where: MemoryWhere, ids: string[]): Promise<number>;
|
|
247
|
+
isPaused(where: MemoryWhere): Promise<boolean>;
|
|
248
|
+
setPaused(where: MemoryWhere, paused: boolean): Promise<boolean>;
|
|
249
|
+
portrait(where: MemoryWhere, options?: PortraitOptions & { masked?: boolean }): Promise<string>;
|
|
250
|
+
consolidate(where: MemoryWhere, input: ConsolidateInput): Promise<ConsolidateResult>;
|
|
251
|
+
reindex(options?: { limit?: number; source?: string }): Promise<{ updated: number; failed: number }>;
|
|
252
|
+
readonly kinds: readonly string[];
|
|
253
|
+
normalizeKind(value: unknown, fallback?: string | null): string | null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function createMemory(options: MemoryOptions): MemoryService;
|
|
257
|
+
|
|
258
|
+
export class MemoryError extends Error {
|
|
259
|
+
constructor(code: string, message?: string);
|
|
260
|
+
code: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export const DEFAULT_KINDS: readonly string[];
|
|
264
|
+
export const CHANNELS: Readonly<{ EXPLICIT: 'explicit'; AUTO: 'auto'; BACKGROUND: 'background' }>;
|
|
265
|
+
export const REASONS: Readonly<{
|
|
266
|
+
EMPTY: 'empty';
|
|
267
|
+
TOO_LONG: 'too_long';
|
|
268
|
+
INVALID_KIND: 'invalid_kind';
|
|
269
|
+
KIND_NOT_ALLOWED: 'kind_not_allowed';
|
|
270
|
+
OTHER_PERSON: 'other_person';
|
|
271
|
+
PAUSED: 'paused';
|
|
272
|
+
NOT_FOUND: 'not_found';
|
|
273
|
+
CONFLICT: 'conflict';
|
|
274
|
+
AI_DISABLED: 'ai_disabled';
|
|
275
|
+
}>;
|
|
276
|
+
|
|
277
|
+
export function createMemoryStore(): MemoryStore & {
|
|
278
|
+
claimRef(where: MemoryPlace, ref: string): Promise<boolean>;
|
|
279
|
+
releaseRef(where: MemoryPlace, ref: string): Promise<void>;
|
|
280
|
+
search(where: MemoryPlace, input: MemorySearchInput): Promise<{ semantic: MemoryRecord[]; lexical: MemoryRecord[] }>;
|
|
281
|
+
listNeedingVector(options: { limit?: number; source?: string }): Promise<MemoryRecord[]>;
|
|
282
|
+
size(): number;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/* ---- rules and helpers ---- */
|
|
286
|
+
|
|
287
|
+
export function fold(value: unknown): string;
|
|
288
|
+
export function wordsOf(value: unknown): string;
|
|
289
|
+
export function cleanText(value: unknown): string;
|
|
290
|
+
export function normalizeKind(value: unknown, options?: { kinds?: string[]; aliases?: Record<string, string>; fallback?: string | null }): string | null;
|
|
291
|
+
export function normalizeImportance(value: unknown, fallback?: number): number;
|
|
292
|
+
export function mentionsName(text: string, name: string): boolean;
|
|
293
|
+
export function patternRule(options: {
|
|
294
|
+
code: string;
|
|
295
|
+
patterns: RegExp[];
|
|
296
|
+
roles?: string[];
|
|
297
|
+
exceptRoles?: string[];
|
|
298
|
+
allowWhenExplicit?: boolean;
|
|
299
|
+
}): MemoryRule;
|
|
300
|
+
export function checkCandidate(
|
|
301
|
+
candidate: Candidate,
|
|
302
|
+
config: { kinds: string[]; roleKinds: Record<string, string[]>; rules: MemoryRule[]; maxTextLength: number }
|
|
303
|
+
): Promise<string | null>;
|
|
304
|
+
|
|
305
|
+
export interface PortraitOptions {
|
|
306
|
+
/** Default 1200. */
|
|
307
|
+
maxLength?: number;
|
|
308
|
+
/** Default 4. */
|
|
309
|
+
minImportance?: number;
|
|
310
|
+
format?: (memory: { text: string; importance: number }) => string;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export function cosine(a: number[], b: number[]): number;
|
|
314
|
+
export function keywordScore(query: string, text: string): number;
|
|
315
|
+
export function fuseByRank(lists: string[][], k?: number): string[];
|
|
316
|
+
export function buildPortrait(
|
|
317
|
+
memories: Array<{ text: string; importance: number; lastUsedAt?: Date | string | null; createdAt?: Date | string | null }>,
|
|
318
|
+
options?: PortraitOptions
|
|
319
|
+
): string;
|
|
320
|
+
|
|
321
|
+
export function parseModelJson(value: unknown): Record<string, unknown>;
|
|
322
|
+
export function defaultConsolidationPrompt(input: {
|
|
323
|
+
kinds: string[];
|
|
324
|
+
known: Array<{ id: string; text: string }>;
|
|
325
|
+
transcript: string;
|
|
326
|
+
language?: string;
|
|
327
|
+
role?: string;
|
|
328
|
+
}): ConsolidationRequest;
|
|
329
|
+
export function transcriptText(transcript: unknown): string;
|
|
330
|
+
|
|
331
|
+
/* ---- tools for @astratra/ai ---- */
|
|
332
|
+
|
|
333
|
+
/** Same shape as @astratra/ai's ToolDefinition. */
|
|
334
|
+
export interface MemoryToolDefinition {
|
|
335
|
+
name: string;
|
|
336
|
+
description: string;
|
|
337
|
+
type: string;
|
|
338
|
+
roles: string[];
|
|
339
|
+
params: Record<string, unknown>;
|
|
340
|
+
handler(params: Record<string, unknown>, ctx: Record<string, unknown>): Promise<MemoryToolResult>;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export type MemoryToolResult =
|
|
344
|
+
| { ok: true; code: 'memory_saved' | 'memory_corrected'; memory: Pick<Memory, 'id' | 'text' | 'kind' | 'importance'>; undo: { id: string } | null; message?: string }
|
|
345
|
+
| { ok: true; code: 'memories_found'; memories: Array<Pick<Memory, 'id' | 'text' | 'kind' | 'importance' | 'createdAt' | 'lastUsedAt'>>; message?: string }
|
|
346
|
+
| { ok: true; code: 'memory_forgotten'; id: string; message?: string }
|
|
347
|
+
| { ok: false; code: 'refused'; reason: string; message?: string };
|
|
348
|
+
|
|
349
|
+
export interface MemoryToolsOptions {
|
|
350
|
+
memory: MemoryService;
|
|
351
|
+
roles: string[];
|
|
352
|
+
whereOf: (ctx: Record<string, any>) => MemoryWhere;
|
|
353
|
+
roleOf?: (ctx: Record<string, any>) => string | null | undefined;
|
|
354
|
+
personNameOf?: (ctx: Record<string, any>) => string;
|
|
355
|
+
isExplicit?: (params: Record<string, unknown>, ctx: Record<string, any>) => Awaitable<boolean>;
|
|
356
|
+
sourceOf?: (params: Record<string, unknown>, ctx: Record<string, any>) => Record<string, unknown>;
|
|
357
|
+
isAiEnabled?: (ctx: Record<string, any>) => Awaitable<boolean>;
|
|
358
|
+
translate?: (code: string, ctx: Record<string, any>) => string;
|
|
359
|
+
names?: Partial<Record<'remember' | 'recall' | 'update' | 'forget', string>>;
|
|
360
|
+
descriptions?: Partial<Record<'remember' | 'recall' | 'update' | 'forget', string>>;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export function createMemoryTools(options: MemoryToolsOptions): MemoryToolDefinition[];
|
|
364
|
+
export const DEFAULT_TOOL_NAMES: Readonly<Record<'remember' | 'recall' | 'update' | 'forget', string>>;
|
|
365
|
+
export const DEFAULT_TOOL_DESCRIPTIONS: Readonly<Record<'remember' | 'recall' | 'update' | 'forget', string>>;
|
|
366
|
+
|
|
367
|
+
/* ---- handlers for a "my memories" screen ---- */
|
|
368
|
+
|
|
369
|
+
export interface MemoryHandlers {
|
|
370
|
+
list(where: MemoryWhere): Promise<{ ok: true; paused: boolean; memories: Memory[] }>;
|
|
371
|
+
listUnseen(where: MemoryWhere): Promise<{ ok: true; memories: Memory[] }>;
|
|
372
|
+
markSeen(where: MemoryWhere, input: { ids?: unknown[] }): Promise<{ ok: true; seen: number }>;
|
|
373
|
+
setPaused(where: MemoryWhere, input: { paused?: unknown }): Promise<{ ok: true; paused: boolean }>;
|
|
374
|
+
undo(where: MemoryWhere, input: { id?: string }): Promise<{ ok: true; undone: true } | Refusal>;
|
|
375
|
+
erase(where: MemoryWhere, input: { id?: string }): Promise<{ ok: true; erased: true } | Refusal>;
|
|
376
|
+
eraseAll(where: MemoryWhere): Promise<{ ok: true; erased: number }>;
|
|
377
|
+
purgeOwner(ownerId: string): Promise<{ ok: true; memories: number; settings: number; refs?: number }>;
|
|
378
|
+
update(
|
|
379
|
+
where: MemoryWhere,
|
|
380
|
+
input: { id?: string; text?: string; kind?: string; importance?: number | string; personName?: string }
|
|
381
|
+
): Promise<{ ok: true; memory: Memory; supersededId: string | null } | Refusal>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export function createMemoryHandlers(options: { memory: MemoryService; isAiEnabled?: (where: MemoryWhere) => Awaitable<boolean> }): MemoryHandlers;
|
|
385
|
+
export const PRIVACY_OPERATIONS: readonly string[];
|
|
386
|
+
export const AI_OPERATIONS: readonly string[];
|
|
387
|
+
export function worksWithoutAi(operation: string): boolean;
|
|
388
|
+
|
|
389
|
+
/* ---- store contract ---- */
|
|
390
|
+
|
|
391
|
+
export interface ContractRunner {
|
|
392
|
+
describe?: (name: string, fn: () => void) => void;
|
|
393
|
+
test?: (name: string, fn: () => Promise<void> | void) => void;
|
|
394
|
+
expect?: (value: unknown) => any;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export function runStoreContract(makeStore: () => Awaitable<MemoryStore>, runner?: ContractRunner): void;
|
|
398
|
+
export function contractRecord(overrides?: Partial<MemoryRecord>): MemoryRecord;
|
package/src/index.js
ADDED