mirror of
https://github.com/openai/codex.git
synced 2026-05-03 21:01:55 +03:00
feat(ts-sdk): allow overriding CLI environment (#6648)
## Summary - add an `env` option for the TypeScript Codex client and plumb it into `CodexExec` so the CLI can run without inheriting `process.env` - extend the test spy to capture spawn environments, add coverage for the new option, and document how to use it ## Testing - `pnpm test` *(fails: corepack cannot download pnpm because outbound network access is blocked in the sandbox)* ------ [Codex Task](https://chatgpt.com/codex/tasks/task_i_6916b2d7c7548322a72d61d91a2dac85)
This commit is contained in:
@@ -115,3 +115,19 @@ const thread = codex.startThread({
|
||||
skipGitRepoCheck: true,
|
||||
});
|
||||
```
|
||||
|
||||
### Controlling the Codex CLI environment
|
||||
|
||||
By default, the Codex CLI inherits the Node.js process environment. Provide the optional `env` parameter when instantiating the
|
||||
`Codex` client to fully control which variables the CLI receives—useful for sandboxed hosts like Electron apps.
|
||||
|
||||
```typescript
|
||||
const codex = new Codex({
|
||||
env: {
|
||||
PATH: "/usr/local/bin",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
The SDK still injects its required variables (such as `OPENAI_BASE_URL` and `CODEX_API_KEY`) on top of the environment you
|
||||
provide.
|
||||
|
||||
Reference in New Issue
Block a user