Commit Graph

32 Commits

  • feat: add --reasoning CLI flag (#314)
    This PR adds a new CLI flag: `--reasoning`, which allows users to
    customize the reasoning effort level (`low`, `medium`, or `high`) used
    by OpenAI's `o` models.
    By introducing the `--reasoning` flag, users gain more flexibility when
    working with the models. It enables optimization for either speed or
    depth of reasoning, depending on specific use cases.
    This PR resolves #107
    
    - **Flag**: `--reasoning`
    - **Accepted Values**: `low`, `medium`, `high`
    - **Default Behavior**: If not specified, the model uses the default
    reasoning level.
    
    ## Example Usage
    
    ```bash
    codex --reasoning=low "Write a simple function to calculate factorial"
    
    ---------
    
    Co-authored-by: Fouad Matin <169186268+fouad-openai@users.noreply.github.com>
    Co-authored-by: yashrwealthy <yash.rastogi@wealthy.in>
    Co-authored-by: Thibault Sottiaux <tibo@openai.com>
  • chore: upgrade prettier to v3 (#644)
    ## Description
    
    This PR addresses the following improvements:
    
    **Unify Prettier Version**: Currently, the Prettier version used in
    `/package.json` and `/codex-cli/package.json` are different. In this PR,
    we're updating both to use Prettier v3.
    
    - Prettier v3 introduces improved support for JavaScript and TypeScript.
    (e.g. the formatting scenario shown in the image below. This is more
    aligned with the TypeScript indentation standard).
    
    <img width="1126" alt="image"
    src="https://github.com/user-attachments/assets/6e237eb8-4553-4574-b336-ed9561c55370"
    />
    
    **Add Prettier Auto-Formatting in lint-staged**: We've added a step to
    automatically run prettier --write on JavaScript and TypeScript files as
    part of the lint-staged process, before the ESLint checks.
    
    - This will help ensure that all committed code is properly formatted
    according to the project's Prettier configuration.
  • feat: add specific instructions for creating API keys in error msg (#581)
    Updates the error message for missing Gemini API keys to reference
    "Google AI Studio" instead of the generic "GEMINI dashboard". This
    provides users with more accurate information about where to obtain
    their Gemini API keys.
    
    This could be extended to other providers as well.
  • bug: fix error catching when checking for updates (#597)
    This fixes https://github.com/openai/codex/issues/480 where the latest
    code was crashing when attempting to be run inside docker since the
    update checker attempts to reach out to `npm.antfu.dev` but that DNS is
    not allowed in the firewall rules.
    
    I believe the original code was attempting to catch and ignore any
    errors when checking for updates but was doing so incorrectly. If you
    use await on a promise, you have to use a standard try/catch instead of
    `Promise.catch` so this fixes that.
    
    ## Testing
    
    ### Before
    
    ```
    $ scripts/run_in_container.sh "explain this project to me"
    7d1aa845edf9a36fe4d5b331474b5cb8ba79537b682922b554ea677f14996c6b
    Resolving api.openai.com...
    Adding 162.159.140.245 for api.openai.com
    Adding 172.66.0.243 for api.openai.com
    Host network detected as: 172.17.0.0/24
    Firewall configuration complete
    Verifying firewall rules...
    Firewall verification passed - unable to reach https://example.com as expected
    Firewall verification passed - able to reach https://api.openai.com as expected
    TypeError: fetch failed
        at node:internal/deps/undici/undici:13510:13
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async getLatestVersionBatch (file:///usr/local/share/npm-global/lib/node_modules/@openai/codex/dist/cli.js:132669:17)
        at async getLatestVersion (file:///usr/local/share/npm-global/lib/node_modules/@openai/codex/dist/cli.js:132674:19)
        at async getUpdateCheckInfo (file:///usr/local/share/npm-global/lib/node_modules/@openai/codex/dist/cli.js:132748:20)
        at async checkForUpdates (file:///usr/local/share/npm-global/lib/node_modules/@openai/codex/dist/cli.js:132772:23)
        at async file:///usr/local/share/npm-global/lib/node_modules/@openai/codex/dist/cli.js:142027:1 {
      [cause]: AggregateError [ECONNREFUSED]: 
          at internalConnectMultiple (node:net:1122:18)
          at afterConnectMultiple (node:net:1689:7) {
        code: 'ECONNREFUSED',
        [errors]: [ [Error], [Error] ]
      }
    }
    ```
    
    ### After
    
    ```
    $ scripts/run_in_container.sh "explain this project to me"
    91aa716e3d3f86c9cf6013dd567be31b2c44eb5d7ab184d55ef498731020bb8d
    Resolving api.openai.com...
    Adding 162.159.140.245 for api.openai.com
    Adding 172.66.0.243 for api.openai.com
    Host network detected as: 172.17.0.0/24
    Firewall configuration complete
    Verifying firewall rules...
    Firewall verification passed - unable to reach https://example.com as expected
    Firewall verification passed - able to reach https://api.openai.com as expected
    ╭──────────────────────────────────────────────────────────────╮
    │ ● OpenAI Codex (research preview) v0.1.2504221401            │
    ╰──────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────╮
    │ localhost session: 7c782f196ae04503866e39f071e26a69          │
    │ ↳ model: o4-mini                                             │
    │ ↳ provider: openai                                           │
    │ ↳ approval: full-auto                                        │
    ╰──────────────────────────────────────────────────────────────╯
    user
    explain this project to me
    ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │( ●    ) 2s  Thinking                                                                                                                                                                                                                                                  │
    ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
      send q or ctrl+c to exit | send "/clear" to reset | send "/help" for commands | press enter to send | shift+enter for new line — 100% context left
    ```
  • feat: added provider to run quiet mode function (#571)
    Adding support to be able to run other models in quiet mode
    
    ie: `codex --approval-mode full-auto -q "explain the current directory"
    --provider xai --model grok-3-beta`
  • fix: remove requirement for api key for ollama (#546)
    Fixes #540 
    # Skip API key validation for Ollama provider
    
    ## Description
    This PR modifies the CLI to not require an API key when using Ollama as
    the provider
    
    ## Changes
    - Modified the validation logic to skip API key checks for these
    providers
    - Updated the README to clarify that Ollama doesn't require an API key
  • feat: show actionable errors when api keys are missing (#523)
    Change errors on missing api key of other providers from
    <img width="854" alt="image"
    src="https://github.com/user-attachments/assets/f488a247-5040-4b02-92d6-90a2204419ff"
    />
    (missing deepseek key but still throws error for openai)
    to
    <img width="854" alt="image"
    src="https://github.com/user-attachments/assets/8333d24a-91f8-4ba8-9a51-ed22a7e8a074"
    />
    This should help new users figure out the issue easier and go to the
    right place to get api keys
    
    OpenAI key missing would popup with the right link
    <img width="854" alt="image"
    src="https://github.com/user-attachments/assets/0ecc9320-380f-425c-972e-4312bf610955"
    />
  • feat: add CLI –version flag (#492)
    Adds a new flag to cli `--version` that prints the current version and
    exits
    
    ---------
    
    Co-authored-by: Thibault Sottiaux <tibo@openai.com>
  • feat: add support for ZDR orgs (#481)
    - Add `store: boolean` to `AgentLoop` to enable client-side storage of
    response items
    - Add `--disable-response-storage` arg + `disableResponseStorage` config
  • chore: improve storage/ implementation; use log(...) consistently (#473)
    This PR tidies up primitives under storage/.
    
    **Noop changes:**
    
    * Promote logger implementation to top-level utility outside of agent/
    * Use logger within storage primitives
    * Cleanup doc strings and comments
    
    **Functional changes:**
    
    * Increase command history size to 10_000
    * Remove unnecessary debounce implementation and ensure a session ID is
    created only once per agent loop
    
    ---------
    
    Signed-off-by: Thibault Sottiaux <tibo@openai.com>
  • feat: support multiple providers via Responses-Completion transformation (#247)
    https://github.com/user-attachments/assets/9ecb51be-fa65-4e99-8512-abb898dda569
    
    Implemented it as a transformation between Responses API and Completion
    API so that it supports existing providers that implement the Completion
    API and minimizes the changes needed to the codex repo.
    
    ---------
    
    Co-authored-by: Thibault Sottiaux <tibo@openai.com>
    Co-authored-by: Fouad Matin <169186268+fouad-openai@users.noreply.github.com>
    Co-authored-by: Fouad Matin <fouad@openai.com>
  • feat: read approvalMode from config file (#298)
    This PR implements support for reading the approvalMode setting from the
    user's config file (`~/.codex/config.json` or `~/.codex/config.yaml`),
    allowing users to set a persistent default approval mode without needing
    to specify command-line flags for each session.
    
    Changes:
    - Added approvalMode to the AppConfig type in config.ts
    - Updated loadConfig() to read the approval mode from the config file
    - Modified saveConfig() to persist the approval mode setting
    - Updated CLI logic to respect the config-defined approval mode (while
    maintaining CLI flag priority)
    - Added comprehensive tests for approval mode config functionality
    - Updated README to document the new config option in both YAML and JSON
    formats
    - additions to `.gitignore` for other CLI tools
    
    Motivation:
    As a user who regularly works with CLI-tools, I found it odd to have to
    alias this with the command flags I wanted when `approvalMode` simply
    wasn't being parsed even though it was an optional prop in `config.ts`.
    This change allows me (and other users) to set the preference once in
    the config file, streamlining daily usage while maintaining the ability
    to override via command-line flags when needed.
    
    Testing:
    I've added a new test case loads and saves approvalMode correctly that
    verifies:
    - Reading the approvalMode from the config file works correctly
    - Saving the approvalMode to the config file works as expected
    - The value persists through load/save operations
    
    All tests related to the implementation are passing.
  • feat: add flex mode option for cost savings (#372)
    Adding in an option to turn on flex processing mode to reduce costs when
    running the agent.
    
    Bumped the openai typescript version to add the new feature.
    
    ---------
    
    Co-authored-by: Thibault Sottiaux <tibo@openai.com>
  • feat: notify when a newer version is available (#333)
    **Summary**  
    This change introduces a new startup check that notifies users if a
    newer `@openai/codex` version is available. To avoid spamming, it writes
    a small state file recording the last check time and will only re‑check
    once every 24 hours.
    
    **What’s Changed**  
    - **New file** `src/utils/check-updates.ts`  
      - Runs `npm outdated --global @openai/codex`  
      - Reads/writes `codex-state.json` under `CONFIG_DIR`  
      - Limits checks to once per day (`UPDATE_CHECK_FREQUENCY = 24h`)  
    - Uses `boxen` for a styled alert and `which` to locate the npm binary
    - **Hooked into** `src/cli.tsx` entrypoint:
      ```ts
      import { checkForUpdates } from "./utils/check-updates";
      // …
      // after loading config
      await checkForUpdates().catch();
      ```
    - **Dependencies**  
      - Added `boxen@^8.0.1`, `which@^5.0.0`, `@types/which@^3.0.4`  
    - **Tests**  
      - Vitest suite under `tests/check-updates.test.ts`  
      - Snapshot in `__snapshots__/check-updates.test.ts.snap`  
    
    **Motivation**  
    Addresses issue #244. Users running a stale global install will now see
    a friendly reminder—at most once per day—to upgrade and enjoy the latest
    features.
    
    **Test Plan**  
    - `getNPMCommandPath()` resolves npm correctly  
    - `checkOutdated()` parses `npm outdated` JSON  
    - State file prevents repeat alerts within 24h  
    - Boxen snapshot matches expected output  
    - No console output when state indicates a recent check  
    
    **Related Issue**  
    try resolves #244
    
    
    **Preview**
    Prompt a pnpm‑style alert when outdated  
    
    ![outdated‑alert](https://github.com/user-attachments/assets/294dad45-d858-45d1-bf34-55e672ab883a)
    
    Let me know if you’d tweak any of the messaging, throttle frequency,
    placement in the startup flow, or anything else.
    
    ---------
    
    Co-authored-by: Thibault Sottiaux <tibo@openai.com>
  • fix: standardize filename to kebab-case 🐍➡️🥙 (#302)
    Probably not the most exciting PR you’ll get today, but I noticed that
    every file in the repo follows kebab-case… except one brave little
    underscore in `cli_singlepass.tsx`.
    
    So I made the world a little more consistent. Just a filename rename —
    no logic changes, no semicolons harmed
    
    Didn’t touch any code, I promise. Just bringing order to the filesystem
    — one hyphen at a time.
  • feat: add notifications for MacOS using Applescript (#160)
    yolo'ed it with codex. Let me know if this looks good to you.
    
    https://github.com/openai/codex/issues/148
    
    tested with:
    ```
    npm run build:dev
    ```
    
    <img width="377" alt="Screenshot 2025-04-16 at 18 12 01"
    src="https://github.com/user-attachments/assets/79aa799b-b0b9-479d-84f1-bfb83d34bfb9"
    />
  • add support for -w,--writable-root to add more writable roots for sandbox (#263)
    This adds support for a new flag, `-w,--writable-root`, that can be
    specified multiple times to _amend_ the list of folders that should be
    configured as "writable roots" by the sandbox used in `full-auto` mode.
    Values that are passed as relative paths will be resolved to absolute
    paths.
    
    Incidentally, this required updating a number of the `agent*.test.ts`
    files: it feels like some of the setup logic across those tests could be
    consolidated.
    
    In my testing, it seems that this might be slightly out of distribution
    for the model, as I had to explicitly tell it to run `apply_patch` and
    that it had the permissions to write those files (initially, it just
    showed me a diff and told me to apply it myself). Nevertheless, I think
    this is a good starting point.
  • feat: --config/-c flag to open global instructions in nvim (#158)
    I promised I'd never write JavaScript code, but I never said anything
    about using AI to write it for me...entirely authored with `codex`. No
    idea how good the code is, didn't read it (sorta joking but I really
    don't know js/ts)
    
    closes #154
    
    
    https://github.com/user-attachments/assets/94cf2276-bfcf-4ba1-ad2f-aaefebbf8f06
  • feat: add shell completion subcommand (#138)
    Why
    ---
    Improves the usability of the `codex` CLI by adding shell completion for
    file paths. This allows users to quickly complete file arguments using
    tab completion in bash, zsh, and fish shells. Enable via `eval "$(codex
    completion <shell>)"`.
  • dotenv support (#122)
    Signed-off-by: Aron Jones <aron.jones@gmail.com>
  • add: release script (#96)
    * add: release script
    
    * add: src to npm module
    
    * fix: readme
    
    Signed-off-by: Fouad Matin <fouad@openai.com>
    
    ---------
    
    Signed-off-by: Fouad Matin <fouad@openai.com>
  • Update model in code to o4-mini (#39)
    Old docs had o3 as the default
  • Initial commit
    Signed-off-by: Ilan Bigio <ilan@openai.com>