Skip to main content

graphToJson()

graphToJson(graph): Record<string, unknown>

Defined in: loader.ts:99

Serialize an ExecutionGraph to a plain JSON-safe object.

The inverse of loadGraph. nodes is written as a plain object keyed by node ID, which is the most readable format for trace files on disk.

Parameters

ParameterTypeDescription
graphExecutionGraphThe execution graph to serialize.

Returns

Record<string, unknown>

A plain object safe to pass to JSON.stringify.

Example

import { writeFileSync } from 'fs';
import { graphToJson } from 'agentflow-core';

writeFileSync('trace.json', JSON.stringify(graphToJson(graph), null, 2));