@codex-native/sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +379 -0
- package/codex_native.darwin-arm64.node +0 -0
- package/dist/index.d.mts +562 -0
- package/dist/index.mjs +638 -0
- package/dist/index.mjs.map +1 -0
- package/npm/darwin-arm64/README.md +3 -0
- package/npm/darwin-arm64/package.json +21 -0
- package/npm/darwin-x64/README.md +3 -0
- package/npm/darwin-x64/package.json +21 -0
- package/npm/linux-arm64-gnu/README.md +3 -0
- package/npm/linux-arm64-gnu/package.json +24 -0
- package/npm/linux-arm64-musl/README.md +3 -0
- package/npm/linux-arm64-musl/package.json +24 -0
- package/npm/linux-x64-gnu/README.md +3 -0
- package/npm/linux-x64-gnu/package.json +24 -0
- package/npm/linux-x64-musl/README.md +3 -0
- package/npm/linux-x64-musl/package.json +24 -0
- package/npm/win32-arm64-msvc/README.md +3 -0
- package/npm/win32-arm64-msvc/package.json +21 -0
- package/npm/win32-x64-msvc/README.md +3 -0
- package/npm/win32-x64-msvc/package.json +21 -0
- package/package.json +70 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { ContentBlock } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
|
|
3
|
+
/** The status of a command execution. */
|
|
4
|
+
type CommandExecutionStatus = "in_progress" | "completed" | "failed";
|
|
5
|
+
/** A command executed by the agent. */
|
|
6
|
+
type CommandExecutionItem = {
|
|
7
|
+
id: string;
|
|
8
|
+
type: "command_execution";
|
|
9
|
+
/** The command line executed by the agent. */
|
|
10
|
+
command: string;
|
|
11
|
+
/** Aggregated stdout and stderr captured while the command was running. */
|
|
12
|
+
aggregated_output: string;
|
|
13
|
+
/** Set when the command exits; omitted while still running. */
|
|
14
|
+
exit_code?: number;
|
|
15
|
+
/** Current status of the command execution. */
|
|
16
|
+
status: CommandExecutionStatus;
|
|
17
|
+
};
|
|
18
|
+
/** Indicates the type of the file change. */
|
|
19
|
+
type PatchChangeKind = "add" | "delete" | "update";
|
|
20
|
+
/** A set of file changes by the agent. */
|
|
21
|
+
type FileUpdateChange = {
|
|
22
|
+
path: string;
|
|
23
|
+
kind: PatchChangeKind;
|
|
24
|
+
};
|
|
25
|
+
/** The status of a file change. */
|
|
26
|
+
type PatchApplyStatus = "completed" | "failed";
|
|
27
|
+
/** A set of file changes by the agent. Emitted once the patch succeeds or fails. */
|
|
28
|
+
type FileChangeItem = {
|
|
29
|
+
id: string;
|
|
30
|
+
type: "file_change";
|
|
31
|
+
/** Individual file changes that comprise the patch. */
|
|
32
|
+
changes: FileUpdateChange[];
|
|
33
|
+
/** Whether the patch ultimately succeeded or failed. */
|
|
34
|
+
status: PatchApplyStatus;
|
|
35
|
+
};
|
|
36
|
+
/** The status of an MCP tool call. */
|
|
37
|
+
type McpToolCallStatus = "in_progress" | "completed" | "failed";
|
|
38
|
+
/**
|
|
39
|
+
* Represents a call to an MCP tool. The item starts when the invocation is dispatched
|
|
40
|
+
* and completes when the MCP server reports success or failure.
|
|
41
|
+
*/
|
|
42
|
+
type McpToolCallItem = {
|
|
43
|
+
id: string;
|
|
44
|
+
type: "mcp_tool_call";
|
|
45
|
+
/** Name of the MCP server handling the request. */
|
|
46
|
+
server: string;
|
|
47
|
+
/** The tool invoked on the MCP server. */
|
|
48
|
+
tool: string;
|
|
49
|
+
/** Arguments forwarded to the tool invocation. */
|
|
50
|
+
arguments: unknown;
|
|
51
|
+
/** Result payload returned by the MCP server for successful calls. */
|
|
52
|
+
result?: {
|
|
53
|
+
content: ContentBlock[];
|
|
54
|
+
structured_content: unknown;
|
|
55
|
+
};
|
|
56
|
+
/** Error message reported for failed calls. */
|
|
57
|
+
error?: {
|
|
58
|
+
message: string;
|
|
59
|
+
};
|
|
60
|
+
/** Current status of the tool invocation. */
|
|
61
|
+
status: McpToolCallStatus;
|
|
62
|
+
};
|
|
63
|
+
/** Response from the agent. Either natural-language text or JSON when structured output is requested. */
|
|
64
|
+
type AgentMessageItem = {
|
|
65
|
+
id: string;
|
|
66
|
+
type: "agent_message";
|
|
67
|
+
/** Either natural-language text or JSON when structured output is requested. */
|
|
68
|
+
text: string;
|
|
69
|
+
};
|
|
70
|
+
/** Agent's reasoning summary. */
|
|
71
|
+
type ReasoningItem = {
|
|
72
|
+
id: string;
|
|
73
|
+
type: "reasoning";
|
|
74
|
+
text: string;
|
|
75
|
+
};
|
|
76
|
+
/** Captures a web search request. Completes when results are returned to the agent. */
|
|
77
|
+
type WebSearchItem = {
|
|
78
|
+
id: string;
|
|
79
|
+
type: "web_search";
|
|
80
|
+
query: string;
|
|
81
|
+
};
|
|
82
|
+
/** Describes a non-fatal error surfaced as an item. */
|
|
83
|
+
type ErrorItem = {
|
|
84
|
+
id: string;
|
|
85
|
+
type: "error";
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
/** An item in the agent's to-do list. */
|
|
89
|
+
type TodoItem = {
|
|
90
|
+
text: string;
|
|
91
|
+
completed: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Tracks the agent's running to-do list. Starts when the plan is issued, updates as steps change,
|
|
95
|
+
* and completes when the turn ends.
|
|
96
|
+
*/
|
|
97
|
+
type TodoListItem = {
|
|
98
|
+
id: string;
|
|
99
|
+
type: "todo_list";
|
|
100
|
+
items: TodoItem[];
|
|
101
|
+
};
|
|
102
|
+
/** Canonical union of thread items and their type-specific payloads. */
|
|
103
|
+
type ThreadItem = AgentMessageItem | ReasoningItem | CommandExecutionItem | FileChangeItem | McpToolCallItem | WebSearchItem | TodoListItem | ErrorItem;
|
|
104
|
+
|
|
105
|
+
/** Emitted when a new thread is started as the first event. */
|
|
106
|
+
type ThreadStartedEvent = {
|
|
107
|
+
type: "thread.started";
|
|
108
|
+
/** The identifier of the new thread. Can be used to resume the thread later. */
|
|
109
|
+
thread_id: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Emitted when a turn is started by sending a new prompt to the model.
|
|
113
|
+
* A turn encompasses all events that happen while the agent is processing the prompt.
|
|
114
|
+
*/
|
|
115
|
+
type TurnStartedEvent = {
|
|
116
|
+
type: "turn.started";
|
|
117
|
+
};
|
|
118
|
+
/** Describes the usage of tokens during a turn. */
|
|
119
|
+
type Usage$1 = {
|
|
120
|
+
/** The number of input tokens used during the turn. */
|
|
121
|
+
input_tokens: number;
|
|
122
|
+
/** The number of cached input tokens used during the turn. */
|
|
123
|
+
cached_input_tokens: number;
|
|
124
|
+
/** The number of output tokens used during the turn. */
|
|
125
|
+
output_tokens: number;
|
|
126
|
+
};
|
|
127
|
+
/** Emitted when a turn is completed. Typically right after the assistant's response. */
|
|
128
|
+
type TurnCompletedEvent = {
|
|
129
|
+
type: "turn.completed";
|
|
130
|
+
usage: Usage$1;
|
|
131
|
+
};
|
|
132
|
+
/** Indicates that a turn failed with an error. */
|
|
133
|
+
type TurnFailedEvent = {
|
|
134
|
+
type: "turn.failed";
|
|
135
|
+
error: ThreadError;
|
|
136
|
+
};
|
|
137
|
+
/** Emitted when a new item is added to the thread. Typically the item is initially "in progress". */
|
|
138
|
+
type ItemStartedEvent = {
|
|
139
|
+
type: "item.started";
|
|
140
|
+
item: ThreadItem;
|
|
141
|
+
};
|
|
142
|
+
/** Emitted when an item is updated. */
|
|
143
|
+
type ItemUpdatedEvent = {
|
|
144
|
+
type: "item.updated";
|
|
145
|
+
item: ThreadItem;
|
|
146
|
+
};
|
|
147
|
+
/** Signals that an item has reached a terminal state—either success or failure. */
|
|
148
|
+
type ItemCompletedEvent = {
|
|
149
|
+
type: "item.completed";
|
|
150
|
+
item: ThreadItem;
|
|
151
|
+
};
|
|
152
|
+
/** Fatal error emitted by the stream. */
|
|
153
|
+
type ThreadError = {
|
|
154
|
+
message: string;
|
|
155
|
+
};
|
|
156
|
+
/** Represents an unrecoverable error emitted directly by the event stream. */
|
|
157
|
+
type ThreadErrorEvent = {
|
|
158
|
+
type: "error";
|
|
159
|
+
message: string;
|
|
160
|
+
};
|
|
161
|
+
/** Top-level JSONL events emitted by codex exec. */
|
|
162
|
+
type ThreadEvent = ThreadStartedEvent | TurnStartedEvent | TurnCompletedEvent | TurnFailedEvent | ItemStartedEvent | ItemUpdatedEvent | ItemCompletedEvent | ThreadErrorEvent;
|
|
163
|
+
|
|
164
|
+
type TurnOptions = {
|
|
165
|
+
/** JSON schema describing the expected agent output. */
|
|
166
|
+
outputSchema?: unknown;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/** Completed turn. */
|
|
170
|
+
type Turn = {
|
|
171
|
+
items: ThreadItem[];
|
|
172
|
+
finalResponse: string;
|
|
173
|
+
usage: Usage$1 | null;
|
|
174
|
+
};
|
|
175
|
+
/** Alias for `Turn` to describe the result of `run()`. */
|
|
176
|
+
type RunResult = Turn;
|
|
177
|
+
/** The result of the `runStreamed` method. */
|
|
178
|
+
type StreamedTurn = {
|
|
179
|
+
events: AsyncGenerator<ThreadEvent>;
|
|
180
|
+
};
|
|
181
|
+
/** Alias for `StreamedTurn` to describe the result of `runStreamed()`. */
|
|
182
|
+
type RunStreamedResult = StreamedTurn;
|
|
183
|
+
/** An input to send to the agent. */
|
|
184
|
+
type UserInput = {
|
|
185
|
+
type: "text";
|
|
186
|
+
text: string;
|
|
187
|
+
} | {
|
|
188
|
+
type: "local_image";
|
|
189
|
+
path: string;
|
|
190
|
+
};
|
|
191
|
+
type Input = string | UserInput[];
|
|
192
|
+
/** Respesent a thread of conversation with the agent. One thread can have multiple consecutive turns. */
|
|
193
|
+
declare class Thread {
|
|
194
|
+
private _exec;
|
|
195
|
+
private _options;
|
|
196
|
+
private _id;
|
|
197
|
+
private _threadOptions;
|
|
198
|
+
/** Returns the ID of the thread. Populated after the first turn starts. */
|
|
199
|
+
get id(): string | null;
|
|
200
|
+
/** Provides the input to the agent and streams events as they are produced during the turn. */
|
|
201
|
+
runStreamed(input: Input, turnOptions?: TurnOptions): Promise<StreamedTurn>;
|
|
202
|
+
private runStreamedInternal;
|
|
203
|
+
/** Provides the input to the agent and returns the completed turn. */
|
|
204
|
+
run(input: Input, turnOptions?: TurnOptions): Promise<Turn>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type ApprovalMode = "never" | "on-request" | "on-failure" | "untrusted";
|
|
208
|
+
type SandboxMode = "read-only" | "workspace-write" | "danger-full-access";
|
|
209
|
+
type ThreadOptions = {
|
|
210
|
+
model?: string;
|
|
211
|
+
sandboxMode?: SandboxMode;
|
|
212
|
+
workingDirectory?: string;
|
|
213
|
+
skipGitRepoCheck?: boolean;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
type NativeToolInfo = {
|
|
217
|
+
name: string;
|
|
218
|
+
description?: string;
|
|
219
|
+
parameters?: unknown;
|
|
220
|
+
strict?: boolean;
|
|
221
|
+
supportsParallel?: boolean;
|
|
222
|
+
};
|
|
223
|
+
type NativeToolInvocation = {
|
|
224
|
+
toolName: string;
|
|
225
|
+
callId: string;
|
|
226
|
+
arguments?: string;
|
|
227
|
+
input?: string;
|
|
228
|
+
};
|
|
229
|
+
type NativeToolResult = {
|
|
230
|
+
output?: string;
|
|
231
|
+
success?: boolean;
|
|
232
|
+
error?: string;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
type NativeToolDefinition = NativeToolInfo & {
|
|
236
|
+
handler: (call: NativeToolInvocation) => Promise<NativeToolResult> | NativeToolResult;
|
|
237
|
+
};
|
|
238
|
+
type CodexOptions = {
|
|
239
|
+
codexPathOverride?: string;
|
|
240
|
+
baseUrl?: string;
|
|
241
|
+
apiKey?: string;
|
|
242
|
+
tools?: NativeToolDefinition[];
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Codex is the main class for interacting with the Codex agent.
|
|
247
|
+
*
|
|
248
|
+
* This is the native NAPI-based implementation that uses Rust bindings directly.
|
|
249
|
+
*
|
|
250
|
+
* Use the `startThread()` method to start a new thread or `resumeThread()` to resume a previously started thread.
|
|
251
|
+
*/
|
|
252
|
+
declare class Codex {
|
|
253
|
+
private exec;
|
|
254
|
+
private options;
|
|
255
|
+
private readonly nativeBinding;
|
|
256
|
+
constructor(options?: CodexOptions);
|
|
257
|
+
registerTool(tool: NativeToolDefinition): void;
|
|
258
|
+
/**
|
|
259
|
+
* Starts a new conversation with an agent.
|
|
260
|
+
* @returns A new thread instance.
|
|
261
|
+
*/
|
|
262
|
+
startThread(options?: ThreadOptions): Thread;
|
|
263
|
+
/**
|
|
264
|
+
* Resumes a conversation with an agent based on the thread id.
|
|
265
|
+
* Threads are persisted in ~/.codex/sessions.
|
|
266
|
+
*
|
|
267
|
+
* @param id The id of the thread to resume.
|
|
268
|
+
* @returns A new thread instance.
|
|
269
|
+
*/
|
|
270
|
+
resumeThread(id: string, options?: ThreadOptions): Thread;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Type definitions for OpenAI Agents JS framework compatibility
|
|
275
|
+
* Based on @openai/agents-core package
|
|
276
|
+
*/
|
|
277
|
+
interface ModelProvider {
|
|
278
|
+
/**
|
|
279
|
+
* Get a model by name
|
|
280
|
+
* @param modelName - The name of the model to get.
|
|
281
|
+
*/
|
|
282
|
+
getModel(modelName?: string): Promise<Model> | Model;
|
|
283
|
+
}
|
|
284
|
+
interface Model {
|
|
285
|
+
/**
|
|
286
|
+
* Get a response from the model (buffered)
|
|
287
|
+
*/
|
|
288
|
+
getResponse(request: ModelRequest): Promise<ModelResponse>;
|
|
289
|
+
/**
|
|
290
|
+
* Get a streamed response from the model
|
|
291
|
+
*/
|
|
292
|
+
getStreamedResponse(request: ModelRequest): AsyncIterable<StreamEvent>;
|
|
293
|
+
}
|
|
294
|
+
interface ModelRequest {
|
|
295
|
+
systemInstructions?: string;
|
|
296
|
+
input: string | AgentInputItem[];
|
|
297
|
+
previousResponseId?: string;
|
|
298
|
+
conversationId?: string;
|
|
299
|
+
modelSettings: ModelSettings;
|
|
300
|
+
tools: SerializedTool[];
|
|
301
|
+
outputType: SerializedOutputType;
|
|
302
|
+
handoffs: SerializedHandoff[];
|
|
303
|
+
tracing: ModelTracing;
|
|
304
|
+
signal?: AbortSignal;
|
|
305
|
+
prompt?: Prompt;
|
|
306
|
+
overridePromptModel?: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface ModelSettings {
|
|
309
|
+
temperature?: number;
|
|
310
|
+
topP?: number;
|
|
311
|
+
frequencyPenalty?: number;
|
|
312
|
+
presencePenalty?: number;
|
|
313
|
+
toolChoice?: ModelSettingsToolChoice;
|
|
314
|
+
parallelToolCalls?: boolean;
|
|
315
|
+
truncation?: "auto" | "disabled";
|
|
316
|
+
maxTokens?: number;
|
|
317
|
+
store?: boolean;
|
|
318
|
+
reasoning?: ModelSettingsReasoning;
|
|
319
|
+
text?: ModelSettingsText;
|
|
320
|
+
providerData?: Record<string, unknown>;
|
|
321
|
+
}
|
|
322
|
+
interface ModelSettingsToolChoice {
|
|
323
|
+
type: "auto" | "required" | "none" | "function";
|
|
324
|
+
functionName?: string;
|
|
325
|
+
}
|
|
326
|
+
interface ModelSettingsReasoning {
|
|
327
|
+
type: "internal" | "explicit";
|
|
328
|
+
maxTokens?: number;
|
|
329
|
+
}
|
|
330
|
+
interface ModelSettingsText {
|
|
331
|
+
format?: {
|
|
332
|
+
type: string;
|
|
333
|
+
schema?: Record<string, unknown>;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
type AgentInputItem = InputText | InputImage | InputFile | InputAudio | InputFunctionCallResult | InputRefusal;
|
|
337
|
+
interface InputText {
|
|
338
|
+
type: "input_text";
|
|
339
|
+
text: string;
|
|
340
|
+
}
|
|
341
|
+
interface InputImage {
|
|
342
|
+
type: "input_image";
|
|
343
|
+
image: string | {
|
|
344
|
+
url: string;
|
|
345
|
+
} | {
|
|
346
|
+
fileId: string;
|
|
347
|
+
};
|
|
348
|
+
detail?: "auto" | "low" | "high";
|
|
349
|
+
}
|
|
350
|
+
interface InputFile {
|
|
351
|
+
type: "input_file";
|
|
352
|
+
file: {
|
|
353
|
+
fileId: string;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
interface InputAudio {
|
|
357
|
+
type: "input_audio";
|
|
358
|
+
audio: string | {
|
|
359
|
+
data: string;
|
|
360
|
+
format: string;
|
|
361
|
+
};
|
|
362
|
+
transcript?: string;
|
|
363
|
+
}
|
|
364
|
+
interface InputFunctionCallResult {
|
|
365
|
+
type: "function_call_result";
|
|
366
|
+
callId: string;
|
|
367
|
+
name: string;
|
|
368
|
+
result: string;
|
|
369
|
+
}
|
|
370
|
+
interface InputRefusal {
|
|
371
|
+
type: "input_refusal";
|
|
372
|
+
refusal: string;
|
|
373
|
+
}
|
|
374
|
+
interface ModelResponse {
|
|
375
|
+
usage: Usage;
|
|
376
|
+
output: AgentOutputItem[];
|
|
377
|
+
responseId?: string;
|
|
378
|
+
providerData?: Record<string, unknown>;
|
|
379
|
+
}
|
|
380
|
+
interface Usage {
|
|
381
|
+
inputTokens: number;
|
|
382
|
+
outputTokens: number;
|
|
383
|
+
totalTokens: number;
|
|
384
|
+
inputTokensDetails?: Array<Record<string, number>>;
|
|
385
|
+
outputTokensDetails?: Array<Record<string, number>>;
|
|
386
|
+
}
|
|
387
|
+
type AgentOutputItem = AssistantMessageItem | FunctionCallItem | Refusal | AudioContent | ImageContent | Reasoning;
|
|
388
|
+
interface AssistantMessageItem {
|
|
389
|
+
type: "assistant_message";
|
|
390
|
+
role: "assistant";
|
|
391
|
+
status: "in_progress" | "completed";
|
|
392
|
+
content: OutputContent[];
|
|
393
|
+
}
|
|
394
|
+
interface FunctionCallItem {
|
|
395
|
+
type: "function_call";
|
|
396
|
+
callId: string;
|
|
397
|
+
name: string;
|
|
398
|
+
arguments: string;
|
|
399
|
+
}
|
|
400
|
+
interface Refusal {
|
|
401
|
+
type: "refusal";
|
|
402
|
+
refusal: string;
|
|
403
|
+
}
|
|
404
|
+
interface AudioContent {
|
|
405
|
+
type: "audio";
|
|
406
|
+
audio: string;
|
|
407
|
+
transcript?: string;
|
|
408
|
+
}
|
|
409
|
+
interface ImageContent {
|
|
410
|
+
type: "image";
|
|
411
|
+
image: string;
|
|
412
|
+
}
|
|
413
|
+
interface Reasoning {
|
|
414
|
+
type: "reasoning";
|
|
415
|
+
reasoning: string;
|
|
416
|
+
}
|
|
417
|
+
type OutputContent = OutputText | OutputImage | OutputAudio | OutputRefusal;
|
|
418
|
+
interface OutputText {
|
|
419
|
+
type: "output_text";
|
|
420
|
+
text: string;
|
|
421
|
+
}
|
|
422
|
+
interface OutputImage {
|
|
423
|
+
type: "output_image";
|
|
424
|
+
image: string;
|
|
425
|
+
}
|
|
426
|
+
interface OutputAudio {
|
|
427
|
+
type: "output_audio";
|
|
428
|
+
audio: string;
|
|
429
|
+
transcript?: string;
|
|
430
|
+
}
|
|
431
|
+
interface OutputRefusal {
|
|
432
|
+
type: "output_refusal";
|
|
433
|
+
refusal: string;
|
|
434
|
+
}
|
|
435
|
+
type StreamEvent = ResponseStartedEvent | OutputTextDeltaEvent | OutputTextDoneEvent | OutputAudioDeltaEvent | OutputAudioDoneEvent | FunctionCallArgumentsDeltaEvent | FunctionCallArgumentsDoneEvent | ReasoningDeltaEvent | ReasoningDoneEvent | ResponseDoneEvent | ErrorEvent;
|
|
436
|
+
interface ResponseStartedEvent {
|
|
437
|
+
type: "response_started";
|
|
438
|
+
}
|
|
439
|
+
interface OutputTextDeltaEvent {
|
|
440
|
+
type: "output_text_delta";
|
|
441
|
+
delta: string;
|
|
442
|
+
}
|
|
443
|
+
interface OutputTextDoneEvent {
|
|
444
|
+
type: "output_text_done";
|
|
445
|
+
text: string;
|
|
446
|
+
}
|
|
447
|
+
interface OutputAudioDeltaEvent {
|
|
448
|
+
type: "output_audio_delta";
|
|
449
|
+
delta: string;
|
|
450
|
+
}
|
|
451
|
+
interface OutputAudioDoneEvent {
|
|
452
|
+
type: "output_audio_done";
|
|
453
|
+
audio: string;
|
|
454
|
+
transcript?: string;
|
|
455
|
+
}
|
|
456
|
+
interface FunctionCallArgumentsDeltaEvent {
|
|
457
|
+
type: "function_call_arguments_delta";
|
|
458
|
+
callId: string;
|
|
459
|
+
name: string;
|
|
460
|
+
delta: string;
|
|
461
|
+
}
|
|
462
|
+
interface FunctionCallArgumentsDoneEvent {
|
|
463
|
+
type: "function_call_arguments_done";
|
|
464
|
+
callId: string;
|
|
465
|
+
name: string;
|
|
466
|
+
arguments: string;
|
|
467
|
+
}
|
|
468
|
+
interface ReasoningDeltaEvent {
|
|
469
|
+
type: "reasoning_delta";
|
|
470
|
+
delta: string;
|
|
471
|
+
}
|
|
472
|
+
interface ReasoningDoneEvent {
|
|
473
|
+
type: "reasoning_done";
|
|
474
|
+
reasoning: string;
|
|
475
|
+
}
|
|
476
|
+
interface ResponseDoneEvent {
|
|
477
|
+
type: "response_done";
|
|
478
|
+
response: ModelResponse;
|
|
479
|
+
}
|
|
480
|
+
interface ErrorEvent {
|
|
481
|
+
type: "error";
|
|
482
|
+
error: {
|
|
483
|
+
message: string;
|
|
484
|
+
code?: string;
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
interface SerializedTool {
|
|
488
|
+
type: "function";
|
|
489
|
+
name: string;
|
|
490
|
+
description?: string;
|
|
491
|
+
parameters?: Record<string, unknown>;
|
|
492
|
+
}
|
|
493
|
+
interface SerializedOutputType {
|
|
494
|
+
type: "json_schema";
|
|
495
|
+
schema: Record<string, unknown>;
|
|
496
|
+
}
|
|
497
|
+
interface SerializedHandoff {
|
|
498
|
+
name: string;
|
|
499
|
+
description?: string;
|
|
500
|
+
}
|
|
501
|
+
interface ModelTracing {
|
|
502
|
+
enabled: boolean;
|
|
503
|
+
metadata?: Record<string, unknown>;
|
|
504
|
+
}
|
|
505
|
+
interface Prompt {
|
|
506
|
+
model?: string;
|
|
507
|
+
template?: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Options for creating a CodexProvider
|
|
512
|
+
*/
|
|
513
|
+
interface CodexProviderOptions extends CodexOptions {
|
|
514
|
+
/**
|
|
515
|
+
* Default model to use when none is specified
|
|
516
|
+
*/
|
|
517
|
+
defaultModel?: string;
|
|
518
|
+
/**
|
|
519
|
+
* Working directory for Codex operations
|
|
520
|
+
* @default process.cwd()
|
|
521
|
+
*/
|
|
522
|
+
workingDirectory?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Skip git repository check
|
|
525
|
+
* @default false
|
|
526
|
+
*/
|
|
527
|
+
skipGitRepoCheck?: boolean;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Provider implementation that uses Codex as the backend for OpenAI Agents
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* import { CodexProvider } from '@openai/codex-native/agents';
|
|
535
|
+
* import { Agent, Runner } from '@openai/agents';
|
|
536
|
+
*
|
|
537
|
+
* const provider = new CodexProvider({
|
|
538
|
+
* apiKey: process.env.CODEX_API_KEY,
|
|
539
|
+
* defaultModel: 'claude-sonnet-4.5'
|
|
540
|
+
* });
|
|
541
|
+
*
|
|
542
|
+
* const agent = new Agent({
|
|
543
|
+
* name: 'CodeAssistant',
|
|
544
|
+
* instructions: 'You are a helpful coding assistant'
|
|
545
|
+
* });
|
|
546
|
+
*
|
|
547
|
+
* const runner = new Runner({ modelProvider: provider });
|
|
548
|
+
* const result = await runner.run(agent, 'Fix the failing tests');
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
declare class CodexProvider implements ModelProvider {
|
|
552
|
+
private codex;
|
|
553
|
+
private options;
|
|
554
|
+
constructor(options?: CodexProviderOptions);
|
|
555
|
+
/**
|
|
556
|
+
* Lazy initialization of Codex instance
|
|
557
|
+
*/
|
|
558
|
+
private getCodex;
|
|
559
|
+
getModel(modelName?: string): Model;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export { type AgentMessageItem, type ApprovalMode, Codex, type CodexOptions, CodexProvider, type CodexProviderOptions, type CommandExecutionItem, type ErrorItem, type FileChangeItem, type Input, type ItemCompletedEvent, type ItemStartedEvent, type ItemUpdatedEvent, type McpToolCallItem, type NativeToolDefinition, type NativeToolInvocation, type NativeToolResult, 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$1 as Usage, type UserInput, type WebSearchItem };
|