@ai-sdk/openai 4.0.0-beta.29 → 4.0.0-beta.30
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 +12 -0
- package/dist/index.js +1608 -1496
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1536 -1470
- package/dist/internal/index.js.map +1 -1
- package/package.json +9 -10
- package/dist/index.d.mts +0 -1210
- package/dist/index.mjs +0 -7176
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -1203
- package/dist/internal/index.mjs +0 -6772
- package/dist/internal/index.mjs.map +0 -1
package/dist/internal/index.js
CHANGED
|
@@ -1,80 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/internal/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
OpenAIChatLanguageModel: () => OpenAIChatLanguageModel,
|
|
24
|
-
OpenAICompletionLanguageModel: () => OpenAICompletionLanguageModel,
|
|
25
|
-
OpenAIEmbeddingModel: () => OpenAIEmbeddingModel,
|
|
26
|
-
OpenAIImageModel: () => OpenAIImageModel,
|
|
27
|
-
OpenAIResponsesLanguageModel: () => OpenAIResponsesLanguageModel,
|
|
28
|
-
OpenAISpeechModel: () => OpenAISpeechModel,
|
|
29
|
-
OpenAITranscriptionModel: () => OpenAITranscriptionModel,
|
|
30
|
-
applyPatch: () => applyPatch,
|
|
31
|
-
applyPatchArgsSchema: () => applyPatchArgsSchema,
|
|
32
|
-
applyPatchInputSchema: () => applyPatchInputSchema,
|
|
33
|
-
applyPatchOutputSchema: () => applyPatchOutputSchema,
|
|
34
|
-
applyPatchToolFactory: () => applyPatchToolFactory,
|
|
35
|
-
codeInterpreter: () => codeInterpreter,
|
|
36
|
-
codeInterpreterArgsSchema: () => codeInterpreterArgsSchema,
|
|
37
|
-
codeInterpreterInputSchema: () => codeInterpreterInputSchema,
|
|
38
|
-
codeInterpreterOutputSchema: () => codeInterpreterOutputSchema,
|
|
39
|
-
codeInterpreterToolFactory: () => codeInterpreterToolFactory,
|
|
40
|
-
fileSearch: () => fileSearch,
|
|
41
|
-
fileSearchArgsSchema: () => fileSearchArgsSchema,
|
|
42
|
-
fileSearchOutputSchema: () => fileSearchOutputSchema,
|
|
43
|
-
hasDefaultResponseFormat: () => hasDefaultResponseFormat,
|
|
44
|
-
imageGeneration: () => imageGeneration,
|
|
45
|
-
imageGenerationArgsSchema: () => imageGenerationArgsSchema,
|
|
46
|
-
imageGenerationOutputSchema: () => imageGenerationOutputSchema,
|
|
47
|
-
modelMaxImagesPerCall: () => modelMaxImagesPerCall,
|
|
48
|
-
openAITranscriptionModelOptions: () => openAITranscriptionModelOptions,
|
|
49
|
-
openaiEmbeddingModelOptions: () => openaiEmbeddingModelOptions,
|
|
50
|
-
openaiLanguageModelChatOptions: () => openaiLanguageModelChatOptions,
|
|
51
|
-
openaiLanguageModelCompletionOptions: () => openaiLanguageModelCompletionOptions,
|
|
52
|
-
openaiSpeechModelOptionsSchema: () => openaiSpeechModelOptionsSchema,
|
|
53
|
-
webSearchPreview: () => webSearchPreview,
|
|
54
|
-
webSearchPreviewArgsSchema: () => webSearchPreviewArgsSchema,
|
|
55
|
-
webSearchPreviewInputSchema: () => webSearchPreviewInputSchema
|
|
56
|
-
});
|
|
57
|
-
module.exports = __toCommonJS(index_exports);
|
|
58
|
-
|
|
59
1
|
// src/chat/openai-chat-language-model.ts
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
import {
|
|
3
|
+
InvalidResponseDataError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
combineHeaders,
|
|
7
|
+
createEventSourceResponseHandler,
|
|
8
|
+
createJsonResponseHandler,
|
|
9
|
+
generateId,
|
|
10
|
+
isCustomReasoning,
|
|
11
|
+
isParsableJson,
|
|
12
|
+
parseProviderOptions,
|
|
13
|
+
postJsonToApi
|
|
14
|
+
} from "@ai-sdk/provider-utils";
|
|
62
15
|
|
|
63
16
|
// src/openai-error.ts
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var openaiErrorDataSchema =
|
|
67
|
-
error:
|
|
68
|
-
message:
|
|
17
|
+
import { z } from "zod/v4";
|
|
18
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
19
|
+
var openaiErrorDataSchema = z.object({
|
|
20
|
+
error: z.object({
|
|
21
|
+
message: z.string(),
|
|
69
22
|
// The additional information below is handled loosely to support
|
|
70
23
|
// OpenAI-compatible providers that have slightly different error
|
|
71
24
|
// responses:
|
|
72
|
-
type:
|
|
73
|
-
param:
|
|
74
|
-
code:
|
|
25
|
+
type: z.string().nullish(),
|
|
26
|
+
param: z.any().nullish(),
|
|
27
|
+
code: z.union([z.string(), z.number()]).nullish()
|
|
75
28
|
})
|
|
76
29
|
});
|
|
77
|
-
var openaiFailedResponseHandler =
|
|
30
|
+
var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
78
31
|
errorSchema: openaiErrorDataSchema,
|
|
79
32
|
errorToMessage: (data) => data.error.message
|
|
80
33
|
});
|
|
@@ -135,8 +88,14 @@ function convertOpenAIChatUsage(usage) {
|
|
|
135
88
|
}
|
|
136
89
|
|
|
137
90
|
// src/chat/convert-to-openai-chat-messages.ts
|
|
138
|
-
|
|
139
|
-
|
|
91
|
+
import {
|
|
92
|
+
UnsupportedFunctionalityError
|
|
93
|
+
} from "@ai-sdk/provider";
|
|
94
|
+
import {
|
|
95
|
+
convertToBase64,
|
|
96
|
+
isProviderReference,
|
|
97
|
+
resolveProviderReference
|
|
98
|
+
} from "@ai-sdk/provider-utils";
|
|
140
99
|
function convertToOpenAIChatMessages({
|
|
141
100
|
prompt,
|
|
142
101
|
systemMessageMode = "system"
|
|
@@ -186,11 +145,11 @@ function convertToOpenAIChatMessages({
|
|
|
186
145
|
return { type: "text", text: part.text };
|
|
187
146
|
}
|
|
188
147
|
case "file": {
|
|
189
|
-
if (
|
|
148
|
+
if (isProviderReference(part.data)) {
|
|
190
149
|
return {
|
|
191
150
|
type: "file",
|
|
192
151
|
file: {
|
|
193
|
-
file_id:
|
|
152
|
+
file_id: resolveProviderReference({
|
|
194
153
|
reference: part.data,
|
|
195
154
|
provider: "openai"
|
|
196
155
|
})
|
|
@@ -202,13 +161,13 @@ function convertToOpenAIChatMessages({
|
|
|
202
161
|
return {
|
|
203
162
|
type: "image_url",
|
|
204
163
|
image_url: {
|
|
205
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
164
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
206
165
|
detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
|
|
207
166
|
}
|
|
208
167
|
};
|
|
209
168
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
210
169
|
if (part.data instanceof URL) {
|
|
211
|
-
throw new
|
|
170
|
+
throw new UnsupportedFunctionalityError({
|
|
212
171
|
functionality: "audio file parts with URLs"
|
|
213
172
|
});
|
|
214
173
|
}
|
|
@@ -217,7 +176,7 @@ function convertToOpenAIChatMessages({
|
|
|
217
176
|
return {
|
|
218
177
|
type: "input_audio",
|
|
219
178
|
input_audio: {
|
|
220
|
-
data:
|
|
179
|
+
data: convertToBase64(part.data),
|
|
221
180
|
format: "wav"
|
|
222
181
|
}
|
|
223
182
|
};
|
|
@@ -227,20 +186,20 @@ function convertToOpenAIChatMessages({
|
|
|
227
186
|
return {
|
|
228
187
|
type: "input_audio",
|
|
229
188
|
input_audio: {
|
|
230
|
-
data:
|
|
189
|
+
data: convertToBase64(part.data),
|
|
231
190
|
format: "mp3"
|
|
232
191
|
}
|
|
233
192
|
};
|
|
234
193
|
}
|
|
235
194
|
default: {
|
|
236
|
-
throw new
|
|
195
|
+
throw new UnsupportedFunctionalityError({
|
|
237
196
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
238
197
|
});
|
|
239
198
|
}
|
|
240
199
|
}
|
|
241
200
|
} else if (part.mediaType === "application/pdf") {
|
|
242
201
|
if (part.data instanceof URL) {
|
|
243
|
-
throw new
|
|
202
|
+
throw new UnsupportedFunctionalityError({
|
|
244
203
|
functionality: "PDF file parts with URLs"
|
|
245
204
|
});
|
|
246
205
|
}
|
|
@@ -248,11 +207,11 @@ function convertToOpenAIChatMessages({
|
|
|
248
207
|
type: "file",
|
|
249
208
|
file: {
|
|
250
209
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
251
|
-
file_data: `data:application/pdf;base64,${
|
|
210
|
+
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
252
211
|
}
|
|
253
212
|
};
|
|
254
213
|
} else {
|
|
255
|
-
throw new
|
|
214
|
+
throw new UnsupportedFunctionalityError({
|
|
256
215
|
functionality: `file part media type ${part.mediaType}`
|
|
257
216
|
});
|
|
258
217
|
}
|
|
@@ -360,139 +319,139 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
360
319
|
}
|
|
361
320
|
|
|
362
321
|
// src/chat/openai-chat-api.ts
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
var openaiChatResponseSchema =
|
|
366
|
-
() =>
|
|
367
|
-
|
|
368
|
-
id:
|
|
369
|
-
created:
|
|
370
|
-
model:
|
|
371
|
-
choices:
|
|
372
|
-
|
|
373
|
-
message:
|
|
374
|
-
role:
|
|
375
|
-
content:
|
|
376
|
-
tool_calls:
|
|
377
|
-
|
|
378
|
-
id:
|
|
379
|
-
type:
|
|
380
|
-
function:
|
|
381
|
-
name:
|
|
382
|
-
arguments:
|
|
322
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
323
|
+
import { z as z2 } from "zod/v4";
|
|
324
|
+
var openaiChatResponseSchema = lazySchema(
|
|
325
|
+
() => zodSchema(
|
|
326
|
+
z2.object({
|
|
327
|
+
id: z2.string().nullish(),
|
|
328
|
+
created: z2.number().nullish(),
|
|
329
|
+
model: z2.string().nullish(),
|
|
330
|
+
choices: z2.array(
|
|
331
|
+
z2.object({
|
|
332
|
+
message: z2.object({
|
|
333
|
+
role: z2.literal("assistant").nullish(),
|
|
334
|
+
content: z2.string().nullish(),
|
|
335
|
+
tool_calls: z2.array(
|
|
336
|
+
z2.object({
|
|
337
|
+
id: z2.string().nullish(),
|
|
338
|
+
type: z2.literal("function"),
|
|
339
|
+
function: z2.object({
|
|
340
|
+
name: z2.string(),
|
|
341
|
+
arguments: z2.string()
|
|
383
342
|
})
|
|
384
343
|
})
|
|
385
344
|
).nullish(),
|
|
386
|
-
annotations:
|
|
387
|
-
|
|
388
|
-
type:
|
|
389
|
-
url_citation:
|
|
390
|
-
start_index:
|
|
391
|
-
end_index:
|
|
392
|
-
url:
|
|
393
|
-
title:
|
|
345
|
+
annotations: z2.array(
|
|
346
|
+
z2.object({
|
|
347
|
+
type: z2.literal("url_citation"),
|
|
348
|
+
url_citation: z2.object({
|
|
349
|
+
start_index: z2.number(),
|
|
350
|
+
end_index: z2.number(),
|
|
351
|
+
url: z2.string(),
|
|
352
|
+
title: z2.string()
|
|
394
353
|
})
|
|
395
354
|
})
|
|
396
355
|
).nullish()
|
|
397
356
|
}),
|
|
398
|
-
index:
|
|
399
|
-
logprobs:
|
|
400
|
-
content:
|
|
401
|
-
|
|
402
|
-
token:
|
|
403
|
-
logprob:
|
|
404
|
-
top_logprobs:
|
|
405
|
-
|
|
406
|
-
token:
|
|
407
|
-
logprob:
|
|
357
|
+
index: z2.number(),
|
|
358
|
+
logprobs: z2.object({
|
|
359
|
+
content: z2.array(
|
|
360
|
+
z2.object({
|
|
361
|
+
token: z2.string(),
|
|
362
|
+
logprob: z2.number(),
|
|
363
|
+
top_logprobs: z2.array(
|
|
364
|
+
z2.object({
|
|
365
|
+
token: z2.string(),
|
|
366
|
+
logprob: z2.number()
|
|
408
367
|
})
|
|
409
368
|
)
|
|
410
369
|
})
|
|
411
370
|
).nullish()
|
|
412
371
|
}).nullish(),
|
|
413
|
-
finish_reason:
|
|
372
|
+
finish_reason: z2.string().nullish()
|
|
414
373
|
})
|
|
415
374
|
),
|
|
416
|
-
usage:
|
|
417
|
-
prompt_tokens:
|
|
418
|
-
completion_tokens:
|
|
419
|
-
total_tokens:
|
|
420
|
-
prompt_tokens_details:
|
|
421
|
-
cached_tokens:
|
|
375
|
+
usage: z2.object({
|
|
376
|
+
prompt_tokens: z2.number().nullish(),
|
|
377
|
+
completion_tokens: z2.number().nullish(),
|
|
378
|
+
total_tokens: z2.number().nullish(),
|
|
379
|
+
prompt_tokens_details: z2.object({
|
|
380
|
+
cached_tokens: z2.number().nullish()
|
|
422
381
|
}).nullish(),
|
|
423
|
-
completion_tokens_details:
|
|
424
|
-
reasoning_tokens:
|
|
425
|
-
accepted_prediction_tokens:
|
|
426
|
-
rejected_prediction_tokens:
|
|
382
|
+
completion_tokens_details: z2.object({
|
|
383
|
+
reasoning_tokens: z2.number().nullish(),
|
|
384
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
385
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
427
386
|
}).nullish()
|
|
428
387
|
}).nullish()
|
|
429
388
|
})
|
|
430
389
|
)
|
|
431
390
|
);
|
|
432
|
-
var openaiChatChunkSchema =
|
|
433
|
-
() =>
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
id:
|
|
437
|
-
created:
|
|
438
|
-
model:
|
|
439
|
-
choices:
|
|
440
|
-
|
|
441
|
-
delta:
|
|
442
|
-
role:
|
|
443
|
-
content:
|
|
444
|
-
tool_calls:
|
|
445
|
-
|
|
446
|
-
index:
|
|
447
|
-
id:
|
|
448
|
-
type:
|
|
449
|
-
function:
|
|
450
|
-
name:
|
|
451
|
-
arguments:
|
|
391
|
+
var openaiChatChunkSchema = lazySchema(
|
|
392
|
+
() => zodSchema(
|
|
393
|
+
z2.union([
|
|
394
|
+
z2.object({
|
|
395
|
+
id: z2.string().nullish(),
|
|
396
|
+
created: z2.number().nullish(),
|
|
397
|
+
model: z2.string().nullish(),
|
|
398
|
+
choices: z2.array(
|
|
399
|
+
z2.object({
|
|
400
|
+
delta: z2.object({
|
|
401
|
+
role: z2.enum(["assistant"]).nullish(),
|
|
402
|
+
content: z2.string().nullish(),
|
|
403
|
+
tool_calls: z2.array(
|
|
404
|
+
z2.object({
|
|
405
|
+
index: z2.number(),
|
|
406
|
+
id: z2.string().nullish(),
|
|
407
|
+
type: z2.literal("function").nullish(),
|
|
408
|
+
function: z2.object({
|
|
409
|
+
name: z2.string().nullish(),
|
|
410
|
+
arguments: z2.string().nullish()
|
|
452
411
|
})
|
|
453
412
|
})
|
|
454
413
|
).nullish(),
|
|
455
|
-
annotations:
|
|
456
|
-
|
|
457
|
-
type:
|
|
458
|
-
url_citation:
|
|
459
|
-
start_index:
|
|
460
|
-
end_index:
|
|
461
|
-
url:
|
|
462
|
-
title:
|
|
414
|
+
annotations: z2.array(
|
|
415
|
+
z2.object({
|
|
416
|
+
type: z2.literal("url_citation"),
|
|
417
|
+
url_citation: z2.object({
|
|
418
|
+
start_index: z2.number(),
|
|
419
|
+
end_index: z2.number(),
|
|
420
|
+
url: z2.string(),
|
|
421
|
+
title: z2.string()
|
|
463
422
|
})
|
|
464
423
|
})
|
|
465
424
|
).nullish()
|
|
466
425
|
}).nullish(),
|
|
467
|
-
logprobs:
|
|
468
|
-
content:
|
|
469
|
-
|
|
470
|
-
token:
|
|
471
|
-
logprob:
|
|
472
|
-
top_logprobs:
|
|
473
|
-
|
|
474
|
-
token:
|
|
475
|
-
logprob:
|
|
426
|
+
logprobs: z2.object({
|
|
427
|
+
content: z2.array(
|
|
428
|
+
z2.object({
|
|
429
|
+
token: z2.string(),
|
|
430
|
+
logprob: z2.number(),
|
|
431
|
+
top_logprobs: z2.array(
|
|
432
|
+
z2.object({
|
|
433
|
+
token: z2.string(),
|
|
434
|
+
logprob: z2.number()
|
|
476
435
|
})
|
|
477
436
|
)
|
|
478
437
|
})
|
|
479
438
|
).nullish()
|
|
480
439
|
}).nullish(),
|
|
481
|
-
finish_reason:
|
|
482
|
-
index:
|
|
440
|
+
finish_reason: z2.string().nullish(),
|
|
441
|
+
index: z2.number()
|
|
483
442
|
})
|
|
484
443
|
),
|
|
485
|
-
usage:
|
|
486
|
-
prompt_tokens:
|
|
487
|
-
completion_tokens:
|
|
488
|
-
total_tokens:
|
|
489
|
-
prompt_tokens_details:
|
|
490
|
-
cached_tokens:
|
|
444
|
+
usage: z2.object({
|
|
445
|
+
prompt_tokens: z2.number().nullish(),
|
|
446
|
+
completion_tokens: z2.number().nullish(),
|
|
447
|
+
total_tokens: z2.number().nullish(),
|
|
448
|
+
prompt_tokens_details: z2.object({
|
|
449
|
+
cached_tokens: z2.number().nullish()
|
|
491
450
|
}).nullish(),
|
|
492
|
-
completion_tokens_details:
|
|
493
|
-
reasoning_tokens:
|
|
494
|
-
accepted_prediction_tokens:
|
|
495
|
-
rejected_prediction_tokens:
|
|
451
|
+
completion_tokens_details: z2.object({
|
|
452
|
+
reasoning_tokens: z2.number().nullish(),
|
|
453
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
454
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
496
455
|
}).nullish()
|
|
497
456
|
}).nullish()
|
|
498
457
|
}),
|
|
@@ -502,18 +461,18 @@ var openaiChatChunkSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
502
461
|
);
|
|
503
462
|
|
|
504
463
|
// src/chat/openai-chat-options.ts
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
var openaiLanguageModelChatOptions = (
|
|
508
|
-
() => (
|
|
509
|
-
|
|
464
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
465
|
+
import { z as z3 } from "zod/v4";
|
|
466
|
+
var openaiLanguageModelChatOptions = lazySchema2(
|
|
467
|
+
() => zodSchema2(
|
|
468
|
+
z3.object({
|
|
510
469
|
/**
|
|
511
470
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
512
471
|
*
|
|
513
472
|
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
514
473
|
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
515
474
|
*/
|
|
516
|
-
logitBias:
|
|
475
|
+
logitBias: z3.record(z3.coerce.number(), z3.number()).optional(),
|
|
517
476
|
/**
|
|
518
477
|
* Return the log probabilities of the tokens.
|
|
519
478
|
*
|
|
@@ -523,36 +482,36 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
523
482
|
* Setting to a number will return the log probabilities of the top n
|
|
524
483
|
* tokens that were generated.
|
|
525
484
|
*/
|
|
526
|
-
logprobs:
|
|
485
|
+
logprobs: z3.union([z3.boolean(), z3.number()]).optional(),
|
|
527
486
|
/**
|
|
528
487
|
* Whether to enable parallel function calling during tool use. Default to true.
|
|
529
488
|
*/
|
|
530
|
-
parallelToolCalls:
|
|
489
|
+
parallelToolCalls: z3.boolean().optional(),
|
|
531
490
|
/**
|
|
532
491
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
533
492
|
* monitor and detect abuse.
|
|
534
493
|
*/
|
|
535
|
-
user:
|
|
494
|
+
user: z3.string().optional(),
|
|
536
495
|
/**
|
|
537
496
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
538
497
|
*/
|
|
539
|
-
reasoningEffort:
|
|
498
|
+
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
|
|
540
499
|
/**
|
|
541
500
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
542
501
|
*/
|
|
543
|
-
maxCompletionTokens:
|
|
502
|
+
maxCompletionTokens: z3.number().optional(),
|
|
544
503
|
/**
|
|
545
504
|
* Whether to enable persistence in responses API.
|
|
546
505
|
*/
|
|
547
|
-
store:
|
|
506
|
+
store: z3.boolean().optional(),
|
|
548
507
|
/**
|
|
549
508
|
* Metadata to associate with the request.
|
|
550
509
|
*/
|
|
551
|
-
metadata:
|
|
510
|
+
metadata: z3.record(z3.string().max(64), z3.string().max(512)).optional(),
|
|
552
511
|
/**
|
|
553
512
|
* Parameters for prediction mode.
|
|
554
513
|
*/
|
|
555
|
-
prediction:
|
|
514
|
+
prediction: z3.record(z3.string(), z3.any()).optional(),
|
|
556
515
|
/**
|
|
557
516
|
* Service tier for the request.
|
|
558
517
|
* - 'auto': Default service tier. The request will be processed with the service tier configured in the
|
|
@@ -563,23 +522,23 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
563
522
|
*
|
|
564
523
|
* @default 'auto'
|
|
565
524
|
*/
|
|
566
|
-
serviceTier:
|
|
525
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
567
526
|
/**
|
|
568
527
|
* Whether to use strict JSON schema validation.
|
|
569
528
|
*
|
|
570
529
|
* @default true
|
|
571
530
|
*/
|
|
572
|
-
strictJsonSchema:
|
|
531
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
573
532
|
/**
|
|
574
533
|
* Controls the verbosity of the model's responses.
|
|
575
534
|
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
576
535
|
*/
|
|
577
|
-
textVerbosity:
|
|
536
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
578
537
|
/**
|
|
579
538
|
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
580
539
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
581
540
|
*/
|
|
582
|
-
promptCacheKey:
|
|
541
|
+
promptCacheKey: z3.string().optional(),
|
|
583
542
|
/**
|
|
584
543
|
* The retention policy for the prompt cache.
|
|
585
544
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
@@ -588,7 +547,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
588
547
|
*
|
|
589
548
|
* @default 'in_memory'
|
|
590
549
|
*/
|
|
591
|
-
promptCacheRetention:
|
|
550
|
+
promptCacheRetention: z3.enum(["in_memory", "24h"]).optional(),
|
|
592
551
|
/**
|
|
593
552
|
* A stable identifier used to help detect users of your application
|
|
594
553
|
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
@@ -596,7 +555,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
596
555
|
* username or email address, in order to avoid sending us any identifying
|
|
597
556
|
* information.
|
|
598
557
|
*/
|
|
599
|
-
safetyIdentifier:
|
|
558
|
+
safetyIdentifier: z3.string().optional(),
|
|
600
559
|
/**
|
|
601
560
|
* Override the system message mode for this model.
|
|
602
561
|
* - 'system': Use the 'system' role for system messages (default for most models)
|
|
@@ -605,7 +564,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
605
564
|
*
|
|
606
565
|
* If not specified, the mode is automatically determined based on the model.
|
|
607
566
|
*/
|
|
608
|
-
systemMessageMode:
|
|
567
|
+
systemMessageMode: z3.enum(["system", "developer", "remove"]).optional(),
|
|
609
568
|
/**
|
|
610
569
|
* Force treating this model as a reasoning model.
|
|
611
570
|
*
|
|
@@ -615,13 +574,15 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
615
574
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
616
575
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
617
576
|
*/
|
|
618
|
-
forceReasoning:
|
|
577
|
+
forceReasoning: z3.boolean().optional()
|
|
619
578
|
})
|
|
620
579
|
)
|
|
621
580
|
);
|
|
622
581
|
|
|
623
582
|
// src/chat/openai-chat-prepare-tools.ts
|
|
624
|
-
|
|
583
|
+
import {
|
|
584
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
585
|
+
} from "@ai-sdk/provider";
|
|
625
586
|
function prepareChatTools({
|
|
626
587
|
tools,
|
|
627
588
|
toolChoice
|
|
@@ -675,7 +636,7 @@ function prepareChatTools({
|
|
|
675
636
|
};
|
|
676
637
|
default: {
|
|
677
638
|
const _exhaustiveCheck = type;
|
|
678
|
-
throw new
|
|
639
|
+
throw new UnsupportedFunctionalityError2({
|
|
679
640
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
680
641
|
});
|
|
681
642
|
}
|
|
@@ -713,13 +674,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
713
674
|
}) {
|
|
714
675
|
var _a, _b, _c, _d, _e, _f;
|
|
715
676
|
const warnings = [];
|
|
716
|
-
const openaiOptions = (_a = await
|
|
677
|
+
const openaiOptions = (_a = await parseProviderOptions({
|
|
717
678
|
provider: "openai",
|
|
718
679
|
providerOptions,
|
|
719
680
|
schema: openaiLanguageModelChatOptions
|
|
720
681
|
})) != null ? _a : {};
|
|
721
682
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
722
|
-
const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b :
|
|
683
|
+
const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
|
|
723
684
|
const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
|
|
724
685
|
if (topK != null) {
|
|
725
686
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -885,15 +846,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
885
846
|
responseHeaders,
|
|
886
847
|
value: response,
|
|
887
848
|
rawValue: rawResponse
|
|
888
|
-
} = await
|
|
849
|
+
} = await postJsonToApi({
|
|
889
850
|
url: this.config.url({
|
|
890
851
|
path: "/chat/completions",
|
|
891
852
|
modelId: this.modelId
|
|
892
853
|
}),
|
|
893
|
-
headers:
|
|
854
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
894
855
|
body,
|
|
895
856
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
896
|
-
successfulResponseHandler:
|
|
857
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
897
858
|
openaiChatResponseSchema
|
|
898
859
|
),
|
|
899
860
|
abortSignal: options.abortSignal,
|
|
@@ -908,7 +869,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
908
869
|
for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
|
|
909
870
|
content.push({
|
|
910
871
|
type: "tool-call",
|
|
911
|
-
toolCallId: (_b = toolCall.id) != null ? _b :
|
|
872
|
+
toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
|
|
912
873
|
toolName: toolCall.function.name,
|
|
913
874
|
input: toolCall.function.arguments
|
|
914
875
|
});
|
|
@@ -917,7 +878,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
917
878
|
content.push({
|
|
918
879
|
type: "source",
|
|
919
880
|
sourceType: "url",
|
|
920
|
-
id:
|
|
881
|
+
id: generateId(),
|
|
921
882
|
url: annotation.url_citation.url,
|
|
922
883
|
title: annotation.url_citation.title
|
|
923
884
|
});
|
|
@@ -959,15 +920,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
959
920
|
include_usage: true
|
|
960
921
|
}
|
|
961
922
|
};
|
|
962
|
-
const { responseHeaders, value: response } = await
|
|
923
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
963
924
|
url: this.config.url({
|
|
964
925
|
path: "/chat/completions",
|
|
965
926
|
modelId: this.modelId
|
|
966
927
|
}),
|
|
967
|
-
headers:
|
|
928
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
968
929
|
body,
|
|
969
930
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
970
|
-
successfulResponseHandler:
|
|
931
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
971
932
|
openaiChatChunkSchema
|
|
972
933
|
),
|
|
973
934
|
abortSignal: options.abortSignal,
|
|
@@ -1053,19 +1014,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
1053
1014
|
const index = toolCallDelta.index;
|
|
1054
1015
|
if (toolCalls[index] == null) {
|
|
1055
1016
|
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
1056
|
-
throw new
|
|
1017
|
+
throw new InvalidResponseDataError({
|
|
1057
1018
|
data: toolCallDelta,
|
|
1058
1019
|
message: `Expected 'function' type.`
|
|
1059
1020
|
});
|
|
1060
1021
|
}
|
|
1061
1022
|
if (toolCallDelta.id == null) {
|
|
1062
|
-
throw new
|
|
1023
|
+
throw new InvalidResponseDataError({
|
|
1063
1024
|
data: toolCallDelta,
|
|
1064
1025
|
message: `Expected 'id' to be a string.`
|
|
1065
1026
|
});
|
|
1066
1027
|
}
|
|
1067
1028
|
if (((_f = toolCallDelta.function) == null ? void 0 : _f.name) == null) {
|
|
1068
|
-
throw new
|
|
1029
|
+
throw new InvalidResponseDataError({
|
|
1069
1030
|
data: toolCallDelta,
|
|
1070
1031
|
message: `Expected 'function.name' to be a string.`
|
|
1071
1032
|
});
|
|
@@ -1093,14 +1054,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1093
1054
|
delta: toolCall2.function.arguments
|
|
1094
1055
|
});
|
|
1095
1056
|
}
|
|
1096
|
-
if (
|
|
1057
|
+
if (isParsableJson(toolCall2.function.arguments)) {
|
|
1097
1058
|
controller.enqueue({
|
|
1098
1059
|
type: "tool-input-end",
|
|
1099
1060
|
id: toolCall2.id
|
|
1100
1061
|
});
|
|
1101
1062
|
controller.enqueue({
|
|
1102
1063
|
type: "tool-call",
|
|
1103
|
-
toolCallId: (_j = toolCall2.id) != null ? _j :
|
|
1064
|
+
toolCallId: (_j = toolCall2.id) != null ? _j : generateId(),
|
|
1104
1065
|
toolName: toolCall2.function.name,
|
|
1105
1066
|
input: toolCall2.function.arguments
|
|
1106
1067
|
});
|
|
@@ -1121,14 +1082,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1121
1082
|
id: toolCall.id,
|
|
1122
1083
|
delta: (_n = toolCallDelta.function.arguments) != null ? _n : ""
|
|
1123
1084
|
});
|
|
1124
|
-
if (((_o = toolCall.function) == null ? void 0 : _o.name) != null && ((_p = toolCall.function) == null ? void 0 : _p.arguments) != null &&
|
|
1085
|
+
if (((_o = toolCall.function) == null ? void 0 : _o.name) != null && ((_p = toolCall.function) == null ? void 0 : _p.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
1125
1086
|
controller.enqueue({
|
|
1126
1087
|
type: "tool-input-end",
|
|
1127
1088
|
id: toolCall.id
|
|
1128
1089
|
});
|
|
1129
1090
|
controller.enqueue({
|
|
1130
1091
|
type: "tool-call",
|
|
1131
|
-
toolCallId: (_q = toolCall.id) != null ? _q :
|
|
1092
|
+
toolCallId: (_q = toolCall.id) != null ? _q : generateId(),
|
|
1132
1093
|
toolName: toolCall.function.name,
|
|
1133
1094
|
input: toolCall.function.arguments
|
|
1134
1095
|
});
|
|
@@ -1141,7 +1102,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1141
1102
|
controller.enqueue({
|
|
1142
1103
|
type: "source",
|
|
1143
1104
|
sourceType: "url",
|
|
1144
|
-
id:
|
|
1105
|
+
id: generateId(),
|
|
1145
1106
|
url: annotation.url_citation.url,
|
|
1146
1107
|
title: annotation.url_citation.title
|
|
1147
1108
|
});
|
|
@@ -1168,7 +1129,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
1168
1129
|
};
|
|
1169
1130
|
|
|
1170
1131
|
// src/completion/openai-completion-language-model.ts
|
|
1171
|
-
|
|
1132
|
+
import {
|
|
1133
|
+
combineHeaders as combineHeaders2,
|
|
1134
|
+
createEventSourceResponseHandler as createEventSourceResponseHandler2,
|
|
1135
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
1136
|
+
parseProviderOptions as parseProviderOptions2,
|
|
1137
|
+
postJsonToApi as postJsonToApi2
|
|
1138
|
+
} from "@ai-sdk/provider-utils";
|
|
1172
1139
|
|
|
1173
1140
|
// src/completion/convert-openai-completion-usage.ts
|
|
1174
1141
|
function convertOpenAICompletionUsage(usage) {
|
|
@@ -1208,7 +1175,10 @@ function convertOpenAICompletionUsage(usage) {
|
|
|
1208
1175
|
}
|
|
1209
1176
|
|
|
1210
1177
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1211
|
-
|
|
1178
|
+
import {
|
|
1179
|
+
InvalidPromptError,
|
|
1180
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
1181
|
+
} from "@ai-sdk/provider";
|
|
1212
1182
|
function convertToOpenAICompletionPrompt({
|
|
1213
1183
|
prompt,
|
|
1214
1184
|
user = "user",
|
|
@@ -1224,7 +1194,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
1224
1194
|
for (const { role, content } of prompt) {
|
|
1225
1195
|
switch (role) {
|
|
1226
1196
|
case "system": {
|
|
1227
|
-
throw new
|
|
1197
|
+
throw new InvalidPromptError({
|
|
1228
1198
|
message: "Unexpected system message in prompt: ${content}",
|
|
1229
1199
|
prompt
|
|
1230
1200
|
});
|
|
@@ -1250,7 +1220,7 @@ ${userMessage}
|
|
|
1250
1220
|
return part.text;
|
|
1251
1221
|
}
|
|
1252
1222
|
case "tool-call": {
|
|
1253
|
-
throw new
|
|
1223
|
+
throw new UnsupportedFunctionalityError3({
|
|
1254
1224
|
functionality: "tool-call messages"
|
|
1255
1225
|
});
|
|
1256
1226
|
}
|
|
@@ -1263,7 +1233,7 @@ ${assistantMessage}
|
|
|
1263
1233
|
break;
|
|
1264
1234
|
}
|
|
1265
1235
|
case "tool": {
|
|
1266
|
-
throw new
|
|
1236
|
+
throw new UnsupportedFunctionalityError3({
|
|
1267
1237
|
functionality: "tool messages"
|
|
1268
1238
|
});
|
|
1269
1239
|
}
|
|
@@ -1313,56 +1283,56 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1313
1283
|
}
|
|
1314
1284
|
|
|
1315
1285
|
// src/completion/openai-completion-api.ts
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
var openaiCompletionResponseSchema = (
|
|
1319
|
-
() => (
|
|
1320
|
-
|
|
1321
|
-
id:
|
|
1322
|
-
created:
|
|
1323
|
-
model:
|
|
1324
|
-
choices:
|
|
1325
|
-
|
|
1326
|
-
text:
|
|
1327
|
-
finish_reason:
|
|
1328
|
-
logprobs:
|
|
1329
|
-
tokens:
|
|
1330
|
-
token_logprobs:
|
|
1331
|
-
top_logprobs:
|
|
1286
|
+
import { z as z4 } from "zod/v4";
|
|
1287
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
1288
|
+
var openaiCompletionResponseSchema = lazySchema3(
|
|
1289
|
+
() => zodSchema3(
|
|
1290
|
+
z4.object({
|
|
1291
|
+
id: z4.string().nullish(),
|
|
1292
|
+
created: z4.number().nullish(),
|
|
1293
|
+
model: z4.string().nullish(),
|
|
1294
|
+
choices: z4.array(
|
|
1295
|
+
z4.object({
|
|
1296
|
+
text: z4.string(),
|
|
1297
|
+
finish_reason: z4.string(),
|
|
1298
|
+
logprobs: z4.object({
|
|
1299
|
+
tokens: z4.array(z4.string()),
|
|
1300
|
+
token_logprobs: z4.array(z4.number()),
|
|
1301
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1332
1302
|
}).nullish()
|
|
1333
1303
|
})
|
|
1334
1304
|
),
|
|
1335
|
-
usage:
|
|
1336
|
-
prompt_tokens:
|
|
1337
|
-
completion_tokens:
|
|
1338
|
-
total_tokens:
|
|
1305
|
+
usage: z4.object({
|
|
1306
|
+
prompt_tokens: z4.number(),
|
|
1307
|
+
completion_tokens: z4.number(),
|
|
1308
|
+
total_tokens: z4.number()
|
|
1339
1309
|
}).nullish()
|
|
1340
1310
|
})
|
|
1341
1311
|
)
|
|
1342
1312
|
);
|
|
1343
|
-
var openaiCompletionChunkSchema = (
|
|
1344
|
-
() => (
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
id:
|
|
1348
|
-
created:
|
|
1349
|
-
model:
|
|
1350
|
-
choices:
|
|
1351
|
-
|
|
1352
|
-
text:
|
|
1353
|
-
finish_reason:
|
|
1354
|
-
index:
|
|
1355
|
-
logprobs:
|
|
1356
|
-
tokens:
|
|
1357
|
-
token_logprobs:
|
|
1358
|
-
top_logprobs:
|
|
1313
|
+
var openaiCompletionChunkSchema = lazySchema3(
|
|
1314
|
+
() => zodSchema3(
|
|
1315
|
+
z4.union([
|
|
1316
|
+
z4.object({
|
|
1317
|
+
id: z4.string().nullish(),
|
|
1318
|
+
created: z4.number().nullish(),
|
|
1319
|
+
model: z4.string().nullish(),
|
|
1320
|
+
choices: z4.array(
|
|
1321
|
+
z4.object({
|
|
1322
|
+
text: z4.string(),
|
|
1323
|
+
finish_reason: z4.string().nullish(),
|
|
1324
|
+
index: z4.number(),
|
|
1325
|
+
logprobs: z4.object({
|
|
1326
|
+
tokens: z4.array(z4.string()),
|
|
1327
|
+
token_logprobs: z4.array(z4.number()),
|
|
1328
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1359
1329
|
}).nullish()
|
|
1360
1330
|
})
|
|
1361
1331
|
),
|
|
1362
|
-
usage:
|
|
1363
|
-
prompt_tokens:
|
|
1364
|
-
completion_tokens:
|
|
1365
|
-
total_tokens:
|
|
1332
|
+
usage: z4.object({
|
|
1333
|
+
prompt_tokens: z4.number(),
|
|
1334
|
+
completion_tokens: z4.number(),
|
|
1335
|
+
total_tokens: z4.number()
|
|
1366
1336
|
}).nullish()
|
|
1367
1337
|
}),
|
|
1368
1338
|
openaiErrorDataSchema
|
|
@@ -1371,15 +1341,15 @@ var openaiCompletionChunkSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1371
1341
|
);
|
|
1372
1342
|
|
|
1373
1343
|
// src/completion/openai-completion-options.ts
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
var openaiLanguageModelCompletionOptions = (
|
|
1377
|
-
() => (
|
|
1378
|
-
|
|
1344
|
+
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
1345
|
+
import { z as z5 } from "zod/v4";
|
|
1346
|
+
var openaiLanguageModelCompletionOptions = lazySchema4(
|
|
1347
|
+
() => zodSchema4(
|
|
1348
|
+
z5.object({
|
|
1379
1349
|
/**
|
|
1380
1350
|
* Echo back the prompt in addition to the completion.
|
|
1381
1351
|
*/
|
|
1382
|
-
echo:
|
|
1352
|
+
echo: z5.boolean().optional(),
|
|
1383
1353
|
/**
|
|
1384
1354
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
1385
1355
|
*
|
|
@@ -1394,16 +1364,16 @@ var openaiLanguageModelCompletionOptions = (0, import_provider_utils7.lazySchema
|
|
|
1394
1364
|
* As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1395
1365
|
* token from being generated.
|
|
1396
1366
|
*/
|
|
1397
|
-
logitBias:
|
|
1367
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1398
1368
|
/**
|
|
1399
1369
|
* The suffix that comes after a completion of inserted text.
|
|
1400
1370
|
*/
|
|
1401
|
-
suffix:
|
|
1371
|
+
suffix: z5.string().optional(),
|
|
1402
1372
|
/**
|
|
1403
1373
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
1404
1374
|
* monitor and detect abuse. Learn more.
|
|
1405
1375
|
*/
|
|
1406
|
-
user:
|
|
1376
|
+
user: z5.string().optional(),
|
|
1407
1377
|
/**
|
|
1408
1378
|
* Return the log probabilities of the tokens. Including logprobs will increase
|
|
1409
1379
|
* the response size and can slow down response times. However, it can
|
|
@@ -1413,7 +1383,7 @@ var openaiLanguageModelCompletionOptions = (0, import_provider_utils7.lazySchema
|
|
|
1413
1383
|
* Setting to a number will return the log probabilities of the top n
|
|
1414
1384
|
* tokens that were generated.
|
|
1415
1385
|
*/
|
|
1416
|
-
logprobs:
|
|
1386
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1417
1387
|
})
|
|
1418
1388
|
)
|
|
1419
1389
|
);
|
|
@@ -1451,12 +1421,12 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1451
1421
|
}) {
|
|
1452
1422
|
const warnings = [];
|
|
1453
1423
|
const openaiOptions = {
|
|
1454
|
-
...await (
|
|
1424
|
+
...await parseProviderOptions2({
|
|
1455
1425
|
provider: "openai",
|
|
1456
1426
|
providerOptions,
|
|
1457
1427
|
schema: openaiLanguageModelCompletionOptions
|
|
1458
1428
|
}),
|
|
1459
|
-
...await (
|
|
1429
|
+
...await parseProviderOptions2({
|
|
1460
1430
|
provider: this.providerOptionsName,
|
|
1461
1431
|
providerOptions,
|
|
1462
1432
|
schema: openaiLanguageModelCompletionOptions
|
|
@@ -1512,15 +1482,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1512
1482
|
responseHeaders,
|
|
1513
1483
|
value: response,
|
|
1514
1484
|
rawValue: rawResponse
|
|
1515
|
-
} = await (
|
|
1485
|
+
} = await postJsonToApi2({
|
|
1516
1486
|
url: this.config.url({
|
|
1517
1487
|
path: "/completions",
|
|
1518
1488
|
modelId: this.modelId
|
|
1519
1489
|
}),
|
|
1520
|
-
headers: (
|
|
1490
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
1521
1491
|
body: args,
|
|
1522
1492
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1523
|
-
successfulResponseHandler: (
|
|
1493
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
1524
1494
|
openaiCompletionResponseSchema
|
|
1525
1495
|
),
|
|
1526
1496
|
abortSignal: options.abortSignal,
|
|
@@ -1557,15 +1527,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1557
1527
|
include_usage: true
|
|
1558
1528
|
}
|
|
1559
1529
|
};
|
|
1560
|
-
const { responseHeaders, value: response } = await (
|
|
1530
|
+
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
1561
1531
|
url: this.config.url({
|
|
1562
1532
|
path: "/completions",
|
|
1563
1533
|
modelId: this.modelId
|
|
1564
1534
|
}),
|
|
1565
|
-
headers: (
|
|
1535
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
1566
1536
|
body,
|
|
1567
1537
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1568
|
-
successfulResponseHandler: (
|
|
1538
|
+
successfulResponseHandler: createEventSourceResponseHandler2(
|
|
1569
1539
|
openaiCompletionChunkSchema
|
|
1570
1540
|
),
|
|
1571
1541
|
abortSignal: options.abortSignal,
|
|
@@ -1648,37 +1618,44 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1648
1618
|
};
|
|
1649
1619
|
|
|
1650
1620
|
// src/embedding/openai-embedding-model.ts
|
|
1651
|
-
|
|
1652
|
-
|
|
1621
|
+
import {
|
|
1622
|
+
TooManyEmbeddingValuesForCallError
|
|
1623
|
+
} from "@ai-sdk/provider";
|
|
1624
|
+
import {
|
|
1625
|
+
combineHeaders as combineHeaders3,
|
|
1626
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1627
|
+
parseProviderOptions as parseProviderOptions3,
|
|
1628
|
+
postJsonToApi as postJsonToApi3
|
|
1629
|
+
} from "@ai-sdk/provider-utils";
|
|
1653
1630
|
|
|
1654
1631
|
// src/embedding/openai-embedding-options.ts
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
var openaiEmbeddingModelOptions = (
|
|
1658
|
-
() => (
|
|
1659
|
-
|
|
1632
|
+
import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
|
|
1633
|
+
import { z as z6 } from "zod/v4";
|
|
1634
|
+
var openaiEmbeddingModelOptions = lazySchema5(
|
|
1635
|
+
() => zodSchema5(
|
|
1636
|
+
z6.object({
|
|
1660
1637
|
/**
|
|
1661
1638
|
* The number of dimensions the resulting output embeddings should have.
|
|
1662
1639
|
* Only supported in text-embedding-3 and later models.
|
|
1663
1640
|
*/
|
|
1664
|
-
dimensions:
|
|
1641
|
+
dimensions: z6.number().optional(),
|
|
1665
1642
|
/**
|
|
1666
1643
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
1667
1644
|
* monitor and detect abuse. Learn more.
|
|
1668
1645
|
*/
|
|
1669
|
-
user:
|
|
1646
|
+
user: z6.string().optional()
|
|
1670
1647
|
})
|
|
1671
1648
|
)
|
|
1672
1649
|
);
|
|
1673
1650
|
|
|
1674
1651
|
// src/embedding/openai-embedding-api.ts
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
var openaiTextEmbeddingResponseSchema = (
|
|
1678
|
-
() => (
|
|
1679
|
-
|
|
1680
|
-
data:
|
|
1681
|
-
usage:
|
|
1652
|
+
import { lazySchema as lazySchema6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
1653
|
+
import { z as z7 } from "zod/v4";
|
|
1654
|
+
var openaiTextEmbeddingResponseSchema = lazySchema6(
|
|
1655
|
+
() => zodSchema6(
|
|
1656
|
+
z7.object({
|
|
1657
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1658
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1682
1659
|
})
|
|
1683
1660
|
)
|
|
1684
1661
|
);
|
|
@@ -1703,14 +1680,14 @@ var OpenAIEmbeddingModel = class {
|
|
|
1703
1680
|
}) {
|
|
1704
1681
|
var _a;
|
|
1705
1682
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
1706
|
-
throw new
|
|
1683
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
1707
1684
|
provider: this.provider,
|
|
1708
1685
|
modelId: this.modelId,
|
|
1709
1686
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
1710
1687
|
values
|
|
1711
1688
|
});
|
|
1712
1689
|
}
|
|
1713
|
-
const openaiOptions = (_a = await (
|
|
1690
|
+
const openaiOptions = (_a = await parseProviderOptions3({
|
|
1714
1691
|
provider: "openai",
|
|
1715
1692
|
providerOptions,
|
|
1716
1693
|
schema: openaiEmbeddingModelOptions
|
|
@@ -1719,12 +1696,12 @@ var OpenAIEmbeddingModel = class {
|
|
|
1719
1696
|
responseHeaders,
|
|
1720
1697
|
value: response,
|
|
1721
1698
|
rawValue
|
|
1722
|
-
} = await (
|
|
1699
|
+
} = await postJsonToApi3({
|
|
1723
1700
|
url: this.config.url({
|
|
1724
1701
|
path: "/embeddings",
|
|
1725
1702
|
modelId: this.modelId
|
|
1726
1703
|
}),
|
|
1727
|
-
headers: (
|
|
1704
|
+
headers: combineHeaders3(this.config.headers(), headers),
|
|
1728
1705
|
body: {
|
|
1729
1706
|
model: this.modelId,
|
|
1730
1707
|
input: values,
|
|
@@ -1733,7 +1710,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1733
1710
|
user: openaiOptions.user
|
|
1734
1711
|
},
|
|
1735
1712
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1736
|
-
successfulResponseHandler: (
|
|
1713
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
1737
1714
|
openaiTextEmbeddingResponseSchema
|
|
1738
1715
|
),
|
|
1739
1716
|
abortSignal,
|
|
@@ -1749,32 +1726,40 @@ var OpenAIEmbeddingModel = class {
|
|
|
1749
1726
|
};
|
|
1750
1727
|
|
|
1751
1728
|
// src/image/openai-image-model.ts
|
|
1752
|
-
|
|
1729
|
+
import {
|
|
1730
|
+
combineHeaders as combineHeaders4,
|
|
1731
|
+
convertBase64ToUint8Array,
|
|
1732
|
+
convertToFormData,
|
|
1733
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1734
|
+
downloadBlob,
|
|
1735
|
+
postFormDataToApi,
|
|
1736
|
+
postJsonToApi as postJsonToApi4
|
|
1737
|
+
} from "@ai-sdk/provider-utils";
|
|
1753
1738
|
|
|
1754
1739
|
// src/image/openai-image-api.ts
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
var openaiImageResponseSchema = (
|
|
1758
|
-
() => (
|
|
1759
|
-
|
|
1760
|
-
created:
|
|
1761
|
-
data:
|
|
1762
|
-
|
|
1763
|
-
b64_json:
|
|
1764
|
-
revised_prompt:
|
|
1740
|
+
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
1741
|
+
import { z as z8 } from "zod/v4";
|
|
1742
|
+
var openaiImageResponseSchema = lazySchema7(
|
|
1743
|
+
() => zodSchema7(
|
|
1744
|
+
z8.object({
|
|
1745
|
+
created: z8.number().nullish(),
|
|
1746
|
+
data: z8.array(
|
|
1747
|
+
z8.object({
|
|
1748
|
+
b64_json: z8.string(),
|
|
1749
|
+
revised_prompt: z8.string().nullish()
|
|
1765
1750
|
})
|
|
1766
1751
|
),
|
|
1767
|
-
background:
|
|
1768
|
-
output_format:
|
|
1769
|
-
size:
|
|
1770
|
-
quality:
|
|
1771
|
-
usage:
|
|
1772
|
-
input_tokens:
|
|
1773
|
-
output_tokens:
|
|
1774
|
-
total_tokens:
|
|
1775
|
-
input_tokens_details:
|
|
1776
|
-
image_tokens:
|
|
1777
|
-
text_tokens:
|
|
1752
|
+
background: z8.string().nullish(),
|
|
1753
|
+
output_format: z8.string().nullish(),
|
|
1754
|
+
size: z8.string().nullish(),
|
|
1755
|
+
quality: z8.string().nullish(),
|
|
1756
|
+
usage: z8.object({
|
|
1757
|
+
input_tokens: z8.number().nullish(),
|
|
1758
|
+
output_tokens: z8.number().nullish(),
|
|
1759
|
+
total_tokens: z8.number().nullish(),
|
|
1760
|
+
input_tokens_details: z8.object({
|
|
1761
|
+
image_tokens: z8.number().nullish(),
|
|
1762
|
+
text_tokens: z8.number().nullish()
|
|
1778
1763
|
}).nullish()
|
|
1779
1764
|
}).nullish()
|
|
1780
1765
|
})
|
|
@@ -1842,13 +1827,13 @@ var OpenAIImageModel = class {
|
|
|
1842
1827
|
}
|
|
1843
1828
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1844
1829
|
if (files != null) {
|
|
1845
|
-
const { value: response2, responseHeaders: responseHeaders2 } = await
|
|
1830
|
+
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
|
|
1846
1831
|
url: this.config.url({
|
|
1847
1832
|
path: "/images/edits",
|
|
1848
1833
|
modelId: this.modelId
|
|
1849
1834
|
}),
|
|
1850
|
-
headers: (
|
|
1851
|
-
formData:
|
|
1835
|
+
headers: combineHeaders4(this.config.headers(), headers),
|
|
1836
|
+
formData: convertToFormData({
|
|
1852
1837
|
model: this.modelId,
|
|
1853
1838
|
prompt,
|
|
1854
1839
|
image: await Promise.all(
|
|
@@ -1857,12 +1842,12 @@ var OpenAIImageModel = class {
|
|
|
1857
1842
|
[
|
|
1858
1843
|
file.data instanceof Uint8Array ? new Blob([file.data], {
|
|
1859
1844
|
type: file.mediaType
|
|
1860
|
-
}) : new Blob([
|
|
1845
|
+
}) : new Blob([convertBase64ToUint8Array(file.data)], {
|
|
1861
1846
|
type: file.mediaType
|
|
1862
1847
|
})
|
|
1863
1848
|
],
|
|
1864
1849
|
{ type: file.mediaType }
|
|
1865
|
-
) :
|
|
1850
|
+
) : downloadBlob(file.url)
|
|
1866
1851
|
)
|
|
1867
1852
|
),
|
|
1868
1853
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
@@ -1871,7 +1856,7 @@ var OpenAIImageModel = class {
|
|
|
1871
1856
|
...(_d = providerOptions.openai) != null ? _d : {}
|
|
1872
1857
|
}),
|
|
1873
1858
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1874
|
-
successfulResponseHandler: (
|
|
1859
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
1875
1860
|
openaiImageResponseSchema
|
|
1876
1861
|
),
|
|
1877
1862
|
abortSignal,
|
|
@@ -1912,12 +1897,12 @@ var OpenAIImageModel = class {
|
|
|
1912
1897
|
}
|
|
1913
1898
|
};
|
|
1914
1899
|
}
|
|
1915
|
-
const { value: response, responseHeaders } = await (
|
|
1900
|
+
const { value: response, responseHeaders } = await postJsonToApi4({
|
|
1916
1901
|
url: this.config.url({
|
|
1917
1902
|
path: "/images/generations",
|
|
1918
1903
|
modelId: this.modelId
|
|
1919
1904
|
}),
|
|
1920
|
-
headers: (
|
|
1905
|
+
headers: combineHeaders4(this.config.headers(), headers),
|
|
1921
1906
|
body: {
|
|
1922
1907
|
model: this.modelId,
|
|
1923
1908
|
prompt,
|
|
@@ -1927,7 +1912,7 @@ var OpenAIImageModel = class {
|
|
|
1927
1912
|
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1928
1913
|
},
|
|
1929
1914
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1930
|
-
successfulResponseHandler: (
|
|
1915
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
1931
1916
|
openaiImageResponseSchema
|
|
1932
1917
|
),
|
|
1933
1918
|
abortSignal,
|
|
@@ -1989,43 +1974,50 @@ function distributeTokenDetails(details, index, total) {
|
|
|
1989
1974
|
async function fileToBlob(file) {
|
|
1990
1975
|
if (!file) return void 0;
|
|
1991
1976
|
if (file.type === "url") {
|
|
1992
|
-
return
|
|
1977
|
+
return downloadBlob(file.url);
|
|
1993
1978
|
}
|
|
1994
|
-
const data = file.data instanceof Uint8Array ? file.data :
|
|
1979
|
+
const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
|
|
1995
1980
|
return new Blob([data], { type: file.mediaType });
|
|
1996
1981
|
}
|
|
1997
1982
|
|
|
1998
1983
|
// src/transcription/openai-transcription-model.ts
|
|
1999
|
-
|
|
1984
|
+
import {
|
|
1985
|
+
combineHeaders as combineHeaders5,
|
|
1986
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
1987
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
1988
|
+
mediaTypeToExtension,
|
|
1989
|
+
parseProviderOptions as parseProviderOptions4,
|
|
1990
|
+
postFormDataToApi as postFormDataToApi2
|
|
1991
|
+
} from "@ai-sdk/provider-utils";
|
|
2000
1992
|
|
|
2001
1993
|
// src/transcription/openai-transcription-api.ts
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
var openaiTranscriptionResponseSchema = (
|
|
2005
|
-
() => (
|
|
2006
|
-
|
|
2007
|
-
text:
|
|
2008
|
-
language:
|
|
2009
|
-
duration:
|
|
2010
|
-
words:
|
|
2011
|
-
|
|
2012
|
-
word:
|
|
2013
|
-
start:
|
|
2014
|
-
end:
|
|
1994
|
+
import { lazySchema as lazySchema8, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
|
|
1995
|
+
import { z as z9 } from "zod/v4";
|
|
1996
|
+
var openaiTranscriptionResponseSchema = lazySchema8(
|
|
1997
|
+
() => zodSchema8(
|
|
1998
|
+
z9.object({
|
|
1999
|
+
text: z9.string(),
|
|
2000
|
+
language: z9.string().nullish(),
|
|
2001
|
+
duration: z9.number().nullish(),
|
|
2002
|
+
words: z9.array(
|
|
2003
|
+
z9.object({
|
|
2004
|
+
word: z9.string(),
|
|
2005
|
+
start: z9.number(),
|
|
2006
|
+
end: z9.number()
|
|
2015
2007
|
})
|
|
2016
2008
|
).nullish(),
|
|
2017
|
-
segments:
|
|
2018
|
-
|
|
2019
|
-
id:
|
|
2020
|
-
seek:
|
|
2021
|
-
start:
|
|
2022
|
-
end:
|
|
2023
|
-
text:
|
|
2024
|
-
tokens:
|
|
2025
|
-
temperature:
|
|
2026
|
-
avg_logprob:
|
|
2027
|
-
compression_ratio:
|
|
2028
|
-
no_speech_prob:
|
|
2009
|
+
segments: z9.array(
|
|
2010
|
+
z9.object({
|
|
2011
|
+
id: z9.number(),
|
|
2012
|
+
seek: z9.number(),
|
|
2013
|
+
start: z9.number(),
|
|
2014
|
+
end: z9.number(),
|
|
2015
|
+
text: z9.string(),
|
|
2016
|
+
tokens: z9.array(z9.number()),
|
|
2017
|
+
temperature: z9.number(),
|
|
2018
|
+
avg_logprob: z9.number(),
|
|
2019
|
+
compression_ratio: z9.number(),
|
|
2020
|
+
no_speech_prob: z9.number()
|
|
2029
2021
|
})
|
|
2030
2022
|
).nullish()
|
|
2031
2023
|
})
|
|
@@ -2033,33 +2025,33 @@ var openaiTranscriptionResponseSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
2033
2025
|
);
|
|
2034
2026
|
|
|
2035
2027
|
// src/transcription/openai-transcription-options.ts
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
var openAITranscriptionModelOptions = (
|
|
2039
|
-
() => (
|
|
2040
|
-
|
|
2028
|
+
import { lazySchema as lazySchema9, zodSchema as zodSchema9 } from "@ai-sdk/provider-utils";
|
|
2029
|
+
import { z as z10 } from "zod/v4";
|
|
2030
|
+
var openAITranscriptionModelOptions = lazySchema9(
|
|
2031
|
+
() => zodSchema9(
|
|
2032
|
+
z10.object({
|
|
2041
2033
|
/**
|
|
2042
2034
|
* Additional information to include in the transcription response.
|
|
2043
2035
|
*/
|
|
2044
|
-
include:
|
|
2036
|
+
include: z10.array(z10.string()).optional(),
|
|
2045
2037
|
/**
|
|
2046
2038
|
* The language of the input audio in ISO-639-1 format.
|
|
2047
2039
|
*/
|
|
2048
|
-
language:
|
|
2040
|
+
language: z10.string().optional(),
|
|
2049
2041
|
/**
|
|
2050
2042
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
2051
2043
|
*/
|
|
2052
|
-
prompt:
|
|
2044
|
+
prompt: z10.string().optional(),
|
|
2053
2045
|
/**
|
|
2054
2046
|
* The sampling temperature, between 0 and 1.
|
|
2055
2047
|
* @default 0
|
|
2056
2048
|
*/
|
|
2057
|
-
temperature:
|
|
2049
|
+
temperature: z10.number().min(0).max(1).default(0).optional(),
|
|
2058
2050
|
/**
|
|
2059
2051
|
* The timestamp granularities to populate for this transcription.
|
|
2060
2052
|
* @default ['segment']
|
|
2061
2053
|
*/
|
|
2062
|
-
timestampGranularities:
|
|
2054
|
+
timestampGranularities: z10.array(z10.enum(["word", "segment"])).default(["segment"]).optional()
|
|
2063
2055
|
})
|
|
2064
2056
|
)
|
|
2065
2057
|
);
|
|
@@ -2139,15 +2131,15 @@ var OpenAITranscriptionModel = class {
|
|
|
2139
2131
|
providerOptions
|
|
2140
2132
|
}) {
|
|
2141
2133
|
const warnings = [];
|
|
2142
|
-
const openAIOptions = await (
|
|
2134
|
+
const openAIOptions = await parseProviderOptions4({
|
|
2143
2135
|
provider: "openai",
|
|
2144
2136
|
providerOptions,
|
|
2145
2137
|
schema: openAITranscriptionModelOptions
|
|
2146
2138
|
});
|
|
2147
2139
|
const formData = new FormData();
|
|
2148
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(
|
|
2140
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array2(audio)]);
|
|
2149
2141
|
formData.append("model", this.modelId);
|
|
2150
|
-
const fileExtension =
|
|
2142
|
+
const fileExtension = mediaTypeToExtension(mediaType);
|
|
2151
2143
|
formData.append(
|
|
2152
2144
|
"file",
|
|
2153
2145
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -2192,15 +2184,15 @@ var OpenAITranscriptionModel = class {
|
|
|
2192
2184
|
value: response,
|
|
2193
2185
|
responseHeaders,
|
|
2194
2186
|
rawValue: rawResponse
|
|
2195
|
-
} = await (
|
|
2187
|
+
} = await postFormDataToApi2({
|
|
2196
2188
|
url: this.config.url({
|
|
2197
2189
|
path: "/audio/transcriptions",
|
|
2198
2190
|
modelId: this.modelId
|
|
2199
2191
|
}),
|
|
2200
|
-
headers: (
|
|
2192
|
+
headers: combineHeaders5(this.config.headers(), options.headers),
|
|
2201
2193
|
formData,
|
|
2202
2194
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2203
|
-
successfulResponseHandler: (
|
|
2195
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
2204
2196
|
openaiTranscriptionResponseSchema
|
|
2205
2197
|
),
|
|
2206
2198
|
abortSignal: options.abortSignal,
|
|
@@ -2232,16 +2224,21 @@ var OpenAITranscriptionModel = class {
|
|
|
2232
2224
|
};
|
|
2233
2225
|
|
|
2234
2226
|
// src/speech/openai-speech-model.ts
|
|
2235
|
-
|
|
2227
|
+
import {
|
|
2228
|
+
combineHeaders as combineHeaders6,
|
|
2229
|
+
createBinaryResponseHandler,
|
|
2230
|
+
parseProviderOptions as parseProviderOptions5,
|
|
2231
|
+
postJsonToApi as postJsonToApi5
|
|
2232
|
+
} from "@ai-sdk/provider-utils";
|
|
2236
2233
|
|
|
2237
2234
|
// src/speech/openai-speech-options.ts
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
var openaiSpeechModelOptionsSchema = (
|
|
2241
|
-
() => (
|
|
2242
|
-
|
|
2243
|
-
instructions:
|
|
2244
|
-
speed:
|
|
2235
|
+
import { lazySchema as lazySchema10, zodSchema as zodSchema10 } from "@ai-sdk/provider-utils";
|
|
2236
|
+
import { z as z11 } from "zod/v4";
|
|
2237
|
+
var openaiSpeechModelOptionsSchema = lazySchema10(
|
|
2238
|
+
() => zodSchema10(
|
|
2239
|
+
z11.object({
|
|
2240
|
+
instructions: z11.string().nullish(),
|
|
2241
|
+
speed: z11.number().min(0.25).max(4).default(1).nullish()
|
|
2245
2242
|
})
|
|
2246
2243
|
)
|
|
2247
2244
|
);
|
|
@@ -2266,7 +2263,7 @@ var OpenAISpeechModel = class {
|
|
|
2266
2263
|
providerOptions
|
|
2267
2264
|
}) {
|
|
2268
2265
|
const warnings = [];
|
|
2269
|
-
const openAIOptions = await (
|
|
2266
|
+
const openAIOptions = await parseProviderOptions5({
|
|
2270
2267
|
provider: "openai",
|
|
2271
2268
|
providerOptions,
|
|
2272
2269
|
schema: openaiSpeechModelOptionsSchema
|
|
@@ -2319,15 +2316,15 @@ var OpenAISpeechModel = class {
|
|
|
2319
2316
|
value: audio,
|
|
2320
2317
|
responseHeaders,
|
|
2321
2318
|
rawValue: rawResponse
|
|
2322
|
-
} = await (
|
|
2319
|
+
} = await postJsonToApi5({
|
|
2323
2320
|
url: this.config.url({
|
|
2324
2321
|
path: "/audio/speech",
|
|
2325
2322
|
modelId: this.modelId
|
|
2326
2323
|
}),
|
|
2327
|
-
headers: (
|
|
2324
|
+
headers: combineHeaders6(this.config.headers(), options.headers),
|
|
2328
2325
|
body: requestBody,
|
|
2329
2326
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2330
|
-
successfulResponseHandler:
|
|
2327
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
2331
2328
|
abortSignal: options.abortSignal,
|
|
2332
2329
|
fetch: this.config.fetch
|
|
2333
2330
|
});
|
|
@@ -2348,8 +2345,19 @@ var OpenAISpeechModel = class {
|
|
|
2348
2345
|
};
|
|
2349
2346
|
|
|
2350
2347
|
// src/responses/openai-responses-language-model.ts
|
|
2351
|
-
|
|
2352
|
-
|
|
2348
|
+
import {
|
|
2349
|
+
APICallError
|
|
2350
|
+
} from "@ai-sdk/provider";
|
|
2351
|
+
import {
|
|
2352
|
+
combineHeaders as combineHeaders7,
|
|
2353
|
+
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
2354
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
2355
|
+
createToolNameMapping,
|
|
2356
|
+
generateId as generateId2,
|
|
2357
|
+
isCustomReasoning as isCustomReasoning2,
|
|
2358
|
+
parseProviderOptions as parseProviderOptions7,
|
|
2359
|
+
postJsonToApi as postJsonToApi6
|
|
2360
|
+
} from "@ai-sdk/provider-utils";
|
|
2353
2361
|
|
|
2354
2362
|
// src/responses/convert-openai-responses-usage.ts
|
|
2355
2363
|
function convertOpenAIResponsesUsage(usage) {
|
|
@@ -2391,46 +2399,60 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2391
2399
|
}
|
|
2392
2400
|
|
|
2393
2401
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2402
|
+
import {
|
|
2403
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2404
|
+
} from "@ai-sdk/provider";
|
|
2405
|
+
import {
|
|
2406
|
+
convertToBase64 as convertToBase642,
|
|
2407
|
+
isNonNullable,
|
|
2408
|
+
isProviderReference as isProviderReference2,
|
|
2409
|
+
parseJSON,
|
|
2410
|
+
parseProviderOptions as parseProviderOptions6,
|
|
2411
|
+
resolveProviderReference as resolveProviderReference2,
|
|
2412
|
+
validateTypes
|
|
2413
|
+
} from "@ai-sdk/provider-utils";
|
|
2414
|
+
import { z as z16 } from "zod/v4";
|
|
2397
2415
|
|
|
2398
2416
|
// src/tool/apply-patch.ts
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2417
|
+
import {
|
|
2418
|
+
createProviderToolFactoryWithOutputSchema,
|
|
2419
|
+
lazySchema as lazySchema11,
|
|
2420
|
+
zodSchema as zodSchema11
|
|
2421
|
+
} from "@ai-sdk/provider-utils";
|
|
2422
|
+
import { z as z12 } from "zod/v4";
|
|
2423
|
+
var applyPatchInputSchema = lazySchema11(
|
|
2424
|
+
() => zodSchema11(
|
|
2425
|
+
z12.object({
|
|
2426
|
+
callId: z12.string(),
|
|
2427
|
+
operation: z12.discriminatedUnion("type", [
|
|
2428
|
+
z12.object({
|
|
2429
|
+
type: z12.literal("create_file"),
|
|
2430
|
+
path: z12.string(),
|
|
2431
|
+
diff: z12.string()
|
|
2410
2432
|
}),
|
|
2411
|
-
|
|
2412
|
-
type:
|
|
2413
|
-
path:
|
|
2433
|
+
z12.object({
|
|
2434
|
+
type: z12.literal("delete_file"),
|
|
2435
|
+
path: z12.string()
|
|
2414
2436
|
}),
|
|
2415
|
-
|
|
2416
|
-
type:
|
|
2417
|
-
path:
|
|
2418
|
-
diff:
|
|
2437
|
+
z12.object({
|
|
2438
|
+
type: z12.literal("update_file"),
|
|
2439
|
+
path: z12.string(),
|
|
2440
|
+
diff: z12.string()
|
|
2419
2441
|
})
|
|
2420
2442
|
])
|
|
2421
2443
|
})
|
|
2422
2444
|
)
|
|
2423
2445
|
);
|
|
2424
|
-
var applyPatchOutputSchema = (
|
|
2425
|
-
() => (
|
|
2426
|
-
|
|
2427
|
-
status:
|
|
2428
|
-
output:
|
|
2446
|
+
var applyPatchOutputSchema = lazySchema11(
|
|
2447
|
+
() => zodSchema11(
|
|
2448
|
+
z12.object({
|
|
2449
|
+
status: z12.enum(["completed", "failed"]),
|
|
2450
|
+
output: z12.string().optional()
|
|
2429
2451
|
})
|
|
2430
2452
|
)
|
|
2431
2453
|
);
|
|
2432
|
-
var applyPatchArgsSchema = (
|
|
2433
|
-
var applyPatchToolFactory =
|
|
2454
|
+
var applyPatchArgsSchema = lazySchema11(() => zodSchema11(z12.object({})));
|
|
2455
|
+
var applyPatchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
2434
2456
|
id: "openai.apply_patch",
|
|
2435
2457
|
inputSchema: applyPatchInputSchema,
|
|
2436
2458
|
outputSchema: applyPatchOutputSchema
|
|
@@ -2438,115 +2460,123 @@ var applyPatchToolFactory = (0, import_provider_utils19.createProviderToolFactor
|
|
|
2438
2460
|
var applyPatch = applyPatchToolFactory;
|
|
2439
2461
|
|
|
2440
2462
|
// src/tool/local-shell.ts
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2463
|
+
import {
|
|
2464
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
2465
|
+
lazySchema as lazySchema12,
|
|
2466
|
+
zodSchema as zodSchema12
|
|
2467
|
+
} from "@ai-sdk/provider-utils";
|
|
2468
|
+
import { z as z13 } from "zod/v4";
|
|
2469
|
+
var localShellInputSchema = lazySchema12(
|
|
2470
|
+
() => zodSchema12(
|
|
2471
|
+
z13.object({
|
|
2472
|
+
action: z13.object({
|
|
2473
|
+
type: z13.literal("exec"),
|
|
2474
|
+
command: z13.array(z13.string()),
|
|
2475
|
+
timeoutMs: z13.number().optional(),
|
|
2476
|
+
user: z13.string().optional(),
|
|
2477
|
+
workingDirectory: z13.string().optional(),
|
|
2478
|
+
env: z13.record(z13.string(), z13.string()).optional()
|
|
2453
2479
|
})
|
|
2454
2480
|
})
|
|
2455
2481
|
)
|
|
2456
2482
|
);
|
|
2457
|
-
var localShellOutputSchema = (
|
|
2458
|
-
() => (
|
|
2483
|
+
var localShellOutputSchema = lazySchema12(
|
|
2484
|
+
() => zodSchema12(z13.object({ output: z13.string() }))
|
|
2459
2485
|
);
|
|
2460
|
-
var localShell = (
|
|
2486
|
+
var localShell = createProviderToolFactoryWithOutputSchema2({
|
|
2461
2487
|
id: "openai.local_shell",
|
|
2462
2488
|
inputSchema: localShellInputSchema,
|
|
2463
2489
|
outputSchema: localShellOutputSchema
|
|
2464
2490
|
});
|
|
2465
2491
|
|
|
2466
2492
|
// src/tool/shell.ts
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2493
|
+
import {
|
|
2494
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
2495
|
+
lazySchema as lazySchema13,
|
|
2496
|
+
zodSchema as zodSchema13
|
|
2497
|
+
} from "@ai-sdk/provider-utils";
|
|
2498
|
+
import { z as z14 } from "zod/v4";
|
|
2499
|
+
var shellInputSchema = lazySchema13(
|
|
2500
|
+
() => zodSchema13(
|
|
2501
|
+
z14.object({
|
|
2502
|
+
action: z14.object({
|
|
2503
|
+
commands: z14.array(z14.string()),
|
|
2504
|
+
timeoutMs: z14.number().optional(),
|
|
2505
|
+
maxOutputLength: z14.number().optional()
|
|
2476
2506
|
})
|
|
2477
2507
|
})
|
|
2478
2508
|
)
|
|
2479
2509
|
);
|
|
2480
|
-
var shellOutputSchema = (
|
|
2481
|
-
() => (
|
|
2482
|
-
|
|
2483
|
-
output:
|
|
2484
|
-
|
|
2485
|
-
stdout:
|
|
2486
|
-
stderr:
|
|
2487
|
-
outcome:
|
|
2488
|
-
|
|
2489
|
-
|
|
2510
|
+
var shellOutputSchema = lazySchema13(
|
|
2511
|
+
() => zodSchema13(
|
|
2512
|
+
z14.object({
|
|
2513
|
+
output: z14.array(
|
|
2514
|
+
z14.object({
|
|
2515
|
+
stdout: z14.string(),
|
|
2516
|
+
stderr: z14.string(),
|
|
2517
|
+
outcome: z14.discriminatedUnion("type", [
|
|
2518
|
+
z14.object({ type: z14.literal("timeout") }),
|
|
2519
|
+
z14.object({ type: z14.literal("exit"), exitCode: z14.number() })
|
|
2490
2520
|
])
|
|
2491
2521
|
})
|
|
2492
2522
|
)
|
|
2493
2523
|
})
|
|
2494
2524
|
)
|
|
2495
2525
|
);
|
|
2496
|
-
var shellSkillsSchema =
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
type:
|
|
2500
|
-
providerReference:
|
|
2501
|
-
version:
|
|
2526
|
+
var shellSkillsSchema = z14.array(
|
|
2527
|
+
z14.discriminatedUnion("type", [
|
|
2528
|
+
z14.object({
|
|
2529
|
+
type: z14.literal("skillReference"),
|
|
2530
|
+
providerReference: z14.record(z14.string(), z14.string()),
|
|
2531
|
+
version: z14.string().optional()
|
|
2502
2532
|
}),
|
|
2503
|
-
|
|
2504
|
-
type:
|
|
2505
|
-
name:
|
|
2506
|
-
description:
|
|
2507
|
-
source:
|
|
2508
|
-
type:
|
|
2509
|
-
mediaType:
|
|
2510
|
-
data:
|
|
2533
|
+
z14.object({
|
|
2534
|
+
type: z14.literal("inline"),
|
|
2535
|
+
name: z14.string(),
|
|
2536
|
+
description: z14.string(),
|
|
2537
|
+
source: z14.object({
|
|
2538
|
+
type: z14.literal("base64"),
|
|
2539
|
+
mediaType: z14.literal("application/zip"),
|
|
2540
|
+
data: z14.string()
|
|
2511
2541
|
})
|
|
2512
2542
|
})
|
|
2513
2543
|
])
|
|
2514
2544
|
).optional();
|
|
2515
|
-
var shellArgsSchema = (
|
|
2516
|
-
() => (
|
|
2517
|
-
|
|
2518
|
-
environment:
|
|
2519
|
-
|
|
2520
|
-
type:
|
|
2521
|
-
fileIds:
|
|
2522
|
-
memoryLimit:
|
|
2523
|
-
networkPolicy:
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
type:
|
|
2527
|
-
allowedDomains:
|
|
2528
|
-
domainSecrets:
|
|
2529
|
-
|
|
2530
|
-
domain:
|
|
2531
|
-
name:
|
|
2532
|
-
value:
|
|
2545
|
+
var shellArgsSchema = lazySchema13(
|
|
2546
|
+
() => zodSchema13(
|
|
2547
|
+
z14.object({
|
|
2548
|
+
environment: z14.union([
|
|
2549
|
+
z14.object({
|
|
2550
|
+
type: z14.literal("containerAuto"),
|
|
2551
|
+
fileIds: z14.array(z14.string()).optional(),
|
|
2552
|
+
memoryLimit: z14.enum(["1g", "4g", "16g", "64g"]).optional(),
|
|
2553
|
+
networkPolicy: z14.discriminatedUnion("type", [
|
|
2554
|
+
z14.object({ type: z14.literal("disabled") }),
|
|
2555
|
+
z14.object({
|
|
2556
|
+
type: z14.literal("allowlist"),
|
|
2557
|
+
allowedDomains: z14.array(z14.string()),
|
|
2558
|
+
domainSecrets: z14.array(
|
|
2559
|
+
z14.object({
|
|
2560
|
+
domain: z14.string(),
|
|
2561
|
+
name: z14.string(),
|
|
2562
|
+
value: z14.string()
|
|
2533
2563
|
})
|
|
2534
2564
|
).optional()
|
|
2535
2565
|
})
|
|
2536
2566
|
]).optional(),
|
|
2537
2567
|
skills: shellSkillsSchema
|
|
2538
2568
|
}),
|
|
2539
|
-
|
|
2540
|
-
type:
|
|
2541
|
-
containerId:
|
|
2569
|
+
z14.object({
|
|
2570
|
+
type: z14.literal("containerReference"),
|
|
2571
|
+
containerId: z14.string()
|
|
2542
2572
|
}),
|
|
2543
|
-
|
|
2544
|
-
type:
|
|
2545
|
-
skills:
|
|
2546
|
-
|
|
2547
|
-
name:
|
|
2548
|
-
description:
|
|
2549
|
-
path:
|
|
2573
|
+
z14.object({
|
|
2574
|
+
type: z14.literal("local").optional(),
|
|
2575
|
+
skills: z14.array(
|
|
2576
|
+
z14.object({
|
|
2577
|
+
name: z14.string(),
|
|
2578
|
+
description: z14.string(),
|
|
2579
|
+
path: z14.string()
|
|
2550
2580
|
})
|
|
2551
2581
|
).optional()
|
|
2552
2582
|
})
|
|
@@ -2554,40 +2584,44 @@ var shellArgsSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2554
2584
|
})
|
|
2555
2585
|
)
|
|
2556
2586
|
);
|
|
2557
|
-
var shell = (
|
|
2587
|
+
var shell = createProviderToolFactoryWithOutputSchema3({
|
|
2558
2588
|
id: "openai.shell",
|
|
2559
2589
|
inputSchema: shellInputSchema,
|
|
2560
2590
|
outputSchema: shellOutputSchema
|
|
2561
2591
|
});
|
|
2562
2592
|
|
|
2563
2593
|
// src/tool/tool-search.ts
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2594
|
+
import {
|
|
2595
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
2596
|
+
lazySchema as lazySchema14,
|
|
2597
|
+
zodSchema as zodSchema14
|
|
2598
|
+
} from "@ai-sdk/provider-utils";
|
|
2599
|
+
import { z as z15 } from "zod/v4";
|
|
2600
|
+
var toolSearchArgsSchema = lazySchema14(
|
|
2601
|
+
() => zodSchema14(
|
|
2602
|
+
z15.object({
|
|
2603
|
+
execution: z15.enum(["server", "client"]).optional(),
|
|
2604
|
+
description: z15.string().optional(),
|
|
2605
|
+
parameters: z15.record(z15.string(), z15.unknown()).optional()
|
|
2572
2606
|
})
|
|
2573
2607
|
)
|
|
2574
2608
|
);
|
|
2575
|
-
var toolSearchInputSchema = (
|
|
2576
|
-
() => (
|
|
2577
|
-
|
|
2578
|
-
arguments:
|
|
2579
|
-
call_id:
|
|
2609
|
+
var toolSearchInputSchema = lazySchema14(
|
|
2610
|
+
() => zodSchema14(
|
|
2611
|
+
z15.object({
|
|
2612
|
+
arguments: z15.unknown().optional(),
|
|
2613
|
+
call_id: z15.string().nullish()
|
|
2580
2614
|
})
|
|
2581
2615
|
)
|
|
2582
2616
|
);
|
|
2583
|
-
var toolSearchOutputSchema = (
|
|
2584
|
-
() => (
|
|
2585
|
-
|
|
2586
|
-
tools:
|
|
2617
|
+
var toolSearchOutputSchema = lazySchema14(
|
|
2618
|
+
() => zodSchema14(
|
|
2619
|
+
z15.object({
|
|
2620
|
+
tools: z15.array(z15.record(z15.string(), z15.unknown()))
|
|
2587
2621
|
})
|
|
2588
2622
|
)
|
|
2589
2623
|
);
|
|
2590
|
-
var toolSearchToolFactory = (
|
|
2624
|
+
var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
|
|
2591
2625
|
id: "openai.tool_search",
|
|
2592
2626
|
inputSchema: toolSearchInputSchema,
|
|
2593
2627
|
outputSchema: toolSearchOutputSchema
|
|
@@ -2653,8 +2687,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2653
2687
|
return { type: "input_text", text: part.text };
|
|
2654
2688
|
}
|
|
2655
2689
|
case "file": {
|
|
2656
|
-
if ((
|
|
2657
|
-
const fileId = (
|
|
2690
|
+
if (isProviderReference2(part.data)) {
|
|
2691
|
+
const fileId = resolveProviderReference2({
|
|
2658
2692
|
reference: part.data,
|
|
2659
2693
|
provider: providerOptionsName
|
|
2660
2694
|
});
|
|
@@ -2675,7 +2709,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2675
2709
|
return {
|
|
2676
2710
|
type: "input_image",
|
|
2677
2711
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2678
|
-
image_url: `data:${mediaType};base64,${(
|
|
2712
|
+
image_url: `data:${mediaType};base64,${convertToBase642(part.data)}`
|
|
2679
2713
|
},
|
|
2680
2714
|
detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
2681
2715
|
};
|
|
@@ -2690,11 +2724,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2690
2724
|
type: "input_file",
|
|
2691
2725
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2692
2726
|
filename: (_e2 = part.filename) != null ? _e2 : `part-${index}.pdf`,
|
|
2693
|
-
file_data: `data:application/pdf;base64,${(
|
|
2727
|
+
file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
|
|
2694
2728
|
}
|
|
2695
2729
|
};
|
|
2696
2730
|
} else {
|
|
2697
|
-
throw new
|
|
2731
|
+
throw new UnsupportedFunctionalityError4({
|
|
2698
2732
|
functionality: `file part media type ${part.mediaType}`
|
|
2699
2733
|
});
|
|
2700
2734
|
}
|
|
@@ -2740,10 +2774,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2740
2774
|
input.push({ type: "item_reference", id });
|
|
2741
2775
|
break;
|
|
2742
2776
|
}
|
|
2743
|
-
const parsedInput = typeof part.input === "string" ? await
|
|
2777
|
+
const parsedInput = typeof part.input === "string" ? await parseJSON({
|
|
2744
2778
|
text: part.input,
|
|
2745
2779
|
schema: toolSearchInputSchema
|
|
2746
|
-
}) : await
|
|
2780
|
+
}) : await validateTypes({
|
|
2747
2781
|
value: part.input,
|
|
2748
2782
|
schema: toolSearchInputSchema
|
|
2749
2783
|
});
|
|
@@ -2769,7 +2803,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2769
2803
|
break;
|
|
2770
2804
|
}
|
|
2771
2805
|
if (hasLocalShellTool && resolvedToolName === "local_shell") {
|
|
2772
|
-
const parsedInput = await
|
|
2806
|
+
const parsedInput = await validateTypes({
|
|
2773
2807
|
value: part.input,
|
|
2774
2808
|
schema: localShellInputSchema
|
|
2775
2809
|
});
|
|
@@ -2789,7 +2823,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2789
2823
|
break;
|
|
2790
2824
|
}
|
|
2791
2825
|
if (hasShellTool && resolvedToolName === "shell") {
|
|
2792
|
-
const parsedInput = await
|
|
2826
|
+
const parsedInput = await validateTypes({
|
|
2793
2827
|
value: part.input,
|
|
2794
2828
|
schema: shellInputSchema
|
|
2795
2829
|
});
|
|
@@ -2807,7 +2841,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2807
2841
|
break;
|
|
2808
2842
|
}
|
|
2809
2843
|
if (hasApplyPatchTool && resolvedToolName === "apply_patch") {
|
|
2810
|
-
const parsedInput = await
|
|
2844
|
+
const parsedInput = await validateTypes({
|
|
2811
2845
|
value: part.input,
|
|
2812
2846
|
schema: applyPatchInputSchema
|
|
2813
2847
|
});
|
|
@@ -2855,7 +2889,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2855
2889
|
if (store) {
|
|
2856
2890
|
input.push({ type: "item_reference", id: itemId });
|
|
2857
2891
|
} else if (part.output.type === "json") {
|
|
2858
|
-
const parsedOutput = await
|
|
2892
|
+
const parsedOutput = await validateTypes({
|
|
2859
2893
|
value: part.output.value,
|
|
2860
2894
|
schema: toolSearchOutputSchema
|
|
2861
2895
|
});
|
|
@@ -2872,7 +2906,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2872
2906
|
}
|
|
2873
2907
|
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
2874
2908
|
if (part.output.type === "json") {
|
|
2875
|
-
const parsedOutput = await
|
|
2909
|
+
const parsedOutput = await validateTypes({
|
|
2876
2910
|
value: part.output.value,
|
|
2877
2911
|
schema: shellOutputSchema
|
|
2878
2912
|
});
|
|
@@ -2903,7 +2937,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2903
2937
|
break;
|
|
2904
2938
|
}
|
|
2905
2939
|
case "reasoning": {
|
|
2906
|
-
const providerOptions = await (
|
|
2940
|
+
const providerOptions = await parseProviderOptions6({
|
|
2907
2941
|
provider: providerOptionsName,
|
|
2908
2942
|
providerOptions: part.providerOptions,
|
|
2909
2943
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
@@ -3033,7 +3067,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3033
3067
|
part.toolName
|
|
3034
3068
|
);
|
|
3035
3069
|
if (resolvedToolName === "tool_search" && output.type === "json") {
|
|
3036
|
-
const parsedOutput = await
|
|
3070
|
+
const parsedOutput = await validateTypes({
|
|
3037
3071
|
value: output.value,
|
|
3038
3072
|
schema: toolSearchOutputSchema
|
|
3039
3073
|
});
|
|
@@ -3047,7 +3081,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3047
3081
|
continue;
|
|
3048
3082
|
}
|
|
3049
3083
|
if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
|
|
3050
|
-
const parsedOutput = await
|
|
3084
|
+
const parsedOutput = await validateTypes({
|
|
3051
3085
|
value: output.value,
|
|
3052
3086
|
schema: localShellOutputSchema
|
|
3053
3087
|
});
|
|
@@ -3059,7 +3093,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3059
3093
|
continue;
|
|
3060
3094
|
}
|
|
3061
3095
|
if (hasShellTool && resolvedToolName === "shell" && output.type === "json") {
|
|
3062
|
-
const parsedOutput = await
|
|
3096
|
+
const parsedOutput = await validateTypes({
|
|
3063
3097
|
value: output.value,
|
|
3064
3098
|
schema: shellOutputSchema
|
|
3065
3099
|
});
|
|
@@ -3078,7 +3112,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3078
3112
|
continue;
|
|
3079
3113
|
}
|
|
3080
3114
|
if (hasApplyPatchTool && part.toolName === "apply_patch" && output.type === "json") {
|
|
3081
|
-
const parsedOutput = await
|
|
3115
|
+
const parsedOutput = await validateTypes({
|
|
3082
3116
|
value: output.value,
|
|
3083
3117
|
schema: applyPatchOutputSchema
|
|
3084
3118
|
});
|
|
@@ -3138,7 +3172,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3138
3172
|
});
|
|
3139
3173
|
return void 0;
|
|
3140
3174
|
}
|
|
3141
|
-
}).filter(
|
|
3175
|
+
}).filter(isNonNullable);
|
|
3142
3176
|
break;
|
|
3143
3177
|
default:
|
|
3144
3178
|
outputValue = "";
|
|
@@ -3203,7 +3237,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3203
3237
|
return void 0;
|
|
3204
3238
|
}
|
|
3205
3239
|
}
|
|
3206
|
-
}).filter(
|
|
3240
|
+
}).filter(isNonNullable);
|
|
3207
3241
|
break;
|
|
3208
3242
|
}
|
|
3209
3243
|
input.push({
|
|
@@ -3233,9 +3267,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3233
3267
|
}
|
|
3234
3268
|
return { input, warnings };
|
|
3235
3269
|
}
|
|
3236
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
3237
|
-
itemId:
|
|
3238
|
-
reasoningEncryptedContent:
|
|
3270
|
+
var openaiResponsesReasoningProviderOptionsSchema = z16.object({
|
|
3271
|
+
itemId: z16.string().nullish(),
|
|
3272
|
+
reasoningEncryptedContent: z16.string().nullish()
|
|
3239
3273
|
});
|
|
3240
3274
|
|
|
3241
3275
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -3257,552 +3291,552 @@ function mapOpenAIResponseFinishReason({
|
|
|
3257
3291
|
}
|
|
3258
3292
|
|
|
3259
3293
|
// src/responses/openai-responses-api.ts
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
var jsonValueSchema =
|
|
3263
|
-
() =>
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3294
|
+
import { lazySchema as lazySchema15, zodSchema as zodSchema15 } from "@ai-sdk/provider-utils";
|
|
3295
|
+
import { z as z17 } from "zod/v4";
|
|
3296
|
+
var jsonValueSchema = z17.lazy(
|
|
3297
|
+
() => z17.union([
|
|
3298
|
+
z17.string(),
|
|
3299
|
+
z17.number(),
|
|
3300
|
+
z17.boolean(),
|
|
3301
|
+
z17.null(),
|
|
3302
|
+
z17.array(jsonValueSchema),
|
|
3303
|
+
z17.record(z17.string(), jsonValueSchema.optional())
|
|
3270
3304
|
])
|
|
3271
3305
|
);
|
|
3272
|
-
var openaiResponsesChunkSchema = (
|
|
3273
|
-
() => (
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
type:
|
|
3277
|
-
item_id:
|
|
3278
|
-
delta:
|
|
3279
|
-
logprobs:
|
|
3280
|
-
|
|
3281
|
-
token:
|
|
3282
|
-
logprob:
|
|
3283
|
-
top_logprobs:
|
|
3284
|
-
|
|
3285
|
-
token:
|
|
3286
|
-
logprob:
|
|
3306
|
+
var openaiResponsesChunkSchema = lazySchema15(
|
|
3307
|
+
() => zodSchema15(
|
|
3308
|
+
z17.union([
|
|
3309
|
+
z17.object({
|
|
3310
|
+
type: z17.literal("response.output_text.delta"),
|
|
3311
|
+
item_id: z17.string(),
|
|
3312
|
+
delta: z17.string(),
|
|
3313
|
+
logprobs: z17.array(
|
|
3314
|
+
z17.object({
|
|
3315
|
+
token: z17.string(),
|
|
3316
|
+
logprob: z17.number(),
|
|
3317
|
+
top_logprobs: z17.array(
|
|
3318
|
+
z17.object({
|
|
3319
|
+
token: z17.string(),
|
|
3320
|
+
logprob: z17.number()
|
|
3287
3321
|
})
|
|
3288
3322
|
)
|
|
3289
3323
|
})
|
|
3290
3324
|
).nullish()
|
|
3291
3325
|
}),
|
|
3292
|
-
|
|
3293
|
-
type:
|
|
3294
|
-
response:
|
|
3295
|
-
incomplete_details:
|
|
3296
|
-
usage:
|
|
3297
|
-
input_tokens:
|
|
3298
|
-
input_tokens_details:
|
|
3299
|
-
output_tokens:
|
|
3300
|
-
output_tokens_details:
|
|
3326
|
+
z17.object({
|
|
3327
|
+
type: z17.enum(["response.completed", "response.incomplete"]),
|
|
3328
|
+
response: z17.object({
|
|
3329
|
+
incomplete_details: z17.object({ reason: z17.string() }).nullish(),
|
|
3330
|
+
usage: z17.object({
|
|
3331
|
+
input_tokens: z17.number(),
|
|
3332
|
+
input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
|
|
3333
|
+
output_tokens: z17.number(),
|
|
3334
|
+
output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
|
|
3301
3335
|
}),
|
|
3302
|
-
service_tier:
|
|
3336
|
+
service_tier: z17.string().nullish()
|
|
3303
3337
|
})
|
|
3304
3338
|
}),
|
|
3305
|
-
|
|
3306
|
-
type:
|
|
3307
|
-
response:
|
|
3308
|
-
error:
|
|
3309
|
-
code:
|
|
3310
|
-
message:
|
|
3339
|
+
z17.object({
|
|
3340
|
+
type: z17.literal("response.failed"),
|
|
3341
|
+
response: z17.object({
|
|
3342
|
+
error: z17.object({
|
|
3343
|
+
code: z17.string().nullish(),
|
|
3344
|
+
message: z17.string()
|
|
3311
3345
|
}).nullish(),
|
|
3312
|
-
incomplete_details:
|
|
3313
|
-
usage:
|
|
3314
|
-
input_tokens:
|
|
3315
|
-
input_tokens_details:
|
|
3316
|
-
output_tokens:
|
|
3317
|
-
output_tokens_details:
|
|
3346
|
+
incomplete_details: z17.object({ reason: z17.string() }).nullish(),
|
|
3347
|
+
usage: z17.object({
|
|
3348
|
+
input_tokens: z17.number(),
|
|
3349
|
+
input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
|
|
3350
|
+
output_tokens: z17.number(),
|
|
3351
|
+
output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
|
|
3318
3352
|
}).nullish(),
|
|
3319
|
-
service_tier:
|
|
3353
|
+
service_tier: z17.string().nullish()
|
|
3320
3354
|
})
|
|
3321
3355
|
}),
|
|
3322
|
-
|
|
3323
|
-
type:
|
|
3324
|
-
response:
|
|
3325
|
-
id:
|
|
3326
|
-
created_at:
|
|
3327
|
-
model:
|
|
3328
|
-
service_tier:
|
|
3356
|
+
z17.object({
|
|
3357
|
+
type: z17.literal("response.created"),
|
|
3358
|
+
response: z17.object({
|
|
3359
|
+
id: z17.string(),
|
|
3360
|
+
created_at: z17.number(),
|
|
3361
|
+
model: z17.string(),
|
|
3362
|
+
service_tier: z17.string().nullish()
|
|
3329
3363
|
})
|
|
3330
3364
|
}),
|
|
3331
|
-
|
|
3332
|
-
type:
|
|
3333
|
-
output_index:
|
|
3334
|
-
item:
|
|
3335
|
-
|
|
3336
|
-
type:
|
|
3337
|
-
id:
|
|
3338
|
-
phase:
|
|
3365
|
+
z17.object({
|
|
3366
|
+
type: z17.literal("response.output_item.added"),
|
|
3367
|
+
output_index: z17.number(),
|
|
3368
|
+
item: z17.discriminatedUnion("type", [
|
|
3369
|
+
z17.object({
|
|
3370
|
+
type: z17.literal("message"),
|
|
3371
|
+
id: z17.string(),
|
|
3372
|
+
phase: z17.enum(["commentary", "final_answer"]).nullish()
|
|
3339
3373
|
}),
|
|
3340
|
-
|
|
3341
|
-
type:
|
|
3342
|
-
id:
|
|
3343
|
-
encrypted_content:
|
|
3374
|
+
z17.object({
|
|
3375
|
+
type: z17.literal("reasoning"),
|
|
3376
|
+
id: z17.string(),
|
|
3377
|
+
encrypted_content: z17.string().nullish()
|
|
3344
3378
|
}),
|
|
3345
|
-
|
|
3346
|
-
type:
|
|
3347
|
-
id:
|
|
3348
|
-
call_id:
|
|
3349
|
-
name:
|
|
3350
|
-
arguments:
|
|
3379
|
+
z17.object({
|
|
3380
|
+
type: z17.literal("function_call"),
|
|
3381
|
+
id: z17.string(),
|
|
3382
|
+
call_id: z17.string(),
|
|
3383
|
+
name: z17.string(),
|
|
3384
|
+
arguments: z17.string()
|
|
3351
3385
|
}),
|
|
3352
|
-
|
|
3353
|
-
type:
|
|
3354
|
-
id:
|
|
3355
|
-
status:
|
|
3386
|
+
z17.object({
|
|
3387
|
+
type: z17.literal("web_search_call"),
|
|
3388
|
+
id: z17.string(),
|
|
3389
|
+
status: z17.string()
|
|
3356
3390
|
}),
|
|
3357
|
-
|
|
3358
|
-
type:
|
|
3359
|
-
id:
|
|
3360
|
-
status:
|
|
3391
|
+
z17.object({
|
|
3392
|
+
type: z17.literal("computer_call"),
|
|
3393
|
+
id: z17.string(),
|
|
3394
|
+
status: z17.string()
|
|
3361
3395
|
}),
|
|
3362
|
-
|
|
3363
|
-
type:
|
|
3364
|
-
id:
|
|
3396
|
+
z17.object({
|
|
3397
|
+
type: z17.literal("file_search_call"),
|
|
3398
|
+
id: z17.string()
|
|
3365
3399
|
}),
|
|
3366
|
-
|
|
3367
|
-
type:
|
|
3368
|
-
id:
|
|
3400
|
+
z17.object({
|
|
3401
|
+
type: z17.literal("image_generation_call"),
|
|
3402
|
+
id: z17.string()
|
|
3369
3403
|
}),
|
|
3370
|
-
|
|
3371
|
-
type:
|
|
3372
|
-
id:
|
|
3373
|
-
container_id:
|
|
3374
|
-
code:
|
|
3375
|
-
outputs:
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3404
|
+
z17.object({
|
|
3405
|
+
type: z17.literal("code_interpreter_call"),
|
|
3406
|
+
id: z17.string(),
|
|
3407
|
+
container_id: z17.string(),
|
|
3408
|
+
code: z17.string().nullable(),
|
|
3409
|
+
outputs: z17.array(
|
|
3410
|
+
z17.discriminatedUnion("type", [
|
|
3411
|
+
z17.object({ type: z17.literal("logs"), logs: z17.string() }),
|
|
3412
|
+
z17.object({ type: z17.literal("image"), url: z17.string() })
|
|
3379
3413
|
])
|
|
3380
3414
|
).nullable(),
|
|
3381
|
-
status:
|
|
3415
|
+
status: z17.string()
|
|
3382
3416
|
}),
|
|
3383
|
-
|
|
3384
|
-
type:
|
|
3385
|
-
id:
|
|
3386
|
-
status:
|
|
3387
|
-
approval_request_id:
|
|
3417
|
+
z17.object({
|
|
3418
|
+
type: z17.literal("mcp_call"),
|
|
3419
|
+
id: z17.string(),
|
|
3420
|
+
status: z17.string(),
|
|
3421
|
+
approval_request_id: z17.string().nullish()
|
|
3388
3422
|
}),
|
|
3389
|
-
|
|
3390
|
-
type:
|
|
3391
|
-
id:
|
|
3423
|
+
z17.object({
|
|
3424
|
+
type: z17.literal("mcp_list_tools"),
|
|
3425
|
+
id: z17.string()
|
|
3392
3426
|
}),
|
|
3393
|
-
|
|
3394
|
-
type:
|
|
3395
|
-
id:
|
|
3427
|
+
z17.object({
|
|
3428
|
+
type: z17.literal("mcp_approval_request"),
|
|
3429
|
+
id: z17.string()
|
|
3396
3430
|
}),
|
|
3397
|
-
|
|
3398
|
-
type:
|
|
3399
|
-
id:
|
|
3400
|
-
call_id:
|
|
3401
|
-
status:
|
|
3402
|
-
operation:
|
|
3403
|
-
|
|
3404
|
-
type:
|
|
3405
|
-
path:
|
|
3406
|
-
diff:
|
|
3431
|
+
z17.object({
|
|
3432
|
+
type: z17.literal("apply_patch_call"),
|
|
3433
|
+
id: z17.string(),
|
|
3434
|
+
call_id: z17.string(),
|
|
3435
|
+
status: z17.enum(["in_progress", "completed"]),
|
|
3436
|
+
operation: z17.discriminatedUnion("type", [
|
|
3437
|
+
z17.object({
|
|
3438
|
+
type: z17.literal("create_file"),
|
|
3439
|
+
path: z17.string(),
|
|
3440
|
+
diff: z17.string()
|
|
3407
3441
|
}),
|
|
3408
|
-
|
|
3409
|
-
type:
|
|
3410
|
-
path:
|
|
3442
|
+
z17.object({
|
|
3443
|
+
type: z17.literal("delete_file"),
|
|
3444
|
+
path: z17.string()
|
|
3411
3445
|
}),
|
|
3412
|
-
|
|
3413
|
-
type:
|
|
3414
|
-
path:
|
|
3415
|
-
diff:
|
|
3446
|
+
z17.object({
|
|
3447
|
+
type: z17.literal("update_file"),
|
|
3448
|
+
path: z17.string(),
|
|
3449
|
+
diff: z17.string()
|
|
3416
3450
|
})
|
|
3417
3451
|
])
|
|
3418
3452
|
}),
|
|
3419
|
-
|
|
3420
|
-
type:
|
|
3421
|
-
id:
|
|
3422
|
-
call_id:
|
|
3423
|
-
name:
|
|
3424
|
-
input:
|
|
3453
|
+
z17.object({
|
|
3454
|
+
type: z17.literal("custom_tool_call"),
|
|
3455
|
+
id: z17.string(),
|
|
3456
|
+
call_id: z17.string(),
|
|
3457
|
+
name: z17.string(),
|
|
3458
|
+
input: z17.string()
|
|
3425
3459
|
}),
|
|
3426
|
-
|
|
3427
|
-
type:
|
|
3428
|
-
id:
|
|
3429
|
-
call_id:
|
|
3430
|
-
status:
|
|
3431
|
-
action:
|
|
3432
|
-
commands:
|
|
3460
|
+
z17.object({
|
|
3461
|
+
type: z17.literal("shell_call"),
|
|
3462
|
+
id: z17.string(),
|
|
3463
|
+
call_id: z17.string(),
|
|
3464
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3465
|
+
action: z17.object({
|
|
3466
|
+
commands: z17.array(z17.string())
|
|
3433
3467
|
})
|
|
3434
3468
|
}),
|
|
3435
|
-
|
|
3436
|
-
type:
|
|
3437
|
-
id:
|
|
3438
|
-
encrypted_content:
|
|
3469
|
+
z17.object({
|
|
3470
|
+
type: z17.literal("compaction"),
|
|
3471
|
+
id: z17.string(),
|
|
3472
|
+
encrypted_content: z17.string().nullish()
|
|
3439
3473
|
}),
|
|
3440
|
-
|
|
3441
|
-
type:
|
|
3442
|
-
id:
|
|
3443
|
-
call_id:
|
|
3444
|
-
status:
|
|
3445
|
-
output:
|
|
3446
|
-
|
|
3447
|
-
stdout:
|
|
3448
|
-
stderr:
|
|
3449
|
-
outcome:
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
type:
|
|
3453
|
-
exit_code:
|
|
3474
|
+
z17.object({
|
|
3475
|
+
type: z17.literal("shell_call_output"),
|
|
3476
|
+
id: z17.string(),
|
|
3477
|
+
call_id: z17.string(),
|
|
3478
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3479
|
+
output: z17.array(
|
|
3480
|
+
z17.object({
|
|
3481
|
+
stdout: z17.string(),
|
|
3482
|
+
stderr: z17.string(),
|
|
3483
|
+
outcome: z17.discriminatedUnion("type", [
|
|
3484
|
+
z17.object({ type: z17.literal("timeout") }),
|
|
3485
|
+
z17.object({
|
|
3486
|
+
type: z17.literal("exit"),
|
|
3487
|
+
exit_code: z17.number()
|
|
3454
3488
|
})
|
|
3455
3489
|
])
|
|
3456
3490
|
})
|
|
3457
3491
|
)
|
|
3458
3492
|
}),
|
|
3459
|
-
|
|
3460
|
-
type:
|
|
3461
|
-
id:
|
|
3462
|
-
execution:
|
|
3463
|
-
call_id:
|
|
3464
|
-
status:
|
|
3465
|
-
arguments:
|
|
3493
|
+
z17.object({
|
|
3494
|
+
type: z17.literal("tool_search_call"),
|
|
3495
|
+
id: z17.string(),
|
|
3496
|
+
execution: z17.enum(["server", "client"]),
|
|
3497
|
+
call_id: z17.string().nullable(),
|
|
3498
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3499
|
+
arguments: z17.unknown()
|
|
3466
3500
|
}),
|
|
3467
|
-
|
|
3468
|
-
type:
|
|
3469
|
-
id:
|
|
3470
|
-
execution:
|
|
3471
|
-
call_id:
|
|
3472
|
-
status:
|
|
3473
|
-
tools:
|
|
3501
|
+
z17.object({
|
|
3502
|
+
type: z17.literal("tool_search_output"),
|
|
3503
|
+
id: z17.string(),
|
|
3504
|
+
execution: z17.enum(["server", "client"]),
|
|
3505
|
+
call_id: z17.string().nullable(),
|
|
3506
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3507
|
+
tools: z17.array(z17.record(z17.string(), jsonValueSchema.optional()))
|
|
3474
3508
|
})
|
|
3475
3509
|
])
|
|
3476
3510
|
}),
|
|
3477
|
-
|
|
3478
|
-
type:
|
|
3479
|
-
output_index:
|
|
3480
|
-
item:
|
|
3481
|
-
|
|
3482
|
-
type:
|
|
3483
|
-
id:
|
|
3484
|
-
phase:
|
|
3511
|
+
z17.object({
|
|
3512
|
+
type: z17.literal("response.output_item.done"),
|
|
3513
|
+
output_index: z17.number(),
|
|
3514
|
+
item: z17.discriminatedUnion("type", [
|
|
3515
|
+
z17.object({
|
|
3516
|
+
type: z17.literal("message"),
|
|
3517
|
+
id: z17.string(),
|
|
3518
|
+
phase: z17.enum(["commentary", "final_answer"]).nullish()
|
|
3485
3519
|
}),
|
|
3486
|
-
|
|
3487
|
-
type:
|
|
3488
|
-
id:
|
|
3489
|
-
encrypted_content:
|
|
3520
|
+
z17.object({
|
|
3521
|
+
type: z17.literal("reasoning"),
|
|
3522
|
+
id: z17.string(),
|
|
3523
|
+
encrypted_content: z17.string().nullish()
|
|
3490
3524
|
}),
|
|
3491
|
-
|
|
3492
|
-
type:
|
|
3493
|
-
id:
|
|
3494
|
-
call_id:
|
|
3495
|
-
name:
|
|
3496
|
-
arguments:
|
|
3497
|
-
status:
|
|
3525
|
+
z17.object({
|
|
3526
|
+
type: z17.literal("function_call"),
|
|
3527
|
+
id: z17.string(),
|
|
3528
|
+
call_id: z17.string(),
|
|
3529
|
+
name: z17.string(),
|
|
3530
|
+
arguments: z17.string(),
|
|
3531
|
+
status: z17.literal("completed")
|
|
3498
3532
|
}),
|
|
3499
|
-
|
|
3500
|
-
type:
|
|
3501
|
-
id:
|
|
3502
|
-
call_id:
|
|
3503
|
-
name:
|
|
3504
|
-
input:
|
|
3505
|
-
status:
|
|
3533
|
+
z17.object({
|
|
3534
|
+
type: z17.literal("custom_tool_call"),
|
|
3535
|
+
id: z17.string(),
|
|
3536
|
+
call_id: z17.string(),
|
|
3537
|
+
name: z17.string(),
|
|
3538
|
+
input: z17.string(),
|
|
3539
|
+
status: z17.literal("completed")
|
|
3506
3540
|
}),
|
|
3507
|
-
|
|
3508
|
-
type:
|
|
3509
|
-
id:
|
|
3510
|
-
code:
|
|
3511
|
-
container_id:
|
|
3512
|
-
outputs:
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3541
|
+
z17.object({
|
|
3542
|
+
type: z17.literal("code_interpreter_call"),
|
|
3543
|
+
id: z17.string(),
|
|
3544
|
+
code: z17.string().nullable(),
|
|
3545
|
+
container_id: z17.string(),
|
|
3546
|
+
outputs: z17.array(
|
|
3547
|
+
z17.discriminatedUnion("type", [
|
|
3548
|
+
z17.object({ type: z17.literal("logs"), logs: z17.string() }),
|
|
3549
|
+
z17.object({ type: z17.literal("image"), url: z17.string() })
|
|
3516
3550
|
])
|
|
3517
3551
|
).nullable()
|
|
3518
3552
|
}),
|
|
3519
|
-
|
|
3520
|
-
type:
|
|
3521
|
-
id:
|
|
3522
|
-
result:
|
|
3553
|
+
z17.object({
|
|
3554
|
+
type: z17.literal("image_generation_call"),
|
|
3555
|
+
id: z17.string(),
|
|
3556
|
+
result: z17.string()
|
|
3523
3557
|
}),
|
|
3524
|
-
|
|
3525
|
-
type:
|
|
3526
|
-
id:
|
|
3527
|
-
status:
|
|
3528
|
-
action:
|
|
3529
|
-
|
|
3530
|
-
type:
|
|
3531
|
-
query:
|
|
3532
|
-
sources:
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3558
|
+
z17.object({
|
|
3559
|
+
type: z17.literal("web_search_call"),
|
|
3560
|
+
id: z17.string(),
|
|
3561
|
+
status: z17.string(),
|
|
3562
|
+
action: z17.discriminatedUnion("type", [
|
|
3563
|
+
z17.object({
|
|
3564
|
+
type: z17.literal("search"),
|
|
3565
|
+
query: z17.string().nullish(),
|
|
3566
|
+
sources: z17.array(
|
|
3567
|
+
z17.discriminatedUnion("type", [
|
|
3568
|
+
z17.object({ type: z17.literal("url"), url: z17.string() }),
|
|
3569
|
+
z17.object({ type: z17.literal("api"), name: z17.string() })
|
|
3536
3570
|
])
|
|
3537
3571
|
).nullish()
|
|
3538
3572
|
}),
|
|
3539
|
-
|
|
3540
|
-
type:
|
|
3541
|
-
url:
|
|
3573
|
+
z17.object({
|
|
3574
|
+
type: z17.literal("open_page"),
|
|
3575
|
+
url: z17.string().nullish()
|
|
3542
3576
|
}),
|
|
3543
|
-
|
|
3544
|
-
type:
|
|
3545
|
-
url:
|
|
3546
|
-
pattern:
|
|
3577
|
+
z17.object({
|
|
3578
|
+
type: z17.literal("find_in_page"),
|
|
3579
|
+
url: z17.string().nullish(),
|
|
3580
|
+
pattern: z17.string().nullish()
|
|
3547
3581
|
})
|
|
3548
3582
|
]).nullish()
|
|
3549
3583
|
}),
|
|
3550
|
-
|
|
3551
|
-
type:
|
|
3552
|
-
id:
|
|
3553
|
-
queries:
|
|
3554
|
-
results:
|
|
3555
|
-
|
|
3556
|
-
attributes:
|
|
3557
|
-
|
|
3558
|
-
|
|
3584
|
+
z17.object({
|
|
3585
|
+
type: z17.literal("file_search_call"),
|
|
3586
|
+
id: z17.string(),
|
|
3587
|
+
queries: z17.array(z17.string()),
|
|
3588
|
+
results: z17.array(
|
|
3589
|
+
z17.object({
|
|
3590
|
+
attributes: z17.record(
|
|
3591
|
+
z17.string(),
|
|
3592
|
+
z17.union([z17.string(), z17.number(), z17.boolean()])
|
|
3559
3593
|
),
|
|
3560
|
-
file_id:
|
|
3561
|
-
filename:
|
|
3562
|
-
score:
|
|
3563
|
-
text:
|
|
3594
|
+
file_id: z17.string(),
|
|
3595
|
+
filename: z17.string(),
|
|
3596
|
+
score: z17.number(),
|
|
3597
|
+
text: z17.string()
|
|
3564
3598
|
})
|
|
3565
3599
|
).nullish()
|
|
3566
3600
|
}),
|
|
3567
|
-
|
|
3568
|
-
type:
|
|
3569
|
-
id:
|
|
3570
|
-
call_id:
|
|
3571
|
-
action:
|
|
3572
|
-
type:
|
|
3573
|
-
command:
|
|
3574
|
-
timeout_ms:
|
|
3575
|
-
user:
|
|
3576
|
-
working_directory:
|
|
3577
|
-
env:
|
|
3601
|
+
z17.object({
|
|
3602
|
+
type: z17.literal("local_shell_call"),
|
|
3603
|
+
id: z17.string(),
|
|
3604
|
+
call_id: z17.string(),
|
|
3605
|
+
action: z17.object({
|
|
3606
|
+
type: z17.literal("exec"),
|
|
3607
|
+
command: z17.array(z17.string()),
|
|
3608
|
+
timeout_ms: z17.number().optional(),
|
|
3609
|
+
user: z17.string().optional(),
|
|
3610
|
+
working_directory: z17.string().optional(),
|
|
3611
|
+
env: z17.record(z17.string(), z17.string()).optional()
|
|
3578
3612
|
})
|
|
3579
3613
|
}),
|
|
3580
|
-
|
|
3581
|
-
type:
|
|
3582
|
-
id:
|
|
3583
|
-
status:
|
|
3614
|
+
z17.object({
|
|
3615
|
+
type: z17.literal("computer_call"),
|
|
3616
|
+
id: z17.string(),
|
|
3617
|
+
status: z17.literal("completed")
|
|
3584
3618
|
}),
|
|
3585
|
-
|
|
3586
|
-
type:
|
|
3587
|
-
id:
|
|
3588
|
-
status:
|
|
3589
|
-
arguments:
|
|
3590
|
-
name:
|
|
3591
|
-
server_label:
|
|
3592
|
-
output:
|
|
3593
|
-
error:
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
type:
|
|
3597
|
-
code:
|
|
3598
|
-
message:
|
|
3619
|
+
z17.object({
|
|
3620
|
+
type: z17.literal("mcp_call"),
|
|
3621
|
+
id: z17.string(),
|
|
3622
|
+
status: z17.string(),
|
|
3623
|
+
arguments: z17.string(),
|
|
3624
|
+
name: z17.string(),
|
|
3625
|
+
server_label: z17.string(),
|
|
3626
|
+
output: z17.string().nullish(),
|
|
3627
|
+
error: z17.union([
|
|
3628
|
+
z17.string(),
|
|
3629
|
+
z17.object({
|
|
3630
|
+
type: z17.string().optional(),
|
|
3631
|
+
code: z17.union([z17.number(), z17.string()]).optional(),
|
|
3632
|
+
message: z17.string().optional()
|
|
3599
3633
|
}).loose()
|
|
3600
3634
|
]).nullish(),
|
|
3601
|
-
approval_request_id:
|
|
3635
|
+
approval_request_id: z17.string().nullish()
|
|
3602
3636
|
}),
|
|
3603
|
-
|
|
3604
|
-
type:
|
|
3605
|
-
id:
|
|
3606
|
-
server_label:
|
|
3607
|
-
tools:
|
|
3608
|
-
|
|
3609
|
-
name:
|
|
3610
|
-
description:
|
|
3611
|
-
input_schema:
|
|
3612
|
-
annotations:
|
|
3637
|
+
z17.object({
|
|
3638
|
+
type: z17.literal("mcp_list_tools"),
|
|
3639
|
+
id: z17.string(),
|
|
3640
|
+
server_label: z17.string(),
|
|
3641
|
+
tools: z17.array(
|
|
3642
|
+
z17.object({
|
|
3643
|
+
name: z17.string(),
|
|
3644
|
+
description: z17.string().optional(),
|
|
3645
|
+
input_schema: z17.any(),
|
|
3646
|
+
annotations: z17.record(z17.string(), z17.unknown()).optional()
|
|
3613
3647
|
})
|
|
3614
3648
|
),
|
|
3615
|
-
error:
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
type:
|
|
3619
|
-
code:
|
|
3620
|
-
message:
|
|
3649
|
+
error: z17.union([
|
|
3650
|
+
z17.string(),
|
|
3651
|
+
z17.object({
|
|
3652
|
+
type: z17.string().optional(),
|
|
3653
|
+
code: z17.union([z17.number(), z17.string()]).optional(),
|
|
3654
|
+
message: z17.string().optional()
|
|
3621
3655
|
}).loose()
|
|
3622
3656
|
]).optional()
|
|
3623
3657
|
}),
|
|
3624
|
-
|
|
3625
|
-
type:
|
|
3626
|
-
id:
|
|
3627
|
-
server_label:
|
|
3628
|
-
name:
|
|
3629
|
-
arguments:
|
|
3630
|
-
approval_request_id:
|
|
3658
|
+
z17.object({
|
|
3659
|
+
type: z17.literal("mcp_approval_request"),
|
|
3660
|
+
id: z17.string(),
|
|
3661
|
+
server_label: z17.string(),
|
|
3662
|
+
name: z17.string(),
|
|
3663
|
+
arguments: z17.string(),
|
|
3664
|
+
approval_request_id: z17.string().optional()
|
|
3631
3665
|
}),
|
|
3632
|
-
|
|
3633
|
-
type:
|
|
3634
|
-
id:
|
|
3635
|
-
call_id:
|
|
3636
|
-
status:
|
|
3637
|
-
operation:
|
|
3638
|
-
|
|
3639
|
-
type:
|
|
3640
|
-
path:
|
|
3641
|
-
diff:
|
|
3666
|
+
z17.object({
|
|
3667
|
+
type: z17.literal("apply_patch_call"),
|
|
3668
|
+
id: z17.string(),
|
|
3669
|
+
call_id: z17.string(),
|
|
3670
|
+
status: z17.enum(["in_progress", "completed"]),
|
|
3671
|
+
operation: z17.discriminatedUnion("type", [
|
|
3672
|
+
z17.object({
|
|
3673
|
+
type: z17.literal("create_file"),
|
|
3674
|
+
path: z17.string(),
|
|
3675
|
+
diff: z17.string()
|
|
3642
3676
|
}),
|
|
3643
|
-
|
|
3644
|
-
type:
|
|
3645
|
-
path:
|
|
3677
|
+
z17.object({
|
|
3678
|
+
type: z17.literal("delete_file"),
|
|
3679
|
+
path: z17.string()
|
|
3646
3680
|
}),
|
|
3647
|
-
|
|
3648
|
-
type:
|
|
3649
|
-
path:
|
|
3650
|
-
diff:
|
|
3681
|
+
z17.object({
|
|
3682
|
+
type: z17.literal("update_file"),
|
|
3683
|
+
path: z17.string(),
|
|
3684
|
+
diff: z17.string()
|
|
3651
3685
|
})
|
|
3652
3686
|
])
|
|
3653
3687
|
}),
|
|
3654
|
-
|
|
3655
|
-
type:
|
|
3656
|
-
id:
|
|
3657
|
-
call_id:
|
|
3658
|
-
status:
|
|
3659
|
-
action:
|
|
3660
|
-
commands:
|
|
3688
|
+
z17.object({
|
|
3689
|
+
type: z17.literal("shell_call"),
|
|
3690
|
+
id: z17.string(),
|
|
3691
|
+
call_id: z17.string(),
|
|
3692
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3693
|
+
action: z17.object({
|
|
3694
|
+
commands: z17.array(z17.string())
|
|
3661
3695
|
})
|
|
3662
3696
|
}),
|
|
3663
|
-
|
|
3664
|
-
type:
|
|
3665
|
-
id:
|
|
3666
|
-
encrypted_content:
|
|
3697
|
+
z17.object({
|
|
3698
|
+
type: z17.literal("compaction"),
|
|
3699
|
+
id: z17.string(),
|
|
3700
|
+
encrypted_content: z17.string()
|
|
3667
3701
|
}),
|
|
3668
|
-
|
|
3669
|
-
type:
|
|
3670
|
-
id:
|
|
3671
|
-
call_id:
|
|
3672
|
-
status:
|
|
3673
|
-
output:
|
|
3674
|
-
|
|
3675
|
-
stdout:
|
|
3676
|
-
stderr:
|
|
3677
|
-
outcome:
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
type:
|
|
3681
|
-
exit_code:
|
|
3702
|
+
z17.object({
|
|
3703
|
+
type: z17.literal("shell_call_output"),
|
|
3704
|
+
id: z17.string(),
|
|
3705
|
+
call_id: z17.string(),
|
|
3706
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3707
|
+
output: z17.array(
|
|
3708
|
+
z17.object({
|
|
3709
|
+
stdout: z17.string(),
|
|
3710
|
+
stderr: z17.string(),
|
|
3711
|
+
outcome: z17.discriminatedUnion("type", [
|
|
3712
|
+
z17.object({ type: z17.literal("timeout") }),
|
|
3713
|
+
z17.object({
|
|
3714
|
+
type: z17.literal("exit"),
|
|
3715
|
+
exit_code: z17.number()
|
|
3682
3716
|
})
|
|
3683
3717
|
])
|
|
3684
3718
|
})
|
|
3685
3719
|
)
|
|
3686
3720
|
}),
|
|
3687
|
-
|
|
3688
|
-
type:
|
|
3689
|
-
id:
|
|
3690
|
-
execution:
|
|
3691
|
-
call_id:
|
|
3692
|
-
status:
|
|
3693
|
-
arguments:
|
|
3721
|
+
z17.object({
|
|
3722
|
+
type: z17.literal("tool_search_call"),
|
|
3723
|
+
id: z17.string(),
|
|
3724
|
+
execution: z17.enum(["server", "client"]),
|
|
3725
|
+
call_id: z17.string().nullable(),
|
|
3726
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3727
|
+
arguments: z17.unknown()
|
|
3694
3728
|
}),
|
|
3695
|
-
|
|
3696
|
-
type:
|
|
3697
|
-
id:
|
|
3698
|
-
execution:
|
|
3699
|
-
call_id:
|
|
3700
|
-
status:
|
|
3701
|
-
tools:
|
|
3729
|
+
z17.object({
|
|
3730
|
+
type: z17.literal("tool_search_output"),
|
|
3731
|
+
id: z17.string(),
|
|
3732
|
+
execution: z17.enum(["server", "client"]),
|
|
3733
|
+
call_id: z17.string().nullable(),
|
|
3734
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
3735
|
+
tools: z17.array(z17.record(z17.string(), jsonValueSchema.optional()))
|
|
3702
3736
|
})
|
|
3703
3737
|
])
|
|
3704
3738
|
}),
|
|
3705
|
-
|
|
3706
|
-
type:
|
|
3707
|
-
item_id:
|
|
3708
|
-
output_index:
|
|
3709
|
-
delta:
|
|
3739
|
+
z17.object({
|
|
3740
|
+
type: z17.literal("response.function_call_arguments.delta"),
|
|
3741
|
+
item_id: z17.string(),
|
|
3742
|
+
output_index: z17.number(),
|
|
3743
|
+
delta: z17.string()
|
|
3710
3744
|
}),
|
|
3711
|
-
|
|
3712
|
-
type:
|
|
3713
|
-
item_id:
|
|
3714
|
-
output_index:
|
|
3715
|
-
delta:
|
|
3745
|
+
z17.object({
|
|
3746
|
+
type: z17.literal("response.custom_tool_call_input.delta"),
|
|
3747
|
+
item_id: z17.string(),
|
|
3748
|
+
output_index: z17.number(),
|
|
3749
|
+
delta: z17.string()
|
|
3716
3750
|
}),
|
|
3717
|
-
|
|
3718
|
-
type:
|
|
3719
|
-
item_id:
|
|
3720
|
-
output_index:
|
|
3721
|
-
partial_image_b64:
|
|
3751
|
+
z17.object({
|
|
3752
|
+
type: z17.literal("response.image_generation_call.partial_image"),
|
|
3753
|
+
item_id: z17.string(),
|
|
3754
|
+
output_index: z17.number(),
|
|
3755
|
+
partial_image_b64: z17.string()
|
|
3722
3756
|
}),
|
|
3723
|
-
|
|
3724
|
-
type:
|
|
3725
|
-
item_id:
|
|
3726
|
-
output_index:
|
|
3727
|
-
delta:
|
|
3757
|
+
z17.object({
|
|
3758
|
+
type: z17.literal("response.code_interpreter_call_code.delta"),
|
|
3759
|
+
item_id: z17.string(),
|
|
3760
|
+
output_index: z17.number(),
|
|
3761
|
+
delta: z17.string()
|
|
3728
3762
|
}),
|
|
3729
|
-
|
|
3730
|
-
type:
|
|
3731
|
-
item_id:
|
|
3732
|
-
output_index:
|
|
3733
|
-
code:
|
|
3763
|
+
z17.object({
|
|
3764
|
+
type: z17.literal("response.code_interpreter_call_code.done"),
|
|
3765
|
+
item_id: z17.string(),
|
|
3766
|
+
output_index: z17.number(),
|
|
3767
|
+
code: z17.string()
|
|
3734
3768
|
}),
|
|
3735
|
-
|
|
3736
|
-
type:
|
|
3737
|
-
annotation:
|
|
3738
|
-
|
|
3739
|
-
type:
|
|
3740
|
-
start_index:
|
|
3741
|
-
end_index:
|
|
3742
|
-
url:
|
|
3743
|
-
title:
|
|
3769
|
+
z17.object({
|
|
3770
|
+
type: z17.literal("response.output_text.annotation.added"),
|
|
3771
|
+
annotation: z17.discriminatedUnion("type", [
|
|
3772
|
+
z17.object({
|
|
3773
|
+
type: z17.literal("url_citation"),
|
|
3774
|
+
start_index: z17.number(),
|
|
3775
|
+
end_index: z17.number(),
|
|
3776
|
+
url: z17.string(),
|
|
3777
|
+
title: z17.string()
|
|
3744
3778
|
}),
|
|
3745
|
-
|
|
3746
|
-
type:
|
|
3747
|
-
file_id:
|
|
3748
|
-
filename:
|
|
3749
|
-
index:
|
|
3779
|
+
z17.object({
|
|
3780
|
+
type: z17.literal("file_citation"),
|
|
3781
|
+
file_id: z17.string(),
|
|
3782
|
+
filename: z17.string(),
|
|
3783
|
+
index: z17.number()
|
|
3750
3784
|
}),
|
|
3751
|
-
|
|
3752
|
-
type:
|
|
3753
|
-
container_id:
|
|
3754
|
-
file_id:
|
|
3755
|
-
filename:
|
|
3756
|
-
start_index:
|
|
3757
|
-
end_index:
|
|
3785
|
+
z17.object({
|
|
3786
|
+
type: z17.literal("container_file_citation"),
|
|
3787
|
+
container_id: z17.string(),
|
|
3788
|
+
file_id: z17.string(),
|
|
3789
|
+
filename: z17.string(),
|
|
3790
|
+
start_index: z17.number(),
|
|
3791
|
+
end_index: z17.number()
|
|
3758
3792
|
}),
|
|
3759
|
-
|
|
3760
|
-
type:
|
|
3761
|
-
file_id:
|
|
3762
|
-
index:
|
|
3793
|
+
z17.object({
|
|
3794
|
+
type: z17.literal("file_path"),
|
|
3795
|
+
file_id: z17.string(),
|
|
3796
|
+
index: z17.number()
|
|
3763
3797
|
})
|
|
3764
3798
|
])
|
|
3765
3799
|
}),
|
|
3766
|
-
|
|
3767
|
-
type:
|
|
3768
|
-
item_id:
|
|
3769
|
-
summary_index:
|
|
3800
|
+
z17.object({
|
|
3801
|
+
type: z17.literal("response.reasoning_summary_part.added"),
|
|
3802
|
+
item_id: z17.string(),
|
|
3803
|
+
summary_index: z17.number()
|
|
3770
3804
|
}),
|
|
3771
|
-
|
|
3772
|
-
type:
|
|
3773
|
-
item_id:
|
|
3774
|
-
summary_index:
|
|
3775
|
-
delta:
|
|
3805
|
+
z17.object({
|
|
3806
|
+
type: z17.literal("response.reasoning_summary_text.delta"),
|
|
3807
|
+
item_id: z17.string(),
|
|
3808
|
+
summary_index: z17.number(),
|
|
3809
|
+
delta: z17.string()
|
|
3776
3810
|
}),
|
|
3777
|
-
|
|
3778
|
-
type:
|
|
3779
|
-
item_id:
|
|
3780
|
-
summary_index:
|
|
3811
|
+
z17.object({
|
|
3812
|
+
type: z17.literal("response.reasoning_summary_part.done"),
|
|
3813
|
+
item_id: z17.string(),
|
|
3814
|
+
summary_index: z17.number()
|
|
3781
3815
|
}),
|
|
3782
|
-
|
|
3783
|
-
type:
|
|
3784
|
-
item_id:
|
|
3785
|
-
output_index:
|
|
3786
|
-
delta:
|
|
3787
|
-
obfuscation:
|
|
3816
|
+
z17.object({
|
|
3817
|
+
type: z17.literal("response.apply_patch_call_operation_diff.delta"),
|
|
3818
|
+
item_id: z17.string(),
|
|
3819
|
+
output_index: z17.number(),
|
|
3820
|
+
delta: z17.string(),
|
|
3821
|
+
obfuscation: z17.string().nullish()
|
|
3788
3822
|
}),
|
|
3789
|
-
|
|
3790
|
-
type:
|
|
3791
|
-
item_id:
|
|
3792
|
-
output_index:
|
|
3793
|
-
diff:
|
|
3823
|
+
z17.object({
|
|
3824
|
+
type: z17.literal("response.apply_patch_call_operation_diff.done"),
|
|
3825
|
+
item_id: z17.string(),
|
|
3826
|
+
output_index: z17.number(),
|
|
3827
|
+
diff: z17.string()
|
|
3794
3828
|
}),
|
|
3795
|
-
|
|
3796
|
-
type:
|
|
3797
|
-
sequence_number:
|
|
3798
|
-
error:
|
|
3799
|
-
type:
|
|
3800
|
-
code:
|
|
3801
|
-
message:
|
|
3802
|
-
param:
|
|
3829
|
+
z17.object({
|
|
3830
|
+
type: z17.literal("error"),
|
|
3831
|
+
sequence_number: z17.number(),
|
|
3832
|
+
error: z17.object({
|
|
3833
|
+
type: z17.string(),
|
|
3834
|
+
code: z17.string(),
|
|
3835
|
+
message: z17.string(),
|
|
3836
|
+
param: z17.string().nullish()
|
|
3803
3837
|
})
|
|
3804
3838
|
}),
|
|
3805
|
-
|
|
3839
|
+
z17.object({ type: z17.string() }).loose().transform((value) => ({
|
|
3806
3840
|
type: "unknown_chunk",
|
|
3807
3841
|
message: value.type
|
|
3808
3842
|
}))
|
|
@@ -3810,315 +3844,315 @@ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3810
3844
|
])
|
|
3811
3845
|
)
|
|
3812
3846
|
);
|
|
3813
|
-
var openaiResponsesResponseSchema = (
|
|
3814
|
-
() => (
|
|
3815
|
-
|
|
3816
|
-
id:
|
|
3817
|
-
created_at:
|
|
3818
|
-
error:
|
|
3819
|
-
message:
|
|
3820
|
-
type:
|
|
3821
|
-
param:
|
|
3822
|
-
code:
|
|
3847
|
+
var openaiResponsesResponseSchema = lazySchema15(
|
|
3848
|
+
() => zodSchema15(
|
|
3849
|
+
z17.object({
|
|
3850
|
+
id: z17.string().optional(),
|
|
3851
|
+
created_at: z17.number().optional(),
|
|
3852
|
+
error: z17.object({
|
|
3853
|
+
message: z17.string(),
|
|
3854
|
+
type: z17.string(),
|
|
3855
|
+
param: z17.string().nullish(),
|
|
3856
|
+
code: z17.string()
|
|
3823
3857
|
}).nullish(),
|
|
3824
|
-
model:
|
|
3825
|
-
output:
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
type:
|
|
3829
|
-
role:
|
|
3830
|
-
id:
|
|
3831
|
-
phase:
|
|
3832
|
-
content:
|
|
3833
|
-
|
|
3834
|
-
type:
|
|
3835
|
-
text:
|
|
3836
|
-
logprobs:
|
|
3837
|
-
|
|
3838
|
-
token:
|
|
3839
|
-
logprob:
|
|
3840
|
-
top_logprobs:
|
|
3841
|
-
|
|
3842
|
-
token:
|
|
3843
|
-
logprob:
|
|
3858
|
+
model: z17.string().optional(),
|
|
3859
|
+
output: z17.array(
|
|
3860
|
+
z17.discriminatedUnion("type", [
|
|
3861
|
+
z17.object({
|
|
3862
|
+
type: z17.literal("message"),
|
|
3863
|
+
role: z17.literal("assistant"),
|
|
3864
|
+
id: z17.string(),
|
|
3865
|
+
phase: z17.enum(["commentary", "final_answer"]).nullish(),
|
|
3866
|
+
content: z17.array(
|
|
3867
|
+
z17.object({
|
|
3868
|
+
type: z17.literal("output_text"),
|
|
3869
|
+
text: z17.string(),
|
|
3870
|
+
logprobs: z17.array(
|
|
3871
|
+
z17.object({
|
|
3872
|
+
token: z17.string(),
|
|
3873
|
+
logprob: z17.number(),
|
|
3874
|
+
top_logprobs: z17.array(
|
|
3875
|
+
z17.object({
|
|
3876
|
+
token: z17.string(),
|
|
3877
|
+
logprob: z17.number()
|
|
3844
3878
|
})
|
|
3845
3879
|
)
|
|
3846
3880
|
})
|
|
3847
3881
|
).nullish(),
|
|
3848
|
-
annotations:
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
type:
|
|
3852
|
-
start_index:
|
|
3853
|
-
end_index:
|
|
3854
|
-
url:
|
|
3855
|
-
title:
|
|
3882
|
+
annotations: z17.array(
|
|
3883
|
+
z17.discriminatedUnion("type", [
|
|
3884
|
+
z17.object({
|
|
3885
|
+
type: z17.literal("url_citation"),
|
|
3886
|
+
start_index: z17.number(),
|
|
3887
|
+
end_index: z17.number(),
|
|
3888
|
+
url: z17.string(),
|
|
3889
|
+
title: z17.string()
|
|
3856
3890
|
}),
|
|
3857
|
-
|
|
3858
|
-
type:
|
|
3859
|
-
file_id:
|
|
3860
|
-
filename:
|
|
3861
|
-
index:
|
|
3891
|
+
z17.object({
|
|
3892
|
+
type: z17.literal("file_citation"),
|
|
3893
|
+
file_id: z17.string(),
|
|
3894
|
+
filename: z17.string(),
|
|
3895
|
+
index: z17.number()
|
|
3862
3896
|
}),
|
|
3863
|
-
|
|
3864
|
-
type:
|
|
3865
|
-
container_id:
|
|
3866
|
-
file_id:
|
|
3867
|
-
filename:
|
|
3868
|
-
start_index:
|
|
3869
|
-
end_index:
|
|
3897
|
+
z17.object({
|
|
3898
|
+
type: z17.literal("container_file_citation"),
|
|
3899
|
+
container_id: z17.string(),
|
|
3900
|
+
file_id: z17.string(),
|
|
3901
|
+
filename: z17.string(),
|
|
3902
|
+
start_index: z17.number(),
|
|
3903
|
+
end_index: z17.number()
|
|
3870
3904
|
}),
|
|
3871
|
-
|
|
3872
|
-
type:
|
|
3873
|
-
file_id:
|
|
3874
|
-
index:
|
|
3905
|
+
z17.object({
|
|
3906
|
+
type: z17.literal("file_path"),
|
|
3907
|
+
file_id: z17.string(),
|
|
3908
|
+
index: z17.number()
|
|
3875
3909
|
})
|
|
3876
3910
|
])
|
|
3877
3911
|
)
|
|
3878
3912
|
})
|
|
3879
3913
|
)
|
|
3880
3914
|
}),
|
|
3881
|
-
|
|
3882
|
-
type:
|
|
3883
|
-
id:
|
|
3884
|
-
status:
|
|
3885
|
-
action:
|
|
3886
|
-
|
|
3887
|
-
type:
|
|
3888
|
-
query:
|
|
3889
|
-
sources:
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
type:
|
|
3894
|
-
name:
|
|
3915
|
+
z17.object({
|
|
3916
|
+
type: z17.literal("web_search_call"),
|
|
3917
|
+
id: z17.string(),
|
|
3918
|
+
status: z17.string(),
|
|
3919
|
+
action: z17.discriminatedUnion("type", [
|
|
3920
|
+
z17.object({
|
|
3921
|
+
type: z17.literal("search"),
|
|
3922
|
+
query: z17.string().nullish(),
|
|
3923
|
+
sources: z17.array(
|
|
3924
|
+
z17.discriminatedUnion("type", [
|
|
3925
|
+
z17.object({ type: z17.literal("url"), url: z17.string() }),
|
|
3926
|
+
z17.object({
|
|
3927
|
+
type: z17.literal("api"),
|
|
3928
|
+
name: z17.string()
|
|
3895
3929
|
})
|
|
3896
3930
|
])
|
|
3897
3931
|
).nullish()
|
|
3898
3932
|
}),
|
|
3899
|
-
|
|
3900
|
-
type:
|
|
3901
|
-
url:
|
|
3933
|
+
z17.object({
|
|
3934
|
+
type: z17.literal("open_page"),
|
|
3935
|
+
url: z17.string().nullish()
|
|
3902
3936
|
}),
|
|
3903
|
-
|
|
3904
|
-
type:
|
|
3905
|
-
url:
|
|
3906
|
-
pattern:
|
|
3937
|
+
z17.object({
|
|
3938
|
+
type: z17.literal("find_in_page"),
|
|
3939
|
+
url: z17.string().nullish(),
|
|
3940
|
+
pattern: z17.string().nullish()
|
|
3907
3941
|
})
|
|
3908
3942
|
]).nullish()
|
|
3909
3943
|
}),
|
|
3910
|
-
|
|
3911
|
-
type:
|
|
3912
|
-
id:
|
|
3913
|
-
queries:
|
|
3914
|
-
results:
|
|
3915
|
-
|
|
3916
|
-
attributes:
|
|
3917
|
-
|
|
3918
|
-
|
|
3944
|
+
z17.object({
|
|
3945
|
+
type: z17.literal("file_search_call"),
|
|
3946
|
+
id: z17.string(),
|
|
3947
|
+
queries: z17.array(z17.string()),
|
|
3948
|
+
results: z17.array(
|
|
3949
|
+
z17.object({
|
|
3950
|
+
attributes: z17.record(
|
|
3951
|
+
z17.string(),
|
|
3952
|
+
z17.union([z17.string(), z17.number(), z17.boolean()])
|
|
3919
3953
|
),
|
|
3920
|
-
file_id:
|
|
3921
|
-
filename:
|
|
3922
|
-
score:
|
|
3923
|
-
text:
|
|
3954
|
+
file_id: z17.string(),
|
|
3955
|
+
filename: z17.string(),
|
|
3956
|
+
score: z17.number(),
|
|
3957
|
+
text: z17.string()
|
|
3924
3958
|
})
|
|
3925
3959
|
).nullish()
|
|
3926
3960
|
}),
|
|
3927
|
-
|
|
3928
|
-
type:
|
|
3929
|
-
id:
|
|
3930
|
-
code:
|
|
3931
|
-
container_id:
|
|
3932
|
-
outputs:
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3961
|
+
z17.object({
|
|
3962
|
+
type: z17.literal("code_interpreter_call"),
|
|
3963
|
+
id: z17.string(),
|
|
3964
|
+
code: z17.string().nullable(),
|
|
3965
|
+
container_id: z17.string(),
|
|
3966
|
+
outputs: z17.array(
|
|
3967
|
+
z17.discriminatedUnion("type", [
|
|
3968
|
+
z17.object({ type: z17.literal("logs"), logs: z17.string() }),
|
|
3969
|
+
z17.object({ type: z17.literal("image"), url: z17.string() })
|
|
3936
3970
|
])
|
|
3937
3971
|
).nullable()
|
|
3938
3972
|
}),
|
|
3939
|
-
|
|
3940
|
-
type:
|
|
3941
|
-
id:
|
|
3942
|
-
result:
|
|
3973
|
+
z17.object({
|
|
3974
|
+
type: z17.literal("image_generation_call"),
|
|
3975
|
+
id: z17.string(),
|
|
3976
|
+
result: z17.string()
|
|
3943
3977
|
}),
|
|
3944
|
-
|
|
3945
|
-
type:
|
|
3946
|
-
id:
|
|
3947
|
-
call_id:
|
|
3948
|
-
action:
|
|
3949
|
-
type:
|
|
3950
|
-
command:
|
|
3951
|
-
timeout_ms:
|
|
3952
|
-
user:
|
|
3953
|
-
working_directory:
|
|
3954
|
-
env:
|
|
3978
|
+
z17.object({
|
|
3979
|
+
type: z17.literal("local_shell_call"),
|
|
3980
|
+
id: z17.string(),
|
|
3981
|
+
call_id: z17.string(),
|
|
3982
|
+
action: z17.object({
|
|
3983
|
+
type: z17.literal("exec"),
|
|
3984
|
+
command: z17.array(z17.string()),
|
|
3985
|
+
timeout_ms: z17.number().optional(),
|
|
3986
|
+
user: z17.string().optional(),
|
|
3987
|
+
working_directory: z17.string().optional(),
|
|
3988
|
+
env: z17.record(z17.string(), z17.string()).optional()
|
|
3955
3989
|
})
|
|
3956
3990
|
}),
|
|
3957
|
-
|
|
3958
|
-
type:
|
|
3959
|
-
call_id:
|
|
3960
|
-
name:
|
|
3961
|
-
arguments:
|
|
3962
|
-
id:
|
|
3991
|
+
z17.object({
|
|
3992
|
+
type: z17.literal("function_call"),
|
|
3993
|
+
call_id: z17.string(),
|
|
3994
|
+
name: z17.string(),
|
|
3995
|
+
arguments: z17.string(),
|
|
3996
|
+
id: z17.string()
|
|
3963
3997
|
}),
|
|
3964
|
-
|
|
3965
|
-
type:
|
|
3966
|
-
call_id:
|
|
3967
|
-
name:
|
|
3968
|
-
input:
|
|
3969
|
-
id:
|
|
3998
|
+
z17.object({
|
|
3999
|
+
type: z17.literal("custom_tool_call"),
|
|
4000
|
+
call_id: z17.string(),
|
|
4001
|
+
name: z17.string(),
|
|
4002
|
+
input: z17.string(),
|
|
4003
|
+
id: z17.string()
|
|
3970
4004
|
}),
|
|
3971
|
-
|
|
3972
|
-
type:
|
|
3973
|
-
id:
|
|
3974
|
-
status:
|
|
4005
|
+
z17.object({
|
|
4006
|
+
type: z17.literal("computer_call"),
|
|
4007
|
+
id: z17.string(),
|
|
4008
|
+
status: z17.string().optional()
|
|
3975
4009
|
}),
|
|
3976
|
-
|
|
3977
|
-
type:
|
|
3978
|
-
id:
|
|
3979
|
-
encrypted_content:
|
|
3980
|
-
summary:
|
|
3981
|
-
|
|
3982
|
-
type:
|
|
3983
|
-
text:
|
|
4010
|
+
z17.object({
|
|
4011
|
+
type: z17.literal("reasoning"),
|
|
4012
|
+
id: z17.string(),
|
|
4013
|
+
encrypted_content: z17.string().nullish(),
|
|
4014
|
+
summary: z17.array(
|
|
4015
|
+
z17.object({
|
|
4016
|
+
type: z17.literal("summary_text"),
|
|
4017
|
+
text: z17.string()
|
|
3984
4018
|
})
|
|
3985
4019
|
)
|
|
3986
4020
|
}),
|
|
3987
|
-
|
|
3988
|
-
type:
|
|
3989
|
-
id:
|
|
3990
|
-
status:
|
|
3991
|
-
arguments:
|
|
3992
|
-
name:
|
|
3993
|
-
server_label:
|
|
3994
|
-
output:
|
|
3995
|
-
error:
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
type:
|
|
3999
|
-
code:
|
|
4000
|
-
message:
|
|
4021
|
+
z17.object({
|
|
4022
|
+
type: z17.literal("mcp_call"),
|
|
4023
|
+
id: z17.string(),
|
|
4024
|
+
status: z17.string(),
|
|
4025
|
+
arguments: z17.string(),
|
|
4026
|
+
name: z17.string(),
|
|
4027
|
+
server_label: z17.string(),
|
|
4028
|
+
output: z17.string().nullish(),
|
|
4029
|
+
error: z17.union([
|
|
4030
|
+
z17.string(),
|
|
4031
|
+
z17.object({
|
|
4032
|
+
type: z17.string().optional(),
|
|
4033
|
+
code: z17.union([z17.number(), z17.string()]).optional(),
|
|
4034
|
+
message: z17.string().optional()
|
|
4001
4035
|
}).loose()
|
|
4002
4036
|
]).nullish(),
|
|
4003
|
-
approval_request_id:
|
|
4037
|
+
approval_request_id: z17.string().nullish()
|
|
4004
4038
|
}),
|
|
4005
|
-
|
|
4006
|
-
type:
|
|
4007
|
-
id:
|
|
4008
|
-
server_label:
|
|
4009
|
-
tools:
|
|
4010
|
-
|
|
4011
|
-
name:
|
|
4012
|
-
description:
|
|
4013
|
-
input_schema:
|
|
4014
|
-
annotations:
|
|
4039
|
+
z17.object({
|
|
4040
|
+
type: z17.literal("mcp_list_tools"),
|
|
4041
|
+
id: z17.string(),
|
|
4042
|
+
server_label: z17.string(),
|
|
4043
|
+
tools: z17.array(
|
|
4044
|
+
z17.object({
|
|
4045
|
+
name: z17.string(),
|
|
4046
|
+
description: z17.string().optional(),
|
|
4047
|
+
input_schema: z17.any(),
|
|
4048
|
+
annotations: z17.record(z17.string(), z17.unknown()).optional()
|
|
4015
4049
|
})
|
|
4016
4050
|
),
|
|
4017
|
-
error:
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
type:
|
|
4021
|
-
code:
|
|
4022
|
-
message:
|
|
4051
|
+
error: z17.union([
|
|
4052
|
+
z17.string(),
|
|
4053
|
+
z17.object({
|
|
4054
|
+
type: z17.string().optional(),
|
|
4055
|
+
code: z17.union([z17.number(), z17.string()]).optional(),
|
|
4056
|
+
message: z17.string().optional()
|
|
4023
4057
|
}).loose()
|
|
4024
4058
|
]).optional()
|
|
4025
4059
|
}),
|
|
4026
|
-
|
|
4027
|
-
type:
|
|
4028
|
-
id:
|
|
4029
|
-
server_label:
|
|
4030
|
-
name:
|
|
4031
|
-
arguments:
|
|
4032
|
-
approval_request_id:
|
|
4060
|
+
z17.object({
|
|
4061
|
+
type: z17.literal("mcp_approval_request"),
|
|
4062
|
+
id: z17.string(),
|
|
4063
|
+
server_label: z17.string(),
|
|
4064
|
+
name: z17.string(),
|
|
4065
|
+
arguments: z17.string(),
|
|
4066
|
+
approval_request_id: z17.string().optional()
|
|
4033
4067
|
}),
|
|
4034
|
-
|
|
4035
|
-
type:
|
|
4036
|
-
id:
|
|
4037
|
-
call_id:
|
|
4038
|
-
status:
|
|
4039
|
-
operation:
|
|
4040
|
-
|
|
4041
|
-
type:
|
|
4042
|
-
path:
|
|
4043
|
-
diff:
|
|
4068
|
+
z17.object({
|
|
4069
|
+
type: z17.literal("apply_patch_call"),
|
|
4070
|
+
id: z17.string(),
|
|
4071
|
+
call_id: z17.string(),
|
|
4072
|
+
status: z17.enum(["in_progress", "completed"]),
|
|
4073
|
+
operation: z17.discriminatedUnion("type", [
|
|
4074
|
+
z17.object({
|
|
4075
|
+
type: z17.literal("create_file"),
|
|
4076
|
+
path: z17.string(),
|
|
4077
|
+
diff: z17.string()
|
|
4044
4078
|
}),
|
|
4045
|
-
|
|
4046
|
-
type:
|
|
4047
|
-
path:
|
|
4079
|
+
z17.object({
|
|
4080
|
+
type: z17.literal("delete_file"),
|
|
4081
|
+
path: z17.string()
|
|
4048
4082
|
}),
|
|
4049
|
-
|
|
4050
|
-
type:
|
|
4051
|
-
path:
|
|
4052
|
-
diff:
|
|
4083
|
+
z17.object({
|
|
4084
|
+
type: z17.literal("update_file"),
|
|
4085
|
+
path: z17.string(),
|
|
4086
|
+
diff: z17.string()
|
|
4053
4087
|
})
|
|
4054
4088
|
])
|
|
4055
4089
|
}),
|
|
4056
|
-
|
|
4057
|
-
type:
|
|
4058
|
-
id:
|
|
4059
|
-
call_id:
|
|
4060
|
-
status:
|
|
4061
|
-
action:
|
|
4062
|
-
commands:
|
|
4090
|
+
z17.object({
|
|
4091
|
+
type: z17.literal("shell_call"),
|
|
4092
|
+
id: z17.string(),
|
|
4093
|
+
call_id: z17.string(),
|
|
4094
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
4095
|
+
action: z17.object({
|
|
4096
|
+
commands: z17.array(z17.string())
|
|
4063
4097
|
})
|
|
4064
4098
|
}),
|
|
4065
|
-
|
|
4066
|
-
type:
|
|
4067
|
-
id:
|
|
4068
|
-
encrypted_content:
|
|
4099
|
+
z17.object({
|
|
4100
|
+
type: z17.literal("compaction"),
|
|
4101
|
+
id: z17.string(),
|
|
4102
|
+
encrypted_content: z17.string()
|
|
4069
4103
|
}),
|
|
4070
|
-
|
|
4071
|
-
type:
|
|
4072
|
-
id:
|
|
4073
|
-
call_id:
|
|
4074
|
-
status:
|
|
4075
|
-
output:
|
|
4076
|
-
|
|
4077
|
-
stdout:
|
|
4078
|
-
stderr:
|
|
4079
|
-
outcome:
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
type:
|
|
4083
|
-
exit_code:
|
|
4104
|
+
z17.object({
|
|
4105
|
+
type: z17.literal("shell_call_output"),
|
|
4106
|
+
id: z17.string(),
|
|
4107
|
+
call_id: z17.string(),
|
|
4108
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
4109
|
+
output: z17.array(
|
|
4110
|
+
z17.object({
|
|
4111
|
+
stdout: z17.string(),
|
|
4112
|
+
stderr: z17.string(),
|
|
4113
|
+
outcome: z17.discriminatedUnion("type", [
|
|
4114
|
+
z17.object({ type: z17.literal("timeout") }),
|
|
4115
|
+
z17.object({
|
|
4116
|
+
type: z17.literal("exit"),
|
|
4117
|
+
exit_code: z17.number()
|
|
4084
4118
|
})
|
|
4085
4119
|
])
|
|
4086
4120
|
})
|
|
4087
4121
|
)
|
|
4088
4122
|
}),
|
|
4089
|
-
|
|
4090
|
-
type:
|
|
4091
|
-
id:
|
|
4092
|
-
execution:
|
|
4093
|
-
call_id:
|
|
4094
|
-
status:
|
|
4095
|
-
arguments:
|
|
4123
|
+
z17.object({
|
|
4124
|
+
type: z17.literal("tool_search_call"),
|
|
4125
|
+
id: z17.string(),
|
|
4126
|
+
execution: z17.enum(["server", "client"]),
|
|
4127
|
+
call_id: z17.string().nullable(),
|
|
4128
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
4129
|
+
arguments: z17.unknown()
|
|
4096
4130
|
}),
|
|
4097
|
-
|
|
4098
|
-
type:
|
|
4099
|
-
id:
|
|
4100
|
-
execution:
|
|
4101
|
-
call_id:
|
|
4102
|
-
status:
|
|
4103
|
-
tools:
|
|
4131
|
+
z17.object({
|
|
4132
|
+
type: z17.literal("tool_search_output"),
|
|
4133
|
+
id: z17.string(),
|
|
4134
|
+
execution: z17.enum(["server", "client"]),
|
|
4135
|
+
call_id: z17.string().nullable(),
|
|
4136
|
+
status: z17.enum(["in_progress", "completed", "incomplete"]),
|
|
4137
|
+
tools: z17.array(z17.record(z17.string(), jsonValueSchema.optional()))
|
|
4104
4138
|
})
|
|
4105
4139
|
])
|
|
4106
4140
|
).optional(),
|
|
4107
|
-
service_tier:
|
|
4108
|
-
incomplete_details:
|
|
4109
|
-
usage:
|
|
4110
|
-
input_tokens:
|
|
4111
|
-
input_tokens_details:
|
|
4112
|
-
output_tokens:
|
|
4113
|
-
output_tokens_details:
|
|
4141
|
+
service_tier: z17.string().nullish(),
|
|
4142
|
+
incomplete_details: z17.object({ reason: z17.string() }).nullish(),
|
|
4143
|
+
usage: z17.object({
|
|
4144
|
+
input_tokens: z17.number(),
|
|
4145
|
+
input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
|
|
4146
|
+
output_tokens: z17.number(),
|
|
4147
|
+
output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
|
|
4114
4148
|
}).optional()
|
|
4115
4149
|
})
|
|
4116
4150
|
)
|
|
4117
4151
|
);
|
|
4118
4152
|
|
|
4119
4153
|
// src/responses/openai-responses-options.ts
|
|
4120
|
-
|
|
4121
|
-
|
|
4154
|
+
import { lazySchema as lazySchema16, zodSchema as zodSchema16 } from "@ai-sdk/provider-utils";
|
|
4155
|
+
import { z as z18 } from "zod/v4";
|
|
4122
4156
|
var TOP_LOGPROBS_MAX = 20;
|
|
4123
4157
|
var openaiResponsesReasoningModelIds = [
|
|
4124
4158
|
"o1",
|
|
@@ -4183,9 +4217,9 @@ var openaiResponsesModelIds = [
|
|
|
4183
4217
|
"gpt-5-chat-latest",
|
|
4184
4218
|
...openaiResponsesReasoningModelIds
|
|
4185
4219
|
];
|
|
4186
|
-
var openaiLanguageModelResponsesOptionsSchema = (
|
|
4187
|
-
() => (
|
|
4188
|
-
|
|
4220
|
+
var openaiLanguageModelResponsesOptionsSchema = lazySchema16(
|
|
4221
|
+
() => zodSchema16(
|
|
4222
|
+
z18.object({
|
|
4189
4223
|
/**
|
|
4190
4224
|
* The ID of the OpenAI Conversation to continue.
|
|
4191
4225
|
* You must create a conversation first via the OpenAI API.
|
|
@@ -4193,13 +4227,13 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4193
4227
|
* Defaults to `undefined`.
|
|
4194
4228
|
* @see https://platform.openai.com/docs/api-reference/conversations/create
|
|
4195
4229
|
*/
|
|
4196
|
-
conversation:
|
|
4230
|
+
conversation: z18.string().nullish(),
|
|
4197
4231
|
/**
|
|
4198
4232
|
* The set of extra fields to include in the response (advanced, usually not needed).
|
|
4199
4233
|
* Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
|
|
4200
4234
|
*/
|
|
4201
|
-
include:
|
|
4202
|
-
|
|
4235
|
+
include: z18.array(
|
|
4236
|
+
z18.enum([
|
|
4203
4237
|
"reasoning.encrypted_content",
|
|
4204
4238
|
// handled internally by default, only needed for unknown reasoning models
|
|
4205
4239
|
"file_search_call.results",
|
|
@@ -4211,7 +4245,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4211
4245
|
* They can be used to change the system or developer message when continuing a conversation using the `previousResponseId` option.
|
|
4212
4246
|
* Defaults to `undefined`.
|
|
4213
4247
|
*/
|
|
4214
|
-
instructions:
|
|
4248
|
+
instructions: z18.string().nullish(),
|
|
4215
4249
|
/**
|
|
4216
4250
|
* Return the log probabilities of the tokens. Including logprobs will increase
|
|
4217
4251
|
* the response size and can slow down response times. However, it can
|
|
@@ -4226,30 +4260,30 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4226
4260
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
4227
4261
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
4228
4262
|
*/
|
|
4229
|
-
logprobs:
|
|
4263
|
+
logprobs: z18.union([z18.boolean(), z18.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
4230
4264
|
/**
|
|
4231
4265
|
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
4232
4266
|
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
4233
4267
|
* Any further attempts to call a tool by the model will be ignored.
|
|
4234
4268
|
*/
|
|
4235
|
-
maxToolCalls:
|
|
4269
|
+
maxToolCalls: z18.number().nullish(),
|
|
4236
4270
|
/**
|
|
4237
4271
|
* Additional metadata to store with the generation.
|
|
4238
4272
|
*/
|
|
4239
|
-
metadata:
|
|
4273
|
+
metadata: z18.any().nullish(),
|
|
4240
4274
|
/**
|
|
4241
4275
|
* Whether to use parallel tool calls. Defaults to `true`.
|
|
4242
4276
|
*/
|
|
4243
|
-
parallelToolCalls:
|
|
4277
|
+
parallelToolCalls: z18.boolean().nullish(),
|
|
4244
4278
|
/**
|
|
4245
4279
|
* The ID of the previous response. You can use it to continue a conversation.
|
|
4246
4280
|
* Defaults to `undefined`.
|
|
4247
4281
|
*/
|
|
4248
|
-
previousResponseId:
|
|
4282
|
+
previousResponseId: z18.string().nullish(),
|
|
4249
4283
|
/**
|
|
4250
4284
|
* Sets a cache key to tie this prompt to cached prefixes for better caching performance.
|
|
4251
4285
|
*/
|
|
4252
|
-
promptCacheKey:
|
|
4286
|
+
promptCacheKey: z18.string().nullish(),
|
|
4253
4287
|
/**
|
|
4254
4288
|
* The retention policy for the prompt cache.
|
|
4255
4289
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
@@ -4258,7 +4292,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4258
4292
|
*
|
|
4259
4293
|
* @default 'in_memory'
|
|
4260
4294
|
*/
|
|
4261
|
-
promptCacheRetention:
|
|
4295
|
+
promptCacheRetention: z18.enum(["in_memory", "24h"]).nullish(),
|
|
4262
4296
|
/**
|
|
4263
4297
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
4264
4298
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
@@ -4269,17 +4303,17 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4269
4303
|
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
4270
4304
|
* an error.
|
|
4271
4305
|
*/
|
|
4272
|
-
reasoningEffort:
|
|
4306
|
+
reasoningEffort: z18.string().nullish(),
|
|
4273
4307
|
/**
|
|
4274
4308
|
* Controls reasoning summary output from the model.
|
|
4275
4309
|
* Set to "auto" to automatically receive the richest level available,
|
|
4276
4310
|
* or "detailed" for comprehensive summaries.
|
|
4277
4311
|
*/
|
|
4278
|
-
reasoningSummary:
|
|
4312
|
+
reasoningSummary: z18.string().nullish(),
|
|
4279
4313
|
/**
|
|
4280
4314
|
* The identifier for safety monitoring and tracking.
|
|
4281
4315
|
*/
|
|
4282
|
-
safetyIdentifier:
|
|
4316
|
+
safetyIdentifier: z18.string().nullish(),
|
|
4283
4317
|
/**
|
|
4284
4318
|
* Service tier for the request.
|
|
4285
4319
|
* Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
|
|
@@ -4287,34 +4321,34 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4287
4321
|
*
|
|
4288
4322
|
* Defaults to 'auto'.
|
|
4289
4323
|
*/
|
|
4290
|
-
serviceTier:
|
|
4324
|
+
serviceTier: z18.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
4291
4325
|
/**
|
|
4292
4326
|
* Whether to store the generation. Defaults to `true`.
|
|
4293
4327
|
*/
|
|
4294
|
-
store:
|
|
4328
|
+
store: z18.boolean().nullish(),
|
|
4295
4329
|
/**
|
|
4296
4330
|
* Whether to use strict JSON schema validation.
|
|
4297
4331
|
* Defaults to `true`.
|
|
4298
4332
|
*/
|
|
4299
|
-
strictJsonSchema:
|
|
4333
|
+
strictJsonSchema: z18.boolean().nullish(),
|
|
4300
4334
|
/**
|
|
4301
4335
|
* Controls the verbosity of the model's responses. Lower values ('low') will result
|
|
4302
4336
|
* in more concise responses, while higher values ('high') will result in more verbose responses.
|
|
4303
4337
|
* Valid values: 'low', 'medium', 'high'.
|
|
4304
4338
|
*/
|
|
4305
|
-
textVerbosity:
|
|
4339
|
+
textVerbosity: z18.enum(["low", "medium", "high"]).nullish(),
|
|
4306
4340
|
/**
|
|
4307
4341
|
* Controls output truncation. 'auto' (default) performs truncation automatically;
|
|
4308
4342
|
* 'disabled' turns truncation off.
|
|
4309
4343
|
*/
|
|
4310
|
-
truncation:
|
|
4344
|
+
truncation: z18.enum(["auto", "disabled"]).nullish(),
|
|
4311
4345
|
/**
|
|
4312
4346
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
4313
4347
|
* monitor and detect abuse.
|
|
4314
4348
|
* Defaults to `undefined`.
|
|
4315
4349
|
* @see https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids
|
|
4316
4350
|
*/
|
|
4317
|
-
user:
|
|
4351
|
+
user: z18.string().nullish(),
|
|
4318
4352
|
/**
|
|
4319
4353
|
* Override the system message mode for this model.
|
|
4320
4354
|
* - 'system': Use the 'system' role for system messages (default for most models)
|
|
@@ -4323,7 +4357,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4323
4357
|
*
|
|
4324
4358
|
* If not specified, the mode is automatically determined based on the model.
|
|
4325
4359
|
*/
|
|
4326
|
-
systemMessageMode:
|
|
4360
|
+
systemMessageMode: z18.enum(["system", "developer", "remove"]).optional(),
|
|
4327
4361
|
/**
|
|
4328
4362
|
* Force treating this model as a reasoning model.
|
|
4329
4363
|
*
|
|
@@ -4333,14 +4367,14 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4333
4367
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4334
4368
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4335
4369
|
*/
|
|
4336
|
-
forceReasoning:
|
|
4370
|
+
forceReasoning: z18.boolean().optional(),
|
|
4337
4371
|
/**
|
|
4338
4372
|
* Enable server-side context management (compaction).
|
|
4339
4373
|
*/
|
|
4340
|
-
contextManagement:
|
|
4341
|
-
|
|
4342
|
-
type:
|
|
4343
|
-
compactThreshold:
|
|
4374
|
+
contextManagement: z18.array(
|
|
4375
|
+
z18.object({
|
|
4376
|
+
type: z18.literal("compaction"),
|
|
4377
|
+
compactThreshold: z18.number()
|
|
4344
4378
|
})
|
|
4345
4379
|
).nullish()
|
|
4346
4380
|
})
|
|
@@ -4348,45 +4382,54 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4348
4382
|
);
|
|
4349
4383
|
|
|
4350
4384
|
// src/responses/openai-responses-prepare-tools.ts
|
|
4351
|
-
|
|
4352
|
-
|
|
4385
|
+
import {
|
|
4386
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
4387
|
+
} from "@ai-sdk/provider";
|
|
4388
|
+
import {
|
|
4389
|
+
resolveProviderReference as resolveProviderReference3,
|
|
4390
|
+
validateTypes as validateTypes2
|
|
4391
|
+
} from "@ai-sdk/provider-utils";
|
|
4353
4392
|
|
|
4354
4393
|
// src/tool/code-interpreter.ts
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4394
|
+
import {
|
|
4395
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
4396
|
+
lazySchema as lazySchema17,
|
|
4397
|
+
zodSchema as zodSchema17
|
|
4398
|
+
} from "@ai-sdk/provider-utils";
|
|
4399
|
+
import { z as z19 } from "zod/v4";
|
|
4400
|
+
var codeInterpreterInputSchema = lazySchema17(
|
|
4401
|
+
() => zodSchema17(
|
|
4402
|
+
z19.object({
|
|
4403
|
+
code: z19.string().nullish(),
|
|
4404
|
+
containerId: z19.string()
|
|
4362
4405
|
})
|
|
4363
4406
|
)
|
|
4364
4407
|
);
|
|
4365
|
-
var codeInterpreterOutputSchema = (
|
|
4366
|
-
() => (
|
|
4367
|
-
|
|
4368
|
-
outputs:
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4408
|
+
var codeInterpreterOutputSchema = lazySchema17(
|
|
4409
|
+
() => zodSchema17(
|
|
4410
|
+
z19.object({
|
|
4411
|
+
outputs: z19.array(
|
|
4412
|
+
z19.discriminatedUnion("type", [
|
|
4413
|
+
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
4414
|
+
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
4372
4415
|
])
|
|
4373
4416
|
).nullish()
|
|
4374
4417
|
})
|
|
4375
4418
|
)
|
|
4376
4419
|
);
|
|
4377
|
-
var codeInterpreterArgsSchema = (
|
|
4378
|
-
() => (
|
|
4379
|
-
|
|
4380
|
-
container:
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
fileIds:
|
|
4420
|
+
var codeInterpreterArgsSchema = lazySchema17(
|
|
4421
|
+
() => zodSchema17(
|
|
4422
|
+
z19.object({
|
|
4423
|
+
container: z19.union([
|
|
4424
|
+
z19.string(),
|
|
4425
|
+
z19.object({
|
|
4426
|
+
fileIds: z19.array(z19.string()).optional()
|
|
4384
4427
|
})
|
|
4385
4428
|
]).optional()
|
|
4386
4429
|
})
|
|
4387
4430
|
)
|
|
4388
4431
|
);
|
|
4389
|
-
var codeInterpreterToolFactory = (
|
|
4432
|
+
var codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema5({
|
|
4390
4433
|
id: "openai.code_interpreter",
|
|
4391
4434
|
inputSchema: codeInterpreterInputSchema,
|
|
4392
4435
|
outputSchema: codeInterpreterOutputSchema
|
|
@@ -4396,81 +4439,89 @@ var codeInterpreter = (args = {}) => {
|
|
|
4396
4439
|
};
|
|
4397
4440
|
|
|
4398
4441
|
// src/tool/file-search.ts
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4442
|
+
import {
|
|
4443
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
4444
|
+
lazySchema as lazySchema18,
|
|
4445
|
+
zodSchema as zodSchema18
|
|
4446
|
+
} from "@ai-sdk/provider-utils";
|
|
4447
|
+
import { z as z20 } from "zod/v4";
|
|
4448
|
+
var comparisonFilterSchema = z20.object({
|
|
4449
|
+
key: z20.string(),
|
|
4450
|
+
type: z20.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
|
|
4451
|
+
value: z20.union([z20.string(), z20.number(), z20.boolean(), z20.array(z20.string())])
|
|
4405
4452
|
});
|
|
4406
|
-
var compoundFilterSchema =
|
|
4407
|
-
type:
|
|
4408
|
-
filters:
|
|
4409
|
-
|
|
4453
|
+
var compoundFilterSchema = z20.object({
|
|
4454
|
+
type: z20.enum(["and", "or"]),
|
|
4455
|
+
filters: z20.array(
|
|
4456
|
+
z20.union([comparisonFilterSchema, z20.lazy(() => compoundFilterSchema)])
|
|
4410
4457
|
)
|
|
4411
4458
|
});
|
|
4412
|
-
var fileSearchArgsSchema = (
|
|
4413
|
-
() => (
|
|
4414
|
-
|
|
4415
|
-
vectorStoreIds:
|
|
4416
|
-
maxNumResults:
|
|
4417
|
-
ranking:
|
|
4418
|
-
ranker:
|
|
4419
|
-
scoreThreshold:
|
|
4459
|
+
var fileSearchArgsSchema = lazySchema18(
|
|
4460
|
+
() => zodSchema18(
|
|
4461
|
+
z20.object({
|
|
4462
|
+
vectorStoreIds: z20.array(z20.string()),
|
|
4463
|
+
maxNumResults: z20.number().optional(),
|
|
4464
|
+
ranking: z20.object({
|
|
4465
|
+
ranker: z20.string().optional(),
|
|
4466
|
+
scoreThreshold: z20.number().optional()
|
|
4420
4467
|
}).optional(),
|
|
4421
|
-
filters:
|
|
4468
|
+
filters: z20.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
4422
4469
|
})
|
|
4423
4470
|
)
|
|
4424
4471
|
);
|
|
4425
|
-
var fileSearchOutputSchema = (
|
|
4426
|
-
() => (
|
|
4427
|
-
|
|
4428
|
-
queries:
|
|
4429
|
-
results:
|
|
4430
|
-
|
|
4431
|
-
attributes:
|
|
4432
|
-
fileId:
|
|
4433
|
-
filename:
|
|
4434
|
-
score:
|
|
4435
|
-
text:
|
|
4472
|
+
var fileSearchOutputSchema = lazySchema18(
|
|
4473
|
+
() => zodSchema18(
|
|
4474
|
+
z20.object({
|
|
4475
|
+
queries: z20.array(z20.string()),
|
|
4476
|
+
results: z20.array(
|
|
4477
|
+
z20.object({
|
|
4478
|
+
attributes: z20.record(z20.string(), z20.unknown()),
|
|
4479
|
+
fileId: z20.string(),
|
|
4480
|
+
filename: z20.string(),
|
|
4481
|
+
score: z20.number(),
|
|
4482
|
+
text: z20.string()
|
|
4436
4483
|
})
|
|
4437
4484
|
).nullable()
|
|
4438
4485
|
})
|
|
4439
4486
|
)
|
|
4440
4487
|
);
|
|
4441
|
-
var fileSearch = (
|
|
4488
|
+
var fileSearch = createProviderToolFactoryWithOutputSchema6({
|
|
4442
4489
|
id: "openai.file_search",
|
|
4443
|
-
inputSchema:
|
|
4490
|
+
inputSchema: z20.object({}),
|
|
4444
4491
|
outputSchema: fileSearchOutputSchema
|
|
4445
4492
|
});
|
|
4446
4493
|
|
|
4447
4494
|
// src/tool/image-generation.ts
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4495
|
+
import {
|
|
4496
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
4497
|
+
lazySchema as lazySchema19,
|
|
4498
|
+
zodSchema as zodSchema19
|
|
4499
|
+
} from "@ai-sdk/provider-utils";
|
|
4500
|
+
import { z as z21 } from "zod/v4";
|
|
4501
|
+
var imageGenerationArgsSchema = lazySchema19(
|
|
4502
|
+
() => zodSchema19(
|
|
4503
|
+
z21.object({
|
|
4504
|
+
background: z21.enum(["auto", "opaque", "transparent"]).optional(),
|
|
4505
|
+
inputFidelity: z21.enum(["low", "high"]).optional(),
|
|
4506
|
+
inputImageMask: z21.object({
|
|
4507
|
+
fileId: z21.string().optional(),
|
|
4508
|
+
imageUrl: z21.string().optional()
|
|
4458
4509
|
}).optional(),
|
|
4459
|
-
model:
|
|
4460
|
-
moderation:
|
|
4461
|
-
outputCompression:
|
|
4462
|
-
outputFormat:
|
|
4463
|
-
partialImages:
|
|
4464
|
-
quality:
|
|
4465
|
-
size:
|
|
4510
|
+
model: z21.string().optional(),
|
|
4511
|
+
moderation: z21.enum(["auto"]).optional(),
|
|
4512
|
+
outputCompression: z21.number().int().min(0).max(100).optional(),
|
|
4513
|
+
outputFormat: z21.enum(["png", "jpeg", "webp"]).optional(),
|
|
4514
|
+
partialImages: z21.number().int().min(0).max(3).optional(),
|
|
4515
|
+
quality: z21.enum(["auto", "low", "medium", "high"]).optional(),
|
|
4516
|
+
size: z21.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
4466
4517
|
}).strict()
|
|
4467
4518
|
)
|
|
4468
4519
|
);
|
|
4469
|
-
var imageGenerationInputSchema = (
|
|
4470
|
-
var imageGenerationOutputSchema = (
|
|
4471
|
-
() => (
|
|
4520
|
+
var imageGenerationInputSchema = lazySchema19(() => zodSchema19(z21.object({})));
|
|
4521
|
+
var imageGenerationOutputSchema = lazySchema19(
|
|
4522
|
+
() => zodSchema19(z21.object({ result: z21.string() }))
|
|
4472
4523
|
);
|
|
4473
|
-
var imageGenerationToolFactory = (
|
|
4524
|
+
var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema7({
|
|
4474
4525
|
id: "openai.image_generation",
|
|
4475
4526
|
inputSchema: imageGenerationInputSchema,
|
|
4476
4527
|
outputSchema: imageGenerationOutputSchema
|
|
@@ -4480,188 +4531,204 @@ var imageGeneration = (args = {}) => {
|
|
|
4480
4531
|
};
|
|
4481
4532
|
|
|
4482
4533
|
// src/tool/custom.ts
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4534
|
+
import {
|
|
4535
|
+
createProviderToolFactory,
|
|
4536
|
+
lazySchema as lazySchema20,
|
|
4537
|
+
zodSchema as zodSchema20
|
|
4538
|
+
} from "@ai-sdk/provider-utils";
|
|
4539
|
+
import { z as z22 } from "zod/v4";
|
|
4540
|
+
var customArgsSchema = lazySchema20(
|
|
4541
|
+
() => zodSchema20(
|
|
4542
|
+
z22.object({
|
|
4543
|
+
description: z22.string().optional(),
|
|
4544
|
+
format: z22.union([
|
|
4545
|
+
z22.object({
|
|
4546
|
+
type: z22.literal("grammar"),
|
|
4547
|
+
syntax: z22.enum(["regex", "lark"]),
|
|
4548
|
+
definition: z22.string()
|
|
4494
4549
|
}),
|
|
4495
|
-
|
|
4496
|
-
type:
|
|
4550
|
+
z22.object({
|
|
4551
|
+
type: z22.literal("text")
|
|
4497
4552
|
})
|
|
4498
4553
|
]).optional()
|
|
4499
4554
|
})
|
|
4500
4555
|
)
|
|
4501
4556
|
);
|
|
4502
|
-
var customInputSchema = (
|
|
4503
|
-
var customToolFactory =
|
|
4557
|
+
var customInputSchema = lazySchema20(() => zodSchema20(z22.string()));
|
|
4558
|
+
var customToolFactory = createProviderToolFactory({
|
|
4504
4559
|
id: "openai.custom",
|
|
4505
4560
|
inputSchema: customInputSchema
|
|
4506
4561
|
});
|
|
4507
4562
|
|
|
4508
4563
|
// src/tool/mcp.ts
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4564
|
+
import {
|
|
4565
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
4566
|
+
lazySchema as lazySchema21,
|
|
4567
|
+
zodSchema as zodSchema21
|
|
4568
|
+
} from "@ai-sdk/provider-utils";
|
|
4569
|
+
import { z as z23 } from "zod/v4";
|
|
4570
|
+
var jsonValueSchema2 = z23.lazy(
|
|
4571
|
+
() => z23.union([
|
|
4572
|
+
z23.string(),
|
|
4573
|
+
z23.number(),
|
|
4574
|
+
z23.boolean(),
|
|
4575
|
+
z23.null(),
|
|
4576
|
+
z23.array(jsonValueSchema2),
|
|
4577
|
+
z23.record(z23.string(), jsonValueSchema2)
|
|
4519
4578
|
])
|
|
4520
4579
|
);
|
|
4521
|
-
var mcpArgsSchema = (
|
|
4522
|
-
() => (
|
|
4523
|
-
|
|
4524
|
-
serverLabel:
|
|
4525
|
-
allowedTools:
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
readOnly:
|
|
4529
|
-
toolNames:
|
|
4580
|
+
var mcpArgsSchema = lazySchema21(
|
|
4581
|
+
() => zodSchema21(
|
|
4582
|
+
z23.object({
|
|
4583
|
+
serverLabel: z23.string(),
|
|
4584
|
+
allowedTools: z23.union([
|
|
4585
|
+
z23.array(z23.string()),
|
|
4586
|
+
z23.object({
|
|
4587
|
+
readOnly: z23.boolean().optional(),
|
|
4588
|
+
toolNames: z23.array(z23.string()).optional()
|
|
4530
4589
|
})
|
|
4531
4590
|
]).optional(),
|
|
4532
|
-
authorization:
|
|
4533
|
-
connectorId:
|
|
4534
|
-
headers:
|
|
4535
|
-
requireApproval:
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
never:
|
|
4539
|
-
toolNames:
|
|
4591
|
+
authorization: z23.string().optional(),
|
|
4592
|
+
connectorId: z23.string().optional(),
|
|
4593
|
+
headers: z23.record(z23.string(), z23.string()).optional(),
|
|
4594
|
+
requireApproval: z23.union([
|
|
4595
|
+
z23.enum(["always", "never"]),
|
|
4596
|
+
z23.object({
|
|
4597
|
+
never: z23.object({
|
|
4598
|
+
toolNames: z23.array(z23.string()).optional()
|
|
4540
4599
|
}).optional()
|
|
4541
4600
|
})
|
|
4542
4601
|
]).optional(),
|
|
4543
|
-
serverDescription:
|
|
4544
|
-
serverUrl:
|
|
4602
|
+
serverDescription: z23.string().optional(),
|
|
4603
|
+
serverUrl: z23.string().optional()
|
|
4545
4604
|
}).refine(
|
|
4546
4605
|
(v) => v.serverUrl != null || v.connectorId != null,
|
|
4547
4606
|
"One of serverUrl or connectorId must be provided."
|
|
4548
4607
|
)
|
|
4549
4608
|
)
|
|
4550
4609
|
);
|
|
4551
|
-
var mcpInputSchema = (
|
|
4552
|
-
var mcpOutputSchema = (
|
|
4553
|
-
() => (
|
|
4554
|
-
|
|
4555
|
-
type:
|
|
4556
|
-
serverLabel:
|
|
4557
|
-
name:
|
|
4558
|
-
arguments:
|
|
4559
|
-
output:
|
|
4560
|
-
error:
|
|
4610
|
+
var mcpInputSchema = lazySchema21(() => zodSchema21(z23.object({})));
|
|
4611
|
+
var mcpOutputSchema = lazySchema21(
|
|
4612
|
+
() => zodSchema21(
|
|
4613
|
+
z23.object({
|
|
4614
|
+
type: z23.literal("call"),
|
|
4615
|
+
serverLabel: z23.string(),
|
|
4616
|
+
name: z23.string(),
|
|
4617
|
+
arguments: z23.string(),
|
|
4618
|
+
output: z23.string().nullish(),
|
|
4619
|
+
error: z23.union([z23.string(), jsonValueSchema2]).optional()
|
|
4561
4620
|
})
|
|
4562
4621
|
)
|
|
4563
4622
|
);
|
|
4564
|
-
var mcpToolFactory = (
|
|
4623
|
+
var mcpToolFactory = createProviderToolFactoryWithOutputSchema8({
|
|
4565
4624
|
id: "openai.mcp",
|
|
4566
4625
|
inputSchema: mcpInputSchema,
|
|
4567
4626
|
outputSchema: mcpOutputSchema
|
|
4568
4627
|
});
|
|
4569
4628
|
|
|
4570
4629
|
// src/tool/web-search.ts
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4630
|
+
import {
|
|
4631
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
|
|
4632
|
+
lazySchema as lazySchema22,
|
|
4633
|
+
zodSchema as zodSchema22
|
|
4634
|
+
} from "@ai-sdk/provider-utils";
|
|
4635
|
+
import { z as z24 } from "zod/v4";
|
|
4636
|
+
var webSearchArgsSchema = lazySchema22(
|
|
4637
|
+
() => zodSchema22(
|
|
4638
|
+
z24.object({
|
|
4639
|
+
externalWebAccess: z24.boolean().optional(),
|
|
4640
|
+
filters: z24.object({ allowedDomains: z24.array(z24.string()).optional() }).optional(),
|
|
4641
|
+
searchContextSize: z24.enum(["low", "medium", "high"]).optional(),
|
|
4642
|
+
userLocation: z24.object({
|
|
4643
|
+
type: z24.literal("approximate"),
|
|
4644
|
+
country: z24.string().optional(),
|
|
4645
|
+
city: z24.string().optional(),
|
|
4646
|
+
region: z24.string().optional(),
|
|
4647
|
+
timezone: z24.string().optional()
|
|
4585
4648
|
}).optional()
|
|
4586
4649
|
})
|
|
4587
4650
|
)
|
|
4588
4651
|
);
|
|
4589
|
-
var webSearchInputSchema = (
|
|
4590
|
-
var webSearchOutputSchema = (
|
|
4591
|
-
() => (
|
|
4592
|
-
|
|
4593
|
-
action:
|
|
4594
|
-
|
|
4595
|
-
type:
|
|
4596
|
-
query:
|
|
4652
|
+
var webSearchInputSchema = lazySchema22(() => zodSchema22(z24.object({})));
|
|
4653
|
+
var webSearchOutputSchema = lazySchema22(
|
|
4654
|
+
() => zodSchema22(
|
|
4655
|
+
z24.object({
|
|
4656
|
+
action: z24.discriminatedUnion("type", [
|
|
4657
|
+
z24.object({
|
|
4658
|
+
type: z24.literal("search"),
|
|
4659
|
+
query: z24.string().optional()
|
|
4597
4660
|
}),
|
|
4598
|
-
|
|
4599
|
-
type:
|
|
4600
|
-
url:
|
|
4661
|
+
z24.object({
|
|
4662
|
+
type: z24.literal("openPage"),
|
|
4663
|
+
url: z24.string().nullish()
|
|
4601
4664
|
}),
|
|
4602
|
-
|
|
4603
|
-
type:
|
|
4604
|
-
url:
|
|
4605
|
-
pattern:
|
|
4665
|
+
z24.object({
|
|
4666
|
+
type: z24.literal("findInPage"),
|
|
4667
|
+
url: z24.string().nullish(),
|
|
4668
|
+
pattern: z24.string().nullish()
|
|
4606
4669
|
})
|
|
4607
4670
|
]).optional(),
|
|
4608
|
-
sources:
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4671
|
+
sources: z24.array(
|
|
4672
|
+
z24.discriminatedUnion("type", [
|
|
4673
|
+
z24.object({ type: z24.literal("url"), url: z24.string() }),
|
|
4674
|
+
z24.object({ type: z24.literal("api"), name: z24.string() })
|
|
4612
4675
|
])
|
|
4613
4676
|
).optional()
|
|
4614
4677
|
})
|
|
4615
4678
|
)
|
|
4616
4679
|
);
|
|
4617
|
-
var webSearchToolFactory = (
|
|
4680
|
+
var webSearchToolFactory = createProviderToolFactoryWithOutputSchema9({
|
|
4618
4681
|
id: "openai.web_search",
|
|
4619
4682
|
inputSchema: webSearchInputSchema,
|
|
4620
4683
|
outputSchema: webSearchOutputSchema
|
|
4621
4684
|
});
|
|
4622
4685
|
|
|
4623
4686
|
// src/tool/web-search-preview.ts
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4687
|
+
import {
|
|
4688
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema10,
|
|
4689
|
+
lazySchema as lazySchema23,
|
|
4690
|
+
zodSchema as zodSchema23
|
|
4691
|
+
} from "@ai-sdk/provider-utils";
|
|
4692
|
+
import { z as z25 } from "zod/v4";
|
|
4693
|
+
var webSearchPreviewArgsSchema = lazySchema23(
|
|
4694
|
+
() => zodSchema23(
|
|
4695
|
+
z25.object({
|
|
4696
|
+
searchContextSize: z25.enum(["low", "medium", "high"]).optional(),
|
|
4697
|
+
userLocation: z25.object({
|
|
4698
|
+
type: z25.literal("approximate"),
|
|
4699
|
+
country: z25.string().optional(),
|
|
4700
|
+
city: z25.string().optional(),
|
|
4701
|
+
region: z25.string().optional(),
|
|
4702
|
+
timezone: z25.string().optional()
|
|
4636
4703
|
}).optional()
|
|
4637
4704
|
})
|
|
4638
4705
|
)
|
|
4639
4706
|
);
|
|
4640
|
-
var webSearchPreviewInputSchema = (
|
|
4641
|
-
() => (
|
|
4707
|
+
var webSearchPreviewInputSchema = lazySchema23(
|
|
4708
|
+
() => zodSchema23(z25.object({}))
|
|
4642
4709
|
);
|
|
4643
|
-
var webSearchPreviewOutputSchema = (
|
|
4644
|
-
() => (
|
|
4645
|
-
|
|
4646
|
-
action:
|
|
4647
|
-
|
|
4648
|
-
type:
|
|
4649
|
-
query:
|
|
4710
|
+
var webSearchPreviewOutputSchema = lazySchema23(
|
|
4711
|
+
() => zodSchema23(
|
|
4712
|
+
z25.object({
|
|
4713
|
+
action: z25.discriminatedUnion("type", [
|
|
4714
|
+
z25.object({
|
|
4715
|
+
type: z25.literal("search"),
|
|
4716
|
+
query: z25.string().optional()
|
|
4650
4717
|
}),
|
|
4651
|
-
|
|
4652
|
-
type:
|
|
4653
|
-
url:
|
|
4718
|
+
z25.object({
|
|
4719
|
+
type: z25.literal("openPage"),
|
|
4720
|
+
url: z25.string().nullish()
|
|
4654
4721
|
}),
|
|
4655
|
-
|
|
4656
|
-
type:
|
|
4657
|
-
url:
|
|
4658
|
-
pattern:
|
|
4722
|
+
z25.object({
|
|
4723
|
+
type: z25.literal("findInPage"),
|
|
4724
|
+
url: z25.string().nullish(),
|
|
4725
|
+
pattern: z25.string().nullish()
|
|
4659
4726
|
})
|
|
4660
4727
|
]).optional()
|
|
4661
4728
|
})
|
|
4662
4729
|
)
|
|
4663
4730
|
);
|
|
4664
|
-
var webSearchPreview = (
|
|
4731
|
+
var webSearchPreview = createProviderToolFactoryWithOutputSchema10({
|
|
4665
4732
|
id: "openai.web_search_preview",
|
|
4666
4733
|
inputSchema: webSearchPreviewInputSchema,
|
|
4667
4734
|
outputSchema: webSearchPreviewOutputSchema
|
|
@@ -4700,7 +4767,7 @@ async function prepareResponsesTools({
|
|
|
4700
4767
|
case "provider": {
|
|
4701
4768
|
switch (tool.id) {
|
|
4702
4769
|
case "openai.file_search": {
|
|
4703
|
-
const args = await (
|
|
4770
|
+
const args = await validateTypes2({
|
|
4704
4771
|
value: tool.args,
|
|
4705
4772
|
schema: fileSearchArgsSchema
|
|
4706
4773
|
});
|
|
@@ -4723,7 +4790,7 @@ async function prepareResponsesTools({
|
|
|
4723
4790
|
break;
|
|
4724
4791
|
}
|
|
4725
4792
|
case "openai.shell": {
|
|
4726
|
-
const args = await (
|
|
4793
|
+
const args = await validateTypes2({
|
|
4727
4794
|
value: tool.args,
|
|
4728
4795
|
schema: shellArgsSchema
|
|
4729
4796
|
});
|
|
@@ -4742,7 +4809,7 @@ async function prepareResponsesTools({
|
|
|
4742
4809
|
break;
|
|
4743
4810
|
}
|
|
4744
4811
|
case "openai.web_search_preview": {
|
|
4745
|
-
const args = await (
|
|
4812
|
+
const args = await validateTypes2({
|
|
4746
4813
|
value: tool.args,
|
|
4747
4814
|
schema: webSearchPreviewArgsSchema
|
|
4748
4815
|
});
|
|
@@ -4754,7 +4821,7 @@ async function prepareResponsesTools({
|
|
|
4754
4821
|
break;
|
|
4755
4822
|
}
|
|
4756
4823
|
case "openai.web_search": {
|
|
4757
|
-
const args = await (
|
|
4824
|
+
const args = await validateTypes2({
|
|
4758
4825
|
value: tool.args,
|
|
4759
4826
|
schema: webSearchArgsSchema
|
|
4760
4827
|
});
|
|
@@ -4768,7 +4835,7 @@ async function prepareResponsesTools({
|
|
|
4768
4835
|
break;
|
|
4769
4836
|
}
|
|
4770
4837
|
case "openai.code_interpreter": {
|
|
4771
|
-
const args = await (
|
|
4838
|
+
const args = await validateTypes2({
|
|
4772
4839
|
value: tool.args,
|
|
4773
4840
|
schema: codeInterpreterArgsSchema
|
|
4774
4841
|
});
|
|
@@ -4779,7 +4846,7 @@ async function prepareResponsesTools({
|
|
|
4779
4846
|
break;
|
|
4780
4847
|
}
|
|
4781
4848
|
case "openai.image_generation": {
|
|
4782
|
-
const args = await (
|
|
4849
|
+
const args = await validateTypes2({
|
|
4783
4850
|
value: tool.args,
|
|
4784
4851
|
schema: imageGenerationArgsSchema
|
|
4785
4852
|
});
|
|
@@ -4802,7 +4869,7 @@ async function prepareResponsesTools({
|
|
|
4802
4869
|
break;
|
|
4803
4870
|
}
|
|
4804
4871
|
case "openai.mcp": {
|
|
4805
|
-
const args = await (
|
|
4872
|
+
const args = await validateTypes2({
|
|
4806
4873
|
value: tool.args,
|
|
4807
4874
|
schema: mcpArgsSchema
|
|
4808
4875
|
});
|
|
@@ -4828,7 +4895,7 @@ async function prepareResponsesTools({
|
|
|
4828
4895
|
break;
|
|
4829
4896
|
}
|
|
4830
4897
|
case "openai.custom": {
|
|
4831
|
-
const args = await (
|
|
4898
|
+
const args = await validateTypes2({
|
|
4832
4899
|
value: tool.args,
|
|
4833
4900
|
schema: customArgsSchema
|
|
4834
4901
|
});
|
|
@@ -4842,7 +4909,7 @@ async function prepareResponsesTools({
|
|
|
4842
4909
|
break;
|
|
4843
4910
|
}
|
|
4844
4911
|
case "openai.tool_search": {
|
|
4845
|
-
const args = await (
|
|
4912
|
+
const args = await validateTypes2({
|
|
4846
4913
|
value: tool.args,
|
|
4847
4914
|
schema: toolSearchArgsSchema
|
|
4848
4915
|
});
|
|
@@ -4884,7 +4951,7 @@ async function prepareResponsesTools({
|
|
|
4884
4951
|
}
|
|
4885
4952
|
default: {
|
|
4886
4953
|
const _exhaustiveCheck = type;
|
|
4887
|
-
throw new
|
|
4954
|
+
throw new UnsupportedFunctionalityError5({
|
|
4888
4955
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
4889
4956
|
});
|
|
4890
4957
|
}
|
|
@@ -4924,7 +4991,7 @@ function mapShellSkills(skills) {
|
|
|
4924
4991
|
var _a, _b;
|
|
4925
4992
|
return skill.type === "skillReference" ? {
|
|
4926
4993
|
type: "skill_reference",
|
|
4927
|
-
skill_id: (
|
|
4994
|
+
skill_id: resolveProviderReference3({
|
|
4928
4995
|
reference: (_a = skill.providerReference) != null ? _a : {},
|
|
4929
4996
|
provider: "openai"
|
|
4930
4997
|
}),
|
|
@@ -5007,19 +5074,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5007
5074
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
5008
5075
|
}
|
|
5009
5076
|
const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
|
|
5010
|
-
let openaiOptions = await (
|
|
5077
|
+
let openaiOptions = await parseProviderOptions7({
|
|
5011
5078
|
provider: providerOptionsName,
|
|
5012
5079
|
providerOptions,
|
|
5013
5080
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
5014
5081
|
});
|
|
5015
5082
|
if (openaiOptions == null && providerOptionsName !== "openai") {
|
|
5016
|
-
openaiOptions = await (
|
|
5083
|
+
openaiOptions = await parseProviderOptions7({
|
|
5017
5084
|
provider: "openai",
|
|
5018
5085
|
providerOptions,
|
|
5019
5086
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
5020
5087
|
});
|
|
5021
5088
|
}
|
|
5022
|
-
const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : (
|
|
5089
|
+
const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : isCustomReasoning2(reasoning) ? reasoning : void 0;
|
|
5023
5090
|
const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
5024
5091
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
5025
5092
|
warnings.push({
|
|
@@ -5028,7 +5095,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5028
5095
|
details: "conversation and previousResponseId cannot be used together"
|
|
5029
5096
|
});
|
|
5030
5097
|
}
|
|
5031
|
-
const toolNameMapping =
|
|
5098
|
+
const toolNameMapping = createToolNameMapping({
|
|
5032
5099
|
tools,
|
|
5033
5100
|
providerToolNames: {
|
|
5034
5101
|
"openai.code_interpreter": "code_interpreter",
|
|
@@ -5242,19 +5309,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5242
5309
|
responseHeaders,
|
|
5243
5310
|
value: response,
|
|
5244
5311
|
rawValue: rawResponse
|
|
5245
|
-
} = await (
|
|
5312
|
+
} = await postJsonToApi6({
|
|
5246
5313
|
url,
|
|
5247
|
-
headers: (
|
|
5314
|
+
headers: combineHeaders7(this.config.headers(), options.headers),
|
|
5248
5315
|
body,
|
|
5249
5316
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
5250
|
-
successfulResponseHandler: (
|
|
5317
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
5251
5318
|
openaiResponsesResponseSchema
|
|
5252
5319
|
),
|
|
5253
5320
|
abortSignal: options.abortSignal,
|
|
5254
5321
|
fetch: this.config.fetch
|
|
5255
5322
|
});
|
|
5256
5323
|
if (response.error) {
|
|
5257
|
-
throw new
|
|
5324
|
+
throw new APICallError({
|
|
5258
5325
|
message: response.error.message,
|
|
5259
5326
|
url,
|
|
5260
5327
|
requestBodyValues: body,
|
|
@@ -5423,7 +5490,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5423
5490
|
content.push({
|
|
5424
5491
|
type: "source",
|
|
5425
5492
|
sourceType: "url",
|
|
5426
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (
|
|
5493
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
5427
5494
|
url: annotation.url,
|
|
5428
5495
|
title: annotation.title
|
|
5429
5496
|
});
|
|
@@ -5431,7 +5498,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5431
5498
|
content.push({
|
|
5432
5499
|
type: "source",
|
|
5433
5500
|
sourceType: "document",
|
|
5434
|
-
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (
|
|
5501
|
+
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
|
|
5435
5502
|
mediaType: "text/plain",
|
|
5436
5503
|
title: annotation.filename,
|
|
5437
5504
|
filename: annotation.filename,
|
|
@@ -5447,7 +5514,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5447
5514
|
content.push({
|
|
5448
5515
|
type: "source",
|
|
5449
5516
|
sourceType: "document",
|
|
5450
|
-
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (
|
|
5517
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
|
|
5451
5518
|
mediaType: "text/plain",
|
|
5452
5519
|
title: annotation.filename,
|
|
5453
5520
|
filename: annotation.filename,
|
|
@@ -5463,7 +5530,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5463
5530
|
content.push({
|
|
5464
5531
|
type: "source",
|
|
5465
5532
|
sourceType: "document",
|
|
5466
|
-
id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (
|
|
5533
|
+
id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
|
|
5467
5534
|
mediaType: "application/octet-stream",
|
|
5468
5535
|
title: annotation.file_id,
|
|
5469
5536
|
filename: annotation.file_id,
|
|
@@ -5567,7 +5634,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5567
5634
|
}
|
|
5568
5635
|
case "mcp_approval_request": {
|
|
5569
5636
|
const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
|
|
5570
|
-
const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (
|
|
5637
|
+
const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2();
|
|
5571
5638
|
const toolName = `mcp.${part.name}`;
|
|
5572
5639
|
content.push({
|
|
5573
5640
|
type: "tool-call",
|
|
@@ -5722,18 +5789,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5722
5789
|
providerOptionsName,
|
|
5723
5790
|
isShellProviderExecuted
|
|
5724
5791
|
} = await this.getArgs(options);
|
|
5725
|
-
const { responseHeaders, value: response } = await (
|
|
5792
|
+
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
5726
5793
|
url: this.config.url({
|
|
5727
5794
|
path: "/responses",
|
|
5728
5795
|
modelId: this.modelId
|
|
5729
5796
|
}),
|
|
5730
|
-
headers: (
|
|
5797
|
+
headers: combineHeaders7(this.config.headers(), options.headers),
|
|
5731
5798
|
body: {
|
|
5732
5799
|
...body,
|
|
5733
5800
|
stream: true
|
|
5734
5801
|
},
|
|
5735
5802
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
5736
|
-
successfulResponseHandler: (
|
|
5803
|
+
successfulResponseHandler: createEventSourceResponseHandler3(
|
|
5737
5804
|
openaiResponsesChunkSchema
|
|
5738
5805
|
),
|
|
5739
5806
|
abortSignal: options.abortSignal,
|
|
@@ -6213,7 +6280,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6213
6280
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6214
6281
|
} else if (value.item.type === "mcp_approval_request") {
|
|
6215
6282
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6216
|
-
const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (
|
|
6283
|
+
const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2();
|
|
6217
6284
|
const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
|
|
6218
6285
|
approvalRequestIdToDummyToolCallIdFromStream.set(
|
|
6219
6286
|
approvalRequestId,
|
|
@@ -6516,7 +6583,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6516
6583
|
controller.enqueue({
|
|
6517
6584
|
type: "source",
|
|
6518
6585
|
sourceType: "url",
|
|
6519
|
-
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (
|
|
6586
|
+
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
|
|
6520
6587
|
url: value.annotation.url,
|
|
6521
6588
|
title: value.annotation.title
|
|
6522
6589
|
});
|
|
@@ -6524,7 +6591,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6524
6591
|
controller.enqueue({
|
|
6525
6592
|
type: "source",
|
|
6526
6593
|
sourceType: "document",
|
|
6527
|
-
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (
|
|
6594
|
+
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
|
|
6528
6595
|
mediaType: "text/plain",
|
|
6529
6596
|
title: value.annotation.filename,
|
|
6530
6597
|
filename: value.annotation.filename,
|
|
@@ -6540,7 +6607,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6540
6607
|
controller.enqueue({
|
|
6541
6608
|
type: "source",
|
|
6542
6609
|
sourceType: "document",
|
|
6543
|
-
id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (
|
|
6610
|
+
id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
|
|
6544
6611
|
mediaType: "text/plain",
|
|
6545
6612
|
title: value.annotation.filename,
|
|
6546
6613
|
filename: value.annotation.filename,
|
|
@@ -6556,7 +6623,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6556
6623
|
controller.enqueue({
|
|
6557
6624
|
type: "source",
|
|
6558
6625
|
sourceType: "document",
|
|
6559
|
-
id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (
|
|
6626
|
+
id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
|
|
6560
6627
|
mediaType: "application/octet-stream",
|
|
6561
6628
|
title: value.annotation.file_id,
|
|
6562
6629
|
filename: value.annotation.file_id,
|
|
@@ -6667,8 +6734,7 @@ function mapWebSearchOutput(action) {
|
|
|
6667
6734
|
function escapeJSONDelta(delta) {
|
|
6668
6735
|
return JSON.stringify(delta).slice(1, -1);
|
|
6669
6736
|
}
|
|
6670
|
-
|
|
6671
|
-
0 && (module.exports = {
|
|
6737
|
+
export {
|
|
6672
6738
|
OpenAIChatLanguageModel,
|
|
6673
6739
|
OpenAICompletionLanguageModel,
|
|
6674
6740
|
OpenAIEmbeddingModel,
|
|
@@ -6702,5 +6768,5 @@ function escapeJSONDelta(delta) {
|
|
|
6702
6768
|
webSearchPreview,
|
|
6703
6769
|
webSearchPreviewArgsSchema,
|
|
6704
6770
|
webSearchPreviewInputSchema
|
|
6705
|
-
}
|
|
6771
|
+
};
|
|
6706
6772
|
//# sourceMappingURL=index.js.map
|