Skip to content

feat(provider): launch Codex against a custom provider profile (PR-2) - #68

Merged
xjoker merged 1 commit into
cursor/provider-profiles-store-5a91from
cursor/provider-launch-5a91
Aug 26, 2026
Merged

feat(provider): launch Codex against a custom provider profile (PR-2)#68
xjoker merged 1 commit into
cursor/provider-profiles-store-5a91from
cursor/provider-launch-5a91

Conversation

@xjoker

@xjoker xjoker commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Second slice of custom-provider support (方案 A). Wires provider profiles into codex-switch launch.

Stacked on PR-1 (#67) — base branch is cursor/provider-profiles-store-5a91, so this diff shows only the launch changes. Retarget to dev once #67 merges.

What's in this PR

When the launch alias names a provider profile, launch takes a separate, simpler path from the ChatGPT one:

  • Translate the profile into codex -c … overrides (model_providers.<id>.name/base_url/env_key/wire_api, model_provider, model). These layer on top of the user's base ~/.codex/config.toml, so ~/.codex is never written and its MCP servers/settings are preserved.
  • Inject the API key into the Codex child process under the profile's env_keynever onto the command line (stays out of argv/ps).
  • No auth.json staging/backup/restore for providers (there's no OAuth token), so that entire window is skipped.
  • Auto-select (launch with no alias) stays ChatGPT-only.
  • Extracted ensure_codex_available() and child_exit_code(), now shared by both launch paths.

src/provider.rs gains pure, unit-tested helpers: codex_config_args(), launch_env(), toml_string().

Tests

  • Unit (provider.rs): overrides are present and TOML-quoted; the API key never appears in argv; launch_env() returns the derived var + key; toml_string escaping.
  • Stub-codex smoke: launch <provider> <arg> passes the -c overrides, injects the key via env, forwards user args, and the key is not in argv.
  • Real Codex 0.149.1 smoke: codex-switch launch <provider> mcp list applies the -c provider and still lists a base-config MCP server → base config/MCP preserved through a provider launch.

Verification (Linux)

cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --all — all pass, 0 failed.

Out of scope: TUI add/display (PR-3), docs (PR-4), provider use-mode, DeepSeek-via-OpenRouter guidance.

Note: CI Format and audit will be red until #63 (webbrowser RUSTSEC bump) merges to dev; pre-existing and unrelated.

Open in Web Open in Cursor 

Wire provider profiles into `codex-switch launch`. When the alias names a
provider profile, launch takes a separate path from the ChatGPT one:

- translate the profile into `codex -c model_providers.<id>.* / model_provider
  / model` overrides (layered over the user's base config, so ~/.codex and its
  MCP servers are untouched), and
- inject the API key into the Codex child process under the profile's env_key,
  never onto the command line.

No auth.json staging/backup/restore happens for providers (there is no OAuth
token), so that whole window is skipped. Auto-select (no alias) stays
ChatGPT-only. Extracted ensure_codex_available() and child_exit_code() shared
by both launch paths.

provider.rs gains codex_config_args()/launch_env()/toml_string() (pure,
unit-tested: overrides present and TOML-quoted, key absent from argv, env pair
correct, escaping). Verified end-to-end with a stub codex (args + env, key not
in argv) and real codex 0.149.1 (base MCP server still lists through a provider
launch).

Co-authored-by: xJoker <xjoker@users.noreply.github.com>
@xjoker
xjoker marked this pull request as ready for review August 26, 2026 05:01
@xjoker
xjoker merged commit eb12ac2 into cursor/provider-profiles-store-5a91 Aug 26, 2026
cursor Bot pushed a commit that referenced this pull request Aug 26, 2026
Real dev already carries #67 (provider store) and #72 (env config). Re-merged
the true dev HEAD and resolved the add/add conflicts in provider.rs / cli.rs /
commands/provider.rs by keeping the provider-docs full-feature versions
(verified supersets of dev's #67). environment.json (#72) merged in cleanly.
This PR now cleanly adds #68-#73 (launch / TUI / docs / codex overrides) that
are not yet in dev. Full suite: 1019 passed.

Co-authored-by: xJoker <xjoker@users.noreply.github.com>
xjoker added a commit that referenced this pull request Aug 26, 2026
Completes the custom API provider feature. #67 (profiles store + CLI) and #72
(Cloud Agent environment) are already on dev; this adds the remaining pieces as
a single clean commit on top of dev so the repo's rebase-and-merge can apply it
without conflicts:

- launch <provider>: codex -c overrides + env-injected API key (never argv,
  never ~/.codex/auth.json)
- TUI Accounts/Providers tabs + add/remove provider wizard
- per-provider Codex overrides: --set KEY=VALUE, --reasoning, --no-web-search,
  and matching TUI wizard steps (values passed to Codex verbatim)
- provider documentation (docs/wiki/Providers.md, etc.)

The original per-PR history is preserved in the already-merged #68-#73.
Full suite: 1019 passed.

Co-authored-by: xJoker <xjoker@users.noreply.github.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.

2 participants