Expand description
Claude Code adapter — the MVP’s fully implemented one.
Reads ~/.claude/projects/<url-encoded-cwd>/*.jsonl (READ-ONLY). Sub-agent
transcripts live in <project>/<parent-session-uuid>/subagents/agent-<id>.jsonl
and are attributed back to the parent via Session::parent_session.
Schema notes, VERIFIED against real local files (Claude Code v2.1.162, 2026-06-13):
- A single API request is written as 2–10 assistant lines (one per content
block) that all repeat
message.usageand share onerequestId. Observed real ratios: 83 lines -> 26 requests; 642 -> 262. Accounting MUST dedup (CLAUDE.md §8.1) — that happens inanalysis::dedup, not here; the adapter preserves the raw lines as events. message.usagekeys:input_tokens,output_tokens,cache_creation_input_tokens,cache_read_input_tokens, plus acache_creation: { ephemeral_5m_input_tokens, ephemeral_1h_input_tokens }breakdown (the TTLs are priced differently — seepricing).- API-error lines have
model: "<synthetic>"/isApiErrorMessage: truewith zeroed usage that never hit the API; their usage is dropped. - Sub-agent spawns are
tool_useblocks namedTask(legacy) orAgent(current), withinput.description/input.subagent_type. output_tokensALREADY includes extended-thinking tokens (VERIFIED on real v2.1.178 data: thinking-only requests report output far larger than the visible text alone) — do NOT add an estimate on top, orknown_totaldouble-counts. Thinking blocks are frequently encrypted ("thinking": ""+signature; ~85% of thinking requests on the sampled machine), so the thinking SHARE of output is usually unmeasurable; that is surfaced honestly (encrypted-thinking count), never guessed.- Bookkeeping line types carrying no spend (VERIFIED on real files):
summary,mode,permission-mode,last-prompt,file-history-snapshot,ai-title,custom-title,queue-operation,agent-name— ignored without counting as “skipped” so the skip stat means unexpected. attachmentlines (deferred-tool/skill listings, MCP instruction blocks, IDE/file context, reminders) carry no spend but ARE kept asEventKind::Attachmentevents — their category/size feedanalysis::context(verifiedattachment.type∈ {deferred_tools_delta, skill_listing, mcp_instructions_delta, task_reminder, file, …}).- TODO(verify): compaction markers (
subtype: "compact_boundary"system lines,isCompactSummaryuser lines) were not present in sampled files; the mapping below is best-effort from documentation.
Structs§
- Claude
Code - Claude Code (
~/.claude).