Class: JsonImporter
Defined in: packages/agentos/src/cognition/memory/io/JsonImporter.ts:159
Imports a JsonExporter-compatible JSON file into a Brain.
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/cognition/memory/io/JsonImporter.ts:163
Parameters
brain
The target Brain to import into.
Returns
JsonImporter
Methods
import()
import(
sourcePath,options?):Promise<ImportResult>
Defined in: packages/agentos/src/cognition/memory/io/JsonImporter.ts:185
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.
options?
Pick<ImportOptions, "dedup">
Returns
Promise<ImportResult>
ImportResult with counts of imported, skipped, and errored items.
importFromString()
importFromString(
jsonContent,options?):Promise<ImportResult>
Defined in: packages/agentos/src/cognition/memory/io/JsonImporter.ts:207
Import a JSON string directly into the target brain without filesystem access.
Parameters
jsonContent
string
The JSON string to parse and import.
options?
Pick<ImportOptions, "dedup">
Returns
Promise<ImportResult>
ImportResult with counts of imported, skipped, and errored items.