Converts the inner messages of a stream-json transcript into AI SDK model
messages, the format @langwatch/scenario works with.
Claude Code writes Anthropic-format messages: an assistant turn is an array
of thinking, text and tool_use blocks, and each tool result comes back
as a user message holding tool_result blocks. Each assistant turn
becomes one text part (the text blocks joined, an empty string when the turn
only called tools) followed by one tool-call part per tool_use block.
Each tool_result block becomes a tool-result part of a tool message,
with the tool name looked up from the call it answers. Thinking blocks are
dropped. A block of any other type leaves a line naming it.
Converts the inner messages of a stream-json transcript into AI SDK model messages, the format
@langwatch/scenarioworks with.Claude Code writes Anthropic-format messages: an assistant turn is an array of
thinking,textandtool_useblocks, and each tool result comes back as ausermessage holdingtool_resultblocks. Each assistant turn becomes one text part (the text blocks joined, an empty string when the turn only called tools) followed by onetool-callpart pertool_useblock. Eachtool_resultblock becomes atool-resultpart of atoolmessage, with the tool name looked up from the call it answers. Thinking blocks are dropped. A block of any other type leaves a line naming it.