feat: add AgentAdapter abstraction with Codex CLI support#95
Open
feat: add AgentAdapter abstraction with Codex CLI support#95
Conversation
Replace hardcoded Claude Code transcript parsing with an extensible AgentAdapter trait and registry. Each agent gets its own adapter for event mapping, file change extraction, and transcript record parsing. - AgentAdapter trait with ClaudeCode, Codex, and Default adapters - Codex transcript parsing (response_item/message, custom_tool_call, event_msg, apply_patch file changes from transcript chunks) - CLI: protocol v2, --agent flag, Codex hook response format - tracevault init --codex installs .codex/hooks.json - AgentBadge component with per-agent icon on session list and detail - Remove old hardcoded extract_file_change/is_file_modifying_tool - 34 adapter tests, UTF-8 safe truncation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow multiple agents via --agent flag (e.g. --agent codex --agent gemini) instead of single --codex bool. Extensible for future agents. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codex sends model in turn_context chunks which may arrive in a separate batch from token_count chunks. Previously model was only saved when the batch contained tokens. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace hardcoded Claude Code transcript parsing with an extensible AgentAdapter trait and registry. Each AI coding agent gets its own adapter for event mapping, file change extraction, and transcript record parsing. Adds full Codex CLI support.
What's included
tracevault-coreresponse_item/message,custom_tool_call,event_msg,apply_patchfile changes from transcript chunks--agentflag forstreamcommand, Codex-compatible hook response formattracevault init --agent codex— installs Codex hooks in.codex/hooks.jsonextract_file_change/is_file_modifying_toolfromstreaming.rsHow it works
The server resolves the adapter from
sessions.toolcolumn (set by CLI via--agentflag). During ingestion (stream.rs), the adapter extracts tokens and file changes. During display (session_detail.rs,traces_ui.rs), it parses transcript chunks intoTranscriptRecords for the frontend.Codex file modifications come exclusively through transcript chunks (
custom_tool_callwithapply_patch), not through hook ToolUse events — the adapter handles this viaextract_file_changes_from_transcript.Checklist
cargo fmtpassescargo clippypasses🤖 Generated with Claude Code