Parent issue
#756
Depends on
#757
Context
The @anthropic-ai/claude-agent-sdk query() function accepts options.input_messages as MessageParam[] (same shape as the Anthropic SDK). This issue implements the conversion layer and validates edge cases before the core handler is built in the next issue.
Files
src/api/providers/claude-code-messages.ts (new)
src/api/providers/__tests__/claude-code-messages.spec.ts (new)
Work
convertToClaudeCodeMessages(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): { system: string, messages: MessageParam[] } — pass-through for text content, strip or warn on unsupported block types
- Handle multi-turn conversations (alternating user/assistant)
- Handle image content blocks (pass base64 through; document that the CLI must support vision)
- Handle tool use and tool result blocks (pass through as-is — Agent SDK accepts native Anthropic tool format)
Tests
- Text-only single-turn round-trip
- Multi-turn conversation preserves message order
- Image content blocks are passed through
- Tool use / tool result blocks are passed through
- Empty messages array returns only system prompt
Acceptance criteria
convertToClaudeCodeMessages is exported and fully typed
- All tests pass
- No runtime dependency on
@anthropic-ai/claude-agent-sdk in this file (pure transformation)
Parent issue
#756
Depends on
#757
Context
The
@anthropic-ai/claude-agent-sdkquery()function acceptsoptions.input_messagesasMessageParam[](same shape as the Anthropic SDK). This issue implements the conversion layer and validates edge cases before the core handler is built in the next issue.Files
src/api/providers/claude-code-messages.ts(new)src/api/providers/__tests__/claude-code-messages.spec.ts(new)Work
convertToClaudeCodeMessages(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): { system: string, messages: MessageParam[] }— pass-through for text content, strip or warn on unsupported block typesTests
Acceptance criteria
convertToClaudeCodeMessagesis exported and fully typed@anthropic-ai/claude-agent-sdkin this file (pure transformation)