feat(chat-runtime): Claude harness adapter with recorded wire fixtures

Merged
SA
3mo ago
+2497-0

Stacked on #6167. ClaudeTranslator (pure SDKMessage→AdapterEvent core) + ClaudeAdapter wiring @anthropic-ai/claude-agent-sdk 0.3.201 (pinned exact, injected query — tests never spawn a process). Six real recorded scenarios as fixtures (text, bash, edit approved/declined, abort mid-tool, subagent); 69 tests + a live smoke (passed 14.3s, kept skipped in CI). Includes 11 wire-truth findings vs the mapping doc — notably allowedTools silently bypassing canUseTool, updatedInput required-at-runtime on accept, abort as thrown iterator error, and the Agent/Task tool naming — doc amendments to chat-harness-adapters.md follow separately.

https://claude.ai/code/session_01XRFCEPsfmJHu2SenDKYJ2h


Summary by cubic

Adds a Claude harness adapter and translator for chat-runtime, wired to @anthropic-ai/claude-agent-sdk@0.3.201 and validated with recorded wire fixtures. Fixes cancel/interrupt behavior, delta targeting, and tool mapping to match the SDK stream.

  • New Features

    • Adapter streams SDK messages into AdapterEvents via ClaudeTranslator using an injected query (no external process in tests/CI).
    • Tool-use rendering via mapToolUse with kind, titles, locations, and concise outcome text.
    • Six recorded JSONL fixtures and a recording script; 69 tests + a live smoke test (skipped in CI).
  • Bug Fixes

    • Cancel/interrupt now aborts the session and settles the turn cleanly.
    • Corrected delta targeting and tool mapping (e.g., Write→edit, BashOutput→execute) to align with real SDK behavior.

Summary by CodeRabbit

  • New Features

    • Added Claude integration for streaming responses, tool usage, approvals, cancellations, interruptions, edits, Bash commands, and subagent activity.
    • Added translated events with tool details, file locations, usage, costs, errors, and turn lifecycle updates.
    • Added support for resuming Claude sessions and configurable session behavior.
  • Tests

    • Added comprehensive coverage for Claude conversations, tool mapping, streaming, cancellation, approvals, interruptions, and subagent workflows.
    • Added representative scenarios for automated integration testing.