/** * exportCorpus / importCorpus — a corpus as a build artifact. * * Pattern: projection (store → plain-JSON bundle) and its inverse. * Role: rag/ layer — the build-time half of the story whose runtime half * is `staticVectorStore` (`agentfootprint/memory`). Index where the * credentials and the durable disk live; ship the bundle with the * deploy; serve it read-only where the process runs. * Emits: N/A — build-step helpers, not run-time stages. * * ── The deployment shape this exists for ──────────────────────────────────── * An immutable or serverless runtime loses its disk between invocations and * often holds no embedding-API credentials — while the build machine has * both. So the corpus becomes an artifact of the BUILD: * * // build step (cron, CI, deploy hook) — credentials live here * const report = await indexFolder('./docs', { to: store, embedder }); * writeFileSync('corpus.json', JSON.stringify(await exportCorpus(store))); * * // runtime — no disk, no embedding writes, no drift * const store = staticVectorStore(JSON.parse(readFileSync('corpus.json', 'utf8')), embedder); * const docs = defineRAG({ id: 'docs', store, embedder }); * * The bundle records the embedder id and dimensions it was built with, so the * runtime can REFUSE a mismatched embedder at load instead of discovering it * as an empty retrieval — the same fingerprint discipline the durable store * enforces per write. * * `importCorpus` is the inverse for a WRITABLE store: load a bundle into * InMemoryStore at boot, or into sqliteVectorStore to migrate a corpus * between machines without re-embedding (and re-billing) anything. */ import type { MemoryStore } from '../memory/store/index.js'; import type { MemoryIdentity } from '../memory/identity/index.js'; import { type CorpusBundle } from '../memory/store/staticVectorStore.js'; /** * Export every entry of a corpus namespace as a plain-JSON bundle. * * @param store the store the corpus was indexed into. Any `MemoryStore` * that can `list` — the reference stores and the durable one * all can. * @param identity the namespace to export. Defaults to the same * `{ conversationId: '_global' }` that `indexCorpus`, * `indexFolder`, `indexDocuments` and `defineRAG` default to, * so the plain path needs no argument anywhere. * * @throws when the namespace is empty (almost always an identity mismatch, * named as such), when an entry carries no vector or no passage (a * bundle never ships an unservable entry), or when the namespace * mixes embedding spaces (two spaces in one bundle could never be * served by one embedder). */ export declare function exportCorpus(store: MemoryStore, identity?: MemoryIdentity): Promise; /** * Load a bundle into a WRITABLE vector-capable store — the inverse of * `exportCorpus`. Use it to seed an `InMemoryStore` at boot from a shipped * bundle, or to migrate a corpus between machines without re-embedding. * * Entries are written in the same formatter-ready shape `staticVectorStore` * serves, so the two paths render identically. * * @returns the number of entries written. */ export declare function importCorpus(store: MemoryStore, bundle: CorpusBundle, identity?: MemoryIdentity): Promise;