Feat/32 codex provider - #33
Merged
Merged
Conversation
Adds full Codex support (issue #32): OpenAI's Codex CLI driven through a Bun-compiled sidecar wrapping @openai/codex-sdk. - packages/codex-sidecar: NDJSON stdin/stdout protocol, one agentic turn per request; resolves the user-installed Codex CLI (PATH, ~/.codex/bin, ChatGPT/Codex desktop app bundled CLI, npm .cmd shims) - Rust commands/codex.rs: codex_run/codex_cancel (real process kill), codex_login/logout/login_status (ChatGPT OAuth via CLI), codex_cli_status (CLI detection + version) - CodexProvider + CodexInvoke in ai-providers; registered always when the transport is available (API key optional, ChatGPT login supported) - Settings UI: CodexAuthRow with install prompt + sign-in flow, setup guide, provider catalog (gpt-5.6 sol/terra/luna, gpt-5.5/5.4/5.4-mini) - Bundling: bundle.externalBin for both sidecars (triple-tagged by scripts/tag-sidecar-triple.mjs); beforeDev/BuildCommand build sidecars; Inno installer ships them; CI builds sidecars on ubuntu/windows/macos incl. new macOS release job - The Codex CLI itself is user-installed (npm install -g @openai/codex) and detected at runtime — never bundled Refs #32
The sidecar in a running dev session could predate the CLI-discovery fix (manual copy:sidecars was the only way to refresh target/debug before externalBin). Harden detection and make failures diagnosable: - sidecar + Rust now also find the CLI bundled with the VS Code ChatGPT extension (~/.vscode/extensions/openai.chatgpt-*/bin/<triple>/codex.exe) - 'Codex CLI not found' error now lists every location checked (PATH, ~/.codex/bin, %LOCALAPPDATA%\\OpenAI\\Codex\\bin, VS Code extension) - new Rust unit test for the VS Code extension lookup (9/9 codex tests pass) Refs #32
…viders Codex / Claude Agent execute tools internally; the streamed tool calls are informational evidence, not requests for the harness to route. - ProviderCapabilities.agenticToolExecution flag (set on CodexProvider + ClaudeAgentProvider) - Harness: for agentic providers, tool calls emit tool_call_start/tool_call_result (renders tool cards in the chat), are recorded in history + turn summary, and end the iteration normally instead of being routed (previously 'shell'/'apply_patch' would hit Unknown tool errors) - New harness test for the informational path (220 tests pass) Refs #32
Codex streams one agent_message item per interim step; the harness concatenated every text_delta into a single assistant message per iteration, gluing the agent's working notes and the final answer into one paragraph. - New message_boundary StreamChunk (ai-providers types) - Sidecar: emits message_boundary lazily before each subsequent non-empty agent_message (no trailing boundary, so the final segment stays the response) - Transport maps it; harness finalizes the completed segment (history + transcript_message + new assistant_segment_end event) and resets buffers - Bridge: assistant_segment_end flushes the current message and begins a new assistant message - Tests: harness segment-splitting (221 pass), Rust boundary parse (10 pass) Refs #32
…pricing) Updated from developers.openai.com/api/docs/models (2026-08): - gpt-5.6-sol: 1.05M ctx, \.00/\.50/\.00 - gpt-5.6-terra: 1.05M ctx, \.00/\.20/\.00 - gpt-5.6-luna: 1.05M ctx, \.20/\.02/\.20 - gpt-5.5: 1.05M ctx, \.00/\.50/\.00 - gpt-5.4: 1.05M ctx, \.50/\.25/\.00 - gpt-5.4-mini: 400K ctx, \.75/\.075/\.50 (input / cached input / output per 1M tokens). Docs table updated with a note about the >272K-token 2x/1.5x surcharge. Refs #32
An empty model with an explicit providerId (provider switch with no enabled models, stale selection) was forwarded as model:'' — the Codex SDK treats '' as 'no --model flag', silently making the CLI use its own default model. - registry.chat: empty model now falls back to the provider's first catalog model (all providers) - CodexProvider.chat: guards params.model || first catalog model (last line of defense) - New test: empty model → gpt-5.6-sol (32 ai-providers tests pass) Refs #32
Stop support: the harness abort signal is now forwarded through CodexInvoke to the transport, which calls codex_cancel — Rust kills the sidecar process and emits the terminal 'Cancelled by user' chunk, so the stop button works immediately instead of waiting for the turn to finish.
Agent modes: ChatParams.agentMode (set by the harness from the agent type) is mapped to the Codex CLI native sandbox so mode restrictions are enforced, not just prompted:
- chat/review → read-only
- plan → workspace-write
- build/debug → danger-full-access
(unknown/empty → danger-full-access, previous behavior)
Chain: request-preparation → provider (AGENT_MODE_TO_SANDBOX) → transport → codex_run (sandbox_mode) → sidecar startThread({ sandboxMode }). New tests: signal forwarding + 7-case sandbox mapping table (34 ai-providers tests pass).
Refs #32
The mode system prompts referenced HysCode-only tools (read_file, edit_file, search_code, request_mode_switch, spawn_subagent, ask_user, memory tools...) that Codex does not have — noise that misdirected the agent. - agents.ts: CODEX_AGENTIC base prompt (same structure: intent analysis, context verification, language, thinking, core principles; tool guidance adapted to shell/apply_patch/code search/web/AGENTS.md; HysCode mechanics replaced with agentic equivalents) + AGENTIC_MODE_FIXES (16 verbatim swaps across the chat/build/review/debug/plan role sections) + exported adaptSystemPromptForAgentic() - context-manager: buildSnapshot(..., agenticExecution) adapts the base prompt (user overrides untouched) - harness: resolves the provider before the snapshot and passes agenticToolExecution - agents.test.ts: completeness guard — no HysCode tool name survives in any of the 5 adapted mode prompts; Codex guidance present; catches prompt drift (it already caught a real leftover, git_diff in the debug prompt) - docs: AI_PROVIDERS.md sandbox mapping note 227 agent-harness tests pass (6 new), typecheck/lint/preflight green. Refs #32
The assistant message now shows only the 'Agent' label (with the streaming indicator); the Sparkles avatar column and the consecutive-message spacer were removed. The icon remains in the empty state. Refs #32
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.
Tipo de Mudança
Marque exatamente uma:
type:bug— correção que não quebra APItype:feat— nova funcionalidadetype:chore— build, dependência, manutençãotype:refactor— refatoração sem mudança de comportamentotype:perf— performancetype:docs— apenas documentaçãotype:test— apenas testesIssue
Área e Milestone
Descrição
Como Testar
git fetch <remote> && git switch <branch>pnpm installChecklist Agente
gh auth statusok<type>/<issue#>-<scope>-<slug>pnpm lintpassa sem errospnpm typecheckpassa sem errospnpm testpassa (e adicionados testes para mudança)cargo fmt --check && cargo clippy(se Rust mudou; warnings são informativos)TODO,FIXME,// implement later)console.log/println!de debuggit push --forceem main ou PR abertadocs/atualizado se houve mudança de contrato/arquiteturaAGENTS.md/docs/WORKFLOW.mdatualizado se mudou convençãoBreaking Changes
Descriçãoe adicionada nota no CHANGELOGScreenshots / Vídeos
Merge (humano executar)