Commit Graph

1750 Commits

Author SHA1 Message Date
Michael Bolin
73ae461b80 merge commit for archive created by Sapling 2025-06-24 16:22:56 -07:00
Michael Bolin
d81914669b feat: redesign sandbox config 2025-06-24 16:22:49 -07:00
Michael Bolin
66eba709a7 merge commit for archive created by Sapling 2025-06-24 15:20:35 -07:00
Michael Bolin
21b846bd87 feat: redesign sandbox config 2025-06-24 15:20:28 -07:00
Michael Bolin
afd2768d56 Merge 0d6f705d51 into sapling-pr-archive-bolinfest 2025-06-24 14:52:51 -07:00
Michael Bolin
0d6f705d51 feat: redesign sandbox config 2025-06-24 14:08:43 -07:00
Eric Wright
ed5e848f3e add: responses api support for azure (#1321)
- Use Responses API for Azure provider endpoints
- Added a unit test to catch regression on the change from
`/chat/completions` to `/responses`
- Updated the default AOAI api version from `2025-03-01-preview` to
`2025-04-01-preview` to avoid user/400 errors due to missing summary
support in the March API version.
- Changes have been tested locally on AOAI endpoints
2025-06-22 18:01:13 -07:00
Govind Kamtamneni
5aafe190e2 feat(ts): provider‑specific API‑key discovery and clearer Azure guidance (#1324)
## Summary

This PR refactors the Codex CLI authentication flow so that
**non-OpenAI** providers (for example **azure**, or any future addition)
can supply their API key through a dedicated environment variable
without triggering the OpenAI login flow.

Key behaviours introduced:

* When `provider !== "openai"` the CLI consults `src/utils/providers.ts`
to locate the correct environment variable (`AZURE_OPENAI_API_KEY`,
`GEMINI_API_KEY`, and so on) before considering any interactive login.
* Credit redemption (`--free`) and PKCE login now run **only** when the
provider is OpenAI, eliminating unwanted browser prompts for Azure and
others.
* User-facing error messages are revamped to guide Azure users to
**[https://ai.azure.com/](https://ai.azure.com)** and show the exact
variable name they must set.
* All code paths still export `OPENAI_API_KEY` so legacy scripts
continue to operate unchanged.

---

## Example `config.json`

```jsonc
{
  "model": "codex-mini",
  "provider": "azure",
  "providers": {
    "azure": {
      "name": "AzureOpenAI",
      "baseURL": "https://ai-<project-name>.openai.azure.com/openai",
      "envKey": "AZURE_OPENAI_API_KEY"
    }
  },
  "history": {
    "maxSize": 1000,
    "saveHistory": true,
    "sensitivePatterns": []
  }
}
```

With this file in `~/.codex/config.json`, a single command line is
enough:

```bash
export AZURE_OPENAI_API_KEY="<your-key>"
codex "Hello from Azure"
```

No browser window opens, and the CLI works in entirely non-interactive
mode.

---

## Rationale

The new flow enables Codex to run **asynchronously** in sandboxed
environments such as GitHub Actions pipelines. By passing `--provider
azure` (or setting it in `config.json`) and exporting the correct key,
CI/CD jobs can invoke Codex without any ChatGPT-style login or PKCE
round-trip. This unlocks fully automated testing and deployment
scenarios.

---

## What’s changed

| File | Type | Description |
| ------------------------ | ------------------- |
-----------------------------------------------------------------------------------------------------------------------------
|
| `codex-cli/src/cli.tsx` | **feat / refactor** | +43 / -20 lines.
Imports `providers`, adds early provider-specific key lookup, gates
`--free` redemption, rewrites help text. |
| `src/utils/providers.ts` | **chore** | Now consumed by CLI for env-var
discovery. |

---

## How to test

```bash
# Azure example
export AZURE_OPENAI_API_KEY="<your-key>"
codex --provider azure "Automated run in CI"

# OpenAI example (unchanged behaviour)
codex --provider openai --login "Standard OpenAI flow"
```

Expected outcomes:

* Azure and other provider paths are non-interactive when provider flag
is passed.
* The CLI always sets `OPENAI_API_KEY` for backward compatibility.

---

## Checklist

* [x] Logic behind provider-specific env-var lookup added.
* [x] Redundant OpenAI login steps removed for other providers.
* [x] Unit tests cover new branches.
* [x] README and sample config updated.
* [x] CI passes on all supported Node versions.

---

**Related work**

* #92
* #769 
* #1321



I have read the CLA Document and I hereby sign the CLA.
2025-06-22 17:56:36 -07:00
Michael Bolin
132d35ea17 merge commit for archive created by Sapling 2025-06-09 16:28:02 -04:00
Michael Bolin
2422660594 feat: list-models subcommand for full CLI 2025-06-09 16:27:56 -04:00
Michael Bolin
7a4605990f Merge 5d8ec161e8 into sapling-pr-archive-bolinfest 2025-06-09 13:12:49 -07:00
Michael Bolin
5d8ec161e8 feat: list-models subcommand for full CLI 2025-06-09 16:12:43 -04:00
Michael Bolin
b73426c1c4 docs: update codex-rs/README.md to list new features in the Rust CLI (#1267)
Let users know about what the Rust CLI supports that the TypeScript CLI
doesn't!
2025-06-06 18:32:10 -07:00
Michael Bolin
cfc3586d11 merge commit for archive created by Sapling 2025-06-06 18:31:21 -07:00
Michael Bolin
dd29ac43a8 docs: update codex-rs/README.md to list new features in the Rust CLI 2025-06-06 18:31:13 -07:00
Reilly Wood
345a38502d codex-rs: Rename /clear to /new, make it start an entirely new chat (#1264)
I noticed that `/clear` wasn't fully clearing chat history; it would
clear the chat history widgets _in the UI_, but the LLM still had access
to information from previous messages.

This PR renames `/clear` to `/new` for clarity as per Michael's
suggestion, resetting `app_state` to a fresh `ChatWidget`.
2025-06-06 16:29:37 -07:00
Michael Bolin
029f39b9da feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_chatgpt.py (#1221)
This builds on https://github.com/openai/codex/pull/1212 and ports the
`maybeRedeemCredits()` function from `get-api-key.ts` to
`login_with_chatgpt.py`:


a80240cfdc/codex-cli/src/utils/get-api-key.tsx (L84-L89)
codex-rs-5fc3c3023d9f179fb416b2722d1434bac278e916-1-rust-v0.0.2506060849
2025-06-05 23:34:10 -07:00
Michael Bolin
b122100561 Merge b1b9423a13 into sapling-pr-archive-bolinfest 2025-06-05 23:30:12 -07:00
Michael Bolin
b1b9423a13 feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_chatgpt.py 2025-06-05 23:30:08 -07:00
Michael Bolin
2389b6d764 merge commit for archive created by Sapling 2025-06-05 23:28:49 -07:00
Michael Bolin
5c11e74b92 feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_chatgpt.py 2025-06-05 23:28:43 -07:00
Michael Bolin
aaded1f4b1 Merge c87b5194fb into sapling-pr-archive-bolinfest 2025-06-05 23:22:30 -07:00
Michael Bolin
a80240cfdc chore: ensure next Node.js release includes musl binaries for arm64 Linux (#1232)
Target a workflow with more recent binary artifacts.
2025-06-05 23:14:10 -07:00
Michael Bolin
56398edef2 merge commit for archive created by Sapling 2025-06-05 23:09:06 -07:00
Michael Bolin
c6e890536e chore: ensure next Node.js release includes musl binaries for arm64 Linux 2025-06-05 23:08:59 -07:00
Michael Bolin
c87b5194fb feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_chatgpt.py 2025-06-05 22:59:11 -07:00
Michael Bolin
2d5246050a fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-gnu (#1228)
Now that we have published a GitHub Release that contains arm64 musl
artifacts for Linux, update the following scripts to take advantage of
them:

- `dotslash-config.json` now uses musl artifacts for the `linux-aarch64`
target
- `install_native_deps.sh` for the TypeScript CLI now includes
`codex-linux-sandbox-aarch64-unknown-linux-musl` instead of
`codex-linux-sandbox-aarch64-unknown-linux-gnu` for sandboxing
- `codex-cli/bin/codex.js` now checks for `aarch64-unknown-linux-musl`
artifacts instead of `aarch64-unknown-linux-gnu` ones
codex-rs-ac6e1b2661320a631d80aa51bdfa8f1635e0c8fa-1-rust-v0.0.2506052246
2025-06-05 22:45:45 -07:00
Michael Bolin
e8d82ae2cd Merge c730de4c7d into sapling-pr-archive-bolinfest 2025-06-05 22:18:41 -07:00
Michael Bolin
c730de4c7d fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-gnu 2025-06-05 22:18:25 -07:00
Michael Bolin
77b017f67d fix: truncate auth.json file before rewriting it (#1231)
This was missed in https://github.com/openai/codex/pull/1212. Caught by
@rizwankce in
https://github.com/openai/codex/discussions/1174#discussioncomment-13377475.
codex-rs-121686615fd634e35f3e415896f36908cf8632f9-1-rust-v0.0.2506052203
2025-06-05 22:11:02 -07:00
Michael Bolin
c02d25fbad fix: include codex-linux-sandbox-aarch64-unknown-linux-musl in the set of release artifacts (#1230)
This was missed in https://github.com/openai/codex/pull/1225. Once we
create a new GitHub Release with this change, we can use the URL from
the workflow that triggered the release in
https://github.com/openai/codex/pull/1228.
2025-06-05 22:03:07 -07:00
Michael Bolin
43b1b27d00 merge commit for archive created by Sapling 2025-06-05 22:00:23 -07:00
Michael Bolin
fa6ba8f2d9 fix: truncate auth.json file before rewriting it 2025-06-05 22:00:15 -07:00
Michael Bolin
95da270f6b Merge 8b66da118e into sapling-pr-archive-bolinfest 2025-06-05 21:56:04 -07:00
Michael Bolin
8b66da118e fix: include codex-linux-sandbox-aarch64-unknown-linux-musl in the set of release artifacts 2025-06-05 21:55:57 -07:00
Michael Bolin
0ec9a3bc45 Merge 70e420d1d2 into sapling-pr-archive-bolinfest 2025-06-05 21:50:07 -07:00
Michael Bolin
70e420d1d2 fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-gnu 2025-06-05 21:36:13 -07:00
Michael Bolin
2a63375959 Merge d77563d78d into sapling-pr-archive-bolinfest 2025-06-05 20:42:42 -07:00
Michael Bolin
d77563d78d fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-gnu 2025-06-05 20:42:34 -07:00
Michael Bolin
9db53b33aa fix: support arm64 build for Linux (#1225)
Users were running into issues with glibc mismatches on arm64 linux. In
the past, we did not provide a musl build for arm64 Linux because we had
trouble getting the openssl dependency to build correctly. Though today
I just tried the same trick in `Cargo.toml` that we were doing for
`x86_64-unknown-linux-musl` (using `openssl-sys` with `features =
["vendored"]`), so I'm not sure what problem we had in the past the
builds "just worked" today!

Though one tweak that did have to be made is that the integration tests
for Seccomp/Landlock empirically require longer timeouts on arm64 linux,
or at least on the `ubuntu-24.04-arm` GitHub Runner. As such, we change
the timeouts for arm64 in `codex-rs/linux-sandbox/tests/landlock.rs`.

Though in solving this problem, I decided I needed a turnkey solution
for testing the Linux build(s) from my Mac laptop, so this PR introduces
`.devcontainer/Dockerfile` and `.devcontainer/devcontainer.json` to
facilitate this. Detailed instructions are in `.devcontainer/README.md`.

We will update `dotslash-config.json` and other release-related scripts
in a follow-up PR.
codex-rs-84eae7b1bc4e3b5420f2d6127b7c17e7a979a5b0-1-rust-v0.0.2506052135
2025-06-05 20:29:46 -07:00
Michael Bolin
33724c2ae1 merge commit for archive created by Sapling 2025-06-05 20:25:33 -07:00
Michael Bolin
19bb463b97 fix: support arm64 build for Linux 2025-06-05 20:25:28 -07:00
Michael Bolin
bb335f44c3 merge commit for archive created by Sapling 2025-06-05 20:22:25 -07:00
Michael Bolin
bca266f5ca fix: support arm64 build for Linux 2025-06-05 20:22:18 -07:00
Michael Bolin
6df663a988 Merge f5c9a961b0 into sapling-pr-archive-bolinfest 2025-06-05 20:17:51 -07:00
Michael Bolin
f5c9a961b0 fix: support arm64 build for Linux 2025-06-05 20:17:46 -07:00
Michael Bolin
5b684d03e6 merge commit for archive created by Sapling 2025-06-05 17:27:39 -07:00
Michael Bolin
7c845c34d4 fix: support arm64 build for Linux 2025-06-05 17:27:32 -07:00
Michael Bolin
de221589d3 Merge 5bd4ce9efa into sapling-pr-archive-bolinfest 2025-06-05 17:12:59 -07:00
Michael Bolin
5bd4ce9efa fix: support arm64 build for Linux 2025-06-05 17:12:53 -07:00