ai-sdk-provider-codex-cli 1.3.1 → 2.0.0

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/dist/index.d.cts DELETED
@@ -1,806 +0,0 @@
1
- import { ProviderV3, LanguageModelV3, UnsupportedFunctionalityError } from '@ai-sdk/provider';
2
- import { ZodType } from 'zod';
3
-
4
- /**
5
- * Logger interface for custom logging.
6
- */
7
- interface Logger {
8
- debug: (message: string) => void;
9
- info: (message: string) => void;
10
- warn: (message: string) => void;
11
- error: (message: string) => void;
12
- }
13
- /**
14
- * Known Codex-capable model IDs with string fallback for forward compatibility.
15
- */
16
- type CodexModelId = 'gpt-5.5' | 'gpt-5.3-codex' | 'gpt-5.2-codex' | 'gpt-5.2-codex-max' | 'gpt-5.2-codex-mini' | 'gpt-5.1' | 'gpt-5.2' | (string & {});
17
- type ApprovalMode = 'untrusted' | 'on-failure' | 'on-request' | 'never';
18
- type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
19
- type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
20
- /**
21
- * Reasoning summary detail level for exec mode.
22
- */
23
- type ReasoningSummary = 'auto' | 'detailed';
24
- type ReasoningSummaryFormat = 'none' | 'experimental';
25
- type ModelVerbosity = 'low' | 'medium' | 'high';
26
- interface McpServerBase {
27
- enabled?: boolean;
28
- startupTimeoutSec?: number;
29
- toolTimeoutSec?: number;
30
- enabledTools?: string[];
31
- disabledTools?: string[];
32
- }
33
- interface McpServerStdio extends McpServerBase {
34
- transport: 'stdio';
35
- command: string;
36
- args?: string[];
37
- env?: Record<string, string>;
38
- cwd?: string;
39
- }
40
- interface McpServerHttp extends McpServerBase {
41
- transport: 'http';
42
- url: string;
43
- bearerToken?: string;
44
- bearerTokenEnvVar?: string;
45
- httpHeaders?: Record<string, string>;
46
- envHttpHeaders?: Record<string, string>;
47
- }
48
- type McpServerConfig = McpServerStdio | McpServerHttp;
49
- type CodexConfigOverrideValue = string | number | boolean | object;
50
- interface CodexSharedSettings {
51
- cwd?: string;
52
- approvalMode?: ApprovalMode;
53
- sandboxMode?: SandboxMode;
54
- env?: Record<string, string>;
55
- verbose?: boolean;
56
- logger?: Logger | false;
57
- reasoningEffort?: ReasoningEffort;
58
- reasoningSummary?: ReasoningSummary;
59
- reasoningSummaryFormat?: ReasoningSummaryFormat;
60
- modelVerbosity?: ModelVerbosity;
61
- mcpServers?: Record<string, McpServerConfig>;
62
- rmcpClient?: boolean;
63
- configOverrides?: Record<string, CodexConfigOverrideValue>;
64
- }
65
- interface CodexSharedProviderOptions {
66
- reasoningEffort?: ReasoningEffort;
67
- reasoningSummary?: ReasoningSummary;
68
- reasoningSummaryFormat?: ReasoningSummaryFormat;
69
- textVerbosity?: ModelVerbosity;
70
- mcpServers?: Record<string, McpServerConfig>;
71
- rmcpClient?: boolean;
72
- configOverrides?: Record<string, CodexConfigOverrideValue>;
73
- }
74
-
75
- interface CodexExecSettings extends CodexSharedSettings {
76
- codexPath?: string;
77
- addDirs?: string[];
78
- fullAuto?: boolean;
79
- dangerouslyBypassApprovalsAndSandbox?: boolean;
80
- skipGitRepoCheck?: boolean;
81
- color?: 'always' | 'never' | 'auto';
82
- allowNpx?: boolean;
83
- outputLastMessageFile?: string;
84
- profile?: string;
85
- oss?: boolean;
86
- webSearch?: boolean;
87
- configOverrides?: Record<string, CodexConfigOverrideValue>;
88
- }
89
- interface CodexExecProviderSettings {
90
- defaultSettings?: CodexExecSettings;
91
- }
92
- /**
93
- * Per-call overrides supplied through AI SDK providerOptions.
94
- */
95
- interface CodexExecProviderOptions extends CodexSharedProviderOptions {
96
- addDirs?: string[];
97
- }
98
- type CodexCliSettings = CodexExecSettings;
99
- type CodexCliProviderSettings = CodexExecProviderSettings;
100
- type CodexCliProviderOptions = CodexExecProviderOptions;
101
-
102
- type JsonRpcId = number | string;
103
- interface JsonRpcRequest {
104
- id: JsonRpcId;
105
- method: string;
106
- params?: unknown;
107
- }
108
- interface JsonRpcResponse<T = unknown> {
109
- id: JsonRpcId;
110
- result: T;
111
- }
112
- interface JsonRpcError {
113
- code: number;
114
- message: string;
115
- data?: unknown;
116
- }
117
- interface JsonRpcErrorResponse {
118
- id: JsonRpcId | null;
119
- error: JsonRpcError;
120
- }
121
- interface JsonRpcNotification {
122
- method: string;
123
- params?: Record<string, unknown>;
124
- }
125
- type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse | JsonRpcErrorResponse | JsonRpcNotification;
126
- interface ModelInfo {
127
- id: string;
128
- name?: string | null;
129
- modelProvider?: string | null;
130
- description?: string | null;
131
- isDefault?: boolean | null;
132
- [k: string]: unknown;
133
- }
134
- interface Thread {
135
- id: string;
136
- preview?: string;
137
- modelProvider?: string;
138
- createdAt?: number;
139
- [k: string]: unknown;
140
- }
141
- interface ThreadStartParams {
142
- model?: string | null;
143
- modelProvider?: string | null;
144
- cwd?: string | null;
145
- approvalPolicy?: unknown;
146
- sandbox?: unknown;
147
- config?: Record<string, unknown> | null;
148
- baseInstructions?: string | null;
149
- developerInstructions?: string | null;
150
- personality?: 'none' | 'friendly' | 'pragmatic' | null;
151
- ephemeral?: boolean | null;
152
- experimentalRawEvents: boolean;
153
- persistExtendedHistory: boolean;
154
- }
155
- interface ThreadStartResponse {
156
- thread: Thread;
157
- model: string;
158
- modelProvider: string;
159
- cwd: string;
160
- approvalPolicy: unknown;
161
- sandbox: unknown;
162
- reasoningEffort: string | null;
163
- }
164
- interface ThreadResumeParams {
165
- threadId: string;
166
- history?: unknown[] | null;
167
- path?: string | null;
168
- model?: string | null;
169
- modelProvider?: string | null;
170
- cwd?: string | null;
171
- approvalPolicy?: unknown;
172
- sandbox?: unknown;
173
- config?: Record<string, unknown> | null;
174
- baseInstructions?: string | null;
175
- developerInstructions?: string | null;
176
- personality?: 'none' | 'friendly' | 'pragmatic' | null;
177
- persistExtendedHistory: boolean;
178
- }
179
- type ThreadResumeResponse = ThreadStartResponse;
180
- type UserInput = {
181
- type: 'text';
182
- text: string;
183
- text_elements: unknown[];
184
- } | {
185
- type: 'image';
186
- url?: string;
187
- imageUrl?: string;
188
- } | {
189
- type: 'localImage';
190
- path: string;
191
- } | {
192
- type: 'skill';
193
- name: string;
194
- path: string;
195
- } | {
196
- type: 'mention';
197
- name: string;
198
- path: string;
199
- };
200
- interface TurnStartParams {
201
- threadId: string;
202
- input: UserInput[];
203
- cwd?: string | null;
204
- approvalPolicy?: unknown;
205
- sandboxPolicy?: unknown;
206
- model?: string | null;
207
- effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | null;
208
- summary?: 'auto' | 'concise' | 'detailed' | 'none' | null;
209
- personality?: 'none' | 'friendly' | 'pragmatic' | null;
210
- outputSchema?: unknown;
211
- collaborationMode?: unknown;
212
- }
213
- type CodexErrorInfo = 'contextWindowExceeded' | 'usageLimitExceeded' | 'serverOverloaded' | 'internalServerError' | 'unauthorized' | 'badRequest' | 'threadRollbackFailed' | 'sandboxError' | 'other' | {
214
- httpConnectionFailed: {
215
- httpStatusCode: number | null;
216
- };
217
- } | {
218
- responseStreamConnectionFailed: {
219
- httpStatusCode: number | null;
220
- };
221
- } | {
222
- responseStreamDisconnected: {
223
- httpStatusCode: number | null;
224
- };
225
- } | {
226
- responseTooManyFailedAttempts: {
227
- httpStatusCode: number | null;
228
- };
229
- };
230
- interface TurnError {
231
- message: string;
232
- codexErrorInfo: CodexErrorInfo | null;
233
- additionalDetails: string | null;
234
- }
235
- type TurnStatus = 'completed' | 'interrupted' | 'failed' | 'inProgress';
236
- type UserMessageItem = {
237
- type: 'userMessage';
238
- id: string;
239
- content: UserInput[];
240
- };
241
- type AgentMessageItem = {
242
- type: 'agentMessage';
243
- id: string;
244
- text: string;
245
- phase: string | null;
246
- };
247
- type PlanItem = {
248
- type: 'plan';
249
- id: string;
250
- text: string;
251
- };
252
- type ReasoningItem = {
253
- type: 'reasoning';
254
- id: string;
255
- summary: string[];
256
- content: string[];
257
- };
258
- type CommandExecutionItem = {
259
- type: 'commandExecution';
260
- id: string;
261
- command: string;
262
- cwd: string;
263
- processId: string | null;
264
- status: string;
265
- commandActions: unknown[];
266
- aggregatedOutput: string | null;
267
- exitCode: number | null;
268
- durationMs: number | null;
269
- };
270
- type FileChangeItem = {
271
- type: 'fileChange';
272
- id: string;
273
- changes: unknown[];
274
- status: string;
275
- };
276
- type McpToolCallItem = {
277
- type: 'mcpToolCall';
278
- id: string;
279
- server: string;
280
- tool: string;
281
- status: string;
282
- arguments: unknown;
283
- result: unknown | null;
284
- error: unknown | null;
285
- durationMs: number | null;
286
- };
287
- type CollabAgentToolCallItem = {
288
- type: 'collabAgentToolCall';
289
- id: string;
290
- tool: string;
291
- status: string;
292
- senderThreadId: string;
293
- receiverThreadIds: string[];
294
- prompt: string | null;
295
- agentsStates: Record<string, unknown>;
296
- };
297
- type WebSearchItem = {
298
- type: 'webSearch';
299
- id: string;
300
- query: string;
301
- action: unknown | null;
302
- };
303
- type ImageViewItem = {
304
- type: 'imageView';
305
- id: string;
306
- path: string;
307
- };
308
- type EnteredReviewModeItem = {
309
- type: 'enteredReviewMode';
310
- id: string;
311
- review: string;
312
- };
313
- type ExitedReviewModeItem = {
314
- type: 'exitedReviewMode';
315
- id: string;
316
- review: string;
317
- };
318
- type ContextCompactionItem = {
319
- type: 'contextCompaction';
320
- id: string;
321
- };
322
- type ThreadItem = UserMessageItem | AgentMessageItem | PlanItem | ReasoningItem | CommandExecutionItem | FileChangeItem | McpToolCallItem | CollabAgentToolCallItem | WebSearchItem | ImageViewItem | EnteredReviewModeItem | ExitedReviewModeItem | ContextCompactionItem;
323
- interface Turn {
324
- id: string;
325
- items: ThreadItem[];
326
- status: TurnStatus;
327
- error: TurnError | null;
328
- }
329
- interface TurnStartResponse {
330
- turn: Turn;
331
- }
332
- interface TurnInterruptParams {
333
- threadId: string;
334
- turnId: string;
335
- }
336
- type TurnInterruptResponse = Record<string, never>;
337
- interface ThreadStartedNotification {
338
- thread: Thread;
339
- }
340
- interface TurnStartedNotification {
341
- threadId: string;
342
- turn: Turn;
343
- }
344
- interface TurnCompletedNotification {
345
- threadId: string;
346
- turn: Turn;
347
- }
348
- interface ItemStartedNotification {
349
- item: ThreadItem;
350
- threadId: string;
351
- turnId: string;
352
- }
353
- interface ItemCompletedNotification {
354
- item: ThreadItem;
355
- threadId: string;
356
- turnId: string;
357
- }
358
- interface ErrorNotification {
359
- error: TurnError;
360
- willRetry: boolean;
361
- threadId: string;
362
- turnId: string;
363
- [k: string]: unknown;
364
- }
365
- interface CommandExecutionRequestApprovalParams {
366
- threadId: string;
367
- turnId: string;
368
- itemId: string;
369
- approvalId?: string | null;
370
- reason?: string | null;
371
- networkApprovalContext?: unknown | null;
372
- command?: string | null;
373
- cwd?: string | null;
374
- commandActions?: unknown[] | null;
375
- proposedExecpolicyAmendment?: unknown | null;
376
- }
377
- interface CommandExecutionRequestApprovalResponse {
378
- decision: 'accept' | 'acceptForSession' | 'decline' | 'cancel' | {
379
- acceptWithExecpolicyAmendment: {
380
- execpolicy_amendment: unknown;
381
- };
382
- };
383
- }
384
- interface FileChangeRequestApprovalParams {
385
- threadId: string;
386
- turnId: string;
387
- itemId: string;
388
- reason?: string | null;
389
- grantRoot?: string | null;
390
- }
391
- interface FileChangeRequestApprovalResponse {
392
- decision: 'accept' | 'acceptForSession' | 'decline' | 'cancel';
393
- }
394
- interface SkillRequestApprovalParams {
395
- itemId: string;
396
- skillName: string;
397
- }
398
- interface SkillRequestApprovalResponse {
399
- decision: 'approve' | 'decline';
400
- }
401
- interface ToolRequestUserInputParams {
402
- threadId: string;
403
- turnId: string;
404
- itemId: string;
405
- questions: unknown[];
406
- }
407
- interface ToolRequestUserInputResponse {
408
- answers: Record<string, unknown>;
409
- }
410
- type McpServerElicitationAction = 'accept' | 'decline' | 'cancel';
411
- interface McpServerElicitationRequestParams {
412
- threadId: string;
413
- /** Nullable: the elicitation may arrive outside of an active turn. */
414
- turnId?: string | null;
415
- serverName: string;
416
- /** 'form' requests carry message/requestedSchema; 'url' requests carry url/elicitationId. */
417
- mode?: string;
418
- message?: string;
419
- requestedSchema?: unknown;
420
- url?: string;
421
- elicitationId?: string;
422
- /**
423
- * For MCP tool approval elicitations, Codex sets
424
- * `codex_approval_kind: 'mcp_tool_call'` and may include `persist` hints.
425
- */
426
- _meta?: Record<string, unknown> | null;
427
- }
428
- interface McpServerElicitationRequestResponse {
429
- action: McpServerElicitationAction;
430
- /** Structured user input for accepted elicitations; null for decline/cancel. */
431
- content?: Record<string, unknown> | null;
432
- }
433
- interface DynamicToolCallParams {
434
- threadId: string;
435
- turnId: string;
436
- callId: string;
437
- tool: string;
438
- arguments: unknown;
439
- }
440
- interface DynamicToolCallResponse {
441
- contentItems: unknown[];
442
- success: boolean;
443
- }
444
- interface ChatgptAuthTokensRefreshParams {
445
- reason: string;
446
- previousAccountId?: string | null;
447
- }
448
- interface ChatgptAuthTokensRefreshResponse {
449
- accessToken: string;
450
- chatgptAccountId: string;
451
- chatgptPlanType: string | null;
452
- }
453
-
454
- interface LocalToolDefinition<TParams = unknown, TResult = unknown> {
455
- name: string;
456
- description: string;
457
- parameters: ZodType<TParams>;
458
- execute: (params: TParams) => Promise<TResult>;
459
- }
460
- interface LocalTool {
461
- name: string;
462
- description: string;
463
- inputSchema: Record<string, unknown>;
464
- execute: (params: unknown) => Promise<unknown>;
465
- }
466
- declare function tool<TParams, TResult>(definition: LocalToolDefinition<TParams, TResult>): LocalTool;
467
-
468
- interface LocalMcpServerOptions {
469
- name: string;
470
- tools: LocalTool[];
471
- port?: number;
472
- host?: string;
473
- allowNonLoopbackHost?: boolean;
474
- }
475
- interface LocalMcpServer {
476
- config: McpServerHttp;
477
- url: string;
478
- port: number;
479
- stop: () => Promise<void>;
480
- }
481
- declare function createLocalMcpServer(options: LocalMcpServerOptions): Promise<LocalMcpServer>;
482
-
483
- declare const SDK_MCP_SERVER_MARKER: unique symbol;
484
- interface SdkMcpServer {
485
- readonly [SDK_MCP_SERVER_MARKER]: true;
486
- readonly name: string;
487
- readonly cacheKey?: string;
488
- readonly tools: LocalTool[];
489
- _server?: LocalMcpServer;
490
- _start(): Promise<LocalMcpServer['config']>;
491
- _stop(): Promise<void>;
492
- }
493
- interface SdkMcpServerOptions {
494
- name: string;
495
- cacheKey?: string;
496
- tools: LocalTool[];
497
- }
498
- declare function createSdkMcpServer(options: SdkMcpServerOptions): SdkMcpServer;
499
-
500
- type AppServerThreadMode = 'stateless' | 'persistent';
501
- type AppServerPersonality = 'none' | 'friendly' | 'pragmatic';
502
- type AppServerReasoningSummary = 'auto' | 'concise' | 'detailed' | 'none';
503
- type AppServerApprovalPolicy = 'untrusted' | 'on-failure' | 'on-request' | 'never' | {
504
- reject: {
505
- sandbox_approval: boolean;
506
- rules: boolean;
507
- mcp_elicitations: boolean;
508
- };
509
- };
510
- type AppServerSandboxPolicy = 'read-only' | 'workspace-write' | 'danger-full-access' | {
511
- type: 'dangerFullAccess';
512
- } | {
513
- type: 'readOnly';
514
- access?: unknown;
515
- } | {
516
- type: 'externalSandbox';
517
- networkAccess?: 'restricted' | 'enabled';
518
- } | {
519
- type: 'workspaceWrite';
520
- writableRoots?: string[];
521
- readOnlyAccess?: unknown;
522
- networkAccess?: boolean;
523
- excludeTmpdirEnvVar?: boolean;
524
- excludeSlashTmp?: boolean;
525
- };
526
- type AppServerUserInput = {
527
- type: 'text';
528
- text: string;
529
- } | {
530
- type: 'image';
531
- imageUrl: string;
532
- } | {
533
- type: 'localImage';
534
- path: string;
535
- };
536
- /**
537
- * Live session handle for an active app-server thread.
538
- *
539
- * Session callbacks are most useful in streaming flows where you can inject
540
- * follow-up instructions while a turn is still running.
541
- */
542
- interface CodexAppServerSession {
543
- readonly threadId: string;
544
- readonly turnId: string | null;
545
- /**
546
- * Injects an additional user message into the current thread.
547
- */
548
- injectMessage(content: string | AppServerUserInput[]): Promise<void>;
549
- /**
550
- * Requests interruption of the currently running turn.
551
- */
552
- interrupt(): Promise<void>;
553
- /**
554
- * Returns whether this session currently has an active turn.
555
- */
556
- isActive(): boolean;
557
- }
558
- interface AppServerCommandExecutionApprovalRequest {
559
- id: JsonRpcId;
560
- method: 'item/commandExecution/requestApproval';
561
- params: CommandExecutionRequestApprovalParams;
562
- }
563
- interface AppServerFileChangeApprovalRequest {
564
- id: JsonRpcId;
565
- method: 'item/fileChange/requestApproval';
566
- params: FileChangeRequestApprovalParams;
567
- }
568
- interface AppServerSkillApprovalRequest {
569
- id: JsonRpcId;
570
- method: 'skill/requestApproval';
571
- params: SkillRequestApprovalParams;
572
- }
573
- interface AppServerMcpElicitationRequest {
574
- id: JsonRpcId;
575
- method: 'mcpServer/elicitation/request';
576
- params: McpServerElicitationRequestParams;
577
- }
578
- interface AppServerToolRequestUserInputRequest {
579
- id: JsonRpcId;
580
- method: 'item/tool/requestUserInput';
581
- params: ToolRequestUserInputParams;
582
- }
583
- interface AppServerDynamicToolCallRequest {
584
- id: JsonRpcId;
585
- method: 'item/tool/call';
586
- params: DynamicToolCallParams;
587
- }
588
- interface AppServerAuthRefreshRequest {
589
- id: JsonRpcId;
590
- method: 'account/chatgptAuthTokens/refresh';
591
- params: ChatgptAuthTokensRefreshParams;
592
- }
593
- interface AppServerUnhandledRequest {
594
- id: JsonRpcId;
595
- method: string;
596
- params: Record<string, unknown>;
597
- }
598
- /**
599
- * Typed handlers for server-initiated JSON-RPC requests.
600
- *
601
- * Handler precedence:
602
- * 1) per-call provider options
603
- * 2) provider default settings
604
- * 3) built-in defaults in the RPC client
605
- * 4) `onUnhandled` fallback
606
- */
607
- interface CodexAppServerRequestHandlers {
608
- onCommandExecutionApproval?: (request: AppServerCommandExecutionApprovalRequest) => Promise<CommandExecutionRequestApprovalResponse | undefined>;
609
- onFileChangeApproval?: (request: AppServerFileChangeApprovalRequest) => Promise<FileChangeRequestApprovalResponse | undefined>;
610
- onSkillApproval?: (request: AppServerSkillApprovalRequest) => Promise<SkillRequestApprovalResponse | undefined>;
611
- /**
612
- * Handles `mcpServer/elicitation/request` (Codex >= 0.139), which includes
613
- * MCP tool call approvals (`params._meta.codex_approval_kind === 'mcp_tool_call'`).
614
- * Built-in default: accept tool call approvals when `autoApprove` is true,
615
- * decline all other elicitations.
616
- */
617
- onMcpElicitation?: (request: AppServerMcpElicitationRequest) => Promise<McpServerElicitationRequestResponse | undefined>;
618
- onToolRequestUserInput?: (request: AppServerToolRequestUserInputRequest) => Promise<ToolRequestUserInputResponse | undefined>;
619
- onDynamicToolCall?: (request: AppServerDynamicToolCallRequest) => Promise<DynamicToolCallResponse | undefined>;
620
- onAuthRefresh?: (request: AppServerAuthRefreshRequest) => Promise<ChatgptAuthTokensRefreshResponse | undefined>;
621
- onUnhandled?: (request: AppServerUnhandledRequest) => Promise<unknown>;
622
- }
623
- type AppServerMcpServerConfig = McpServerConfig | SdkMcpServer;
624
- /**
625
- * Provider-level and model-level settings for Codex app-server mode.
626
- */
627
- interface CodexAppServerSettings {
628
- codexPath?: string;
629
- cwd?: string;
630
- env?: Record<string, string>;
631
- verbose?: boolean;
632
- logger?: Logger | false;
633
- personality?: AppServerPersonality;
634
- effort?: ReasoningEffort;
635
- summary?: AppServerReasoningSummary;
636
- approvalPolicy?: AppServerApprovalPolicy;
637
- sandboxPolicy?: AppServerSandboxPolicy;
638
- baseInstructions?: string;
639
- developerInstructions?: string;
640
- mcpServers?: Record<string, AppServerMcpServerConfig>;
641
- rmcpClient?: boolean;
642
- configOverrides?: Record<string, CodexConfigOverrideValue>;
643
- autoApprove?: boolean;
644
- persistExtendedHistory?: boolean;
645
- connectionTimeoutMs?: number;
646
- requestTimeoutMs?: number;
647
- idleTimeoutMs?: number;
648
- minCodexVersion?: string;
649
- threadMode?: AppServerThreadMode;
650
- resume?: string;
651
- includeRawChunks?: boolean;
652
- serverRequests?: CodexAppServerRequestHandlers;
653
- onSessionCreated?: (session: CodexAppServerSession) => void | Promise<void>;
654
- }
655
- /**
656
- * Factory options passed to `createCodexAppServer`.
657
- */
658
- interface CodexAppServerProviderSettings {
659
- defaultSettings?: CodexAppServerSettings;
660
- }
661
- /**
662
- * Per-request overrides passed via `providerOptions['codex-app-server']`.
663
- */
664
- interface CodexAppServerProviderOptions {
665
- threadId?: string;
666
- resume?: string;
667
- threadMode?: AppServerThreadMode;
668
- includeRawChunks?: boolean;
669
- personality?: AppServerPersonality;
670
- effort?: ReasoningEffort;
671
- summary?: AppServerReasoningSummary;
672
- approvalPolicy?: AppServerApprovalPolicy;
673
- sandboxPolicy?: AppServerSandboxPolicy;
674
- baseInstructions?: string;
675
- developerInstructions?: string;
676
- mcpServers?: Record<string, AppServerMcpServerConfig>;
677
- rmcpClient?: boolean;
678
- configOverrides?: Record<string, CodexConfigOverrideValue>;
679
- autoApprove?: boolean;
680
- persistExtendedHistory?: boolean;
681
- serverRequests?: Partial<CodexAppServerRequestHandlers>;
682
- onSessionCreated?: (session: CodexAppServerSession) => void | Promise<void>;
683
- }
684
-
685
- interface CodexExecProvider extends ProviderV3 {
686
- (modelId: CodexModelId, settings?: CodexExecSettings): LanguageModelV3;
687
- languageModel(modelId: CodexModelId, settings?: CodexExecSettings): LanguageModelV3;
688
- chat(modelId: CodexModelId, settings?: CodexExecSettings): LanguageModelV3;
689
- embeddingModel(modelId: string): never;
690
- imageModel(modelId: string): never;
691
- }
692
- declare function createCodexExec(options?: CodexExecProviderSettings): CodexExecProvider;
693
- declare const codexExec: CodexExecProvider;
694
-
695
- interface CodexAppServerModelListResult {
696
- models: ModelInfo[];
697
- defaultModel?: ModelInfo;
698
- nextCursor?: string | null;
699
- }
700
- /**
701
- * Provider interface for the persistent Codex app-server transport.
702
- *
703
- * Use this via `createCodexAppServer()` or the default `codexAppServer` export.
704
- */
705
- interface CodexAppServerProvider extends ProviderV3 {
706
- (modelId: CodexModelId, settings?: CodexAppServerSettings): LanguageModelV3;
707
- languageModel(modelId: CodexModelId, settings?: CodexAppServerSettings): LanguageModelV3;
708
- chat(modelId: CodexModelId, settings?: CodexAppServerSettings): LanguageModelV3;
709
- embeddingModel(modelId: string): never;
710
- imageModel(modelId: string): never;
711
- close(): Promise<void>;
712
- dispose(): Promise<void>;
713
- listModels(modelProviders?: string[]): Promise<CodexAppServerModelListResult>;
714
- }
715
- /**
716
- * Creates a Codex app-server provider instance.
717
- *
718
- * The provider maintains a shared JSON-RPC client process and can be reused
719
- * across many model calls. Always call `provider.close()` (or `dispose()`)
720
- * when finished.
721
- *
722
- * @example
723
- * ```ts
724
- * const provider = createCodexAppServer({
725
- * defaultSettings: { minCodexVersion: '0.144.0' },
726
- * });
727
- *
728
- * try {
729
- * const model = provider('gpt-5.3-codex');
730
- * // use with generateText / streamText / generateObject
731
- * } finally {
732
- * await provider.close();
733
- * }
734
- * ```
735
- */
736
- declare function createCodexAppServer(options?: CodexAppServerProviderSettings): CodexAppServerProvider;
737
- declare const codexAppServer: CodexAppServerProvider;
738
-
739
- interface ListModelsOptions {
740
- codexPath?: string;
741
- env?: Record<string, string>;
742
- cwd?: string;
743
- minCodexVersion?: string;
744
- modelProviders?: string[];
745
- connectionTimeoutMs?: number;
746
- requestTimeoutMs?: number;
747
- }
748
- interface ListModelsResult {
749
- models: ModelInfo[];
750
- defaultModel?: ModelInfo;
751
- nextCursor?: string | null;
752
- }
753
- declare function listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
754
-
755
- interface ExecLanguageModelOptions {
756
- id: CodexModelId;
757
- settings?: CodexExecSettings;
758
- }
759
- declare class ExecLanguageModel implements LanguageModelV3 {
760
- readonly specificationVersion: "v3";
761
- readonly provider = "codex-cli";
762
- readonly defaultObjectGenerationMode: "json";
763
- readonly supportsImageUrls = false;
764
- readonly supportedUrls: {};
765
- readonly supportsStructuredOutputs = true;
766
- readonly modelId: string;
767
- readonly settings: CodexExecSettings;
768
- private logger;
769
- private sessionId?;
770
- constructor(options: ExecLanguageModelOptions);
771
- private mergeSettings;
772
- private getItemType;
773
- private buildArgs;
774
- private applyMcpSettings;
775
- private addConfigOverride;
776
- /**
777
- * Serialize a config override value into a CLI-safe string.
778
- */
779
- private serializeConfigValue;
780
- private parseExperimentalJsonEvent;
781
- private extractUsage;
782
- private getToolName;
783
- private buildToolInputPayload;
784
- private buildToolResultPayload;
785
- private emitToolInvocation;
786
- private emitToolResult;
787
- private handleSpawnError;
788
- doGenerate(options: Parameters<LanguageModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doGenerate']>>>;
789
- doStream(options: Parameters<LanguageModelV3['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doStream']>>>;
790
- }
791
-
792
- declare class UnsupportedFeatureError extends UnsupportedFunctionalityError {
793
- readonly feature: string;
794
- readonly minCodexVersion?: string;
795
- readonly serverVersion?: string;
796
- constructor({ feature, minCodexVersion, serverVersion, message, }: {
797
- feature: string;
798
- minCodexVersion?: string;
799
- serverVersion?: string;
800
- message?: string;
801
- });
802
- }
803
- declare function isAuthenticationError(err: unknown): boolean;
804
- declare function isUnsupportedFeatureError(err: unknown): err is UnsupportedFeatureError;
805
-
806
- export { type AppServerThreadMode, type AppServerUserInput, type CodexAppServerModelListResult, type CodexAppServerProvider, type CodexAppServerProviderOptions, type CodexAppServerProviderSettings, type CodexAppServerRequestHandlers, type CodexAppServerSession, type CodexAppServerSettings, ExecLanguageModel as CodexCliLanguageModel, type CodexExecProvider as CodexCliProvider, type CodexCliProviderOptions, type CodexCliProviderSettings, type CodexCliSettings, type CodexExecProvider, type CodexExecProviderOptions, type CodexExecProviderSettings, type CodexExecSettings, type CodexModelId, type ErrorNotification, ExecLanguageModel, type ItemCompletedNotification, type ItemStartedNotification, type JsonRpcError, type JsonRpcErrorResponse, type JsonRpcId, type JsonRpcMessage, type JsonRpcNotification, type JsonRpcRequest, type JsonRpcResponse, type ListModelsOptions, type ListModelsResult, type LocalMcpServer, type LocalMcpServerOptions, type LocalTool, type LocalToolDefinition, type Logger, type ModelVerbosity, type ReasoningEffort, type ReasoningSummary, type ReasoningSummaryFormat, type SdkMcpServer, type SdkMcpServerOptions, type Thread, type ThreadItem, type ThreadResumeParams, type ThreadResumeResponse, type ThreadStartParams, type ThreadStartResponse, type ThreadStartedNotification, type Turn, type TurnCompletedNotification, type TurnInterruptParams, type TurnInterruptResponse, type TurnStartParams, type TurnStartResponse, type TurnStartedNotification, UnsupportedFeatureError, type UserInput, codexAppServer, codexExec as codexCli, codexExec, createCodexAppServer, createCodexExec as createCodexCli, createCodexExec, createLocalMcpServer, createSdkMcpServer, isAuthenticationError, isUnsupportedFeatureError, listModels, tool };