Skip to content

feat(agents): add OpenAI Codex CLI plugin with API key bypass#212

Open
8nevil8 wants to merge 2 commits intomainfrom
feat/codex-agent-plugin
Open

feat(agents): add OpenAI Codex CLI plugin with API key bypass#212
8nevil8 wants to merge 2 commits intomainfrom
feat/codex-agent-plugin

Conversation

@8nevil8
Copy link
Collaborator

@8nevil8 8nevil8 commented Mar 12, 2026

Summary

Adds OpenAI Codex CLI (@openai/codex) as a selectable agent in CodeMie via a new CodexPlugin. Includes a fix for API key injection that bypasses ~/.codex/auth.json, which has higher priority than environment variables for the default OpenAI provider.

Changes

  • New CodexPlugin (src/agents/plugins/codex/) — BaseAgentAdapter implementation with full session lifecycle: onSessionStart, enrichArgs, onSessionEnd. Includes rollout file analytics via CodexSessionAdapter.
  • API key bypassenrichArgs configures model_providers.codemie with env_key=CODEMIE_API_KEY and selects it via model_provider="codemie", bypassing auth.json which overrides OPENAI_API_KEY for the default provider.
  • CODEMIE_API_KEY passthrough — intentionally excluded from envMapping.apiKey to prevent transformEnvVars from wiping it before enrichArgs reads config.apiKey.
  • codemie-codex binary — new bin/codemie-codex.js entry point registered in package.json.
  • Config fixloadLocalConfigProfile now skips legacy local config when an explicit named profile is requested via --profile, preventing sso-provided key contamination.
  • Registry + tests — codex registered in AgentRegistry/AgentCLI; registry tests updated for 6 agents.

Impact

Before: codemie-codex --profile lite-codex received sso-provided from auth.json, causing 401 errors.
After: Codex uses model_providers.codemie provider with API key read from CODEMIE_API_KEY env var, bypassing auth.json entirely.

Checklist

  • Self-reviewed
  • Manual testing performed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)

8nevil8 and others added 2 commits March 12, 2026 15:43
- Add CodexPlugin (BaseAgentAdapter) with session lifecycle hooks
- Register codex agent in AgentRegistry and AgentCLI
- Add codemie-codex binary entry point (bin/codemie-codex.js)
- Fix enrichArgs to configure model_providers.codemie with env_key=CODEMIE_API_KEY,
  bypassing ~/.codex/auth.json which has higher priority than OPENAI_API_KEY env var
- Fix loadLocalConfigProfile: skip legacy local config when explicit named profile
  is requested via --profile to prevent sso-provided key contamination
- Update registry tests for 6 agents

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
- Replace generic Error throws with ConfigurationError (codex.session.ts x4,
  codex-message-types.ts x1) for proper error classification
- Extract shared readJSONLTolerant utility to jsonl-reader.ts; delegate from
  codex.storage-utils.ts and opencode.storage-utils.ts to eliminate duplication
- Parallelize discoverSessions directory traversal with Promise.all at all 4 levels
  (year/month/day/file) replacing sequential await loops
- Add BaseNormalizedMessage to core session types; codex processor uses it directly,
  opencode processor extends it — removes duplicate interface definitions
- Narrow onSessionEnd session correlation to rollout files modified within 5 minutes,
  preventing wrong-session metric attribution

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant