@ziro-agent/memory
Advanced tools
+3
-1
@@ -177,2 +177,4 @@ import { ChatMessage } from '@ziro-agent/core'; | ||
| } | ||
| /** Deletes persisted conversation snapshots for each thread (RFC 0016 wiring). */ | ||
| declare function deleteConversationSnapshotThreads(store: ConversationSnapshotStore, threadIds: readonly string[]): Promise<void>; | ||
| /** | ||
@@ -378,2 +380,2 @@ * One JSON file per thread under `directory` (`<threadId>.json`). | ||
| export { type AgentMemoryConfig, BM25Index, type ChunkOptions, type CitationEntry, type CohereRerankerOptions, type ConversationMemory, type ConversationMemoryContext, type ConversationSnapshotStore, DirConversationSnapshotStore, Document, type DocumentParseContext, type DocumentParser, EmbeddedDocument, EmbeddingModel, type LoadedDocument, type MemoryProcessor, type MemoryProcessorContext, MemoryVectorStore, type MemoryVectorStoreOptions, Metadata, type OpenAIEmbeddingOptions, PersistingConversationMemory, type PersistingConversationMemoryOptions, type RerankDocument, type RerankerAdapter, type RetrieveOptions, SearchResult, SearchStrategy, SlidingWindowConversationMemory, type SnippetCompressorOptions, SummarizingConversationMemory, type SummarizingConversationMemoryOptions, type TextWithCitations, VectorQuery, VectorStore, type VoyageRerankerOptions, WorkingMemory, buildTextWithCitations, chunkText, clearDocumentParserRegistry, composeMemoryProcessors, cosineSimilarity, createCohereReranker, createDroppedMessagesSnippetCompressor, createOpenAIEmbedder, createVoyageReranker, loadDocument, normalize, passthroughReranker, reciprocalRankFusion, registerDocumentParser, retrieve, tokenize, trimNonSystemMessageCount }; | ||
| export { type AgentMemoryConfig, BM25Index, type ChunkOptions, type CitationEntry, type CohereRerankerOptions, type ConversationMemory, type ConversationMemoryContext, type ConversationSnapshotStore, DirConversationSnapshotStore, Document, type DocumentParseContext, type DocumentParser, EmbeddedDocument, EmbeddingModel, type LoadedDocument, type MemoryProcessor, type MemoryProcessorContext, MemoryVectorStore, type MemoryVectorStoreOptions, Metadata, type OpenAIEmbeddingOptions, PersistingConversationMemory, type PersistingConversationMemoryOptions, type RerankDocument, type RerankerAdapter, type RetrieveOptions, SearchResult, SearchStrategy, SlidingWindowConversationMemory, type SnippetCompressorOptions, SummarizingConversationMemory, type SummarizingConversationMemoryOptions, type TextWithCitations, VectorQuery, VectorStore, type VoyageRerankerOptions, WorkingMemory, buildTextWithCitations, chunkText, clearDocumentParserRegistry, composeMemoryProcessors, cosineSimilarity, createCohereReranker, createDroppedMessagesSnippetCompressor, createOpenAIEmbedder, createVoyageReranker, deleteConversationSnapshotThreads, loadDocument, normalize, passthroughReranker, reciprocalRankFusion, registerDocumentParser, retrieve, tokenize, trimNonSystemMessageCount }; |
+3
-1
@@ -177,2 +177,4 @@ import { ChatMessage } from '@ziro-agent/core'; | ||
| } | ||
| /** Deletes persisted conversation snapshots for each thread (RFC 0016 wiring). */ | ||
| declare function deleteConversationSnapshotThreads(store: ConversationSnapshotStore, threadIds: readonly string[]): Promise<void>; | ||
| /** | ||
@@ -378,2 +380,2 @@ * One JSON file per thread under `directory` (`<threadId>.json`). | ||
| export { type AgentMemoryConfig, BM25Index, type ChunkOptions, type CitationEntry, type CohereRerankerOptions, type ConversationMemory, type ConversationMemoryContext, type ConversationSnapshotStore, DirConversationSnapshotStore, Document, type DocumentParseContext, type DocumentParser, EmbeddedDocument, EmbeddingModel, type LoadedDocument, type MemoryProcessor, type MemoryProcessorContext, MemoryVectorStore, type MemoryVectorStoreOptions, Metadata, type OpenAIEmbeddingOptions, PersistingConversationMemory, type PersistingConversationMemoryOptions, type RerankDocument, type RerankerAdapter, type RetrieveOptions, SearchResult, SearchStrategy, SlidingWindowConversationMemory, type SnippetCompressorOptions, SummarizingConversationMemory, type SummarizingConversationMemoryOptions, type TextWithCitations, VectorQuery, VectorStore, type VoyageRerankerOptions, WorkingMemory, buildTextWithCitations, chunkText, clearDocumentParserRegistry, composeMemoryProcessors, cosineSimilarity, createCohereReranker, createDroppedMessagesSnippetCompressor, createOpenAIEmbedder, createVoyageReranker, loadDocument, normalize, passthroughReranker, reciprocalRankFusion, registerDocumentParser, retrieve, tokenize, trimNonSystemMessageCount }; | ||
| export { type AgentMemoryConfig, BM25Index, type ChunkOptions, type CitationEntry, type CohereRerankerOptions, type ConversationMemory, type ConversationMemoryContext, type ConversationSnapshotStore, DirConversationSnapshotStore, Document, type DocumentParseContext, type DocumentParser, EmbeddedDocument, EmbeddingModel, type LoadedDocument, type MemoryProcessor, type MemoryProcessorContext, MemoryVectorStore, type MemoryVectorStoreOptions, Metadata, type OpenAIEmbeddingOptions, PersistingConversationMemory, type PersistingConversationMemoryOptions, type RerankDocument, type RerankerAdapter, type RetrieveOptions, SearchResult, SearchStrategy, SlidingWindowConversationMemory, type SnippetCompressorOptions, SummarizingConversationMemory, type SummarizingConversationMemoryOptions, type TextWithCitations, VectorQuery, VectorStore, type VoyageRerankerOptions, WorkingMemory, buildTextWithCitations, chunkText, clearDocumentParserRegistry, composeMemoryProcessors, cosineSimilarity, createCohereReranker, createDroppedMessagesSnippetCompressor, createOpenAIEmbedder, createVoyageReranker, deleteConversationSnapshotThreads, loadDocument, normalize, passthroughReranker, reciprocalRankFusion, registerDocumentParser, retrieve, tokenize, trimNonSystemMessageCount }; |
+18
-2
@@ -8,6 +8,20 @@ 'use strict'; | ||
| // src/file-backed-working-memory.ts | ||
| function backingFilePath(baseDir, scope, key) { | ||
| function resolveFileBackedWorkingMemoryPath(baseDir, scope, key) { | ||
| const h = crypto.createHash("sha256").update(`${scope}\0${key}`).digest("hex").slice(0, 32); | ||
| return path.join(baseDir, `${scope}-${h}.working.md`); | ||
| } | ||
| async function deleteFileBackedWorkingMemoryFiles(baseDir, scope, keys) { | ||
| await Promise.all( | ||
| keys.map(async (key) => { | ||
| const p = resolveFileBackedWorkingMemoryPath(baseDir, scope, key); | ||
| try { | ||
| await promises.unlink(p); | ||
| } catch (e) { | ||
| const err = e; | ||
| if (err.code === "ENOENT") return; | ||
| throw e; | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| var FileBackedWorkingMemory = class { | ||
@@ -17,3 +31,3 @@ constructor(scope, key, baseDir) { | ||
| this.key = key; | ||
| this.filePath = backingFilePath(baseDir, scope, key); | ||
| this.filePath = resolveFileBackedWorkingMemoryPath(baseDir, scope, key); | ||
| } | ||
@@ -54,3 +68,5 @@ scope; | ||
| exports.FileBackedWorkingMemory = FileBackedWorkingMemory; | ||
| exports.deleteFileBackedWorkingMemoryFiles = deleteFileBackedWorkingMemoryFiles; | ||
| exports.resolveFileBackedWorkingMemoryPath = resolveFileBackedWorkingMemoryPath; | ||
| //# sourceMappingURL=node.cjs.map | ||
| //# sourceMappingURL=node.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/file-backed-working-memory.ts"],"names":["createHash","join","readFile","mkdir","dirname","writeFile","unlink"],"mappings":";;;;;;;AASA,SAAS,eAAA,CAAgB,OAAA,EAAiB,KAAA,EAA2B,GAAA,EAAqB;AACxF,EAAA,MAAM,IAAIA,iBAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,EAAE,MAAA,CAAO,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,EAAE,CAAA;AACnF,EAAA,OAAOC,UAAK,OAAA,EAAS,CAAA,EAAG,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,WAAA,CAAa,CAAA;AACjD;AAMO,IAAM,0BAAN,MAAuD;AAAA,EAG5D,WAAA,CACW,KAAA,EACA,GAAA,EAET,OAAA,EACA;AAJS,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACA,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAIT,IAAA,IAAA,CAAK,QAAA,GAAW,eAAA,CAAgB,OAAA,EAAS,KAAA,EAAO,GAAG,CAAA;AAAA,EACrD;AAAA,EANW,KAAA;AAAA,EACA,GAAA;AAAA,EAJM,QAAA;AAAA,EAWjB,MAAM,IAAA,GAAwB;AAC5B,IAAA,IAAI;AACF,MAAA,OAAO,MAAMC,iBAAA,CAAS,IAAA,CAAK,QAAA,EAAU,MAAM,CAAA;AAAA,IAC7C,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,GAAA,GAAM,CAAA;AACZ,MAAA,IAAI,GAAA,CAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAA;AAClC,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAM,MAAM,QAAA,EAAiC;AAC3C,IAAA,MAAMC,cAAA,CAAMC,aAAQ,IAAA,CAAK,QAAQ,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AACvD,IAAA,MAAMC,kBAAA,CAAU,IAAA,CAAK,QAAA,EAAU,QAAA,EAAU,MAAM,CAAA;AAAA,EACjD;AAAA,EAEA,MAAM,OAAO,QAAA,EAAiC;AAC5C,IAAA,IAAI,GAAA,GAAM,MAAM,IAAA,CAAK,IAAA,EAAK;AAC1B,IAAA,IAAI,GAAA,CAAI,SAAS,CAAA,IAAK,CAAC,IAAI,QAAA,CAAS,IAAI,GAAG,GAAA,IAAO,IAAA;AAClD,IAAA,GAAA,IAAO,QAAA;AACP,IAAA,MAAM,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACtB;AAAA,EAEA,MAAM,KAAA,GAAuB;AAC3B,IAAA,IAAI;AACF,MAAA,MAAMC,eAAA,CAAO,KAAK,QAAQ,CAAA;AAAA,IAC5B,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,GAAA,GAAM,CAAA;AACZ,MAAA,IAAI,GAAA,CAAI,SAAS,QAAA,EAAU;AAC3B,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AACF","file":"node.cjs","sourcesContent":["/**\n * Durable working-memory tier (RFC 0011) — Node filesystem backing.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { WorkingMemory, WorkingMemoryScope } from './working-memory.js';\n\nfunction backingFilePath(baseDir: string, scope: WorkingMemoryScope, key: string): string {\n const h = createHash('sha256').update(`${scope}\\0${key}`).digest('hex').slice(0, 32);\n return join(baseDir, `${scope}-${h}.working.md`);\n}\n\n/**\n * Persists working-memory markdown under `baseDir` (one file per `scope`+`key`).\n * Safe for arbitrary `key` strings (hashed into the filename).\n */\nexport class FileBackedWorkingMemory implements WorkingMemory {\n private readonly filePath: string;\n\n constructor(\n readonly scope: WorkingMemoryScope,\n readonly key: string,\n /** Directory to store `.working.md` files (created on first write). */\n baseDir: string,\n ) {\n this.filePath = backingFilePath(baseDir, scope, key);\n }\n\n async read(): Promise<string> {\n try {\n return await readFile(this.filePath, 'utf8');\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return '';\n throw e;\n }\n }\n\n async write(markdown: string): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n await writeFile(this.filePath, markdown, 'utf8');\n }\n\n async append(markdown: string): Promise<void> {\n let cur = await this.read();\n if (cur.length > 0 && !cur.endsWith('\\n')) cur += '\\n';\n cur += markdown;\n await this.write(cur);\n }\n\n async clear(): Promise<void> {\n try {\n await unlink(this.filePath);\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return;\n throw e;\n }\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/file-backed-working-memory.ts"],"names":["createHash","join","unlink","readFile","mkdir","dirname","writeFile"],"mappings":";;;;;;;AAaO,SAAS,kCAAA,CACd,OAAA,EACA,KAAA,EACA,GAAA,EACQ;AACR,EAAA,MAAM,IAAIA,iBAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,EAAE,MAAA,CAAO,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,EAAE,CAAA;AACnF,EAAA,OAAOC,UAAK,OAAA,EAAS,CAAA,EAAG,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,WAAA,CAAa,CAAA;AACjD;AAGA,eAAsB,kCAAA,CACpB,OAAA,EAC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AAA,EAAU,QAAA,EAAU,MAAM,CAAA;AAAA,EACjD;AAAA,EAEA,MAAM,OAAO,QAAA,EAAiC;AAC5C,IAAA,IAAI,GAAA,GAAM,MAAM,IAAA,CAAK,IAAA,EAAK;AAC1B,IAAA,IAAI,GAAA,CAAI,SAAS,CAAA,IAAK,CAAC,IAAI,QAAA,CAAS,IAAI,GAAG,GAAA,IAAO,IAAA;AAClD,IAAA,GAAA,IAAO,QAAA;AACP,IAAA,MAAM,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACtB;AAAA,EAEA,MAAM,KAAA,GAAuB;AAC3B,IAAA,IAAI;AACF,MAAA,MAAMJ,eAAA,CAAO,KAAK,QAAQ,CAAA;AAAA,IAC5B,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,GAAA,GAAM,CAAA;AACZ,MAAA,IAAI,GAAA,CAAI,SAAS,QAAA,EAAU;AAC3B,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AACF","file":"node.cjs","sourcesContent":["/**\n * Durable working-memory tier (RFC 0011) — Node filesystem backing.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { WorkingMemory, WorkingMemoryScope } from './working-memory.js';\n\n/**\n * Resolves the backing file path for a `(scope, key)` pair — matches\n * {@link FileBackedWorkingMemory} on disk (for deletion / inspection tooling).\n */\nexport function resolveFileBackedWorkingMemoryPath(\n baseDir: string,\n scope: WorkingMemoryScope,\n key: string,\n): string {\n const h = createHash('sha256').update(`${scope}\\0${key}`).digest('hex').slice(0, 32);\n return join(baseDir, `${scope}-${h}.working.md`);\n}\n\n/** Best-effort `unlink` for each key’s backing file under `baseDir` (RFC 0016). */\nexport async function deleteFileBackedWorkingMemoryFiles(\n baseDir: string,\n scope: WorkingMemoryScope,\n keys: readonly string[],\n): Promise<void> {\n await Promise.all(\n keys.map(async (key) => {\n const p = resolveFileBackedWorkingMemoryPath(baseDir, scope, key);\n try {\n await unlink(p);\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return;\n throw e;\n }\n }),\n );\n}\n\n/**\n * Persists working-memory markdown under `baseDir` (one file per `scope`+`key`).\n * Safe for arbitrary `key` strings (hashed into the filename).\n */\nexport class FileBackedWorkingMemory implements WorkingMemory {\n private readonly filePath: string;\n\n constructor(\n readonly scope: WorkingMemoryScope,\n readonly key: string,\n /** Directory to store `.working.md` files (created on first write). */\n baseDir: string,\n ) {\n this.filePath = resolveFileBackedWorkingMemoryPath(baseDir, scope, key);\n }\n\n async read(): Promise<string> {\n try {\n return await readFile(this.filePath, 'utf8');\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return '';\n throw e;\n }\n }\n\n async write(markdown: string): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n await writeFile(this.filePath, markdown, 'utf8');\n }\n\n async append(markdown: string): Promise<void> {\n let cur = await this.read();\n if (cur.length > 0 && !cur.endsWith('\\n')) cur += '\\n';\n cur += markdown;\n await this.write(cur);\n }\n\n async clear(): Promise<void> {\n try {\n await unlink(this.filePath);\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return;\n throw e;\n }\n }\n}\n"]} |
+8
-1
@@ -9,2 +9,9 @@ import { W as WorkingMemory, a as WorkingMemoryScope } from './working-memory-CiY2b5_U.cjs'; | ||
| /** | ||
| * Resolves the backing file path for a `(scope, key)` pair — matches | ||
| * {@link FileBackedWorkingMemory} on disk (for deletion / inspection tooling). | ||
| */ | ||
| declare function resolveFileBackedWorkingMemoryPath(baseDir: string, scope: WorkingMemoryScope, key: string): string; | ||
| /** Best-effort `unlink` for each key’s backing file under `baseDir` (RFC 0016). */ | ||
| declare function deleteFileBackedWorkingMemoryFiles(baseDir: string, scope: WorkingMemoryScope, keys: readonly string[]): Promise<void>; | ||
| /** | ||
| * Persists working-memory markdown under `baseDir` (one file per `scope`+`key`). | ||
@@ -26,2 +33,2 @@ * Safe for arbitrary `key` strings (hashed into the filename). | ||
| export { FileBackedWorkingMemory }; | ||
| export { FileBackedWorkingMemory, deleteFileBackedWorkingMemoryFiles, resolveFileBackedWorkingMemoryPath }; |
+8
-1
@@ -9,2 +9,9 @@ import { W as WorkingMemory, a as WorkingMemoryScope } from './working-memory-CiY2b5_U.js'; | ||
| /** | ||
| * Resolves the backing file path for a `(scope, key)` pair — matches | ||
| * {@link FileBackedWorkingMemory} on disk (for deletion / inspection tooling). | ||
| */ | ||
| declare function resolveFileBackedWorkingMemoryPath(baseDir: string, scope: WorkingMemoryScope, key: string): string; | ||
| /** Best-effort `unlink` for each key’s backing file under `baseDir` (RFC 0016). */ | ||
| declare function deleteFileBackedWorkingMemoryFiles(baseDir: string, scope: WorkingMemoryScope, keys: readonly string[]): Promise<void>; | ||
| /** | ||
| * Persists working-memory markdown under `baseDir` (one file per `scope`+`key`). | ||
@@ -26,2 +33,2 @@ * Safe for arbitrary `key` strings (hashed into the filename). | ||
| export { FileBackedWorkingMemory }; | ||
| export { FileBackedWorkingMemory, deleteFileBackedWorkingMemoryFiles, resolveFileBackedWorkingMemoryPath }; |
+19
-5
| import { createHash } from 'crypto'; | ||
| import { readFile, mkdir, writeFile, unlink } from 'fs/promises'; | ||
| import { dirname, join } from 'path'; | ||
| import { unlink, readFile, mkdir, writeFile } from 'fs/promises'; | ||
| import { join, dirname } from 'path'; | ||
| // src/file-backed-working-memory.ts | ||
| function backingFilePath(baseDir, scope, key) { | ||
| function resolveFileBackedWorkingMemoryPath(baseDir, scope, key) { | ||
| const h = createHash("sha256").update(`${scope}\0${key}`).digest("hex").slice(0, 32); | ||
| return join(baseDir, `${scope}-${h}.working.md`); | ||
| } | ||
| async function deleteFileBackedWorkingMemoryFiles(baseDir, scope, keys) { | ||
| await Promise.all( | ||
| keys.map(async (key) => { | ||
| const p = resolveFileBackedWorkingMemoryPath(baseDir, scope, key); | ||
| try { | ||
| await unlink(p); | ||
| } catch (e) { | ||
| const err = e; | ||
| if (err.code === "ENOENT") return; | ||
| throw e; | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| var FileBackedWorkingMemory = class { | ||
@@ -14,3 +28,3 @@ constructor(scope, key, baseDir) { | ||
| this.key = key; | ||
| this.filePath = backingFilePath(baseDir, scope, key); | ||
| this.filePath = resolveFileBackedWorkingMemoryPath(baseDir, scope, key); | ||
| } | ||
@@ -50,4 +64,4 @@ scope; | ||
| export { FileBackedWorkingMemory }; | ||
| export { FileBackedWorkingMemory, deleteFileBackedWorkingMemoryFiles, resolveFileBackedWorkingMemoryPath }; | ||
| //# sourceMappingURL=node.js.map | ||
| //# sourceMappingURL=node.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/file-backed-working-memory.ts"],"names":[],"mappings":";;;;;AASA,SAAS,eAAA,CAAgB,OAAA,EAAiB,KAAA,EAA2B,GAAA,EAAqB;AACxF,EAAA,MAAM,IAAI,UAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,EAAE,MAAA,CAAO,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,EAAE,CAAA;AACnF,EAAA,OAAO,KAAK,OAAA,EAAS,CAAA,EAAG,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,WAAA,CAAa,CAAA;AACjD;AAMO,IAAM,0BAAN,MAAuD;AAAA,EAG5D,WAAA,CACW,KAAA,EACA,GAAA,EAET,OAAA,EACA;AAJS,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACA,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAIT,IAAA,IAAA,CAAK,QAAA,GAAW,eAAA,CAAgB,OAAA,EAAS,KAAA,EAAO,GAAG,CAAA;AAAA,EACrD;AAAA,EANW,KAAA;AAAA,EACA,GAAA;AAAA,EAJM,QAAA;AAAA,EAWjB,MAAM,IAAA,GAAwB;AAC5B,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,QAAA,CAAS,IAAA,CAAK,QAAA,EAAU,MAAM,CAAA;AAAA,IAC7C,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,GAAA,GAAM,CAAA;AACZ,MAAA,IAAI,GAAA,CAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAA;AAClC,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAM,MAAM,QAAA,EAAiC;AAC3C,IAAA,MAAM,KAAA,CAAM,QAAQ,IAAA,CAAK,QAAQ,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AACvD,IAAA,MAAM,SAAA,CAAU,IAAA,CAAK,QAAA,EAAU,QAAA,EAAU,MAAM,CAAA;AAAA,EACjD;AAAA,EAEA,MAAM,OAAO,QAAA,EAAiC;AAC5C,IAAA,IAAI,GAAA,GAAM,MAAM,IAAA,CAAK,IAAA,EAAK;AAC1B,IAAA,IAAI,GAAA,CAAI,SAAS,CAAA,IAAK,CAAC,IAAI,QAAA,CAAS,IAAI,GAAG,GAAA,IAAO,IAAA;AAClD,IAAA,GAAA,IAAO,QAAA;AACP,IAAA,MAAM,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACtB;AAAA,EAEA,MAAM,KAAA,GAAuB;AAC3B,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,KAAK,QAAQ,CAAA;AAAA,IAC5B,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,GAAA,GAAM,CAAA;AACZ,MAAA,IAAI,GAAA,CAAI,SAAS,QAAA,EAAU;AAC3B,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AACF","file":"node.js","sourcesContent":["/**\n * Durable working-memory tier (RFC 0011) — Node filesystem backing.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { WorkingMemory, WorkingMemoryScope } from './working-memory.js';\n\nfunction backingFilePath(baseDir: string, scope: WorkingMemoryScope, key: string): string {\n const h = createHash('sha256').update(`${scope}\\0${key}`).digest('hex').slice(0, 32);\n return join(baseDir, `${scope}-${h}.working.md`);\n}\n\n/**\n * Persists working-memory markdown under `baseDir` (one file per `scope`+`key`).\n * Safe for arbitrary `key` strings (hashed into the filename).\n */\nexport class FileBackedWorkingMemory implements WorkingMemory {\n private readonly filePath: string;\n\n constructor(\n readonly scope: WorkingMemoryScope,\n readonly key: string,\n /** Directory to store `.working.md` files (created on first write). */\n baseDir: string,\n ) {\n this.filePath = backingFilePath(baseDir, scope, key);\n }\n\n async read(): Promise<string> {\n try {\n return await readFile(this.filePath, 'utf8');\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return '';\n throw e;\n }\n }\n\n async write(markdown: string): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n await writeFile(this.filePath, markdown, 'utf8');\n }\n\n async append(markdown: string): Promise<void> {\n let cur = await this.read();\n if (cur.length > 0 && !cur.endsWith('\\n')) cur += '\\n';\n cur += markdown;\n await this.write(cur);\n }\n\n async clear(): Promise<void> {\n try {\n await unlink(this.filePath);\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return;\n throw e;\n }\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/file-backed-working-memory.ts"],"names":[],"mappings":";;;;;AAaO,SAAS,kCAAA,CACd,OAAA,EACA,KAAA,EACA,GAAA,EACQ;AACR,EAAA,MAAM,IAAI,UAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,EAAE,MAAA,CAAO,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,EAAE,CAAA;AACnF,EAAA,OAAO,KAAK,OAAA,EAAS,CAAA,EAAG,KAAK,CAAA,CAAA,EAAI,CAAC,CAAA,WAAA,CAAa,CAAA;AACjD;AAGA,eAAsB,kCAAA,CACpB,OA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,EAAU,QAAA,EAAU,MAAM,CAAA;AAAA,EACjD;AAAA,EAEA,MAAM,OAAO,QAAA,EAAiC;AAC5C,IAAA,IAAI,GAAA,GAAM,MAAM,IAAA,CAAK,IAAA,EAAK;AAC1B,IAAA,IAAI,GAAA,CAAI,SAAS,CAAA,IAAK,CAAC,IAAI,QAAA,CAAS,IAAI,GAAG,GAAA,IAAO,IAAA;AAClD,IAAA,GAAA,IAAO,QAAA;AACP,IAAA,MAAM,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACtB;AAAA,EAEA,MAAM,KAAA,GAAuB;AAC3B,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,KAAK,QAAQ,CAAA;AAAA,IAC5B,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,GAAA,GAAM,CAAA;AACZ,MAAA,IAAI,GAAA,CAAI,SAAS,QAAA,EAAU;AAC3B,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AACF","file":"node.js","sourcesContent":["/**\n * Durable working-memory tier (RFC 0011) — Node filesystem backing.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { WorkingMemory, WorkingMemoryScope } from './working-memory.js';\n\n/**\n * Resolves the backing file path for a `(scope, key)` pair — matches\n * {@link FileBackedWorkingMemory} on disk (for deletion / inspection tooling).\n */\nexport function resolveFileBackedWorkingMemoryPath(\n baseDir: string,\n scope: WorkingMemoryScope,\n key: string,\n): string {\n const h = createHash('sha256').update(`${scope}\\0${key}`).digest('hex').slice(0, 32);\n return join(baseDir, `${scope}-${h}.working.md`);\n}\n\n/** Best-effort `unlink` for each key’s backing file under `baseDir` (RFC 0016). */\nexport async function deleteFileBackedWorkingMemoryFiles(\n baseDir: string,\n scope: WorkingMemoryScope,\n keys: readonly string[],\n): Promise<void> {\n await Promise.all(\n keys.map(async (key) => {\n const p = resolveFileBackedWorkingMemoryPath(baseDir, scope, key);\n try {\n await unlink(p);\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return;\n throw e;\n }\n }),\n );\n}\n\n/**\n * Persists working-memory markdown under `baseDir` (one file per `scope`+`key`).\n * Safe for arbitrary `key` strings (hashed into the filename).\n */\nexport class FileBackedWorkingMemory implements WorkingMemory {\n private readonly filePath: string;\n\n constructor(\n readonly scope: WorkingMemoryScope,\n readonly key: string,\n /** Directory to store `.working.md` files (created on first write). */\n baseDir: string,\n ) {\n this.filePath = resolveFileBackedWorkingMemoryPath(baseDir, scope, key);\n }\n\n async read(): Promise<string> {\n try {\n return await readFile(this.filePath, 'utf8');\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return '';\n throw e;\n }\n }\n\n async write(markdown: string): Promise<void> {\n await mkdir(dirname(this.filePath), { recursive: true });\n await writeFile(this.filePath, markdown, 'utf8');\n }\n\n async append(markdown: string): Promise<void> {\n let cur = await this.read();\n if (cur.length > 0 && !cur.endsWith('\\n')) cur += '\\n';\n cur += markdown;\n await this.write(cur);\n }\n\n async clear(): Promise<void> {\n try {\n await unlink(this.filePath);\n } catch (e) {\n const err = e as NodeJS.ErrnoException;\n if (err.code === 'ENOENT') return;\n throw e;\n }\n }\n}\n"]} |
+1
-1
| { | ||
| "name": "@ziro-agent/memory", | ||
| "version": "0.5.0", | ||
| "version": "0.5.1", | ||
| "description": "Vector store interfaces, in-memory & pgvector adapters, chunking and embedding helpers for ZiroAgent SDK.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10724612
0.06%74495
0.06%