wolbarg 0.5.1 → 0.5.3

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
@@ -49,7 +49,7 @@ declare const meta: {
49
49
  * Schema is intentionally extensible for future providers (Postgres, cloud).
50
50
  */
51
51
  /** Public operation names recorded as telemetry events. */
52
- type TelemetryOperation = "remember" | "recall" | "forget" | "compress" | "rememberBatch" | "recallBatch" | "export" | "import" | "checkpoint" | "rollback" | "error" | "startup" | "shutdown" | "ingest" | "history" | "stats" | "clear" | "deleteCheckpoint" | "listCheckpoints" | "getCheckpoint" | "linkMemories" | "getRelated" | "graphQuery";
52
+ type TelemetryOperation = "remember" | "recall" | "forget" | "compress" | "rememberBatch" | "recallBatch" | "export" | "import" | "checkpoint" | "rollback" | "error" | "startup" | "shutdown" | "ingest" | "history" | "stats" | "clear" | "deleteCheckpoint" | "listCheckpoints" | "getCheckpoint" | "linkMemories" | "getRelated" | "graphQuery" | "rememberFromMessages";
53
53
  type TelemetryStatus = "ok" | "error" | "cancelled";
54
54
  type TelemetryLogLevel = "off" | "error" | "warn" | "info" | "debug" | "trace";
55
55
  /** Stage-level latency breakdown recorded on each event. */
@@ -341,6 +341,35 @@ interface RememberOptions {
341
341
  /** Per-call dedupe override; undefined uses constructor `memory.dedupe`. */
342
342
  dedupe?: boolean | MemoryDedupeConfig;
343
343
  }
344
+ /**
345
+ * Chat turn for {@link Wolbarg.rememberFromMessages}.
346
+ * @experimental until 1.0
347
+ */
348
+ interface ConversationMessage {
349
+ role: string;
350
+ content: string;
351
+ }
352
+ /** How `mode: "raw"` selects user turns to store. */
353
+ type RememberFromMessagesRawStrategy = "last_user" | "all_user";
354
+ /**
355
+ * Options for {@link Wolbarg.rememberFromMessages}.
356
+ * @experimental until 1.0
357
+ */
358
+ interface RememberFromMessagesOptions {
359
+ /** Agent identifier that owns the stored memories. */
360
+ agent: string;
361
+ /**
362
+ * `raw` (default) — store user message text without an LLM.
363
+ * `extract` — use configured `llm` to extract atomic facts, then remember each.
364
+ */
365
+ mode?: "raw" | "extract";
366
+ /** Used when `mode` is `raw`. Defaults to `last_user`. */
367
+ rawStrategy?: RememberFromMessagesRawStrategy;
368
+ /** Optional opaque metadata attached to every stored memory. */
369
+ metadata?: MemoryMetadata;
370
+ /** Per-call dedupe override; undefined uses constructor `memory.dedupe`. */
371
+ dedupe?: boolean | MemoryDedupeConfig;
372
+ }
344
373
  /** Whether remember created a new row or updated an existing one. */
345
374
  type RememberAction = "created" | "updated";
346
375
  /** Result of {@link Wolbarg.remember} — MemoryRecord plus upsert action. */
@@ -730,7 +759,7 @@ declare function createChunkingStrategy(name?: "fixed" | "sentence" | "paragraph
730
759
 
731
760
  /**
732
761
  * LLM provider abstractions and OpenAI-compatible chat implementation.
733
- * Used exclusively for memory compression (and future ORC features).
762
+ * Used for memory compression and experimental rememberFromMessages extract mode.
734
763
  */
735
764
 
736
765
  interface ChatMessage {
@@ -1296,6 +1325,15 @@ declare class Wolbarg<HasLlm extends boolean = false> {
1296
1325
  remember(options: RememberOptions): Promise<RememberResult>;
1297
1326
  /** Batch remember — sequential when dedupe enabled; otherwise one TX batch. */
1298
1327
  rememberBatch(items: RememberOptions[]): Promise<RememberResult[]>;
1328
+ /**
1329
+ * Store memories from a chat transcript.
1330
+ *
1331
+ * **Experimental** until 1.0 — API shape may change.
1332
+ *
1333
+ * - `mode: "raw"` (default) — remember user message text (no LLM).
1334
+ * - `mode: "extract"` — require configured `llm`; extract atomic facts then remember each.
1335
+ */
1336
+ rememberFromMessages(messages: ConversationMessage[], options: RememberFromMessagesOptions): Promise<RememberResult[]>;
1299
1337
  /**
1300
1338
  * Update an existing memory by id (re-embeds when content changes).
1301
1339
  */
@@ -1388,7 +1426,7 @@ declare class Wolbarg<HasLlm extends boolean = false> {
1388
1426
  declare function wolbarg$1(options: WolbargOptions): Wolbarg;
1389
1427
 
1390
1428
  /** Published SDK semver — keep in sync with package.json `version`. */
1391
- declare const SDK_VERSION = "0.5.0";
1429
+ declare const SDK_VERSION = "0.5.3";
1392
1430
 
1393
1431
  /**
1394
1432
  * Operation-scoped errors with reason + suggestion for developer experience.
@@ -1701,6 +1739,8 @@ declare class SqliteStorageProvider implements StorageProvider {
1701
1739
  private requireStatements;
1702
1740
  private requireVectorReady;
1703
1741
  private toVectorParam;
1742
+ /** sqlite-vec vec0 PKs must be bound as BigInt under node:sqlite. */
1743
+ private toVecRowid;
1704
1744
  private describe;
1705
1745
  }
1706
1746
  /** @deprecated Prefer {@link SqliteStorageProvider}. */
@@ -2208,4 +2248,4 @@ interface BenchmarkReport {
2208
2248
  declare function runBenchmark(name: string, iterations: number, fn: () => Promise<void> | void): Promise<BenchmarkSample[]>;
2209
2249
  declare function summarizeBenchmark(samples: BenchmarkSample[], startedAt: string, finishedAt: string): BenchmarkReport;
2210
2250
 
2211
- export { type BenchmarkReport, type BenchmarkSample, type ChatMessage, type CheckpointInfo, type CheckpointMeta, type CheckpointOptions, type CheckpointProvider, type Chunk, type ChunkingOptions, type ChunkingStrategy, type ClearOptions, type CompressOptions, type CompressResult, CompressionError, type CompressionProvider, type ConcurrencyConfig$1 as ConcurrencyConfig, ConfigurationError, type CreateCheckpointOptions, type DatabaseConfig, DatabaseError, type DatabaseProvider, type DatabaseProviderName, type EmbeddingCacheConfig, type EmbeddingConfig, EmbeddingError, type EmbeddingProvider, type EventDatabase, type ExportResult, FixedChunkingStrategy, type ForgetByFilterOptions, type ForgetByIdOptions, type ForgetOptions, type GetRelatedOptions, GraphCheckpointNotSupportedError, type GraphConfig, type GraphDirection, type GraphEntityInput, type GraphHealthResult, type GraphInput$1 as GraphInput, type GraphProvider, HeadingChunkingStrategy, type HistoryEvent, type HistoryOptions, type HistoryResult, type HybridConfig, type ImportResult, type IngestOptions, type IngestResult, type InitOptions, InitializationError, type KeywordDocument, type KeywordSearchHit, type KeywordSearchProvider, type LatencyBreakdown, LlmCompressionProvider, type LlmConfig, type LlmProvider, MarkdownChunkingStrategy, type MemoryChangeCallback, type MemoryChangeEvent, type MemoryContent, type MemoryDedupeConfig, type MemoryDedupeStrategy, type MemoryFilter, type MemoryMetadata, MemoryNotFoundError, type MemoryProvider, type MemoryRecord, type MetadataFilter as MetaFilter, type MetadataComparison, type MetadataFilter, type MmrConfig, Neo4jGraphProvider, NoopTelemetryProvider, type OCRProvider, type OcrResult, ParagraphChunkingStrategy, type PersistedRecallExplainPayload, type PostgresDatabaseConfig, PostgresStorageProvider, ProviderNotConfiguredError, type RecallExplainResponse, type RecallExplanationHit, type RecallOptions, type RecallResult, type RememberAction, type RememberOptions, type RememberResult, type RerankDocument, type RerankHit, type RerankerProvider, type RetrievalConfig, SDK_VERSION, SentenceChunkingStrategy, SqliteCheckpointProvider, type SqliteDatabaseConfig, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, type StageSpan, type StatsResult, type StorageConfig, StorageLockedError, type StorageProvider, type StorageProviderName, type SubscribableEvent, type SubscribeFilter, type TelemetryConfig, TelemetryEmitter, type TelemetryEvent, type TelemetryEventInput, type TelemetryLogLevel, type TelemetryOperation, type TelemetryProvider, type TelemetryQuery, type TelemetryQueryResult, type TelemetryStatus, type Unsubscribe, ValidationError, type VisionProvider, type VisionResult, Wolbarg, WolbargError, WolbargLogger, type WolbargOptions, type WolbargOptionsWithLlm, type WolbargOptionsWithoutLlm, bgeReranker, bm25, cohereReranker, createChunkingStrategy, createCompressionProvider, createDatabaseProvider, createEmbeddingProvider, createLlmProvider, createStorageProvider, createTelemetryProvider, wolbarg as createWolbarg, crossEncoder, geminiEmbedding, geminiVision, jinaReranker, lmStudioEmbedding, meta, neo4jGraph, ollamaEmbedding, ollamaLlm, openRouterEmbedding, openRouterLlm, openaiCompatibleEmbedding, openaiCompatibleLlm, openaiEmbedding, openaiLlm, openaiReranker, openaiVision, postgres, postgresConfig, runBenchmark, sqlite, sqliteCheckpoint, sqliteConfig, sqliteGraph, sqliteTelemetry, summarizeBenchmark, tesseract, togetherEmbedding, vllmEmbedding, wolbarg$1 as wolbarg, wrapOperationError };
2251
+ export { type BenchmarkReport, type BenchmarkSample, type ChatMessage, type CheckpointInfo, type CheckpointMeta, type CheckpointOptions, type CheckpointProvider, type Chunk, type ChunkingOptions, type ChunkingStrategy, type ClearOptions, type CompressOptions, type CompressResult, CompressionError, type CompressionProvider, type ConcurrencyConfig$1 as ConcurrencyConfig, ConfigurationError, type ConversationMessage, type CreateCheckpointOptions, type DatabaseConfig, DatabaseError, type DatabaseProvider, type DatabaseProviderName, type EmbeddingCacheConfig, type EmbeddingConfig, EmbeddingError, type EmbeddingProvider, type EventDatabase, type ExportResult, FixedChunkingStrategy, type ForgetByFilterOptions, type ForgetByIdOptions, type ForgetOptions, type GetRelatedOptions, GraphCheckpointNotSupportedError, type GraphConfig, type GraphDirection, type GraphEntityInput, type GraphHealthResult, type GraphInput$1 as GraphInput, type GraphProvider, HeadingChunkingStrategy, type HistoryEvent, type HistoryOptions, type HistoryResult, type HybridConfig, type ImportResult, type IngestOptions, type IngestResult, type InitOptions, InitializationError, type KeywordDocument, type KeywordSearchHit, type KeywordSearchProvider, type LatencyBreakdown, LlmCompressionProvider, type LlmConfig, type LlmProvider, MarkdownChunkingStrategy, type MemoryChangeCallback, type MemoryChangeEvent, type MemoryContent, type MemoryDedupeConfig, type MemoryDedupeStrategy, type MemoryFilter, type MemoryMetadata, MemoryNotFoundError, type MemoryProvider, type MemoryRecord, type MetadataFilter as MetaFilter, type MetadataComparison, type MetadataFilter, type MmrConfig, Neo4jGraphProvider, NoopTelemetryProvider, type OCRProvider, type OcrResult, ParagraphChunkingStrategy, type PersistedRecallExplainPayload, type PostgresDatabaseConfig, PostgresStorageProvider, ProviderNotConfiguredError, type RecallExplainResponse, type RecallExplanationHit, type RecallOptions, type RecallResult, type RememberAction, type RememberFromMessagesOptions, type RememberFromMessagesRawStrategy, type RememberOptions, type RememberResult, type RerankDocument, type RerankHit, type RerankerProvider, type RetrievalConfig, SDK_VERSION, SentenceChunkingStrategy, SqliteCheckpointProvider, type SqliteDatabaseConfig, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, type StageSpan, type StatsResult, type StorageConfig, StorageLockedError, type StorageProvider, type StorageProviderName, type SubscribableEvent, type SubscribeFilter, type TelemetryConfig, TelemetryEmitter, type TelemetryEvent, type TelemetryEventInput, type TelemetryLogLevel, type TelemetryOperation, type TelemetryProvider, type TelemetryQuery, type TelemetryQueryResult, type TelemetryStatus, type Unsubscribe, ValidationError, type VisionProvider, type VisionResult, Wolbarg, WolbargError, WolbargLogger, type WolbargOptions, type WolbargOptionsWithLlm, type WolbargOptionsWithoutLlm, bgeReranker, bm25, cohereReranker, createChunkingStrategy, createCompressionProvider, createDatabaseProvider, createEmbeddingProvider, createLlmProvider, createStorageProvider, createTelemetryProvider, wolbarg as createWolbarg, crossEncoder, geminiEmbedding, geminiVision, jinaReranker, lmStudioEmbedding, meta, neo4jGraph, ollamaEmbedding, ollamaLlm, openRouterEmbedding, openRouterLlm, openaiCompatibleEmbedding, openaiCompatibleLlm, openaiEmbedding, openaiLlm, openaiReranker, openaiVision, postgres, postgresConfig, runBenchmark, sqlite, sqliteCheckpoint, sqliteConfig, sqliteGraph, sqliteTelemetry, summarizeBenchmark, tesseract, togetherEmbedding, vllmEmbedding, wolbarg$1 as wolbarg, wrapOperationError };
package/dist/index.d.ts CHANGED
@@ -49,7 +49,7 @@ declare const meta: {
49
49
  * Schema is intentionally extensible for future providers (Postgres, cloud).
50
50
  */
51
51
  /** Public operation names recorded as telemetry events. */
52
- type TelemetryOperation = "remember" | "recall" | "forget" | "compress" | "rememberBatch" | "recallBatch" | "export" | "import" | "checkpoint" | "rollback" | "error" | "startup" | "shutdown" | "ingest" | "history" | "stats" | "clear" | "deleteCheckpoint" | "listCheckpoints" | "getCheckpoint" | "linkMemories" | "getRelated" | "graphQuery";
52
+ type TelemetryOperation = "remember" | "recall" | "forget" | "compress" | "rememberBatch" | "recallBatch" | "export" | "import" | "checkpoint" | "rollback" | "error" | "startup" | "shutdown" | "ingest" | "history" | "stats" | "clear" | "deleteCheckpoint" | "listCheckpoints" | "getCheckpoint" | "linkMemories" | "getRelated" | "graphQuery" | "rememberFromMessages";
53
53
  type TelemetryStatus = "ok" | "error" | "cancelled";
54
54
  type TelemetryLogLevel = "off" | "error" | "warn" | "info" | "debug" | "trace";
55
55
  /** Stage-level latency breakdown recorded on each event. */
@@ -341,6 +341,35 @@ interface RememberOptions {
341
341
  /** Per-call dedupe override; undefined uses constructor `memory.dedupe`. */
342
342
  dedupe?: boolean | MemoryDedupeConfig;
343
343
  }
344
+ /**
345
+ * Chat turn for {@link Wolbarg.rememberFromMessages}.
346
+ * @experimental until 1.0
347
+ */
348
+ interface ConversationMessage {
349
+ role: string;
350
+ content: string;
351
+ }
352
+ /** How `mode: "raw"` selects user turns to store. */
353
+ type RememberFromMessagesRawStrategy = "last_user" | "all_user";
354
+ /**
355
+ * Options for {@link Wolbarg.rememberFromMessages}.
356
+ * @experimental until 1.0
357
+ */
358
+ interface RememberFromMessagesOptions {
359
+ /** Agent identifier that owns the stored memories. */
360
+ agent: string;
361
+ /**
362
+ * `raw` (default) — store user message text without an LLM.
363
+ * `extract` — use configured `llm` to extract atomic facts, then remember each.
364
+ */
365
+ mode?: "raw" | "extract";
366
+ /** Used when `mode` is `raw`. Defaults to `last_user`. */
367
+ rawStrategy?: RememberFromMessagesRawStrategy;
368
+ /** Optional opaque metadata attached to every stored memory. */
369
+ metadata?: MemoryMetadata;
370
+ /** Per-call dedupe override; undefined uses constructor `memory.dedupe`. */
371
+ dedupe?: boolean | MemoryDedupeConfig;
372
+ }
344
373
  /** Whether remember created a new row or updated an existing one. */
345
374
  type RememberAction = "created" | "updated";
346
375
  /** Result of {@link Wolbarg.remember} — MemoryRecord plus upsert action. */
@@ -730,7 +759,7 @@ declare function createChunkingStrategy(name?: "fixed" | "sentence" | "paragraph
730
759
 
731
760
  /**
732
761
  * LLM provider abstractions and OpenAI-compatible chat implementation.
733
- * Used exclusively for memory compression (and future ORC features).
762
+ * Used for memory compression and experimental rememberFromMessages extract mode.
734
763
  */
735
764
 
736
765
  interface ChatMessage {
@@ -1296,6 +1325,15 @@ declare class Wolbarg<HasLlm extends boolean = false> {
1296
1325
  remember(options: RememberOptions): Promise<RememberResult>;
1297
1326
  /** Batch remember — sequential when dedupe enabled; otherwise one TX batch. */
1298
1327
  rememberBatch(items: RememberOptions[]): Promise<RememberResult[]>;
1328
+ /**
1329
+ * Store memories from a chat transcript.
1330
+ *
1331
+ * **Experimental** until 1.0 — API shape may change.
1332
+ *
1333
+ * - `mode: "raw"` (default) — remember user message text (no LLM).
1334
+ * - `mode: "extract"` — require configured `llm`; extract atomic facts then remember each.
1335
+ */
1336
+ rememberFromMessages(messages: ConversationMessage[], options: RememberFromMessagesOptions): Promise<RememberResult[]>;
1299
1337
  /**
1300
1338
  * Update an existing memory by id (re-embeds when content changes).
1301
1339
  */
@@ -1388,7 +1426,7 @@ declare class Wolbarg<HasLlm extends boolean = false> {
1388
1426
  declare function wolbarg$1(options: WolbargOptions): Wolbarg;
1389
1427
 
1390
1428
  /** Published SDK semver — keep in sync with package.json `version`. */
1391
- declare const SDK_VERSION = "0.5.0";
1429
+ declare const SDK_VERSION = "0.5.3";
1392
1430
 
1393
1431
  /**
1394
1432
  * Operation-scoped errors with reason + suggestion for developer experience.
@@ -1701,6 +1739,8 @@ declare class SqliteStorageProvider implements StorageProvider {
1701
1739
  private requireStatements;
1702
1740
  private requireVectorReady;
1703
1741
  private toVectorParam;
1742
+ /** sqlite-vec vec0 PKs must be bound as BigInt under node:sqlite. */
1743
+ private toVecRowid;
1704
1744
  private describe;
1705
1745
  }
1706
1746
  /** @deprecated Prefer {@link SqliteStorageProvider}. */
@@ -2208,4 +2248,4 @@ interface BenchmarkReport {
2208
2248
  declare function runBenchmark(name: string, iterations: number, fn: () => Promise<void> | void): Promise<BenchmarkSample[]>;
2209
2249
  declare function summarizeBenchmark(samples: BenchmarkSample[], startedAt: string, finishedAt: string): BenchmarkReport;
2210
2250
 
2211
- export { type BenchmarkReport, type BenchmarkSample, type ChatMessage, type CheckpointInfo, type CheckpointMeta, type CheckpointOptions, type CheckpointProvider, type Chunk, type ChunkingOptions, type ChunkingStrategy, type ClearOptions, type CompressOptions, type CompressResult, CompressionError, type CompressionProvider, type ConcurrencyConfig$1 as ConcurrencyConfig, ConfigurationError, type CreateCheckpointOptions, type DatabaseConfig, DatabaseError, type DatabaseProvider, type DatabaseProviderName, type EmbeddingCacheConfig, type EmbeddingConfig, EmbeddingError, type EmbeddingProvider, type EventDatabase, type ExportResult, FixedChunkingStrategy, type ForgetByFilterOptions, type ForgetByIdOptions, type ForgetOptions, type GetRelatedOptions, GraphCheckpointNotSupportedError, type GraphConfig, type GraphDirection, type GraphEntityInput, type GraphHealthResult, type GraphInput$1 as GraphInput, type GraphProvider, HeadingChunkingStrategy, type HistoryEvent, type HistoryOptions, type HistoryResult, type HybridConfig, type ImportResult, type IngestOptions, type IngestResult, type InitOptions, InitializationError, type KeywordDocument, type KeywordSearchHit, type KeywordSearchProvider, type LatencyBreakdown, LlmCompressionProvider, type LlmConfig, type LlmProvider, MarkdownChunkingStrategy, type MemoryChangeCallback, type MemoryChangeEvent, type MemoryContent, type MemoryDedupeConfig, type MemoryDedupeStrategy, type MemoryFilter, type MemoryMetadata, MemoryNotFoundError, type MemoryProvider, type MemoryRecord, type MetadataFilter as MetaFilter, type MetadataComparison, type MetadataFilter, type MmrConfig, Neo4jGraphProvider, NoopTelemetryProvider, type OCRProvider, type OcrResult, ParagraphChunkingStrategy, type PersistedRecallExplainPayload, type PostgresDatabaseConfig, PostgresStorageProvider, ProviderNotConfiguredError, type RecallExplainResponse, type RecallExplanationHit, type RecallOptions, type RecallResult, type RememberAction, type RememberOptions, type RememberResult, type RerankDocument, type RerankHit, type RerankerProvider, type RetrievalConfig, SDK_VERSION, SentenceChunkingStrategy, SqliteCheckpointProvider, type SqliteDatabaseConfig, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, type StageSpan, type StatsResult, type StorageConfig, StorageLockedError, type StorageProvider, type StorageProviderName, type SubscribableEvent, type SubscribeFilter, type TelemetryConfig, TelemetryEmitter, type TelemetryEvent, type TelemetryEventInput, type TelemetryLogLevel, type TelemetryOperation, type TelemetryProvider, type TelemetryQuery, type TelemetryQueryResult, type TelemetryStatus, type Unsubscribe, ValidationError, type VisionProvider, type VisionResult, Wolbarg, WolbargError, WolbargLogger, type WolbargOptions, type WolbargOptionsWithLlm, type WolbargOptionsWithoutLlm, bgeReranker, bm25, cohereReranker, createChunkingStrategy, createCompressionProvider, createDatabaseProvider, createEmbeddingProvider, createLlmProvider, createStorageProvider, createTelemetryProvider, wolbarg as createWolbarg, crossEncoder, geminiEmbedding, geminiVision, jinaReranker, lmStudioEmbedding, meta, neo4jGraph, ollamaEmbedding, ollamaLlm, openRouterEmbedding, openRouterLlm, openaiCompatibleEmbedding, openaiCompatibleLlm, openaiEmbedding, openaiLlm, openaiReranker, openaiVision, postgres, postgresConfig, runBenchmark, sqlite, sqliteCheckpoint, sqliteConfig, sqliteGraph, sqliteTelemetry, summarizeBenchmark, tesseract, togetherEmbedding, vllmEmbedding, wolbarg$1 as wolbarg, wrapOperationError };
2251
+ export { type BenchmarkReport, type BenchmarkSample, type ChatMessage, type CheckpointInfo, type CheckpointMeta, type CheckpointOptions, type CheckpointProvider, type Chunk, type ChunkingOptions, type ChunkingStrategy, type ClearOptions, type CompressOptions, type CompressResult, CompressionError, type CompressionProvider, type ConcurrencyConfig$1 as ConcurrencyConfig, ConfigurationError, type ConversationMessage, type CreateCheckpointOptions, type DatabaseConfig, DatabaseError, type DatabaseProvider, type DatabaseProviderName, type EmbeddingCacheConfig, type EmbeddingConfig, EmbeddingError, type EmbeddingProvider, type EventDatabase, type ExportResult, FixedChunkingStrategy, type ForgetByFilterOptions, type ForgetByIdOptions, type ForgetOptions, type GetRelatedOptions, GraphCheckpointNotSupportedError, type GraphConfig, type GraphDirection, type GraphEntityInput, type GraphHealthResult, type GraphInput$1 as GraphInput, type GraphProvider, HeadingChunkingStrategy, type HistoryEvent, type HistoryOptions, type HistoryResult, type HybridConfig, type ImportResult, type IngestOptions, type IngestResult, type InitOptions, InitializationError, type KeywordDocument, type KeywordSearchHit, type KeywordSearchProvider, type LatencyBreakdown, LlmCompressionProvider, type LlmConfig, type LlmProvider, MarkdownChunkingStrategy, type MemoryChangeCallback, type MemoryChangeEvent, type MemoryContent, type MemoryDedupeConfig, type MemoryDedupeStrategy, type MemoryFilter, type MemoryMetadata, MemoryNotFoundError, type MemoryProvider, type MemoryRecord, type MetadataFilter as MetaFilter, type MetadataComparison, type MetadataFilter, type MmrConfig, Neo4jGraphProvider, NoopTelemetryProvider, type OCRProvider, type OcrResult, ParagraphChunkingStrategy, type PersistedRecallExplainPayload, type PostgresDatabaseConfig, PostgresStorageProvider, ProviderNotConfiguredError, type RecallExplainResponse, type RecallExplanationHit, type RecallOptions, type RecallResult, type RememberAction, type RememberFromMessagesOptions, type RememberFromMessagesRawStrategy, type RememberOptions, type RememberResult, type RerankDocument, type RerankHit, type RerankerProvider, type RetrievalConfig, SDK_VERSION, SentenceChunkingStrategy, SqliteCheckpointProvider, type SqliteDatabaseConfig, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, type StageSpan, type StatsResult, type StorageConfig, StorageLockedError, type StorageProvider, type StorageProviderName, type SubscribableEvent, type SubscribeFilter, type TelemetryConfig, TelemetryEmitter, type TelemetryEvent, type TelemetryEventInput, type TelemetryLogLevel, type TelemetryOperation, type TelemetryProvider, type TelemetryQuery, type TelemetryQueryResult, type TelemetryStatus, type Unsubscribe, ValidationError, type VisionProvider, type VisionResult, Wolbarg, WolbargError, WolbargLogger, type WolbargOptions, type WolbargOptionsWithLlm, type WolbargOptionsWithoutLlm, bgeReranker, bm25, cohereReranker, createChunkingStrategy, createCompressionProvider, createDatabaseProvider, createEmbeddingProvider, createLlmProvider, createStorageProvider, createTelemetryProvider, wolbarg as createWolbarg, crossEncoder, geminiEmbedding, geminiVision, jinaReranker, lmStudioEmbedding, meta, neo4jGraph, ollamaEmbedding, ollamaLlm, openRouterEmbedding, openRouterLlm, openaiCompatibleEmbedding, openaiCompatibleLlm, openaiEmbedding, openaiLlm, openaiReranker, openaiVision, postgres, postgresConfig, runBenchmark, sqlite, sqliteCheckpoint, sqliteConfig, sqliteGraph, sqliteTelemetry, summarizeBenchmark, tesseract, togetherEmbedding, vllmEmbedding, wolbarg$1 as wolbarg, wrapOperationError };
package/dist/index.js CHANGED
@@ -1607,7 +1607,7 @@ var SQL = {
1607
1607
  AND k = ?
1608
1608
  `,
1609
1609
  insertEmbeddingBlob: `
1610
- INSERT INTO memory_embeddings_blob (memory_rowid, embedding) VALUES (?, ?)
1610
+ INSERT OR REPLACE INTO memory_embeddings_blob (memory_rowid, embedding) VALUES (?, ?)
1611
1611
  `,
1612
1612
  deleteEmbeddingBlob: `
1613
1613
  DELETE FROM memory_embeddings_blob WHERE memory_rowid = ?
@@ -2563,6 +2563,13 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
2563
2563
  this.deleteEmbeddingsForScope(organization);
2564
2564
  this.deleteFtsForScope(organization);
2565
2565
  const result = stmts.deleteMemoriesByOrg.run(organization);
2566
+ try {
2567
+ this.requireDb().exec(`
2568
+ DELETE FROM memory_embeddings_blob
2569
+ WHERE memory_rowid NOT IN (SELECT rowid FROM memories)
2570
+ `);
2571
+ } catch {
2572
+ }
2566
2573
  return Number(result.changes);
2567
2574
  });
2568
2575
  }
@@ -3077,7 +3084,7 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
3077
3084
  if (!stmt) {
3078
3085
  const values = Array.from({ length: n }, () => "(?, ?)").join(", ");
3079
3086
  stmt = this.requireDb().prepare(
3080
- `INSERT INTO memory_embeddings_blob (memory_rowid, embedding) VALUES ${values}`
3087
+ `INSERT OR REPLACE INTO memory_embeddings_blob (memory_rowid, embedding) VALUES ${values}`
3081
3088
  );
3082
3089
  this.batchBlobEmbStatements.set(n, stmt);
3083
3090
  }
@@ -3298,12 +3305,13 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
3298
3305
  insertEmbedding(rowid, embedding) {
3299
3306
  const stmts = this.requireStatements();
3300
3307
  if (this.vectorBackend === "sqlite-vec") {
3301
- stmts.insertEmbedding.run(rowid, this.toVectorParam(embedding));
3308
+ stmts.insertEmbedding.run(this.toVecRowid(rowid), this.toVectorParam(embedding));
3302
3309
  return;
3303
3310
  }
3304
- stmts.insertEmbeddingBlob.run(rowid, embeddingToBuffer(embedding));
3311
+ const id = Number(rowid);
3312
+ stmts.insertEmbeddingBlob.run(id, embeddingToBuffer(embedding));
3305
3313
  if (this.memoryIndex) {
3306
- this.memoryIndex.upsert(rowid, embedding);
3314
+ this.memoryIndex.upsert(id, embedding);
3307
3315
  this.memoryIndexDirty = false;
3308
3316
  } else {
3309
3317
  this.memoryIndexDirty = true;
@@ -3313,10 +3321,11 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
3313
3321
  const stmts = this.requireStatements();
3314
3322
  try {
3315
3323
  if (this.vectorBackend === "sqlite-vec" && stmts.deleteEmbedding) {
3316
- stmts.deleteEmbedding.run(rowid);
3324
+ stmts.deleteEmbedding.run(this.toVecRowid(rowid));
3317
3325
  } else if (stmts.deleteEmbeddingBlob) {
3318
- stmts.deleteEmbeddingBlob.run(rowid);
3319
- this.memoryIndex?.remove(rowid);
3326
+ const id = Number(rowid);
3327
+ stmts.deleteEmbeddingBlob.run(id);
3328
+ this.memoryIndex?.remove(id);
3320
3329
  this.memoryIndexDirty = true;
3321
3330
  }
3322
3331
  } catch {
@@ -3333,8 +3342,8 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
3333
3342
  for (let i = 0; i < rows.length; i += 1) {
3334
3343
  const row = rows[i];
3335
3344
  hits[i] = {
3336
- memoryRowid: row.memory_rowid,
3337
- distance: row.distance
3345
+ memoryRowid: Number(row.memory_rowid),
3346
+ distance: Number(row.distance)
3338
3347
  };
3339
3348
  }
3340
3349
  return hits;
@@ -3410,6 +3419,10 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
3410
3419
  const buffer = embeddingToBuffer(embedding);
3411
3420
  return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
3412
3421
  }
3422
+ /** sqlite-vec vec0 PKs must be bound as BigInt under node:sqlite. */
3423
+ toVecRowid(rowid) {
3424
+ return typeof rowid === "bigint" ? rowid : BigInt(rowid);
3425
+ }
3413
3426
  describe(error) {
3414
3427
  if (error instanceof Error) {
3415
3428
  return error.message;
@@ -5138,7 +5151,7 @@ function createDatabaseProvider(config) {
5138
5151
  }
5139
5152
 
5140
5153
  // src/version.ts
5141
- var SDK_VERSION = "0.5.0";
5154
+ var SDK_VERSION = "0.5.3";
5142
5155
 
5143
5156
  // src/memory/transfer.ts
5144
5157
  var SqliteMemoryTransferProvider = class {
@@ -5264,6 +5277,96 @@ function resolvePath(p) {
5264
5277
  return path7.isAbsolute(p) ? p : path7.resolve(process.cwd(), p);
5265
5278
  }
5266
5279
 
5280
+ // src/memory/from-messages.ts
5281
+ var DEFAULT_RAW_STRATEGY = "last_user";
5282
+ function normalizeConversationMessages(messages) {
5283
+ if (!Array.isArray(messages)) {
5284
+ throw new ValidationError("messages must be an array");
5285
+ }
5286
+ if (messages.length === 0) {
5287
+ throw new ValidationError("messages must be a non-empty array");
5288
+ }
5289
+ return messages.map((message, index) => {
5290
+ if (!message || typeof message !== "object") {
5291
+ throw new ValidationError(`messages[${index}] must be an object`);
5292
+ }
5293
+ if (typeof message.role !== "string" || message.role.trim().length === 0) {
5294
+ throw new ValidationError(`messages[${index}].role must be a non-empty string`);
5295
+ }
5296
+ if (typeof message.content !== "string") {
5297
+ throw new ValidationError(`messages[${index}].content must be a string`);
5298
+ }
5299
+ return {
5300
+ role: message.role.trim(),
5301
+ content: message.content.trim()
5302
+ };
5303
+ });
5304
+ }
5305
+ function resolveRememberFromMessagesOptions(options) {
5306
+ if (!options || typeof options !== "object") {
5307
+ throw new ValidationError("options is required");
5308
+ }
5309
+ if (typeof options.agent !== "string" || options.agent.trim().length === 0) {
5310
+ throw new ValidationError("agent must be a non-empty string");
5311
+ }
5312
+ const mode = options.mode ?? "raw";
5313
+ if (mode !== "raw" && mode !== "extract") {
5314
+ throw new ValidationError('mode must be "raw" or "extract"');
5315
+ }
5316
+ const rawStrategy = options.rawStrategy ?? DEFAULT_RAW_STRATEGY;
5317
+ if (rawStrategy !== "last_user" && rawStrategy !== "all_user") {
5318
+ throw new ValidationError('rawStrategy must be "last_user" or "all_user"');
5319
+ }
5320
+ return {
5321
+ agent: options.agent.trim(),
5322
+ mode,
5323
+ rawStrategy,
5324
+ ...options.metadata !== void 0 ? { metadata: options.metadata } : {},
5325
+ ...options.dedupe !== void 0 ? { dedupe: options.dedupe } : {}
5326
+ };
5327
+ }
5328
+ function selectRawUserTexts(messages, strategy) {
5329
+ const userTexts = messages.filter((m) => m.role === "user" && m.content.length > 0).map((m) => m.content);
5330
+ if (userTexts.length === 0) {
5331
+ throw new ValidationError(
5332
+ 'no user messages with non-empty content \u2014 nothing to remember in mode "raw"'
5333
+ );
5334
+ }
5335
+ if (strategy === "last_user") {
5336
+ return [userTexts[userTexts.length - 1]];
5337
+ }
5338
+ return userTexts;
5339
+ }
5340
+ function buildExtractMessages(messages) {
5341
+ const transcript = messages.map((m) => `${m.role}: ${m.content}`).join("\n");
5342
+ return [
5343
+ {
5344
+ role: "system",
5345
+ content: "Extract durable factual memories from the conversation. Return only atomic facts, one per line. No numbering, bullets, or commentary. If there are no facts worth storing, reply with exactly NONE."
5346
+ },
5347
+ {
5348
+ role: "user",
5349
+ content: transcript
5350
+ }
5351
+ ];
5352
+ }
5353
+ function parseExtractedFacts(llmOutput) {
5354
+ const trimmed = llmOutput.trim();
5355
+ if (trimmed.length === 0 || /^none$/i.test(trimmed)) {
5356
+ return [];
5357
+ }
5358
+ const facts = [];
5359
+ for (const line of trimmed.split(/\r?\n/)) {
5360
+ let fact = line.trim();
5361
+ if (fact.length === 0) continue;
5362
+ fact = fact.replace(/^[-*•]\s+/, "");
5363
+ fact = fact.replace(/^\d+[.)]\s+/, "");
5364
+ if (fact.length === 0 || /^none$/i.test(fact)) continue;
5365
+ facts.push(fact);
5366
+ }
5367
+ return facts;
5368
+ }
5369
+
5267
5370
  // src/memory/index.ts
5268
5371
  function toMemoryRecord(row) {
5269
5372
  return {
@@ -7712,6 +7815,81 @@ var Wolbarg = class {
7712
7815
  throw wrapOperationError("rememberBatch", error);
7713
7816
  }
7714
7817
  }
7818
+ /**
7819
+ * Store memories from a chat transcript.
7820
+ *
7821
+ * **Experimental** until 1.0 — API shape may change.
7822
+ *
7823
+ * - `mode: "raw"` (default) — remember user message text (no LLM).
7824
+ * - `mode: "extract"` — require configured `llm`; extract atomic facts then remember each.
7825
+ */
7826
+ async rememberFromMessages(messages, options) {
7827
+ const parent = this.telemetry.start("rememberFromMessages");
7828
+ try {
7829
+ const normalized = normalizeConversationMessages(messages);
7830
+ const resolved = resolveRememberFromMessagesOptions(options);
7831
+ let texts;
7832
+ if (resolved.mode === "extract") {
7833
+ if (!this.llm) {
7834
+ throw new ProviderNotConfiguredError(
7835
+ "llm",
7836
+ "rememberFromMessages",
7837
+ 'pass llm: openaiLlm(...) in the constructor when mode is "extract"'
7838
+ );
7839
+ }
7840
+ const llmOutput = await this.llm.complete(
7841
+ buildExtractMessages(normalized)
7842
+ );
7843
+ texts = parseExtractedFacts(llmOutput);
7844
+ if (texts.length === 0) {
7845
+ parent.success({
7846
+ returnedCount: 0,
7847
+ agentId: resolved.agent,
7848
+ extra: { mode: "extract", factCount: 0 }
7849
+ });
7850
+ return [];
7851
+ }
7852
+ } else {
7853
+ texts = selectRawUserTexts(normalized, resolved.rawStrategy);
7854
+ }
7855
+ const out = [];
7856
+ for (const text of texts) {
7857
+ const child = parent.child("remember");
7858
+ const result = await this.rememberOne(
7859
+ {
7860
+ agent: resolved.agent,
7861
+ content: { text },
7862
+ ...resolved.metadata !== void 0 ? { metadata: resolved.metadata } : {},
7863
+ ...resolved.dedupe !== void 0 ? { dedupe: resolved.dedupe } : {}
7864
+ },
7865
+ child
7866
+ );
7867
+ child.success({
7868
+ provider: this.storage?.name,
7869
+ memoryIds: [result.id],
7870
+ returnedCount: 1,
7871
+ metadata: result.metadata,
7872
+ agentId: result.agent,
7873
+ tags: telemetryTags(result.metadata),
7874
+ extra: { upsertAction: result.action, mode: resolved.mode }
7875
+ });
7876
+ out.push(result);
7877
+ }
7878
+ parent.success({
7879
+ provider: this.storage?.name,
7880
+ memoryIds: out.map((r) => r.id),
7881
+ returnedCount: out.length,
7882
+ embeddingProvider: this.embedding?.model,
7883
+ model: this.embedding?.model,
7884
+ agentId: resolved.agent,
7885
+ extra: { mode: resolved.mode }
7886
+ });
7887
+ return out;
7888
+ } catch (error) {
7889
+ parent.failure(error, { agentId: options?.agent });
7890
+ throw wrapOperationError("rememberFromMessages", error);
7891
+ }
7892
+ }
7715
7893
  /**
7716
7894
  * Update an existing memory by id (re-embeds when content changes).
7717
7895
  */