@openai/codex-sdk 0.45.0-alpha.3 → 0.45.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -31
- package/package.json +1 -1
- package/vendor/aarch64-apple-darwin/codex/codex +0 -0
- package/vendor/aarch64-pc-windows-msvc/codex/codex.exe +0 -0
- package/vendor/aarch64-unknown-linux-musl/codex/codex +0 -0
- package/vendor/x86_64-apple-darwin/codex/codex +0 -0
- package/vendor/x86_64-pc-windows-msvc/codex/codex.exe +0 -0
- package/vendor/x86_64-unknown-linux-musl/codex/codex +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Codex SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Embed the Codex agent in your workflows and apps.
|
|
4
|
+
|
|
5
|
+
The TypeScript SDK wraps the bundled `codex` binary. It spawns the CLI and exchanges JSONL events over stdin/stdout.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -8,68 +10,64 @@ Bring the power of the best coding agent to your application.
|
|
|
8
10
|
npm install @openai/codex-sdk
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Requires Node.js 18+.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## Quickstart
|
|
14
16
|
|
|
15
17
|
```typescript
|
|
16
18
|
import { Codex } from "@openai/codex-sdk";
|
|
17
19
|
|
|
18
20
|
const codex = new Codex();
|
|
19
21
|
const thread = codex.startThread();
|
|
20
|
-
const
|
|
22
|
+
const turn = await thread.run("Diagnose the test failure and propose a fix");
|
|
21
23
|
|
|
22
|
-
console.log(
|
|
24
|
+
console.log(turn.finalResponse);
|
|
25
|
+
console.log(turn.items);
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
Call `run()` repeatedly on the same `Thread` instance to continue that conversation.
|
|
26
29
|
|
|
27
30
|
```typescript
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
console.log(result);
|
|
31
|
+
const nextTurn = await thread.run("Implement the fix");
|
|
31
32
|
```
|
|
32
33
|
|
|
33
|
-
### Streaming
|
|
34
|
-
|
|
35
|
-
The `run()` method completes when a thread turn is complete and the agent has produced the final response.
|
|
34
|
+
### Streaming responses
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
`run()` buffers events until the turn finishes. To react to intermediate progress—tool calls, streaming responses, and file diffs—use `runStreamed()` instead, which returns an async generator of structured events.
|
|
38
37
|
|
|
39
38
|
```typescript
|
|
40
39
|
const { events } = await thread.runStreamed("Diagnose the test failure and propose a fix");
|
|
41
40
|
|
|
42
41
|
for await (const event of events) {
|
|
43
|
-
|
|
42
|
+
switch (event.type) {
|
|
43
|
+
case "item.completed":
|
|
44
|
+
console.log("item", event.item);
|
|
45
|
+
break;
|
|
46
|
+
case "turn.completed":
|
|
47
|
+
console.log("usage", event.usage);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
```
|
|
46
52
|
|
|
47
|
-
### Resuming
|
|
53
|
+
### Resuming an existing thread
|
|
48
54
|
|
|
49
|
-
If you
|
|
55
|
+
Threads are persisted in `~/.codex/sessions`. If you lose the in-memory `Thread` object, reconstruct it with `resumeThread()` and keep going.
|
|
50
56
|
|
|
51
57
|
```typescript
|
|
52
|
-
const
|
|
53
|
-
const thread = codex.resumeThread(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log(result);
|
|
58
|
+
const savedThreadId = process.env.CODEX_THREAD_ID!;
|
|
59
|
+
const thread = codex.resumeThread(savedThreadId);
|
|
60
|
+
await thread.run("Implement the fix");
|
|
57
61
|
```
|
|
58
62
|
|
|
59
|
-
### Working directory
|
|
63
|
+
### Working directory controls
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
const thread = codex.startThread({
|
|
65
|
-
workingDirectory: "/path/to/working/directory",
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
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.
|
|
65
|
+
Codex runs in the current working directory by default. 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.
|
|
70
66
|
|
|
71
67
|
```typescript
|
|
72
68
|
const thread = codex.startThread({
|
|
69
|
+
workingDirectory: "/path/to/project",
|
|
73
70
|
skipGitRepoCheck: true,
|
|
74
71
|
});
|
|
75
72
|
```
|
|
73
|
+
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|