cencori 1.4.1 → 1.5.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/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +208 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -1
- package/dist/index.mjs.map +1 -1
- package/dist/memory/index.d.mts +209 -1
- package/dist/memory/index.d.ts +209 -1
- package/dist/memory/index.js +118 -1
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/index.mjs +117 -1
- package/dist/memory/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs.map +1 -1
- package/dist/web/index.d.mts +169 -0
- package/dist/web/index.d.ts +169 -0
- package/dist/web/index.js +115 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/index.mjs +88 -0
- package/dist/web/index.mjs.map +1 -0
- package/package.json +7 -2
package/dist/memory/index.d.mts
CHANGED
|
@@ -81,15 +81,31 @@ interface SearchScopedMemoryOptions {
|
|
|
81
81
|
topK?: number;
|
|
82
82
|
threshold?: number;
|
|
83
83
|
namespace?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Temporal recall: search memory as it was valid at this instant (ISO 8601),
|
|
86
|
+
* including facts later superseded. Omit for current state.
|
|
87
|
+
*/
|
|
88
|
+
asOf?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Graph-aware recall (default true): when the query names an entity we know,
|
|
91
|
+
* also walk its relations and return facts about the connected entities that
|
|
92
|
+
* similarity alone would miss. Set false for strictly vector search.
|
|
93
|
+
*/
|
|
94
|
+
graph?: boolean;
|
|
84
95
|
}
|
|
85
96
|
interface ScopedSearchResult {
|
|
86
97
|
results: Array<{
|
|
87
98
|
id: string;
|
|
88
99
|
content: string;
|
|
100
|
+
/** Cosine similarity, or 0 for a memory reached across the graph. */
|
|
89
101
|
score: number;
|
|
90
102
|
namespace: string | null;
|
|
91
103
|
importance: number;
|
|
92
104
|
createdAt: string | null;
|
|
105
|
+
/** 'vector' (matched), 'graph' (walked to), or 'session'. */
|
|
106
|
+
source?: 'vector' | 'graph' | 'session';
|
|
107
|
+
/** Hops from the query's entity, for graph-reached memories. */
|
|
108
|
+
hops?: number;
|
|
93
109
|
}>;
|
|
94
110
|
count: number;
|
|
95
111
|
latencyMs: number;
|
|
@@ -121,6 +137,19 @@ interface RecallOptions {
|
|
|
121
137
|
namespace?: string;
|
|
122
138
|
topK?: number;
|
|
123
139
|
threshold?: number;
|
|
140
|
+
/** Temporal recall: memory as it was valid at this instant (ISO 8601). */
|
|
141
|
+
asOf?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Graph-aware recall (default true): also walk the entity graph from the
|
|
144
|
+
* entities the query names, pulling in connected facts.
|
|
145
|
+
*/
|
|
146
|
+
graph?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* 'inject' (default) returns an inject-ready block of full memory contents.
|
|
149
|
+
* 'index' returns a compact table of contents (`- [id] summary`) — fetch a
|
|
150
|
+
* full note with `memory.fetch(id)` when the summary is relevant.
|
|
151
|
+
*/
|
|
152
|
+
mode?: 'inject' | 'index';
|
|
124
153
|
}
|
|
125
154
|
interface RememberExchange {
|
|
126
155
|
user?: string;
|
|
@@ -146,6 +175,137 @@ interface RememberResult {
|
|
|
146
175
|
count: number;
|
|
147
176
|
scope: MemoryScope;
|
|
148
177
|
}
|
|
178
|
+
interface ForgetSuggestionsOptions {
|
|
179
|
+
userId?: string;
|
|
180
|
+
sessionId?: string;
|
|
181
|
+
scope?: MemoryScope;
|
|
182
|
+
namespace?: string;
|
|
183
|
+
/** Max suggestions (weakest first). Default 20. */
|
|
184
|
+
limit?: number;
|
|
185
|
+
/** Only suggest memories not used in at least this many days. Default 60. */
|
|
186
|
+
minIdleDays?: number;
|
|
187
|
+
}
|
|
188
|
+
interface ForgetSuggestionsResult {
|
|
189
|
+
suggestions: Array<{
|
|
190
|
+
id: string;
|
|
191
|
+
content: string;
|
|
192
|
+
/** Query-independent durability score, 0–1 (lower = safer to forget). */
|
|
193
|
+
strength: number;
|
|
194
|
+
idleDays: number;
|
|
195
|
+
importance: number;
|
|
196
|
+
}>;
|
|
197
|
+
count: number;
|
|
198
|
+
/** How many active memories were evaluated. */
|
|
199
|
+
evaluated: number;
|
|
200
|
+
}
|
|
201
|
+
interface RememberGraphOptions {
|
|
202
|
+
userId?: string;
|
|
203
|
+
sessionId?: string;
|
|
204
|
+
scope?: MemoryScope;
|
|
205
|
+
namespace?: string;
|
|
206
|
+
user?: string;
|
|
207
|
+
assistant?: string;
|
|
208
|
+
}
|
|
209
|
+
interface RememberGraphResult {
|
|
210
|
+
entities: number;
|
|
211
|
+
created: number;
|
|
212
|
+
merged: number;
|
|
213
|
+
relations: number;
|
|
214
|
+
costUsd: number;
|
|
215
|
+
}
|
|
216
|
+
interface GraphQueryOptions {
|
|
217
|
+
userId?: string;
|
|
218
|
+
sessionId?: string;
|
|
219
|
+
scope?: MemoryScope;
|
|
220
|
+
namespace?: string;
|
|
221
|
+
/** Entity name to start the traversal from. */
|
|
222
|
+
entity: string;
|
|
223
|
+
/** How many hops outward (1–4). Default 2. */
|
|
224
|
+
hops?: number;
|
|
225
|
+
}
|
|
226
|
+
interface GraphResult {
|
|
227
|
+
seed: {
|
|
228
|
+
id: string;
|
|
229
|
+
name: string;
|
|
230
|
+
type: string;
|
|
231
|
+
} | null;
|
|
232
|
+
nodes: Array<{
|
|
233
|
+
id: string;
|
|
234
|
+
name: string;
|
|
235
|
+
type: string;
|
|
236
|
+
hops: number;
|
|
237
|
+
path: string[];
|
|
238
|
+
}>;
|
|
239
|
+
edges: Array<{
|
|
240
|
+
source: string;
|
|
241
|
+
relation: string;
|
|
242
|
+
target: string;
|
|
243
|
+
}>;
|
|
244
|
+
message?: string;
|
|
245
|
+
}
|
|
246
|
+
interface ListEntitiesOptions {
|
|
247
|
+
userId?: string;
|
|
248
|
+
sessionId?: string;
|
|
249
|
+
scope?: MemoryScope;
|
|
250
|
+
namespace?: string;
|
|
251
|
+
type?: string;
|
|
252
|
+
limit?: number;
|
|
253
|
+
}
|
|
254
|
+
interface EntitiesResult {
|
|
255
|
+
entities: Array<{
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
type: string;
|
|
259
|
+
aliases: string[];
|
|
260
|
+
mentionCount: number;
|
|
261
|
+
createdAt: string;
|
|
262
|
+
}>;
|
|
263
|
+
count: number;
|
|
264
|
+
}
|
|
265
|
+
/** Full memory returned by `memory.fetch(id)` / GET /v1/memory/:id. */
|
|
266
|
+
interface FetchedMemory {
|
|
267
|
+
id: string;
|
|
268
|
+
scope: MemoryScope;
|
|
269
|
+
scopeKey: string;
|
|
270
|
+
namespace: string | null;
|
|
271
|
+
content: string;
|
|
272
|
+
metadata?: Record<string, unknown>;
|
|
273
|
+
importance: number;
|
|
274
|
+
accessCount?: number;
|
|
275
|
+
lastAccessedAt?: string | null;
|
|
276
|
+
expiresAt?: string | null;
|
|
277
|
+
createdAt: string | null;
|
|
278
|
+
updatedAt?: string | null;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Function-tool schema for index-mode agents. Register it in your `tools` so the
|
|
282
|
+
* model can pull a full memory by id (from the recall index) on demand, then
|
|
283
|
+
* resolve the call with `memory.fetch(id)`.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* tools: [MEMORY_FETCH_TOOL]
|
|
288
|
+
* // when the model calls memory_fetch({ id }): const m = await cencori.memory.fetch(id);
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
declare const MEMORY_FETCH_TOOL: {
|
|
292
|
+
readonly type: "function";
|
|
293
|
+
readonly function: {
|
|
294
|
+
readonly name: "memory_fetch";
|
|
295
|
+
readonly description: "Fetch the full content of a stored memory by its id (shown in the memory index). Only call this for memories whose summary is relevant to the current request; do not fetch memories you do not need.";
|
|
296
|
+
readonly parameters: {
|
|
297
|
+
readonly type: "object";
|
|
298
|
+
readonly properties: {
|
|
299
|
+
readonly id: {
|
|
300
|
+
readonly type: "string";
|
|
301
|
+
readonly description: "The memory id from the memory index, e.g. \"mem_abc123\".";
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
readonly required: readonly ["id"];
|
|
305
|
+
readonly additionalProperties: false;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
};
|
|
149
309
|
/**
|
|
150
310
|
* Memory class for vector storage operations
|
|
151
311
|
*/
|
|
@@ -190,6 +350,43 @@ declare class MemoryClient {
|
|
|
190
350
|
* List an end user's memories (paginated).
|
|
191
351
|
*/
|
|
192
352
|
list(options: ListScopedMemoryOptions): Promise<ScopedMemoryList>;
|
|
353
|
+
/**
|
|
354
|
+
* Suggest memories worth forgetting — stale, low-strength, long-idle
|
|
355
|
+
* candidates (never auto-deleted). Review, then `forget(id)` the ones you
|
|
356
|
+
* want gone. The product never silently forgets a user's memories.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const { suggestions } = await cencori.memory.forgetSuggestions({ userId });
|
|
361
|
+
* for (const s of suggestions) await cencori.memory.forget(s.id);
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
forgetSuggestions(options: ForgetSuggestionsOptions): Promise<ForgetSuggestionsResult>;
|
|
365
|
+
/**
|
|
366
|
+
* Extract entities + relations from an exchange and add them to the user's
|
|
367
|
+
* memory graph (Layer 5). Enables multi-hop recall — "who does Sarah report
|
|
368
|
+
* to, and where do they work?".
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* await cencori.memory.rememberGraph({ userId, user: message, assistant: reply });
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
rememberGraph(options: RememberGraphOptions): Promise<RememberGraphResult>;
|
|
376
|
+
/**
|
|
377
|
+
* Traverse the memory graph outward from an entity, returning connected
|
|
378
|
+
* entities and the relations linking them.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const { nodes, edges } = await cencori.memory.graph({ userId, entity: 'Sarah', hops: 2 });
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
graph(options: GraphQueryOptions): Promise<GraphResult>;
|
|
386
|
+
/**
|
|
387
|
+
* List the entities in a user's memory graph (most-mentioned first).
|
|
388
|
+
*/
|
|
389
|
+
entities(options: ListEntitiesOptions): Promise<EntitiesResult>;
|
|
193
390
|
/**
|
|
194
391
|
* Recall — search a user's memories and return an inject-ready system
|
|
195
392
|
* string. The provider-agnostic read path: drop the result into your own
|
|
@@ -209,6 +406,17 @@ declare class MemoryClient {
|
|
|
209
406
|
* ```
|
|
210
407
|
*/
|
|
211
408
|
recall(userId: string, query: string, options?: RecallOptions): Promise<string>;
|
|
409
|
+
/**
|
|
410
|
+
* Fetch one scoped memory's full content by id — the "pull the full note"
|
|
411
|
+
* half of index-mode recall. Scoped to your project; a foreign id 404s.
|
|
412
|
+
* (`get` is the legacy namespace store; `fetch` is the /v1 scoped store.)
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```typescript
|
|
416
|
+
* const memory = await cencori.memory.fetch('mem_abc123');
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
fetch(id: string): Promise<FetchedMemory>;
|
|
212
420
|
/**
|
|
213
421
|
* Remember — hand us a completed {user, assistant} exchange and we extract
|
|
214
422
|
* the durable facts and persist them (redacted, org-isolated). The
|
|
@@ -282,4 +490,4 @@ declare class MemoryClient {
|
|
|
282
490
|
}
|
|
283
491
|
declare function createMemoryClient(config: CencoriConfig): MemoryClient;
|
|
284
492
|
|
|
285
|
-
export { type CreateNamespaceOptions, type ListScopedMemoryOptions, type Memory, MemoryClient, type MemoryNamespace, type MemoryScope, type RecallOptions, type RememberExchange, type RememberOptions, type RememberResult, type ScopedMemory, type ScopedMemoryList, type ScopedSearchResult, type SearchMemoryOptions, type SearchResult, type SearchScopedMemoryOptions, type StoreMemoryOptions, type WriteScopedMemoryOptions, createMemoryClient };
|
|
493
|
+
export { type CreateNamespaceOptions, type EntitiesResult, type FetchedMemory, type ForgetSuggestionsOptions, type ForgetSuggestionsResult, type GraphQueryOptions, type GraphResult, type ListEntitiesOptions, type ListScopedMemoryOptions, MEMORY_FETCH_TOOL, type Memory, MemoryClient, type MemoryNamespace, type MemoryScope, type RecallOptions, type RememberExchange, type RememberGraphOptions, type RememberGraphResult, type RememberOptions, type RememberResult, type ScopedMemory, type ScopedMemoryList, type ScopedSearchResult, type SearchMemoryOptions, type SearchResult, type SearchScopedMemoryOptions, type StoreMemoryOptions, type WriteScopedMemoryOptions, createMemoryClient };
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -81,15 +81,31 @@ interface SearchScopedMemoryOptions {
|
|
|
81
81
|
topK?: number;
|
|
82
82
|
threshold?: number;
|
|
83
83
|
namespace?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Temporal recall: search memory as it was valid at this instant (ISO 8601),
|
|
86
|
+
* including facts later superseded. Omit for current state.
|
|
87
|
+
*/
|
|
88
|
+
asOf?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Graph-aware recall (default true): when the query names an entity we know,
|
|
91
|
+
* also walk its relations and return facts about the connected entities that
|
|
92
|
+
* similarity alone would miss. Set false for strictly vector search.
|
|
93
|
+
*/
|
|
94
|
+
graph?: boolean;
|
|
84
95
|
}
|
|
85
96
|
interface ScopedSearchResult {
|
|
86
97
|
results: Array<{
|
|
87
98
|
id: string;
|
|
88
99
|
content: string;
|
|
100
|
+
/** Cosine similarity, or 0 for a memory reached across the graph. */
|
|
89
101
|
score: number;
|
|
90
102
|
namespace: string | null;
|
|
91
103
|
importance: number;
|
|
92
104
|
createdAt: string | null;
|
|
105
|
+
/** 'vector' (matched), 'graph' (walked to), or 'session'. */
|
|
106
|
+
source?: 'vector' | 'graph' | 'session';
|
|
107
|
+
/** Hops from the query's entity, for graph-reached memories. */
|
|
108
|
+
hops?: number;
|
|
93
109
|
}>;
|
|
94
110
|
count: number;
|
|
95
111
|
latencyMs: number;
|
|
@@ -121,6 +137,19 @@ interface RecallOptions {
|
|
|
121
137
|
namespace?: string;
|
|
122
138
|
topK?: number;
|
|
123
139
|
threshold?: number;
|
|
140
|
+
/** Temporal recall: memory as it was valid at this instant (ISO 8601). */
|
|
141
|
+
asOf?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Graph-aware recall (default true): also walk the entity graph from the
|
|
144
|
+
* entities the query names, pulling in connected facts.
|
|
145
|
+
*/
|
|
146
|
+
graph?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* 'inject' (default) returns an inject-ready block of full memory contents.
|
|
149
|
+
* 'index' returns a compact table of contents (`- [id] summary`) — fetch a
|
|
150
|
+
* full note with `memory.fetch(id)` when the summary is relevant.
|
|
151
|
+
*/
|
|
152
|
+
mode?: 'inject' | 'index';
|
|
124
153
|
}
|
|
125
154
|
interface RememberExchange {
|
|
126
155
|
user?: string;
|
|
@@ -146,6 +175,137 @@ interface RememberResult {
|
|
|
146
175
|
count: number;
|
|
147
176
|
scope: MemoryScope;
|
|
148
177
|
}
|
|
178
|
+
interface ForgetSuggestionsOptions {
|
|
179
|
+
userId?: string;
|
|
180
|
+
sessionId?: string;
|
|
181
|
+
scope?: MemoryScope;
|
|
182
|
+
namespace?: string;
|
|
183
|
+
/** Max suggestions (weakest first). Default 20. */
|
|
184
|
+
limit?: number;
|
|
185
|
+
/** Only suggest memories not used in at least this many days. Default 60. */
|
|
186
|
+
minIdleDays?: number;
|
|
187
|
+
}
|
|
188
|
+
interface ForgetSuggestionsResult {
|
|
189
|
+
suggestions: Array<{
|
|
190
|
+
id: string;
|
|
191
|
+
content: string;
|
|
192
|
+
/** Query-independent durability score, 0–1 (lower = safer to forget). */
|
|
193
|
+
strength: number;
|
|
194
|
+
idleDays: number;
|
|
195
|
+
importance: number;
|
|
196
|
+
}>;
|
|
197
|
+
count: number;
|
|
198
|
+
/** How many active memories were evaluated. */
|
|
199
|
+
evaluated: number;
|
|
200
|
+
}
|
|
201
|
+
interface RememberGraphOptions {
|
|
202
|
+
userId?: string;
|
|
203
|
+
sessionId?: string;
|
|
204
|
+
scope?: MemoryScope;
|
|
205
|
+
namespace?: string;
|
|
206
|
+
user?: string;
|
|
207
|
+
assistant?: string;
|
|
208
|
+
}
|
|
209
|
+
interface RememberGraphResult {
|
|
210
|
+
entities: number;
|
|
211
|
+
created: number;
|
|
212
|
+
merged: number;
|
|
213
|
+
relations: number;
|
|
214
|
+
costUsd: number;
|
|
215
|
+
}
|
|
216
|
+
interface GraphQueryOptions {
|
|
217
|
+
userId?: string;
|
|
218
|
+
sessionId?: string;
|
|
219
|
+
scope?: MemoryScope;
|
|
220
|
+
namespace?: string;
|
|
221
|
+
/** Entity name to start the traversal from. */
|
|
222
|
+
entity: string;
|
|
223
|
+
/** How many hops outward (1–4). Default 2. */
|
|
224
|
+
hops?: number;
|
|
225
|
+
}
|
|
226
|
+
interface GraphResult {
|
|
227
|
+
seed: {
|
|
228
|
+
id: string;
|
|
229
|
+
name: string;
|
|
230
|
+
type: string;
|
|
231
|
+
} | null;
|
|
232
|
+
nodes: Array<{
|
|
233
|
+
id: string;
|
|
234
|
+
name: string;
|
|
235
|
+
type: string;
|
|
236
|
+
hops: number;
|
|
237
|
+
path: string[];
|
|
238
|
+
}>;
|
|
239
|
+
edges: Array<{
|
|
240
|
+
source: string;
|
|
241
|
+
relation: string;
|
|
242
|
+
target: string;
|
|
243
|
+
}>;
|
|
244
|
+
message?: string;
|
|
245
|
+
}
|
|
246
|
+
interface ListEntitiesOptions {
|
|
247
|
+
userId?: string;
|
|
248
|
+
sessionId?: string;
|
|
249
|
+
scope?: MemoryScope;
|
|
250
|
+
namespace?: string;
|
|
251
|
+
type?: string;
|
|
252
|
+
limit?: number;
|
|
253
|
+
}
|
|
254
|
+
interface EntitiesResult {
|
|
255
|
+
entities: Array<{
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
type: string;
|
|
259
|
+
aliases: string[];
|
|
260
|
+
mentionCount: number;
|
|
261
|
+
createdAt: string;
|
|
262
|
+
}>;
|
|
263
|
+
count: number;
|
|
264
|
+
}
|
|
265
|
+
/** Full memory returned by `memory.fetch(id)` / GET /v1/memory/:id. */
|
|
266
|
+
interface FetchedMemory {
|
|
267
|
+
id: string;
|
|
268
|
+
scope: MemoryScope;
|
|
269
|
+
scopeKey: string;
|
|
270
|
+
namespace: string | null;
|
|
271
|
+
content: string;
|
|
272
|
+
metadata?: Record<string, unknown>;
|
|
273
|
+
importance: number;
|
|
274
|
+
accessCount?: number;
|
|
275
|
+
lastAccessedAt?: string | null;
|
|
276
|
+
expiresAt?: string | null;
|
|
277
|
+
createdAt: string | null;
|
|
278
|
+
updatedAt?: string | null;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Function-tool schema for index-mode agents. Register it in your `tools` so the
|
|
282
|
+
* model can pull a full memory by id (from the recall index) on demand, then
|
|
283
|
+
* resolve the call with `memory.fetch(id)`.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* tools: [MEMORY_FETCH_TOOL]
|
|
288
|
+
* // when the model calls memory_fetch({ id }): const m = await cencori.memory.fetch(id);
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
declare const MEMORY_FETCH_TOOL: {
|
|
292
|
+
readonly type: "function";
|
|
293
|
+
readonly function: {
|
|
294
|
+
readonly name: "memory_fetch";
|
|
295
|
+
readonly description: "Fetch the full content of a stored memory by its id (shown in the memory index). Only call this for memories whose summary is relevant to the current request; do not fetch memories you do not need.";
|
|
296
|
+
readonly parameters: {
|
|
297
|
+
readonly type: "object";
|
|
298
|
+
readonly properties: {
|
|
299
|
+
readonly id: {
|
|
300
|
+
readonly type: "string";
|
|
301
|
+
readonly description: "The memory id from the memory index, e.g. \"mem_abc123\".";
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
readonly required: readonly ["id"];
|
|
305
|
+
readonly additionalProperties: false;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
};
|
|
149
309
|
/**
|
|
150
310
|
* Memory class for vector storage operations
|
|
151
311
|
*/
|
|
@@ -190,6 +350,43 @@ declare class MemoryClient {
|
|
|
190
350
|
* List an end user's memories (paginated).
|
|
191
351
|
*/
|
|
192
352
|
list(options: ListScopedMemoryOptions): Promise<ScopedMemoryList>;
|
|
353
|
+
/**
|
|
354
|
+
* Suggest memories worth forgetting — stale, low-strength, long-idle
|
|
355
|
+
* candidates (never auto-deleted). Review, then `forget(id)` the ones you
|
|
356
|
+
* want gone. The product never silently forgets a user's memories.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const { suggestions } = await cencori.memory.forgetSuggestions({ userId });
|
|
361
|
+
* for (const s of suggestions) await cencori.memory.forget(s.id);
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
forgetSuggestions(options: ForgetSuggestionsOptions): Promise<ForgetSuggestionsResult>;
|
|
365
|
+
/**
|
|
366
|
+
* Extract entities + relations from an exchange and add them to the user's
|
|
367
|
+
* memory graph (Layer 5). Enables multi-hop recall — "who does Sarah report
|
|
368
|
+
* to, and where do they work?".
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* await cencori.memory.rememberGraph({ userId, user: message, assistant: reply });
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
rememberGraph(options: RememberGraphOptions): Promise<RememberGraphResult>;
|
|
376
|
+
/**
|
|
377
|
+
* Traverse the memory graph outward from an entity, returning connected
|
|
378
|
+
* entities and the relations linking them.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const { nodes, edges } = await cencori.memory.graph({ userId, entity: 'Sarah', hops: 2 });
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
graph(options: GraphQueryOptions): Promise<GraphResult>;
|
|
386
|
+
/**
|
|
387
|
+
* List the entities in a user's memory graph (most-mentioned first).
|
|
388
|
+
*/
|
|
389
|
+
entities(options: ListEntitiesOptions): Promise<EntitiesResult>;
|
|
193
390
|
/**
|
|
194
391
|
* Recall — search a user's memories and return an inject-ready system
|
|
195
392
|
* string. The provider-agnostic read path: drop the result into your own
|
|
@@ -209,6 +406,17 @@ declare class MemoryClient {
|
|
|
209
406
|
* ```
|
|
210
407
|
*/
|
|
211
408
|
recall(userId: string, query: string, options?: RecallOptions): Promise<string>;
|
|
409
|
+
/**
|
|
410
|
+
* Fetch one scoped memory's full content by id — the "pull the full note"
|
|
411
|
+
* half of index-mode recall. Scoped to your project; a foreign id 404s.
|
|
412
|
+
* (`get` is the legacy namespace store; `fetch` is the /v1 scoped store.)
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```typescript
|
|
416
|
+
* const memory = await cencori.memory.fetch('mem_abc123');
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
fetch(id: string): Promise<FetchedMemory>;
|
|
212
420
|
/**
|
|
213
421
|
* Remember — hand us a completed {user, assistant} exchange and we extract
|
|
214
422
|
* the durable facts and persist them (redacted, org-isolated). The
|
|
@@ -282,4 +490,4 @@ declare class MemoryClient {
|
|
|
282
490
|
}
|
|
283
491
|
declare function createMemoryClient(config: CencoriConfig): MemoryClient;
|
|
284
492
|
|
|
285
|
-
export { type CreateNamespaceOptions, type ListScopedMemoryOptions, type Memory, MemoryClient, type MemoryNamespace, type MemoryScope, type RecallOptions, type RememberExchange, type RememberOptions, type RememberResult, type ScopedMemory, type ScopedMemoryList, type ScopedSearchResult, type SearchMemoryOptions, type SearchResult, type SearchScopedMemoryOptions, type StoreMemoryOptions, type WriteScopedMemoryOptions, createMemoryClient };
|
|
493
|
+
export { type CreateNamespaceOptions, type EntitiesResult, type FetchedMemory, type ForgetSuggestionsOptions, type ForgetSuggestionsResult, type GraphQueryOptions, type GraphResult, type ListEntitiesOptions, type ListScopedMemoryOptions, MEMORY_FETCH_TOOL, type Memory, MemoryClient, type MemoryNamespace, type MemoryScope, type RecallOptions, type RememberExchange, type RememberGraphOptions, type RememberGraphResult, type RememberOptions, type RememberResult, type ScopedMemory, type ScopedMemoryList, type ScopedSearchResult, type SearchMemoryOptions, type SearchResult, type SearchScopedMemoryOptions, type StoreMemoryOptions, type WriteScopedMemoryOptions, createMemoryClient };
|
package/dist/memory/index.js
CHANGED
|
@@ -20,10 +20,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/memory/index.ts
|
|
21
21
|
var memory_exports = {};
|
|
22
22
|
__export(memory_exports, {
|
|
23
|
+
MEMORY_FETCH_TOOL: () => MEMORY_FETCH_TOOL,
|
|
23
24
|
MemoryClient: () => MemoryClient,
|
|
24
25
|
createMemoryClient: () => createMemoryClient
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(memory_exports);
|
|
28
|
+
var MEMORY_FETCH_TOOL = {
|
|
29
|
+
type: "function",
|
|
30
|
+
function: {
|
|
31
|
+
name: "memory_fetch",
|
|
32
|
+
description: "Fetch the full content of a stored memory by its id (shown in the memory index). Only call this for memories whose summary is relevant to the current request; do not fetch memories you do not need.",
|
|
33
|
+
parameters: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
id: { type: "string", description: 'The memory id from the memory index, e.g. "mem_abc123".' }
|
|
37
|
+
},
|
|
38
|
+
required: ["id"],
|
|
39
|
+
additionalProperties: false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function summarizeMemory(content, maxChars = 100) {
|
|
44
|
+
const flat = content.replace(/\s+/g, " ").trim();
|
|
45
|
+
if (flat.length <= maxChars) return flat;
|
|
46
|
+
const cut = flat.slice(0, maxChars);
|
|
47
|
+
const lastSpace = cut.lastIndexOf(" ");
|
|
48
|
+
return `${(lastSpace > maxChars * 0.6 ? cut.slice(0, lastSpace) : cut).trimEnd()}\u2026`;
|
|
49
|
+
}
|
|
27
50
|
var MemoryClient = class {
|
|
28
51
|
constructor(config) {
|
|
29
52
|
this.config = config;
|
|
@@ -107,6 +130,75 @@ var MemoryClient = class {
|
|
|
107
130
|
if (options.cursor) params.set("cursor", options.cursor);
|
|
108
131
|
return this.request(`/v1/memory/list?${params.toString()}`);
|
|
109
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Suggest memories worth forgetting — stale, low-strength, long-idle
|
|
135
|
+
* candidates (never auto-deleted). Review, then `forget(id)` the ones you
|
|
136
|
+
* want gone. The product never silently forgets a user's memories.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const { suggestions } = await cencori.memory.forgetSuggestions({ userId });
|
|
141
|
+
* for (const s of suggestions) await cencori.memory.forget(s.id);
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
async forgetSuggestions(options) {
|
|
145
|
+
const params = new URLSearchParams();
|
|
146
|
+
if (options.userId) params.set("userId", options.userId);
|
|
147
|
+
if (options.sessionId) params.set("sessionId", options.sessionId);
|
|
148
|
+
if (options.scope) params.set("scope", options.scope);
|
|
149
|
+
if (options.namespace) params.set("namespace", options.namespace);
|
|
150
|
+
if (options.limit) params.set("limit", String(options.limit));
|
|
151
|
+
if (options.minIdleDays != null) params.set("minIdleDays", String(options.minIdleDays));
|
|
152
|
+
return this.request(`/v1/memory/forget-suggestions?${params.toString()}`);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Extract entities + relations from an exchange and add them to the user's
|
|
156
|
+
* memory graph (Layer 5). Enables multi-hop recall — "who does Sarah report
|
|
157
|
+
* to, and where do they work?".
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* await cencori.memory.rememberGraph({ userId, user: message, assistant: reply });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
async rememberGraph(options) {
|
|
165
|
+
return this.request("/v1/memory/graph", {
|
|
166
|
+
method: "POST",
|
|
167
|
+
body: JSON.stringify(options)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Traverse the memory graph outward from an entity, returning connected
|
|
172
|
+
* entities and the relations linking them.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const { nodes, edges } = await cencori.memory.graph({ userId, entity: 'Sarah', hops: 2 });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
async graph(options) {
|
|
180
|
+
const params = new URLSearchParams();
|
|
181
|
+
if (options.userId) params.set("userId", options.userId);
|
|
182
|
+
if (options.sessionId) params.set("sessionId", options.sessionId);
|
|
183
|
+
if (options.scope) params.set("scope", options.scope);
|
|
184
|
+
if (options.namespace) params.set("namespace", options.namespace);
|
|
185
|
+
params.set("entity", options.entity);
|
|
186
|
+
if (options.hops != null) params.set("hops", String(options.hops));
|
|
187
|
+
return this.request(`/v1/memory/graph?${params.toString()}`);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* List the entities in a user's memory graph (most-mentioned first).
|
|
191
|
+
*/
|
|
192
|
+
async entities(options) {
|
|
193
|
+
const params = new URLSearchParams();
|
|
194
|
+
if (options.userId) params.set("userId", options.userId);
|
|
195
|
+
if (options.sessionId) params.set("sessionId", options.sessionId);
|
|
196
|
+
if (options.scope) params.set("scope", options.scope);
|
|
197
|
+
if (options.namespace) params.set("namespace", options.namespace);
|
|
198
|
+
if (options.type) params.set("type", options.type);
|
|
199
|
+
if (options.limit != null) params.set("limit", String(options.limit));
|
|
200
|
+
return this.request(`/v1/memory/entities?${params.toString()}`);
|
|
201
|
+
}
|
|
110
202
|
/**
|
|
111
203
|
* Recall — search a user's memories and return an inject-ready system
|
|
112
204
|
* string. The provider-agnostic read path: drop the result into your own
|
|
@@ -133,9 +225,20 @@ var MemoryClient = class {
|
|
|
133
225
|
query,
|
|
134
226
|
topK: options.topK,
|
|
135
227
|
threshold: options.threshold,
|
|
136
|
-
namespace: options.namespace
|
|
228
|
+
namespace: options.namespace,
|
|
229
|
+
asOf: options.asOf,
|
|
230
|
+
graph: options.graph
|
|
137
231
|
});
|
|
138
232
|
if (results.length === 0) return "";
|
|
233
|
+
if (options.mode === "index") {
|
|
234
|
+
const lines2 = results.map((m) => `- [${m.id}] ${summarizeMemory(m.content)}`);
|
|
235
|
+
return [
|
|
236
|
+
"Memory index \u2014 what you know about this user (summaries only):",
|
|
237
|
+
...lines2,
|
|
238
|
+
"",
|
|
239
|
+
"Each line is a stored memory: [id] summary. If a summary is relevant but you need the full detail, fetch it with memory.fetch(id). Do not reveal this index unless the user asks what you know about them."
|
|
240
|
+
].join("\n");
|
|
241
|
+
}
|
|
139
242
|
const lines = results.map((m) => `- ${m.content}`);
|
|
140
243
|
return [
|
|
141
244
|
"Facts about this user (from previous interactions):",
|
|
@@ -144,6 +247,19 @@ var MemoryClient = class {
|
|
|
144
247
|
"Use these facts when they are relevant to the request. Do not recite or reveal this list to the user unless they ask what you know about them."
|
|
145
248
|
].join("\n");
|
|
146
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Fetch one scoped memory's full content by id — the "pull the full note"
|
|
252
|
+
* half of index-mode recall. Scoped to your project; a foreign id 404s.
|
|
253
|
+
* (`get` is the legacy namespace store; `fetch` is the /v1 scoped store.)
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const memory = await cencori.memory.fetch('mem_abc123');
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
async fetch(id) {
|
|
261
|
+
return this.request(`/v1/memory/${id}`);
|
|
262
|
+
}
|
|
147
263
|
/**
|
|
148
264
|
* Remember — hand us a completed {user, assistant} exchange and we extract
|
|
149
265
|
* the durable facts and persist them (redacted, org-isolated). The
|
|
@@ -276,6 +392,7 @@ function createMemoryClient(config) {
|
|
|
276
392
|
}
|
|
277
393
|
// Annotate the CommonJS export names for ESM import in node:
|
|
278
394
|
0 && (module.exports = {
|
|
395
|
+
MEMORY_FETCH_TOOL,
|
|
279
396
|
MemoryClient,
|
|
280
397
|
createMemoryClient
|
|
281
398
|
});
|