Raxol.Agent.Harness.StreamJson (Raxol Agent v2.6.0)

Copy Markdown View Source

Parser for the --output-format stream-json NDJSON protocol shared by Claude Code and Cursor's cursor-agent.

Each stdout line is a standalone JSON object tagged with a type:

  • system (init/config) -- ignored.
  • assistant -- a model message; its content blocks become :text, :reasoning (thinking), or :tool_call events.
  • user -- tool results echoed back; ignored (the MCP server owns execution).
  • result -- the terminal event; success yields {:done, ...} with the final text + usage, an error subtype yields {:error, ...}.

Non-JSON lines (banners, warnings) parse to [] so stray output never breaks a run. Returns Raxol.Agent.NativeHarness event tuples.

Summary

Functions

Parse one NDJSON line into normalized harness events.

Functions

parse_line(line)

@spec parse_line(String.t()) :: [Raxol.Agent.NativeHarness.event()]

Parse one NDJSON line into normalized harness events.