@ai-sdk/openai 4.0.98 → 4.0.100
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 +27 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -89
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +31 -44
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +82 -72
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +52 -8
- package/package.json +3 -3
- package/src/chat/openai-chat-api.ts +1 -1
- package/src/chat/openai-chat-language-model.ts +2 -1
- package/src/completion/openai-completion-api.ts +1 -1
- package/src/completion/openai-completion-language-model.ts +2 -1
- package/src/files/openai-files.ts +1 -11
- package/src/image/openai-image-model-options.ts +40 -39
- package/src/live/openai-realtime-model-live.ts +13 -4
- package/src/openai-batch.ts +2 -2
- package/src/openai-decision-model.ts +55 -44
- package/src/openai-error.ts +22 -14
- package/src/responses/convert-openai-responses-usage.ts +6 -0
- package/src/responses/convert-to-openai-responses-input.ts +17 -11
- package/src/responses/openai-responses-api.ts +221 -192
- package/src/responses/openai-responses-language-model-options.ts +4 -2
- package/src/responses/openai-responses-language-model.ts +2 -1
- package/src/tool/computer.ts +64 -58
- package/src/tool/file-search.ts +15 -12
- package/src/tool/mcp.ts +13 -11
- package/src/tool/shell.ts +22 -21
|
@@ -8,152 +8,172 @@ import {
|
|
|
8
8
|
import { z } from 'zod/v4';
|
|
9
9
|
import type { OpenAIResponsesToolResultOptions } from './openai-responses-language-model-options';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
z.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
11
|
+
let cachedJsonValueSchema: z.ZodType<JSONValue> | undefined;
|
|
12
|
+
const jsonValueSchema = (): z.ZodType<JSONValue> =>
|
|
13
|
+
(cachedJsonValueSchema ??= z.lazy(() =>
|
|
14
|
+
z.union([
|
|
15
|
+
z.string(),
|
|
16
|
+
z.number(),
|
|
17
|
+
z.boolean(),
|
|
18
|
+
z.null(),
|
|
19
|
+
z.array(jsonValueSchema()),
|
|
20
|
+
z.record(z.string(), jsonValueSchema().optional()),
|
|
21
|
+
]),
|
|
22
|
+
));
|
|
21
23
|
|
|
22
|
-
const jsonObjectSchema =
|
|
24
|
+
const jsonObjectSchema = () =>
|
|
25
|
+
z.record(z.string(), jsonValueSchema().optional());
|
|
26
|
+
|
|
27
|
+
const openaiResponsesUsageSchema = () =>
|
|
28
|
+
z.intersection(
|
|
29
|
+
jsonObjectSchema(),
|
|
30
|
+
z.object({
|
|
31
|
+
input_tokens: z.number(),
|
|
32
|
+
input_tokens_details: z
|
|
33
|
+
.intersection(
|
|
34
|
+
jsonObjectSchema(),
|
|
35
|
+
z.object({
|
|
36
|
+
cached_tokens: z.number().nullish(),
|
|
37
|
+
cache_write_tokens: z.number().nullish(),
|
|
38
|
+
cache_write_tokens_details: z
|
|
39
|
+
.intersection(
|
|
40
|
+
jsonObjectSchema(),
|
|
41
|
+
z.object({
|
|
42
|
+
ttl_30m_tokens: z.number().nullish(),
|
|
43
|
+
ttl_12h_tokens: z.number().nullish(),
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
.nullish(),
|
|
47
|
+
orchestration_input_tokens: z.number().nullish(),
|
|
48
|
+
orchestration_input_cached_tokens: z.number().nullish(),
|
|
49
|
+
}),
|
|
50
|
+
)
|
|
51
|
+
.nullish(),
|
|
52
|
+
output_tokens: z.number(),
|
|
53
|
+
output_tokens_details: z
|
|
54
|
+
.intersection(
|
|
55
|
+
jsonObjectSchema(),
|
|
56
|
+
z.object({
|
|
57
|
+
reasoning_tokens: z.number().nullish(),
|
|
58
|
+
orchestration_output_tokens: z.number().nullish(),
|
|
59
|
+
}),
|
|
60
|
+
)
|
|
61
|
+
.nullish(),
|
|
62
|
+
total_tokens: z.number().optional(),
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
23
65
|
|
|
24
|
-
const
|
|
25
|
-
jsonObjectSchema,
|
|
66
|
+
const openaiResponsesComputerSafetyCheckSchema = () =>
|
|
26
67
|
z.object({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
z.object({
|
|
32
|
-
cached_tokens: z.number().nullish(),
|
|
33
|
-
cache_write_tokens: z.number().nullish(),
|
|
34
|
-
orchestration_input_tokens: z.number().nullish(),
|
|
35
|
-
orchestration_input_cached_tokens: z.number().nullish(),
|
|
36
|
-
}),
|
|
37
|
-
)
|
|
38
|
-
.nullish(),
|
|
39
|
-
output_tokens: z.number(),
|
|
40
|
-
output_tokens_details: z
|
|
41
|
-
.intersection(
|
|
42
|
-
jsonObjectSchema,
|
|
43
|
-
z.object({
|
|
44
|
-
reasoning_tokens: z.number().nullish(),
|
|
45
|
-
orchestration_output_tokens: z.number().nullish(),
|
|
46
|
-
}),
|
|
47
|
-
)
|
|
48
|
-
.nullish(),
|
|
49
|
-
total_tokens: z.number().optional(),
|
|
50
|
-
}),
|
|
51
|
-
);
|
|
68
|
+
id: z.string(),
|
|
69
|
+
code: z.string().nullish(),
|
|
70
|
+
message: z.string().nullish(),
|
|
71
|
+
});
|
|
52
72
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
73
|
+
const openaiResponsesComputerActionSchema = () =>
|
|
74
|
+
z.discriminatedUnion('type', [
|
|
75
|
+
z.object({
|
|
76
|
+
type: z.literal('click'),
|
|
77
|
+
button: z.enum(['left', 'right', 'wheel', 'back', 'forward']),
|
|
78
|
+
x: z.number(),
|
|
79
|
+
y: z.number(),
|
|
80
|
+
keys: z.array(z.string()).nullish(),
|
|
81
|
+
}),
|
|
82
|
+
z.object({
|
|
83
|
+
type: z.literal('double_click'),
|
|
84
|
+
x: z.number(),
|
|
85
|
+
y: z.number(),
|
|
86
|
+
keys: z.array(z.string()).nullish(),
|
|
87
|
+
}),
|
|
88
|
+
z.object({
|
|
89
|
+
type: z.literal('drag'),
|
|
90
|
+
path: z.array(z.object({ x: z.number(), y: z.number() })),
|
|
91
|
+
keys: z.array(z.string()).nullish(),
|
|
92
|
+
}),
|
|
93
|
+
z.object({
|
|
94
|
+
type: z.literal('keypress'),
|
|
95
|
+
keys: z.array(z.string()),
|
|
96
|
+
}),
|
|
97
|
+
z.object({
|
|
98
|
+
type: z.literal('move'),
|
|
99
|
+
x: z.number(),
|
|
100
|
+
y: z.number(),
|
|
101
|
+
keys: z.array(z.string()).nullish(),
|
|
102
|
+
}),
|
|
103
|
+
z.object({
|
|
104
|
+
type: z.literal('screenshot'),
|
|
105
|
+
}),
|
|
106
|
+
z.object({
|
|
107
|
+
type: z.literal('scroll'),
|
|
108
|
+
x: z.number(),
|
|
109
|
+
y: z.number(),
|
|
110
|
+
scroll_x: z.number(),
|
|
111
|
+
scroll_y: z.number(),
|
|
112
|
+
keys: z.array(z.string()).nullish(),
|
|
113
|
+
}),
|
|
114
|
+
z.object({
|
|
115
|
+
type: z.literal('type'),
|
|
116
|
+
text: z.string(),
|
|
117
|
+
}),
|
|
118
|
+
z.object({
|
|
119
|
+
type: z.literal('wait'),
|
|
120
|
+
}),
|
|
121
|
+
]);
|
|
58
122
|
|
|
59
|
-
const
|
|
60
|
-
z.object({
|
|
61
|
-
type: z.literal('click'),
|
|
62
|
-
button: z.enum(['left', 'right', 'wheel', 'back', 'forward']),
|
|
63
|
-
x: z.number(),
|
|
64
|
-
y: z.number(),
|
|
65
|
-
keys: z.array(z.string()).nullish(),
|
|
66
|
-
}),
|
|
67
|
-
z.object({
|
|
68
|
-
type: z.literal('double_click'),
|
|
69
|
-
x: z.number(),
|
|
70
|
-
y: z.number(),
|
|
71
|
-
keys: z.array(z.string()).nullish(),
|
|
72
|
-
}),
|
|
73
|
-
z.object({
|
|
74
|
-
type: z.literal('drag'),
|
|
75
|
-
path: z.array(z.object({ x: z.number(), y: z.number() })),
|
|
76
|
-
keys: z.array(z.string()).nullish(),
|
|
77
|
-
}),
|
|
123
|
+
const openaiResponsesComputerCallSchema = () =>
|
|
78
124
|
z.object({
|
|
79
|
-
type: z.literal('
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
z.
|
|
92
|
-
type: z.literal('
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}),
|
|
99
|
-
z.object({
|
|
100
|
-
type: z.literal('type'),
|
|
101
|
-
text: z.string(),
|
|
102
|
-
}),
|
|
103
|
-
z.object({
|
|
104
|
-
type: z.literal('wait'),
|
|
105
|
-
}),
|
|
106
|
-
]);
|
|
125
|
+
type: z.literal('computer_call'),
|
|
126
|
+
id: z.string(),
|
|
127
|
+
call_id: z.string().nullish(),
|
|
128
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
129
|
+
action: openaiResponsesComputerActionSchema().nullish(),
|
|
130
|
+
actions: z.array(openaiResponsesComputerActionSchema()).nullish(),
|
|
131
|
+
pending_safety_checks: z
|
|
132
|
+
.array(openaiResponsesComputerSafetyCheckSchema())
|
|
133
|
+
.nullish(),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const openaiResponsesToolCallerSchema = () =>
|
|
137
|
+
z.discriminatedUnion('type', [
|
|
138
|
+
z.object({ type: z.literal('direct') }),
|
|
139
|
+
z.object({
|
|
140
|
+
type: z.literal('program'),
|
|
141
|
+
caller_id: z.string(),
|
|
142
|
+
}),
|
|
143
|
+
]);
|
|
107
144
|
|
|
108
|
-
const
|
|
109
|
-
type: z.literal('computer_call'),
|
|
110
|
-
id: z.string(),
|
|
111
|
-
call_id: z.string().nullish(),
|
|
112
|
-
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
113
|
-
action: openaiResponsesComputerActionSchema.nullish(),
|
|
114
|
-
actions: z.array(openaiResponsesComputerActionSchema).nullish(),
|
|
115
|
-
pending_safety_checks: z
|
|
116
|
-
.array(openaiResponsesComputerSafetyCheckSchema)
|
|
117
|
-
.nullish(),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const openaiResponsesToolCallerSchema = z.discriminatedUnion('type', [
|
|
121
|
-
z.object({ type: z.literal('direct') }),
|
|
145
|
+
const openaiResponsesProgramSchema = () =>
|
|
122
146
|
z.object({
|
|
123
147
|
type: z.literal('program'),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
148
|
+
id: z.string(),
|
|
149
|
+
call_id: z.string(),
|
|
150
|
+
code: z.string(),
|
|
151
|
+
fingerprint: z.string(),
|
|
152
|
+
});
|
|
127
153
|
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
timeout_ms: z.number().optional(),
|
|
152
|
-
user: z.string().optional(),
|
|
153
|
-
working_directory: z.string().optional(),
|
|
154
|
-
env: z.record(z.string(), z.string()).optional(),
|
|
155
|
-
}),
|
|
156
|
-
});
|
|
154
|
+
const openaiResponsesProgramOutputSchema = () =>
|
|
155
|
+
z.object({
|
|
156
|
+
type: z.literal('program_output'),
|
|
157
|
+
id: z.string(),
|
|
158
|
+
call_id: z.string(),
|
|
159
|
+
result: z.string(),
|
|
160
|
+
status: z.enum(['completed', 'incomplete']),
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const openaiResponsesLocalShellCallSchema = () =>
|
|
164
|
+
z.object({
|
|
165
|
+
type: z.literal('local_shell_call'),
|
|
166
|
+
id: z.string(),
|
|
167
|
+
call_id: z.string(),
|
|
168
|
+
action: z.object({
|
|
169
|
+
type: z.literal('exec'),
|
|
170
|
+
command: z.array(z.string()),
|
|
171
|
+
timeout_ms: z.number().optional(),
|
|
172
|
+
user: z.string().optional(),
|
|
173
|
+
working_directory: z.string().optional(),
|
|
174
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
175
|
+
}),
|
|
176
|
+
});
|
|
157
177
|
|
|
158
178
|
export type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
|
|
159
179
|
|
|
@@ -220,6 +240,11 @@ export type OpenAIResponsesApplyPatchOperationDiffDoneChunk = {
|
|
|
220
240
|
diff: string;
|
|
221
241
|
};
|
|
222
242
|
|
|
243
|
+
export type OpenAIResponsesPromptCacheBreakpoint = {
|
|
244
|
+
mode: 'explicit';
|
|
245
|
+
ttl?: '30m' | '12h';
|
|
246
|
+
};
|
|
247
|
+
|
|
223
248
|
export type OpenAIResponsesSystemMessage = {
|
|
224
249
|
type?: 'message';
|
|
225
250
|
role: 'system' | 'developer';
|
|
@@ -228,7 +253,7 @@ export type OpenAIResponsesSystemMessage = {
|
|
|
228
253
|
| Array<{
|
|
229
254
|
type: 'input_text';
|
|
230
255
|
text: string;
|
|
231
|
-
prompt_cache_breakpoint?:
|
|
256
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
232
257
|
}>;
|
|
233
258
|
};
|
|
234
259
|
|
|
@@ -239,33 +264,33 @@ export type OpenAIResponsesUserMessage = {
|
|
|
239
264
|
| {
|
|
240
265
|
type: 'input_text';
|
|
241
266
|
text: string;
|
|
242
|
-
prompt_cache_breakpoint?:
|
|
267
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
243
268
|
}
|
|
244
269
|
| {
|
|
245
270
|
type: 'input_image';
|
|
246
271
|
image_url: string;
|
|
247
|
-
prompt_cache_breakpoint?:
|
|
272
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
248
273
|
}
|
|
249
274
|
| {
|
|
250
275
|
type: 'input_image';
|
|
251
276
|
file_id: string;
|
|
252
|
-
prompt_cache_breakpoint?:
|
|
277
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
253
278
|
}
|
|
254
279
|
| {
|
|
255
280
|
type: 'input_file';
|
|
256
281
|
file_url: string;
|
|
257
|
-
prompt_cache_breakpoint?:
|
|
282
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
258
283
|
}
|
|
259
284
|
| {
|
|
260
285
|
type: 'input_file';
|
|
261
286
|
filename: string;
|
|
262
287
|
file_data: string;
|
|
263
|
-
prompt_cache_breakpoint?:
|
|
288
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
264
289
|
}
|
|
265
290
|
| {
|
|
266
291
|
type: 'input_file';
|
|
267
292
|
file_id: string;
|
|
268
|
-
prompt_cache_breakpoint?:
|
|
293
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
269
294
|
}
|
|
270
295
|
>;
|
|
271
296
|
};
|
|
@@ -297,33 +322,33 @@ export type OpenAIResponsesFunctionCallOutput = {
|
|
|
297
322
|
| {
|
|
298
323
|
type: 'input_text';
|
|
299
324
|
text: string;
|
|
300
|
-
prompt_cache_breakpoint?:
|
|
325
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
301
326
|
}
|
|
302
327
|
| {
|
|
303
328
|
type: 'input_image';
|
|
304
329
|
image_url: string;
|
|
305
|
-
prompt_cache_breakpoint?:
|
|
330
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
306
331
|
}
|
|
307
332
|
| {
|
|
308
333
|
type: 'input_image';
|
|
309
334
|
file_id: string;
|
|
310
|
-
prompt_cache_breakpoint?:
|
|
335
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
311
336
|
}
|
|
312
337
|
| {
|
|
313
338
|
type: 'input_file';
|
|
314
339
|
filename: string;
|
|
315
340
|
file_data: string;
|
|
316
|
-
prompt_cache_breakpoint?:
|
|
341
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
317
342
|
}
|
|
318
343
|
| {
|
|
319
344
|
type: 'input_file';
|
|
320
345
|
file_url: string;
|
|
321
|
-
prompt_cache_breakpoint?:
|
|
346
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
322
347
|
}
|
|
323
348
|
| {
|
|
324
349
|
type: 'input_file';
|
|
325
350
|
file_id: string;
|
|
326
|
-
prompt_cache_breakpoint?:
|
|
351
|
+
prompt_cache_breakpoint?: OpenAIResponsesPromptCacheBreakpoint;
|
|
327
352
|
}
|
|
328
353
|
>;
|
|
329
354
|
caller?: OpenAIResponsesToolCaller;
|
|
@@ -378,11 +403,11 @@ export type OpenAIResponsesMcpApprovalResponse = {
|
|
|
378
403
|
};
|
|
379
404
|
|
|
380
405
|
export type OpenAIResponsesComputerAction = InferSchema<
|
|
381
|
-
typeof openaiResponsesComputerActionSchema
|
|
406
|
+
ReturnType<typeof openaiResponsesComputerActionSchema>
|
|
382
407
|
>;
|
|
383
408
|
|
|
384
409
|
export type OpenAIResponsesComputerCall = InferSchema<
|
|
385
|
-
typeof openaiResponsesComputerCallSchema
|
|
410
|
+
ReturnType<typeof openaiResponsesComputerCallSchema>
|
|
386
411
|
>;
|
|
387
412
|
|
|
388
413
|
export type OpenAIResponsesComputerCallOutput = {
|
|
@@ -402,7 +427,7 @@ export type OpenAIResponsesComputerCallOutput = {
|
|
|
402
427
|
};
|
|
403
428
|
|
|
404
429
|
export type OpenAIResponsesLocalShellCall = InferSchema<
|
|
405
|
-
typeof openaiResponsesLocalShellCallSchema
|
|
430
|
+
ReturnType<typeof openaiResponsesLocalShellCallSchema>
|
|
406
431
|
>;
|
|
407
432
|
|
|
408
433
|
export type OpenAIResponsesLocalShellCallOutput = {
|
|
@@ -778,27 +803,29 @@ export type OpenAIResponsesReasoning = {
|
|
|
778
803
|
// Captured from the Responses API when OpenAI returned an early
|
|
779
804
|
// insufficient_quota stream error after HTTP 200. This shape differs from the
|
|
780
805
|
// currently documented ResponseErrorEvent below.
|
|
781
|
-
const openaiResponsesNestedErrorChunkSchema =
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
})
|
|
806
|
+
const openaiResponsesNestedErrorChunkSchema = () =>
|
|
807
|
+
z.object({
|
|
808
|
+
type: z.literal('error'),
|
|
809
|
+
sequence_number: z.number(),
|
|
810
|
+
error: z.object({
|
|
811
|
+
type: z.string(),
|
|
812
|
+
code: z.string().nullish(),
|
|
813
|
+
message: z.string(),
|
|
814
|
+
param: z.string().nullish(),
|
|
815
|
+
}),
|
|
816
|
+
});
|
|
791
817
|
|
|
792
818
|
// Current OpenAI OpenAPI docs define ResponseErrorEvent with top-level
|
|
793
819
|
// code/message/param fields:
|
|
794
820
|
// https://developers.openai.com/api/reference/resources/responses/streaming-events
|
|
795
|
-
const openaiResponsesErrorChunkSchema =
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
821
|
+
const openaiResponsesErrorChunkSchema = () =>
|
|
822
|
+
z.object({
|
|
823
|
+
type: z.literal('error'),
|
|
824
|
+
sequence_number: z.number(),
|
|
825
|
+
code: z.string().nullish(),
|
|
826
|
+
message: z.string(),
|
|
827
|
+
param: z.string().nullish(),
|
|
828
|
+
});
|
|
802
829
|
|
|
803
830
|
/**
|
|
804
831
|
* Chunk types explicitly modeled by openaiResponsesChunkSchema. Keep this set
|
|
@@ -907,7 +934,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
907
934
|
type: z.enum(['response.completed', 'response.incomplete']),
|
|
908
935
|
response: z.object({
|
|
909
936
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
910
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
937
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
911
938
|
reasoning: z
|
|
912
939
|
.object({
|
|
913
940
|
context: z.string().nullish(),
|
|
@@ -927,7 +954,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
927
954
|
})
|
|
928
955
|
.nullish(),
|
|
929
956
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
930
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
957
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
931
958
|
reasoning: z
|
|
932
959
|
.object({
|
|
933
960
|
context: z.string().nullish(),
|
|
@@ -976,21 +1003,21 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
976
1003
|
arguments: z.string(),
|
|
977
1004
|
async: z.boolean().nullish(),
|
|
978
1005
|
namespace: z.string().nullish(),
|
|
979
|
-
caller: openaiResponsesToolCallerSchema.nullish(),
|
|
1006
|
+
caller: openaiResponsesToolCallerSchema().nullish(),
|
|
980
1007
|
}),
|
|
981
|
-
openaiResponsesProgramSchema,
|
|
982
|
-
openaiResponsesProgramOutputSchema,
|
|
1008
|
+
openaiResponsesProgramSchema(),
|
|
1009
|
+
openaiResponsesProgramOutputSchema(),
|
|
983
1010
|
z.object({
|
|
984
1011
|
type: z.literal('web_search_call'),
|
|
985
1012
|
id: z.string(),
|
|
986
1013
|
status: z.string(),
|
|
987
1014
|
}),
|
|
988
|
-
openaiResponsesComputerCallSchema,
|
|
1015
|
+
openaiResponsesComputerCallSchema(),
|
|
989
1016
|
z.object({
|
|
990
1017
|
type: z.literal('file_search_call'),
|
|
991
1018
|
id: z.string(),
|
|
992
1019
|
}),
|
|
993
|
-
openaiResponsesLocalShellCallSchema,
|
|
1020
|
+
openaiResponsesLocalShellCallSchema(),
|
|
994
1021
|
z.object({
|
|
995
1022
|
type: z.literal('image_generation_call'),
|
|
996
1023
|
id: z.string(),
|
|
@@ -1104,7 +1131,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
1104
1131
|
execution: z.enum(['server', 'client']),
|
|
1105
1132
|
call_id: z.string().nullable(),
|
|
1106
1133
|
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1107
|
-
tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
|
|
1134
|
+
tools: z.array(z.record(z.string(), jsonValueSchema().optional())),
|
|
1108
1135
|
}),
|
|
1109
1136
|
]),
|
|
1110
1137
|
}),
|
|
@@ -1131,10 +1158,10 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
1131
1158
|
async: z.boolean().nullish(),
|
|
1132
1159
|
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1133
1160
|
namespace: z.string().nullish(),
|
|
1134
|
-
caller: openaiResponsesToolCallerSchema.nullish(),
|
|
1161
|
+
caller: openaiResponsesToolCallerSchema().nullish(),
|
|
1135
1162
|
}),
|
|
1136
|
-
openaiResponsesProgramSchema,
|
|
1137
|
-
openaiResponsesProgramOutputSchema,
|
|
1163
|
+
openaiResponsesProgramSchema(),
|
|
1164
|
+
openaiResponsesProgramOutputSchema(),
|
|
1138
1165
|
z.object({
|
|
1139
1166
|
type: z.literal('custom_tool_call'),
|
|
1140
1167
|
id: z.string(),
|
|
@@ -1213,8 +1240,8 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
1213
1240
|
)
|
|
1214
1241
|
.nullish(),
|
|
1215
1242
|
}),
|
|
1216
|
-
openaiResponsesLocalShellCallSchema,
|
|
1217
|
-
openaiResponsesComputerCallSchema,
|
|
1243
|
+
openaiResponsesLocalShellCallSchema(),
|
|
1244
|
+
openaiResponsesComputerCallSchema(),
|
|
1218
1245
|
z.object({
|
|
1219
1246
|
type: z.literal('mcp_call'),
|
|
1220
1247
|
id: z.string(),
|
|
@@ -1342,7 +1369,7 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
1342
1369
|
execution: z.enum(['server', 'client']),
|
|
1343
1370
|
call_id: z.string().nullable(),
|
|
1344
1371
|
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1345
|
-
tools: z.array(z.record(z.string(), jsonValueSchema.optional())),
|
|
1372
|
+
tools: z.array(z.record(z.string(), jsonValueSchema().optional())),
|
|
1346
1373
|
}),
|
|
1347
1374
|
]),
|
|
1348
1375
|
}),
|
|
@@ -1447,8 +1474,8 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
1447
1474
|
output_index: z.number(),
|
|
1448
1475
|
diff: z.string(),
|
|
1449
1476
|
}),
|
|
1450
|
-
openaiResponsesNestedErrorChunkSchema,
|
|
1451
|
-
openaiResponsesErrorChunkSchema,
|
|
1477
|
+
openaiResponsesNestedErrorChunkSchema(),
|
|
1478
|
+
openaiResponsesErrorChunkSchema(),
|
|
1452
1479
|
z
|
|
1453
1480
|
.object({ type: z.string() })
|
|
1454
1481
|
.loose()
|
|
@@ -1626,7 +1653,7 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1626
1653
|
id: z.string(),
|
|
1627
1654
|
result: z.string(),
|
|
1628
1655
|
}),
|
|
1629
|
-
openaiResponsesLocalShellCallSchema,
|
|
1656
|
+
openaiResponsesLocalShellCallSchema(),
|
|
1630
1657
|
z.object({
|
|
1631
1658
|
type: z.literal('function_call'),
|
|
1632
1659
|
call_id: z.string(),
|
|
@@ -1635,10 +1662,10 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1635
1662
|
id: z.string(),
|
|
1636
1663
|
async: z.boolean().nullish(),
|
|
1637
1664
|
namespace: z.string().nullish(),
|
|
1638
|
-
caller: openaiResponsesToolCallerSchema.nullish(),
|
|
1665
|
+
caller: openaiResponsesToolCallerSchema().nullish(),
|
|
1639
1666
|
}),
|
|
1640
|
-
openaiResponsesProgramSchema,
|
|
1641
|
-
openaiResponsesProgramOutputSchema,
|
|
1667
|
+
openaiResponsesProgramSchema(),
|
|
1668
|
+
openaiResponsesProgramOutputSchema(),
|
|
1642
1669
|
z.object({
|
|
1643
1670
|
type: z.literal('custom_tool_call'),
|
|
1644
1671
|
call_id: z.string(),
|
|
@@ -1647,7 +1674,7 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1647
1674
|
id: z.string(),
|
|
1648
1675
|
async: z.boolean().nullish(),
|
|
1649
1676
|
}),
|
|
1650
|
-
openaiResponsesComputerCallSchema,
|
|
1677
|
+
openaiResponsesComputerCallSchema(),
|
|
1651
1678
|
z.object({
|
|
1652
1679
|
type: z.literal('reasoning'),
|
|
1653
1680
|
id: z.string(),
|
|
@@ -1786,7 +1813,9 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1786
1813
|
execution: z.enum(['server', 'client']),
|
|
1787
1814
|
call_id: z.string().nullable(),
|
|
1788
1815
|
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
1789
|
-
tools: z.array(
|
|
1816
|
+
tools: z.array(
|
|
1817
|
+
z.record(z.string(), jsonValueSchema().optional()),
|
|
1818
|
+
),
|
|
1790
1819
|
}),
|
|
1791
1820
|
]),
|
|
1792
1821
|
)
|
|
@@ -1798,7 +1827,7 @@ export const openaiResponsesResponseSchema = lazySchema(() =>
|
|
|
1798
1827
|
})
|
|
1799
1828
|
.nullish(),
|
|
1800
1829
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
1801
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
1830
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
1802
1831
|
}),
|
|
1803
1832
|
),
|
|
1804
1833
|
);
|
|
@@ -250,12 +250,14 @@ export const openaiLanguageModelResponsesOptionsSchema = lazySchema(() =>
|
|
|
250
250
|
/**
|
|
251
251
|
* Prompt cache behavior for GPT-5.6 and later models.
|
|
252
252
|
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
253
|
-
* `ttl` sets the minimum cache lifetime
|
|
253
|
+
* `ttl` sets the minimum cache lifetime: `'30m'` (default) or `'12h'`.
|
|
254
|
+
* `prewarm` writes the prompt to the cache without generating output.
|
|
254
255
|
*/
|
|
255
256
|
promptCacheOptions: z
|
|
256
257
|
.object({
|
|
257
258
|
mode: z.enum(['implicit', 'explicit']).optional(),
|
|
258
|
-
ttl: z.
|
|
259
|
+
ttl: z.enum(['30m', '12h']).optional(),
|
|
260
|
+
prewarm: z.boolean().optional(),
|
|
259
261
|
})
|
|
260
262
|
.optional(),
|
|
261
263
|
|
|
@@ -1599,8 +1599,9 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
1599
1599
|
string
|
|
1600
1600
|
>();
|
|
1601
1601
|
|
|
1602
|
+
// A clean end without the provider's completion signal is interrupted.
|
|
1602
1603
|
let finishReason: LanguageModelV4FinishReason = {
|
|
1603
|
-
unified: '
|
|
1604
|
+
unified: 'interrupted',
|
|
1604
1605
|
raw: undefined,
|
|
1605
1606
|
};
|
|
1606
1607
|
let usage: OpenAIResponsesUsage | undefined = undefined;
|