Class: JsonImporter
Defined in: packages/agentos/src/cognition/memory/io/JsonImporter.ts:264
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:268
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:297
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: inside the trace's scope and scope id, a row whosecontentis the record's, or whose metadata names the SHA-256 of that text asimport_hashorcontent_hash, makes the record a duplicate, and it is skipped; a row of another scope id is not a duplicate. - For
knowledge_nodes: SHA-256 oflabel+type. A memory-graph node (typememory_graph) is its trace's node instead: it is written under its trace's id for a trace the import wrote or matched under that id, is the duplicate of the node the brain holds under that id, or is skipped (seememoryGraphNodeImport). - For
knowledge_edges: SHA-256 ofsource_id+target_id+type. An edge that names a memory-graph node the import skipped is skipped.
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:319
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.