Raw stdout (possibly many newline-delimited JSON objects).
Optionallogger: StreamLogger
Optional structural logger; receives an "unknown event"
warn for any line whose parsed type is unrecognized — at most ONCE per
distinct type per call, so a repeated novel type cannot flood the log.
Never throws on a malformed line — non-JSON lines are skipped.
{ text, messages, sessionId, result } — text is the joined
assistant-visible text, messages is every successfully-parsed line,
sessionId is the top-level session_id Claude Code stamps on its
system/init line (and may restamp on later events; last-wins, left
undefined when no line carries one), and result is the terminal
ClaudeResultEnvelope read off the type: "result" line (an empty
object when none was emitted). The adapter threads sessionId to continue a
session across turns and inspects result to tell a real failure — including
a stale --resume — from a healthy run (see the adapter's call).
Parse Claude Code stream-json stdout into the concatenated assistant text and the list of parsed messages.