Summary
Add Codex (OpenAI's terminal coding agent, https://github.com/openai/codex) as a first-class AI provider in HysCode, supporting both sign-in methods available in the Codex CLI:
- ChatGPT OAuth login — reuse the Codex auth flow (
codex login) so users with a ChatGPT plan (Plus/Pro/Business/Edu/Enterprise) can use Codex inside HysCode without an API key.
- API key / access token —
codex login --with-api-key (usage-based billing) and enterprise access tokens (codex login --with-access-token).
Background / Research
Verified 2026-08-01 from https://developers.openai.com/codex/auth and https://developers.openai.com/codex/sdk:
- Install:
npm install -g @openai/codex; Windows: irm https://chatgpt.com/codex/install.ps1 | iex.
- Sign-in methods:
- ChatGPT (OAuth):
codex login opens a browser flow; tokens auto-refresh during use. Device-code variant codex login --device-auth (beta) for headless/remote setups.
- API key:
printenv OPENAI_API_KEY | codex login --with-api-key (standard API rates, platform billing).
- Enterprise access token:
printenv CODEX_ACCESS_TOKEN | codex login --with-access-token (ChatGPT Enterprise workspaces).
- Credentials cached in
~/.codex/auth.json (plaintext) or the OS keyring via cli_auth_credentials_store = "file | keyring | auto" in config.toml. The CLI and IDE extension share the same cache; login state can be queried with codex login status.
- Codex SDK (TypeScript):
@openai/codex-sdk — new Codex(), codex.startThread(), thread.run(prompt), codex.resumeThread(id). Requires Node.js 18+; it spawns/controls the local Codex runtime. This matches the pattern HysCode already uses for the Claude Agent sidecar.
- The Codex CLI also supports non-interactive execution and can run as an MCP server — alternative integration seams.
Proposed integration (decision needed at implementation time)
Option A — SDK sidecar (recommended, mirrors claude-agent-sidecar)
- New package
packages/codex-sidecar bundling @openai/codex-sdk (same shape as packages/claude-agent-sidecar).
- New provider
codex in packages/ai-providers/src/providers/codex.ts following ClaudeAgentProvider (packages/ai-providers/src/providers/claude-agent.ts): model catalog + chat() delegating to an injected CodexInvoke transport.
- New Tauri command
codex_run in apps/desktop/src-tauri/src/commands/ (mirrors claude_agent.rs) that spawns the sidecar.
- Auth: detect existing
~/.codex/auth.json / keyring; optionally drive codex login from the app for the ChatGPT OAuth flow. No API keys stored in TS/SQLite — use the existing Rust keychain layer.
- Registration in
packages/ai-providers/src/registry.ts (initialize + reinitializeProvider).
Option B — Codex CLI as MCP server: connect through the existing packages/mcp-client (stdio transport). Less code, but coarser integration (thread model, streaming, tool routing) and a weaker fit with the AIProvider.chat() contract.
Scope
Acceptance criteria
Notes
- The Codex CLI shares its auth cache with the IDE extension — reading
~/.codex/auth.json must be done carefully (plaintext token file, treated like a password).
- Out of scope for now: Codex cloud / workspace agents,
codex app desktop-app integration, Codex security scans.
Summary
Add Codex (OpenAI's terminal coding agent, https://github.com/openai/codex) as a first-class AI provider in HysCode, supporting both sign-in methods available in the Codex CLI:
codex login) so users with a ChatGPT plan (Plus/Pro/Business/Edu/Enterprise) can use Codex inside HysCode without an API key.codex login --with-api-key(usage-based billing) and enterprise access tokens (codex login --with-access-token).Background / Research
Verified 2026-08-01 from https://developers.openai.com/codex/auth and https://developers.openai.com/codex/sdk:
npm install -g @openai/codex; Windows:irm https://chatgpt.com/codex/install.ps1 | iex.codex loginopens a browser flow; tokens auto-refresh during use. Device-code variantcodex login --device-auth(beta) for headless/remote setups.printenv OPENAI_API_KEY | codex login --with-api-key(standard API rates, platform billing).printenv CODEX_ACCESS_TOKEN | codex login --with-access-token(ChatGPT Enterprise workspaces).~/.codex/auth.json(plaintext) or the OS keyring viacli_auth_credentials_store = "file | keyring | auto"inconfig.toml. The CLI and IDE extension share the same cache; login state can be queried withcodex login status.@openai/codex-sdk—new Codex(),codex.startThread(),thread.run(prompt),codex.resumeThread(id). Requires Node.js 18+; it spawns/controls the local Codex runtime. This matches the pattern HysCode already uses for the Claude Agent sidecar.Proposed integration (decision needed at implementation time)
Option A — SDK sidecar (recommended, mirrors
claude-agent-sidecar)packages/codex-sidecarbundling@openai/codex-sdk(same shape aspackages/claude-agent-sidecar).codexinpackages/ai-providers/src/providers/codex.tsfollowingClaudeAgentProvider(packages/ai-providers/src/providers/claude-agent.ts): model catalog +chat()delegating to an injectedCodexInvoketransport.codex_runinapps/desktop/src-tauri/src/commands/(mirrorsclaude_agent.rs) that spawns the sidecar.~/.codex/auth.json/ keyring; optionally drivecodex loginfrom the app for the ChatGPT OAuth flow. No API keys stored in TS/SQLite — use the existing Rust keychain layer.packages/ai-providers/src/registry.ts(initialize+reinitializeProvider).Option B — Codex CLI as MCP server: connect through the existing
packages/mcp-client(stdio transport). Less code, but coarser integration (thread model, streaming, tool routing) and a weaker fit with theAIProvider.chat()contract.Scope
~/.codex/auth.jsonif presentdocs/architecture/AI_PROVIDERS.mdAcceptance criteria
codexappears in the provider picker and works with both ChatGPT login and API keyAsyncIterable<StreamChunk>) and tool calls work through the harnessnpm run lint && npm run typecheckgreencargo test,cargo clippy,cargo fmtgreen./scripts/agent-preflight.sh(or PowerShell equivalent) greenNotes
~/.codex/auth.jsonmust be done carefully (plaintext token file, treated like a password).codex appdesktop-app integration, Codex security scans.