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

@@ -2,5 +2,4 @@ export type CodexOptions = {
codexPathOverride?: string;
baseUrl?: string;
apiKey?: string;
workingDirectory?: string;
};

View File

@@ -30,4 +30,4 @@ export { Codex } from "./codex";
export type { CodexOptions } from "./codexOptions";
export type { ThreadOptions as TheadOptions, ApprovalMode, SandboxMode } from "./threadOptions";
export type { ThreadOptions, ApprovalMode, SandboxMode } from "./threadOptions";

View File

@@ -1,5 +1,5 @@
import { CodexOptions } from "./codexOptions";
import { ThreadEvent, Usage } from "./events";
import { ThreadEvent, ThreadError, Usage } from "./events";
import { CodexExec } from "./exec";
import { ThreadItem } from "./items";
import { ThreadOptions } from "./threadOptions";
@@ -87,6 +87,7 @@ export class Thread {
const items: ThreadItem[] = [];
let finalResponse: string = "";
let usage: Usage | null = null;
let turnFailure: ThreadError | null = null;
for await (const event of generator) {
if (event.type === "item.completed") {
if (event.item.type === "agent_message") {
@@ -95,8 +96,14 @@ export class Thread {
items.push(event.item);
} else if (event.type === "turn.completed") {
usage = event.usage;
} else if (event.type === "turn.failed") {
turnFailure = event.error;
break;
}
}
if (turnFailure) {
throw new Error(turnFailure.message);
}
return { items, finalResponse, usage };
}
}