Commit Graph

8634 Commits

Author SHA1 Message Date
Michael Bolin
4610c998a1 Merge 1b1611b891 into sapling-pr-archive-bolinfest 2025-06-25 11:32:16 -07:00
Michael Bolin
1b1611b891 feat: add --dangerously-bypass-approvals-and-sandbox 2025-06-25 11:32:11 -07:00
Michael Bolin
66c6ad7801 Merge 1420d2458c into sapling-pr-archive-bolinfest 2025-06-25 11:21:37 -07:00
Michael Bolin
1420d2458c feat: add --dangerously-bypass-approvals-and-sandbox 2025-06-25 11:21:09 -07:00
Michael Bolin
e09691337d chore: improve docstring for --full-auto (#1379)
Reference `-c sandbox.mode=workspace-write` in the docstring and users
can read the config docs for `sandbox` for more information.
2025-06-25 09:13:36 -07:00
Michael Bolin
887a7467f6 Merge 9e144a71d0 into sapling-pr-archive-bolinfest 2025-06-24 22:19:32 -07:00
Michael Bolin
9e144a71d0 chore: improve docstring for --full-auto 2025-06-24 22:19:26 -07:00
Michael Bolin
86d5a9d80d chore: rename unless-allow-listed to untrusted (#1378)
For the `approval_policy` config option, renames `unless-allow-listed`
to `untrusted`. In general, when it comes to exec'ing commands, I think
"trusted" is a more accurate term than "safe."

Also drops the `AskForApproval::AutoEdit` variant, as we were not really
making use of it, anyway.

Fixes https://github.com/openai/codex/issues/1250.


---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1378).
* #1379
* __->__ #1378
2025-06-24 22:19:21 -07:00
Michael Bolin
c6e562aedd merge commit for archive created by Sapling 2025-06-24 22:15:59 -07:00
Michael Bolin
63af91e70d chore: improve docstring for --full-auto 2025-06-24 22:15:47 -07:00
Michael Bolin
4c8514a636 chore: rename unless-allow-listed to untrusted 2025-06-24 22:15:47 -07:00
Michael Bolin
8cd306f8d8 Merge 989afe9e7a into sapling-pr-archive-bolinfest 2025-06-24 22:11:10 -07:00
Michael Bolin
989afe9e7a chore: improve docstring for --full-auto 2025-06-24 22:11:03 -07:00
Michael Bolin
53a97c4b00 chore: rename unless-allow-listed to untrusted 2025-06-24 22:11:03 -07:00
Michael Bolin
b6b2205936 Merge 3734c29859 into sapling-pr-archive-bolinfest 2025-06-24 22:09:22 -07:00
Michael Bolin
3734c29859 chore: improve docstring for --full-auto 2025-06-24 22:09:06 -07:00
Michael Bolin
3d672c2262 merge commit for archive created by Sapling 2025-06-24 22:05:59 -07:00
Michael Bolin
b66373f946 chore: rename unless-allow-listed to untrusted 2025-06-24 22:05:53 -07:00
Michael Bolin
0eff0d93a7 Merge 17fad32de2 into sapling-pr-archive-bolinfest 2025-06-24 22:05:07 -07:00
Michael Bolin
17fad32de2 chore: rename unless-allow-listed to untrusted 2025-06-24 22:04:59 -07:00
Michael Bolin
531ce7626f fix: pretty-print the sandbox config in the TUI/exec modes (#1376)
Now that https://github.com/openai/codex/pull/1373 simplified the
sandbox config, we can print something much simpler in the TUI (and in
`codex exec`) to summarize the sandbox config.

Before:

![Screenshot 2025-06-24 at 5 45
52 PM](https://github.com/user-attachments/assets/b7633efb-a619-43e1-9abe-7bb0be2d0ec0)

With this change:

![Screenshot 2025-06-24 at 5 46
44 PM](https://github.com/user-attachments/assets/8d099bdd-a429-4796-a08d-70931d984e4f)

For reference, my `config.toml` contains:

```
[sandbox]
mode = "workspace-write"
writable_roots = ["/tmp", "/Users/mbolin/.pyenv/shims"]
```

Fixes https://github.com/openai/codex/issues/1248
2025-06-24 17:48:51 -07:00
Michael Bolin
073ff4110c Merge 26f93c320b into sapling-pr-archive-bolinfest 2025-06-24 17:44:11 -07:00
Michael Bolin
26f93c320b fix: pretty-print the sandbox config in the TUI/exec modes 2025-06-24 17:44:04 -07:00
Michael Bolin
63363a54e5 chore: install just in the devcontainer for Linux development (#1375)
Apparently `just` was added to `apt` in Ubuntu 24, so this required
updating the Ubuntu version in the `Dockerfile` to make it so we could
simply `apt install just`.

Though then that caused a conflict with the custom `dev` user we were
using, though the end result seems simpler since now we just use the
default `ubuntu` user provided by Ubuntu 24.
2025-06-24 17:20:53 -07:00
Michael Bolin
e417a49932 Merge 05c8800062 into sapling-pr-archive-bolinfest 2025-06-24 17:16:44 -07:00
Michael Bolin
05c8800062 chore: install just in the devcontainer for Linux development 2025-06-24 17:16:31 -07:00
Michael Bolin
6d65010aad chore: install clippy and rustfmt in the devcontainer for Linux development (#1374)
I discovered it was difficult to do development in the devcontainer
without these tools available.
2025-06-24 17:05:36 -07:00
Michael Bolin
10b61396d3 Merge 90079447da into sapling-pr-archive-bolinfest 2025-06-24 17:02:47 -07:00
Michael Bolin
90079447da chore: install clippy and rustfmt in the devcontainer for Linux development 2025-06-24 17:02:41 -07:00
Michael Bolin
0776d78357 feat: redesign sandbox config (#1373)
This is a major redesign of how sandbox configuration works and aims to
fix https://github.com/openai/codex/issues/1248. Specifically, it
replaces `sandbox_permissions` in `config.toml` (and the
`-s`/`--sandbox-permission` CLI flags) with a "table" with effectively
three variants:

```toml
# Safest option: full disk is read-only, but writes and network access are disallowed.
[sandbox]
mode = "read-only"

# The cwd of the Codex task is writable, as well as $TMPDIR on macOS.
# writable_roots can be used to specify additional writable folders.
[sandbox]
mode = "workspace-write"
writable_roots = []  # Optional, defaults to the empty list.
network_access = false  # Optional, defaults to false.

# Disable sandboxing: use at your own risk!!!
[sandbox]
mode = "danger-full-access"
```

This should make sandboxing easier to reason about. While we have
dropped support for `-s`, the way it works now is:

- no flags => `read-only`
- `--full-auto` => `workspace-write`
- currently, there is no way to specify `danger-full-access` via a CLI
flag, but we will revisit that as part of
https://github.com/openai/codex/issues/1254

Outstanding issue:

- As noted in the `TODO` on `SandboxPolicy::is_unrestricted()`, we are
still conflating sandbox preferences with approval preferences in that
case, which needs to be cleaned up.
2025-06-24 16:59:47 -07:00
Michael Bolin
725bfd5ca7 merge commit for archive created by Sapling 2025-06-24 16:46:51 -07:00
Michael Bolin
364706bddc feat: redesign sandbox config 2025-06-24 16:46:21 -07:00
Michael Bolin
1f95562c13 merge commit for archive created by Sapling 2025-06-24 16:38:48 -07:00
Michael Bolin
c660ec6852 feat: redesign sandbox config 2025-06-24 16:38:41 -07:00
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