exportTrajectoryJson function
Serializes snapshot to a pretty-printed JSON string with full fidelity:
every record keeps its kind, turn/step, timestamps, full texts, raw tool
arguments, results, error fields, request summaries, and usage.
Implementation
String exportTrajectoryJson(TrajectorySnapshot snapshot) {
return const JsonEncoder.withIndent(' ').convert({
'revision': snapshot.revision,
'records': [for (final record in snapshot.records) _recordJson(record)],
'requests': [
for (final request in snapshot.requests) _requestJson(request),
],
// Issue #385 F1/F2/F5: the content-addressed blob table (system
// prompts, tool manifests, opt-in wire dumps) exports when non-empty
// so the export round-trips the full outbound reality.
if (!snapshot.blobs.isEmpty) 'blobs': snapshot.blobs.toJson(),
});
}