Class: ObsidianExporter
Defined in: packages/agentos/src/cognition/memory/io/ObsidianExporter.ts:69
Exports memory traces as an Obsidian-compatible Markdown vault.
Usage:
const exporter = new ObsidianExporter(brain);
await exporter.export('/path/to/obsidian-vault');
Extends
Constructors
Constructor
new ObsidianExporter(
brain):ObsidianExporter
Defined in: packages/agentos/src/cognition/memory/io/MarkdownExporter.ts:126
Parameters
brain
The Brain instance to read from.
Returns
ObsidianExporter
Inherited from
Properties
brain
protectedreadonlybrain:Brain
Defined in: packages/agentos/src/cognition/memory/io/MarkdownExporter.ts:126
The Brain instance to read from.
Inherited from
Methods
buildFileContent()
protectedbuildFileContent(trace):string
Defined in: packages/agentos/src/cognition/memory/io/ObsidianExporter.ts:115
Build Obsidian-flavoured Markdown for a trace.
Additions over the base implementation:
- Tags are rendered as
#tagNameinline hashtags in the body. - Related knowledge nodes (found via
knowledge_edges) are rendered as[[Node Label]]wikilinks appended at the bottom of the note.
Parameters
trace
TraceRow
Parsed trace row.
Returns
string
Full Markdown file content with front-matter.
Overrides
MarkdownExporter.buildFileContent
export()
export(
outputDir,options?):Promise<ExportResult>
Defined in: packages/agentos/src/cognition/memory/io/ObsidianExporter.ts:94
Export all memory traces as Obsidian-flavoured .md files.
Pre-fetches all knowledge-edge relationships into an in-memory cache,
then delegates to the parent export() method. Directory creation,
file writing and the checks on each trace's path are handled there; only
buildFileContent is overridden.
Parameters
outputDir
string
Root directory to write the Obsidian vault into.
options?
Optional export configuration.
Returns
Promise<ExportResult>
The traces left out, with the reason for each.
Overrides
frontMatterOf()
protectedfrontMatterOf(trace,tags):Record<string,unknown>
Defined in: packages/agentos/src/cognition/memory/io/MarkdownExporter.ts:314
The front-matter fields of a trace's file, which MarkdownImporter reads
back: its id, type, scope, strength, tags and creation time, and its scope
id as scopeId when the trace is filed under one. A trace filed under
'' writes no scopeId, and its import files it under ''. A trace of a
Brain that holds the encoded scope-id form writes scopeIdForm: encoded,
so an import takes its scope id as it is written. A trace a second user
filed on another user's session writes that user's id as turnUserId, so
its import files it as that user's trace, which a delete of the user's
traces finds.
Parameters
trace
TraceRow
The trace row.
tags
string[]
The trace's tags, parsed.
Returns
Record<string, unknown>
Inherited from
MarkdownExporter.frontMatterOf
traceRelativePath()
protectedtraceRelativePath(trace):string
Defined in: packages/agentos/src/cognition/memory/io/MarkdownExporter.ts:341
Determine the relative file path for a trace within the output directory.
Default: {scope}/{type}/{id}.md. Each of the three must be a safe file
or folder name (see pathNameProblem), or the trace is refused. Whatever
a subclass returns, the export writes the file only when its resolved
path lies inside the output directory.
Parameters
trace
TraceRow
The trace row.
Returns
string
Relative path string (no leading slash).
Throws
When the trace's scope, type or id is not a safe name; the export reports such a trace in its result instead of writing it.