Misc SDK fixes (#4752)

Remove codex-level workingDirectory
Throw on turn.failed in `run()`
Cleanup readme
This commit is contained in:
pakrym-oai
2025-10-04 19:55:33 -07:00
committed by GitHub
parent 4764fc1ee7
commit 356ea6ea34
6 changed files with 47 additions and 16 deletions

View File

@@ -10,7 +10,7 @@ npm install @openai/codex-sdk
## Usage
Call `startThread()` and `run()` to start a thead with Codex.
Call `startThread()` and `run()` to start a thread with Codex.
```typescript
import { Codex } from "@openai/codex-sdk";
@@ -32,17 +32,21 @@ console.log(result);
### Streaming
The `await run()` method completes when a thread turn is complete and agent is prepared the final response.
The `run()` method completes when a thread turn is complete and the agent has produced the final response.
You can thread items while they are being produced by calling `await runStreamed()`.
You can stream events while they are being produced by calling `runStreamed()` and iterating the returned generator.
```typescript
const result = thread.runStreamed("Diagnose the test failure and propose a fix");
const { events } = await thread.runStreamed("Diagnose the test failure and propose a fix");
for await (const event of events) {
console.log(event);
}
```
### Resuming a thread
If you don't have the original `Thread` instance to continue the thread, you can resume a thread by calling `resumeThread()` and providing the thread.
If you don't have the original `Thread` instance to continue the thread, you can resume by calling `resumeThread()` and providing the thread identifier.
```typescript
const threadId = "...";
@@ -54,7 +58,7 @@ console.log(result);
### Working directory
By default, Codex will run in the current working directory. You can change the working directory by passing the `workingDirectory` option to the when creating a thread.
By default, Codex will run in the current working directory. You can change the working directory by passing the `workingDirectory` option when creating a thread.
```typescript
const thread = codex.startThread({
@@ -62,7 +66,7 @@ const thread = codex.startThread({
});
```
To avoid unrecoverable errors, Codex requires the working directory to be a git repository. You can skip the git repository check by passing the `skipGitRepoCheck` option to the when creating a thread.
To avoid unrecoverable errors, Codex requires the working directory to be a Git repository. You can skip the Git repository check by passing the `skipGitRepoCheck` option when creating a thread.
```typescript
const thread = codex.startThread({