@memstack/core 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/LICENSE +21 -0
- package/README.md +774 -0
- package/dist/index.cjs +1991 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +536 -0
- package/dist/index.d.ts +536 -0
- package/dist/index.js +1974 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
- package/src/adapters/embedding/cohere.ts +77 -0
- package/src/adapters/embedding/openai.ts +65 -0
- package/src/adapters/llm/anthropic.ts +69 -0
- package/src/adapters/llm/groq.ts +185 -0
- package/src/adapters/llm/ollama.ts +85 -0
- package/src/adapters/llm/openai.ts +178 -0
- package/src/adapters/storage/disk.ts +334 -0
- package/src/adapters/storage/memory.ts +147 -0
- package/src/adapters/storage/postgres.ts +310 -0
- package/src/adapters/storage/redis.ts +274 -0
- package/src/client.ts +236 -0
- package/src/errors.ts +47 -0
- package/src/index.ts +52 -0
- package/src/interfaces.ts +154 -0
- package/src/memory/ContextCompiler.ts +158 -0
- package/src/memory/MemoryStore.ts +266 -0
- package/src/memory/Pruner.ts +66 -0
- package/src/memory/Summarizer.ts +46 -0
- package/src/types.ts +50 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
type MemoryType = "interaction" | "summary" | "observation" | "gossip";
|
|
2
|
+
interface Memory {
|
|
3
|
+
id: string;
|
|
4
|
+
actorId: string;
|
|
5
|
+
memoryType: MemoryType;
|
|
6
|
+
content: string;
|
|
7
|
+
importance: number;
|
|
8
|
+
emotionalValence: number;
|
|
9
|
+
tags: string[];
|
|
10
|
+
embedding?: number[];
|
|
11
|
+
sourceId?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
expiresAt?: Date;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
}
|
|
16
|
+
interface CompiledContext {
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
recentMemories: Memory[];
|
|
19
|
+
importantMemories: Memory[];
|
|
20
|
+
tokenEstimate: number;
|
|
21
|
+
}
|
|
22
|
+
interface ProcessResult {
|
|
23
|
+
memory: Memory;
|
|
24
|
+
summaryCreated?: Memory;
|
|
25
|
+
}
|
|
26
|
+
interface MemStackSnapshot {
|
|
27
|
+
version: 1;
|
|
28
|
+
memories: Memory[];
|
|
29
|
+
exportedAt: string;
|
|
30
|
+
}
|
|
31
|
+
interface HealthStatus {
|
|
32
|
+
storage: boolean;
|
|
33
|
+
llm: boolean;
|
|
34
|
+
embedding: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface MemoryStoreInput {
|
|
38
|
+
actorId: string;
|
|
39
|
+
content: string;
|
|
40
|
+
memoryType?: MemoryType;
|
|
41
|
+
importance?: number;
|
|
42
|
+
emotionalValence?: number;
|
|
43
|
+
tags?: string[];
|
|
44
|
+
embedding?: number[];
|
|
45
|
+
sourceId?: string;
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
expiresAt?: Date;
|
|
48
|
+
onConflict?: "append";
|
|
49
|
+
/** Pre-assigned ID. When set, the storage adapter uses it instead of generating one. */
|
|
50
|
+
id?: string;
|
|
51
|
+
}
|
|
52
|
+
interface MemoryCountFilter {
|
|
53
|
+
actorId?: string;
|
|
54
|
+
memoryType?: MemoryType;
|
|
55
|
+
minImportance?: number;
|
|
56
|
+
}
|
|
57
|
+
interface MemoryRetrieveQuery {
|
|
58
|
+
actorId?: string;
|
|
59
|
+
query?: string;
|
|
60
|
+
memoryTypes?: MemoryType[];
|
|
61
|
+
tags?: string[];
|
|
62
|
+
limit?: number;
|
|
63
|
+
strategy?: "semantic" | "hybrid" | "recent" | "important";
|
|
64
|
+
}
|
|
65
|
+
interface ContextOptions {
|
|
66
|
+
actorId: string;
|
|
67
|
+
maxTokens?: number;
|
|
68
|
+
memoryTypes?: MemoryType[];
|
|
69
|
+
}
|
|
70
|
+
interface SummarizeOptions {
|
|
71
|
+
actorId?: string;
|
|
72
|
+
olderThan?: Date;
|
|
73
|
+
skipMostRecent?: number;
|
|
74
|
+
targetCount?: number;
|
|
75
|
+
memoryTypes?: MemoryType[];
|
|
76
|
+
keepOriginals?: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface PruneStrategy {
|
|
79
|
+
type: "byAge" | "byImportance" | "byCount" | "byType" | "custom";
|
|
80
|
+
maxAge?: number;
|
|
81
|
+
minImportance?: number;
|
|
82
|
+
maxPerActor?: number;
|
|
83
|
+
memoryTypes?: MemoryType[];
|
|
84
|
+
/** Custom predicate: return true for memories that should be REMOVED. */
|
|
85
|
+
shouldRemove?: (memory: Memory) => boolean;
|
|
86
|
+
}
|
|
87
|
+
interface LLMProvider {
|
|
88
|
+
complete(request: {
|
|
89
|
+
system: string;
|
|
90
|
+
user: string;
|
|
91
|
+
model?: string;
|
|
92
|
+
temperature?: number;
|
|
93
|
+
maxTokens?: number;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
text: string;
|
|
96
|
+
tokens: {
|
|
97
|
+
prompt: number;
|
|
98
|
+
completion: number;
|
|
99
|
+
total: number;
|
|
100
|
+
};
|
|
101
|
+
}>;
|
|
102
|
+
/** Optional streaming variant. Returns an async iterable of text chunks. */
|
|
103
|
+
completeStream?(request: {
|
|
104
|
+
system: string;
|
|
105
|
+
user: string;
|
|
106
|
+
model?: string;
|
|
107
|
+
temperature?: number;
|
|
108
|
+
maxTokens?: number;
|
|
109
|
+
}): AsyncIterable<{
|
|
110
|
+
text: string;
|
|
111
|
+
tokens: {
|
|
112
|
+
prompt: number;
|
|
113
|
+
completion: number;
|
|
114
|
+
total: number;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
interface EmbeddingProvider {
|
|
119
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
120
|
+
dimensions: number;
|
|
121
|
+
}
|
|
122
|
+
interface StorageProvider {
|
|
123
|
+
initialize(): Promise<void>;
|
|
124
|
+
store(memory: MemoryStoreInput): Promise<Memory>;
|
|
125
|
+
storeBatch(memories: MemoryStoreInput[]): Promise<Memory[]>;
|
|
126
|
+
get(id: string): Promise<Memory | null>;
|
|
127
|
+
delete(id: string): Promise<void>;
|
|
128
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
129
|
+
/** Update the last-accessed timestamp for a memory without changing its content, id, or createdAt. */
|
|
130
|
+
touch?(id: string): Promise<void>;
|
|
131
|
+
retrieve(query: MemoryRetrieveQuery, embedding?: number[]): Promise<Memory[]>;
|
|
132
|
+
count(filter?: MemoryCountFilter): Promise<number>;
|
|
133
|
+
close(): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
interface MemStackConfig {
|
|
136
|
+
llm: LLMProvider;
|
|
137
|
+
embedding?: EmbeddingProvider;
|
|
138
|
+
storage?: StorageProvider;
|
|
139
|
+
defaults?: {
|
|
140
|
+
summarizationThreshold?: number;
|
|
141
|
+
embedOnStore?: boolean;
|
|
142
|
+
pruneStrategy?: PruneStrategy;
|
|
143
|
+
pruneInterval?: number;
|
|
144
|
+
autoImportance?: boolean;
|
|
145
|
+
autoTags?: boolean;
|
|
146
|
+
summarizationPrompt?: string;
|
|
147
|
+
};
|
|
148
|
+
hooks?: {
|
|
149
|
+
onMemoryStored?: (memory: Memory) => void;
|
|
150
|
+
onMemoryPruned?: (ids: string[]) => void;
|
|
151
|
+
onSummaryCreated?: (summary: Memory, deletedCount: number) => void;
|
|
152
|
+
onError?: (error: Error, context: string) => void;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
interface ProcessInput {
|
|
156
|
+
actorId: string;
|
|
157
|
+
content: string;
|
|
158
|
+
memoryType?: MemoryType;
|
|
159
|
+
importance?: number;
|
|
160
|
+
emotionalValence?: number;
|
|
161
|
+
tags?: string[];
|
|
162
|
+
metadata?: Record<string, unknown>;
|
|
163
|
+
expiresAt?: Date;
|
|
164
|
+
onConflict?: "append";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface MemoryStoreConfig {
|
|
168
|
+
storage: StorageProvider;
|
|
169
|
+
embedding?: EmbeddingProvider;
|
|
170
|
+
llm?: LLMProvider;
|
|
171
|
+
embedOnStore?: boolean;
|
|
172
|
+
summarizationPrompt?: string;
|
|
173
|
+
}
|
|
174
|
+
declare class MemoryStore {
|
|
175
|
+
private storage;
|
|
176
|
+
private embedding?;
|
|
177
|
+
private summarizer?;
|
|
178
|
+
private pruner;
|
|
179
|
+
private compiler;
|
|
180
|
+
private embedOnStore;
|
|
181
|
+
constructor(config: MemoryStoreConfig);
|
|
182
|
+
store(input: MemoryStoreInput): Promise<Memory>;
|
|
183
|
+
storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
|
|
184
|
+
get(id: string): Promise<Memory | null>;
|
|
185
|
+
delete(id: string): Promise<void>;
|
|
186
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
187
|
+
touch(id: string): Promise<void>;
|
|
188
|
+
count(filter?: MemoryCountFilter): Promise<number>;
|
|
189
|
+
retrieve(query: MemoryRetrieveQuery): Promise<Memory[]>;
|
|
190
|
+
compileContext(options: ContextOptions): Promise<CompiledContext>;
|
|
191
|
+
summarize(options: SummarizeOptions, onError?: (err: Error) => void): Promise<{
|
|
192
|
+
summary: Memory;
|
|
193
|
+
deletedCount: number;
|
|
194
|
+
}>;
|
|
195
|
+
prune(strategy: PruneStrategy): Promise<{
|
|
196
|
+
pruned: string[];
|
|
197
|
+
count: number;
|
|
198
|
+
}>;
|
|
199
|
+
dryRunPrune(strategy: PruneStrategy): Promise<{
|
|
200
|
+
wouldPrune: string[];
|
|
201
|
+
count: number;
|
|
202
|
+
}>;
|
|
203
|
+
export(): Promise<Memory[]>;
|
|
204
|
+
private _hashContent;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare class MemStack {
|
|
208
|
+
readonly memory: MemoryStore;
|
|
209
|
+
private config;
|
|
210
|
+
private storage;
|
|
211
|
+
private processCount;
|
|
212
|
+
constructor(config: MemStackConfig);
|
|
213
|
+
process(input: ProcessInput): Promise<ProcessResult>;
|
|
214
|
+
export(): Promise<MemStackSnapshot>;
|
|
215
|
+
import(snapshot: MemStackSnapshot): Promise<void>;
|
|
216
|
+
health(): Promise<HealthStatus>;
|
|
217
|
+
close(): Promise<void>;
|
|
218
|
+
private _parseEnrichmentJson;
|
|
219
|
+
private _parseTagsJson;
|
|
220
|
+
/** Strip markdown code fences and extract the JSON payload from LLM output. */
|
|
221
|
+
private _extractJson;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
type MemStackErrorCode = "STORAGE_ERROR" | "EMBEDDING_ERROR" | "LLM_ERROR" | "VALIDATION_ERROR" | "NOT_FOUND" | "CONFIG_ERROR";
|
|
225
|
+
declare class MemStackError extends Error {
|
|
226
|
+
code: MemStackErrorCode;
|
|
227
|
+
retryable: boolean;
|
|
228
|
+
details?: Record<string, unknown>;
|
|
229
|
+
constructor(code: MemStackErrorCode, message: string, options?: {
|
|
230
|
+
retryable?: boolean;
|
|
231
|
+
details?: Record<string, unknown>;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
declare function notFound(entity: string, id: string): MemStackError;
|
|
235
|
+
declare function validationError(message: string, details?: Record<string, unknown>): MemStackError;
|
|
236
|
+
declare function storageError(message: string, cause?: unknown): MemStackError;
|
|
237
|
+
declare function configError(message: string): MemStackError;
|
|
238
|
+
|
|
239
|
+
declare class InMemoryStorage implements StorageProvider {
|
|
240
|
+
private memories;
|
|
241
|
+
initialize(): Promise<void>;
|
|
242
|
+
generateId(): string;
|
|
243
|
+
store(input: MemoryStoreInput): Promise<Memory>;
|
|
244
|
+
storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
|
|
245
|
+
get(id: string): Promise<Memory | null>;
|
|
246
|
+
delete(id: string): Promise<void>;
|
|
247
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
248
|
+
retrieve(query: MemoryRetrieveQuery, _embedding?: number[]): Promise<Memory[]>;
|
|
249
|
+
count(filter?: MemoryCountFilter): Promise<number>;
|
|
250
|
+
touch(id: string): Promise<void>;
|
|
251
|
+
close(): Promise<void>;
|
|
252
|
+
getAllMemories(): Memory[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
interface DiskStorageConfig {
|
|
256
|
+
/** Directory to store memory files. Default: "./memstack-data" */
|
|
257
|
+
storageDir?: string;
|
|
258
|
+
}
|
|
259
|
+
declare class DiskStorage implements StorageProvider {
|
|
260
|
+
private dir;
|
|
261
|
+
private _writeLocks;
|
|
262
|
+
constructor(config?: DiskStorageConfig);
|
|
263
|
+
initialize(): Promise<void>;
|
|
264
|
+
generateId(): string;
|
|
265
|
+
store(input: MemoryStoreInput): Promise<Memory>;
|
|
266
|
+
storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
|
|
267
|
+
get(id: string): Promise<Memory | null>;
|
|
268
|
+
delete(id: string): Promise<void>;
|
|
269
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
270
|
+
retrieve(query: MemoryRetrieveQuery, _embedding?: number[]): Promise<Memory[]>;
|
|
271
|
+
count(filter?: MemoryCountFilter): Promise<number>;
|
|
272
|
+
touch(id: string): Promise<void>;
|
|
273
|
+
close(): Promise<void>;
|
|
274
|
+
private _filePath;
|
|
275
|
+
private _readFile;
|
|
276
|
+
private _writeFile;
|
|
277
|
+
private _withWriteLock;
|
|
278
|
+
private _listActors;
|
|
279
|
+
private _toExternal;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type RedisClient = {
|
|
283
|
+
set(key: string, value: string): Promise<unknown>;
|
|
284
|
+
get(key: string): Promise<string | null>;
|
|
285
|
+
mget(...keys: string[]): Promise<(string | null)[]>;
|
|
286
|
+
del(key: string | string[]): Promise<number>;
|
|
287
|
+
sadd(key: string, ...members: string[]): Promise<number>;
|
|
288
|
+
srem(key: string, ...members: string[]): Promise<number>;
|
|
289
|
+
smembers(key: string): Promise<string[]>;
|
|
290
|
+
};
|
|
291
|
+
interface RedisStorageConfig {
|
|
292
|
+
/** An active ioredis client instance (or compatible) */
|
|
293
|
+
redis: RedisClient;
|
|
294
|
+
/** Key prefix. Default: "memstack" */
|
|
295
|
+
keyPrefix?: string;
|
|
296
|
+
}
|
|
297
|
+
declare class RedisStorage implements StorageProvider {
|
|
298
|
+
private redis;
|
|
299
|
+
private prefix;
|
|
300
|
+
constructor(config: RedisStorageConfig);
|
|
301
|
+
initialize(): Promise<void>;
|
|
302
|
+
generateId(): string;
|
|
303
|
+
store(input: MemoryStoreInput): Promise<Memory>;
|
|
304
|
+
storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
|
|
305
|
+
get(id: string): Promise<Memory | null>;
|
|
306
|
+
delete(id: string): Promise<void>;
|
|
307
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
308
|
+
retrieve(query: MemoryRetrieveQuery, _embedding?: number[]): Promise<Memory[]>;
|
|
309
|
+
count(filter?: MemoryCountFilter): Promise<number>;
|
|
310
|
+
close(): Promise<void>;
|
|
311
|
+
private _actorsSetKey;
|
|
312
|
+
private _actorKey;
|
|
313
|
+
private _memKey;
|
|
314
|
+
private _getActorRecords;
|
|
315
|
+
private _listActors;
|
|
316
|
+
private _toExternal;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
type PgPool = {
|
|
320
|
+
query(text: string, params?: unknown[]): Promise<{
|
|
321
|
+
rows: unknown[];
|
|
322
|
+
}>;
|
|
323
|
+
};
|
|
324
|
+
interface PostgresStorageConfig {
|
|
325
|
+
/** An active pg Pool instance */
|
|
326
|
+
pool: PgPool;
|
|
327
|
+
/** Table name. Default: "memstack_memories" */
|
|
328
|
+
tableName?: string;
|
|
329
|
+
/** Automatically run CREATE TABLE IF NOT EXISTS on init. Default: true */
|
|
330
|
+
autoMigrate?: boolean;
|
|
331
|
+
}
|
|
332
|
+
declare class PostgresStorage implements StorageProvider {
|
|
333
|
+
private pool;
|
|
334
|
+
private table;
|
|
335
|
+
private autoMigrate;
|
|
336
|
+
constructor(config: PostgresStorageConfig);
|
|
337
|
+
initialize(): Promise<void>;
|
|
338
|
+
generateId(): string;
|
|
339
|
+
store(input: MemoryStoreInput): Promise<Memory>;
|
|
340
|
+
storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
|
|
341
|
+
get(id: string): Promise<Memory | null>;
|
|
342
|
+
delete(id: string): Promise<void>;
|
|
343
|
+
deleteMany(ids: string[]): Promise<number>;
|
|
344
|
+
retrieve(query: MemoryRetrieveQuery, embedding?: number[]): Promise<Memory[]>;
|
|
345
|
+
count(filter?: MemoryCountFilter): Promise<number>;
|
|
346
|
+
close(): Promise<void>;
|
|
347
|
+
private _semanticRetrieve;
|
|
348
|
+
private _rowToMemory;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface OpenAILLMConfig {
|
|
352
|
+
apiKey: string;
|
|
353
|
+
baseURL?: string;
|
|
354
|
+
defaultModel?: string;
|
|
355
|
+
defaultTemperature?: number;
|
|
356
|
+
defaultMaxTokens?: number;
|
|
357
|
+
}
|
|
358
|
+
declare class OpenAILLMAdapter implements LLMProvider {
|
|
359
|
+
private apiKey;
|
|
360
|
+
private baseURL;
|
|
361
|
+
private defaultModel;
|
|
362
|
+
private defaultTemperature;
|
|
363
|
+
private defaultMaxTokens;
|
|
364
|
+
constructor(config: OpenAILLMConfig);
|
|
365
|
+
complete(request: {
|
|
366
|
+
system: string;
|
|
367
|
+
user: string;
|
|
368
|
+
model?: string;
|
|
369
|
+
temperature?: number;
|
|
370
|
+
maxTokens?: number;
|
|
371
|
+
}): Promise<{
|
|
372
|
+
text: string;
|
|
373
|
+
tokens: {
|
|
374
|
+
prompt: number;
|
|
375
|
+
completion: number;
|
|
376
|
+
total: number;
|
|
377
|
+
};
|
|
378
|
+
}>;
|
|
379
|
+
completeStream(request: {
|
|
380
|
+
system: string;
|
|
381
|
+
user: string;
|
|
382
|
+
model?: string;
|
|
383
|
+
temperature?: number;
|
|
384
|
+
maxTokens?: number;
|
|
385
|
+
}): AsyncIterable<{
|
|
386
|
+
text: string;
|
|
387
|
+
tokens: {
|
|
388
|
+
prompt: number;
|
|
389
|
+
completion: number;
|
|
390
|
+
total: number;
|
|
391
|
+
};
|
|
392
|
+
}>;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
interface AnthropicLLMConfig {
|
|
396
|
+
apiKey: string;
|
|
397
|
+
baseURL?: string;
|
|
398
|
+
defaultModel?: string;
|
|
399
|
+
defaultMaxTokens?: number;
|
|
400
|
+
}
|
|
401
|
+
declare class AnthropicLLMAdapter implements LLMProvider {
|
|
402
|
+
private apiKey;
|
|
403
|
+
private baseURL;
|
|
404
|
+
private defaultModel;
|
|
405
|
+
private defaultMaxTokens;
|
|
406
|
+
private sdk;
|
|
407
|
+
constructor(config: AnthropicLLMConfig);
|
|
408
|
+
complete(request: {
|
|
409
|
+
system: string;
|
|
410
|
+
user: string;
|
|
411
|
+
model?: string;
|
|
412
|
+
temperature?: number;
|
|
413
|
+
maxTokens?: number;
|
|
414
|
+
}): Promise<{
|
|
415
|
+
text: string;
|
|
416
|
+
tokens: {
|
|
417
|
+
prompt: number;
|
|
418
|
+
completion: number;
|
|
419
|
+
total: number;
|
|
420
|
+
};
|
|
421
|
+
}>;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
interface OpenAIEmbeddingConfig {
|
|
425
|
+
apiKey: string;
|
|
426
|
+
baseURL?: string;
|
|
427
|
+
model?: string;
|
|
428
|
+
}
|
|
429
|
+
declare class OpenAIEmbeddingAdapter implements EmbeddingProvider {
|
|
430
|
+
private apiKey;
|
|
431
|
+
private baseURL;
|
|
432
|
+
private model;
|
|
433
|
+
readonly dimensions: number;
|
|
434
|
+
constructor(config: OpenAIEmbeddingConfig);
|
|
435
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
interface CohereEmbeddingConfig {
|
|
439
|
+
/** Cohere API key */
|
|
440
|
+
apiKey: string;
|
|
441
|
+
/** Model name. Default: "embed-english-v3.0" (1024 dims) */
|
|
442
|
+
model?: string;
|
|
443
|
+
/** Base URL. Default: "https://api.cohere.ai/v1" */
|
|
444
|
+
baseURL?: string;
|
|
445
|
+
}
|
|
446
|
+
declare class CohereEmbeddingAdapter implements EmbeddingProvider {
|
|
447
|
+
private apiKey;
|
|
448
|
+
private baseURL;
|
|
449
|
+
private model;
|
|
450
|
+
readonly dimensions: number;
|
|
451
|
+
constructor(config: CohereEmbeddingConfig);
|
|
452
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
interface OllamaLLMConfig {
|
|
456
|
+
/** Ollama server URL. Default: "http://localhost:11434" */
|
|
457
|
+
baseURL?: string;
|
|
458
|
+
/** Default model name. Default: "llama3.2" */
|
|
459
|
+
defaultModel?: string;
|
|
460
|
+
/** Default temperature. Default: 0.7 */
|
|
461
|
+
defaultTemperature?: number;
|
|
462
|
+
/** Default max tokens. Default: 1024 */
|
|
463
|
+
defaultMaxTokens?: number;
|
|
464
|
+
}
|
|
465
|
+
declare class OllamaLLMAdapter implements LLMProvider {
|
|
466
|
+
private baseURL;
|
|
467
|
+
private defaultModel;
|
|
468
|
+
private defaultTemperature;
|
|
469
|
+
private defaultMaxTokens;
|
|
470
|
+
constructor(config?: OllamaLLMConfig);
|
|
471
|
+
complete(request: {
|
|
472
|
+
system: string;
|
|
473
|
+
user: string;
|
|
474
|
+
model?: string;
|
|
475
|
+
temperature?: number;
|
|
476
|
+
maxTokens?: number;
|
|
477
|
+
}): Promise<{
|
|
478
|
+
text: string;
|
|
479
|
+
tokens: {
|
|
480
|
+
prompt: number;
|
|
481
|
+
completion: number;
|
|
482
|
+
total: number;
|
|
483
|
+
};
|
|
484
|
+
}>;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
interface GroqLLMConfig {
|
|
488
|
+
/** Groq API key */
|
|
489
|
+
apiKey: string;
|
|
490
|
+
/** Base URL. Default: "https://api.groq.com/openai/v1" */
|
|
491
|
+
baseURL?: string;
|
|
492
|
+
/** Default model. Default: "llama-3.3-70b-versatile" */
|
|
493
|
+
defaultModel?: string;
|
|
494
|
+
/** Default temperature. Default: 0.7 */
|
|
495
|
+
defaultTemperature?: number;
|
|
496
|
+
/** Default max tokens. Default: 1024 */
|
|
497
|
+
defaultMaxTokens?: number;
|
|
498
|
+
}
|
|
499
|
+
declare class GroqLLMAdapter implements LLMProvider {
|
|
500
|
+
private apiKey;
|
|
501
|
+
private baseURL;
|
|
502
|
+
private defaultModel;
|
|
503
|
+
private defaultTemperature;
|
|
504
|
+
private defaultMaxTokens;
|
|
505
|
+
constructor(config: GroqLLMConfig);
|
|
506
|
+
complete(request: {
|
|
507
|
+
system: string;
|
|
508
|
+
user: string;
|
|
509
|
+
model?: string;
|
|
510
|
+
temperature?: number;
|
|
511
|
+
maxTokens?: number;
|
|
512
|
+
}): Promise<{
|
|
513
|
+
text: string;
|
|
514
|
+
tokens: {
|
|
515
|
+
prompt: number;
|
|
516
|
+
completion: number;
|
|
517
|
+
total: number;
|
|
518
|
+
};
|
|
519
|
+
}>;
|
|
520
|
+
completeStream(request: {
|
|
521
|
+
system: string;
|
|
522
|
+
user: string;
|
|
523
|
+
model?: string;
|
|
524
|
+
temperature?: number;
|
|
525
|
+
maxTokens?: number;
|
|
526
|
+
}): AsyncIterable<{
|
|
527
|
+
text: string;
|
|
528
|
+
tokens: {
|
|
529
|
+
prompt: number;
|
|
530
|
+
completion: number;
|
|
531
|
+
total: number;
|
|
532
|
+
};
|
|
533
|
+
}>;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export { AnthropicLLMAdapter, type AnthropicLLMConfig, CohereEmbeddingAdapter, type CohereEmbeddingConfig, type CompiledContext, type ContextOptions, DiskStorage, type DiskStorageConfig, type EmbeddingProvider, GroqLLMAdapter, type GroqLLMConfig, type HealthStatus, InMemoryStorage, type LLMProvider, MemStack, type MemStackConfig, MemStackError, type MemStackErrorCode, type MemStackSnapshot, type Memory, type MemoryCountFilter, type MemoryRetrieveQuery, type MemoryStoreInput, type MemoryType, OllamaLLMAdapter, type OllamaLLMConfig, OpenAIEmbeddingAdapter, type OpenAIEmbeddingConfig, OpenAILLMAdapter, type OpenAILLMConfig, PostgresStorage, type PostgresStorageConfig, type ProcessInput, type ProcessResult, type PruneStrategy, RedisStorage, type RedisStorageConfig, type StorageProvider, type SummarizeOptions, configError, notFound, storageError, validationError };
|