agent-memory-client 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/dist/index.d.mts +828 -0
- package/dist/index.d.ts +828 -0
- package/dist/index.js +646 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +631 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter classes for search operations.
|
|
3
|
+
*
|
|
4
|
+
* These filters allow for filtering memory search results.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Filter by session ID
|
|
8
|
+
*/
|
|
9
|
+
declare class SessionId {
|
|
10
|
+
eq?: string;
|
|
11
|
+
in_?: string[];
|
|
12
|
+
not_eq?: string;
|
|
13
|
+
not_in?: string[];
|
|
14
|
+
ne?: string;
|
|
15
|
+
constructor(options?: {
|
|
16
|
+
eq?: string;
|
|
17
|
+
in_?: string[];
|
|
18
|
+
not_eq?: string;
|
|
19
|
+
not_in?: string[];
|
|
20
|
+
ne?: string;
|
|
21
|
+
});
|
|
22
|
+
toJSON(): Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Filter by namespace
|
|
26
|
+
*/
|
|
27
|
+
declare class Namespace {
|
|
28
|
+
eq?: string;
|
|
29
|
+
in_?: string[];
|
|
30
|
+
not_eq?: string;
|
|
31
|
+
not_in?: string[];
|
|
32
|
+
constructor(options?: {
|
|
33
|
+
eq?: string;
|
|
34
|
+
in_?: string[];
|
|
35
|
+
not_eq?: string;
|
|
36
|
+
not_in?: string[];
|
|
37
|
+
});
|
|
38
|
+
toJSON(): Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Filter by user ID
|
|
42
|
+
*/
|
|
43
|
+
declare class UserId {
|
|
44
|
+
eq?: string;
|
|
45
|
+
in_?: string[];
|
|
46
|
+
not_eq?: string;
|
|
47
|
+
not_in?: string[];
|
|
48
|
+
constructor(options?: {
|
|
49
|
+
eq?: string;
|
|
50
|
+
in_?: string[];
|
|
51
|
+
not_eq?: string;
|
|
52
|
+
not_in?: string[];
|
|
53
|
+
});
|
|
54
|
+
toJSON(): Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Filter by topics
|
|
58
|
+
*/
|
|
59
|
+
declare class Topics {
|
|
60
|
+
any?: string[];
|
|
61
|
+
all?: string[];
|
|
62
|
+
none?: string[];
|
|
63
|
+
constructor(options?: {
|
|
64
|
+
any?: string[];
|
|
65
|
+
all?: string[];
|
|
66
|
+
none?: string[];
|
|
67
|
+
});
|
|
68
|
+
toJSON(): Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Filter by entities
|
|
72
|
+
*/
|
|
73
|
+
declare class Entities {
|
|
74
|
+
any?: string[];
|
|
75
|
+
all?: string[];
|
|
76
|
+
none?: string[];
|
|
77
|
+
constructor(options?: {
|
|
78
|
+
any?: string[];
|
|
79
|
+
all?: string[];
|
|
80
|
+
none?: string[];
|
|
81
|
+
});
|
|
82
|
+
toJSON(): Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Filter by creation date
|
|
86
|
+
*/
|
|
87
|
+
declare class CreatedAt {
|
|
88
|
+
gte?: Date | string;
|
|
89
|
+
lte?: Date | string;
|
|
90
|
+
eq?: Date | string;
|
|
91
|
+
constructor(options?: {
|
|
92
|
+
gte?: Date | string;
|
|
93
|
+
lte?: Date | string;
|
|
94
|
+
eq?: Date | string;
|
|
95
|
+
});
|
|
96
|
+
toJSON(): Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Filter by last accessed date
|
|
100
|
+
*/
|
|
101
|
+
declare class LastAccessed {
|
|
102
|
+
gte?: Date | string;
|
|
103
|
+
lte?: Date | string;
|
|
104
|
+
eq?: Date | string;
|
|
105
|
+
constructor(options?: {
|
|
106
|
+
gte?: Date | string;
|
|
107
|
+
lte?: Date | string;
|
|
108
|
+
eq?: Date | string;
|
|
109
|
+
});
|
|
110
|
+
toJSON(): Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Filter by event date
|
|
114
|
+
*/
|
|
115
|
+
declare class EventDate {
|
|
116
|
+
gte?: Date | string;
|
|
117
|
+
lte?: Date | string;
|
|
118
|
+
eq?: Date | string;
|
|
119
|
+
constructor(options?: {
|
|
120
|
+
gte?: Date | string;
|
|
121
|
+
lte?: Date | string;
|
|
122
|
+
eq?: Date | string;
|
|
123
|
+
});
|
|
124
|
+
toJSON(): Record<string, unknown>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Filter by memory type
|
|
128
|
+
*/
|
|
129
|
+
declare class MemoryType {
|
|
130
|
+
eq?: string;
|
|
131
|
+
in_?: string[];
|
|
132
|
+
not_eq?: string;
|
|
133
|
+
not_in?: string[];
|
|
134
|
+
constructor(options?: {
|
|
135
|
+
eq?: string;
|
|
136
|
+
in_?: string[];
|
|
137
|
+
not_eq?: string;
|
|
138
|
+
not_in?: string[];
|
|
139
|
+
});
|
|
140
|
+
toJSON(): Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Data models for the Agent Memory Client.
|
|
145
|
+
*
|
|
146
|
+
* This module contains essential data models needed by the client.
|
|
147
|
+
*/
|
|
148
|
+
/**
|
|
149
|
+
* Supported LLM model names for context window determination
|
|
150
|
+
*/
|
|
151
|
+
type ModelNameLiteral = "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-4" | "gpt-4-32k" | "gpt-4o" | "gpt-4o-mini" | "o1" | "o1-mini" | "o3-mini" | "gpt-5-mini" | "gpt-5-nano" | "gpt-5.1-chat-latest" | "gpt-5.2-chat-latest" | "text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large" | "claude-3-opus-20240229" | "claude-3-sonnet-20240229" | "claude-3-haiku-20240307" | "claude-3-5-sonnet-20240620" | "claude-3-7-sonnet-20250219" | "claude-3-5-sonnet-20241022" | "claude-3-5-haiku-20241022" | "claude-3-7-sonnet-latest" | "claude-3-5-sonnet-latest" | "claude-3-5-haiku-latest" | "claude-3-opus-latest";
|
|
152
|
+
/**
|
|
153
|
+
* Enum for memory types
|
|
154
|
+
*/
|
|
155
|
+
declare enum MemoryTypeEnum {
|
|
156
|
+
EPISODIC = "episodic",
|
|
157
|
+
SEMANTIC = "semantic",
|
|
158
|
+
MESSAGE = "message"
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Memory extraction strategy types
|
|
162
|
+
*/
|
|
163
|
+
type MemoryStrategyType = "discrete" | "summary" | "preferences" | "custom";
|
|
164
|
+
/**
|
|
165
|
+
* Configuration for memory extraction strategy
|
|
166
|
+
*/
|
|
167
|
+
interface MemoryStrategyConfig {
|
|
168
|
+
/** Type of memory extraction strategy to use */
|
|
169
|
+
strategy?: MemoryStrategyType;
|
|
170
|
+
/** Strategy-specific configuration options */
|
|
171
|
+
config?: Record<string, unknown>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A message in the memory system
|
|
175
|
+
*/
|
|
176
|
+
interface MemoryMessage {
|
|
177
|
+
/** Message role (user, assistant, system, tool) */
|
|
178
|
+
role: string;
|
|
179
|
+
/** Message content */
|
|
180
|
+
content: string;
|
|
181
|
+
/** Unique identifier for the message */
|
|
182
|
+
id?: string;
|
|
183
|
+
/** Timestamp when the message was created */
|
|
184
|
+
created_at?: string;
|
|
185
|
+
/** Server-assigned timestamp when message was persisted */
|
|
186
|
+
persisted_at?: string | null;
|
|
187
|
+
/** Whether memory extraction has run for this message */
|
|
188
|
+
discrete_memory_extracted?: "t" | "f";
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A memory record
|
|
192
|
+
*/
|
|
193
|
+
interface MemoryRecord {
|
|
194
|
+
/** Client-provided ID for deduplication and overwrites */
|
|
195
|
+
id: string;
|
|
196
|
+
/** Memory content text */
|
|
197
|
+
text: string;
|
|
198
|
+
/** Optional session ID for the memory record */
|
|
199
|
+
session_id?: string | null;
|
|
200
|
+
/** Optional user ID for the memory record */
|
|
201
|
+
user_id?: string | null;
|
|
202
|
+
/** Optional namespace for the memory record */
|
|
203
|
+
namespace?: string | null;
|
|
204
|
+
/** Datetime when the memory was last accessed */
|
|
205
|
+
last_accessed?: string;
|
|
206
|
+
/** Datetime when the memory was created */
|
|
207
|
+
created_at?: string;
|
|
208
|
+
/** Datetime when the memory was last updated */
|
|
209
|
+
updated_at?: string;
|
|
210
|
+
/** Optional topics for the memory record */
|
|
211
|
+
topics?: string[] | null;
|
|
212
|
+
/** Optional entities for the memory record */
|
|
213
|
+
entities?: string[] | null;
|
|
214
|
+
/** Hash representation of the memory for deduplication */
|
|
215
|
+
memory_hash?: string | null;
|
|
216
|
+
/** Whether memory extraction has run for this memory */
|
|
217
|
+
discrete_memory_extracted?: "t" | "f";
|
|
218
|
+
/** Type of memory */
|
|
219
|
+
memory_type?: MemoryTypeEnum;
|
|
220
|
+
/** Server-assigned timestamp when memory was persisted */
|
|
221
|
+
persisted_at?: string | null;
|
|
222
|
+
/** List of message IDs that this memory was extracted from */
|
|
223
|
+
extracted_from?: string[] | null;
|
|
224
|
+
/** Date/time when the event described in this memory occurred */
|
|
225
|
+
event_date?: string | null;
|
|
226
|
+
}
|
|
227
|
+
/** JSON value types for working memory data */
|
|
228
|
+
type JSONValue = string | number | boolean | null | JSONValue[] | {
|
|
229
|
+
[key: string]: JSONValue;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Working memory for a session
|
|
233
|
+
*/
|
|
234
|
+
interface WorkingMemory {
|
|
235
|
+
/** Session ID (required) */
|
|
236
|
+
session_id: string;
|
|
237
|
+
/** Conversation messages */
|
|
238
|
+
messages?: MemoryMessage[];
|
|
239
|
+
/** Structured memory records */
|
|
240
|
+
memories?: MemoryRecord[];
|
|
241
|
+
/** Arbitrary JSON data storage */
|
|
242
|
+
data?: Record<string, JSONValue> | null;
|
|
243
|
+
/** Optional summary of past session messages */
|
|
244
|
+
context?: string | null;
|
|
245
|
+
/** Optional user ID */
|
|
246
|
+
user_id?: string | null;
|
|
247
|
+
/** Token count */
|
|
248
|
+
tokens?: number;
|
|
249
|
+
/** Optional namespace */
|
|
250
|
+
namespace?: string | null;
|
|
251
|
+
/** Configuration for memory extraction strategy */
|
|
252
|
+
long_term_memory_strategy?: MemoryStrategyConfig;
|
|
253
|
+
/** TTL for the working memory in seconds */
|
|
254
|
+
ttl_seconds?: number | null;
|
|
255
|
+
/** Datetime when the working memory was last accessed */
|
|
256
|
+
last_accessed?: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Response from working memory operations
|
|
260
|
+
*/
|
|
261
|
+
interface WorkingMemoryResponse extends WorkingMemory {
|
|
262
|
+
/** Percentage of total context window currently used (0-100) */
|
|
263
|
+
context_percentage_total_used?: number | null;
|
|
264
|
+
/** Percentage until auto-summarization triggers (0-100) */
|
|
265
|
+
context_percentage_until_summarization?: number | null;
|
|
266
|
+
/** True if session was created, False if existing */
|
|
267
|
+
new_session?: boolean | null;
|
|
268
|
+
/** True if this session data has not been persisted yet */
|
|
269
|
+
unsaved?: boolean | null;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Generic acknowledgement response
|
|
273
|
+
*/
|
|
274
|
+
interface AckResponse {
|
|
275
|
+
status: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Health check response
|
|
279
|
+
*/
|
|
280
|
+
interface HealthCheckResponse {
|
|
281
|
+
now: number;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Response containing a list of sessions
|
|
285
|
+
*/
|
|
286
|
+
interface SessionListResponse {
|
|
287
|
+
sessions: string[];
|
|
288
|
+
total: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Result from a memory search
|
|
292
|
+
*/
|
|
293
|
+
interface MemoryRecordResult extends MemoryRecord {
|
|
294
|
+
/** Distance/similarity score */
|
|
295
|
+
dist: number;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Results from memory search operations
|
|
299
|
+
*/
|
|
300
|
+
interface MemoryRecordResults {
|
|
301
|
+
memories: MemoryRecordResult[];
|
|
302
|
+
total: number;
|
|
303
|
+
next_offset?: number | null;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Client-side configuration for recency-aware ranking
|
|
307
|
+
*/
|
|
308
|
+
interface RecencyConfig {
|
|
309
|
+
/** Enable recency-aware re-ranking */
|
|
310
|
+
recency_boost?: boolean | null;
|
|
311
|
+
/** Weight for semantic similarity */
|
|
312
|
+
semantic_weight?: number | null;
|
|
313
|
+
/** Weight for recency score */
|
|
314
|
+
recency_weight?: number | null;
|
|
315
|
+
/** Weight for freshness component */
|
|
316
|
+
freshness_weight?: number | null;
|
|
317
|
+
/** Weight for novelty/age component */
|
|
318
|
+
novelty_weight?: number | null;
|
|
319
|
+
/** Half-life (days) for last_accessed decay */
|
|
320
|
+
half_life_last_access_days?: number | null;
|
|
321
|
+
/** Half-life (days) for created_at decay */
|
|
322
|
+
half_life_created_days?: number | null;
|
|
323
|
+
/** If true, attempt server-side recency ranking */
|
|
324
|
+
server_side_recency?: boolean | null;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Response from memory prompt endpoint
|
|
328
|
+
*/
|
|
329
|
+
interface MemoryPromptResponse {
|
|
330
|
+
messages: Record<string, unknown>[];
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Session parameters for memory prompt
|
|
334
|
+
*/
|
|
335
|
+
interface SessionParams {
|
|
336
|
+
session_id: string;
|
|
337
|
+
user_id?: string | null;
|
|
338
|
+
namespace?: string | null;
|
|
339
|
+
model_name?: ModelNameLiteral | null;
|
|
340
|
+
context_window_max?: number | null;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Request for memory prompt endpoint
|
|
344
|
+
*/
|
|
345
|
+
interface MemoryPromptRequest {
|
|
346
|
+
query: string;
|
|
347
|
+
session?: SessionParams | null;
|
|
348
|
+
long_term_search?: SearchRequestParams | boolean | null;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Parameters for long-term memory search
|
|
352
|
+
*/
|
|
353
|
+
interface SearchRequestParams {
|
|
354
|
+
text?: string;
|
|
355
|
+
session_id?: SessionIdFilter | null;
|
|
356
|
+
namespace?: NamespaceFilter | null;
|
|
357
|
+
topics?: TopicsFilter | null;
|
|
358
|
+
entities?: EntitiesFilter | null;
|
|
359
|
+
created_at?: CreatedAtFilter | null;
|
|
360
|
+
last_accessed?: LastAccessedFilter | null;
|
|
361
|
+
user_id?: UserIdFilter | null;
|
|
362
|
+
memory_type?: MemoryTypeFilter | null;
|
|
363
|
+
event_date?: EventDateFilter | null;
|
|
364
|
+
distance_threshold?: number | null;
|
|
365
|
+
limit?: number;
|
|
366
|
+
offset?: number;
|
|
367
|
+
recency_boost?: boolean | null;
|
|
368
|
+
recency_semantic_weight?: number | null;
|
|
369
|
+
recency_recency_weight?: number | null;
|
|
370
|
+
recency_freshness_weight?: number | null;
|
|
371
|
+
recency_novelty_weight?: number | null;
|
|
372
|
+
recency_half_life_last_access_days?: number | null;
|
|
373
|
+
recency_half_life_created_days?: number | null;
|
|
374
|
+
server_side_recency?: boolean | null;
|
|
375
|
+
}
|
|
376
|
+
interface SessionIdFilter {
|
|
377
|
+
eq?: string | null;
|
|
378
|
+
in_?: string[] | null;
|
|
379
|
+
not_eq?: string | null;
|
|
380
|
+
not_in?: string[] | null;
|
|
381
|
+
ne?: string | null;
|
|
382
|
+
}
|
|
383
|
+
interface NamespaceFilter {
|
|
384
|
+
eq?: string | null;
|
|
385
|
+
in_?: string[] | null;
|
|
386
|
+
not_eq?: string | null;
|
|
387
|
+
not_in?: string[] | null;
|
|
388
|
+
}
|
|
389
|
+
interface UserIdFilter {
|
|
390
|
+
eq?: string | null;
|
|
391
|
+
in_?: string[] | null;
|
|
392
|
+
not_eq?: string | null;
|
|
393
|
+
not_in?: string[] | null;
|
|
394
|
+
}
|
|
395
|
+
interface TopicsFilter {
|
|
396
|
+
any?: string[] | null;
|
|
397
|
+
all?: string[] | null;
|
|
398
|
+
none?: string[] | null;
|
|
399
|
+
}
|
|
400
|
+
interface EntitiesFilter {
|
|
401
|
+
any?: string[] | null;
|
|
402
|
+
all?: string[] | null;
|
|
403
|
+
none?: string[] | null;
|
|
404
|
+
}
|
|
405
|
+
interface CreatedAtFilter {
|
|
406
|
+
gte?: string | null;
|
|
407
|
+
lte?: string | null;
|
|
408
|
+
eq?: string | null;
|
|
409
|
+
}
|
|
410
|
+
interface LastAccessedFilter {
|
|
411
|
+
gte?: string | null;
|
|
412
|
+
lte?: string | null;
|
|
413
|
+
eq?: string | null;
|
|
414
|
+
}
|
|
415
|
+
interface EventDateFilter {
|
|
416
|
+
gte?: string | null;
|
|
417
|
+
lte?: string | null;
|
|
418
|
+
eq?: string | null;
|
|
419
|
+
}
|
|
420
|
+
interface MemoryTypeFilter {
|
|
421
|
+
eq?: string | null;
|
|
422
|
+
in_?: string[] | null;
|
|
423
|
+
not_eq?: string | null;
|
|
424
|
+
not_in?: string[] | null;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Policy for forgetting memories
|
|
428
|
+
*/
|
|
429
|
+
interface ForgetPolicy {
|
|
430
|
+
/** Maximum age in days for memories to keep */
|
|
431
|
+
max_age_days?: number | null;
|
|
432
|
+
/** Maximum inactive days before forgetting */
|
|
433
|
+
max_inactive_days?: number | null;
|
|
434
|
+
/** Budget limit for forgetting operation */
|
|
435
|
+
budget?: number | null;
|
|
436
|
+
/** Allowlist of memory types to consider for forgetting */
|
|
437
|
+
memory_type_allowlist?: string[] | null;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Response from forget operation
|
|
441
|
+
*/
|
|
442
|
+
interface ForgetResponse {
|
|
443
|
+
/** Number of memories scanned */
|
|
444
|
+
scanned: number;
|
|
445
|
+
/** Number of memories deleted */
|
|
446
|
+
deleted: number;
|
|
447
|
+
/** IDs of deleted memories */
|
|
448
|
+
deleted_ids: string[];
|
|
449
|
+
/** Whether this was a dry run */
|
|
450
|
+
dry_run: boolean;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Source type for summary views
|
|
454
|
+
*/
|
|
455
|
+
type SummaryViewSource = "long_term" | "working_memory";
|
|
456
|
+
/**
|
|
457
|
+
* Summary view configuration
|
|
458
|
+
*/
|
|
459
|
+
interface SummaryView {
|
|
460
|
+
/** Unique identifier for the view */
|
|
461
|
+
id: string;
|
|
462
|
+
/** Optional human-readable name */
|
|
463
|
+
name?: string | null;
|
|
464
|
+
/** Memory source to summarize */
|
|
465
|
+
source: SummaryViewSource;
|
|
466
|
+
/** Fields to group by for partitioning */
|
|
467
|
+
group_by: string[];
|
|
468
|
+
/** Optional filters to apply */
|
|
469
|
+
filters?: Record<string, unknown> | null;
|
|
470
|
+
/** Time window in days for filtering */
|
|
471
|
+
time_window_days?: number | null;
|
|
472
|
+
/** Whether background workers refresh this view */
|
|
473
|
+
continuous?: boolean;
|
|
474
|
+
/** Custom summarization prompt */
|
|
475
|
+
prompt?: string | null;
|
|
476
|
+
/** Model override for summarization */
|
|
477
|
+
model_name?: string | null;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Request to create a summary view
|
|
481
|
+
*/
|
|
482
|
+
interface CreateSummaryViewRequest {
|
|
483
|
+
/** Optional human-readable name */
|
|
484
|
+
name?: string | null;
|
|
485
|
+
/** Memory source to summarize */
|
|
486
|
+
source: SummaryViewSource;
|
|
487
|
+
/** Fields to group by for partitioning */
|
|
488
|
+
group_by: string[];
|
|
489
|
+
/** Optional filters to apply */
|
|
490
|
+
filters?: Record<string, unknown> | null;
|
|
491
|
+
/** Time window in days for filtering */
|
|
492
|
+
time_window_days?: number | null;
|
|
493
|
+
/** Whether background workers refresh this view */
|
|
494
|
+
continuous?: boolean;
|
|
495
|
+
/** Custom summarization prompt */
|
|
496
|
+
prompt?: string | null;
|
|
497
|
+
/** Model override for summarization */
|
|
498
|
+
model_name?: string | null;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Result of summarizing one partition
|
|
502
|
+
*/
|
|
503
|
+
interface SummaryViewPartitionResult {
|
|
504
|
+
/** ID of the SummaryView that produced this result */
|
|
505
|
+
view_id: string;
|
|
506
|
+
/** Concrete values for the view's group_by fields */
|
|
507
|
+
group: Record<string, string>;
|
|
508
|
+
/** Summarized text for this partition */
|
|
509
|
+
summary: string;
|
|
510
|
+
/** Number of memories that contributed to this summary */
|
|
511
|
+
memory_count: number;
|
|
512
|
+
/** When this summary was computed */
|
|
513
|
+
computed_at?: string;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Request to run a summary view partition
|
|
517
|
+
*/
|
|
518
|
+
interface RunSummaryViewPartitionRequest {
|
|
519
|
+
/** Concrete values for the view's group_by fields */
|
|
520
|
+
group: Record<string, string>;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Request to run a full summary view
|
|
524
|
+
*/
|
|
525
|
+
interface RunSummaryViewRequest {
|
|
526
|
+
/** Force recomputation even if cached */
|
|
527
|
+
force?: boolean;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Task type enum
|
|
531
|
+
*/
|
|
532
|
+
type TaskType = "summary_view_full_run" | string;
|
|
533
|
+
/**
|
|
534
|
+
* Task status enum
|
|
535
|
+
*/
|
|
536
|
+
type TaskStatus = "pending" | "running" | "completed" | "failed";
|
|
537
|
+
/**
|
|
538
|
+
* Background task representation
|
|
539
|
+
*/
|
|
540
|
+
interface Task {
|
|
541
|
+
/** Unique task identifier */
|
|
542
|
+
id: string;
|
|
543
|
+
/** Type of task */
|
|
544
|
+
type: TaskType;
|
|
545
|
+
/** Current task status */
|
|
546
|
+
status: TaskStatus;
|
|
547
|
+
/** Associated SummaryView ID, if applicable */
|
|
548
|
+
view_id?: string | null;
|
|
549
|
+
/** When the task record was created */
|
|
550
|
+
created_at?: string;
|
|
551
|
+
/** When execution started */
|
|
552
|
+
started_at?: string | null;
|
|
553
|
+
/** When execution finished */
|
|
554
|
+
completed_at?: string | null;
|
|
555
|
+
/** Error message if failed */
|
|
556
|
+
error_message?: string | null;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Agent Memory API Client
|
|
561
|
+
*
|
|
562
|
+
* A TypeScript/JavaScript client for the Agent Memory Server REST API.
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Configuration for the Memory API Client
|
|
567
|
+
*/
|
|
568
|
+
interface MemoryClientConfig {
|
|
569
|
+
/** Base URL of the memory server (e.g., 'http://localhost:8000') */
|
|
570
|
+
baseUrl: string;
|
|
571
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
572
|
+
timeout?: number;
|
|
573
|
+
/** Optional default namespace to use for operations */
|
|
574
|
+
defaultNamespace?: string;
|
|
575
|
+
/** Optional default model name for auto-summarization */
|
|
576
|
+
defaultModelName?: ModelNameLiteral;
|
|
577
|
+
/** Optional default context window limit for auto-summarization */
|
|
578
|
+
defaultContextWindowMax?: number;
|
|
579
|
+
/** Optional API key for authentication */
|
|
580
|
+
apiKey?: string;
|
|
581
|
+
/** Optional bearer token for authentication */
|
|
582
|
+
bearerToken?: string;
|
|
583
|
+
/** Custom fetch function (for testing or custom implementations) */
|
|
584
|
+
fetch?: typeof fetch;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Options for search operations
|
|
588
|
+
*/
|
|
589
|
+
interface SearchOptions {
|
|
590
|
+
text: string;
|
|
591
|
+
sessionId?: SessionId | {
|
|
592
|
+
eq?: string;
|
|
593
|
+
in_?: string[];
|
|
594
|
+
not_eq?: string;
|
|
595
|
+
not_in?: string[];
|
|
596
|
+
};
|
|
597
|
+
namespace?: Namespace | {
|
|
598
|
+
eq?: string;
|
|
599
|
+
in_?: string[];
|
|
600
|
+
not_eq?: string;
|
|
601
|
+
not_in?: string[];
|
|
602
|
+
};
|
|
603
|
+
topics?: Topics | {
|
|
604
|
+
any?: string[];
|
|
605
|
+
all?: string[];
|
|
606
|
+
none?: string[];
|
|
607
|
+
};
|
|
608
|
+
entities?: Entities | {
|
|
609
|
+
any?: string[];
|
|
610
|
+
all?: string[];
|
|
611
|
+
none?: string[];
|
|
612
|
+
};
|
|
613
|
+
createdAt?: CreatedAt | {
|
|
614
|
+
gte?: Date | string;
|
|
615
|
+
lte?: Date | string;
|
|
616
|
+
eq?: Date | string;
|
|
617
|
+
};
|
|
618
|
+
lastAccessed?: LastAccessed | {
|
|
619
|
+
gte?: Date | string;
|
|
620
|
+
lte?: Date | string;
|
|
621
|
+
eq?: Date | string;
|
|
622
|
+
};
|
|
623
|
+
userId?: UserId | {
|
|
624
|
+
eq?: string;
|
|
625
|
+
in_?: string[];
|
|
626
|
+
not_eq?: string;
|
|
627
|
+
not_in?: string[];
|
|
628
|
+
};
|
|
629
|
+
memoryType?: MemoryType | {
|
|
630
|
+
eq?: string;
|
|
631
|
+
in_?: string[];
|
|
632
|
+
not_eq?: string;
|
|
633
|
+
not_in?: string[];
|
|
634
|
+
};
|
|
635
|
+
eventDate?: EventDate | {
|
|
636
|
+
gte?: Date | string;
|
|
637
|
+
lte?: Date | string;
|
|
638
|
+
eq?: Date | string;
|
|
639
|
+
};
|
|
640
|
+
distanceThreshold?: number;
|
|
641
|
+
limit?: number;
|
|
642
|
+
offset?: number;
|
|
643
|
+
recency?: RecencyConfig;
|
|
644
|
+
optimizeQuery?: boolean;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Client for the Agent Memory Server REST API.
|
|
648
|
+
*
|
|
649
|
+
* Provides methods to interact with all server endpoints:
|
|
650
|
+
* - Health check
|
|
651
|
+
* - Session management (list, get, put, delete)
|
|
652
|
+
* - Long-term memory (create, search, edit, delete)
|
|
653
|
+
*/
|
|
654
|
+
declare class MemoryAPIClient {
|
|
655
|
+
private readonly config;
|
|
656
|
+
private readonly fetchFn;
|
|
657
|
+
constructor(config: MemoryClientConfig);
|
|
658
|
+
/**
|
|
659
|
+
* Get default headers for requests
|
|
660
|
+
*/
|
|
661
|
+
private getHeaders;
|
|
662
|
+
/**
|
|
663
|
+
* Make an HTTP request with error handling
|
|
664
|
+
*/
|
|
665
|
+
private request;
|
|
666
|
+
/**
|
|
667
|
+
* Handle HTTP error responses
|
|
668
|
+
*/
|
|
669
|
+
private handleHttpError;
|
|
670
|
+
/**
|
|
671
|
+
* Check server health
|
|
672
|
+
*/
|
|
673
|
+
healthCheck(): Promise<HealthCheckResponse>;
|
|
674
|
+
/**
|
|
675
|
+
* List all session IDs
|
|
676
|
+
*/
|
|
677
|
+
listSessions(options?: {
|
|
678
|
+
namespace?: string;
|
|
679
|
+
limit?: number;
|
|
680
|
+
offset?: number;
|
|
681
|
+
}): Promise<SessionListResponse>;
|
|
682
|
+
/**
|
|
683
|
+
* Get working memory for a session
|
|
684
|
+
*/
|
|
685
|
+
getWorkingMemory(sessionId: string, options?: {
|
|
686
|
+
namespace?: string;
|
|
687
|
+
modelName?: ModelNameLiteral;
|
|
688
|
+
contextWindowMax?: number;
|
|
689
|
+
}): Promise<WorkingMemoryResponse | null>;
|
|
690
|
+
/**
|
|
691
|
+
* Get or create working memory for a session
|
|
692
|
+
*/
|
|
693
|
+
getOrCreateWorkingMemory(sessionId: string, options?: {
|
|
694
|
+
namespace?: string;
|
|
695
|
+
userId?: string;
|
|
696
|
+
modelName?: ModelNameLiteral;
|
|
697
|
+
contextWindowMax?: number;
|
|
698
|
+
ttlSeconds?: number;
|
|
699
|
+
longTermMemoryStrategy?: MemoryStrategyConfig;
|
|
700
|
+
}): Promise<WorkingMemoryResponse>;
|
|
701
|
+
/**
|
|
702
|
+
* Create or update working memory for a session
|
|
703
|
+
*/
|
|
704
|
+
putWorkingMemory(sessionId: string, workingMemory: Partial<WorkingMemory>, options?: {
|
|
705
|
+
namespace?: string;
|
|
706
|
+
modelName?: ModelNameLiteral;
|
|
707
|
+
contextWindowMax?: number;
|
|
708
|
+
background?: boolean;
|
|
709
|
+
}): Promise<WorkingMemoryResponse>;
|
|
710
|
+
/**
|
|
711
|
+
* Delete working memory for a session
|
|
712
|
+
*/
|
|
713
|
+
deleteWorkingMemory(sessionId: string, options?: {
|
|
714
|
+
namespace?: string;
|
|
715
|
+
}): Promise<AckResponse>;
|
|
716
|
+
/**
|
|
717
|
+
* Create long-term memory records
|
|
718
|
+
*/
|
|
719
|
+
createLongTermMemory(memories: MemoryRecord[], options?: {
|
|
720
|
+
namespace?: string;
|
|
721
|
+
}): Promise<AckResponse>;
|
|
722
|
+
/**
|
|
723
|
+
* Search long-term memory
|
|
724
|
+
*/
|
|
725
|
+
searchLongTermMemory(options: SearchOptions): Promise<MemoryRecordResults>;
|
|
726
|
+
/**
|
|
727
|
+
* Get a long-term memory by ID
|
|
728
|
+
*/
|
|
729
|
+
getLongTermMemory(memoryId: string, options?: {
|
|
730
|
+
namespace?: string;
|
|
731
|
+
}): Promise<MemoryRecord | null>;
|
|
732
|
+
/**
|
|
733
|
+
* Delete long-term memories by IDs
|
|
734
|
+
*/
|
|
735
|
+
deleteLongTermMemories(memoryIds: string[], options?: {
|
|
736
|
+
namespace?: string;
|
|
737
|
+
}): Promise<AckResponse>;
|
|
738
|
+
/**
|
|
739
|
+
* Get memory-enhanced prompt
|
|
740
|
+
*/
|
|
741
|
+
memoryPrompt(request: MemoryPromptRequest): Promise<MemoryPromptResponse>;
|
|
742
|
+
/**
|
|
743
|
+
* Edit a long-term memory by ID
|
|
744
|
+
*/
|
|
745
|
+
editLongTermMemory(memoryId: string, updates: Partial<MemoryRecord>): Promise<MemoryRecord>;
|
|
746
|
+
/**
|
|
747
|
+
* Run a forgetting pass with the provided policy
|
|
748
|
+
*/
|
|
749
|
+
forgetLongTermMemories(options: {
|
|
750
|
+
policy: ForgetPolicy;
|
|
751
|
+
namespace?: string;
|
|
752
|
+
userId?: string;
|
|
753
|
+
sessionId?: string;
|
|
754
|
+
limit?: number;
|
|
755
|
+
dryRun?: boolean;
|
|
756
|
+
pinnedIds?: string[];
|
|
757
|
+
}): Promise<ForgetResponse>;
|
|
758
|
+
/**
|
|
759
|
+
* List all summary views
|
|
760
|
+
*/
|
|
761
|
+
listSummaryViews(): Promise<SummaryView[]>;
|
|
762
|
+
/**
|
|
763
|
+
* Create a new summary view
|
|
764
|
+
*/
|
|
765
|
+
createSummaryView(request: CreateSummaryViewRequest): Promise<SummaryView>;
|
|
766
|
+
/**
|
|
767
|
+
* Get a summary view by ID
|
|
768
|
+
*/
|
|
769
|
+
getSummaryView(viewId: string): Promise<SummaryView | null>;
|
|
770
|
+
/**
|
|
771
|
+
* Delete a summary view
|
|
772
|
+
*/
|
|
773
|
+
deleteSummaryView(viewId: string): Promise<AckResponse>;
|
|
774
|
+
/**
|
|
775
|
+
* Run a summary view partition
|
|
776
|
+
*/
|
|
777
|
+
runSummaryViewPartition(viewId: string, group: Record<string, string>): Promise<SummaryViewPartitionResult>;
|
|
778
|
+
/**
|
|
779
|
+
* List summary view partitions
|
|
780
|
+
*/
|
|
781
|
+
listSummaryViewPartitions(viewId: string, options?: {
|
|
782
|
+
namespace?: string;
|
|
783
|
+
userId?: string;
|
|
784
|
+
sessionId?: string;
|
|
785
|
+
memoryType?: string;
|
|
786
|
+
}): Promise<SummaryViewPartitionResult[]>;
|
|
787
|
+
/**
|
|
788
|
+
* Run a full summary view (async task)
|
|
789
|
+
*/
|
|
790
|
+
runSummaryView(viewId: string, options?: {
|
|
791
|
+
force?: boolean;
|
|
792
|
+
}): Promise<Task>;
|
|
793
|
+
/**
|
|
794
|
+
* Get a task by ID
|
|
795
|
+
*/
|
|
796
|
+
getTask(taskId: string): Promise<Task | null>;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Exception classes for the Agent Memory Client.
|
|
801
|
+
*/
|
|
802
|
+
/**
|
|
803
|
+
* Base error for all memory client errors.
|
|
804
|
+
*/
|
|
805
|
+
declare class MemoryClientError extends Error {
|
|
806
|
+
constructor(message: string);
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Raised when memory record or filter validation fails.
|
|
810
|
+
*/
|
|
811
|
+
declare class MemoryValidationError extends MemoryClientError {
|
|
812
|
+
constructor(message: string);
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Raised when a requested memory or session is not found.
|
|
816
|
+
*/
|
|
817
|
+
declare class MemoryNotFoundError extends MemoryClientError {
|
|
818
|
+
constructor(message: string);
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Raised when the memory server returns an error.
|
|
822
|
+
*/
|
|
823
|
+
declare class MemoryServerError extends MemoryClientError {
|
|
824
|
+
statusCode?: number;
|
|
825
|
+
constructor(message: string, statusCode?: number);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export { type AckResponse, type CreateSummaryViewRequest, CreatedAt, Entities, EventDate, type ForgetPolicy, type ForgetResponse, type HealthCheckResponse, LastAccessed, MemoryAPIClient, type MemoryClientConfig, MemoryClientError, type MemoryMessage, MemoryNotFoundError, type MemoryPromptRequest, type MemoryPromptResponse, type MemoryRecord, type MemoryRecordResult, type MemoryRecordResults, MemoryServerError, MemoryType, MemoryValidationError, Namespace, type RecencyConfig, type RunSummaryViewPartitionRequest, type RunSummaryViewRequest, type SearchOptions, SessionId, type SessionListResponse, type SummaryView, type SummaryViewPartitionResult, type SummaryViewSource, type Task, type TaskStatus, type TaskType, Topics, UserId, type WorkingMemory, type WorkingMemoryResponse };
|