@memstack/core 0.7.3 → 0.8.1

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.cts CHANGED
@@ -1,4 +1,13 @@
1
- type MemoryType = "interaction" | "summary" | "observation" | "fact" | "reflection";
1
+ type MemoryType = "interaction" | "summary" | "observation" | "fact" | "reflection" | "preference" | "decision" | "instruction";
2
+ /** Where a memory came from. Harness writes store it in `metadata.source`. */
3
+ interface MemorySource {
4
+ /** Harness that wrote the memory, e.g. "claude-code" or "codex". */
5
+ harness: string;
6
+ /** Project ID the memory belongs to. */
7
+ project: string;
8
+ sessionId?: string;
9
+ cwd?: string;
10
+ }
2
11
  interface Memory {
3
12
  id: string;
4
13
  actorId: string;
@@ -85,6 +94,8 @@ interface MemoryRetrieveQuery {
85
94
  strategy?: "semantic" | "hybrid" | "recent" | "important";
86
95
  createdAfter?: Date;
87
96
  createdBefore?: Date;
97
+ /** Mark returned memories as accessed. Default true. Set false to read without side effects. */
98
+ touch?: boolean;
88
99
  }
89
100
  interface ContextOptions {
90
101
  actorId: string;
@@ -155,7 +166,30 @@ interface EmbeddingProvider {
155
166
  /** Maximum number of texts per embed() call. Default: 2048. */
156
167
  maxBatchSize?: number;
157
168
  }
169
+ /** What a storage adapter can do beyond the required contract. Unset means unknown. */
170
+ interface StorageCapabilities {
171
+ /** Several processes can read and write the same store at once without errors or lost writes. */
172
+ multiProcess?: boolean;
173
+ /** The adapter implements `search()` with native full-text search. */
174
+ textSearch?: boolean;
175
+ }
176
+ interface TextSearchQuery {
177
+ /** Namespaces to search, matched exactly against `actorId`. */
178
+ actorIds: string[];
179
+ query: string;
180
+ memoryTypes?: MemoryType[];
181
+ limit: number;
182
+ }
183
+ interface ScoredMemory {
184
+ memory: Memory;
185
+ /** Higher is more relevant. Only comparable within one result set. */
186
+ score: number;
187
+ }
158
188
  interface StorageProvider {
189
+ /** Optional capability flags, used by harness setup and diagnostics. */
190
+ readonly capabilities?: StorageCapabilities;
191
+ /** Optional native full-text search. Core ranks memories itself when absent. */
192
+ search?(query: TextSearchQuery): Promise<ScoredMemory[]>;
159
193
  initialize(): Promise<void>;
160
194
  store(memory: MemoryStoreInput): Promise<Memory>;
161
195
  storeBatch(memories: MemoryStoreInput[]): Promise<Memory[]>;
@@ -275,11 +309,130 @@ declare class MemStack {
275
309
  health(): Promise<HealthStatus>;
276
310
  close(): Promise<void>;
277
311
  private _parseEnrichmentJson;
278
- private _parseTagsJson;
279
- /** Strip markdown code fences and extract the JSON payload from LLM output. */
280
- private _extractJson;
281
312
  }
282
313
 
314
+ interface RecallQuery {
315
+ /** Namespaces to recall from, matched exactly against `actorId`, e.g. `["project:abc", "global"]`. */
316
+ actorIds: string[];
317
+ /** Free text. When empty or without words, recall returns the fallback. */
318
+ query?: string;
319
+ memoryTypes?: MemoryType[];
320
+ /** Maximum memories returned. Default 10. */
321
+ limit?: number;
322
+ /** Maximum total characters of returned content. The top result is always returned. Default 8000. */
323
+ maxChars?: number;
324
+ }
325
+ interface RecallHit {
326
+ memory: Memory;
327
+ /** BM25 score, or 0 for fallback results. */
328
+ score: number;
329
+ }
330
+ interface RecallResult {
331
+ hits: RecallHit[];
332
+ /** True when nothing matched the query and the hits are the most important and recent memories. */
333
+ fallback: boolean;
334
+ }
335
+ interface LexicalRetrieverConfig {
336
+ /** Memories loaded per namespace for ranking, most important first. Default 2000. */
337
+ candidateLimit?: number;
338
+ /** Mark returned memories as accessed via `storage.touch`. Default true. */
339
+ touch?: boolean;
340
+ }
341
+ /**
342
+ * Recall that works on every storage adapter: memories in scope are loaded
343
+ * through `StorageProvider.retrieve` and ranked in Core with BM25 over
344
+ * content and tags. Adapters with native `search()` are used instead when
345
+ * they declare `textSearch`. Recall never calls an LLM.
346
+ */
347
+ declare class LexicalRetriever {
348
+ private storage;
349
+ private candidateLimit;
350
+ private touch;
351
+ constructor(storage: StorageProvider, config?: LexicalRetrieverConfig);
352
+ recall(query: RecallQuery): Promise<RecallResult>;
353
+ private loadCandidates;
354
+ private touchAll;
355
+ }
356
+
357
+ interface HarnessMemoryConfig {
358
+ storage: StorageProvider;
359
+ llm: LLMProvider;
360
+ /** Ask the LLM for topic tags on every write. Default true. */
361
+ autoTags?: boolean;
362
+ /** Give up on tagging after this long and store the memory untagged. Default 10000. */
363
+ tagTimeoutMs?: number;
364
+ /** Longest content accepted by `remember`. Default 8000 characters. */
365
+ maxContentChars?: number;
366
+ /** Memories ranked per namespace on recall. Default 2000. */
367
+ candidateLimit?: number;
368
+ /** Called when tagging fails; the memory is still stored. */
369
+ onError?: (error: Error, context: string) => void;
370
+ }
371
+ interface RememberInput {
372
+ /** Namespace to write to, used as `actorId`, e.g. `project:<id>` or `global`. */
373
+ namespace: string;
374
+ content: string;
375
+ kind?: MemoryType;
376
+ importance?: number;
377
+ tags?: string[];
378
+ source: MemorySource;
379
+ }
380
+ interface HarnessRecallInput {
381
+ /** Namespaces to search together, e.g. `["project:<id>", "global"]`. */
382
+ namespaces: string[];
383
+ query?: string;
384
+ kinds?: MemoryType[];
385
+ limit?: number;
386
+ maxChars?: number;
387
+ }
388
+ /**
389
+ * Memory operations for agent harnesses such as Claude Code and Codex.
390
+ * Works on any storage adapter. Every read and delete is limited to the
391
+ * namespaces the caller passes, so one project cannot see another's memories.
392
+ * Recall never calls the LLM; only `remember` does, for tagging.
393
+ */
394
+ declare class HarnessMemory {
395
+ private storage;
396
+ private llm;
397
+ private retriever;
398
+ private autoTags;
399
+ private tagTimeoutMs;
400
+ private maxContentChars;
401
+ private onError?;
402
+ private initialized?;
403
+ constructor(config: HarnessMemoryConfig);
404
+ remember(input: RememberInput): Promise<Memory>;
405
+ recall(input: HarnessRecallInput): Promise<RecallResult>;
406
+ /** The memory with this ID, or null when it does not exist or is outside `namespaces`. */
407
+ get(id: string, namespaces: string[]): Promise<Memory | null>;
408
+ /** Delete a memory. Memories outside `namespaces` are reported as not found. */
409
+ forget(id: string, namespaces: string[]): Promise<void>;
410
+ /** Number of memories in each namespace. */
411
+ stats(namespaces: string[]): Promise<Record<string, number>>;
412
+ /**
413
+ * Moves every memory from one namespace to another, keeping content,
414
+ * kind, importance, tags, provenance, and creation time. Memories get new
415
+ * IDs. Used when a project's ID changes, e.g. after its first commit.
416
+ * Safe to run from two processes at once: a copy whose original was
417
+ * already moved by the other process is removed again.
418
+ */
419
+ moveNamespace(from: string, to: string): Promise<number>;
420
+ /**
421
+ * Adopts memories a project stored under IDs it had before, such as
422
+ * before its first commit. Costs one count per previous ID when there is
423
+ * nothing to move. Returns the number of memories moved.
424
+ */
425
+ adoptProjects(previousIds: string[], projectId: string): Promise<number>;
426
+ private ensureInit;
427
+ private suggestTags;
428
+ }
429
+
430
+ declare const GLOBAL_NAMESPACE = "global";
431
+ declare function projectNamespace(projectId: string): string;
432
+ declare function sessionNamespace(projectId: string, sessionId: string): string;
433
+ /** Namespaces a harness recalls from by default: the project, then global. */
434
+ declare function defaultRecallNamespaces(projectId: string): string[];
435
+
283
436
  type MemStackErrorCode = "STORAGE_ERROR" | "EMBEDDING_ERROR" | "LLM_ERROR" | "VALIDATION_ERROR" | "NOT_FOUND" | "CONFIG_ERROR";
284
437
  declare class MemStackError extends Error {
285
438
  code: MemStackErrorCode;
@@ -296,6 +449,7 @@ declare function storageError(message: string, cause?: unknown): MemStackError;
296
449
  declare function configError(message: string): MemStackError;
297
450
 
298
451
  declare class InMemoryStorageAdapter implements StorageProvider {
452
+ readonly capabilities: StorageCapabilities;
299
453
  private memories;
300
454
  initialize(): Promise<void>;
301
455
  generateId(): string;
@@ -316,6 +470,7 @@ interface DiskStorageConfig {
316
470
  storageDir?: string;
317
471
  }
318
472
  declare class DiskStorageAdapter implements StorageProvider {
473
+ readonly capabilities: StorageCapabilities;
319
474
  private dir;
320
475
  private _writeLocks;
321
476
  private _idIndex;
@@ -352,6 +507,7 @@ interface MarkdownStorageConfig {
352
507
  oneFilePerActor?: boolean;
353
508
  }
354
509
  declare class MarkdownStorageAdapter implements StorageProvider {
510
+ readonly capabilities: StorageCapabilities;
355
511
  private dir;
356
512
  private oneFilePerActor;
357
513
  private _cache;
@@ -423,6 +579,7 @@ interface PostgresStorageConfig {
423
579
  ssl?: boolean | object;
424
580
  }
425
581
  declare class PostgresStorageAdapter implements StorageProvider {
582
+ readonly capabilities: StorageCapabilities;
426
583
  private pool;
427
584
  private table;
428
585
  private vectorDimensions;
@@ -463,6 +620,7 @@ interface RedisStorageConfig {
463
620
  keyPrefix?: string;
464
621
  }
465
622
  declare class RedisStorageAdapter implements StorageProvider {
623
+ readonly capabilities: StorageCapabilities;
466
624
  private redis;
467
625
  private prefix;
468
626
  constructor(config: RedisStorageConfig);
@@ -814,6 +972,7 @@ interface MongoDBStorageConfig {
814
972
  vectorDimensions?: number;
815
973
  }
816
974
  declare class MongoDBStorageAdapter implements StorageProvider {
975
+ readonly capabilities: StorageCapabilities;
817
976
  private collection;
818
977
  private vectorDimensions;
819
978
  constructor(config: MongoDBStorageConfig);
@@ -844,20 +1003,33 @@ type BetterSqlite3Db = {
844
1003
  all(...params: unknown[]): unknown[];
845
1004
  };
846
1005
  close(): void;
1006
+ inTransaction?: boolean;
847
1007
  };
848
1008
  interface SQLiteStorageConfig {
849
1009
  db: BetterSqlite3Db;
850
1010
  tableName?: string;
851
1011
  vectorDimensions?: number;
1012
+ /** How long a write waits for another connection's lock before failing. Default 5000. */
1013
+ busyTimeoutMs?: number;
1014
+ /** Use write-ahead logging so readers never block and writers queue. Default true. */
1015
+ walMode?: boolean;
852
1016
  }
853
1017
  declare class SQLiteStorageAdapter implements StorageProvider {
1018
+ readonly capabilities: StorageCapabilities;
854
1019
  private db;
855
1020
  private table;
856
1021
  private vectorDimensions;
1022
+ private busyTimeoutMs;
1023
+ private walMode;
857
1024
  constructor(config: SQLiteStorageConfig);
858
1025
  initialize(): Promise<void>;
1026
+ /** Schema version applied to this adapter's table, 0 if none. */
1027
+ schemaVersion(): number;
1028
+ private migrate;
1029
+ private transaction;
859
1030
  generateId(): string;
860
1031
  store(input: MemoryStoreInput): Promise<Memory>;
1032
+ private insert;
861
1033
  storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
862
1034
  get(id: string): Promise<Memory | null>;
863
1035
  delete(id: string): Promise<void>;
@@ -866,6 +1038,7 @@ declare class SQLiteStorageAdapter implements StorageProvider {
866
1038
  retrieve(query: MemoryRetrieveQuery, embedding?: number[]): Promise<Memory[]>;
867
1039
  count(filter?: MemoryCountFilter): Promise<number>;
868
1040
  close(): Promise<void>;
1041
+ private touchRows;
869
1042
  private _rowToMemory;
870
1043
  }
871
1044
 
@@ -1056,4 +1229,4 @@ declare class GroqLLMAdapter implements LLMProvider {
1056
1229
  }>;
1057
1230
  }
1058
1231
 
1059
- export { AnthropicLLMAdapter, type AnthropicLLMConfig, CohereEmbeddingAdapter, type CohereEmbeddingConfig, type CompiledContext, type ContextOptions, DiskStorageAdapter, type DiskStorageConfig, type EmbeddingProvider, GroqLLMAdapter, type GroqLLMConfig, type HealthStatus, HybridStorageAdapter, type HybridStorageConfig, InMemoryStorageAdapter, type LLMProvider, LanceDBStorageAdapter, type LanceDBStorageConfig, MarkdownStorageAdapter, type MarkdownStorageConfig, MemStack, type MemStackConfig, MemStackError, type MemStackErrorCode, type MemStackSnapshot, type Memory, type MemoryCountFilter, type MemoryRetrieveQuery, type MemoryStats, type MemoryStoreInput, type MemoryType, MongoDBStorageAdapter, type MongoDBStorageConfig, Neo4jStorageAdapter, type Neo4jStorageConfig, OllamaLLMAdapter, type OllamaLLMConfig, OpenAIEmbeddingAdapter, type OpenAIEmbeddingConfig, OpenAILLMAdapter, type OpenAILLMConfig, PostgresStorageAdapter, type PostgresStorageConfig, type ProcessInput, type ProcessResult, type PruneStrategy, QdrantStorageAdapter, type QdrantStorageConfig, RedisStorageAdapter, type RedisStorageConfig, SQLiteStorageAdapter, type SQLiteStorageConfig, type StorageProvider, type SummarizeOptions, WeaviateStorageAdapter, type WeaviateStorageConfig, configError, notFound, storageError, validationError };
1232
+ export { AnthropicLLMAdapter, type AnthropicLLMConfig, CohereEmbeddingAdapter, type CohereEmbeddingConfig, type CompiledContext, type ContextOptions, DiskStorageAdapter, type DiskStorageConfig, type EmbeddingProvider, GLOBAL_NAMESPACE, GroqLLMAdapter, type GroqLLMConfig, HarnessMemory, type HarnessMemoryConfig, type HarnessRecallInput, type HealthStatus, HybridStorageAdapter, type HybridStorageConfig, InMemoryStorageAdapter, type LLMProvider, LanceDBStorageAdapter, type LanceDBStorageConfig, LexicalRetriever, type LexicalRetrieverConfig, MarkdownStorageAdapter, type MarkdownStorageConfig, MemStack, type MemStackConfig, MemStackError, type MemStackErrorCode, type MemStackSnapshot, type Memory, type MemoryCountFilter, type MemoryRetrieveQuery, type MemorySource, type MemoryStats, type MemoryStoreInput, type MemoryType, MongoDBStorageAdapter, type MongoDBStorageConfig, Neo4jStorageAdapter, type Neo4jStorageConfig, OllamaLLMAdapter, type OllamaLLMConfig, OpenAIEmbeddingAdapter, type OpenAIEmbeddingConfig, OpenAILLMAdapter, type OpenAILLMConfig, PostgresStorageAdapter, type PostgresStorageConfig, type ProcessInput, type ProcessResult, type PruneStrategy, QdrantStorageAdapter, type QdrantStorageConfig, type RecallHit, type RecallQuery, type RecallResult, RedisStorageAdapter, type RedisStorageConfig, type RememberInput, SQLiteStorageAdapter, type SQLiteStorageConfig, type ScoredMemory, type StorageCapabilities, type StorageProvider, type SummarizeOptions, type TextSearchQuery, WeaviateStorageAdapter, type WeaviateStorageConfig, configError, defaultRecallNamespaces, notFound, projectNamespace, sessionNamespace, storageError, validationError };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,13 @@
1
- type MemoryType = "interaction" | "summary" | "observation" | "fact" | "reflection";
1
+ type MemoryType = "interaction" | "summary" | "observation" | "fact" | "reflection" | "preference" | "decision" | "instruction";
2
+ /** Where a memory came from. Harness writes store it in `metadata.source`. */
3
+ interface MemorySource {
4
+ /** Harness that wrote the memory, e.g. "claude-code" or "codex". */
5
+ harness: string;
6
+ /** Project ID the memory belongs to. */
7
+ project: string;
8
+ sessionId?: string;
9
+ cwd?: string;
10
+ }
2
11
  interface Memory {
3
12
  id: string;
4
13
  actorId: string;
@@ -85,6 +94,8 @@ interface MemoryRetrieveQuery {
85
94
  strategy?: "semantic" | "hybrid" | "recent" | "important";
86
95
  createdAfter?: Date;
87
96
  createdBefore?: Date;
97
+ /** Mark returned memories as accessed. Default true. Set false to read without side effects. */
98
+ touch?: boolean;
88
99
  }
89
100
  interface ContextOptions {
90
101
  actorId: string;
@@ -155,7 +166,30 @@ interface EmbeddingProvider {
155
166
  /** Maximum number of texts per embed() call. Default: 2048. */
156
167
  maxBatchSize?: number;
157
168
  }
169
+ /** What a storage adapter can do beyond the required contract. Unset means unknown. */
170
+ interface StorageCapabilities {
171
+ /** Several processes can read and write the same store at once without errors or lost writes. */
172
+ multiProcess?: boolean;
173
+ /** The adapter implements `search()` with native full-text search. */
174
+ textSearch?: boolean;
175
+ }
176
+ interface TextSearchQuery {
177
+ /** Namespaces to search, matched exactly against `actorId`. */
178
+ actorIds: string[];
179
+ query: string;
180
+ memoryTypes?: MemoryType[];
181
+ limit: number;
182
+ }
183
+ interface ScoredMemory {
184
+ memory: Memory;
185
+ /** Higher is more relevant. Only comparable within one result set. */
186
+ score: number;
187
+ }
158
188
  interface StorageProvider {
189
+ /** Optional capability flags, used by harness setup and diagnostics. */
190
+ readonly capabilities?: StorageCapabilities;
191
+ /** Optional native full-text search. Core ranks memories itself when absent. */
192
+ search?(query: TextSearchQuery): Promise<ScoredMemory[]>;
159
193
  initialize(): Promise<void>;
160
194
  store(memory: MemoryStoreInput): Promise<Memory>;
161
195
  storeBatch(memories: MemoryStoreInput[]): Promise<Memory[]>;
@@ -275,11 +309,130 @@ declare class MemStack {
275
309
  health(): Promise<HealthStatus>;
276
310
  close(): Promise<void>;
277
311
  private _parseEnrichmentJson;
278
- private _parseTagsJson;
279
- /** Strip markdown code fences and extract the JSON payload from LLM output. */
280
- private _extractJson;
281
312
  }
282
313
 
314
+ interface RecallQuery {
315
+ /** Namespaces to recall from, matched exactly against `actorId`, e.g. `["project:abc", "global"]`. */
316
+ actorIds: string[];
317
+ /** Free text. When empty or without words, recall returns the fallback. */
318
+ query?: string;
319
+ memoryTypes?: MemoryType[];
320
+ /** Maximum memories returned. Default 10. */
321
+ limit?: number;
322
+ /** Maximum total characters of returned content. The top result is always returned. Default 8000. */
323
+ maxChars?: number;
324
+ }
325
+ interface RecallHit {
326
+ memory: Memory;
327
+ /** BM25 score, or 0 for fallback results. */
328
+ score: number;
329
+ }
330
+ interface RecallResult {
331
+ hits: RecallHit[];
332
+ /** True when nothing matched the query and the hits are the most important and recent memories. */
333
+ fallback: boolean;
334
+ }
335
+ interface LexicalRetrieverConfig {
336
+ /** Memories loaded per namespace for ranking, most important first. Default 2000. */
337
+ candidateLimit?: number;
338
+ /** Mark returned memories as accessed via `storage.touch`. Default true. */
339
+ touch?: boolean;
340
+ }
341
+ /**
342
+ * Recall that works on every storage adapter: memories in scope are loaded
343
+ * through `StorageProvider.retrieve` and ranked in Core with BM25 over
344
+ * content and tags. Adapters with native `search()` are used instead when
345
+ * they declare `textSearch`. Recall never calls an LLM.
346
+ */
347
+ declare class LexicalRetriever {
348
+ private storage;
349
+ private candidateLimit;
350
+ private touch;
351
+ constructor(storage: StorageProvider, config?: LexicalRetrieverConfig);
352
+ recall(query: RecallQuery): Promise<RecallResult>;
353
+ private loadCandidates;
354
+ private touchAll;
355
+ }
356
+
357
+ interface HarnessMemoryConfig {
358
+ storage: StorageProvider;
359
+ llm: LLMProvider;
360
+ /** Ask the LLM for topic tags on every write. Default true. */
361
+ autoTags?: boolean;
362
+ /** Give up on tagging after this long and store the memory untagged. Default 10000. */
363
+ tagTimeoutMs?: number;
364
+ /** Longest content accepted by `remember`. Default 8000 characters. */
365
+ maxContentChars?: number;
366
+ /** Memories ranked per namespace on recall. Default 2000. */
367
+ candidateLimit?: number;
368
+ /** Called when tagging fails; the memory is still stored. */
369
+ onError?: (error: Error, context: string) => void;
370
+ }
371
+ interface RememberInput {
372
+ /** Namespace to write to, used as `actorId`, e.g. `project:<id>` or `global`. */
373
+ namespace: string;
374
+ content: string;
375
+ kind?: MemoryType;
376
+ importance?: number;
377
+ tags?: string[];
378
+ source: MemorySource;
379
+ }
380
+ interface HarnessRecallInput {
381
+ /** Namespaces to search together, e.g. `["project:<id>", "global"]`. */
382
+ namespaces: string[];
383
+ query?: string;
384
+ kinds?: MemoryType[];
385
+ limit?: number;
386
+ maxChars?: number;
387
+ }
388
+ /**
389
+ * Memory operations for agent harnesses such as Claude Code and Codex.
390
+ * Works on any storage adapter. Every read and delete is limited to the
391
+ * namespaces the caller passes, so one project cannot see another's memories.
392
+ * Recall never calls the LLM; only `remember` does, for tagging.
393
+ */
394
+ declare class HarnessMemory {
395
+ private storage;
396
+ private llm;
397
+ private retriever;
398
+ private autoTags;
399
+ private tagTimeoutMs;
400
+ private maxContentChars;
401
+ private onError?;
402
+ private initialized?;
403
+ constructor(config: HarnessMemoryConfig);
404
+ remember(input: RememberInput): Promise<Memory>;
405
+ recall(input: HarnessRecallInput): Promise<RecallResult>;
406
+ /** The memory with this ID, or null when it does not exist or is outside `namespaces`. */
407
+ get(id: string, namespaces: string[]): Promise<Memory | null>;
408
+ /** Delete a memory. Memories outside `namespaces` are reported as not found. */
409
+ forget(id: string, namespaces: string[]): Promise<void>;
410
+ /** Number of memories in each namespace. */
411
+ stats(namespaces: string[]): Promise<Record<string, number>>;
412
+ /**
413
+ * Moves every memory from one namespace to another, keeping content,
414
+ * kind, importance, tags, provenance, and creation time. Memories get new
415
+ * IDs. Used when a project's ID changes, e.g. after its first commit.
416
+ * Safe to run from two processes at once: a copy whose original was
417
+ * already moved by the other process is removed again.
418
+ */
419
+ moveNamespace(from: string, to: string): Promise<number>;
420
+ /**
421
+ * Adopts memories a project stored under IDs it had before, such as
422
+ * before its first commit. Costs one count per previous ID when there is
423
+ * nothing to move. Returns the number of memories moved.
424
+ */
425
+ adoptProjects(previousIds: string[], projectId: string): Promise<number>;
426
+ private ensureInit;
427
+ private suggestTags;
428
+ }
429
+
430
+ declare const GLOBAL_NAMESPACE = "global";
431
+ declare function projectNamespace(projectId: string): string;
432
+ declare function sessionNamespace(projectId: string, sessionId: string): string;
433
+ /** Namespaces a harness recalls from by default: the project, then global. */
434
+ declare function defaultRecallNamespaces(projectId: string): string[];
435
+
283
436
  type MemStackErrorCode = "STORAGE_ERROR" | "EMBEDDING_ERROR" | "LLM_ERROR" | "VALIDATION_ERROR" | "NOT_FOUND" | "CONFIG_ERROR";
284
437
  declare class MemStackError extends Error {
285
438
  code: MemStackErrorCode;
@@ -296,6 +449,7 @@ declare function storageError(message: string, cause?: unknown): MemStackError;
296
449
  declare function configError(message: string): MemStackError;
297
450
 
298
451
  declare class InMemoryStorageAdapter implements StorageProvider {
452
+ readonly capabilities: StorageCapabilities;
299
453
  private memories;
300
454
  initialize(): Promise<void>;
301
455
  generateId(): string;
@@ -316,6 +470,7 @@ interface DiskStorageConfig {
316
470
  storageDir?: string;
317
471
  }
318
472
  declare class DiskStorageAdapter implements StorageProvider {
473
+ readonly capabilities: StorageCapabilities;
319
474
  private dir;
320
475
  private _writeLocks;
321
476
  private _idIndex;
@@ -352,6 +507,7 @@ interface MarkdownStorageConfig {
352
507
  oneFilePerActor?: boolean;
353
508
  }
354
509
  declare class MarkdownStorageAdapter implements StorageProvider {
510
+ readonly capabilities: StorageCapabilities;
355
511
  private dir;
356
512
  private oneFilePerActor;
357
513
  private _cache;
@@ -423,6 +579,7 @@ interface PostgresStorageConfig {
423
579
  ssl?: boolean | object;
424
580
  }
425
581
  declare class PostgresStorageAdapter implements StorageProvider {
582
+ readonly capabilities: StorageCapabilities;
426
583
  private pool;
427
584
  private table;
428
585
  private vectorDimensions;
@@ -463,6 +620,7 @@ interface RedisStorageConfig {
463
620
  keyPrefix?: string;
464
621
  }
465
622
  declare class RedisStorageAdapter implements StorageProvider {
623
+ readonly capabilities: StorageCapabilities;
466
624
  private redis;
467
625
  private prefix;
468
626
  constructor(config: RedisStorageConfig);
@@ -814,6 +972,7 @@ interface MongoDBStorageConfig {
814
972
  vectorDimensions?: number;
815
973
  }
816
974
  declare class MongoDBStorageAdapter implements StorageProvider {
975
+ readonly capabilities: StorageCapabilities;
817
976
  private collection;
818
977
  private vectorDimensions;
819
978
  constructor(config: MongoDBStorageConfig);
@@ -844,20 +1003,33 @@ type BetterSqlite3Db = {
844
1003
  all(...params: unknown[]): unknown[];
845
1004
  };
846
1005
  close(): void;
1006
+ inTransaction?: boolean;
847
1007
  };
848
1008
  interface SQLiteStorageConfig {
849
1009
  db: BetterSqlite3Db;
850
1010
  tableName?: string;
851
1011
  vectorDimensions?: number;
1012
+ /** How long a write waits for another connection's lock before failing. Default 5000. */
1013
+ busyTimeoutMs?: number;
1014
+ /** Use write-ahead logging so readers never block and writers queue. Default true. */
1015
+ walMode?: boolean;
852
1016
  }
853
1017
  declare class SQLiteStorageAdapter implements StorageProvider {
1018
+ readonly capabilities: StorageCapabilities;
854
1019
  private db;
855
1020
  private table;
856
1021
  private vectorDimensions;
1022
+ private busyTimeoutMs;
1023
+ private walMode;
857
1024
  constructor(config: SQLiteStorageConfig);
858
1025
  initialize(): Promise<void>;
1026
+ /** Schema version applied to this adapter's table, 0 if none. */
1027
+ schemaVersion(): number;
1028
+ private migrate;
1029
+ private transaction;
859
1030
  generateId(): string;
860
1031
  store(input: MemoryStoreInput): Promise<Memory>;
1032
+ private insert;
861
1033
  storeBatch(inputs: MemoryStoreInput[]): Promise<Memory[]>;
862
1034
  get(id: string): Promise<Memory | null>;
863
1035
  delete(id: string): Promise<void>;
@@ -866,6 +1038,7 @@ declare class SQLiteStorageAdapter implements StorageProvider {
866
1038
  retrieve(query: MemoryRetrieveQuery, embedding?: number[]): Promise<Memory[]>;
867
1039
  count(filter?: MemoryCountFilter): Promise<number>;
868
1040
  close(): Promise<void>;
1041
+ private touchRows;
869
1042
  private _rowToMemory;
870
1043
  }
871
1044
 
@@ -1056,4 +1229,4 @@ declare class GroqLLMAdapter implements LLMProvider {
1056
1229
  }>;
1057
1230
  }
1058
1231
 
1059
- export { AnthropicLLMAdapter, type AnthropicLLMConfig, CohereEmbeddingAdapter, type CohereEmbeddingConfig, type CompiledContext, type ContextOptions, DiskStorageAdapter, type DiskStorageConfig, type EmbeddingProvider, GroqLLMAdapter, type GroqLLMConfig, type HealthStatus, HybridStorageAdapter, type HybridStorageConfig, InMemoryStorageAdapter, type LLMProvider, LanceDBStorageAdapter, type LanceDBStorageConfig, MarkdownStorageAdapter, type MarkdownStorageConfig, MemStack, type MemStackConfig, MemStackError, type MemStackErrorCode, type MemStackSnapshot, type Memory, type MemoryCountFilter, type MemoryRetrieveQuery, type MemoryStats, type MemoryStoreInput, type MemoryType, MongoDBStorageAdapter, type MongoDBStorageConfig, Neo4jStorageAdapter, type Neo4jStorageConfig, OllamaLLMAdapter, type OllamaLLMConfig, OpenAIEmbeddingAdapter, type OpenAIEmbeddingConfig, OpenAILLMAdapter, type OpenAILLMConfig, PostgresStorageAdapter, type PostgresStorageConfig, type ProcessInput, type ProcessResult, type PruneStrategy, QdrantStorageAdapter, type QdrantStorageConfig, RedisStorageAdapter, type RedisStorageConfig, SQLiteStorageAdapter, type SQLiteStorageConfig, type StorageProvider, type SummarizeOptions, WeaviateStorageAdapter, type WeaviateStorageConfig, configError, notFound, storageError, validationError };
1232
+ export { AnthropicLLMAdapter, type AnthropicLLMConfig, CohereEmbeddingAdapter, type CohereEmbeddingConfig, type CompiledContext, type ContextOptions, DiskStorageAdapter, type DiskStorageConfig, type EmbeddingProvider, GLOBAL_NAMESPACE, GroqLLMAdapter, type GroqLLMConfig, HarnessMemory, type HarnessMemoryConfig, type HarnessRecallInput, type HealthStatus, HybridStorageAdapter, type HybridStorageConfig, InMemoryStorageAdapter, type LLMProvider, LanceDBStorageAdapter, type LanceDBStorageConfig, LexicalRetriever, type LexicalRetrieverConfig, MarkdownStorageAdapter, type MarkdownStorageConfig, MemStack, type MemStackConfig, MemStackError, type MemStackErrorCode, type MemStackSnapshot, type Memory, type MemoryCountFilter, type MemoryRetrieveQuery, type MemorySource, type MemoryStats, type MemoryStoreInput, type MemoryType, MongoDBStorageAdapter, type MongoDBStorageConfig, Neo4jStorageAdapter, type Neo4jStorageConfig, OllamaLLMAdapter, type OllamaLLMConfig, OpenAIEmbeddingAdapter, type OpenAIEmbeddingConfig, OpenAILLMAdapter, type OpenAILLMConfig, PostgresStorageAdapter, type PostgresStorageConfig, type ProcessInput, type ProcessResult, type PruneStrategy, QdrantStorageAdapter, type QdrantStorageConfig, type RecallHit, type RecallQuery, type RecallResult, RedisStorageAdapter, type RedisStorageConfig, type RememberInput, SQLiteStorageAdapter, type SQLiteStorageConfig, type ScoredMemory, type StorageCapabilities, type StorageProvider, type SummarizeOptions, type TextSearchQuery, WeaviateStorageAdapter, type WeaviateStorageConfig, configError, defaultRecallNamespaces, notFound, projectNamespace, sessionNamespace, storageError, validationError };