@openai/codex-sdk 0.48.0-alpha.1 → 0.48.0-alpha.2

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 CHANGED
@@ -83,6 +83,18 @@ const turn = await thread.run("Summarize repository status", {
83
83
  console.log(turn.finalResponse);
84
84
  ```
85
85
 
86
+ ### Attaching images
87
+
88
+ Provide structured input entries when you need to include images alongside text. Text entries are concatenated into the final prompt while image entries are passed to the Codex CLI via `--image`.
89
+
90
+ ```typescript
91
+ const turn = await thread.run([
92
+ { type: "text", text: "Describe these screenshots" },
93
+ { type: "local_image", path: "./ui.png" },
94
+ { type: "local_image", path: "./diagram.jpg" },
95
+ ]);
96
+ ```
97
+
86
98
  ### Resuming an existing thread
87
99
 
88
100
  Threads are persisted in `~/.codex/sessions`. If you lose the in-memory `Thread` object, reconstruct it with `resumeThread()` and keep going.
@@ -95,7 +107,7 @@ await thread.run("Implement the fix");
95
107
 
96
108
  ### Working directory controls
97
109
 
98
- 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.
110
+ 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.
99
111
 
100
112
  ```typescript
101
113
  const thread = codex.startThread({
package/dist/index.d.ts CHANGED
@@ -168,7 +168,14 @@ type StreamedTurn = {
168
168
  /** Alias for `StreamedTurn` to describe the result of `runStreamed()`. */
169
169
  type RunStreamedResult = StreamedTurn;
170
170
  /** An input to send to the agent. */
171
- type Input = string;
171
+ type UserInput = {
172
+ type: "text";
173
+ text: string;
174
+ } | {
175
+ type: "local_image";
176
+ path: string;
177
+ };
178
+ type Input = string | UserInput[];
172
179
  /** Respesent a thread of conversation with the agent. One thread can have multiple consecutive turns. */
173
180
  declare class Thread {
174
181
  private _exec;
@@ -178,10 +185,10 @@ declare class Thread {
178
185
  /** Returns the ID of the thread. Populated after the first turn starts. */
179
186
  get id(): string | null;
180
187
  /** Provides the input to the agent and streams events as they are produced during the turn. */
181
- runStreamed(input: string, turnOptions?: TurnOptions): Promise<StreamedTurn>;
188
+ runStreamed(input: Input, turnOptions?: TurnOptions): Promise<StreamedTurn>;
182
189
  private runStreamedInternal;
183
190
  /** Provides the input to the agent and returns the completed turn. */
184
- run(input: string, turnOptions?: TurnOptions): Promise<Turn>;
191
+ run(input: Input, turnOptions?: TurnOptions): Promise<Turn>;
185
192
  }
186
193
 
187
194
  type CodexOptions = {
@@ -223,4 +230,4 @@ declare class Codex {
223
230
  resumeThread(id: string, options?: ThreadOptions): Thread;
224
231
  }
225
232
 
226
- export { type AgentMessageItem, type ApprovalMode, Codex, type CodexOptions, type CommandExecutionItem, type ErrorItem, type FileChangeItem, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type McpToolCallItem, type ReasoningItem, type RunResult, type RunStreamedResult, type SandboxMode, Thread, type ThreadError, type ThreadErrorEvent, type ThreadEvent, type ThreadItem, type ThreadOptions, type ThreadStartedEvent, type TodoListItem, type TurnCompletedEvent, type TurnFailedEvent, type TurnOptions, type TurnStartedEvent, type Usage, type WebSearchItem };
233
+ export { type AgentMessageItem, type ApprovalMode, Codex, type CodexOptions, type CommandExecutionItem, type ErrorItem, type FileChangeItem, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type McpToolCallItem, type ReasoningItem, type RunResult, type RunStreamedResult, type SandboxMode, Thread, type ThreadError, type ThreadErrorEvent, type ThreadEvent, type ThreadItem, type ThreadOptions, type ThreadStartedEvent, type TodoListItem, type TurnCompletedEvent, type TurnFailedEvent, type TurnOptions, type TurnStartedEvent, type Usage, type UserInput, type WebSearchItem };
package/dist/index.js CHANGED
@@ -54,11 +54,13 @@ var Thread = class {
54
54
  async *runStreamedInternal(input, turnOptions = {}) {
55
55
  const { schemaPath, cleanup } = await createOutputSchemaFile(turnOptions.outputSchema);
56
56
  const options = this._threadOptions;
57
+ const { prompt, images } = normalizeInput(input);
57
58
  const generator = this._exec.run({
58
- input,
59
+ input: prompt,
59
60
  baseUrl: this._options.baseUrl,
60
61
  apiKey: this._options.apiKey,
61
62
  threadId: this._id,
63
+ images,
62
64
  model: options?.model,
63
65
  sandboxMode: options?.sandboxMode,
64
66
  workingDirectory: options?.workingDirectory,
@@ -108,6 +110,21 @@ var Thread = class {
108
110
  return { items, finalResponse, usage };
109
111
  }
110
112
  };
113
+ function normalizeInput(input) {
114
+ if (typeof input === "string") {
115
+ return { prompt: input, images: [] };
116
+ }
117
+ const promptParts = [];
118
+ const images = [];
119
+ for (const item of input) {
120
+ if (item.type === "text") {
121
+ promptParts.push(item.text);
122
+ } else if (item.type === "local_image") {
123
+ images.push(item.path);
124
+ }
125
+ }
126
+ return { prompt: promptParts.join("\n\n"), images };
127
+ }
111
128
 
112
129
  // src/exec.ts
113
130
  import { spawn } from "child_process";
@@ -138,6 +155,11 @@ var CodexExec = class {
138
155
  if (args.outputSchemaFile) {
139
156
  commandArgs.push("--output-schema", args.outputSchemaFile);
140
157
  }
158
+ if (args.images?.length) {
159
+ for (const image of args.images) {
160
+ commandArgs.push("--image", image);
161
+ }
162
+ }
141
163
  if (args.threadId) {
142
164
  commandArgs.push("resume", args.threadId);
143
165
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/outputSchemaFile.ts","../src/thread.ts","../src/exec.ts","../src/codex.ts"],"sourcesContent":["import { promises as fs } from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nexport type OutputSchemaFile = {\n schemaPath?: string;\n cleanup: () => Promise<void>;\n};\n\nexport async function createOutputSchemaFile(schema: unknown): Promise<OutputSchemaFile> {\n if (schema === undefined) {\n return { cleanup: async () => {} };\n }\n\n if (!isJsonObject(schema)) {\n throw new Error(\"outputSchema must be a plain JSON object\");\n }\n\n const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), \"codex-output-schema-\"));\n const schemaPath = path.join(schemaDir, \"schema.json\");\n const cleanup = async () => {\n try {\n await fs.rm(schemaDir, { recursive: true, force: true });\n }\n catch {\n // suppress\n }\n };\n\n try {\n await fs.writeFile(schemaPath, JSON.stringify(schema), \"utf8\");\n return { schemaPath, cleanup };\n } catch (error) {\n await cleanup();\n throw error;\n }\n}\n\nfunction isJsonObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import { CodexOptions } from \"./codexOptions\";\nimport { ThreadEvent, ThreadError, Usage } from \"./events\";\nimport { CodexExec } from \"./exec\";\nimport { ThreadItem } from \"./items\";\nimport { ThreadOptions } from \"./threadOptions\";\nimport { TurnOptions } from \"./turnOptions\";\nimport { createOutputSchemaFile } from \"./outputSchemaFile\";\n\n/** Completed turn. */\nexport type Turn = {\n items: ThreadItem[];\n finalResponse: string;\n usage: Usage | null;\n};\n\n/** Alias for `Turn` to describe the result of `run()`. */\nexport type RunResult = Turn;\n\n/** The result of the `runStreamed` method. */\nexport type StreamedTurn = {\n events: AsyncGenerator<ThreadEvent>;\n};\n\n/** Alias for `StreamedTurn` to describe the result of `runStreamed()`. */\nexport type RunStreamedResult = StreamedTurn;\n\n/** An input to send to the agent. */\nexport type Input = string;\n\n/** Respesent a thread of conversation with the agent. One thread can have multiple consecutive turns. */\nexport class Thread {\n private _exec: CodexExec;\n private _options: CodexOptions;\n private _id: string | null;\n private _threadOptions: ThreadOptions;\n\n /** Returns the ID of the thread. Populated after the first turn starts. */\n public get id(): string | null {\n return this._id;\n }\n\n /* @internal */\n constructor(\n exec: CodexExec,\n options: CodexOptions,\n threadOptions: ThreadOptions,\n id: string | null = null,\n ) {\n this._exec = exec;\n this._options = options;\n this._id = id;\n this._threadOptions = threadOptions;\n }\n\n /** Provides the input to the agent and streams events as they are produced during the turn. */\n async runStreamed(input: string, turnOptions: TurnOptions = {}): Promise<StreamedTurn> {\n return { events: this.runStreamedInternal(input, turnOptions) };\n }\n\n private async *runStreamedInternal(\n input: string,\n turnOptions: TurnOptions = {},\n ): AsyncGenerator<ThreadEvent> {\n const { schemaPath, cleanup } = await createOutputSchemaFile(turnOptions.outputSchema);\n const options = this._threadOptions;\n const generator = this._exec.run({\n input,\n baseUrl: this._options.baseUrl,\n apiKey: this._options.apiKey,\n threadId: this._id,\n model: options?.model,\n sandboxMode: options?.sandboxMode,\n workingDirectory: options?.workingDirectory,\n skipGitRepoCheck: options?.skipGitRepoCheck,\n outputSchemaFile: schemaPath,\n });\n try {\n for await (const item of generator) {\n let parsed: ThreadEvent;\n try {\n parsed = JSON.parse(item) as ThreadEvent;\n } catch (error) {\n throw new Error(`Failed to parse item: ${item}`, { cause: error });\n }\n if (parsed.type === \"thread.started\") {\n this._id = parsed.thread_id;\n }\n yield parsed;\n }\n } finally {\n await cleanup();\n }\n }\n\n /** Provides the input to the agent and returns the completed turn. */\n async run(input: string, turnOptions: TurnOptions = {}): Promise<Turn> {\n const generator = this.runStreamedInternal(input, turnOptions);\n const items: ThreadItem[] = [];\n let finalResponse: string = \"\";\n let usage: Usage | null = null;\n let turnFailure: ThreadError | null = null;\n for await (const event of generator) {\n if (event.type === \"item.completed\") {\n if (event.item.type === \"agent_message\") {\n finalResponse = event.item.text;\n }\n items.push(event.item);\n } else if (event.type === \"turn.completed\") {\n usage = event.usage;\n } else if (event.type === \"turn.failed\") {\n turnFailure = event.error;\n break;\n }\n }\n if (turnFailure) {\n throw new Error(turnFailure.message);\n }\n return { items, finalResponse, usage };\n }\n}\n","import { spawn } from \"node:child_process\";\nimport path from \"node:path\";\nimport readline from \"node:readline\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { SandboxMode } from \"./threadOptions\";\n\nexport type CodexExecArgs = {\n input: string;\n\n baseUrl?: string;\n apiKey?: string;\n threadId?: string | null;\n // --model\n model?: string;\n // --sandbox\n sandboxMode?: SandboxMode;\n // --cd\n workingDirectory?: string;\n // --skip-git-repo-check\n skipGitRepoCheck?: boolean;\n // --output-schema\n outputSchemaFile?: string;\n};\n\nconst INTERNAL_ORIGINATOR_ENV = \"CODEX_INTERNAL_ORIGINATOR_OVERRIDE\";\nconst TYPESCRIPT_SDK_ORIGINATOR = \"codex_sdk_ts\";\n\nexport class CodexExec {\n private executablePath: string;\n constructor(executablePath: string | null = null) {\n this.executablePath = executablePath || findCodexPath();\n }\n\n async *run(args: CodexExecArgs): AsyncGenerator<string> {\n const commandArgs: string[] = [\"exec\", \"--experimental-json\"];\n\n if (args.model) {\n commandArgs.push(\"--model\", args.model);\n }\n\n if (args.sandboxMode) {\n commandArgs.push(\"--sandbox\", args.sandboxMode);\n }\n\n if (args.workingDirectory) {\n commandArgs.push(\"--cd\", args.workingDirectory);\n }\n\n if (args.skipGitRepoCheck) {\n commandArgs.push(\"--skip-git-repo-check\");\n }\n\n if (args.outputSchemaFile) {\n commandArgs.push(\"--output-schema\", args.outputSchemaFile);\n }\n\n if (args.threadId) {\n commandArgs.push(\"resume\", args.threadId);\n }\n\n const env = {\n ...process.env,\n };\n if (!env[INTERNAL_ORIGINATOR_ENV]) {\n env[INTERNAL_ORIGINATOR_ENV] = TYPESCRIPT_SDK_ORIGINATOR;\n }\n if (args.baseUrl) {\n env.OPENAI_BASE_URL = args.baseUrl;\n }\n if (args.apiKey) {\n env.CODEX_API_KEY = args.apiKey;\n }\n\n const child = spawn(this.executablePath, commandArgs, {\n env,\n });\n\n let spawnError: unknown | null = null;\n child.once(\"error\", (err) => (spawnError = err));\n\n if (!child.stdin) {\n child.kill();\n throw new Error(\"Child process has no stdin\");\n }\n child.stdin.write(args.input);\n child.stdin.end();\n\n if (!child.stdout) {\n child.kill();\n throw new Error(\"Child process has no stdout\");\n }\n const stderrChunks: Buffer[] = [];\n\n if (child.stderr) {\n child.stderr.on(\"data\", (data) => {\n stderrChunks.push(data);\n });\n }\n\n const rl = readline.createInterface({\n input: child.stdout,\n crlfDelay: Infinity,\n });\n\n try {\n for await (const line of rl) {\n // `line` is a string (Node sets default encoding to utf8 for readline)\n yield line as string;\n }\n\n const exitCode = new Promise((resolve, reject) => {\n child.once(\"exit\", (code) => {\n if (code === 0) {\n resolve(code);\n } else {\n const stderrBuffer = Buffer.concat(stderrChunks);\n reject(\n new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString(\"utf8\")}`),\n );\n }\n });\n });\n\n if (spawnError) throw spawnError;\n await exitCode;\n } finally {\n rl.close();\n child.removeAllListeners();\n try {\n if (!child.killed) child.kill();\n } catch {\n // ignore\n }\n }\n }\n}\n\nconst scriptFileName = fileURLToPath(import.meta.url);\nconst scriptDirName = path.dirname(scriptFileName);\n\nfunction findCodexPath() {\n const { platform, arch } = process;\n\n let targetTriple = null;\n switch (platform) {\n case \"linux\":\n case \"android\":\n switch (arch) {\n case \"x64\":\n targetTriple = \"x86_64-unknown-linux-musl\";\n break;\n case \"arm64\":\n targetTriple = \"aarch64-unknown-linux-musl\";\n break;\n default:\n break;\n }\n break;\n case \"darwin\":\n switch (arch) {\n case \"x64\":\n targetTriple = \"x86_64-apple-darwin\";\n break;\n case \"arm64\":\n targetTriple = \"aarch64-apple-darwin\";\n break;\n default:\n break;\n }\n break;\n case \"win32\":\n switch (arch) {\n case \"x64\":\n targetTriple = \"x86_64-pc-windows-msvc\";\n break;\n case \"arm64\":\n targetTriple = \"aarch64-pc-windows-msvc\";\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n\n if (!targetTriple) {\n throw new Error(`Unsupported platform: ${platform} (${arch})`);\n }\n\n const vendorRoot = path.join(scriptDirName, \"..\", \"vendor\");\n const archRoot = path.join(vendorRoot, targetTriple);\n const codexBinaryName = process.platform === \"win32\" ? \"codex.exe\" : \"codex\";\n const binaryPath = path.join(archRoot, \"codex\", codexBinaryName);\n\n return binaryPath;\n}\n","import { CodexOptions } from \"./codexOptions\";\nimport { CodexExec } from \"./exec\";\nimport { Thread } from \"./thread\";\nimport { ThreadOptions } from \"./threadOptions\";\n\n/**\n * Codex is the main class for interacting with the Codex agent.\n *\n * Use the `startThread()` method to start a new thread or `resumeThread()` to resume a previously started thread.\n */\nexport class Codex {\n private exec: CodexExec;\n private options: CodexOptions;\n\n constructor(options: CodexOptions = {}) {\n this.exec = new CodexExec(options.codexPathOverride);\n this.options = options;\n }\n\n /**\n * Starts a new conversation with an agent.\n * @returns A new thread instance.\n */\n startThread(options: ThreadOptions = {}): Thread {\n return new Thread(this.exec, this.options, options);\n }\n\n /**\n * Resumes a conversation with an agent based on the thread id.\n * Threads are persisted in ~/.codex/sessions.\n *\n * @param id The id of the thread to resume.\n * @returns A new thread instance.\n */\n resumeThread(id: string, options: ThreadOptions = {}): Thread {\n return new Thread(this.exec, this.options, options, id);\n }\n}\n"],"mappings":";AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,QAAQ;AACf,OAAO,UAAU;AAOjB,eAAsB,uBAAuB,QAA4C;AACvF,MAAI,WAAW,QAAW;AACxB,WAAO,EAAE,SAAS,YAAY;AAAA,IAAC,EAAE;AAAA,EACnC;AAEA,MAAI,CAAC,aAAa,MAAM,GAAG;AACzB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAEA,QAAM,YAAY,MAAM,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,sBAAsB,CAAC;AACjF,QAAM,aAAa,KAAK,KAAK,WAAW,aAAa;AACrD,QAAM,UAAU,YAAY;AAC1B,QAAI;AACF,YAAM,GAAG,GAAG,WAAW,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACzD,QACO;AAAA,IAEP;AAAA,EACF;AAEA,MAAI;AACF,UAAM,GAAG,UAAU,YAAY,KAAK,UAAU,MAAM,GAAG,MAAM;AAC7D,WAAO,EAAE,YAAY,QAAQ;AAAA,EAC/B,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM;AAAA,EACR;AACF;AAEA,SAAS,aAAa,OAAkD;AACtE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;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AC3LO,IAAM,QAAN,MAAY;AAAA,EACT;AAAA,EACA;AAAA,EAER,YAAY,UAAwB,CAAC,GAAG;AACtC,SAAK,OAAO,IAAI,UAAU,QAAQ,iBAAiB;AACnD,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,UAAyB,CAAC,GAAW;AAC/C,WAAO,IAAI,OAAO,KAAK,MAAM,KAAK,SAAS,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,IAAY,UAAyB,CAAC,GAAW;AAC5D,WAAO,IAAI,OAAO,KAAK,MAAM,KAAK,SAAS,SAAS,EAAE;AAAA,EACxD;AACF;","names":["path"]}
1
+ {"version":3,"sources":["../src/outputSchemaFile.ts","../src/thread.ts","../src/exec.ts","../src/codex.ts"],"sourcesContent":["import { promises as fs } from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nexport type OutputSchemaFile = {\n schemaPath?: string;\n cleanup: () => Promise<void>;\n};\n\nexport async function createOutputSchemaFile(schema: unknown): Promise<OutputSchemaFile> {\n if (schema === undefined) {\n return { cleanup: async () => {} };\n }\n\n if (!isJsonObject(schema)) {\n throw new Error(\"outputSchema must be a plain JSON object\");\n }\n\n const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), \"codex-output-schema-\"));\n const schemaPath = path.join(schemaDir, \"schema.json\");\n const cleanup = async () => {\n try {\n await fs.rm(schemaDir, { recursive: true, force: true });\n }\n catch {\n // suppress\n }\n };\n\n try {\n await fs.writeFile(schemaPath, JSON.stringify(schema), \"utf8\");\n return { schemaPath, cleanup };\n } catch (error) {\n await cleanup();\n throw error;\n }\n}\n\nfunction isJsonObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import { CodexOptions } from \"./codexOptions\";\nimport { ThreadEvent, ThreadError, Usage } from \"./events\";\nimport { CodexExec } from \"./exec\";\nimport { ThreadItem } from \"./items\";\nimport { ThreadOptions } from \"./threadOptions\";\nimport { TurnOptions } from \"./turnOptions\";\nimport { createOutputSchemaFile } from \"./outputSchemaFile\";\n\n/** Completed turn. */\nexport type Turn = {\n items: ThreadItem[];\n finalResponse: string;\n usage: Usage | null;\n};\n\n/** Alias for `Turn` to describe the result of `run()`. */\nexport type RunResult = Turn;\n\n/** The result of the `runStreamed` method. */\nexport type StreamedTurn = {\n events: AsyncGenerator<ThreadEvent>;\n};\n\n/** Alias for `StreamedTurn` to describe the result of `runStreamed()`. */\nexport type RunStreamedResult = StreamedTurn;\n\n/** An input to send to the agent. */\nexport type UserInput =\n | {\n type: \"text\";\n text: string;\n }\n | {\n type: \"local_image\";\n path: string;\n };\n\nexport type Input = string | UserInput[];\n\n/** Respesent a thread of conversation with the agent. One thread can have multiple consecutive turns. */\nexport class Thread {\n private _exec: CodexExec;\n private _options: CodexOptions;\n private _id: string | null;\n private _threadOptions: ThreadOptions;\n\n /** Returns the ID of the thread. Populated after the first turn starts. */\n public get id(): string | null {\n return this._id;\n }\n\n /* @internal */\n constructor(\n exec: CodexExec,\n options: CodexOptions,\n threadOptions: ThreadOptions,\n id: string | null = null,\n ) {\n this._exec = exec;\n this._options = options;\n this._id = id;\n this._threadOptions = threadOptions;\n }\n\n /** Provides the input to the agent and streams events as they are produced during the turn. */\n async runStreamed(input: Input, turnOptions: TurnOptions = {}): Promise<StreamedTurn> {\n return { events: this.runStreamedInternal(input, turnOptions) };\n }\n\n private async *runStreamedInternal(\n input: Input,\n turnOptions: TurnOptions = {},\n ): AsyncGenerator<ThreadEvent> {\n const { schemaPath, cleanup } = await createOutputSchemaFile(turnOptions.outputSchema);\n const options = this._threadOptions;\n const { prompt, images } = normalizeInput(input);\n const generator = this._exec.run({\n input: prompt,\n baseUrl: this._options.baseUrl,\n apiKey: this._options.apiKey,\n threadId: this._id,\n images,\n model: options?.model,\n sandboxMode: options?.sandboxMode,\n workingDirectory: options?.workingDirectory,\n skipGitRepoCheck: options?.skipGitRepoCheck,\n outputSchemaFile: schemaPath,\n });\n try {\n for await (const item of generator) {\n let parsed: ThreadEvent;\n try {\n parsed = JSON.parse(item) as ThreadEvent;\n } catch (error) {\n throw new Error(`Failed to parse item: ${item}`, { cause: error });\n }\n if (parsed.type === \"thread.started\") {\n this._id = parsed.thread_id;\n }\n yield parsed;\n }\n } finally {\n await cleanup();\n }\n }\n\n /** Provides the input to the agent and returns the completed turn. */\n async run(input: Input, turnOptions: TurnOptions = {}): Promise<Turn> {\n const generator = this.runStreamedInternal(input, turnOptions);\n const items: ThreadItem[] = [];\n let finalResponse: string = \"\";\n let usage: Usage | null = null;\n let turnFailure: ThreadError | null = null;\n for await (const event of generator) {\n if (event.type === \"item.completed\") {\n if (event.item.type === \"agent_message\") {\n finalResponse = event.item.text;\n }\n items.push(event.item);\n } else if (event.type === \"turn.completed\") {\n usage = event.usage;\n } else if (event.type === \"turn.failed\") {\n turnFailure = event.error;\n break;\n }\n }\n if (turnFailure) {\n throw new Error(turnFailure.message);\n }\n return { items, finalResponse, usage };\n }\n}\n\nfunction normalizeInput(input: Input): { prompt: string; images: string[] } {\n if (typeof input === \"string\") {\n return { prompt: input, images: [] };\n }\n const promptParts: string[] = [];\n const images: string[] = [];\n for (const item of input) {\n if (item.type === \"text\") {\n promptParts.push(item.text);\n } else if (item.type === \"local_image\") {\n images.push(item.path);\n }\n }\n return { prompt: promptParts.join(\"\\n\\n\"), images };\n}\n","import { spawn } from \"node:child_process\";\nimport path from \"node:path\";\nimport readline from \"node:readline\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { SandboxMode } from \"./threadOptions\";\n\nexport type CodexExecArgs = {\n input: string;\n\n baseUrl?: string;\n apiKey?: string;\n threadId?: string | null;\n images?: string[];\n // --model\n model?: string;\n // --sandbox\n sandboxMode?: SandboxMode;\n // --cd\n workingDirectory?: string;\n // --skip-git-repo-check\n skipGitRepoCheck?: boolean;\n // --output-schema\n outputSchemaFile?: string;\n};\n\nconst INTERNAL_ORIGINATOR_ENV = \"CODEX_INTERNAL_ORIGINATOR_OVERRIDE\";\nconst TYPESCRIPT_SDK_ORIGINATOR = \"codex_sdk_ts\";\n\nexport class CodexExec {\n private executablePath: string;\n constructor(executablePath: string | null = null) {\n this.executablePath = executablePath || findCodexPath();\n }\n\n async *run(args: CodexExecArgs): AsyncGenerator<string> {\n const commandArgs: string[] = [\"exec\", \"--experimental-json\"];\n\n if (args.model) {\n commandArgs.push(\"--model\", args.model);\n }\n\n if (args.sandboxMode) {\n commandArgs.push(\"--sandbox\", args.sandboxMode);\n }\n\n if (args.workingDirectory) {\n commandArgs.push(\"--cd\", args.workingDirectory);\n }\n\n if (args.skipGitRepoCheck) {\n commandArgs.push(\"--skip-git-repo-check\");\n }\n\n if (args.outputSchemaFile) {\n commandArgs.push(\"--output-schema\", args.outputSchemaFile);\n }\n\n if (args.images?.length) {\n for (const image of args.images) {\n commandArgs.push(\"--image\", image);\n }\n }\n\n if (args.threadId) {\n commandArgs.push(\"resume\", args.threadId);\n }\n\n const env = {\n ...process.env,\n };\n if (!env[INTERNAL_ORIGINATOR_ENV]) {\n env[INTERNAL_ORIGINATOR_ENV] = TYPESCRIPT_SDK_ORIGINATOR;\n }\n if (args.baseUrl) {\n env.OPENAI_BASE_URL = args.baseUrl;\n }\n if (args.apiKey) {\n env.CODEX_API_KEY = args.apiKey;\n }\n\n const child = spawn(this.executablePath, commandArgs, {\n env,\n });\n\n let spawnError: unknown | null = null;\n child.once(\"error\", (err) => (spawnError = err));\n\n if (!child.stdin) {\n child.kill();\n throw new Error(\"Child process has no stdin\");\n }\n child.stdin.write(args.input);\n child.stdin.end();\n\n if (!child.stdout) {\n child.kill();\n throw new Error(\"Child process has no stdout\");\n }\n const stderrChunks: Buffer[] = [];\n\n if (child.stderr) {\n child.stderr.on(\"data\", (data) => {\n stderrChunks.push(data);\n });\n }\n\n const rl = readline.createInterface({\n input: child.stdout,\n crlfDelay: Infinity,\n });\n\n try {\n for await (const line of rl) {\n // `line` is a string (Node sets default encoding to utf8 for readline)\n yield line as string;\n }\n\n const exitCode = new Promise((resolve, reject) => {\n child.once(\"exit\", (code) => {\n if (code === 0) {\n resolve(code);\n } else {\n const stderrBuffer = Buffer.concat(stderrChunks);\n reject(\n new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString(\"utf8\")}`),\n );\n }\n });\n });\n\n if (spawnError) throw spawnError;\n await exitCode;\n } finally {\n rl.close();\n child.removeAllListeners();\n try {\n if (!child.killed) child.kill();\n } catch {\n // ignore\n }\n }\n }\n}\n\nconst scriptFileName = fileURLToPath(import.meta.url);\nconst scriptDirName = path.dirname(scriptFileName);\n\nfunction findCodexPath() {\n const { platform, arch } = process;\n\n let targetTriple = null;\n switch (platform) {\n case \"linux\":\n case \"android\":\n switch (arch) {\n case \"x64\":\n targetTriple = \"x86_64-unknown-linux-musl\";\n break;\n case \"arm64\":\n targetTriple = \"aarch64-unknown-linux-musl\";\n break;\n default:\n break;\n }\n break;\n case \"darwin\":\n switch (arch) {\n case \"x64\":\n targetTriple = \"x86_64-apple-darwin\";\n break;\n case \"arm64\":\n targetTriple = \"aarch64-apple-darwin\";\n break;\n default:\n break;\n }\n break;\n case \"win32\":\n switch (arch) {\n case \"x64\":\n targetTriple = \"x86_64-pc-windows-msvc\";\n break;\n case \"arm64\":\n targetTriple = \"aarch64-pc-windows-msvc\";\n break;\n default:\n break;\n }\n break;\n default:\n break;\n }\n\n if (!targetTriple) {\n throw new Error(`Unsupported platform: ${platform} (${arch})`);\n }\n\n const vendorRoot = path.join(scriptDirName, \"..\", \"vendor\");\n const archRoot = path.join(vendorRoot, targetTriple);\n const codexBinaryName = process.platform === \"win32\" ? \"codex.exe\" : \"codex\";\n const binaryPath = path.join(archRoot, \"codex\", codexBinaryName);\n\n return binaryPath;\n}\n","import { CodexOptions } from \"./codexOptions\";\nimport { CodexExec } from \"./exec\";\nimport { Thread } from \"./thread\";\nimport { ThreadOptions } from \"./threadOptions\";\n\n/**\n * Codex is the main class for interacting with the Codex agent.\n *\n * Use the `startThread()` method to start a new thread or `resumeThread()` to resume a previously started thread.\n */\nexport class Codex {\n private exec: CodexExec;\n private options: CodexOptions;\n\n constructor(options: CodexOptions = {}) {\n this.exec = new CodexExec(options.codexPathOverride);\n this.options = options;\n }\n\n /**\n * Starts a new conversation with an agent.\n * @returns A new thread instance.\n */\n startThread(options: ThreadOptions = {}): Thread {\n return new Thread(this.exec, this.options, options);\n }\n\n /**\n * Resumes a conversation with an agent based on the thread id.\n * Threads are persisted in ~/.codex/sessions.\n *\n * @param id The id of the thread to resume.\n * @returns A new thread instance.\n */\n resumeThread(id: string, options: ThreadOptions = {}): Thread {\n return new Thread(this.exec, this.options, options, id);\n }\n}\n"],"mappings":";AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,QAAQ;AACf,OAAO,UAAU;AAOjB,eAAsB,uBAAuB,QAA4C;AACvF,MAAI,WAAW,QAAW;AACxB,WAAO,EAAE,SAAS,YAAY;AAAA,IAAC,EAAE;AAAA,EACnC;AAEA,MAAI,CAAC,aAAa,MAAM,GAAG;AACzB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAEA,QAAM,YAAY,MAAM,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,sBAAsB,CAAC;AACjF,QAAM,aAAa,KAAK,KAAK,WAAW,aAAa;AACrD,QAAM,UAAU,YAAY;AAC1B,QAAI;AACF,YAAM,GAAG,GAAG,WAAW,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACzD,QACO;AAAA,IAEP;AAAA,EACF;AAEA,MAAI;AACF,UAAM,GAAG,UAAU,YAAY,KAAK,UAAU,MAAM,GAAG,MAAM;AAC7D,WAAO,EAAE,YAAY,QAAQ;AAAA,EAC/B,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM;AAAA,EACR;AACF;AAEA,SAAS,aAAa,OAAkD;AACtE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM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;AACA;AAAA,IACF,KAAK;AACH,cAAQ,MAAM;AAAA,QACZ,KAAK;AACH,yBAAe;AACf;AAAA,QACF,KAAK;AACH,yBAAe;AACf;AAAA,QACF;AACE;AAAA,MACJ;AACA;AAAA,IACF,KAAK;AACH,cAAQ,MAAM;AAAA,QACZ,KAAK;AACH,yBAAe;AACf;AAAA,QACF,KAAK;AACH,yBAAe;AACf;AAAA,QACF;AACE;AAAA,MACJ;AACA;AAAA,IACF;AACE;AAAA,EACJ;AAEA,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,yBAAyB,QAAQ,KAAK,IAAI,GAAG;AAAA,EAC/D;AAEA,QAAM,aAAaA,MAAK,KAAK,eAAe,MAAM,QAAQ;AAC1D,QAAM,WAAWA,MAAK,KAAK,YAAY,YAAY;AACnD,QAAM,kBAAkB,QAAQ,aAAa,UAAU,cAAc;AACrE,QAAM,aAAaA,MAAK,KAAK,UAAU,SAAS,eAAe;AAE/D,SAAO;AACT;;;AClMO,IAAM,QAAN,MAAY;AAAA,EACT;AAAA,EACA;AAAA,EAER,YAAY,UAAwB,CAAC,GAAG;AACtC,SAAK,OAAO,IAAI,UAAU,QAAQ,iBAAiB;AACnD,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,UAAyB,CAAC,GAAW;AAC/C,WAAO,IAAI,OAAO,KAAK,MAAM,KAAK,SAAS,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,IAAY,UAAyB,CAAC,GAAW;AAC5D,WAAO,IAAI,OAAO,KAAK,MAAM,KAAK,SAAS,SAAS,EAAE;AAAA,EACxD;AACF;","names":["path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openai/codex-sdk",
3
- "version": "0.48.0-alpha.1",
3
+ "version": "0.48.0-alpha.2",
4
4
  "description": "TypeScript SDK for Codex APIs.",
5
5
  "repository": {
6
6
  "type": "git",