ai-sdk-provider-codex-cli 1.0.4 → 1.1.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/README.md +145 -38
- package/dist/index.cjs +4781 -441
- package/dist/index.d.cts +663 -196
- package/dist/index.d.ts +663 -196
- package/dist/index.js +4768 -444
- package/package.json +7 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,265 +1,727 @@
|
|
|
1
|
-
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
1
|
+
import { ProviderV3, LanguageModelV3, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Logger interface for custom logging.
|
|
5
|
-
* Allows consumers to provide their own logging implementation
|
|
6
|
-
* or disable logging entirely.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const customLogger: Logger = {
|
|
11
|
-
* debug: (message) => myLoggingService.debug(message),
|
|
12
|
-
* info: (message) => myLoggingService.info(message),
|
|
13
|
-
* warn: (message) => myLoggingService.warn(message),
|
|
14
|
-
* error: (message) => myLoggingService.error(message),
|
|
15
|
-
* };
|
|
16
|
-
* ```
|
|
17
6
|
*/
|
|
18
7
|
interface Logger {
|
|
19
|
-
/**
|
|
20
|
-
* Log a debug message. Only logged when verbose mode is enabled.
|
|
21
|
-
* Used for detailed execution tracing and troubleshooting.
|
|
22
|
-
*/
|
|
23
8
|
debug: (message: string) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Log an informational message. Only logged when verbose mode is enabled.
|
|
26
|
-
* Used for general execution flow information.
|
|
27
|
-
*/
|
|
28
9
|
info: (message: string) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Log a warning message.
|
|
31
|
-
*/
|
|
32
10
|
warn: (message: string) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Log an error message.
|
|
35
|
-
*/
|
|
36
11
|
error: (message: string) => void;
|
|
37
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Known Codex-capable model IDs with string fallback for forward compatibility.
|
|
15
|
+
*/
|
|
16
|
+
type CodexModelId = '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 & {});
|
|
38
17
|
type ApprovalMode = 'untrusted' | 'on-failure' | 'on-request' | 'never';
|
|
39
18
|
type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
40
19
|
type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
41
20
|
/**
|
|
42
|
-
* Reasoning summary detail level.
|
|
43
|
-
* Note: The API error messages claim 'concise' and 'none' are valid, but they are
|
|
44
|
-
* actually rejected with 400 errors. Only 'auto' and 'detailed' work in practice.
|
|
21
|
+
* Reasoning summary detail level for exec mode.
|
|
45
22
|
*/
|
|
46
23
|
type ReasoningSummary = 'auto' | 'detailed';
|
|
47
24
|
type ReasoningSummaryFormat = 'none' | 'experimental';
|
|
48
25
|
type ModelVerbosity = 'low' | 'medium' | 'high';
|
|
49
26
|
interface McpServerBase {
|
|
50
|
-
/**
|
|
51
|
-
* Enable/disable this MCP server without removing its definition.
|
|
52
|
-
* Maps to: `mcp_servers.<name>.enabled`
|
|
53
|
-
*/
|
|
54
27
|
enabled?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Time allowed for the MCP server to start (in seconds).
|
|
57
|
-
* Maps to: `mcp_servers.<name>.startup_timeout_sec`
|
|
58
|
-
*/
|
|
59
28
|
startupTimeoutSec?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Max time a single MCP tool call may run (in seconds).
|
|
62
|
-
* Maps to: `mcp_servers.<name>.tool_timeout_sec`
|
|
63
|
-
*/
|
|
64
29
|
toolTimeoutSec?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Explicit allow/deny lists for tools exposed by the server.
|
|
67
|
-
* Maps to: `mcp_servers.<name>.enabled_tools` / `disabled_tools`
|
|
68
|
-
*/
|
|
69
30
|
enabledTools?: string[];
|
|
70
31
|
disabledTools?: string[];
|
|
71
32
|
}
|
|
72
33
|
interface McpServerStdio extends McpServerBase {
|
|
73
|
-
/** Execute an MCP server over stdio */
|
|
74
34
|
transport: 'stdio';
|
|
75
|
-
/** Command to start the MCP server (e.g., `node`, `python`, or a binary path). */
|
|
76
35
|
command: string;
|
|
77
|
-
/** Arguments passed to the command. */
|
|
78
36
|
args?: string[];
|
|
79
|
-
/** Environment variables passed to the MCP process. */
|
|
80
37
|
env?: Record<string, string>;
|
|
81
|
-
/** Optional working directory for the MCP server process. */
|
|
82
38
|
cwd?: string;
|
|
83
39
|
}
|
|
84
40
|
interface McpServerHttp extends McpServerBase {
|
|
85
|
-
/** Use an HTTP-based MCP server (RMCP). */
|
|
86
41
|
transport: 'http';
|
|
87
|
-
/** Base URL for the MCP server. */
|
|
88
42
|
url: string;
|
|
89
|
-
/** Bearer token supplied inline (use env var variant to avoid embedding secrets). */
|
|
90
43
|
bearerToken?: string;
|
|
91
|
-
/** Name of env var that holds the bearer token. */
|
|
92
44
|
bearerTokenEnvVar?: string;
|
|
93
|
-
/** Static HTTP headers to send with each MCP request. */
|
|
94
45
|
httpHeaders?: Record<string, string>;
|
|
95
|
-
/** Names of env vars whose values should be sent as HTTP headers. */
|
|
96
46
|
envHttpHeaders?: Record<string, string>;
|
|
97
47
|
}
|
|
98
48
|
type McpServerConfig = McpServerStdio | McpServerHttp;
|
|
99
|
-
|
|
100
|
-
|
|
49
|
+
type CodexConfigOverrideValue = string | number | boolean | object;
|
|
50
|
+
interface CodexSharedSettings {
|
|
101
51
|
cwd?: string;
|
|
102
|
-
addDirs?: string[];
|
|
103
52
|
approvalMode?: ApprovalMode;
|
|
104
53
|
sandboxMode?: SandboxMode;
|
|
105
|
-
fullAuto?: boolean;
|
|
106
|
-
dangerouslyBypassApprovalsAndSandbox?: boolean;
|
|
107
|
-
skipGitRepoCheck?: boolean;
|
|
108
|
-
color?: 'always' | 'never' | 'auto';
|
|
109
|
-
allowNpx?: boolean;
|
|
110
|
-
outputLastMessageFile?: string;
|
|
111
54
|
env?: Record<string, string>;
|
|
112
55
|
verbose?: boolean;
|
|
113
56
|
logger?: Logger | false;
|
|
114
|
-
/**
|
|
115
|
-
* Controls reasoning effort for reasoning-capable models (o3, o4-mini, the GPT-5.1 family,
|
|
116
|
-
* and legacy GPT-5 slugs). Higher effort produces more thorough reasoning at the cost of latency.
|
|
117
|
-
*
|
|
118
|
-
* Codex CLI model presets currently expose `low`/`medium`/`high` for `gpt-5.1` and `gpt-5.1-codex`.
|
|
119
|
-
* Per OpenAI API docs, GPT‑5.1+ models support a `none` level (no extra reasoning); older GPT‑5 slugs used `minimal` instead.
|
|
120
|
-
* `gpt-5.1-codex-max` additionally supports `xhigh`. `gpt-5.1-codex-mini` only offers `medium`/`high`.
|
|
121
|
-
*
|
|
122
|
-
* Maps to: `-c model_reasoning_effort=<value>`
|
|
123
|
-
* @see https://platform.openai.com/docs/guides/reasoning
|
|
124
|
-
*/
|
|
125
57
|
reasoningEffort?: ReasoningEffort;
|
|
126
|
-
/**
|
|
127
|
-
* Controls reasoning summary detail level.
|
|
128
|
-
*
|
|
129
|
-
* Valid values: 'auto' | 'detailed'
|
|
130
|
-
* Note: Despite API error messages claiming 'concise' and 'none' are valid,
|
|
131
|
-
* they are rejected with 400 errors in practice.
|
|
132
|
-
*
|
|
133
|
-
* Maps to: `-c model_reasoning_summary=<value>`
|
|
134
|
-
* @see https://platform.openai.com/docs/guides/reasoning#reasoning-summaries
|
|
135
|
-
*/
|
|
136
58
|
reasoningSummary?: ReasoningSummary;
|
|
137
|
-
/**
|
|
138
|
-
* Controls reasoning summary format (experimental).
|
|
139
|
-
*
|
|
140
|
-
* Maps to: `-c model_reasoning_summary_format=<value>`
|
|
141
|
-
*/
|
|
142
59
|
reasoningSummaryFormat?: ReasoningSummaryFormat;
|
|
143
|
-
/**
|
|
144
|
-
* Controls output length/detail for GPT-5.1 (non-Codex) and legacy GPT-5 models.
|
|
145
|
-
* Codex-specific slugs ignore this flag because the CLI disables verbosity for them.
|
|
146
|
-
* Only applies to models using the Responses API.
|
|
147
|
-
*
|
|
148
|
-
* Maps to: `-c model_verbosity=<value>`
|
|
149
|
-
*/
|
|
150
60
|
modelVerbosity?: ModelVerbosity;
|
|
151
|
-
/**
|
|
152
|
-
* Configure MCP servers (stdio or HTTP/RMCP). Keys are server names.
|
|
153
|
-
* Each entry maps to the Codex CLI `mcp_servers.<name>` table.
|
|
154
|
-
*/
|
|
155
61
|
mcpServers?: Record<string, McpServerConfig>;
|
|
156
|
-
/**
|
|
157
|
-
* Enable the RMCP client so HTTP-based MCP servers can be contacted.
|
|
158
|
-
* Maps to: `-c features.rmcp_client=true`
|
|
159
|
-
*/
|
|
160
62
|
rmcpClient?: boolean;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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;
|
|
166
84
|
profile?: string;
|
|
167
|
-
/**
|
|
168
|
-
* Use OSS provider (experimental).
|
|
169
|
-
*
|
|
170
|
-
* Maps to: `--oss`
|
|
171
|
-
*/
|
|
172
85
|
oss?: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Enable web search tool for the model.
|
|
175
|
-
*
|
|
176
|
-
* Maps to: `-c tools.web_search=true`
|
|
177
|
-
*/
|
|
178
86
|
webSearch?: boolean;
|
|
179
|
-
|
|
180
|
-
* Generic Codex CLI config overrides. Allows setting any config value
|
|
181
|
-
* without updating the provider.
|
|
182
|
-
*
|
|
183
|
-
* Each entry maps to: `-c <key>=<value>`
|
|
184
|
-
*
|
|
185
|
-
* Examples:
|
|
186
|
-
* - `{ experimental_resume: '/tmp/session.jsonl' }`
|
|
187
|
-
* - `{ 'model_providers.custom.base_url': 'http://localhost:8000' }`
|
|
188
|
-
* - `{ 'sandbox_workspace_write': { network_access: true } }`
|
|
189
|
-
*
|
|
190
|
-
* Values are serialized:
|
|
191
|
-
* - string → raw string
|
|
192
|
-
* - number/boolean → String(value)
|
|
193
|
-
* - plain objects → flattened recursively to dotted keys
|
|
194
|
-
* - arrays → JSON.stringify(value)
|
|
195
|
-
* - other objects (Date, RegExp, Map, etc.) → JSON.stringify(value)
|
|
196
|
-
*/
|
|
197
|
-
configOverrides?: Record<string, string | number | boolean | object>;
|
|
87
|
+
configOverrides?: Record<string, CodexConfigOverrideValue>;
|
|
198
88
|
}
|
|
199
|
-
interface
|
|
200
|
-
defaultSettings?:
|
|
89
|
+
interface CodexExecProviderSettings {
|
|
90
|
+
defaultSettings?: CodexExecSettings;
|
|
201
91
|
}
|
|
202
92
|
/**
|
|
203
93
|
* Per-call overrides supplied through AI SDK providerOptions.
|
|
204
|
-
* These values take precedence over constructor-level CodexCliSettings.
|
|
205
94
|
*/
|
|
206
|
-
interface
|
|
207
|
-
/**
|
|
208
|
-
* Per-call override for reasoning depth.
|
|
209
|
-
* Maps to `model_reasoning_effort`.
|
|
210
|
-
*/
|
|
211
|
-
reasoningEffort?: ReasoningEffort;
|
|
212
|
-
/**
|
|
213
|
-
* Per-call override for reasoning summary detail level.
|
|
214
|
-
* Maps to `model_reasoning_summary`.
|
|
215
|
-
*/
|
|
216
|
-
reasoningSummary?: ReasoningSummary;
|
|
217
|
-
/**
|
|
218
|
-
* Per-call override for reasoning summary format.
|
|
219
|
-
* Maps to `model_reasoning_summary_format`.
|
|
220
|
-
*/
|
|
221
|
-
reasoningSummaryFormat?: ReasoningSummaryFormat;
|
|
222
|
-
/**
|
|
223
|
-
* AI SDK naming for per-call verbosity overrides.
|
|
224
|
-
* Maps to Codex `model_verbosity`.
|
|
225
|
-
*/
|
|
226
|
-
textVerbosity?: ModelVerbosity;
|
|
227
|
-
/**
|
|
228
|
-
* Per-call override for extra directories Codex can access.
|
|
229
|
-
* Maps to repeated `--add-dir` flags.
|
|
230
|
-
*/
|
|
95
|
+
interface CodexExecProviderOptions extends CodexSharedProviderOptions {
|
|
231
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
|
+
interface DynamicToolCallParams {
|
|
411
|
+
threadId: string;
|
|
412
|
+
turnId: string;
|
|
413
|
+
callId: string;
|
|
414
|
+
tool: string;
|
|
415
|
+
arguments: unknown;
|
|
416
|
+
}
|
|
417
|
+
interface DynamicToolCallResponse {
|
|
418
|
+
contentItems: unknown[];
|
|
419
|
+
success: boolean;
|
|
420
|
+
}
|
|
421
|
+
interface ChatgptAuthTokensRefreshParams {
|
|
422
|
+
reason: string;
|
|
423
|
+
previousAccountId?: string | null;
|
|
424
|
+
}
|
|
425
|
+
interface ChatgptAuthTokensRefreshResponse {
|
|
426
|
+
accessToken: string;
|
|
427
|
+
chatgptAccountId: string;
|
|
428
|
+
chatgptPlanType: string | null;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
interface LocalToolDefinition<TParams = unknown, TResult = unknown> {
|
|
432
|
+
name: string;
|
|
433
|
+
description: string;
|
|
434
|
+
parameters: ZodType<TParams>;
|
|
435
|
+
execute: (params: TParams) => Promise<TResult>;
|
|
436
|
+
}
|
|
437
|
+
interface LocalTool {
|
|
438
|
+
name: string;
|
|
439
|
+
description: string;
|
|
440
|
+
inputSchema: Record<string, unknown>;
|
|
441
|
+
execute: (params: unknown) => Promise<unknown>;
|
|
442
|
+
}
|
|
443
|
+
declare function tool<TParams, TResult>(definition: LocalToolDefinition<TParams, TResult>): LocalTool;
|
|
444
|
+
|
|
445
|
+
interface LocalMcpServerOptions {
|
|
446
|
+
name: string;
|
|
447
|
+
tools: LocalTool[];
|
|
448
|
+
port?: number;
|
|
449
|
+
host?: string;
|
|
450
|
+
allowNonLoopbackHost?: boolean;
|
|
451
|
+
}
|
|
452
|
+
interface LocalMcpServer {
|
|
453
|
+
config: McpServerHttp;
|
|
454
|
+
url: string;
|
|
455
|
+
port: number;
|
|
456
|
+
stop: () => Promise<void>;
|
|
457
|
+
}
|
|
458
|
+
declare function createLocalMcpServer(options: LocalMcpServerOptions): Promise<LocalMcpServer>;
|
|
459
|
+
|
|
460
|
+
declare const SDK_MCP_SERVER_MARKER: unique symbol;
|
|
461
|
+
interface SdkMcpServer {
|
|
462
|
+
readonly [SDK_MCP_SERVER_MARKER]: true;
|
|
463
|
+
readonly name: string;
|
|
464
|
+
readonly cacheKey?: string;
|
|
465
|
+
readonly tools: LocalTool[];
|
|
466
|
+
_server?: LocalMcpServer;
|
|
467
|
+
_start(): Promise<LocalMcpServer['config']>;
|
|
468
|
+
_stop(): Promise<void>;
|
|
469
|
+
}
|
|
470
|
+
interface SdkMcpServerOptions {
|
|
471
|
+
name: string;
|
|
472
|
+
cacheKey?: string;
|
|
473
|
+
tools: LocalTool[];
|
|
474
|
+
}
|
|
475
|
+
declare function createSdkMcpServer(options: SdkMcpServerOptions): SdkMcpServer;
|
|
476
|
+
|
|
477
|
+
type AppServerThreadMode = 'stateless' | 'persistent';
|
|
478
|
+
type AppServerPersonality = 'none' | 'friendly' | 'pragmatic';
|
|
479
|
+
type AppServerReasoningSummary = 'auto' | 'concise' | 'detailed' | 'none';
|
|
480
|
+
type AppServerApprovalPolicy = 'untrusted' | 'on-failure' | 'on-request' | 'never' | {
|
|
481
|
+
reject: {
|
|
482
|
+
sandbox_approval: boolean;
|
|
483
|
+
rules: boolean;
|
|
484
|
+
mcp_elicitations: boolean;
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
type AppServerSandboxPolicy = 'read-only' | 'workspace-write' | 'danger-full-access' | {
|
|
488
|
+
type: 'dangerFullAccess';
|
|
489
|
+
} | {
|
|
490
|
+
type: 'readOnly';
|
|
491
|
+
access?: unknown;
|
|
492
|
+
} | {
|
|
493
|
+
type: 'externalSandbox';
|
|
494
|
+
networkAccess?: 'restricted' | 'enabled';
|
|
495
|
+
} | {
|
|
496
|
+
type: 'workspaceWrite';
|
|
497
|
+
writableRoots?: string[];
|
|
498
|
+
readOnlyAccess?: unknown;
|
|
499
|
+
networkAccess?: boolean;
|
|
500
|
+
excludeTmpdirEnvVar?: boolean;
|
|
501
|
+
excludeSlashTmp?: boolean;
|
|
502
|
+
};
|
|
503
|
+
type AppServerUserInput = {
|
|
504
|
+
type: 'text';
|
|
505
|
+
text: string;
|
|
506
|
+
} | {
|
|
507
|
+
type: 'image';
|
|
508
|
+
imageUrl: string;
|
|
509
|
+
} | {
|
|
510
|
+
type: 'localImage';
|
|
511
|
+
path: string;
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* Live session handle for an active app-server thread.
|
|
515
|
+
*
|
|
516
|
+
* Session callbacks are most useful in streaming flows where you can inject
|
|
517
|
+
* follow-up instructions while a turn is still running.
|
|
518
|
+
*/
|
|
519
|
+
interface CodexAppServerSession {
|
|
520
|
+
readonly threadId: string;
|
|
521
|
+
readonly turnId: string | null;
|
|
232
522
|
/**
|
|
233
|
-
*
|
|
234
|
-
* constructor-level overrides with per-call values taking precedence.
|
|
523
|
+
* Injects an additional user message into the current thread.
|
|
235
524
|
*/
|
|
236
|
-
|
|
525
|
+
injectMessage(content: string | AppServerUserInput[]): Promise<void>;
|
|
237
526
|
/**
|
|
238
|
-
*
|
|
239
|
-
* (per-call servers and fields take precedence).
|
|
527
|
+
* Requests interruption of the currently running turn.
|
|
240
528
|
*/
|
|
241
|
-
|
|
529
|
+
interrupt(): Promise<void>;
|
|
242
530
|
/**
|
|
243
|
-
*
|
|
531
|
+
* Returns whether this session currently has an active turn.
|
|
244
532
|
*/
|
|
533
|
+
isActive(): boolean;
|
|
534
|
+
}
|
|
535
|
+
interface AppServerCommandExecutionApprovalRequest {
|
|
536
|
+
id: JsonRpcId;
|
|
537
|
+
method: 'item/commandExecution/requestApproval';
|
|
538
|
+
params: CommandExecutionRequestApprovalParams;
|
|
539
|
+
}
|
|
540
|
+
interface AppServerFileChangeApprovalRequest {
|
|
541
|
+
id: JsonRpcId;
|
|
542
|
+
method: 'item/fileChange/requestApproval';
|
|
543
|
+
params: FileChangeRequestApprovalParams;
|
|
544
|
+
}
|
|
545
|
+
interface AppServerSkillApprovalRequest {
|
|
546
|
+
id: JsonRpcId;
|
|
547
|
+
method: 'skill/requestApproval';
|
|
548
|
+
params: SkillRequestApprovalParams;
|
|
549
|
+
}
|
|
550
|
+
interface AppServerToolRequestUserInputRequest {
|
|
551
|
+
id: JsonRpcId;
|
|
552
|
+
method: 'item/tool/requestUserInput';
|
|
553
|
+
params: ToolRequestUserInputParams;
|
|
554
|
+
}
|
|
555
|
+
interface AppServerDynamicToolCallRequest {
|
|
556
|
+
id: JsonRpcId;
|
|
557
|
+
method: 'item/tool/call';
|
|
558
|
+
params: DynamicToolCallParams;
|
|
559
|
+
}
|
|
560
|
+
interface AppServerAuthRefreshRequest {
|
|
561
|
+
id: JsonRpcId;
|
|
562
|
+
method: 'account/chatgptAuthTokens/refresh';
|
|
563
|
+
params: ChatgptAuthTokensRefreshParams;
|
|
564
|
+
}
|
|
565
|
+
interface AppServerUnhandledRequest {
|
|
566
|
+
id: JsonRpcId;
|
|
567
|
+
method: string;
|
|
568
|
+
params: Record<string, unknown>;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Typed handlers for server-initiated JSON-RPC requests.
|
|
572
|
+
*
|
|
573
|
+
* Handler precedence:
|
|
574
|
+
* 1) per-call provider options
|
|
575
|
+
* 2) provider default settings
|
|
576
|
+
* 3) built-in defaults in the RPC client
|
|
577
|
+
* 4) `onUnhandled` fallback
|
|
578
|
+
*/
|
|
579
|
+
interface CodexAppServerRequestHandlers {
|
|
580
|
+
onCommandExecutionApproval?: (request: AppServerCommandExecutionApprovalRequest) => Promise<CommandExecutionRequestApprovalResponse | undefined>;
|
|
581
|
+
onFileChangeApproval?: (request: AppServerFileChangeApprovalRequest) => Promise<FileChangeRequestApprovalResponse | undefined>;
|
|
582
|
+
onSkillApproval?: (request: AppServerSkillApprovalRequest) => Promise<SkillRequestApprovalResponse | undefined>;
|
|
583
|
+
onToolRequestUserInput?: (request: AppServerToolRequestUserInputRequest) => Promise<ToolRequestUserInputResponse | undefined>;
|
|
584
|
+
onDynamicToolCall?: (request: AppServerDynamicToolCallRequest) => Promise<DynamicToolCallResponse | undefined>;
|
|
585
|
+
onAuthRefresh?: (request: AppServerAuthRefreshRequest) => Promise<ChatgptAuthTokensRefreshResponse | undefined>;
|
|
586
|
+
onUnhandled?: (request: AppServerUnhandledRequest) => Promise<unknown>;
|
|
587
|
+
}
|
|
588
|
+
type AppServerMcpServerConfig = McpServerConfig | SdkMcpServer;
|
|
589
|
+
/**
|
|
590
|
+
* Provider-level and model-level settings for Codex app-server mode.
|
|
591
|
+
*/
|
|
592
|
+
interface CodexAppServerSettings {
|
|
593
|
+
codexPath?: string;
|
|
594
|
+
cwd?: string;
|
|
595
|
+
env?: Record<string, string>;
|
|
596
|
+
verbose?: boolean;
|
|
597
|
+
logger?: Logger | false;
|
|
598
|
+
personality?: AppServerPersonality;
|
|
599
|
+
effort?: ReasoningEffort;
|
|
600
|
+
summary?: AppServerReasoningSummary;
|
|
601
|
+
approvalPolicy?: AppServerApprovalPolicy;
|
|
602
|
+
sandboxPolicy?: AppServerSandboxPolicy;
|
|
603
|
+
baseInstructions?: string;
|
|
604
|
+
developerInstructions?: string;
|
|
605
|
+
mcpServers?: Record<string, AppServerMcpServerConfig>;
|
|
245
606
|
rmcpClient?: boolean;
|
|
607
|
+
configOverrides?: Record<string, CodexConfigOverrideValue>;
|
|
608
|
+
autoApprove?: boolean;
|
|
609
|
+
persistExtendedHistory?: boolean;
|
|
610
|
+
connectionTimeoutMs?: number;
|
|
611
|
+
requestTimeoutMs?: number;
|
|
612
|
+
idleTimeoutMs?: number;
|
|
613
|
+
minCodexVersion?: string;
|
|
614
|
+
threadMode?: AppServerThreadMode;
|
|
615
|
+
resume?: string;
|
|
616
|
+
includeRawChunks?: boolean;
|
|
617
|
+
serverRequests?: CodexAppServerRequestHandlers;
|
|
618
|
+
onSessionCreated?: (session: CodexAppServerSession) => void | Promise<void>;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Factory options passed to `createCodexAppServer`.
|
|
622
|
+
*/
|
|
623
|
+
interface CodexAppServerProviderSettings {
|
|
624
|
+
defaultSettings?: CodexAppServerSettings;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Per-request overrides passed via `providerOptions['codex-app-server']`.
|
|
628
|
+
*/
|
|
629
|
+
interface CodexAppServerProviderOptions {
|
|
630
|
+
threadId?: string;
|
|
631
|
+
resume?: string;
|
|
632
|
+
threadMode?: AppServerThreadMode;
|
|
633
|
+
includeRawChunks?: boolean;
|
|
634
|
+
personality?: AppServerPersonality;
|
|
635
|
+
effort?: ReasoningEffort;
|
|
636
|
+
summary?: AppServerReasoningSummary;
|
|
637
|
+
approvalPolicy?: AppServerApprovalPolicy;
|
|
638
|
+
sandboxPolicy?: AppServerSandboxPolicy;
|
|
639
|
+
baseInstructions?: string;
|
|
640
|
+
developerInstructions?: string;
|
|
641
|
+
mcpServers?: Record<string, AppServerMcpServerConfig>;
|
|
642
|
+
rmcpClient?: boolean;
|
|
643
|
+
configOverrides?: Record<string, CodexConfigOverrideValue>;
|
|
644
|
+
autoApprove?: boolean;
|
|
645
|
+
persistExtendedHistory?: boolean;
|
|
646
|
+
serverRequests?: Partial<CodexAppServerRequestHandlers>;
|
|
647
|
+
onSessionCreated?: (session: CodexAppServerSession) => void | Promise<void>;
|
|
246
648
|
}
|
|
247
649
|
|
|
248
|
-
interface
|
|
249
|
-
(modelId:
|
|
250
|
-
languageModel(modelId:
|
|
251
|
-
chat(modelId:
|
|
650
|
+
interface CodexExecProvider extends ProviderV3 {
|
|
651
|
+
(modelId: CodexModelId, settings?: CodexExecSettings): LanguageModelV3;
|
|
652
|
+
languageModel(modelId: CodexModelId, settings?: CodexExecSettings): LanguageModelV3;
|
|
653
|
+
chat(modelId: CodexModelId, settings?: CodexExecSettings): LanguageModelV3;
|
|
252
654
|
embeddingModel(modelId: string): never;
|
|
253
655
|
imageModel(modelId: string): never;
|
|
254
656
|
}
|
|
255
|
-
declare function
|
|
256
|
-
declare const
|
|
657
|
+
declare function createCodexExec(options?: CodexExecProviderSettings): CodexExecProvider;
|
|
658
|
+
declare const codexExec: CodexExecProvider;
|
|
257
659
|
|
|
258
|
-
interface
|
|
259
|
-
|
|
260
|
-
|
|
660
|
+
interface CodexAppServerModelListResult {
|
|
661
|
+
models: ModelInfo[];
|
|
662
|
+
defaultModel?: ModelInfo;
|
|
663
|
+
nextCursor?: string | null;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Provider interface for the persistent Codex app-server transport.
|
|
667
|
+
*
|
|
668
|
+
* Use this via `createCodexAppServer()` or the default `codexAppServer` export.
|
|
669
|
+
*/
|
|
670
|
+
interface CodexAppServerProvider extends ProviderV3 {
|
|
671
|
+
(modelId: CodexModelId, settings?: CodexAppServerSettings): LanguageModelV3;
|
|
672
|
+
languageModel(modelId: CodexModelId, settings?: CodexAppServerSettings): LanguageModelV3;
|
|
673
|
+
chat(modelId: CodexModelId, settings?: CodexAppServerSettings): LanguageModelV3;
|
|
674
|
+
embeddingModel(modelId: string): never;
|
|
675
|
+
imageModel(modelId: string): never;
|
|
676
|
+
close(): Promise<void>;
|
|
677
|
+
dispose(): Promise<void>;
|
|
678
|
+
listModels(modelProviders?: string[]): Promise<CodexAppServerModelListResult>;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Creates a Codex app-server provider instance.
|
|
682
|
+
*
|
|
683
|
+
* The provider maintains a shared JSON-RPC client process and can be reused
|
|
684
|
+
* across many model calls. Always call `provider.close()` (or `dispose()`)
|
|
685
|
+
* when finished.
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* ```ts
|
|
689
|
+
* const provider = createCodexAppServer({
|
|
690
|
+
* defaultSettings: { minCodexVersion: '0.105.0-alpha.0' },
|
|
691
|
+
* });
|
|
692
|
+
*
|
|
693
|
+
* try {
|
|
694
|
+
* const model = provider('gpt-5.3-codex');
|
|
695
|
+
* // use with generateText / streamText / generateObject
|
|
696
|
+
* } finally {
|
|
697
|
+
* await provider.close();
|
|
698
|
+
* }
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
701
|
+
declare function createCodexAppServer(options?: CodexAppServerProviderSettings): CodexAppServerProvider;
|
|
702
|
+
declare const codexAppServer: CodexAppServerProvider;
|
|
703
|
+
|
|
704
|
+
interface ListModelsOptions {
|
|
705
|
+
codexPath?: string;
|
|
706
|
+
env?: Record<string, string>;
|
|
707
|
+
cwd?: string;
|
|
708
|
+
minCodexVersion?: string;
|
|
709
|
+
modelProviders?: string[];
|
|
710
|
+
connectionTimeoutMs?: number;
|
|
711
|
+
requestTimeoutMs?: number;
|
|
712
|
+
}
|
|
713
|
+
interface ListModelsResult {
|
|
714
|
+
models: ModelInfo[];
|
|
715
|
+
defaultModel?: ModelInfo;
|
|
716
|
+
nextCursor?: string | null;
|
|
261
717
|
}
|
|
262
|
-
declare
|
|
718
|
+
declare function listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
|
|
719
|
+
|
|
720
|
+
interface ExecLanguageModelOptions {
|
|
721
|
+
id: CodexModelId;
|
|
722
|
+
settings?: CodexExecSettings;
|
|
723
|
+
}
|
|
724
|
+
declare class ExecLanguageModel implements LanguageModelV3 {
|
|
263
725
|
readonly specificationVersion: "v3";
|
|
264
726
|
readonly provider = "codex-cli";
|
|
265
727
|
readonly defaultObjectGenerationMode: "json";
|
|
@@ -267,14 +729,11 @@ declare class CodexCliLanguageModel implements LanguageModelV3 {
|
|
|
267
729
|
readonly supportedUrls: {};
|
|
268
730
|
readonly supportsStructuredOutputs = true;
|
|
269
731
|
readonly modelId: string;
|
|
270
|
-
readonly settings:
|
|
732
|
+
readonly settings: CodexExecSettings;
|
|
271
733
|
private logger;
|
|
272
734
|
private sessionId?;
|
|
273
|
-
constructor(options:
|
|
735
|
+
constructor(options: ExecLanguageModelOptions);
|
|
274
736
|
private mergeSettings;
|
|
275
|
-
private mergeMcpServers;
|
|
276
|
-
private mergeSingleMcpServer;
|
|
277
|
-
private mergeStringRecord;
|
|
278
737
|
private getItemType;
|
|
279
738
|
private buildArgs;
|
|
280
739
|
private applyMcpSettings;
|
|
@@ -283,15 +742,11 @@ declare class CodexCliLanguageModel implements LanguageModelV3 {
|
|
|
283
742
|
* Serialize a config override value into a CLI-safe string.
|
|
284
743
|
*/
|
|
285
744
|
private serializeConfigValue;
|
|
286
|
-
private isPlainObject;
|
|
287
|
-
private sanitizeJsonSchema;
|
|
288
|
-
private mapWarnings;
|
|
289
745
|
private parseExperimentalJsonEvent;
|
|
290
746
|
private extractUsage;
|
|
291
747
|
private getToolName;
|
|
292
748
|
private buildToolInputPayload;
|
|
293
749
|
private buildToolResultPayload;
|
|
294
|
-
private safeStringify;
|
|
295
750
|
private emitToolInvocation;
|
|
296
751
|
private emitToolResult;
|
|
297
752
|
private handleSpawnError;
|
|
@@ -299,6 +754,18 @@ declare class CodexCliLanguageModel implements LanguageModelV3 {
|
|
|
299
754
|
doStream(options: Parameters<LanguageModelV3['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doStream']>>>;
|
|
300
755
|
}
|
|
301
756
|
|
|
757
|
+
declare class UnsupportedFeatureError extends UnsupportedFunctionalityError {
|
|
758
|
+
readonly feature: string;
|
|
759
|
+
readonly minCodexVersion?: string;
|
|
760
|
+
readonly serverVersion?: string;
|
|
761
|
+
constructor({ feature, minCodexVersion, serverVersion, message, }: {
|
|
762
|
+
feature: string;
|
|
763
|
+
minCodexVersion?: string;
|
|
764
|
+
serverVersion?: string;
|
|
765
|
+
message?: string;
|
|
766
|
+
});
|
|
767
|
+
}
|
|
302
768
|
declare function isAuthenticationError(err: unknown): boolean;
|
|
769
|
+
declare function isUnsupportedFeatureError(err: unknown): err is UnsupportedFeatureError;
|
|
303
770
|
|
|
304
|
-
export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderOptions, type CodexCliProviderSettings, type CodexCliSettings, type Logger, type ModelVerbosity, type ReasoningEffort, type ReasoningSummary, type ReasoningSummaryFormat, codexCli, createCodexCli, isAuthenticationError };
|
|
771
|
+
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 };
|