feat(agents): add OpenAI Codex CLI plugin with API key bypass#212
Open
feat(agents): add OpenAI Codex CLI plugin with API key bypass#212
Conversation
- 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>
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.
Summary
Adds OpenAI Codex CLI (
@openai/codex) as a selectable agent in CodeMie via a newCodexPlugin. 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
CodexPlugin(src/agents/plugins/codex/) —BaseAgentAdapterimplementation with full session lifecycle:onSessionStart,enrichArgs,onSessionEnd. Includes rollout file analytics viaCodexSessionAdapter.enrichArgsconfiguresmodel_providers.codemiewithenv_key=CODEMIE_API_KEYand selects it viamodel_provider="codemie", bypassingauth.jsonwhich overridesOPENAI_API_KEYfor the default provider.CODEMIE_API_KEYpassthrough — intentionally excluded fromenvMapping.apiKeyto preventtransformEnvVarsfrom wiping it beforeenrichArgsreadsconfig.apiKey.codemie-codexbinary — newbin/codemie-codex.jsentry point registered inpackage.json.loadLocalConfigProfilenow skips legacy local config when an explicit named profile is requested via--profile, preventingsso-providedkey contamination.AgentRegistry/AgentCLI; registry tests updated for 6 agents.Impact
Before:
codemie-codex --profile lite-codexreceivedsso-providedfromauth.json, causing 401 errors.After: Codex uses
model_providers.codemieprovider with API key read fromCODEMIE_API_KEYenv var, bypassingauth.jsonentirely.Checklist