feat: support Codex CLI login for the openai provider - #18
Merged
Conversation
Fall back to OpenAI Codex CLI credentials (~/.codex/auth.json, override with CODEX_HOME) when no OPENAI_API_KEY/api_key is set. Two modes: - Sign in with ChatGPT: use the OAuth access token against the ChatGPT backend Responses endpoint (chatgpt.com/backend-api/codex), billed to the ChatGPT plan. Tokens auto-refresh on expiry and on a mid-review 401. - API-key login: use the OPENAI_API_KEY stored in auth.json. The ChatGPT backend is stateless (store: false): stream the request, aggregate output items from the stream, resend the full input (echoing encrypted reasoning) across tool rounds, and drop unsupported params (temperature, top_p, max_output_tokens, previous_response_id). Model is limited to plan-exposed slugs (default gpt-5.4). Cross-round continuity is preserved by replaying prior rounds' turns via a new conversationReplay provider capability (same mechanism as the Anthropic provider), so previous_review_id keeps working. Explicit env/request keys always take precedence over the CLI login. Add DUUL_REASONING_EFFORT (default medium) to tune reasoning effort. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Addresses blocking issues raised over five DUUL plan-review rounds: - reviewer: clear the conversation memoryCache on workspace switch so one workspace's turns are never flushed into or replayed from another's .duul/conversations.json. - codex-auth: when a ChatGPT token is expired, fall back to a stored OPENAI_API_KEY if refresh is unavailable or fails, instead of returning a credential that will 401. - codex-auth: chmodSync(auth.json, 0600) after refresh — the writeFileSync mode option only applies on create, not overwrite. - capabilities: previousResponseId now means NATIVE server-side chaining only (OpenAI api-key mode); replay-based continuity is conversationReplay. Anthropic set to previousResponseId=false/conversationReplay=true. - reviewer: extract pure continuityPlan() helper for the load/warn decision. Tests (94 total): OpenAI capability flags per mode, codex-auth refresh perms/failure/fallback, continuityPlan cases, conversation store roundtrip, and workspace-switch isolation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merged
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
Lets DUUL use OpenAI Codex CLI login for the
openaiprovider — noOPENAI_API_KEYrequired. When no explicit key is set, DUUL falls back to~/.codex/auth.json(override withCODEX_HOME):https://chatgpt.com/backend-api/codex), billed to the ChatGPT plan. Tokens auto-refresh on expiry and on a mid-review 401.OPENAI_API_KEYstored inauth.json.An explicit env var or per-request
api_keyalways takes precedence over the CLI login.How it works
The ChatGPT backend is stateless (
store: false), so the provider:response.completed.outputempty),temperature,top_p,max_output_tokens,previous_response_id),conversationReplayprovider capability — same mechanism as the Anthropic provider), soprevious_review_idkeeps working.DUUL_REASONING_EFFORT(defaultmedium) tunes reasoning effort. Model is limited to plan-exposed slugs (defaultgpt-5.4).Capability semantics cleanup
previousResponseIdnow means native server-side chaining only (OpenAI api-key mode); replay-based continuity is the newconversationReplay. Anthropic →previousResponseId=false,conversationReplay=true.Testing
codex-auth.test.ts(JWT/expiry/refresh perms+failure+fallback),openai-capabilities.test.ts(per-mode capability flags),reviewer-continuity.test.ts(continuityPlan, store roundtrip, workspace-switch isolation).previous_review_idreplay.Files
src/services/providers/codex-auth.tsopenai.ts,reviewer.ts,types.ts,anthropic.ts,google.ts,README.md/README.ko.md, changeset🤖 Generated with Claude Code