@escouade/graph-trace-file-exporter
v0.1.2
Published
Node.js file exporter for graph-trace — writes a TraceDocument as JSON, merging runs into one file.
Maintainers
Readme
@escouade/graph-trace-file-exporter
Node.js file exporter for @escouade/graph-trace.
Writes a TraceDocument as JSON to a resolved path, merging with any existing file so conversation runs accumulate in one place.
Filesystem coupling is assumed here (
node:fs/promises/node:path) — the core stays runtime-agnostic. For another runtime (browser, OPFS, HTTP), implement the coreTraceExporter<TraceDocument>port in a sibling package.
Install
npm install @escouade/graph-trace-file-exporter @escouade/graph-traceUsage
import { TraceCollector } from '@escouade/graph-trace';
import { FileExporter } from '@escouade/graph-trace-file-exporter';
const collector = new TraceCollector({
exporters: [
new FileExporter({
resolvePath: (doc) => `./traces/${doc.meta.traceId}.trace.json`,
}),
],
});Each run is merged into the existing file via mergeTraceDocuments. If the file is absent or corrupt, the run is written as-is. Files are written with mode 0o600.
API
FileExporterOptions
| Field | Type | Required | Description |
| ------------- | ---------------------------------- | -------- | ------------------------------------------------- |
| resolvePath | (trace: TraceDocument) => string | yes | Resolves the output path from the projected trace |
FileExporter
Implements TraceExporter<TraceDocument> from @escouade/graph-trace. Passed to TraceCollector as an exporter.
Resources
License
MIT
