Class: JsonImporter
Defined in: packages/agentos/src/memory/io/JsonImporter.ts:112
Imports a JsonExporter-compatible JSON file into a SqliteBrain.
Usage:
const importer = new JsonImporter(brain);
const result = await importer.import('/path/to/export.json');
console.log(result.imported, result.skipped, result.errors);
Constructors
Constructor
new JsonImporter(
brain):JsonImporter
Defined in: packages/agentos/src/memory/io/JsonImporter.ts:116
Parameters
brain
The target SqliteBrain to import into.
Returns
JsonImporter
Methods
import()
import(
sourcePath):Promise<ImportResult>
Defined in: packages/agentos/src/memory/io/JsonImporter.ts:138
Read and merge a JSON export file into the target brain.
Validation:
- The file must be valid JSON.
- The top-level object must contain a
tracesarray.
Deduplication:
- For
memory_traces: SHA-256 ofcontentis used as the dedup key. Existing rows with the same hash are skipped. - For
knowledge_nodes: SHA-256 oflabel+type. - For
knowledge_edges: SHA-256 ofsource_id+target_id+type.
Parameters
sourcePath
string
Absolute path to the JSON file to import.
Returns
Promise<ImportResult>
ImportResult with counts of imported, skipped, and errored items.