@ai-sdk/openai 3.0.14 → 3.0.15
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/CHANGELOG.md +6 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -5
- package/src/chat/__fixtures__/azure-model-router.1.chunks.txt +8 -0
- package/src/chat/__snapshots__/openai-chat-language-model.test.ts.snap +88 -0
- package/src/chat/convert-openai-chat-usage.ts +57 -0
- package/src/chat/convert-to-openai-chat-messages.test.ts +516 -0
- package/src/chat/convert-to-openai-chat-messages.ts +225 -0
- package/src/chat/get-response-metadata.ts +15 -0
- package/src/chat/map-openai-finish-reason.ts +19 -0
- package/src/chat/openai-chat-api.ts +198 -0
- package/src/chat/openai-chat-language-model.test.ts +3496 -0
- package/src/chat/openai-chat-language-model.ts +700 -0
- package/src/chat/openai-chat-options.ts +186 -0
- package/src/chat/openai-chat-prepare-tools.test.ts +322 -0
- package/src/chat/openai-chat-prepare-tools.ts +84 -0
- package/src/chat/openai-chat-prompt.ts +70 -0
- package/src/completion/convert-openai-completion-usage.ts +46 -0
- package/src/completion/convert-to-openai-completion-prompt.ts +93 -0
- package/src/completion/get-response-metadata.ts +15 -0
- package/src/completion/map-openai-finish-reason.ts +19 -0
- package/src/completion/openai-completion-api.ts +81 -0
- package/src/completion/openai-completion-language-model.test.ts +752 -0
- package/src/completion/openai-completion-language-model.ts +336 -0
- package/src/completion/openai-completion-options.ts +58 -0
- package/src/embedding/__snapshots__/openai-embedding-model.test.ts.snap +43 -0
- package/src/embedding/openai-embedding-api.ts +13 -0
- package/src/embedding/openai-embedding-model.test.ts +146 -0
- package/src/embedding/openai-embedding-model.ts +95 -0
- package/src/embedding/openai-embedding-options.ts +30 -0
- package/src/image/openai-image-api.ts +35 -0
- package/src/image/openai-image-model.test.ts +722 -0
- package/src/image/openai-image-model.ts +305 -0
- package/src/image/openai-image-options.ts +28 -0
- package/src/index.ts +9 -0
- package/src/internal/index.ts +19 -0
- package/src/openai-config.ts +18 -0
- package/src/openai-error.test.ts +34 -0
- package/src/openai-error.ts +22 -0
- package/src/openai-language-model-capabilities.test.ts +93 -0
- package/src/openai-language-model-capabilities.ts +54 -0
- package/src/openai-provider.test.ts +98 -0
- package/src/openai-provider.ts +270 -0
- package/src/openai-tools.ts +114 -0
- package/src/responses/__fixtures__/openai-apply-patch-tool-delete.1.chunks.txt +5 -0
- package/src/responses/__fixtures__/openai-apply-patch-tool.1.chunks.txt +38 -0
- package/src/responses/__fixtures__/openai-apply-patch-tool.1.json +69 -0
- package/src/responses/__fixtures__/openai-code-interpreter-tool.1.chunks.txt +393 -0
- package/src/responses/__fixtures__/openai-code-interpreter-tool.1.json +137 -0
- package/src/responses/__fixtures__/openai-error.1.chunks.txt +4 -0
- package/src/responses/__fixtures__/openai-error.1.json +8 -0
- package/src/responses/__fixtures__/openai-file-search-tool.1.chunks.txt +94 -0
- package/src/responses/__fixtures__/openai-file-search-tool.1.json +89 -0
- package/src/responses/__fixtures__/openai-file-search-tool.2.chunks.txt +93 -0
- package/src/responses/__fixtures__/openai-file-search-tool.2.json +112 -0
- package/src/responses/__fixtures__/openai-image-generation-tool.1.chunks.txt +16 -0
- package/src/responses/__fixtures__/openai-image-generation-tool.1.json +96 -0
- package/src/responses/__fixtures__/openai-local-shell-tool.1.chunks.txt +7 -0
- package/src/responses/__fixtures__/openai-local-shell-tool.1.json +70 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.1.chunks.txt +11 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.1.json +169 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.2.chunks.txt +123 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.2.json +176 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.3.chunks.txt +11 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.3.json +169 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.4.chunks.txt +84 -0
- package/src/responses/__fixtures__/openai-mcp-tool-approval.4.json +182 -0
- package/src/responses/__fixtures__/openai-mcp-tool.1.chunks.txt +373 -0
- package/src/responses/__fixtures__/openai-mcp-tool.1.json +159 -0
- package/src/responses/__fixtures__/openai-reasoning-encrypted-content.1.chunks.txt +110 -0
- package/src/responses/__fixtures__/openai-reasoning-encrypted-content.1.json +117 -0
- package/src/responses/__fixtures__/openai-shell-tool.1.chunks.txt +182 -0
- package/src/responses/__fixtures__/openai-shell-tool.1.json +73 -0
- package/src/responses/__fixtures__/openai-web-search-tool.1.chunks.txt +185 -0
- package/src/responses/__fixtures__/openai-web-search-tool.1.json +266 -0
- package/src/responses/__snapshots__/openai-responses-language-model.test.ts.snap +10955 -0
- package/src/responses/convert-openai-responses-usage.ts +53 -0
- package/src/responses/convert-to-openai-responses-input.test.ts +2976 -0
- package/src/responses/convert-to-openai-responses-input.ts +578 -0
- package/src/responses/map-openai-responses-finish-reason.ts +22 -0
- package/src/responses/openai-responses-api.test.ts +89 -0
- package/src/responses/openai-responses-api.ts +1086 -0
- package/src/responses/openai-responses-language-model.test.ts +6927 -0
- package/src/responses/openai-responses-language-model.ts +1932 -0
- package/src/responses/openai-responses-options.ts +312 -0
- package/src/responses/openai-responses-prepare-tools.test.ts +924 -0
- package/src/responses/openai-responses-prepare-tools.ts +264 -0
- package/src/responses/openai-responses-provider-metadata.ts +39 -0
- package/src/speech/openai-speech-api.ts +38 -0
- package/src/speech/openai-speech-model.test.ts +202 -0
- package/src/speech/openai-speech-model.ts +137 -0
- package/src/speech/openai-speech-options.ts +22 -0
- package/src/tool/apply-patch.ts +141 -0
- package/src/tool/code-interpreter.ts +104 -0
- package/src/tool/file-search.ts +145 -0
- package/src/tool/image-generation.ts +126 -0
- package/src/tool/local-shell.test-d.ts +20 -0
- package/src/tool/local-shell.ts +72 -0
- package/src/tool/mcp.ts +125 -0
- package/src/tool/shell.ts +85 -0
- package/src/tool/web-search-preview.ts +139 -0
- package/src/tool/web-search.test-d.ts +13 -0
- package/src/tool/web-search.ts +179 -0
- package/src/transcription/openai-transcription-api.ts +37 -0
- package/src/transcription/openai-transcription-model.test.ts +507 -0
- package/src/transcription/openai-transcription-model.ts +232 -0
- package/src/transcription/openai-transcription-options.ts +50 -0
- package/src/transcription/transcription-test.mp3 +0 -0
- package/src/version.ts +6 -0
|
@@ -0,0 +1,1086 @@
|
|
|
1
|
+
import { JSONSchema7 } from '@ai-sdk/provider';
|
|
2
|
+
import { InferSchema, lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
|
+
|
|
5
|
+
export type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
|
|
6
|
+
|
|
7
|
+
export type OpenAIResponsesInputItem =
|
|
8
|
+
| OpenAIResponsesSystemMessage
|
|
9
|
+
| OpenAIResponsesUserMessage
|
|
10
|
+
| OpenAIResponsesAssistantMessage
|
|
11
|
+
| OpenAIResponsesFunctionCall
|
|
12
|
+
| OpenAIResponsesFunctionCallOutput
|
|
13
|
+
| OpenAIResponsesMcpApprovalResponse
|
|
14
|
+
| OpenAIResponsesComputerCall
|
|
15
|
+
| OpenAIResponsesLocalShellCall
|
|
16
|
+
| OpenAIResponsesLocalShellCallOutput
|
|
17
|
+
| OpenAIResponsesShellCall
|
|
18
|
+
| OpenAIResponsesShellCallOutput
|
|
19
|
+
| OpenAIResponsesApplyPatchCall
|
|
20
|
+
| OpenAIResponsesApplyPatchCallOutput
|
|
21
|
+
| OpenAIResponsesReasoning
|
|
22
|
+
| OpenAIResponsesItemReference;
|
|
23
|
+
|
|
24
|
+
export type OpenAIResponsesIncludeValue =
|
|
25
|
+
| 'web_search_call.action.sources'
|
|
26
|
+
| 'code_interpreter_call.outputs'
|
|
27
|
+
| 'computer_call_output.output.image_url'
|
|
28
|
+
| 'file_search_call.results'
|
|
29
|
+
| 'message.input_image.image_url'
|
|
30
|
+
| 'message.output_text.logprobs'
|
|
31
|
+
| 'reasoning.encrypted_content';
|
|
32
|
+
|
|
33
|
+
export type OpenAIResponsesIncludeOptions =
|
|
34
|
+
| Array<OpenAIResponsesIncludeValue>
|
|
35
|
+
| undefined
|
|
36
|
+
| null;
|
|
37
|
+
|
|
38
|
+
export type OpenAIResponsesApplyPatchOperationDiffDeltaChunk = {
|
|
39
|
+
type: 'response.apply_patch_call_operation_diff.delta';
|
|
40
|
+
item_id: string;
|
|
41
|
+
output_index: number;
|
|
42
|
+
delta: string;
|
|
43
|
+
obfuscation?: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type OpenAIResponsesApplyPatchOperationDiffDoneChunk = {
|
|
47
|
+
type: 'response.apply_patch_call_operation_diff.done';
|
|
48
|
+
item_id: string;
|
|
49
|
+
output_index: number;
|
|
50
|
+
diff: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type OpenAIResponsesSystemMessage = {
|
|
54
|
+
role: 'system' | 'developer';
|
|
55
|
+
content: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type OpenAIResponsesUserMessage = {
|
|
59
|
+
role: 'user';
|
|
60
|
+
content: Array<
|
|
61
|
+
| { type: 'input_text'; text: string }
|
|
62
|
+
| { type: 'input_image'; image_url: string }
|
|
63
|
+
| { type: 'input_image'; file_id: string }
|
|
64
|
+
| { type: 'input_file'; file_url: string }
|
|
65
|
+
| { type: 'input_file'; filename: string; file_data: string }
|
|
66
|
+
| { type: 'input_file'; file_id: string }
|
|
67
|
+
>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type OpenAIResponsesAssistantMessage = {
|
|
71
|
+
role: 'assistant';
|
|
72
|
+
content: Array<{ type: 'output_text'; text: string }>;
|
|
73
|
+
id?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type OpenAIResponsesFunctionCall = {
|
|
77
|
+
type: 'function_call';
|
|
78
|
+
call_id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
arguments: string;
|
|
81
|
+
id?: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type OpenAIResponsesFunctionCallOutput = {
|
|
85
|
+
type: 'function_call_output';
|
|
86
|
+
call_id: string;
|
|
87
|
+
output:
|
|
88
|
+
| string
|
|
89
|
+
| Array<
|
|
90
|
+
| { type: 'input_text'; text: string }
|
|
91
|
+
| { type: 'input_image'; image_url: string }
|
|
92
|
+
| { type: 'input_file'; filename: string; file_data: string }
|
|
93
|
+
>;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type OpenAIResponsesMcpApprovalResponse = {
|
|
97
|
+
type: 'mcp_approval_response';
|
|
98
|
+
approval_request_id: string;
|
|
99
|
+
approve: boolean;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type OpenAIResponsesComputerCall = {
|
|
103
|
+
type: 'computer_call';
|
|
104
|
+
id: string;
|
|
105
|
+
status?: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type OpenAIResponsesLocalShellCall = {
|
|
109
|
+
type: 'local_shell_call';
|
|
110
|
+
id: string;
|
|
111
|
+
call_id: string;
|
|
112
|
+
action: {
|
|
113
|
+
type: 'exec';
|
|
114
|
+
command: string[];
|
|
115
|
+
timeout_ms?: number;
|
|
116
|
+
user?: string;
|
|
117
|
+
working_directory?: string;
|
|
118
|
+
env?: Record<string, string>;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type OpenAIResponsesLocalShellCallOutput = {
|
|
123
|
+
type: 'local_shell_call_output';
|
|
124
|
+
call_id: string;
|
|
125
|
+
output: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Official OpenAI API Specifications: https://platform.openai.com/docs/api-reference/responses/object#responses-object-output-shell_tool_call
|
|
130
|
+
*/
|
|
131
|
+
export type OpenAIResponsesShellCall = {
|
|
132
|
+
type: 'shell_call';
|
|
133
|
+
id: string;
|
|
134
|
+
call_id: string;
|
|
135
|
+
status: 'in_progress' | 'completed' | 'incomplete';
|
|
136
|
+
action: {
|
|
137
|
+
commands: string[];
|
|
138
|
+
timeout_ms?: number;
|
|
139
|
+
max_output_length?: number;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export type OpenAIResponsesShellCallOutput = {
|
|
144
|
+
type: 'shell_call_output';
|
|
145
|
+
call_id: string;
|
|
146
|
+
max_output_length?: number;
|
|
147
|
+
output: Array<{
|
|
148
|
+
stdout: string;
|
|
149
|
+
stderr: string;
|
|
150
|
+
outcome: { type: 'timeout' } | { type: 'exit'; exit_code: number };
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type OpenAIResponsesApplyPatchCall = {
|
|
155
|
+
type: 'apply_patch_call';
|
|
156
|
+
id?: string;
|
|
157
|
+
call_id: string;
|
|
158
|
+
status: 'in_progress' | 'completed';
|
|
159
|
+
operation:
|
|
160
|
+
| {
|
|
161
|
+
type: 'create_file';
|
|
162
|
+
path: string;
|
|
163
|
+
diff: string;
|
|
164
|
+
}
|
|
165
|
+
| {
|
|
166
|
+
type: 'delete_file';
|
|
167
|
+
path: string;
|
|
168
|
+
}
|
|
169
|
+
| {
|
|
170
|
+
type: 'update_file';
|
|
171
|
+
path: string;
|
|
172
|
+
diff: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type OpenAIResponsesApplyPatchCallOutput = {
|
|
177
|
+
type: 'apply_patch_call_output';
|
|
178
|
+
call_id: string;
|
|
179
|
+
status: 'completed' | 'failed';
|
|
180
|
+
output?: string;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export type OpenAIResponsesItemReference = {
|
|
184
|
+
type: 'item_reference';
|
|
185
|
+
id: string;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A filter used to compare a specified attribute key to a given value using a defined comparison operation.
|
|
190
|
+
*/
|
|
191
|
+
export type OpenAIResponsesFileSearchToolComparisonFilter = {
|
|
192
|
+
/**
|
|
193
|
+
* The key to compare against the value.
|
|
194
|
+
*/
|
|
195
|
+
key: string;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Specifies the comparison operator: eq, ne, gt, gte, lt, lte, in, nin.
|
|
199
|
+
*/
|
|
200
|
+
type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin';
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The value to compare against the attribute key; supports string, number, boolean, or array of string types.
|
|
204
|
+
*/
|
|
205
|
+
value: string | number | boolean | string[];
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Combine multiple filters using and or or.
|
|
210
|
+
*/
|
|
211
|
+
export type OpenAIResponsesFileSearchToolCompoundFilter = {
|
|
212
|
+
/**
|
|
213
|
+
* Type of operation: and or or.
|
|
214
|
+
*/
|
|
215
|
+
type: 'and' | 'or';
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.
|
|
219
|
+
*/
|
|
220
|
+
filters: Array<
|
|
221
|
+
| OpenAIResponsesFileSearchToolComparisonFilter
|
|
222
|
+
| OpenAIResponsesFileSearchToolCompoundFilter
|
|
223
|
+
>;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export type OpenAIResponsesTool =
|
|
227
|
+
| {
|
|
228
|
+
type: 'function';
|
|
229
|
+
name: string;
|
|
230
|
+
description: string | undefined;
|
|
231
|
+
parameters: JSONSchema7;
|
|
232
|
+
strict?: boolean;
|
|
233
|
+
}
|
|
234
|
+
| {
|
|
235
|
+
type: 'apply_patch';
|
|
236
|
+
}
|
|
237
|
+
| {
|
|
238
|
+
type: 'web_search';
|
|
239
|
+
external_web_access: boolean | undefined;
|
|
240
|
+
filters: { allowed_domains: string[] | undefined } | undefined;
|
|
241
|
+
search_context_size: 'low' | 'medium' | 'high' | undefined;
|
|
242
|
+
user_location:
|
|
243
|
+
| {
|
|
244
|
+
type: 'approximate';
|
|
245
|
+
city?: string;
|
|
246
|
+
country?: string;
|
|
247
|
+
region?: string;
|
|
248
|
+
timezone?: string;
|
|
249
|
+
}
|
|
250
|
+
| undefined;
|
|
251
|
+
}
|
|
252
|
+
| {
|
|
253
|
+
type: 'web_search_preview';
|
|
254
|
+
search_context_size: 'low' | 'medium' | 'high' | undefined;
|
|
255
|
+
user_location:
|
|
256
|
+
| {
|
|
257
|
+
type: 'approximate';
|
|
258
|
+
city?: string;
|
|
259
|
+
country?: string;
|
|
260
|
+
region?: string;
|
|
261
|
+
timezone?: string;
|
|
262
|
+
}
|
|
263
|
+
| undefined;
|
|
264
|
+
}
|
|
265
|
+
| {
|
|
266
|
+
type: 'code_interpreter';
|
|
267
|
+
container: string | { type: 'auto'; file_ids: string[] | undefined };
|
|
268
|
+
}
|
|
269
|
+
| {
|
|
270
|
+
type: 'file_search';
|
|
271
|
+
vector_store_ids: string[];
|
|
272
|
+
max_num_results: number | undefined;
|
|
273
|
+
ranking_options:
|
|
274
|
+
| { ranker?: string; score_threshold?: number }
|
|
275
|
+
| undefined;
|
|
276
|
+
filters:
|
|
277
|
+
| OpenAIResponsesFileSearchToolComparisonFilter
|
|
278
|
+
| OpenAIResponsesFileSearchToolCompoundFilter
|
|
279
|
+
| undefined;
|
|
280
|
+
}
|
|
281
|
+
| {
|
|
282
|
+
type: 'image_generation';
|
|
283
|
+
background: 'auto' | 'opaque' | 'transparent' | undefined;
|
|
284
|
+
input_fidelity: 'low' | 'high' | undefined;
|
|
285
|
+
input_image_mask:
|
|
286
|
+
| {
|
|
287
|
+
file_id: string | undefined;
|
|
288
|
+
image_url: string | undefined;
|
|
289
|
+
}
|
|
290
|
+
| undefined;
|
|
291
|
+
model: string | undefined;
|
|
292
|
+
moderation: 'auto' | undefined;
|
|
293
|
+
output_compression: number | undefined;
|
|
294
|
+
output_format: 'png' | 'jpeg' | 'webp' | undefined;
|
|
295
|
+
partial_images: number | undefined;
|
|
296
|
+
quality: 'auto' | 'low' | 'medium' | 'high' | undefined;
|
|
297
|
+
size: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | undefined;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Official OpenAI API Specifications: https://platform.openai.com/docs/api-reference/responses/create#responses_create-tools-mcp_tool
|
|
302
|
+
*/
|
|
303
|
+
| {
|
|
304
|
+
type: 'mcp';
|
|
305
|
+
server_label: string;
|
|
306
|
+
allowed_tools:
|
|
307
|
+
| string[]
|
|
308
|
+
| {
|
|
309
|
+
read_only?: boolean;
|
|
310
|
+
tool_names?: string[];
|
|
311
|
+
}
|
|
312
|
+
| undefined;
|
|
313
|
+
authorization: string | undefined;
|
|
314
|
+
connector_id: string | undefined;
|
|
315
|
+
headers: Record<string, string> | undefined;
|
|
316
|
+
require_approval:
|
|
317
|
+
| 'always'
|
|
318
|
+
| 'never'
|
|
319
|
+
| {
|
|
320
|
+
never?: { tool_names?: string[] };
|
|
321
|
+
}
|
|
322
|
+
| undefined;
|
|
323
|
+
server_description: string | undefined;
|
|
324
|
+
server_url: string | undefined;
|
|
325
|
+
}
|
|
326
|
+
| {
|
|
327
|
+
type: 'local_shell';
|
|
328
|
+
}
|
|
329
|
+
| {
|
|
330
|
+
type: 'shell';
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export type OpenAIResponsesReasoning = {
|
|
334
|
+
type: 'reasoning';
|
|
335
|
+
id: string;
|
|
336
|
+
encrypted_content?: string | null;
|
|
337
|
+
summary: Array<{
|
|
338
|
+
type: 'summary_text';
|
|
339
|
+
text: string;
|
|
340
|
+
}>;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
344
|
+
zodSchema(
|
|
345
|
+
z.union([
|
|
346
|
+
z.object({
|
|
347
|
+
type: z.literal('response.output_text.delta'),
|
|
348
|
+
item_id: z.string(),
|
|
349
|
+
delta: z.string(),
|
|
350
|
+
logprobs: z
|
|
351
|
+
.array(
|
|
352
|
+
z.object({
|
|
353
|
+
token: z.string(),
|
|
354
|
+
logprob: z.number(),
|
|
355
|
+
top_logprobs: z.array(
|
|
356
|
+
z.object({
|
|
357
|
+
token: z.string(),
|
|
358
|
+
logprob: z.number(),
|
|
359
|
+
}),
|
|
360
|
+
),
|
|
361
|
+
}),
|
|
362
|
+
)
|
|
363
|
+
.nullish(),
|
|
364
|
+
}),
|
|
365
|
+
z.object({
|
|
366
|
+
type: z.enum(['response.completed', 'response.incomplete']),
|
|
367
|
+
response: z.object({
|
|
368
|
+
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
369
|
+
usage: z.object({
|
|
370
|
+
input_tokens: z.number(),
|
|
371
|
+
input_tokens_details: z
|
|
372
|
+
.object({ cached_tokens: z.number().nullish() })
|
|
373
|
+
.nullish(),
|
|
374
|
+
output_tokens: z.number(),
|
|
375
|
+
output_tokens_details: z
|
|
376
|
+
.object({ reasoning_tokens: z.number().nullish() })
|
|
377
|
+
.nullish(),
|
|
378
|
+
}),
|
|
379
|
+
service_tier: z.string().nullish(),
|
|
380
|
+
}),
|
|
381
|
+
}),
|
|
382
|
+
z.object({
|
|
383
|
+
type: z.literal('response.created'),
|
|
384
|
+
response: z.object({
|
|
385
|
+
id: z.string(),
|
|
386
|
+
created_at: z.number(),
|
|
387
|
+
model: z.string(),
|
|
388
|
+
service_tier: z.string().nullish(),
|
|
389
|
+
}),
|
|
390
|
+
}),
|
|
391
|
+
z.object({
|
|
392
|
+
type: z.literal('response.output_item.added'),
|
|
393
|
+
output_index: z.number(),
|
|
394
|
+
item: z.discriminatedUnion('type', [
|
|
395
|
+
z.object({
|
|
396
|
+
type: z.literal('message'),
|
|
397
|
+
id: z.string(),
|
|
398
|
+
}),
|
|
399
|
+
z.object({
|
|
400
|
+
type: z.literal('reasoning'),
|
|
401
|
+
id: z.string(),
|
|
402
|
+
encrypted_content: z.string().nullish(),
|
|
403
|
+
}),
|
|
404
|
+
z.object({
|
|
405
|
+
type: z.literal('function_call'),
|
|
406
|
+
id: z.string(),
|
|
407
|
+
call_id: z.string(),
|
|
408
|
+
name: z.string(),
|
|
409
|
+
arguments: z.string(),
|
|
410
|
+
}),
|
|
411
|
+
z.object({
|
|
412
|
+
type: z.literal('web_search_call'),
|
|
413
|
+
id: z.string(),
|
|
414
|
+
status: z.string(),
|
|
415
|
+
}),
|
|
416
|
+
z.object({
|
|
417
|
+
type: z.literal('computer_call'),
|
|
418
|
+
id: z.string(),
|
|
419
|
+
status: z.string(),
|
|
420
|
+
}),
|
|
421
|
+
z.object({
|
|
422
|
+
type: z.literal('file_search_call'),
|
|
423
|
+
id: z.string(),
|
|
424
|
+
}),
|
|
425
|
+
z.object({
|
|
426
|
+
type: z.literal('image_generation_call'),
|
|
427
|
+
id: z.string(),
|
|
428
|
+
}),
|
|
429
|
+
z.object({
|
|
430
|
+
type: z.literal('code_interpreter_call'),
|
|
431
|
+
id: z.string(),
|
|
432
|
+
container_id: z.string(),
|
|
433
|
+
code: z.string().nullable(),
|
|
434
|
+
outputs: z
|
|
435
|
+
.array(
|
|
436
|
+
z.discriminatedUnion('type', [
|
|
437
|
+
z.object({ type: z.literal('logs'), logs: z.string() }),
|
|
438
|
+
z.object({ type: z.literal('image'), url: z.string() }),
|
|
439
|
+
]),
|
|
440
|
+
)
|
|
441
|
+
.nullable(),
|
|
442
|
+
status: z.string(),
|
|
443
|
+
}),
|
|
444
|
+
z.object({
|
|
445
|
+
type: z.literal('mcp_call'),
|
|
446
|
+
id: z.string(),
|
|
447
|
+
status: z.string(),
|
|
448
|
+
approval_request_id: z.string().nullish(),
|
|
449
|
+
}),
|
|
450
|
+
z.object({
|
|
451
|
+
type: z.literal('mcp_list_tools'),
|
|
452
|
+
id: z.string(),
|
|
453
|
+
}),
|
|
454
|
+
z.object({
|
|
455
|
+
type: z.literal('mcp_approval_request'),
|
|
456
|
+
id: z.string(),
|
|
457
|
+
}),
|
|
458
|
+
z.object({
|
|
459
|
+
type: z.literal('apply_patch_call'),
|
|
460
|
+
id: z.string(),
|
|
461
|
+
call_id: z.string(),
|
|
462
|
+
status: z.enum(['in_progress', 'completed']),
|
|
463
|
+
operation: z.discriminatedUnion('type', [
|
|
464
|
+
z.object({
|
|
465
|
+
type: z.literal('create_file'),
|
|
466
|
+
path: z.string(),
|
|
467
|
+
diff: z.string(),
|
|
468
|
+
}),
|
|
469
|
+
z.object({
|
|
470
|
+
type: z.literal('delete_file'),
|
|
471
|
+
path: z.string(),
|
|
472
|
+
}),
|
|
473
|
+
z.object({
|
|
474
|
+
type: z.literal('update_file'),
|
|
475
|
+
path: z.string(),
|
|
476
|
+
diff: z.string(),
|
|
477
|
+
}),
|
|
478
|
+
]),
|
|
479
|
+
}),
|
|
480
|
+
z.object({
|
|
481
|
+
type: z.literal('shell_call'),
|
|
482
|
+
id: z.string(),
|
|
483
|
+
call_id: z.string(),
|
|
484
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
485
|
+
action: z.object({
|
|
486
|
+
commands: z.array(z.string()),
|
|
487
|
+
}),
|
|
488
|
+
}),
|
|
489
|
+
]),
|
|
490
|
+
}),
|
|
491
|
+
z.object({
|
|
492
|
+
type: z.literal('response.output_item.done'),
|
|
493
|
+
output_index: z.number(),
|
|
494
|
+
item: z.discriminatedUnion('type', [
|
|
495
|
+
z.object({
|
|
496
|
+
type: z.literal('message'),
|
|
497
|
+
id: z.string(),
|
|
498
|
+
}),
|
|
499
|
+
z.object({
|
|
500
|
+
type: z.literal('reasoning'),
|
|
501
|
+
id: z.string(),
|
|
502
|
+
encrypted_content: z.string().nullish(),
|
|
503
|
+
}),
|
|
504
|
+
z.object({
|
|
505
|
+
type: z.literal('function_call'),
|
|
506
|
+
id: z.string(),
|
|
507
|
+
call_id: z.string(),
|
|
508
|
+
name: z.string(),
|
|
509
|
+
arguments: z.string(),
|
|
510
|
+
status: z.literal('completed'),
|
|
511
|
+
}),
|
|
512
|
+
z.object({
|
|
513
|
+
type: z.literal('code_interpreter_call'),
|
|
514
|
+
id: z.string(),
|
|
515
|
+
code: z.string().nullable(),
|
|
516
|
+
container_id: z.string(),
|
|
517
|
+
outputs: z
|
|
518
|
+
.array(
|
|
519
|
+
z.discriminatedUnion('type', [
|
|
520
|
+
z.object({ type: z.literal('logs'), logs: z.string() }),
|
|
521
|
+
z.object({ type: z.literal('image'), url: z.string() }),
|
|
522
|
+
]),
|
|
523
|
+
)
|
|
524
|
+
.nullable(),
|
|
525
|
+
}),
|
|
526
|
+
z.object({
|
|
527
|
+
type: z.literal('image_generation_call'),
|
|
528
|
+
id: z.string(),
|
|
529
|
+
result: z.string(),
|
|
530
|
+
}),
|
|
531
|
+
z.object({
|
|
532
|
+
type: z.literal('web_search_call'),
|
|
533
|
+
id: z.string(),
|
|
534
|
+
status: z.string(),
|
|
535
|
+
action: z.discriminatedUnion('type', [
|
|
536
|
+
z.object({
|
|
537
|
+
type: z.literal('search'),
|
|
538
|
+
query: z.string().nullish(),
|
|
539
|
+
sources: z
|
|
540
|
+
.array(
|
|
541
|
+
z.discriminatedUnion('type', [
|
|
542
|
+
z.object({ type: z.literal('url'), url: z.string() }),
|
|
543
|
+
z.object({ type: z.literal('api'), name: z.string() }),
|
|
544
|
+
]),
|
|
545
|
+
)
|
|
546
|
+
.nullish(),
|
|
547
|
+
}),
|
|
548
|
+
z.object({
|
|
549
|
+
type: z.literal('open_page'),
|
|
550
|
+
url: z.string().nullish(),
|
|
551
|
+
}),
|
|
552
|
+
z.object({
|
|
553
|
+
type: z.literal('find_in_page'),
|
|
554
|
+
url: z.string().nullish(),
|
|
555
|
+
pattern: z.string().nullish(),
|
|
556
|
+
}),
|
|
557
|
+
]),
|
|
558
|
+
}),
|
|
559
|
+
z.object({
|
|
560
|
+
type: z.literal('file_search_call'),
|
|
561
|
+
id: z.string(),
|
|
562
|
+
queries: z.array(z.string()),
|
|
563
|
+
results: z
|
|
564
|
+
.array(
|
|
565
|
+
z.object({
|
|
566
|
+
attributes: z.record(
|
|
567
|
+
z.string(),
|
|
568
|
+
z.union([z.string(), z.number(), z.boolean()]),
|
|
569
|
+
),
|
|
570
|
+
file_id: z.string(),
|
|
571
|
+
filename: z.string(),
|
|
572
|
+
score: z.number(),
|
|
573
|
+
text: z.string(),
|
|
574
|
+
}),
|
|
575
|
+
)
|
|
576
|
+
.nullish(),
|
|
577
|
+
}),
|
|
578
|
+
z.object({
|
|
579
|
+
type: z.literal('local_shell_call'),
|
|
580
|
+
id: z.string(),
|
|
581
|
+
call_id: z.string(),
|
|
582
|
+
action: z.object({
|
|
583
|
+
type: z.literal('exec'),
|
|
584
|
+
command: z.array(z.string()),
|
|
585
|
+
timeout_ms: z.number().optional(),
|
|
586
|
+
user: z.string().optional(),
|
|
587
|
+
working_directory: z.string().optional(),
|
|
588
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
589
|
+
}),
|
|
590
|
+
}),
|
|
591
|
+
z.object({
|
|
592
|
+
type: z.literal('computer_call'),
|
|
593
|
+
id: z.string(),
|
|
594
|
+
status: z.literal('completed'),
|
|
595
|
+
}),
|
|
596
|
+
z.object({
|
|
597
|
+
type: z.literal('mcp_call'),
|
|
598
|
+
id: z.string(),
|
|
599
|
+
status: z.string(),
|
|
600
|
+
arguments: z.string(),
|
|
601
|
+
name: z.string(),
|
|
602
|
+
server_label: z.string(),
|
|
603
|
+
output: z.string().nullish(),
|
|
604
|
+
error: z
|
|
605
|
+
.union([
|
|
606
|
+
z.string(),
|
|
607
|
+
z
|
|
608
|
+
.object({
|
|
609
|
+
type: z.string().optional(),
|
|
610
|
+
code: z.union([z.number(), z.string()]).optional(),
|
|
611
|
+
message: z.string().optional(),
|
|
612
|
+
})
|
|
613
|
+
.loose(),
|
|
614
|
+
])
|
|
615
|
+
.nullish(),
|
|
616
|
+
approval_request_id: z.string().nullish(),
|
|
617
|
+
}),
|
|
618
|
+
z.object({
|
|
619
|
+
type: z.literal('mcp_list_tools'),
|
|
620
|
+
id: z.string(),
|
|
621
|
+
server_label: z.string(),
|
|
622
|
+
tools: z.array(
|
|
623
|
+
z.object({
|
|
624
|
+
name: z.string(),
|
|
625
|
+
description: z.string().optional(),
|
|
626
|
+
input_schema: z.any(),
|
|
627
|
+
annotations: z.record(z.string(), z.unknown()).optional(),
|
|
628
|
+
}),
|
|
629
|
+
),
|
|
630
|
+
error: z
|
|
631
|
+
.union([
|
|
632
|
+
z.string(),
|
|
633
|
+
z
|
|
634
|
+
.object({
|
|
635
|
+
type: z.string().optional(),
|
|
636
|
+
code: z.union([z.number(), z.string()]).optional(),
|
|
637
|
+
message: z.string().optional(),
|
|
638
|
+
})
|
|
639
|
+
.loose(),
|
|
640
|
+
])
|
|
641
|
+
.optional(),
|
|
642
|
+
}),
|
|
643
|
+
z.object({
|
|
644
|
+
type: z.literal('mcp_approval_request'),
|
|
645
|
+
id: z.string(),
|
|
646
|
+
server_label: z.string(),
|
|
647
|
+
name: z.string(),
|
|
648
|
+
arguments: z.string(),
|
|
649
|
+
approval_request_id: z.string().optional(),
|
|
650
|
+
}),
|
|
651
|
+
z.object({
|
|
652
|
+
type: z.literal('apply_patch_call'),
|
|
653
|
+
id: z.string(),
|
|
654
|
+
call_id: z.string(),
|
|
655
|
+
status: z.enum(['in_progress', 'completed']),
|
|
656
|
+
operation: z.discriminatedUnion('type', [
|
|
657
|
+
z.object({
|
|
658
|
+
type: z.literal('create_file'),
|
|
659
|
+
path: z.string(),
|
|
660
|
+
diff: z.string(),
|
|
661
|
+
}),
|
|
662
|
+
z.object({
|
|
663
|
+
type: z.literal('delete_file'),
|
|
664
|
+
path: z.string(),
|
|
665
|
+
}),
|
|
666
|
+
z.object({
|
|
667
|
+
type: z.literal('update_file'),
|
|
668
|
+
path: z.string(),
|
|
669
|
+
diff: z.string(),
|
|
670
|
+
}),
|
|
671
|
+
]),
|
|
672
|
+
}),
|
|
673
|
+
z.object({
|
|
674
|
+
type: z.literal('shell_call'),
|
|
675
|
+
id: z.string(),
|
|
676
|
+
call_id: z.string(),
|
|
677
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
678
|
+
action: z.object({
|
|
679
|
+
commands: z.array(z.string()),
|
|
680
|
+
}),
|
|
681
|
+
}),
|
|
682
|
+
]),
|
|
683
|
+
}),
|
|
684
|
+
z.object({
|
|
685
|
+
type: z.literal('response.function_call_arguments.delta'),
|
|
686
|
+
item_id: z.string(),
|
|
687
|
+
output_index: z.number(),
|
|
688
|
+
delta: z.string(),
|
|
689
|
+
}),
|
|
690
|
+
z.object({
|
|
691
|
+
type: z.literal('response.image_generation_call.partial_image'),
|
|
692
|
+
item_id: z.string(),
|
|
693
|
+
output_index: z.number(),
|
|
694
|
+
partial_image_b64: z.string(),
|
|
695
|
+
}),
|
|
696
|
+
z.object({
|
|
697
|
+
type: z.literal('response.code_interpreter_call_code.delta'),
|
|
698
|
+
item_id: z.string(),
|
|
699
|
+
output_index: z.number(),
|
|
700
|
+
delta: z.string(),
|
|
701
|
+
}),
|
|
702
|
+
z.object({
|
|
703
|
+
type: z.literal('response.code_interpreter_call_code.done'),
|
|
704
|
+
item_id: z.string(),
|
|
705
|
+
output_index: z.number(),
|
|
706
|
+
code: z.string(),
|
|
707
|
+
}),
|
|
708
|
+
z.object({
|
|
709
|
+
type: z.literal('response.output_text.annotation.added'),
|
|
710
|
+
annotation: z.discriminatedUnion('type', [
|
|
711
|
+
z.object({
|
|
712
|
+
type: z.literal('url_citation'),
|
|
713
|
+
start_index: z.number(),
|
|
714
|
+
end_index: z.number(),
|
|
715
|
+
url: z.string(),
|
|
716
|
+
title: z.string(),
|
|
717
|
+
}),
|
|
718
|
+
z.object({
|
|
719
|
+
type: z.literal('file_citation'),
|
|
720
|
+
file_id: z.string(),
|
|
721
|
+
filename: z.string(),
|
|
722
|
+
index: z.number(),
|
|
723
|
+
}),
|
|
724
|
+
z.object({
|
|
725
|
+
type: z.literal('container_file_citation'),
|
|
726
|
+
container_id: z.string(),
|
|
727
|
+
file_id: z.string(),
|
|
728
|
+
filename: z.string(),
|
|
729
|
+
start_index: z.number(),
|
|
730
|
+
end_index: z.number(),
|
|
731
|
+
}),
|
|
732
|
+
z.object({
|
|
733
|
+
type: z.literal('file_path'),
|
|
734
|
+
file_id: z.string(),
|
|
735
|
+
index: z.number(),
|
|
736
|
+
}),
|
|
737
|
+
]),
|
|
738
|
+
}),
|
|
739
|
+
z.object({
|
|
740
|
+
type: z.literal('response.reasoning_summary_part.added'),
|
|
741
|
+
item_id: z.string(),
|
|
742
|
+
summary_index: z.number(),
|
|
743
|
+
}),
|
|
744
|
+
z.object({
|
|
745
|
+
type: z.literal('response.reasoning_summary_text.delta'),
|
|
746
|
+
item_id: z.string(),
|
|
747
|
+
summary_index: z.number(),
|
|
748
|
+
delta: z.string(),
|
|
749
|
+
}),
|
|
750
|
+
z.object({
|
|
751
|
+
type: z.literal('response.reasoning_summary_part.done'),
|
|
752
|
+
item_id: z.string(),
|
|
753
|
+
summary_index: z.number(),
|
|
754
|
+
}),
|
|
755
|
+
z.object({
|
|
756
|
+
type: z.literal('response.apply_patch_call_operation_diff.delta'),
|
|
757
|
+
item_id: z.string(),
|
|
758
|
+
output_index: z.number(),
|
|
759
|
+
delta: z.string(),
|
|
760
|
+
obfuscation: z.string().nullish(),
|
|
761
|
+
}),
|
|
762
|
+
z.object({
|
|
763
|
+
type: z.literal('response.apply_patch_call_operation_diff.done'),
|
|
764
|
+
item_id: z.string(),
|
|
765
|
+
output_index: z.number(),
|
|
766
|
+
diff: z.string(),
|
|
767
|
+
}),
|
|
768
|
+
z.object({
|
|
769
|
+
type: z.literal('error'),
|
|
770
|
+
sequence_number: z.number(),
|
|
771
|
+
error: z.object({
|
|
772
|
+
type: z.string(),
|
|
773
|
+
code: z.string(),
|
|
774
|
+
message: z.string(),
|
|
775
|
+
param: z.string().nullish(),
|
|
776
|
+
}),
|
|
777
|
+
}),
|
|
778
|
+
z
|
|
779
|
+
.object({ type: z.string() })
|
|
780
|
+
.loose()
|
|
781
|
+
.transform(value => ({
|
|
782
|
+
type: 'unknown_chunk' as const,
|
|
783
|
+
message: value.type,
|
|
784
|
+
})), // fallback for unknown chunks
|
|
785
|
+
]),
|
|
786
|
+
),
|
|
787
|
+
);
|
|
788
|
+
|
|
789
|
+
export type OpenAIResponsesChunk = InferSchema<
|
|
790
|
+
typeof openaiResponsesChunkSchema
|
|
791
|
+
>;
|
|
792
|
+
|
|
793
|
+
export type OpenAIResponsesLogprobs = NonNullable<
|
|
794
|
+
(OpenAIResponsesChunk & {
|
|
795
|
+
type: 'response.output_text.delta';
|
|
796
|
+
})['logprobs']
|
|
797
|
+
> | null;
|
|
798
|
+
|
|
799
|
+
export type OpenAIResponsesWebSearchAction = NonNullable<
|
|
800
|
+
((OpenAIResponsesChunk & {
|
|
801
|
+
type: 'response.output_item.done';
|
|
802
|
+
})['item'] & {
|
|
803
|
+
type: 'web_search_call';
|
|
804
|
+
})['action']
|
|
805
|
+
>;
|
|
806
|
+
|
|
807
|
+
export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
808
|
+
zodSchema(
|
|
809
|
+
z.object({
|
|
810
|
+
id: z.string().optional(),
|
|
811
|
+
created_at: z.number().optional(),
|
|
812
|
+
error: z
|
|
813
|
+
.object({
|
|
814
|
+
message: z.string(),
|
|
815
|
+
type: z.string(),
|
|
816
|
+
param: z.string().nullish(),
|
|
817
|
+
code: z.string(),
|
|
818
|
+
})
|
|
819
|
+
.nullish(),
|
|
820
|
+
model: z.string().optional(),
|
|
821
|
+
output: z
|
|
822
|
+
.array(
|
|
823
|
+
z.discriminatedUnion('type', [
|
|
824
|
+
z.object({
|
|
825
|
+
type: z.literal('message'),
|
|
826
|
+
role: z.literal('assistant'),
|
|
827
|
+
id: z.string(),
|
|
828
|
+
content: z.array(
|
|
829
|
+
z.object({
|
|
830
|
+
type: z.literal('output_text'),
|
|
831
|
+
text: z.string(),
|
|
832
|
+
logprobs: z
|
|
833
|
+
.array(
|
|
834
|
+
z.object({
|
|
835
|
+
token: z.string(),
|
|
836
|
+
logprob: z.number(),
|
|
837
|
+
top_logprobs: z.array(
|
|
838
|
+
z.object({
|
|
839
|
+
token: z.string(),
|
|
840
|
+
logprob: z.number(),
|
|
841
|
+
}),
|
|
842
|
+
),
|
|
843
|
+
}),
|
|
844
|
+
)
|
|
845
|
+
.nullish(),
|
|
846
|
+
annotations: z.array(
|
|
847
|
+
z.discriminatedUnion('type', [
|
|
848
|
+
z.object({
|
|
849
|
+
type: z.literal('url_citation'),
|
|
850
|
+
start_index: z.number(),
|
|
851
|
+
end_index: z.number(),
|
|
852
|
+
url: z.string(),
|
|
853
|
+
title: z.string(),
|
|
854
|
+
}),
|
|
855
|
+
z.object({
|
|
856
|
+
type: z.literal('file_citation'),
|
|
857
|
+
file_id: z.string(),
|
|
858
|
+
filename: z.string(),
|
|
859
|
+
index: z.number(),
|
|
860
|
+
}),
|
|
861
|
+
z.object({
|
|
862
|
+
type: z.literal('container_file_citation'),
|
|
863
|
+
container_id: z.string(),
|
|
864
|
+
file_id: z.string(),
|
|
865
|
+
filename: z.string(),
|
|
866
|
+
start_index: z.number(),
|
|
867
|
+
end_index: z.number(),
|
|
868
|
+
}),
|
|
869
|
+
z.object({
|
|
870
|
+
type: z.literal('file_path'),
|
|
871
|
+
file_id: z.string(),
|
|
872
|
+
index: z.number(),
|
|
873
|
+
}),
|
|
874
|
+
]),
|
|
875
|
+
),
|
|
876
|
+
}),
|
|
877
|
+
),
|
|
878
|
+
}),
|
|
879
|
+
z.object({
|
|
880
|
+
type: z.literal('web_search_call'),
|
|
881
|
+
id: z.string(),
|
|
882
|
+
status: z.string(),
|
|
883
|
+
action: z.discriminatedUnion('type', [
|
|
884
|
+
z.object({
|
|
885
|
+
type: z.literal('search'),
|
|
886
|
+
query: z.string().nullish(),
|
|
887
|
+
sources: z
|
|
888
|
+
.array(
|
|
889
|
+
z.discriminatedUnion('type', [
|
|
890
|
+
z.object({ type: z.literal('url'), url: z.string() }),
|
|
891
|
+
z.object({ type: z.literal('api'), name: z.string() }),
|
|
892
|
+
]),
|
|
893
|
+
)
|
|
894
|
+
.nullish(),
|
|
895
|
+
}),
|
|
896
|
+
z.object({
|
|
897
|
+
type: z.literal('open_page'),
|
|
898
|
+
url: z.string().nullish(),
|
|
899
|
+
}),
|
|
900
|
+
z.object({
|
|
901
|
+
type: z.literal('find_in_page'),
|
|
902
|
+
url: z.string().nullish(),
|
|
903
|
+
pattern: z.string().nullish(),
|
|
904
|
+
}),
|
|
905
|
+
]),
|
|
906
|
+
}),
|
|
907
|
+
z.object({
|
|
908
|
+
type: z.literal('file_search_call'),
|
|
909
|
+
id: z.string(),
|
|
910
|
+
queries: z.array(z.string()),
|
|
911
|
+
results: z
|
|
912
|
+
.array(
|
|
913
|
+
z.object({
|
|
914
|
+
attributes: z.record(
|
|
915
|
+
z.string(),
|
|
916
|
+
z.union([z.string(), z.number(), z.boolean()]),
|
|
917
|
+
),
|
|
918
|
+
file_id: z.string(),
|
|
919
|
+
filename: z.string(),
|
|
920
|
+
score: z.number(),
|
|
921
|
+
text: z.string(),
|
|
922
|
+
}),
|
|
923
|
+
)
|
|
924
|
+
.nullish(),
|
|
925
|
+
}),
|
|
926
|
+
z.object({
|
|
927
|
+
type: z.literal('code_interpreter_call'),
|
|
928
|
+
id: z.string(),
|
|
929
|
+
code: z.string().nullable(),
|
|
930
|
+
container_id: z.string(),
|
|
931
|
+
outputs: z
|
|
932
|
+
.array(
|
|
933
|
+
z.discriminatedUnion('type', [
|
|
934
|
+
z.object({ type: z.literal('logs'), logs: z.string() }),
|
|
935
|
+
z.object({ type: z.literal('image'), url: z.string() }),
|
|
936
|
+
]),
|
|
937
|
+
)
|
|
938
|
+
.nullable(),
|
|
939
|
+
}),
|
|
940
|
+
z.object({
|
|
941
|
+
type: z.literal('image_generation_call'),
|
|
942
|
+
id: z.string(),
|
|
943
|
+
result: z.string(),
|
|
944
|
+
}),
|
|
945
|
+
z.object({
|
|
946
|
+
type: z.literal('local_shell_call'),
|
|
947
|
+
id: z.string(),
|
|
948
|
+
call_id: z.string(),
|
|
949
|
+
action: z.object({
|
|
950
|
+
type: z.literal('exec'),
|
|
951
|
+
command: z.array(z.string()),
|
|
952
|
+
timeout_ms: z.number().optional(),
|
|
953
|
+
user: z.string().optional(),
|
|
954
|
+
working_directory: z.string().optional(),
|
|
955
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
956
|
+
}),
|
|
957
|
+
}),
|
|
958
|
+
z.object({
|
|
959
|
+
type: z.literal('function_call'),
|
|
960
|
+
call_id: z.string(),
|
|
961
|
+
name: z.string(),
|
|
962
|
+
arguments: z.string(),
|
|
963
|
+
id: z.string(),
|
|
964
|
+
}),
|
|
965
|
+
z.object({
|
|
966
|
+
type: z.literal('computer_call'),
|
|
967
|
+
id: z.string(),
|
|
968
|
+
status: z.string().optional(),
|
|
969
|
+
}),
|
|
970
|
+
z.object({
|
|
971
|
+
type: z.literal('reasoning'),
|
|
972
|
+
id: z.string(),
|
|
973
|
+
encrypted_content: z.string().nullish(),
|
|
974
|
+
summary: z.array(
|
|
975
|
+
z.object({
|
|
976
|
+
type: z.literal('summary_text'),
|
|
977
|
+
text: z.string(),
|
|
978
|
+
}),
|
|
979
|
+
),
|
|
980
|
+
}),
|
|
981
|
+
z.object({
|
|
982
|
+
type: z.literal('mcp_call'),
|
|
983
|
+
id: z.string(),
|
|
984
|
+
status: z.string(),
|
|
985
|
+
arguments: z.string(),
|
|
986
|
+
name: z.string(),
|
|
987
|
+
server_label: z.string(),
|
|
988
|
+
output: z.string().nullish(),
|
|
989
|
+
error: z
|
|
990
|
+
.union([
|
|
991
|
+
z.string(),
|
|
992
|
+
z
|
|
993
|
+
.object({
|
|
994
|
+
type: z.string().optional(),
|
|
995
|
+
code: z.union([z.number(), z.string()]).optional(),
|
|
996
|
+
message: z.string().optional(),
|
|
997
|
+
})
|
|
998
|
+
.loose(),
|
|
999
|
+
])
|
|
1000
|
+
.nullish(),
|
|
1001
|
+
approval_request_id: z.string().nullish(),
|
|
1002
|
+
}),
|
|
1003
|
+
z.object({
|
|
1004
|
+
type: z.literal('mcp_list_tools'),
|
|
1005
|
+
id: z.string(),
|
|
1006
|
+
server_label: z.string(),
|
|
1007
|
+
tools: z.array(
|
|
1008
|
+
z.object({
|
|
1009
|
+
name: z.string(),
|
|
1010
|
+
description: z.string().optional(),
|
|
1011
|
+
input_schema: z.any(),
|
|
1012
|
+
annotations: z.record(z.string(), z.unknown()).optional(),
|
|
1013
|
+
}),
|
|
1014
|
+
),
|
|
1015
|
+
error: z
|
|
1016
|
+
.union([
|
|
1017
|
+
z.string(),
|
|
1018
|
+
z
|
|
1019
|
+
.object({
|
|
1020
|
+
type: z.string().optional(),
|
|
1021
|
+
code: z.union([z.number(), z.string()]).optional(),
|
|
1022
|
+
message: z.string().optional(),
|
|
1023
|
+
})
|
|
1024
|
+
.loose(),
|
|
1025
|
+
])
|
|
1026
|
+
.optional(),
|
|
1027
|
+
}),
|
|
1028
|
+
z.object({
|
|
1029
|
+
type: z.literal('mcp_approval_request'),
|
|
1030
|
+
id: z.string(),
|
|
1031
|
+
server_label: z.string(),
|
|
1032
|
+
name: z.string(),
|
|
1033
|
+
arguments: z.string(),
|
|
1034
|
+
approval_request_id: z.string().optional(),
|
|
1035
|
+
}),
|
|
1036
|
+
z.object({
|
|
1037
|
+
type: z.literal('apply_patch_call'),
|
|
1038
|
+
id: z.string(),
|
|
1039
|
+
call_id: z.string(),
|
|
1040
|
+
status: z.enum(['in_progress', 'completed']),
|
|
1041
|
+
operation: z.discriminatedUnion('type', [
|
|
1042
|
+
z.object({
|
|
1043
|
+
type: z.literal('create_file'),
|
|
1044
|
+
path: z.string(),
|
|
1045
|
+
diff: z.string(),
|
|
1046
|
+
}),
|
|
1047
|
+
z.object({
|
|
1048
|
+
type: z.literal('delete_file'),
|
|
1049
|
+
path: z.string(),
|
|
1050
|
+
}),
|
|
1051
|
+
z.object({
|
|
1052
|
+
type: z.literal('update_file'),
|
|
1053
|
+
path: z.string(),
|
|
1054
|
+
diff: z.string(),
|
|
1055
|
+
}),
|
|
1056
|
+
]),
|
|
1057
|
+
}),
|
|
1058
|
+
z.object({
|
|
1059
|
+
type: z.literal('shell_call'),
|
|
1060
|
+
id: z.string(),
|
|
1061
|
+
call_id: z.string(),
|
|
1062
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1063
|
+
action: z.object({
|
|
1064
|
+
commands: z.array(z.string()),
|
|
1065
|
+
}),
|
|
1066
|
+
}),
|
|
1067
|
+
]),
|
|
1068
|
+
)
|
|
1069
|
+
.optional(),
|
|
1070
|
+
service_tier: z.string().nullish(),
|
|
1071
|
+
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
1072
|
+
usage: z
|
|
1073
|
+
.object({
|
|
1074
|
+
input_tokens: z.number(),
|
|
1075
|
+
input_tokens_details: z
|
|
1076
|
+
.object({ cached_tokens: z.number().nullish() })
|
|
1077
|
+
.nullish(),
|
|
1078
|
+
output_tokens: z.number(),
|
|
1079
|
+
output_tokens_details: z
|
|
1080
|
+
.object({ reasoning_tokens: z.number().nullish() })
|
|
1081
|
+
.nullish(),
|
|
1082
|
+
})
|
|
1083
|
+
.optional(),
|
|
1084
|
+
}),
|
|
1085
|
+
),
|
|
1086
|
+
);
|