@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/index.js
CHANGED
|
@@ -1,53 +1,41 @@
|
|
|
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/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
createOpenAI: () => createOpenAI,
|
|
25
|
-
openai: () => openai
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/openai-provider.ts
|
|
30
|
-
|
|
2
|
+
import {
|
|
3
|
+
loadApiKey,
|
|
4
|
+
loadOptionalSetting,
|
|
5
|
+
withoutTrailingSlash,
|
|
6
|
+
withUserAgentSuffix
|
|
7
|
+
} from "@ai-sdk/provider-utils";
|
|
31
8
|
|
|
32
9
|
// src/chat/openai-chat-language-model.ts
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
import {
|
|
11
|
+
InvalidResponseDataError
|
|
12
|
+
} from "@ai-sdk/provider";
|
|
13
|
+
import {
|
|
14
|
+
combineHeaders,
|
|
15
|
+
createEventSourceResponseHandler,
|
|
16
|
+
createJsonResponseHandler,
|
|
17
|
+
generateId,
|
|
18
|
+
isCustomReasoning,
|
|
19
|
+
isParsableJson,
|
|
20
|
+
parseProviderOptions,
|
|
21
|
+
postJsonToApi
|
|
22
|
+
} from "@ai-sdk/provider-utils";
|
|
35
23
|
|
|
36
24
|
// src/openai-error.ts
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var openaiErrorDataSchema =
|
|
40
|
-
error:
|
|
41
|
-
message:
|
|
25
|
+
import { z } from "zod/v4";
|
|
26
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
27
|
+
var openaiErrorDataSchema = z.object({
|
|
28
|
+
error: z.object({
|
|
29
|
+
message: z.string(),
|
|
42
30
|
// The additional information below is handled loosely to support
|
|
43
31
|
// OpenAI-compatible providers that have slightly different error
|
|
44
32
|
// responses:
|
|
45
|
-
type:
|
|
46
|
-
param:
|
|
47
|
-
code:
|
|
33
|
+
type: z.string().nullish(),
|
|
34
|
+
param: z.any().nullish(),
|
|
35
|
+
code: z.union([z.string(), z.number()]).nullish()
|
|
48
36
|
})
|
|
49
37
|
});
|
|
50
|
-
var openaiFailedResponseHandler =
|
|
38
|
+
var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
51
39
|
errorSchema: openaiErrorDataSchema,
|
|
52
40
|
errorToMessage: (data) => data.error.message
|
|
53
41
|
});
|
|
@@ -108,8 +96,14 @@ function convertOpenAIChatUsage(usage) {
|
|
|
108
96
|
}
|
|
109
97
|
|
|
110
98
|
// src/chat/convert-to-openai-chat-messages.ts
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
import {
|
|
100
|
+
UnsupportedFunctionalityError
|
|
101
|
+
} from "@ai-sdk/provider";
|
|
102
|
+
import {
|
|
103
|
+
convertToBase64,
|
|
104
|
+
isProviderReference,
|
|
105
|
+
resolveProviderReference
|
|
106
|
+
} from "@ai-sdk/provider-utils";
|
|
113
107
|
function convertToOpenAIChatMessages({
|
|
114
108
|
prompt,
|
|
115
109
|
systemMessageMode = "system"
|
|
@@ -159,11 +153,11 @@ function convertToOpenAIChatMessages({
|
|
|
159
153
|
return { type: "text", text: part.text };
|
|
160
154
|
}
|
|
161
155
|
case "file": {
|
|
162
|
-
if (
|
|
156
|
+
if (isProviderReference(part.data)) {
|
|
163
157
|
return {
|
|
164
158
|
type: "file",
|
|
165
159
|
file: {
|
|
166
|
-
file_id:
|
|
160
|
+
file_id: resolveProviderReference({
|
|
167
161
|
reference: part.data,
|
|
168
162
|
provider: "openai"
|
|
169
163
|
})
|
|
@@ -175,13 +169,13 @@ function convertToOpenAIChatMessages({
|
|
|
175
169
|
return {
|
|
176
170
|
type: "image_url",
|
|
177
171
|
image_url: {
|
|
178
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${
|
|
172
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
179
173
|
detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
|
|
180
174
|
}
|
|
181
175
|
};
|
|
182
176
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
183
177
|
if (part.data instanceof URL) {
|
|
184
|
-
throw new
|
|
178
|
+
throw new UnsupportedFunctionalityError({
|
|
185
179
|
functionality: "audio file parts with URLs"
|
|
186
180
|
});
|
|
187
181
|
}
|
|
@@ -190,7 +184,7 @@ function convertToOpenAIChatMessages({
|
|
|
190
184
|
return {
|
|
191
185
|
type: "input_audio",
|
|
192
186
|
input_audio: {
|
|
193
|
-
data:
|
|
187
|
+
data: convertToBase64(part.data),
|
|
194
188
|
format: "wav"
|
|
195
189
|
}
|
|
196
190
|
};
|
|
@@ -200,20 +194,20 @@ function convertToOpenAIChatMessages({
|
|
|
200
194
|
return {
|
|
201
195
|
type: "input_audio",
|
|
202
196
|
input_audio: {
|
|
203
|
-
data:
|
|
197
|
+
data: convertToBase64(part.data),
|
|
204
198
|
format: "mp3"
|
|
205
199
|
}
|
|
206
200
|
};
|
|
207
201
|
}
|
|
208
202
|
default: {
|
|
209
|
-
throw new
|
|
203
|
+
throw new UnsupportedFunctionalityError({
|
|
210
204
|
functionality: `audio content parts with media type ${part.mediaType}`
|
|
211
205
|
});
|
|
212
206
|
}
|
|
213
207
|
}
|
|
214
208
|
} else if (part.mediaType === "application/pdf") {
|
|
215
209
|
if (part.data instanceof URL) {
|
|
216
|
-
throw new
|
|
210
|
+
throw new UnsupportedFunctionalityError({
|
|
217
211
|
functionality: "PDF file parts with URLs"
|
|
218
212
|
});
|
|
219
213
|
}
|
|
@@ -221,11 +215,11 @@ function convertToOpenAIChatMessages({
|
|
|
221
215
|
type: "file",
|
|
222
216
|
file: {
|
|
223
217
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
224
|
-
file_data: `data:application/pdf;base64,${
|
|
218
|
+
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
225
219
|
}
|
|
226
220
|
};
|
|
227
221
|
} else {
|
|
228
|
-
throw new
|
|
222
|
+
throw new UnsupportedFunctionalityError({
|
|
229
223
|
functionality: `file part media type ${part.mediaType}`
|
|
230
224
|
});
|
|
231
225
|
}
|
|
@@ -333,139 +327,139 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
333
327
|
}
|
|
334
328
|
|
|
335
329
|
// src/chat/openai-chat-api.ts
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
var openaiChatResponseSchema =
|
|
339
|
-
() =>
|
|
340
|
-
|
|
341
|
-
id:
|
|
342
|
-
created:
|
|
343
|
-
model:
|
|
344
|
-
choices:
|
|
345
|
-
|
|
346
|
-
message:
|
|
347
|
-
role:
|
|
348
|
-
content:
|
|
349
|
-
tool_calls:
|
|
350
|
-
|
|
351
|
-
id:
|
|
352
|
-
type:
|
|
353
|
-
function:
|
|
354
|
-
name:
|
|
355
|
-
arguments:
|
|
330
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
331
|
+
import { z as z2 } from "zod/v4";
|
|
332
|
+
var openaiChatResponseSchema = lazySchema(
|
|
333
|
+
() => zodSchema(
|
|
334
|
+
z2.object({
|
|
335
|
+
id: z2.string().nullish(),
|
|
336
|
+
created: z2.number().nullish(),
|
|
337
|
+
model: z2.string().nullish(),
|
|
338
|
+
choices: z2.array(
|
|
339
|
+
z2.object({
|
|
340
|
+
message: z2.object({
|
|
341
|
+
role: z2.literal("assistant").nullish(),
|
|
342
|
+
content: z2.string().nullish(),
|
|
343
|
+
tool_calls: z2.array(
|
|
344
|
+
z2.object({
|
|
345
|
+
id: z2.string().nullish(),
|
|
346
|
+
type: z2.literal("function"),
|
|
347
|
+
function: z2.object({
|
|
348
|
+
name: z2.string(),
|
|
349
|
+
arguments: z2.string()
|
|
356
350
|
})
|
|
357
351
|
})
|
|
358
352
|
).nullish(),
|
|
359
|
-
annotations:
|
|
360
|
-
|
|
361
|
-
type:
|
|
362
|
-
url_citation:
|
|
363
|
-
start_index:
|
|
364
|
-
end_index:
|
|
365
|
-
url:
|
|
366
|
-
title:
|
|
353
|
+
annotations: z2.array(
|
|
354
|
+
z2.object({
|
|
355
|
+
type: z2.literal("url_citation"),
|
|
356
|
+
url_citation: z2.object({
|
|
357
|
+
start_index: z2.number(),
|
|
358
|
+
end_index: z2.number(),
|
|
359
|
+
url: z2.string(),
|
|
360
|
+
title: z2.string()
|
|
367
361
|
})
|
|
368
362
|
})
|
|
369
363
|
).nullish()
|
|
370
364
|
}),
|
|
371
|
-
index:
|
|
372
|
-
logprobs:
|
|
373
|
-
content:
|
|
374
|
-
|
|
375
|
-
token:
|
|
376
|
-
logprob:
|
|
377
|
-
top_logprobs:
|
|
378
|
-
|
|
379
|
-
token:
|
|
380
|
-
logprob:
|
|
365
|
+
index: z2.number(),
|
|
366
|
+
logprobs: z2.object({
|
|
367
|
+
content: z2.array(
|
|
368
|
+
z2.object({
|
|
369
|
+
token: z2.string(),
|
|
370
|
+
logprob: z2.number(),
|
|
371
|
+
top_logprobs: z2.array(
|
|
372
|
+
z2.object({
|
|
373
|
+
token: z2.string(),
|
|
374
|
+
logprob: z2.number()
|
|
381
375
|
})
|
|
382
376
|
)
|
|
383
377
|
})
|
|
384
378
|
).nullish()
|
|
385
379
|
}).nullish(),
|
|
386
|
-
finish_reason:
|
|
380
|
+
finish_reason: z2.string().nullish()
|
|
387
381
|
})
|
|
388
382
|
),
|
|
389
|
-
usage:
|
|
390
|
-
prompt_tokens:
|
|
391
|
-
completion_tokens:
|
|
392
|
-
total_tokens:
|
|
393
|
-
prompt_tokens_details:
|
|
394
|
-
cached_tokens:
|
|
383
|
+
usage: z2.object({
|
|
384
|
+
prompt_tokens: z2.number().nullish(),
|
|
385
|
+
completion_tokens: z2.number().nullish(),
|
|
386
|
+
total_tokens: z2.number().nullish(),
|
|
387
|
+
prompt_tokens_details: z2.object({
|
|
388
|
+
cached_tokens: z2.number().nullish()
|
|
395
389
|
}).nullish(),
|
|
396
|
-
completion_tokens_details:
|
|
397
|
-
reasoning_tokens:
|
|
398
|
-
accepted_prediction_tokens:
|
|
399
|
-
rejected_prediction_tokens:
|
|
390
|
+
completion_tokens_details: z2.object({
|
|
391
|
+
reasoning_tokens: z2.number().nullish(),
|
|
392
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
393
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
400
394
|
}).nullish()
|
|
401
395
|
}).nullish()
|
|
402
396
|
})
|
|
403
397
|
)
|
|
404
398
|
);
|
|
405
|
-
var openaiChatChunkSchema =
|
|
406
|
-
() =>
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
id:
|
|
410
|
-
created:
|
|
411
|
-
model:
|
|
412
|
-
choices:
|
|
413
|
-
|
|
414
|
-
delta:
|
|
415
|
-
role:
|
|
416
|
-
content:
|
|
417
|
-
tool_calls:
|
|
418
|
-
|
|
419
|
-
index:
|
|
420
|
-
id:
|
|
421
|
-
type:
|
|
422
|
-
function:
|
|
423
|
-
name:
|
|
424
|
-
arguments:
|
|
399
|
+
var openaiChatChunkSchema = lazySchema(
|
|
400
|
+
() => zodSchema(
|
|
401
|
+
z2.union([
|
|
402
|
+
z2.object({
|
|
403
|
+
id: z2.string().nullish(),
|
|
404
|
+
created: z2.number().nullish(),
|
|
405
|
+
model: z2.string().nullish(),
|
|
406
|
+
choices: z2.array(
|
|
407
|
+
z2.object({
|
|
408
|
+
delta: z2.object({
|
|
409
|
+
role: z2.enum(["assistant"]).nullish(),
|
|
410
|
+
content: z2.string().nullish(),
|
|
411
|
+
tool_calls: z2.array(
|
|
412
|
+
z2.object({
|
|
413
|
+
index: z2.number(),
|
|
414
|
+
id: z2.string().nullish(),
|
|
415
|
+
type: z2.literal("function").nullish(),
|
|
416
|
+
function: z2.object({
|
|
417
|
+
name: z2.string().nullish(),
|
|
418
|
+
arguments: z2.string().nullish()
|
|
425
419
|
})
|
|
426
420
|
})
|
|
427
421
|
).nullish(),
|
|
428
|
-
annotations:
|
|
429
|
-
|
|
430
|
-
type:
|
|
431
|
-
url_citation:
|
|
432
|
-
start_index:
|
|
433
|
-
end_index:
|
|
434
|
-
url:
|
|
435
|
-
title:
|
|
422
|
+
annotations: z2.array(
|
|
423
|
+
z2.object({
|
|
424
|
+
type: z2.literal("url_citation"),
|
|
425
|
+
url_citation: z2.object({
|
|
426
|
+
start_index: z2.number(),
|
|
427
|
+
end_index: z2.number(),
|
|
428
|
+
url: z2.string(),
|
|
429
|
+
title: z2.string()
|
|
436
430
|
})
|
|
437
431
|
})
|
|
438
432
|
).nullish()
|
|
439
433
|
}).nullish(),
|
|
440
|
-
logprobs:
|
|
441
|
-
content:
|
|
442
|
-
|
|
443
|
-
token:
|
|
444
|
-
logprob:
|
|
445
|
-
top_logprobs:
|
|
446
|
-
|
|
447
|
-
token:
|
|
448
|
-
logprob:
|
|
434
|
+
logprobs: z2.object({
|
|
435
|
+
content: z2.array(
|
|
436
|
+
z2.object({
|
|
437
|
+
token: z2.string(),
|
|
438
|
+
logprob: z2.number(),
|
|
439
|
+
top_logprobs: z2.array(
|
|
440
|
+
z2.object({
|
|
441
|
+
token: z2.string(),
|
|
442
|
+
logprob: z2.number()
|
|
449
443
|
})
|
|
450
444
|
)
|
|
451
445
|
})
|
|
452
446
|
).nullish()
|
|
453
447
|
}).nullish(),
|
|
454
|
-
finish_reason:
|
|
455
|
-
index:
|
|
448
|
+
finish_reason: z2.string().nullish(),
|
|
449
|
+
index: z2.number()
|
|
456
450
|
})
|
|
457
451
|
),
|
|
458
|
-
usage:
|
|
459
|
-
prompt_tokens:
|
|
460
|
-
completion_tokens:
|
|
461
|
-
total_tokens:
|
|
462
|
-
prompt_tokens_details:
|
|
463
|
-
cached_tokens:
|
|
452
|
+
usage: z2.object({
|
|
453
|
+
prompt_tokens: z2.number().nullish(),
|
|
454
|
+
completion_tokens: z2.number().nullish(),
|
|
455
|
+
total_tokens: z2.number().nullish(),
|
|
456
|
+
prompt_tokens_details: z2.object({
|
|
457
|
+
cached_tokens: z2.number().nullish()
|
|
464
458
|
}).nullish(),
|
|
465
|
-
completion_tokens_details:
|
|
466
|
-
reasoning_tokens:
|
|
467
|
-
accepted_prediction_tokens:
|
|
468
|
-
rejected_prediction_tokens:
|
|
459
|
+
completion_tokens_details: z2.object({
|
|
460
|
+
reasoning_tokens: z2.number().nullish(),
|
|
461
|
+
accepted_prediction_tokens: z2.number().nullish(),
|
|
462
|
+
rejected_prediction_tokens: z2.number().nullish()
|
|
469
463
|
}).nullish()
|
|
470
464
|
}).nullish()
|
|
471
465
|
}),
|
|
@@ -475,18 +469,18 @@ var openaiChatChunkSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
475
469
|
);
|
|
476
470
|
|
|
477
471
|
// src/chat/openai-chat-options.ts
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
var openaiLanguageModelChatOptions = (
|
|
481
|
-
() => (
|
|
482
|
-
|
|
472
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
473
|
+
import { z as z3 } from "zod/v4";
|
|
474
|
+
var openaiLanguageModelChatOptions = lazySchema2(
|
|
475
|
+
() => zodSchema2(
|
|
476
|
+
z3.object({
|
|
483
477
|
/**
|
|
484
478
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
485
479
|
*
|
|
486
480
|
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
487
481
|
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
488
482
|
*/
|
|
489
|
-
logitBias:
|
|
483
|
+
logitBias: z3.record(z3.coerce.number(), z3.number()).optional(),
|
|
490
484
|
/**
|
|
491
485
|
* Return the log probabilities of the tokens.
|
|
492
486
|
*
|
|
@@ -496,36 +490,36 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
496
490
|
* Setting to a number will return the log probabilities of the top n
|
|
497
491
|
* tokens that were generated.
|
|
498
492
|
*/
|
|
499
|
-
logprobs:
|
|
493
|
+
logprobs: z3.union([z3.boolean(), z3.number()]).optional(),
|
|
500
494
|
/**
|
|
501
495
|
* Whether to enable parallel function calling during tool use. Default to true.
|
|
502
496
|
*/
|
|
503
|
-
parallelToolCalls:
|
|
497
|
+
parallelToolCalls: z3.boolean().optional(),
|
|
504
498
|
/**
|
|
505
499
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
506
500
|
* monitor and detect abuse.
|
|
507
501
|
*/
|
|
508
|
-
user:
|
|
502
|
+
user: z3.string().optional(),
|
|
509
503
|
/**
|
|
510
504
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
511
505
|
*/
|
|
512
|
-
reasoningEffort:
|
|
506
|
+
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional(),
|
|
513
507
|
/**
|
|
514
508
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
515
509
|
*/
|
|
516
|
-
maxCompletionTokens:
|
|
510
|
+
maxCompletionTokens: z3.number().optional(),
|
|
517
511
|
/**
|
|
518
512
|
* Whether to enable persistence in responses API.
|
|
519
513
|
*/
|
|
520
|
-
store:
|
|
514
|
+
store: z3.boolean().optional(),
|
|
521
515
|
/**
|
|
522
516
|
* Metadata to associate with the request.
|
|
523
517
|
*/
|
|
524
|
-
metadata:
|
|
518
|
+
metadata: z3.record(z3.string().max(64), z3.string().max(512)).optional(),
|
|
525
519
|
/**
|
|
526
520
|
* Parameters for prediction mode.
|
|
527
521
|
*/
|
|
528
|
-
prediction:
|
|
522
|
+
prediction: z3.record(z3.string(), z3.any()).optional(),
|
|
529
523
|
/**
|
|
530
524
|
* Service tier for the request.
|
|
531
525
|
* - 'auto': Default service tier. The request will be processed with the service tier configured in the
|
|
@@ -536,23 +530,23 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
536
530
|
*
|
|
537
531
|
* @default 'auto'
|
|
538
532
|
*/
|
|
539
|
-
serviceTier:
|
|
533
|
+
serviceTier: z3.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
540
534
|
/**
|
|
541
535
|
* Whether to use strict JSON schema validation.
|
|
542
536
|
*
|
|
543
537
|
* @default true
|
|
544
538
|
*/
|
|
545
|
-
strictJsonSchema:
|
|
539
|
+
strictJsonSchema: z3.boolean().optional(),
|
|
546
540
|
/**
|
|
547
541
|
* Controls the verbosity of the model's responses.
|
|
548
542
|
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
549
543
|
*/
|
|
550
|
-
textVerbosity:
|
|
544
|
+
textVerbosity: z3.enum(["low", "medium", "high"]).optional(),
|
|
551
545
|
/**
|
|
552
546
|
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
553
547
|
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
554
548
|
*/
|
|
555
|
-
promptCacheKey:
|
|
549
|
+
promptCacheKey: z3.string().optional(),
|
|
556
550
|
/**
|
|
557
551
|
* The retention policy for the prompt cache.
|
|
558
552
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
@@ -561,7 +555,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
561
555
|
*
|
|
562
556
|
* @default 'in_memory'
|
|
563
557
|
*/
|
|
564
|
-
promptCacheRetention:
|
|
558
|
+
promptCacheRetention: z3.enum(["in_memory", "24h"]).optional(),
|
|
565
559
|
/**
|
|
566
560
|
* A stable identifier used to help detect users of your application
|
|
567
561
|
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
@@ -569,7 +563,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
569
563
|
* username or email address, in order to avoid sending us any identifying
|
|
570
564
|
* information.
|
|
571
565
|
*/
|
|
572
|
-
safetyIdentifier:
|
|
566
|
+
safetyIdentifier: z3.string().optional(),
|
|
573
567
|
/**
|
|
574
568
|
* Override the system message mode for this model.
|
|
575
569
|
* - 'system': Use the 'system' role for system messages (default for most models)
|
|
@@ -578,7 +572,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
578
572
|
*
|
|
579
573
|
* If not specified, the mode is automatically determined based on the model.
|
|
580
574
|
*/
|
|
581
|
-
systemMessageMode:
|
|
575
|
+
systemMessageMode: z3.enum(["system", "developer", "remove"]).optional(),
|
|
582
576
|
/**
|
|
583
577
|
* Force treating this model as a reasoning model.
|
|
584
578
|
*
|
|
@@ -588,13 +582,15 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
588
582
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
589
583
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
590
584
|
*/
|
|
591
|
-
forceReasoning:
|
|
585
|
+
forceReasoning: z3.boolean().optional()
|
|
592
586
|
})
|
|
593
587
|
)
|
|
594
588
|
);
|
|
595
589
|
|
|
596
590
|
// src/chat/openai-chat-prepare-tools.ts
|
|
597
|
-
|
|
591
|
+
import {
|
|
592
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
593
|
+
} from "@ai-sdk/provider";
|
|
598
594
|
function prepareChatTools({
|
|
599
595
|
tools,
|
|
600
596
|
toolChoice
|
|
@@ -648,7 +644,7 @@ function prepareChatTools({
|
|
|
648
644
|
};
|
|
649
645
|
default: {
|
|
650
646
|
const _exhaustiveCheck = type;
|
|
651
|
-
throw new
|
|
647
|
+
throw new UnsupportedFunctionalityError2({
|
|
652
648
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
653
649
|
});
|
|
654
650
|
}
|
|
@@ -686,13 +682,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
686
682
|
}) {
|
|
687
683
|
var _a, _b, _c, _d, _e, _f;
|
|
688
684
|
const warnings = [];
|
|
689
|
-
const openaiOptions = (_a = await
|
|
685
|
+
const openaiOptions = (_a = await parseProviderOptions({
|
|
690
686
|
provider: "openai",
|
|
691
687
|
providerOptions,
|
|
692
688
|
schema: openaiLanguageModelChatOptions
|
|
693
689
|
})) != null ? _a : {};
|
|
694
690
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
695
|
-
const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b :
|
|
691
|
+
const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
|
|
696
692
|
const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
|
|
697
693
|
if (topK != null) {
|
|
698
694
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -858,15 +854,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
858
854
|
responseHeaders,
|
|
859
855
|
value: response,
|
|
860
856
|
rawValue: rawResponse
|
|
861
|
-
} = await
|
|
857
|
+
} = await postJsonToApi({
|
|
862
858
|
url: this.config.url({
|
|
863
859
|
path: "/chat/completions",
|
|
864
860
|
modelId: this.modelId
|
|
865
861
|
}),
|
|
866
|
-
headers:
|
|
862
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
867
863
|
body,
|
|
868
864
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
869
|
-
successfulResponseHandler:
|
|
865
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
870
866
|
openaiChatResponseSchema
|
|
871
867
|
),
|
|
872
868
|
abortSignal: options.abortSignal,
|
|
@@ -881,7 +877,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
881
877
|
for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
|
|
882
878
|
content.push({
|
|
883
879
|
type: "tool-call",
|
|
884
|
-
toolCallId: (_b = toolCall.id) != null ? _b :
|
|
880
|
+
toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
|
|
885
881
|
toolName: toolCall.function.name,
|
|
886
882
|
input: toolCall.function.arguments
|
|
887
883
|
});
|
|
@@ -890,7 +886,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
890
886
|
content.push({
|
|
891
887
|
type: "source",
|
|
892
888
|
sourceType: "url",
|
|
893
|
-
id:
|
|
889
|
+
id: generateId(),
|
|
894
890
|
url: annotation.url_citation.url,
|
|
895
891
|
title: annotation.url_citation.title
|
|
896
892
|
});
|
|
@@ -932,15 +928,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
932
928
|
include_usage: true
|
|
933
929
|
}
|
|
934
930
|
};
|
|
935
|
-
const { responseHeaders, value: response } = await
|
|
931
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
936
932
|
url: this.config.url({
|
|
937
933
|
path: "/chat/completions",
|
|
938
934
|
modelId: this.modelId
|
|
939
935
|
}),
|
|
940
|
-
headers:
|
|
936
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
941
937
|
body,
|
|
942
938
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
943
|
-
successfulResponseHandler:
|
|
939
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
944
940
|
openaiChatChunkSchema
|
|
945
941
|
),
|
|
946
942
|
abortSignal: options.abortSignal,
|
|
@@ -1026,19 +1022,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
1026
1022
|
const index = toolCallDelta.index;
|
|
1027
1023
|
if (toolCalls[index] == null) {
|
|
1028
1024
|
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
1029
|
-
throw new
|
|
1025
|
+
throw new InvalidResponseDataError({
|
|
1030
1026
|
data: toolCallDelta,
|
|
1031
1027
|
message: `Expected 'function' type.`
|
|
1032
1028
|
});
|
|
1033
1029
|
}
|
|
1034
1030
|
if (toolCallDelta.id == null) {
|
|
1035
|
-
throw new
|
|
1031
|
+
throw new InvalidResponseDataError({
|
|
1036
1032
|
data: toolCallDelta,
|
|
1037
1033
|
message: `Expected 'id' to be a string.`
|
|
1038
1034
|
});
|
|
1039
1035
|
}
|
|
1040
1036
|
if (((_f = toolCallDelta.function) == null ? void 0 : _f.name) == null) {
|
|
1041
|
-
throw new
|
|
1037
|
+
throw new InvalidResponseDataError({
|
|
1042
1038
|
data: toolCallDelta,
|
|
1043
1039
|
message: `Expected 'function.name' to be a string.`
|
|
1044
1040
|
});
|
|
@@ -1066,14 +1062,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1066
1062
|
delta: toolCall2.function.arguments
|
|
1067
1063
|
});
|
|
1068
1064
|
}
|
|
1069
|
-
if (
|
|
1065
|
+
if (isParsableJson(toolCall2.function.arguments)) {
|
|
1070
1066
|
controller.enqueue({
|
|
1071
1067
|
type: "tool-input-end",
|
|
1072
1068
|
id: toolCall2.id
|
|
1073
1069
|
});
|
|
1074
1070
|
controller.enqueue({
|
|
1075
1071
|
type: "tool-call",
|
|
1076
|
-
toolCallId: (_j = toolCall2.id) != null ? _j :
|
|
1072
|
+
toolCallId: (_j = toolCall2.id) != null ? _j : generateId(),
|
|
1077
1073
|
toolName: toolCall2.function.name,
|
|
1078
1074
|
input: toolCall2.function.arguments
|
|
1079
1075
|
});
|
|
@@ -1094,14 +1090,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1094
1090
|
id: toolCall.id,
|
|
1095
1091
|
delta: (_n = toolCallDelta.function.arguments) != null ? _n : ""
|
|
1096
1092
|
});
|
|
1097
|
-
if (((_o = toolCall.function) == null ? void 0 : _o.name) != null && ((_p = toolCall.function) == null ? void 0 : _p.arguments) != null &&
|
|
1093
|
+
if (((_o = toolCall.function) == null ? void 0 : _o.name) != null && ((_p = toolCall.function) == null ? void 0 : _p.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
1098
1094
|
controller.enqueue({
|
|
1099
1095
|
type: "tool-input-end",
|
|
1100
1096
|
id: toolCall.id
|
|
1101
1097
|
});
|
|
1102
1098
|
controller.enqueue({
|
|
1103
1099
|
type: "tool-call",
|
|
1104
|
-
toolCallId: (_q = toolCall.id) != null ? _q :
|
|
1100
|
+
toolCallId: (_q = toolCall.id) != null ? _q : generateId(),
|
|
1105
1101
|
toolName: toolCall.function.name,
|
|
1106
1102
|
input: toolCall.function.arguments
|
|
1107
1103
|
});
|
|
@@ -1114,7 +1110,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1114
1110
|
controller.enqueue({
|
|
1115
1111
|
type: "source",
|
|
1116
1112
|
sourceType: "url",
|
|
1117
|
-
id:
|
|
1113
|
+
id: generateId(),
|
|
1118
1114
|
url: annotation.url_citation.url,
|
|
1119
1115
|
title: annotation.url_citation.title
|
|
1120
1116
|
});
|
|
@@ -1141,7 +1137,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
1141
1137
|
};
|
|
1142
1138
|
|
|
1143
1139
|
// src/completion/openai-completion-language-model.ts
|
|
1144
|
-
|
|
1140
|
+
import {
|
|
1141
|
+
combineHeaders as combineHeaders2,
|
|
1142
|
+
createEventSourceResponseHandler as createEventSourceResponseHandler2,
|
|
1143
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
1144
|
+
parseProviderOptions as parseProviderOptions2,
|
|
1145
|
+
postJsonToApi as postJsonToApi2
|
|
1146
|
+
} from "@ai-sdk/provider-utils";
|
|
1145
1147
|
|
|
1146
1148
|
// src/completion/convert-openai-completion-usage.ts
|
|
1147
1149
|
function convertOpenAICompletionUsage(usage) {
|
|
@@ -1181,7 +1183,10 @@ function convertOpenAICompletionUsage(usage) {
|
|
|
1181
1183
|
}
|
|
1182
1184
|
|
|
1183
1185
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
1184
|
-
|
|
1186
|
+
import {
|
|
1187
|
+
InvalidPromptError,
|
|
1188
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
1189
|
+
} from "@ai-sdk/provider";
|
|
1185
1190
|
function convertToOpenAICompletionPrompt({
|
|
1186
1191
|
prompt,
|
|
1187
1192
|
user = "user",
|
|
@@ -1197,7 +1202,7 @@ function convertToOpenAICompletionPrompt({
|
|
|
1197
1202
|
for (const { role, content } of prompt) {
|
|
1198
1203
|
switch (role) {
|
|
1199
1204
|
case "system": {
|
|
1200
|
-
throw new
|
|
1205
|
+
throw new InvalidPromptError({
|
|
1201
1206
|
message: "Unexpected system message in prompt: ${content}",
|
|
1202
1207
|
prompt
|
|
1203
1208
|
});
|
|
@@ -1223,7 +1228,7 @@ ${userMessage}
|
|
|
1223
1228
|
return part.text;
|
|
1224
1229
|
}
|
|
1225
1230
|
case "tool-call": {
|
|
1226
|
-
throw new
|
|
1231
|
+
throw new UnsupportedFunctionalityError3({
|
|
1227
1232
|
functionality: "tool-call messages"
|
|
1228
1233
|
});
|
|
1229
1234
|
}
|
|
@@ -1236,7 +1241,7 @@ ${assistantMessage}
|
|
|
1236
1241
|
break;
|
|
1237
1242
|
}
|
|
1238
1243
|
case "tool": {
|
|
1239
|
-
throw new
|
|
1244
|
+
throw new UnsupportedFunctionalityError3({
|
|
1240
1245
|
functionality: "tool messages"
|
|
1241
1246
|
});
|
|
1242
1247
|
}
|
|
@@ -1286,56 +1291,56 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1286
1291
|
}
|
|
1287
1292
|
|
|
1288
1293
|
// src/completion/openai-completion-api.ts
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
var openaiCompletionResponseSchema = (
|
|
1292
|
-
() => (
|
|
1293
|
-
|
|
1294
|
-
id:
|
|
1295
|
-
created:
|
|
1296
|
-
model:
|
|
1297
|
-
choices:
|
|
1298
|
-
|
|
1299
|
-
text:
|
|
1300
|
-
finish_reason:
|
|
1301
|
-
logprobs:
|
|
1302
|
-
tokens:
|
|
1303
|
-
token_logprobs:
|
|
1304
|
-
top_logprobs:
|
|
1294
|
+
import { z as z4 } from "zod/v4";
|
|
1295
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
1296
|
+
var openaiCompletionResponseSchema = lazySchema3(
|
|
1297
|
+
() => zodSchema3(
|
|
1298
|
+
z4.object({
|
|
1299
|
+
id: z4.string().nullish(),
|
|
1300
|
+
created: z4.number().nullish(),
|
|
1301
|
+
model: z4.string().nullish(),
|
|
1302
|
+
choices: z4.array(
|
|
1303
|
+
z4.object({
|
|
1304
|
+
text: z4.string(),
|
|
1305
|
+
finish_reason: z4.string(),
|
|
1306
|
+
logprobs: z4.object({
|
|
1307
|
+
tokens: z4.array(z4.string()),
|
|
1308
|
+
token_logprobs: z4.array(z4.number()),
|
|
1309
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1305
1310
|
}).nullish()
|
|
1306
1311
|
})
|
|
1307
1312
|
),
|
|
1308
|
-
usage:
|
|
1309
|
-
prompt_tokens:
|
|
1310
|
-
completion_tokens:
|
|
1311
|
-
total_tokens:
|
|
1313
|
+
usage: z4.object({
|
|
1314
|
+
prompt_tokens: z4.number(),
|
|
1315
|
+
completion_tokens: z4.number(),
|
|
1316
|
+
total_tokens: z4.number()
|
|
1312
1317
|
}).nullish()
|
|
1313
1318
|
})
|
|
1314
1319
|
)
|
|
1315
1320
|
);
|
|
1316
|
-
var openaiCompletionChunkSchema = (
|
|
1317
|
-
() => (
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
id:
|
|
1321
|
-
created:
|
|
1322
|
-
model:
|
|
1323
|
-
choices:
|
|
1324
|
-
|
|
1325
|
-
text:
|
|
1326
|
-
finish_reason:
|
|
1327
|
-
index:
|
|
1328
|
-
logprobs:
|
|
1329
|
-
tokens:
|
|
1330
|
-
token_logprobs:
|
|
1331
|
-
top_logprobs:
|
|
1321
|
+
var openaiCompletionChunkSchema = lazySchema3(
|
|
1322
|
+
() => zodSchema3(
|
|
1323
|
+
z4.union([
|
|
1324
|
+
z4.object({
|
|
1325
|
+
id: z4.string().nullish(),
|
|
1326
|
+
created: z4.number().nullish(),
|
|
1327
|
+
model: z4.string().nullish(),
|
|
1328
|
+
choices: z4.array(
|
|
1329
|
+
z4.object({
|
|
1330
|
+
text: z4.string(),
|
|
1331
|
+
finish_reason: z4.string().nullish(),
|
|
1332
|
+
index: z4.number(),
|
|
1333
|
+
logprobs: z4.object({
|
|
1334
|
+
tokens: z4.array(z4.string()),
|
|
1335
|
+
token_logprobs: z4.array(z4.number()),
|
|
1336
|
+
top_logprobs: z4.array(z4.record(z4.string(), z4.number())).nullish()
|
|
1332
1337
|
}).nullish()
|
|
1333
1338
|
})
|
|
1334
1339
|
),
|
|
1335
|
-
usage:
|
|
1336
|
-
prompt_tokens:
|
|
1337
|
-
completion_tokens:
|
|
1338
|
-
total_tokens:
|
|
1340
|
+
usage: z4.object({
|
|
1341
|
+
prompt_tokens: z4.number(),
|
|
1342
|
+
completion_tokens: z4.number(),
|
|
1343
|
+
total_tokens: z4.number()
|
|
1339
1344
|
}).nullish()
|
|
1340
1345
|
}),
|
|
1341
1346
|
openaiErrorDataSchema
|
|
@@ -1344,15 +1349,15 @@ var openaiCompletionChunkSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1344
1349
|
);
|
|
1345
1350
|
|
|
1346
1351
|
// src/completion/openai-completion-options.ts
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
var openaiLanguageModelCompletionOptions = (
|
|
1350
|
-
() => (
|
|
1351
|
-
|
|
1352
|
+
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
1353
|
+
import { z as z5 } from "zod/v4";
|
|
1354
|
+
var openaiLanguageModelCompletionOptions = lazySchema4(
|
|
1355
|
+
() => zodSchema4(
|
|
1356
|
+
z5.object({
|
|
1352
1357
|
/**
|
|
1353
1358
|
* Echo back the prompt in addition to the completion.
|
|
1354
1359
|
*/
|
|
1355
|
-
echo:
|
|
1360
|
+
echo: z5.boolean().optional(),
|
|
1356
1361
|
/**
|
|
1357
1362
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
1358
1363
|
*
|
|
@@ -1367,16 +1372,16 @@ var openaiLanguageModelCompletionOptions = (0, import_provider_utils7.lazySchema
|
|
|
1367
1372
|
* As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
1368
1373
|
* token from being generated.
|
|
1369
1374
|
*/
|
|
1370
|
-
logitBias:
|
|
1375
|
+
logitBias: z5.record(z5.string(), z5.number()).optional(),
|
|
1371
1376
|
/**
|
|
1372
1377
|
* The suffix that comes after a completion of inserted text.
|
|
1373
1378
|
*/
|
|
1374
|
-
suffix:
|
|
1379
|
+
suffix: z5.string().optional(),
|
|
1375
1380
|
/**
|
|
1376
1381
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
1377
1382
|
* monitor and detect abuse. Learn more.
|
|
1378
1383
|
*/
|
|
1379
|
-
user:
|
|
1384
|
+
user: z5.string().optional(),
|
|
1380
1385
|
/**
|
|
1381
1386
|
* Return the log probabilities of the tokens. Including logprobs will increase
|
|
1382
1387
|
* the response size and can slow down response times. However, it can
|
|
@@ -1386,7 +1391,7 @@ var openaiLanguageModelCompletionOptions = (0, import_provider_utils7.lazySchema
|
|
|
1386
1391
|
* Setting to a number will return the log probabilities of the top n
|
|
1387
1392
|
* tokens that were generated.
|
|
1388
1393
|
*/
|
|
1389
|
-
logprobs:
|
|
1394
|
+
logprobs: z5.union([z5.boolean(), z5.number()]).optional()
|
|
1390
1395
|
})
|
|
1391
1396
|
)
|
|
1392
1397
|
);
|
|
@@ -1424,12 +1429,12 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1424
1429
|
}) {
|
|
1425
1430
|
const warnings = [];
|
|
1426
1431
|
const openaiOptions = {
|
|
1427
|
-
...await (
|
|
1432
|
+
...await parseProviderOptions2({
|
|
1428
1433
|
provider: "openai",
|
|
1429
1434
|
providerOptions,
|
|
1430
1435
|
schema: openaiLanguageModelCompletionOptions
|
|
1431
1436
|
}),
|
|
1432
|
-
...await (
|
|
1437
|
+
...await parseProviderOptions2({
|
|
1433
1438
|
provider: this.providerOptionsName,
|
|
1434
1439
|
providerOptions,
|
|
1435
1440
|
schema: openaiLanguageModelCompletionOptions
|
|
@@ -1485,15 +1490,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1485
1490
|
responseHeaders,
|
|
1486
1491
|
value: response,
|
|
1487
1492
|
rawValue: rawResponse
|
|
1488
|
-
} = await (
|
|
1493
|
+
} = await postJsonToApi2({
|
|
1489
1494
|
url: this.config.url({
|
|
1490
1495
|
path: "/completions",
|
|
1491
1496
|
modelId: this.modelId
|
|
1492
1497
|
}),
|
|
1493
|
-
headers: (
|
|
1498
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
1494
1499
|
body: args,
|
|
1495
1500
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1496
|
-
successfulResponseHandler: (
|
|
1501
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
1497
1502
|
openaiCompletionResponseSchema
|
|
1498
1503
|
),
|
|
1499
1504
|
abortSignal: options.abortSignal,
|
|
@@ -1530,15 +1535,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1530
1535
|
include_usage: true
|
|
1531
1536
|
}
|
|
1532
1537
|
};
|
|
1533
|
-
const { responseHeaders, value: response } = await (
|
|
1538
|
+
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
1534
1539
|
url: this.config.url({
|
|
1535
1540
|
path: "/completions",
|
|
1536
1541
|
modelId: this.modelId
|
|
1537
1542
|
}),
|
|
1538
|
-
headers: (
|
|
1543
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
1539
1544
|
body,
|
|
1540
1545
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1541
|
-
successfulResponseHandler: (
|
|
1546
|
+
successfulResponseHandler: createEventSourceResponseHandler2(
|
|
1542
1547
|
openaiCompletionChunkSchema
|
|
1543
1548
|
),
|
|
1544
1549
|
abortSignal: options.abortSignal,
|
|
@@ -1621,37 +1626,44 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1621
1626
|
};
|
|
1622
1627
|
|
|
1623
1628
|
// src/embedding/openai-embedding-model.ts
|
|
1624
|
-
|
|
1625
|
-
|
|
1629
|
+
import {
|
|
1630
|
+
TooManyEmbeddingValuesForCallError
|
|
1631
|
+
} from "@ai-sdk/provider";
|
|
1632
|
+
import {
|
|
1633
|
+
combineHeaders as combineHeaders3,
|
|
1634
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1635
|
+
parseProviderOptions as parseProviderOptions3,
|
|
1636
|
+
postJsonToApi as postJsonToApi3
|
|
1637
|
+
} from "@ai-sdk/provider-utils";
|
|
1626
1638
|
|
|
1627
1639
|
// src/embedding/openai-embedding-options.ts
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
var openaiEmbeddingModelOptions = (
|
|
1631
|
-
() => (
|
|
1632
|
-
|
|
1640
|
+
import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
|
|
1641
|
+
import { z as z6 } from "zod/v4";
|
|
1642
|
+
var openaiEmbeddingModelOptions = lazySchema5(
|
|
1643
|
+
() => zodSchema5(
|
|
1644
|
+
z6.object({
|
|
1633
1645
|
/**
|
|
1634
1646
|
* The number of dimensions the resulting output embeddings should have.
|
|
1635
1647
|
* Only supported in text-embedding-3 and later models.
|
|
1636
1648
|
*/
|
|
1637
|
-
dimensions:
|
|
1649
|
+
dimensions: z6.number().optional(),
|
|
1638
1650
|
/**
|
|
1639
1651
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
1640
1652
|
* monitor and detect abuse. Learn more.
|
|
1641
1653
|
*/
|
|
1642
|
-
user:
|
|
1654
|
+
user: z6.string().optional()
|
|
1643
1655
|
})
|
|
1644
1656
|
)
|
|
1645
1657
|
);
|
|
1646
1658
|
|
|
1647
1659
|
// src/embedding/openai-embedding-api.ts
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
var openaiTextEmbeddingResponseSchema = (
|
|
1651
|
-
() => (
|
|
1652
|
-
|
|
1653
|
-
data:
|
|
1654
|
-
usage:
|
|
1660
|
+
import { lazySchema as lazySchema6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
|
|
1661
|
+
import { z as z7 } from "zod/v4";
|
|
1662
|
+
var openaiTextEmbeddingResponseSchema = lazySchema6(
|
|
1663
|
+
() => zodSchema6(
|
|
1664
|
+
z7.object({
|
|
1665
|
+
data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
|
|
1666
|
+
usage: z7.object({ prompt_tokens: z7.number() }).nullish()
|
|
1655
1667
|
})
|
|
1656
1668
|
)
|
|
1657
1669
|
);
|
|
@@ -1676,14 +1688,14 @@ var OpenAIEmbeddingModel = class {
|
|
|
1676
1688
|
}) {
|
|
1677
1689
|
var _a;
|
|
1678
1690
|
if (values.length > this.maxEmbeddingsPerCall) {
|
|
1679
|
-
throw new
|
|
1691
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
1680
1692
|
provider: this.provider,
|
|
1681
1693
|
modelId: this.modelId,
|
|
1682
1694
|
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
1683
1695
|
values
|
|
1684
1696
|
});
|
|
1685
1697
|
}
|
|
1686
|
-
const openaiOptions = (_a = await (
|
|
1698
|
+
const openaiOptions = (_a = await parseProviderOptions3({
|
|
1687
1699
|
provider: "openai",
|
|
1688
1700
|
providerOptions,
|
|
1689
1701
|
schema: openaiEmbeddingModelOptions
|
|
@@ -1692,12 +1704,12 @@ var OpenAIEmbeddingModel = class {
|
|
|
1692
1704
|
responseHeaders,
|
|
1693
1705
|
value: response,
|
|
1694
1706
|
rawValue
|
|
1695
|
-
} = await (
|
|
1707
|
+
} = await postJsonToApi3({
|
|
1696
1708
|
url: this.config.url({
|
|
1697
1709
|
path: "/embeddings",
|
|
1698
1710
|
modelId: this.modelId
|
|
1699
1711
|
}),
|
|
1700
|
-
headers: (
|
|
1712
|
+
headers: combineHeaders3(this.config.headers(), headers),
|
|
1701
1713
|
body: {
|
|
1702
1714
|
model: this.modelId,
|
|
1703
1715
|
input: values,
|
|
@@ -1706,7 +1718,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1706
1718
|
user: openaiOptions.user
|
|
1707
1719
|
},
|
|
1708
1720
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1709
|
-
successfulResponseHandler: (
|
|
1721
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
1710
1722
|
openaiTextEmbeddingResponseSchema
|
|
1711
1723
|
),
|
|
1712
1724
|
abortSignal,
|
|
@@ -1722,39 +1734,45 @@ var OpenAIEmbeddingModel = class {
|
|
|
1722
1734
|
};
|
|
1723
1735
|
|
|
1724
1736
|
// src/files/openai-files.ts
|
|
1725
|
-
|
|
1737
|
+
import {
|
|
1738
|
+
combineHeaders as combineHeaders4,
|
|
1739
|
+
convertBase64ToUint8Array,
|
|
1740
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1741
|
+
parseProviderOptions as parseProviderOptions4,
|
|
1742
|
+
postFormDataToApi
|
|
1743
|
+
} from "@ai-sdk/provider-utils";
|
|
1726
1744
|
|
|
1727
1745
|
// src/files/openai-files-api.ts
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
var openaiFilesResponseSchema = (
|
|
1731
|
-
() => (
|
|
1732
|
-
|
|
1733
|
-
id:
|
|
1734
|
-
object:
|
|
1735
|
-
bytes:
|
|
1736
|
-
created_at:
|
|
1737
|
-
filename:
|
|
1738
|
-
purpose:
|
|
1739
|
-
status:
|
|
1740
|
-
expires_at:
|
|
1746
|
+
import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
|
|
1747
|
+
import { z as z8 } from "zod/v4";
|
|
1748
|
+
var openaiFilesResponseSchema = lazySchema7(
|
|
1749
|
+
() => zodSchema7(
|
|
1750
|
+
z8.object({
|
|
1751
|
+
id: z8.string(),
|
|
1752
|
+
object: z8.string().nullish(),
|
|
1753
|
+
bytes: z8.number().nullish(),
|
|
1754
|
+
created_at: z8.number().nullish(),
|
|
1755
|
+
filename: z8.string().nullish(),
|
|
1756
|
+
purpose: z8.string().nullish(),
|
|
1757
|
+
status: z8.string().nullish(),
|
|
1758
|
+
expires_at: z8.number().nullish()
|
|
1741
1759
|
})
|
|
1742
1760
|
)
|
|
1743
1761
|
);
|
|
1744
1762
|
|
|
1745
1763
|
// src/files/openai-files-options.ts
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
var openaiFilesOptionsSchema = (
|
|
1749
|
-
() => (
|
|
1750
|
-
|
|
1764
|
+
import { lazySchema as lazySchema8, zodSchema as zodSchema8 } from "@ai-sdk/provider-utils";
|
|
1765
|
+
import { z as z9 } from "zod/v4";
|
|
1766
|
+
var openaiFilesOptionsSchema = lazySchema8(
|
|
1767
|
+
() => zodSchema8(
|
|
1768
|
+
z9.object({
|
|
1751
1769
|
/*
|
|
1752
1770
|
* Required by the OpenAI API, but optional here because
|
|
1753
1771
|
* the SDK defaults to "assistants" — by far the most common
|
|
1754
1772
|
* purpose when uploading files in this context.
|
|
1755
1773
|
*/
|
|
1756
|
-
purpose:
|
|
1757
|
-
expiresAfter:
|
|
1774
|
+
purpose: z9.string().optional(),
|
|
1775
|
+
expiresAfter: z9.number().optional()
|
|
1758
1776
|
})
|
|
1759
1777
|
)
|
|
1760
1778
|
);
|
|
@@ -1775,12 +1793,12 @@ var OpenAIFiles = class {
|
|
|
1775
1793
|
providerOptions
|
|
1776
1794
|
}) {
|
|
1777
1795
|
var _a, _b, _c;
|
|
1778
|
-
const openaiOptions = await (
|
|
1796
|
+
const openaiOptions = await parseProviderOptions4({
|
|
1779
1797
|
provider: "openai",
|
|
1780
1798
|
providerOptions,
|
|
1781
1799
|
schema: openaiFilesOptionsSchema
|
|
1782
1800
|
});
|
|
1783
|
-
const fileBytes = data instanceof Uint8Array ? data :
|
|
1801
|
+
const fileBytes = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
|
|
1784
1802
|
const blob = new Blob([fileBytes], {
|
|
1785
1803
|
type: mediaType
|
|
1786
1804
|
});
|
|
@@ -1794,12 +1812,12 @@ var OpenAIFiles = class {
|
|
|
1794
1812
|
if ((openaiOptions == null ? void 0 : openaiOptions.expiresAfter) != null) {
|
|
1795
1813
|
formData.append("expires_after", String(openaiOptions.expiresAfter));
|
|
1796
1814
|
}
|
|
1797
|
-
const { value: response } = await
|
|
1815
|
+
const { value: response } = await postFormDataToApi({
|
|
1798
1816
|
url: `${this.config.baseURL}/files`,
|
|
1799
|
-
headers: (
|
|
1817
|
+
headers: combineHeaders4(this.config.headers()),
|
|
1800
1818
|
formData,
|
|
1801
1819
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1802
|
-
successfulResponseHandler: (
|
|
1820
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
1803
1821
|
openaiFilesResponseSchema
|
|
1804
1822
|
),
|
|
1805
1823
|
fetch: this.config.fetch
|
|
@@ -1824,32 +1842,40 @@ var OpenAIFiles = class {
|
|
|
1824
1842
|
};
|
|
1825
1843
|
|
|
1826
1844
|
// src/image/openai-image-model.ts
|
|
1827
|
-
|
|
1845
|
+
import {
|
|
1846
|
+
combineHeaders as combineHeaders5,
|
|
1847
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
1848
|
+
convertToFormData,
|
|
1849
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
1850
|
+
downloadBlob,
|
|
1851
|
+
postFormDataToApi as postFormDataToApi2,
|
|
1852
|
+
postJsonToApi as postJsonToApi4
|
|
1853
|
+
} from "@ai-sdk/provider-utils";
|
|
1828
1854
|
|
|
1829
1855
|
// src/image/openai-image-api.ts
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
var openaiImageResponseSchema = (
|
|
1833
|
-
() => (
|
|
1834
|
-
|
|
1835
|
-
created:
|
|
1836
|
-
data:
|
|
1837
|
-
|
|
1838
|
-
b64_json:
|
|
1839
|
-
revised_prompt:
|
|
1856
|
+
import { lazySchema as lazySchema9, zodSchema as zodSchema9 } from "@ai-sdk/provider-utils";
|
|
1857
|
+
import { z as z10 } from "zod/v4";
|
|
1858
|
+
var openaiImageResponseSchema = lazySchema9(
|
|
1859
|
+
() => zodSchema9(
|
|
1860
|
+
z10.object({
|
|
1861
|
+
created: z10.number().nullish(),
|
|
1862
|
+
data: z10.array(
|
|
1863
|
+
z10.object({
|
|
1864
|
+
b64_json: z10.string(),
|
|
1865
|
+
revised_prompt: z10.string().nullish()
|
|
1840
1866
|
})
|
|
1841
1867
|
),
|
|
1842
|
-
background:
|
|
1843
|
-
output_format:
|
|
1844
|
-
size:
|
|
1845
|
-
quality:
|
|
1846
|
-
usage:
|
|
1847
|
-
input_tokens:
|
|
1848
|
-
output_tokens:
|
|
1849
|
-
total_tokens:
|
|
1850
|
-
input_tokens_details:
|
|
1851
|
-
image_tokens:
|
|
1852
|
-
text_tokens:
|
|
1868
|
+
background: z10.string().nullish(),
|
|
1869
|
+
output_format: z10.string().nullish(),
|
|
1870
|
+
size: z10.string().nullish(),
|
|
1871
|
+
quality: z10.string().nullish(),
|
|
1872
|
+
usage: z10.object({
|
|
1873
|
+
input_tokens: z10.number().nullish(),
|
|
1874
|
+
output_tokens: z10.number().nullish(),
|
|
1875
|
+
total_tokens: z10.number().nullish(),
|
|
1876
|
+
input_tokens_details: z10.object({
|
|
1877
|
+
image_tokens: z10.number().nullish(),
|
|
1878
|
+
text_tokens: z10.number().nullish()
|
|
1853
1879
|
}).nullish()
|
|
1854
1880
|
}).nullish()
|
|
1855
1881
|
})
|
|
@@ -1917,13 +1943,13 @@ var OpenAIImageModel = class {
|
|
|
1917
1943
|
}
|
|
1918
1944
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1919
1945
|
if (files != null) {
|
|
1920
|
-
const { value: response2, responseHeaders: responseHeaders2 } = await (
|
|
1946
|
+
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi2({
|
|
1921
1947
|
url: this.config.url({
|
|
1922
1948
|
path: "/images/edits",
|
|
1923
1949
|
modelId: this.modelId
|
|
1924
1950
|
}),
|
|
1925
|
-
headers: (
|
|
1926
|
-
formData:
|
|
1951
|
+
headers: combineHeaders5(this.config.headers(), headers),
|
|
1952
|
+
formData: convertToFormData({
|
|
1927
1953
|
model: this.modelId,
|
|
1928
1954
|
prompt,
|
|
1929
1955
|
image: await Promise.all(
|
|
@@ -1932,12 +1958,12 @@ var OpenAIImageModel = class {
|
|
|
1932
1958
|
[
|
|
1933
1959
|
file.data instanceof Uint8Array ? new Blob([file.data], {
|
|
1934
1960
|
type: file.mediaType
|
|
1935
|
-
}) : new Blob([(
|
|
1961
|
+
}) : new Blob([convertBase64ToUint8Array2(file.data)], {
|
|
1936
1962
|
type: file.mediaType
|
|
1937
1963
|
})
|
|
1938
1964
|
],
|
|
1939
1965
|
{ type: file.mediaType }
|
|
1940
|
-
) :
|
|
1966
|
+
) : downloadBlob(file.url)
|
|
1941
1967
|
)
|
|
1942
1968
|
),
|
|
1943
1969
|
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
@@ -1946,7 +1972,7 @@ var OpenAIImageModel = class {
|
|
|
1946
1972
|
...(_d = providerOptions.openai) != null ? _d : {}
|
|
1947
1973
|
}),
|
|
1948
1974
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1949
|
-
successfulResponseHandler: (
|
|
1975
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
1950
1976
|
openaiImageResponseSchema
|
|
1951
1977
|
),
|
|
1952
1978
|
abortSignal,
|
|
@@ -1987,12 +2013,12 @@ var OpenAIImageModel = class {
|
|
|
1987
2013
|
}
|
|
1988
2014
|
};
|
|
1989
2015
|
}
|
|
1990
|
-
const { value: response, responseHeaders } = await (
|
|
2016
|
+
const { value: response, responseHeaders } = await postJsonToApi4({
|
|
1991
2017
|
url: this.config.url({
|
|
1992
2018
|
path: "/images/generations",
|
|
1993
2019
|
modelId: this.modelId
|
|
1994
2020
|
}),
|
|
1995
|
-
headers: (
|
|
2021
|
+
headers: combineHeaders5(this.config.headers(), headers),
|
|
1996
2022
|
body: {
|
|
1997
2023
|
model: this.modelId,
|
|
1998
2024
|
prompt,
|
|
@@ -2002,7 +2028,7 @@ var OpenAIImageModel = class {
|
|
|
2002
2028
|
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
2003
2029
|
},
|
|
2004
2030
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2005
|
-
successfulResponseHandler: (
|
|
2031
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
2006
2032
|
openaiImageResponseSchema
|
|
2007
2033
|
),
|
|
2008
2034
|
abortSignal,
|
|
@@ -2064,48 +2090,52 @@ function distributeTokenDetails(details, index, total) {
|
|
|
2064
2090
|
async function fileToBlob(file) {
|
|
2065
2091
|
if (!file) return void 0;
|
|
2066
2092
|
if (file.type === "url") {
|
|
2067
|
-
return
|
|
2093
|
+
return downloadBlob(file.url);
|
|
2068
2094
|
}
|
|
2069
|
-
const data = file.data instanceof Uint8Array ? file.data : (
|
|
2095
|
+
const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array2(file.data);
|
|
2070
2096
|
return new Blob([data], { type: file.mediaType });
|
|
2071
2097
|
}
|
|
2072
2098
|
|
|
2073
2099
|
// src/tool/apply-patch.ts
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2100
|
+
import {
|
|
2101
|
+
createProviderToolFactoryWithOutputSchema,
|
|
2102
|
+
lazySchema as lazySchema10,
|
|
2103
|
+
zodSchema as zodSchema10
|
|
2104
|
+
} from "@ai-sdk/provider-utils";
|
|
2105
|
+
import { z as z11 } from "zod/v4";
|
|
2106
|
+
var applyPatchInputSchema = lazySchema10(
|
|
2107
|
+
() => zodSchema10(
|
|
2108
|
+
z11.object({
|
|
2109
|
+
callId: z11.string(),
|
|
2110
|
+
operation: z11.discriminatedUnion("type", [
|
|
2111
|
+
z11.object({
|
|
2112
|
+
type: z11.literal("create_file"),
|
|
2113
|
+
path: z11.string(),
|
|
2114
|
+
diff: z11.string()
|
|
2085
2115
|
}),
|
|
2086
|
-
|
|
2087
|
-
type:
|
|
2088
|
-
path:
|
|
2116
|
+
z11.object({
|
|
2117
|
+
type: z11.literal("delete_file"),
|
|
2118
|
+
path: z11.string()
|
|
2089
2119
|
}),
|
|
2090
|
-
|
|
2091
|
-
type:
|
|
2092
|
-
path:
|
|
2093
|
-
diff:
|
|
2120
|
+
z11.object({
|
|
2121
|
+
type: z11.literal("update_file"),
|
|
2122
|
+
path: z11.string(),
|
|
2123
|
+
diff: z11.string()
|
|
2094
2124
|
})
|
|
2095
2125
|
])
|
|
2096
2126
|
})
|
|
2097
2127
|
)
|
|
2098
2128
|
);
|
|
2099
|
-
var applyPatchOutputSchema = (
|
|
2100
|
-
() => (
|
|
2101
|
-
|
|
2102
|
-
status:
|
|
2103
|
-
output:
|
|
2129
|
+
var applyPatchOutputSchema = lazySchema10(
|
|
2130
|
+
() => zodSchema10(
|
|
2131
|
+
z11.object({
|
|
2132
|
+
status: z11.enum(["completed", "failed"]),
|
|
2133
|
+
output: z11.string().optional()
|
|
2104
2134
|
})
|
|
2105
2135
|
)
|
|
2106
2136
|
);
|
|
2107
|
-
var applyPatchArgsSchema = (
|
|
2108
|
-
var applyPatchToolFactory =
|
|
2137
|
+
var applyPatchArgsSchema = lazySchema10(() => zodSchema10(z11.object({})));
|
|
2138
|
+
var applyPatchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
2109
2139
|
id: "openai.apply_patch",
|
|
2110
2140
|
inputSchema: applyPatchInputSchema,
|
|
2111
2141
|
outputSchema: applyPatchOutputSchema
|
|
@@ -2113,41 +2143,45 @@ var applyPatchToolFactory = (0, import_provider_utils17.createProviderToolFactor
|
|
|
2113
2143
|
var applyPatch = applyPatchToolFactory;
|
|
2114
2144
|
|
|
2115
2145
|
// src/tool/code-interpreter.ts
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2146
|
+
import {
|
|
2147
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
2148
|
+
lazySchema as lazySchema11,
|
|
2149
|
+
zodSchema as zodSchema11
|
|
2150
|
+
} from "@ai-sdk/provider-utils";
|
|
2151
|
+
import { z as z12 } from "zod/v4";
|
|
2152
|
+
var codeInterpreterInputSchema = lazySchema11(
|
|
2153
|
+
() => zodSchema11(
|
|
2154
|
+
z12.object({
|
|
2155
|
+
code: z12.string().nullish(),
|
|
2156
|
+
containerId: z12.string()
|
|
2123
2157
|
})
|
|
2124
2158
|
)
|
|
2125
2159
|
);
|
|
2126
|
-
var codeInterpreterOutputSchema = (
|
|
2127
|
-
() => (
|
|
2128
|
-
|
|
2129
|
-
outputs:
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2160
|
+
var codeInterpreterOutputSchema = lazySchema11(
|
|
2161
|
+
() => zodSchema11(
|
|
2162
|
+
z12.object({
|
|
2163
|
+
outputs: z12.array(
|
|
2164
|
+
z12.discriminatedUnion("type", [
|
|
2165
|
+
z12.object({ type: z12.literal("logs"), logs: z12.string() }),
|
|
2166
|
+
z12.object({ type: z12.literal("image"), url: z12.string() })
|
|
2133
2167
|
])
|
|
2134
2168
|
).nullish()
|
|
2135
2169
|
})
|
|
2136
2170
|
)
|
|
2137
2171
|
);
|
|
2138
|
-
var codeInterpreterArgsSchema = (
|
|
2139
|
-
() => (
|
|
2140
|
-
|
|
2141
|
-
container:
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
fileIds:
|
|
2172
|
+
var codeInterpreterArgsSchema = lazySchema11(
|
|
2173
|
+
() => zodSchema11(
|
|
2174
|
+
z12.object({
|
|
2175
|
+
container: z12.union([
|
|
2176
|
+
z12.string(),
|
|
2177
|
+
z12.object({
|
|
2178
|
+
fileIds: z12.array(z12.string()).optional()
|
|
2145
2179
|
})
|
|
2146
2180
|
]).optional()
|
|
2147
2181
|
})
|
|
2148
2182
|
)
|
|
2149
2183
|
);
|
|
2150
|
-
var codeInterpreterToolFactory = (
|
|
2184
|
+
var codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema2({
|
|
2151
2185
|
id: "openai.code_interpreter",
|
|
2152
2186
|
inputSchema: codeInterpreterInputSchema,
|
|
2153
2187
|
outputSchema: codeInterpreterOutputSchema
|
|
@@ -2157,108 +2191,120 @@ var codeInterpreter = (args = {}) => {
|
|
|
2157
2191
|
};
|
|
2158
2192
|
|
|
2159
2193
|
// src/tool/custom.ts
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2194
|
+
import {
|
|
2195
|
+
createProviderToolFactory,
|
|
2196
|
+
lazySchema as lazySchema12,
|
|
2197
|
+
zodSchema as zodSchema12
|
|
2198
|
+
} from "@ai-sdk/provider-utils";
|
|
2199
|
+
import { z as z13 } from "zod/v4";
|
|
2200
|
+
var customArgsSchema = lazySchema12(
|
|
2201
|
+
() => zodSchema12(
|
|
2202
|
+
z13.object({
|
|
2203
|
+
description: z13.string().optional(),
|
|
2204
|
+
format: z13.union([
|
|
2205
|
+
z13.object({
|
|
2206
|
+
type: z13.literal("grammar"),
|
|
2207
|
+
syntax: z13.enum(["regex", "lark"]),
|
|
2208
|
+
definition: z13.string()
|
|
2171
2209
|
}),
|
|
2172
|
-
|
|
2173
|
-
type:
|
|
2210
|
+
z13.object({
|
|
2211
|
+
type: z13.literal("text")
|
|
2174
2212
|
})
|
|
2175
2213
|
]).optional()
|
|
2176
2214
|
})
|
|
2177
2215
|
)
|
|
2178
2216
|
);
|
|
2179
|
-
var customInputSchema = (
|
|
2180
|
-
var customToolFactory =
|
|
2217
|
+
var customInputSchema = lazySchema12(() => zodSchema12(z13.string()));
|
|
2218
|
+
var customToolFactory = createProviderToolFactory({
|
|
2181
2219
|
id: "openai.custom",
|
|
2182
2220
|
inputSchema: customInputSchema
|
|
2183
2221
|
});
|
|
2184
2222
|
var customTool = (args) => customToolFactory(args);
|
|
2185
2223
|
|
|
2186
2224
|
// src/tool/file-search.ts
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2225
|
+
import {
|
|
2226
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
2227
|
+
lazySchema as lazySchema13,
|
|
2228
|
+
zodSchema as zodSchema13
|
|
2229
|
+
} from "@ai-sdk/provider-utils";
|
|
2230
|
+
import { z as z14 } from "zod/v4";
|
|
2231
|
+
var comparisonFilterSchema = z14.object({
|
|
2232
|
+
key: z14.string(),
|
|
2233
|
+
type: z14.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
|
|
2234
|
+
value: z14.union([z14.string(), z14.number(), z14.boolean(), z14.array(z14.string())])
|
|
2193
2235
|
});
|
|
2194
|
-
var compoundFilterSchema =
|
|
2195
|
-
type:
|
|
2196
|
-
filters:
|
|
2197
|
-
|
|
2236
|
+
var compoundFilterSchema = z14.object({
|
|
2237
|
+
type: z14.enum(["and", "or"]),
|
|
2238
|
+
filters: z14.array(
|
|
2239
|
+
z14.union([comparisonFilterSchema, z14.lazy(() => compoundFilterSchema)])
|
|
2198
2240
|
)
|
|
2199
2241
|
});
|
|
2200
|
-
var fileSearchArgsSchema = (
|
|
2201
|
-
() => (
|
|
2202
|
-
|
|
2203
|
-
vectorStoreIds:
|
|
2204
|
-
maxNumResults:
|
|
2205
|
-
ranking:
|
|
2206
|
-
ranker:
|
|
2207
|
-
scoreThreshold:
|
|
2242
|
+
var fileSearchArgsSchema = lazySchema13(
|
|
2243
|
+
() => zodSchema13(
|
|
2244
|
+
z14.object({
|
|
2245
|
+
vectorStoreIds: z14.array(z14.string()),
|
|
2246
|
+
maxNumResults: z14.number().optional(),
|
|
2247
|
+
ranking: z14.object({
|
|
2248
|
+
ranker: z14.string().optional(),
|
|
2249
|
+
scoreThreshold: z14.number().optional()
|
|
2208
2250
|
}).optional(),
|
|
2209
|
-
filters:
|
|
2251
|
+
filters: z14.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
2210
2252
|
})
|
|
2211
2253
|
)
|
|
2212
2254
|
);
|
|
2213
|
-
var fileSearchOutputSchema = (
|
|
2214
|
-
() => (
|
|
2215
|
-
|
|
2216
|
-
queries:
|
|
2217
|
-
results:
|
|
2218
|
-
|
|
2219
|
-
attributes:
|
|
2220
|
-
fileId:
|
|
2221
|
-
filename:
|
|
2222
|
-
score:
|
|
2223
|
-
text:
|
|
2255
|
+
var fileSearchOutputSchema = lazySchema13(
|
|
2256
|
+
() => zodSchema13(
|
|
2257
|
+
z14.object({
|
|
2258
|
+
queries: z14.array(z14.string()),
|
|
2259
|
+
results: z14.array(
|
|
2260
|
+
z14.object({
|
|
2261
|
+
attributes: z14.record(z14.string(), z14.unknown()),
|
|
2262
|
+
fileId: z14.string(),
|
|
2263
|
+
filename: z14.string(),
|
|
2264
|
+
score: z14.number(),
|
|
2265
|
+
text: z14.string()
|
|
2224
2266
|
})
|
|
2225
2267
|
).nullable()
|
|
2226
2268
|
})
|
|
2227
2269
|
)
|
|
2228
2270
|
);
|
|
2229
|
-
var fileSearch = (
|
|
2271
|
+
var fileSearch = createProviderToolFactoryWithOutputSchema3({
|
|
2230
2272
|
id: "openai.file_search",
|
|
2231
|
-
inputSchema:
|
|
2273
|
+
inputSchema: z14.object({}),
|
|
2232
2274
|
outputSchema: fileSearchOutputSchema
|
|
2233
2275
|
});
|
|
2234
2276
|
|
|
2235
2277
|
// src/tool/image-generation.ts
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2278
|
+
import {
|
|
2279
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
2280
|
+
lazySchema as lazySchema14,
|
|
2281
|
+
zodSchema as zodSchema14
|
|
2282
|
+
} from "@ai-sdk/provider-utils";
|
|
2283
|
+
import { z as z15 } from "zod/v4";
|
|
2284
|
+
var imageGenerationArgsSchema = lazySchema14(
|
|
2285
|
+
() => zodSchema14(
|
|
2286
|
+
z15.object({
|
|
2287
|
+
background: z15.enum(["auto", "opaque", "transparent"]).optional(),
|
|
2288
|
+
inputFidelity: z15.enum(["low", "high"]).optional(),
|
|
2289
|
+
inputImageMask: z15.object({
|
|
2290
|
+
fileId: z15.string().optional(),
|
|
2291
|
+
imageUrl: z15.string().optional()
|
|
2246
2292
|
}).optional(),
|
|
2247
|
-
model:
|
|
2248
|
-
moderation:
|
|
2249
|
-
outputCompression:
|
|
2250
|
-
outputFormat:
|
|
2251
|
-
partialImages:
|
|
2252
|
-
quality:
|
|
2253
|
-
size:
|
|
2293
|
+
model: z15.string().optional(),
|
|
2294
|
+
moderation: z15.enum(["auto"]).optional(),
|
|
2295
|
+
outputCompression: z15.number().int().min(0).max(100).optional(),
|
|
2296
|
+
outputFormat: z15.enum(["png", "jpeg", "webp"]).optional(),
|
|
2297
|
+
partialImages: z15.number().int().min(0).max(3).optional(),
|
|
2298
|
+
quality: z15.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2299
|
+
size: z15.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
2254
2300
|
}).strict()
|
|
2255
2301
|
)
|
|
2256
2302
|
);
|
|
2257
|
-
var imageGenerationInputSchema = (
|
|
2258
|
-
var imageGenerationOutputSchema = (
|
|
2259
|
-
() => (
|
|
2303
|
+
var imageGenerationInputSchema = lazySchema14(() => zodSchema14(z15.object({})));
|
|
2304
|
+
var imageGenerationOutputSchema = lazySchema14(
|
|
2305
|
+
() => zodSchema14(z15.object({ result: z15.string() }))
|
|
2260
2306
|
);
|
|
2261
|
-
var imageGenerationToolFactory = (
|
|
2307
|
+
var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema4({
|
|
2262
2308
|
id: "openai.image_generation",
|
|
2263
2309
|
inputSchema: imageGenerationInputSchema,
|
|
2264
2310
|
outputSchema: imageGenerationOutputSchema
|
|
@@ -2268,115 +2314,123 @@ var imageGeneration = (args = {}) => {
|
|
|
2268
2314
|
};
|
|
2269
2315
|
|
|
2270
2316
|
// src/tool/local-shell.ts
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2317
|
+
import {
|
|
2318
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
2319
|
+
lazySchema as lazySchema15,
|
|
2320
|
+
zodSchema as zodSchema15
|
|
2321
|
+
} from "@ai-sdk/provider-utils";
|
|
2322
|
+
import { z as z16 } from "zod/v4";
|
|
2323
|
+
var localShellInputSchema = lazySchema15(
|
|
2324
|
+
() => zodSchema15(
|
|
2325
|
+
z16.object({
|
|
2326
|
+
action: z16.object({
|
|
2327
|
+
type: z16.literal("exec"),
|
|
2328
|
+
command: z16.array(z16.string()),
|
|
2329
|
+
timeoutMs: z16.number().optional(),
|
|
2330
|
+
user: z16.string().optional(),
|
|
2331
|
+
workingDirectory: z16.string().optional(),
|
|
2332
|
+
env: z16.record(z16.string(), z16.string()).optional()
|
|
2283
2333
|
})
|
|
2284
2334
|
})
|
|
2285
2335
|
)
|
|
2286
2336
|
);
|
|
2287
|
-
var localShellOutputSchema = (
|
|
2288
|
-
() => (
|
|
2337
|
+
var localShellOutputSchema = lazySchema15(
|
|
2338
|
+
() => zodSchema15(z16.object({ output: z16.string() }))
|
|
2289
2339
|
);
|
|
2290
|
-
var localShell = (
|
|
2340
|
+
var localShell = createProviderToolFactoryWithOutputSchema5({
|
|
2291
2341
|
id: "openai.local_shell",
|
|
2292
2342
|
inputSchema: localShellInputSchema,
|
|
2293
2343
|
outputSchema: localShellOutputSchema
|
|
2294
2344
|
});
|
|
2295
2345
|
|
|
2296
2346
|
// src/tool/shell.ts
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2347
|
+
import {
|
|
2348
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
2349
|
+
lazySchema as lazySchema16,
|
|
2350
|
+
zodSchema as zodSchema16
|
|
2351
|
+
} from "@ai-sdk/provider-utils";
|
|
2352
|
+
import { z as z17 } from "zod/v4";
|
|
2353
|
+
var shellInputSchema = lazySchema16(
|
|
2354
|
+
() => zodSchema16(
|
|
2355
|
+
z17.object({
|
|
2356
|
+
action: z17.object({
|
|
2357
|
+
commands: z17.array(z17.string()),
|
|
2358
|
+
timeoutMs: z17.number().optional(),
|
|
2359
|
+
maxOutputLength: z17.number().optional()
|
|
2306
2360
|
})
|
|
2307
2361
|
})
|
|
2308
2362
|
)
|
|
2309
2363
|
);
|
|
2310
|
-
var shellOutputSchema = (
|
|
2311
|
-
() => (
|
|
2312
|
-
|
|
2313
|
-
output:
|
|
2314
|
-
|
|
2315
|
-
stdout:
|
|
2316
|
-
stderr:
|
|
2317
|
-
outcome:
|
|
2318
|
-
|
|
2319
|
-
|
|
2364
|
+
var shellOutputSchema = lazySchema16(
|
|
2365
|
+
() => zodSchema16(
|
|
2366
|
+
z17.object({
|
|
2367
|
+
output: z17.array(
|
|
2368
|
+
z17.object({
|
|
2369
|
+
stdout: z17.string(),
|
|
2370
|
+
stderr: z17.string(),
|
|
2371
|
+
outcome: z17.discriminatedUnion("type", [
|
|
2372
|
+
z17.object({ type: z17.literal("timeout") }),
|
|
2373
|
+
z17.object({ type: z17.literal("exit"), exitCode: z17.number() })
|
|
2320
2374
|
])
|
|
2321
2375
|
})
|
|
2322
2376
|
)
|
|
2323
2377
|
})
|
|
2324
2378
|
)
|
|
2325
2379
|
);
|
|
2326
|
-
var shellSkillsSchema =
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
type:
|
|
2330
|
-
providerReference:
|
|
2331
|
-
version:
|
|
2380
|
+
var shellSkillsSchema = z17.array(
|
|
2381
|
+
z17.discriminatedUnion("type", [
|
|
2382
|
+
z17.object({
|
|
2383
|
+
type: z17.literal("skillReference"),
|
|
2384
|
+
providerReference: z17.record(z17.string(), z17.string()),
|
|
2385
|
+
version: z17.string().optional()
|
|
2332
2386
|
}),
|
|
2333
|
-
|
|
2334
|
-
type:
|
|
2335
|
-
name:
|
|
2336
|
-
description:
|
|
2337
|
-
source:
|
|
2338
|
-
type:
|
|
2339
|
-
mediaType:
|
|
2340
|
-
data:
|
|
2387
|
+
z17.object({
|
|
2388
|
+
type: z17.literal("inline"),
|
|
2389
|
+
name: z17.string(),
|
|
2390
|
+
description: z17.string(),
|
|
2391
|
+
source: z17.object({
|
|
2392
|
+
type: z17.literal("base64"),
|
|
2393
|
+
mediaType: z17.literal("application/zip"),
|
|
2394
|
+
data: z17.string()
|
|
2341
2395
|
})
|
|
2342
2396
|
})
|
|
2343
2397
|
])
|
|
2344
2398
|
).optional();
|
|
2345
|
-
var shellArgsSchema = (
|
|
2346
|
-
() => (
|
|
2347
|
-
|
|
2348
|
-
environment:
|
|
2349
|
-
|
|
2350
|
-
type:
|
|
2351
|
-
fileIds:
|
|
2352
|
-
memoryLimit:
|
|
2353
|
-
networkPolicy:
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
type:
|
|
2357
|
-
allowedDomains:
|
|
2358
|
-
domainSecrets:
|
|
2359
|
-
|
|
2360
|
-
domain:
|
|
2361
|
-
name:
|
|
2362
|
-
value:
|
|
2399
|
+
var shellArgsSchema = lazySchema16(
|
|
2400
|
+
() => zodSchema16(
|
|
2401
|
+
z17.object({
|
|
2402
|
+
environment: z17.union([
|
|
2403
|
+
z17.object({
|
|
2404
|
+
type: z17.literal("containerAuto"),
|
|
2405
|
+
fileIds: z17.array(z17.string()).optional(),
|
|
2406
|
+
memoryLimit: z17.enum(["1g", "4g", "16g", "64g"]).optional(),
|
|
2407
|
+
networkPolicy: z17.discriminatedUnion("type", [
|
|
2408
|
+
z17.object({ type: z17.literal("disabled") }),
|
|
2409
|
+
z17.object({
|
|
2410
|
+
type: z17.literal("allowlist"),
|
|
2411
|
+
allowedDomains: z17.array(z17.string()),
|
|
2412
|
+
domainSecrets: z17.array(
|
|
2413
|
+
z17.object({
|
|
2414
|
+
domain: z17.string(),
|
|
2415
|
+
name: z17.string(),
|
|
2416
|
+
value: z17.string()
|
|
2363
2417
|
})
|
|
2364
2418
|
).optional()
|
|
2365
2419
|
})
|
|
2366
2420
|
]).optional(),
|
|
2367
2421
|
skills: shellSkillsSchema
|
|
2368
2422
|
}),
|
|
2369
|
-
|
|
2370
|
-
type:
|
|
2371
|
-
containerId:
|
|
2423
|
+
z17.object({
|
|
2424
|
+
type: z17.literal("containerReference"),
|
|
2425
|
+
containerId: z17.string()
|
|
2372
2426
|
}),
|
|
2373
|
-
|
|
2374
|
-
type:
|
|
2375
|
-
skills:
|
|
2376
|
-
|
|
2377
|
-
name:
|
|
2378
|
-
description:
|
|
2379
|
-
path:
|
|
2427
|
+
z17.object({
|
|
2428
|
+
type: z17.literal("local").optional(),
|
|
2429
|
+
skills: z17.array(
|
|
2430
|
+
z17.object({
|
|
2431
|
+
name: z17.string(),
|
|
2432
|
+
description: z17.string(),
|
|
2433
|
+
path: z17.string()
|
|
2380
2434
|
})
|
|
2381
2435
|
).optional()
|
|
2382
2436
|
})
|
|
@@ -2384,40 +2438,44 @@ var shellArgsSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
2384
2438
|
})
|
|
2385
2439
|
)
|
|
2386
2440
|
);
|
|
2387
|
-
var shell = (
|
|
2441
|
+
var shell = createProviderToolFactoryWithOutputSchema6({
|
|
2388
2442
|
id: "openai.shell",
|
|
2389
2443
|
inputSchema: shellInputSchema,
|
|
2390
2444
|
outputSchema: shellOutputSchema
|
|
2391
2445
|
});
|
|
2392
2446
|
|
|
2393
2447
|
// src/tool/tool-search.ts
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2448
|
+
import {
|
|
2449
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
2450
|
+
lazySchema as lazySchema17,
|
|
2451
|
+
zodSchema as zodSchema17
|
|
2452
|
+
} from "@ai-sdk/provider-utils";
|
|
2453
|
+
import { z as z18 } from "zod/v4";
|
|
2454
|
+
var toolSearchArgsSchema = lazySchema17(
|
|
2455
|
+
() => zodSchema17(
|
|
2456
|
+
z18.object({
|
|
2457
|
+
execution: z18.enum(["server", "client"]).optional(),
|
|
2458
|
+
description: z18.string().optional(),
|
|
2459
|
+
parameters: z18.record(z18.string(), z18.unknown()).optional()
|
|
2402
2460
|
})
|
|
2403
2461
|
)
|
|
2404
2462
|
);
|
|
2405
|
-
var toolSearchInputSchema = (
|
|
2406
|
-
() => (
|
|
2407
|
-
|
|
2408
|
-
arguments:
|
|
2409
|
-
call_id:
|
|
2463
|
+
var toolSearchInputSchema = lazySchema17(
|
|
2464
|
+
() => zodSchema17(
|
|
2465
|
+
z18.object({
|
|
2466
|
+
arguments: z18.unknown().optional(),
|
|
2467
|
+
call_id: z18.string().nullish()
|
|
2410
2468
|
})
|
|
2411
2469
|
)
|
|
2412
2470
|
);
|
|
2413
|
-
var toolSearchOutputSchema = (
|
|
2414
|
-
() => (
|
|
2415
|
-
|
|
2416
|
-
tools:
|
|
2471
|
+
var toolSearchOutputSchema = lazySchema17(
|
|
2472
|
+
() => zodSchema17(
|
|
2473
|
+
z18.object({
|
|
2474
|
+
tools: z18.array(z18.record(z18.string(), z18.unknown()))
|
|
2417
2475
|
})
|
|
2418
2476
|
)
|
|
2419
2477
|
);
|
|
2420
|
-
var toolSearchToolFactory = (
|
|
2478
|
+
var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema7({
|
|
2421
2479
|
id: "openai.tool_search",
|
|
2422
2480
|
inputSchema: toolSearchInputSchema,
|
|
2423
2481
|
outputSchema: toolSearchOutputSchema
|
|
@@ -2425,53 +2483,57 @@ var toolSearchToolFactory = (0, import_provider_utils24.createProviderToolFactor
|
|
|
2425
2483
|
var toolSearch = (args = {}) => toolSearchToolFactory(args);
|
|
2426
2484
|
|
|
2427
2485
|
// src/tool/web-search.ts
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2486
|
+
import {
|
|
2487
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
2488
|
+
lazySchema as lazySchema18,
|
|
2489
|
+
zodSchema as zodSchema18
|
|
2490
|
+
} from "@ai-sdk/provider-utils";
|
|
2491
|
+
import { z as z19 } from "zod/v4";
|
|
2492
|
+
var webSearchArgsSchema = lazySchema18(
|
|
2493
|
+
() => zodSchema18(
|
|
2494
|
+
z19.object({
|
|
2495
|
+
externalWebAccess: z19.boolean().optional(),
|
|
2496
|
+
filters: z19.object({ allowedDomains: z19.array(z19.string()).optional() }).optional(),
|
|
2497
|
+
searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
|
|
2498
|
+
userLocation: z19.object({
|
|
2499
|
+
type: z19.literal("approximate"),
|
|
2500
|
+
country: z19.string().optional(),
|
|
2501
|
+
city: z19.string().optional(),
|
|
2502
|
+
region: z19.string().optional(),
|
|
2503
|
+
timezone: z19.string().optional()
|
|
2442
2504
|
}).optional()
|
|
2443
2505
|
})
|
|
2444
2506
|
)
|
|
2445
2507
|
);
|
|
2446
|
-
var webSearchInputSchema = (
|
|
2447
|
-
var webSearchOutputSchema = (
|
|
2448
|
-
() => (
|
|
2449
|
-
|
|
2450
|
-
action:
|
|
2451
|
-
|
|
2452
|
-
type:
|
|
2453
|
-
query:
|
|
2508
|
+
var webSearchInputSchema = lazySchema18(() => zodSchema18(z19.object({})));
|
|
2509
|
+
var webSearchOutputSchema = lazySchema18(
|
|
2510
|
+
() => zodSchema18(
|
|
2511
|
+
z19.object({
|
|
2512
|
+
action: z19.discriminatedUnion("type", [
|
|
2513
|
+
z19.object({
|
|
2514
|
+
type: z19.literal("search"),
|
|
2515
|
+
query: z19.string().optional()
|
|
2454
2516
|
}),
|
|
2455
|
-
|
|
2456
|
-
type:
|
|
2457
|
-
url:
|
|
2517
|
+
z19.object({
|
|
2518
|
+
type: z19.literal("openPage"),
|
|
2519
|
+
url: z19.string().nullish()
|
|
2458
2520
|
}),
|
|
2459
|
-
|
|
2460
|
-
type:
|
|
2461
|
-
url:
|
|
2462
|
-
pattern:
|
|
2521
|
+
z19.object({
|
|
2522
|
+
type: z19.literal("findInPage"),
|
|
2523
|
+
url: z19.string().nullish(),
|
|
2524
|
+
pattern: z19.string().nullish()
|
|
2463
2525
|
})
|
|
2464
2526
|
]).optional(),
|
|
2465
|
-
sources:
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2527
|
+
sources: z19.array(
|
|
2528
|
+
z19.discriminatedUnion("type", [
|
|
2529
|
+
z19.object({ type: z19.literal("url"), url: z19.string() }),
|
|
2530
|
+
z19.object({ type: z19.literal("api"), name: z19.string() })
|
|
2469
2531
|
])
|
|
2470
2532
|
).optional()
|
|
2471
2533
|
})
|
|
2472
2534
|
)
|
|
2473
2535
|
);
|
|
2474
|
-
var webSearchToolFactory = (
|
|
2536
|
+
var webSearchToolFactory = createProviderToolFactoryWithOutputSchema8({
|
|
2475
2537
|
id: "openai.web_search",
|
|
2476
2538
|
inputSchema: webSearchInputSchema,
|
|
2477
2539
|
outputSchema: webSearchOutputSchema
|
|
@@ -2479,109 +2541,117 @@ var webSearchToolFactory = (0, import_provider_utils25.createProviderToolFactory
|
|
|
2479
2541
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
2480
2542
|
|
|
2481
2543
|
// src/tool/web-search-preview.ts
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2544
|
+
import {
|
|
2545
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
|
|
2546
|
+
lazySchema as lazySchema19,
|
|
2547
|
+
zodSchema as zodSchema19
|
|
2548
|
+
} from "@ai-sdk/provider-utils";
|
|
2549
|
+
import { z as z20 } from "zod/v4";
|
|
2550
|
+
var webSearchPreviewArgsSchema = lazySchema19(
|
|
2551
|
+
() => zodSchema19(
|
|
2552
|
+
z20.object({
|
|
2553
|
+
searchContextSize: z20.enum(["low", "medium", "high"]).optional(),
|
|
2554
|
+
userLocation: z20.object({
|
|
2555
|
+
type: z20.literal("approximate"),
|
|
2556
|
+
country: z20.string().optional(),
|
|
2557
|
+
city: z20.string().optional(),
|
|
2558
|
+
region: z20.string().optional(),
|
|
2559
|
+
timezone: z20.string().optional()
|
|
2494
2560
|
}).optional()
|
|
2495
2561
|
})
|
|
2496
2562
|
)
|
|
2497
2563
|
);
|
|
2498
|
-
var webSearchPreviewInputSchema = (
|
|
2499
|
-
() => (
|
|
2564
|
+
var webSearchPreviewInputSchema = lazySchema19(
|
|
2565
|
+
() => zodSchema19(z20.object({}))
|
|
2500
2566
|
);
|
|
2501
|
-
var webSearchPreviewOutputSchema = (
|
|
2502
|
-
() => (
|
|
2503
|
-
|
|
2504
|
-
action:
|
|
2505
|
-
|
|
2506
|
-
type:
|
|
2507
|
-
query:
|
|
2567
|
+
var webSearchPreviewOutputSchema = lazySchema19(
|
|
2568
|
+
() => zodSchema19(
|
|
2569
|
+
z20.object({
|
|
2570
|
+
action: z20.discriminatedUnion("type", [
|
|
2571
|
+
z20.object({
|
|
2572
|
+
type: z20.literal("search"),
|
|
2573
|
+
query: z20.string().optional()
|
|
2508
2574
|
}),
|
|
2509
|
-
|
|
2510
|
-
type:
|
|
2511
|
-
url:
|
|
2575
|
+
z20.object({
|
|
2576
|
+
type: z20.literal("openPage"),
|
|
2577
|
+
url: z20.string().nullish()
|
|
2512
2578
|
}),
|
|
2513
|
-
|
|
2514
|
-
type:
|
|
2515
|
-
url:
|
|
2516
|
-
pattern:
|
|
2579
|
+
z20.object({
|
|
2580
|
+
type: z20.literal("findInPage"),
|
|
2581
|
+
url: z20.string().nullish(),
|
|
2582
|
+
pattern: z20.string().nullish()
|
|
2517
2583
|
})
|
|
2518
2584
|
]).optional()
|
|
2519
2585
|
})
|
|
2520
2586
|
)
|
|
2521
2587
|
);
|
|
2522
|
-
var webSearchPreview = (
|
|
2588
|
+
var webSearchPreview = createProviderToolFactoryWithOutputSchema9({
|
|
2523
2589
|
id: "openai.web_search_preview",
|
|
2524
2590
|
inputSchema: webSearchPreviewInputSchema,
|
|
2525
2591
|
outputSchema: webSearchPreviewOutputSchema
|
|
2526
2592
|
});
|
|
2527
2593
|
|
|
2528
2594
|
// src/tool/mcp.ts
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2595
|
+
import {
|
|
2596
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema10,
|
|
2597
|
+
lazySchema as lazySchema20,
|
|
2598
|
+
zodSchema as zodSchema20
|
|
2599
|
+
} from "@ai-sdk/provider-utils";
|
|
2600
|
+
import { z as z21 } from "zod/v4";
|
|
2601
|
+
var jsonValueSchema = z21.lazy(
|
|
2602
|
+
() => z21.union([
|
|
2603
|
+
z21.string(),
|
|
2604
|
+
z21.number(),
|
|
2605
|
+
z21.boolean(),
|
|
2606
|
+
z21.null(),
|
|
2607
|
+
z21.array(jsonValueSchema),
|
|
2608
|
+
z21.record(z21.string(), jsonValueSchema)
|
|
2539
2609
|
])
|
|
2540
2610
|
);
|
|
2541
|
-
var mcpArgsSchema = (
|
|
2542
|
-
() => (
|
|
2543
|
-
|
|
2544
|
-
serverLabel:
|
|
2545
|
-
allowedTools:
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
readOnly:
|
|
2549
|
-
toolNames:
|
|
2611
|
+
var mcpArgsSchema = lazySchema20(
|
|
2612
|
+
() => zodSchema20(
|
|
2613
|
+
z21.object({
|
|
2614
|
+
serverLabel: z21.string(),
|
|
2615
|
+
allowedTools: z21.union([
|
|
2616
|
+
z21.array(z21.string()),
|
|
2617
|
+
z21.object({
|
|
2618
|
+
readOnly: z21.boolean().optional(),
|
|
2619
|
+
toolNames: z21.array(z21.string()).optional()
|
|
2550
2620
|
})
|
|
2551
2621
|
]).optional(),
|
|
2552
|
-
authorization:
|
|
2553
|
-
connectorId:
|
|
2554
|
-
headers:
|
|
2555
|
-
requireApproval:
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
never:
|
|
2559
|
-
toolNames:
|
|
2622
|
+
authorization: z21.string().optional(),
|
|
2623
|
+
connectorId: z21.string().optional(),
|
|
2624
|
+
headers: z21.record(z21.string(), z21.string()).optional(),
|
|
2625
|
+
requireApproval: z21.union([
|
|
2626
|
+
z21.enum(["always", "never"]),
|
|
2627
|
+
z21.object({
|
|
2628
|
+
never: z21.object({
|
|
2629
|
+
toolNames: z21.array(z21.string()).optional()
|
|
2560
2630
|
}).optional()
|
|
2561
2631
|
})
|
|
2562
2632
|
]).optional(),
|
|
2563
|
-
serverDescription:
|
|
2564
|
-
serverUrl:
|
|
2633
|
+
serverDescription: z21.string().optional(),
|
|
2634
|
+
serverUrl: z21.string().optional()
|
|
2565
2635
|
}).refine(
|
|
2566
2636
|
(v) => v.serverUrl != null || v.connectorId != null,
|
|
2567
2637
|
"One of serverUrl or connectorId must be provided."
|
|
2568
2638
|
)
|
|
2569
2639
|
)
|
|
2570
2640
|
);
|
|
2571
|
-
var mcpInputSchema = (
|
|
2572
|
-
var mcpOutputSchema = (
|
|
2573
|
-
() => (
|
|
2574
|
-
|
|
2575
|
-
type:
|
|
2576
|
-
serverLabel:
|
|
2577
|
-
name:
|
|
2578
|
-
arguments:
|
|
2579
|
-
output:
|
|
2580
|
-
error:
|
|
2641
|
+
var mcpInputSchema = lazySchema20(() => zodSchema20(z21.object({})));
|
|
2642
|
+
var mcpOutputSchema = lazySchema20(
|
|
2643
|
+
() => zodSchema20(
|
|
2644
|
+
z21.object({
|
|
2645
|
+
type: z21.literal("call"),
|
|
2646
|
+
serverLabel: z21.string(),
|
|
2647
|
+
name: z21.string(),
|
|
2648
|
+
arguments: z21.string(),
|
|
2649
|
+
output: z21.string().nullish(),
|
|
2650
|
+
error: z21.union([z21.string(), jsonValueSchema]).optional()
|
|
2581
2651
|
})
|
|
2582
2652
|
)
|
|
2583
2653
|
);
|
|
2584
|
-
var mcpToolFactory = (
|
|
2654
|
+
var mcpToolFactory = createProviderToolFactoryWithOutputSchema10({
|
|
2585
2655
|
id: "openai.mcp",
|
|
2586
2656
|
inputSchema: mcpInputSchema,
|
|
2587
2657
|
outputSchema: mcpOutputSchema
|
|
@@ -2706,8 +2776,19 @@ var openaiTools = {
|
|
|
2706
2776
|
};
|
|
2707
2777
|
|
|
2708
2778
|
// src/responses/openai-responses-language-model.ts
|
|
2709
|
-
|
|
2710
|
-
|
|
2779
|
+
import {
|
|
2780
|
+
APICallError
|
|
2781
|
+
} from "@ai-sdk/provider";
|
|
2782
|
+
import {
|
|
2783
|
+
combineHeaders as combineHeaders6,
|
|
2784
|
+
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
2785
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
2786
|
+
createToolNameMapping,
|
|
2787
|
+
generateId as generateId2,
|
|
2788
|
+
isCustomReasoning as isCustomReasoning2,
|
|
2789
|
+
parseProviderOptions as parseProviderOptions6,
|
|
2790
|
+
postJsonToApi as postJsonToApi5
|
|
2791
|
+
} from "@ai-sdk/provider-utils";
|
|
2711
2792
|
|
|
2712
2793
|
// src/responses/convert-openai-responses-usage.ts
|
|
2713
2794
|
function convertOpenAIResponsesUsage(usage) {
|
|
@@ -2749,9 +2830,19 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2749
2830
|
}
|
|
2750
2831
|
|
|
2751
2832
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2833
|
+
import {
|
|
2834
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2835
|
+
} from "@ai-sdk/provider";
|
|
2836
|
+
import {
|
|
2837
|
+
convertToBase64 as convertToBase642,
|
|
2838
|
+
isNonNullable,
|
|
2839
|
+
isProviderReference as isProviderReference2,
|
|
2840
|
+
parseJSON,
|
|
2841
|
+
parseProviderOptions as parseProviderOptions5,
|
|
2842
|
+
resolveProviderReference as resolveProviderReference2,
|
|
2843
|
+
validateTypes
|
|
2844
|
+
} from "@ai-sdk/provider-utils";
|
|
2845
|
+
import { z as z22 } from "zod/v4";
|
|
2755
2846
|
function isFileId(data, prefixes) {
|
|
2756
2847
|
if (!prefixes) return false;
|
|
2757
2848
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2811,8 +2902,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2811
2902
|
return { type: "input_text", text: part.text };
|
|
2812
2903
|
}
|
|
2813
2904
|
case "file": {
|
|
2814
|
-
if ((
|
|
2815
|
-
const fileId = (
|
|
2905
|
+
if (isProviderReference2(part.data)) {
|
|
2906
|
+
const fileId = resolveProviderReference2({
|
|
2816
2907
|
reference: part.data,
|
|
2817
2908
|
provider: providerOptionsName
|
|
2818
2909
|
});
|
|
@@ -2833,7 +2924,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2833
2924
|
return {
|
|
2834
2925
|
type: "input_image",
|
|
2835
2926
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2836
|
-
image_url: `data:${mediaType};base64,${(
|
|
2927
|
+
image_url: `data:${mediaType};base64,${convertToBase642(part.data)}`
|
|
2837
2928
|
},
|
|
2838
2929
|
detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
2839
2930
|
};
|
|
@@ -2848,11 +2939,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2848
2939
|
type: "input_file",
|
|
2849
2940
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2850
2941
|
filename: (_e2 = part.filename) != null ? _e2 : `part-${index}.pdf`,
|
|
2851
|
-
file_data: `data:application/pdf;base64,${(
|
|
2942
|
+
file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
|
|
2852
2943
|
}
|
|
2853
2944
|
};
|
|
2854
2945
|
} else {
|
|
2855
|
-
throw new
|
|
2946
|
+
throw new UnsupportedFunctionalityError4({
|
|
2856
2947
|
functionality: `file part media type ${part.mediaType}`
|
|
2857
2948
|
});
|
|
2858
2949
|
}
|
|
@@ -2898,10 +2989,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2898
2989
|
input.push({ type: "item_reference", id });
|
|
2899
2990
|
break;
|
|
2900
2991
|
}
|
|
2901
|
-
const parsedInput = typeof part.input === "string" ? await
|
|
2992
|
+
const parsedInput = typeof part.input === "string" ? await parseJSON({
|
|
2902
2993
|
text: part.input,
|
|
2903
2994
|
schema: toolSearchInputSchema
|
|
2904
|
-
}) : await
|
|
2995
|
+
}) : await validateTypes({
|
|
2905
2996
|
value: part.input,
|
|
2906
2997
|
schema: toolSearchInputSchema
|
|
2907
2998
|
});
|
|
@@ -2927,7 +3018,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2927
3018
|
break;
|
|
2928
3019
|
}
|
|
2929
3020
|
if (hasLocalShellTool && resolvedToolName === "local_shell") {
|
|
2930
|
-
const parsedInput = await
|
|
3021
|
+
const parsedInput = await validateTypes({
|
|
2931
3022
|
value: part.input,
|
|
2932
3023
|
schema: localShellInputSchema
|
|
2933
3024
|
});
|
|
@@ -2947,7 +3038,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2947
3038
|
break;
|
|
2948
3039
|
}
|
|
2949
3040
|
if (hasShellTool && resolvedToolName === "shell") {
|
|
2950
|
-
const parsedInput = await
|
|
3041
|
+
const parsedInput = await validateTypes({
|
|
2951
3042
|
value: part.input,
|
|
2952
3043
|
schema: shellInputSchema
|
|
2953
3044
|
});
|
|
@@ -2965,7 +3056,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2965
3056
|
break;
|
|
2966
3057
|
}
|
|
2967
3058
|
if (hasApplyPatchTool && resolvedToolName === "apply_patch") {
|
|
2968
|
-
const parsedInput = await
|
|
3059
|
+
const parsedInput = await validateTypes({
|
|
2969
3060
|
value: part.input,
|
|
2970
3061
|
schema: applyPatchInputSchema
|
|
2971
3062
|
});
|
|
@@ -3013,7 +3104,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3013
3104
|
if (store) {
|
|
3014
3105
|
input.push({ type: "item_reference", id: itemId });
|
|
3015
3106
|
} else if (part.output.type === "json") {
|
|
3016
|
-
const parsedOutput = await
|
|
3107
|
+
const parsedOutput = await validateTypes({
|
|
3017
3108
|
value: part.output.value,
|
|
3018
3109
|
schema: toolSearchOutputSchema
|
|
3019
3110
|
});
|
|
@@ -3030,7 +3121,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3030
3121
|
}
|
|
3031
3122
|
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
3032
3123
|
if (part.output.type === "json") {
|
|
3033
|
-
const parsedOutput = await
|
|
3124
|
+
const parsedOutput = await validateTypes({
|
|
3034
3125
|
value: part.output.value,
|
|
3035
3126
|
schema: shellOutputSchema
|
|
3036
3127
|
});
|
|
@@ -3061,7 +3152,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3061
3152
|
break;
|
|
3062
3153
|
}
|
|
3063
3154
|
case "reasoning": {
|
|
3064
|
-
const providerOptions = await (
|
|
3155
|
+
const providerOptions = await parseProviderOptions5({
|
|
3065
3156
|
provider: providerOptionsName,
|
|
3066
3157
|
providerOptions: part.providerOptions,
|
|
3067
3158
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
@@ -3191,7 +3282,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3191
3282
|
part.toolName
|
|
3192
3283
|
);
|
|
3193
3284
|
if (resolvedToolName === "tool_search" && output.type === "json") {
|
|
3194
|
-
const parsedOutput = await
|
|
3285
|
+
const parsedOutput = await validateTypes({
|
|
3195
3286
|
value: output.value,
|
|
3196
3287
|
schema: toolSearchOutputSchema
|
|
3197
3288
|
});
|
|
@@ -3205,7 +3296,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3205
3296
|
continue;
|
|
3206
3297
|
}
|
|
3207
3298
|
if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
|
|
3208
|
-
const parsedOutput = await
|
|
3299
|
+
const parsedOutput = await validateTypes({
|
|
3209
3300
|
value: output.value,
|
|
3210
3301
|
schema: localShellOutputSchema
|
|
3211
3302
|
});
|
|
@@ -3217,7 +3308,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3217
3308
|
continue;
|
|
3218
3309
|
}
|
|
3219
3310
|
if (hasShellTool && resolvedToolName === "shell" && output.type === "json") {
|
|
3220
|
-
const parsedOutput = await
|
|
3311
|
+
const parsedOutput = await validateTypes({
|
|
3221
3312
|
value: output.value,
|
|
3222
3313
|
schema: shellOutputSchema
|
|
3223
3314
|
});
|
|
@@ -3236,7 +3327,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3236
3327
|
continue;
|
|
3237
3328
|
}
|
|
3238
3329
|
if (hasApplyPatchTool && part.toolName === "apply_patch" && output.type === "json") {
|
|
3239
|
-
const parsedOutput = await
|
|
3330
|
+
const parsedOutput = await validateTypes({
|
|
3240
3331
|
value: output.value,
|
|
3241
3332
|
schema: applyPatchOutputSchema
|
|
3242
3333
|
});
|
|
@@ -3296,7 +3387,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3296
3387
|
});
|
|
3297
3388
|
return void 0;
|
|
3298
3389
|
}
|
|
3299
|
-
}).filter(
|
|
3390
|
+
}).filter(isNonNullable);
|
|
3300
3391
|
break;
|
|
3301
3392
|
default:
|
|
3302
3393
|
outputValue = "";
|
|
@@ -3361,7 +3452,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3361
3452
|
return void 0;
|
|
3362
3453
|
}
|
|
3363
3454
|
}
|
|
3364
|
-
}).filter(
|
|
3455
|
+
}).filter(isNonNullable);
|
|
3365
3456
|
break;
|
|
3366
3457
|
}
|
|
3367
3458
|
input.push({
|
|
@@ -3391,9 +3482,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
3391
3482
|
}
|
|
3392
3483
|
return { input, warnings };
|
|
3393
3484
|
}
|
|
3394
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
3395
|
-
itemId:
|
|
3396
|
-
reasoningEncryptedContent:
|
|
3485
|
+
var openaiResponsesReasoningProviderOptionsSchema = z22.object({
|
|
3486
|
+
itemId: z22.string().nullish(),
|
|
3487
|
+
reasoningEncryptedContent: z22.string().nullish()
|
|
3397
3488
|
});
|
|
3398
3489
|
|
|
3399
3490
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -3415,552 +3506,552 @@ function mapOpenAIResponseFinishReason({
|
|
|
3415
3506
|
}
|
|
3416
3507
|
|
|
3417
3508
|
// src/responses/openai-responses-api.ts
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
var jsonValueSchema2 =
|
|
3421
|
-
() =>
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3509
|
+
import { lazySchema as lazySchema21, zodSchema as zodSchema21 } from "@ai-sdk/provider-utils";
|
|
3510
|
+
import { z as z23 } from "zod/v4";
|
|
3511
|
+
var jsonValueSchema2 = z23.lazy(
|
|
3512
|
+
() => z23.union([
|
|
3513
|
+
z23.string(),
|
|
3514
|
+
z23.number(),
|
|
3515
|
+
z23.boolean(),
|
|
3516
|
+
z23.null(),
|
|
3517
|
+
z23.array(jsonValueSchema2),
|
|
3518
|
+
z23.record(z23.string(), jsonValueSchema2.optional())
|
|
3428
3519
|
])
|
|
3429
3520
|
);
|
|
3430
|
-
var openaiResponsesChunkSchema = (
|
|
3431
|
-
() => (
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
type:
|
|
3435
|
-
item_id:
|
|
3436
|
-
delta:
|
|
3437
|
-
logprobs:
|
|
3438
|
-
|
|
3439
|
-
token:
|
|
3440
|
-
logprob:
|
|
3441
|
-
top_logprobs:
|
|
3442
|
-
|
|
3443
|
-
token:
|
|
3444
|
-
logprob:
|
|
3521
|
+
var openaiResponsesChunkSchema = lazySchema21(
|
|
3522
|
+
() => zodSchema21(
|
|
3523
|
+
z23.union([
|
|
3524
|
+
z23.object({
|
|
3525
|
+
type: z23.literal("response.output_text.delta"),
|
|
3526
|
+
item_id: z23.string(),
|
|
3527
|
+
delta: z23.string(),
|
|
3528
|
+
logprobs: z23.array(
|
|
3529
|
+
z23.object({
|
|
3530
|
+
token: z23.string(),
|
|
3531
|
+
logprob: z23.number(),
|
|
3532
|
+
top_logprobs: z23.array(
|
|
3533
|
+
z23.object({
|
|
3534
|
+
token: z23.string(),
|
|
3535
|
+
logprob: z23.number()
|
|
3445
3536
|
})
|
|
3446
3537
|
)
|
|
3447
3538
|
})
|
|
3448
3539
|
).nullish()
|
|
3449
3540
|
}),
|
|
3450
|
-
|
|
3451
|
-
type:
|
|
3452
|
-
response:
|
|
3453
|
-
incomplete_details:
|
|
3454
|
-
usage:
|
|
3455
|
-
input_tokens:
|
|
3456
|
-
input_tokens_details:
|
|
3457
|
-
output_tokens:
|
|
3458
|
-
output_tokens_details:
|
|
3541
|
+
z23.object({
|
|
3542
|
+
type: z23.enum(["response.completed", "response.incomplete"]),
|
|
3543
|
+
response: z23.object({
|
|
3544
|
+
incomplete_details: z23.object({ reason: z23.string() }).nullish(),
|
|
3545
|
+
usage: z23.object({
|
|
3546
|
+
input_tokens: z23.number(),
|
|
3547
|
+
input_tokens_details: z23.object({ cached_tokens: z23.number().nullish() }).nullish(),
|
|
3548
|
+
output_tokens: z23.number(),
|
|
3549
|
+
output_tokens_details: z23.object({ reasoning_tokens: z23.number().nullish() }).nullish()
|
|
3459
3550
|
}),
|
|
3460
|
-
service_tier:
|
|
3551
|
+
service_tier: z23.string().nullish()
|
|
3461
3552
|
})
|
|
3462
3553
|
}),
|
|
3463
|
-
|
|
3464
|
-
type:
|
|
3465
|
-
response:
|
|
3466
|
-
error:
|
|
3467
|
-
code:
|
|
3468
|
-
message:
|
|
3554
|
+
z23.object({
|
|
3555
|
+
type: z23.literal("response.failed"),
|
|
3556
|
+
response: z23.object({
|
|
3557
|
+
error: z23.object({
|
|
3558
|
+
code: z23.string().nullish(),
|
|
3559
|
+
message: z23.string()
|
|
3469
3560
|
}).nullish(),
|
|
3470
|
-
incomplete_details:
|
|
3471
|
-
usage:
|
|
3472
|
-
input_tokens:
|
|
3473
|
-
input_tokens_details:
|
|
3474
|
-
output_tokens:
|
|
3475
|
-
output_tokens_details:
|
|
3561
|
+
incomplete_details: z23.object({ reason: z23.string() }).nullish(),
|
|
3562
|
+
usage: z23.object({
|
|
3563
|
+
input_tokens: z23.number(),
|
|
3564
|
+
input_tokens_details: z23.object({ cached_tokens: z23.number().nullish() }).nullish(),
|
|
3565
|
+
output_tokens: z23.number(),
|
|
3566
|
+
output_tokens_details: z23.object({ reasoning_tokens: z23.number().nullish() }).nullish()
|
|
3476
3567
|
}).nullish(),
|
|
3477
|
-
service_tier:
|
|
3568
|
+
service_tier: z23.string().nullish()
|
|
3478
3569
|
})
|
|
3479
3570
|
}),
|
|
3480
|
-
|
|
3481
|
-
type:
|
|
3482
|
-
response:
|
|
3483
|
-
id:
|
|
3484
|
-
created_at:
|
|
3485
|
-
model:
|
|
3486
|
-
service_tier:
|
|
3571
|
+
z23.object({
|
|
3572
|
+
type: z23.literal("response.created"),
|
|
3573
|
+
response: z23.object({
|
|
3574
|
+
id: z23.string(),
|
|
3575
|
+
created_at: z23.number(),
|
|
3576
|
+
model: z23.string(),
|
|
3577
|
+
service_tier: z23.string().nullish()
|
|
3487
3578
|
})
|
|
3488
3579
|
}),
|
|
3489
|
-
|
|
3490
|
-
type:
|
|
3491
|
-
output_index:
|
|
3492
|
-
item:
|
|
3493
|
-
|
|
3494
|
-
type:
|
|
3495
|
-
id:
|
|
3496
|
-
phase:
|
|
3580
|
+
z23.object({
|
|
3581
|
+
type: z23.literal("response.output_item.added"),
|
|
3582
|
+
output_index: z23.number(),
|
|
3583
|
+
item: z23.discriminatedUnion("type", [
|
|
3584
|
+
z23.object({
|
|
3585
|
+
type: z23.literal("message"),
|
|
3586
|
+
id: z23.string(),
|
|
3587
|
+
phase: z23.enum(["commentary", "final_answer"]).nullish()
|
|
3497
3588
|
}),
|
|
3498
|
-
|
|
3499
|
-
type:
|
|
3500
|
-
id:
|
|
3501
|
-
encrypted_content:
|
|
3589
|
+
z23.object({
|
|
3590
|
+
type: z23.literal("reasoning"),
|
|
3591
|
+
id: z23.string(),
|
|
3592
|
+
encrypted_content: z23.string().nullish()
|
|
3502
3593
|
}),
|
|
3503
|
-
|
|
3504
|
-
type:
|
|
3505
|
-
id:
|
|
3506
|
-
call_id:
|
|
3507
|
-
name:
|
|
3508
|
-
arguments:
|
|
3594
|
+
z23.object({
|
|
3595
|
+
type: z23.literal("function_call"),
|
|
3596
|
+
id: z23.string(),
|
|
3597
|
+
call_id: z23.string(),
|
|
3598
|
+
name: z23.string(),
|
|
3599
|
+
arguments: z23.string()
|
|
3509
3600
|
}),
|
|
3510
|
-
|
|
3511
|
-
type:
|
|
3512
|
-
id:
|
|
3513
|
-
status:
|
|
3601
|
+
z23.object({
|
|
3602
|
+
type: z23.literal("web_search_call"),
|
|
3603
|
+
id: z23.string(),
|
|
3604
|
+
status: z23.string()
|
|
3514
3605
|
}),
|
|
3515
|
-
|
|
3516
|
-
type:
|
|
3517
|
-
id:
|
|
3518
|
-
status:
|
|
3606
|
+
z23.object({
|
|
3607
|
+
type: z23.literal("computer_call"),
|
|
3608
|
+
id: z23.string(),
|
|
3609
|
+
status: z23.string()
|
|
3519
3610
|
}),
|
|
3520
|
-
|
|
3521
|
-
type:
|
|
3522
|
-
id:
|
|
3611
|
+
z23.object({
|
|
3612
|
+
type: z23.literal("file_search_call"),
|
|
3613
|
+
id: z23.string()
|
|
3523
3614
|
}),
|
|
3524
|
-
|
|
3525
|
-
type:
|
|
3526
|
-
id:
|
|
3615
|
+
z23.object({
|
|
3616
|
+
type: z23.literal("image_generation_call"),
|
|
3617
|
+
id: z23.string()
|
|
3527
3618
|
}),
|
|
3528
|
-
|
|
3529
|
-
type:
|
|
3530
|
-
id:
|
|
3531
|
-
container_id:
|
|
3532
|
-
code:
|
|
3533
|
-
outputs:
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3619
|
+
z23.object({
|
|
3620
|
+
type: z23.literal("code_interpreter_call"),
|
|
3621
|
+
id: z23.string(),
|
|
3622
|
+
container_id: z23.string(),
|
|
3623
|
+
code: z23.string().nullable(),
|
|
3624
|
+
outputs: z23.array(
|
|
3625
|
+
z23.discriminatedUnion("type", [
|
|
3626
|
+
z23.object({ type: z23.literal("logs"), logs: z23.string() }),
|
|
3627
|
+
z23.object({ type: z23.literal("image"), url: z23.string() })
|
|
3537
3628
|
])
|
|
3538
3629
|
).nullable(),
|
|
3539
|
-
status:
|
|
3630
|
+
status: z23.string()
|
|
3540
3631
|
}),
|
|
3541
|
-
|
|
3542
|
-
type:
|
|
3543
|
-
id:
|
|
3544
|
-
status:
|
|
3545
|
-
approval_request_id:
|
|
3632
|
+
z23.object({
|
|
3633
|
+
type: z23.literal("mcp_call"),
|
|
3634
|
+
id: z23.string(),
|
|
3635
|
+
status: z23.string(),
|
|
3636
|
+
approval_request_id: z23.string().nullish()
|
|
3546
3637
|
}),
|
|
3547
|
-
|
|
3548
|
-
type:
|
|
3549
|
-
id:
|
|
3638
|
+
z23.object({
|
|
3639
|
+
type: z23.literal("mcp_list_tools"),
|
|
3640
|
+
id: z23.string()
|
|
3550
3641
|
}),
|
|
3551
|
-
|
|
3552
|
-
type:
|
|
3553
|
-
id:
|
|
3642
|
+
z23.object({
|
|
3643
|
+
type: z23.literal("mcp_approval_request"),
|
|
3644
|
+
id: z23.string()
|
|
3554
3645
|
}),
|
|
3555
|
-
|
|
3556
|
-
type:
|
|
3557
|
-
id:
|
|
3558
|
-
call_id:
|
|
3559
|
-
status:
|
|
3560
|
-
operation:
|
|
3561
|
-
|
|
3562
|
-
type:
|
|
3563
|
-
path:
|
|
3564
|
-
diff:
|
|
3646
|
+
z23.object({
|
|
3647
|
+
type: z23.literal("apply_patch_call"),
|
|
3648
|
+
id: z23.string(),
|
|
3649
|
+
call_id: z23.string(),
|
|
3650
|
+
status: z23.enum(["in_progress", "completed"]),
|
|
3651
|
+
operation: z23.discriminatedUnion("type", [
|
|
3652
|
+
z23.object({
|
|
3653
|
+
type: z23.literal("create_file"),
|
|
3654
|
+
path: z23.string(),
|
|
3655
|
+
diff: z23.string()
|
|
3565
3656
|
}),
|
|
3566
|
-
|
|
3567
|
-
type:
|
|
3568
|
-
path:
|
|
3657
|
+
z23.object({
|
|
3658
|
+
type: z23.literal("delete_file"),
|
|
3659
|
+
path: z23.string()
|
|
3569
3660
|
}),
|
|
3570
|
-
|
|
3571
|
-
type:
|
|
3572
|
-
path:
|
|
3573
|
-
diff:
|
|
3661
|
+
z23.object({
|
|
3662
|
+
type: z23.literal("update_file"),
|
|
3663
|
+
path: z23.string(),
|
|
3664
|
+
diff: z23.string()
|
|
3574
3665
|
})
|
|
3575
3666
|
])
|
|
3576
3667
|
}),
|
|
3577
|
-
|
|
3578
|
-
type:
|
|
3579
|
-
id:
|
|
3580
|
-
call_id:
|
|
3581
|
-
name:
|
|
3582
|
-
input:
|
|
3668
|
+
z23.object({
|
|
3669
|
+
type: z23.literal("custom_tool_call"),
|
|
3670
|
+
id: z23.string(),
|
|
3671
|
+
call_id: z23.string(),
|
|
3672
|
+
name: z23.string(),
|
|
3673
|
+
input: z23.string()
|
|
3583
3674
|
}),
|
|
3584
|
-
|
|
3585
|
-
type:
|
|
3586
|
-
id:
|
|
3587
|
-
call_id:
|
|
3588
|
-
status:
|
|
3589
|
-
action:
|
|
3590
|
-
commands:
|
|
3675
|
+
z23.object({
|
|
3676
|
+
type: z23.literal("shell_call"),
|
|
3677
|
+
id: z23.string(),
|
|
3678
|
+
call_id: z23.string(),
|
|
3679
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3680
|
+
action: z23.object({
|
|
3681
|
+
commands: z23.array(z23.string())
|
|
3591
3682
|
})
|
|
3592
3683
|
}),
|
|
3593
|
-
|
|
3594
|
-
type:
|
|
3595
|
-
id:
|
|
3596
|
-
encrypted_content:
|
|
3684
|
+
z23.object({
|
|
3685
|
+
type: z23.literal("compaction"),
|
|
3686
|
+
id: z23.string(),
|
|
3687
|
+
encrypted_content: z23.string().nullish()
|
|
3597
3688
|
}),
|
|
3598
|
-
|
|
3599
|
-
type:
|
|
3600
|
-
id:
|
|
3601
|
-
call_id:
|
|
3602
|
-
status:
|
|
3603
|
-
output:
|
|
3604
|
-
|
|
3605
|
-
stdout:
|
|
3606
|
-
stderr:
|
|
3607
|
-
outcome:
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
type:
|
|
3611
|
-
exit_code:
|
|
3689
|
+
z23.object({
|
|
3690
|
+
type: z23.literal("shell_call_output"),
|
|
3691
|
+
id: z23.string(),
|
|
3692
|
+
call_id: z23.string(),
|
|
3693
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3694
|
+
output: z23.array(
|
|
3695
|
+
z23.object({
|
|
3696
|
+
stdout: z23.string(),
|
|
3697
|
+
stderr: z23.string(),
|
|
3698
|
+
outcome: z23.discriminatedUnion("type", [
|
|
3699
|
+
z23.object({ type: z23.literal("timeout") }),
|
|
3700
|
+
z23.object({
|
|
3701
|
+
type: z23.literal("exit"),
|
|
3702
|
+
exit_code: z23.number()
|
|
3612
3703
|
})
|
|
3613
3704
|
])
|
|
3614
3705
|
})
|
|
3615
3706
|
)
|
|
3616
3707
|
}),
|
|
3617
|
-
|
|
3618
|
-
type:
|
|
3619
|
-
id:
|
|
3620
|
-
execution:
|
|
3621
|
-
call_id:
|
|
3622
|
-
status:
|
|
3623
|
-
arguments:
|
|
3708
|
+
z23.object({
|
|
3709
|
+
type: z23.literal("tool_search_call"),
|
|
3710
|
+
id: z23.string(),
|
|
3711
|
+
execution: z23.enum(["server", "client"]),
|
|
3712
|
+
call_id: z23.string().nullable(),
|
|
3713
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3714
|
+
arguments: z23.unknown()
|
|
3624
3715
|
}),
|
|
3625
|
-
|
|
3626
|
-
type:
|
|
3627
|
-
id:
|
|
3628
|
-
execution:
|
|
3629
|
-
call_id:
|
|
3630
|
-
status:
|
|
3631
|
-
tools:
|
|
3716
|
+
z23.object({
|
|
3717
|
+
type: z23.literal("tool_search_output"),
|
|
3718
|
+
id: z23.string(),
|
|
3719
|
+
execution: z23.enum(["server", "client"]),
|
|
3720
|
+
call_id: z23.string().nullable(),
|
|
3721
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3722
|
+
tools: z23.array(z23.record(z23.string(), jsonValueSchema2.optional()))
|
|
3632
3723
|
})
|
|
3633
3724
|
])
|
|
3634
3725
|
}),
|
|
3635
|
-
|
|
3636
|
-
type:
|
|
3637
|
-
output_index:
|
|
3638
|
-
item:
|
|
3639
|
-
|
|
3640
|
-
type:
|
|
3641
|
-
id:
|
|
3642
|
-
phase:
|
|
3726
|
+
z23.object({
|
|
3727
|
+
type: z23.literal("response.output_item.done"),
|
|
3728
|
+
output_index: z23.number(),
|
|
3729
|
+
item: z23.discriminatedUnion("type", [
|
|
3730
|
+
z23.object({
|
|
3731
|
+
type: z23.literal("message"),
|
|
3732
|
+
id: z23.string(),
|
|
3733
|
+
phase: z23.enum(["commentary", "final_answer"]).nullish()
|
|
3643
3734
|
}),
|
|
3644
|
-
|
|
3645
|
-
type:
|
|
3646
|
-
id:
|
|
3647
|
-
encrypted_content:
|
|
3735
|
+
z23.object({
|
|
3736
|
+
type: z23.literal("reasoning"),
|
|
3737
|
+
id: z23.string(),
|
|
3738
|
+
encrypted_content: z23.string().nullish()
|
|
3648
3739
|
}),
|
|
3649
|
-
|
|
3650
|
-
type:
|
|
3651
|
-
id:
|
|
3652
|
-
call_id:
|
|
3653
|
-
name:
|
|
3654
|
-
arguments:
|
|
3655
|
-
status:
|
|
3740
|
+
z23.object({
|
|
3741
|
+
type: z23.literal("function_call"),
|
|
3742
|
+
id: z23.string(),
|
|
3743
|
+
call_id: z23.string(),
|
|
3744
|
+
name: z23.string(),
|
|
3745
|
+
arguments: z23.string(),
|
|
3746
|
+
status: z23.literal("completed")
|
|
3656
3747
|
}),
|
|
3657
|
-
|
|
3658
|
-
type:
|
|
3659
|
-
id:
|
|
3660
|
-
call_id:
|
|
3661
|
-
name:
|
|
3662
|
-
input:
|
|
3663
|
-
status:
|
|
3748
|
+
z23.object({
|
|
3749
|
+
type: z23.literal("custom_tool_call"),
|
|
3750
|
+
id: z23.string(),
|
|
3751
|
+
call_id: z23.string(),
|
|
3752
|
+
name: z23.string(),
|
|
3753
|
+
input: z23.string(),
|
|
3754
|
+
status: z23.literal("completed")
|
|
3664
3755
|
}),
|
|
3665
|
-
|
|
3666
|
-
type:
|
|
3667
|
-
id:
|
|
3668
|
-
code:
|
|
3669
|
-
container_id:
|
|
3670
|
-
outputs:
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3756
|
+
z23.object({
|
|
3757
|
+
type: z23.literal("code_interpreter_call"),
|
|
3758
|
+
id: z23.string(),
|
|
3759
|
+
code: z23.string().nullable(),
|
|
3760
|
+
container_id: z23.string(),
|
|
3761
|
+
outputs: z23.array(
|
|
3762
|
+
z23.discriminatedUnion("type", [
|
|
3763
|
+
z23.object({ type: z23.literal("logs"), logs: z23.string() }),
|
|
3764
|
+
z23.object({ type: z23.literal("image"), url: z23.string() })
|
|
3674
3765
|
])
|
|
3675
3766
|
).nullable()
|
|
3676
3767
|
}),
|
|
3677
|
-
|
|
3678
|
-
type:
|
|
3679
|
-
id:
|
|
3680
|
-
result:
|
|
3768
|
+
z23.object({
|
|
3769
|
+
type: z23.literal("image_generation_call"),
|
|
3770
|
+
id: z23.string(),
|
|
3771
|
+
result: z23.string()
|
|
3681
3772
|
}),
|
|
3682
|
-
|
|
3683
|
-
type:
|
|
3684
|
-
id:
|
|
3685
|
-
status:
|
|
3686
|
-
action:
|
|
3687
|
-
|
|
3688
|
-
type:
|
|
3689
|
-
query:
|
|
3690
|
-
sources:
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3773
|
+
z23.object({
|
|
3774
|
+
type: z23.literal("web_search_call"),
|
|
3775
|
+
id: z23.string(),
|
|
3776
|
+
status: z23.string(),
|
|
3777
|
+
action: z23.discriminatedUnion("type", [
|
|
3778
|
+
z23.object({
|
|
3779
|
+
type: z23.literal("search"),
|
|
3780
|
+
query: z23.string().nullish(),
|
|
3781
|
+
sources: z23.array(
|
|
3782
|
+
z23.discriminatedUnion("type", [
|
|
3783
|
+
z23.object({ type: z23.literal("url"), url: z23.string() }),
|
|
3784
|
+
z23.object({ type: z23.literal("api"), name: z23.string() })
|
|
3694
3785
|
])
|
|
3695
3786
|
).nullish()
|
|
3696
3787
|
}),
|
|
3697
|
-
|
|
3698
|
-
type:
|
|
3699
|
-
url:
|
|
3788
|
+
z23.object({
|
|
3789
|
+
type: z23.literal("open_page"),
|
|
3790
|
+
url: z23.string().nullish()
|
|
3700
3791
|
}),
|
|
3701
|
-
|
|
3702
|
-
type:
|
|
3703
|
-
url:
|
|
3704
|
-
pattern:
|
|
3792
|
+
z23.object({
|
|
3793
|
+
type: z23.literal("find_in_page"),
|
|
3794
|
+
url: z23.string().nullish(),
|
|
3795
|
+
pattern: z23.string().nullish()
|
|
3705
3796
|
})
|
|
3706
3797
|
]).nullish()
|
|
3707
3798
|
}),
|
|
3708
|
-
|
|
3709
|
-
type:
|
|
3710
|
-
id:
|
|
3711
|
-
queries:
|
|
3712
|
-
results:
|
|
3713
|
-
|
|
3714
|
-
attributes:
|
|
3715
|
-
|
|
3716
|
-
|
|
3799
|
+
z23.object({
|
|
3800
|
+
type: z23.literal("file_search_call"),
|
|
3801
|
+
id: z23.string(),
|
|
3802
|
+
queries: z23.array(z23.string()),
|
|
3803
|
+
results: z23.array(
|
|
3804
|
+
z23.object({
|
|
3805
|
+
attributes: z23.record(
|
|
3806
|
+
z23.string(),
|
|
3807
|
+
z23.union([z23.string(), z23.number(), z23.boolean()])
|
|
3717
3808
|
),
|
|
3718
|
-
file_id:
|
|
3719
|
-
filename:
|
|
3720
|
-
score:
|
|
3721
|
-
text:
|
|
3809
|
+
file_id: z23.string(),
|
|
3810
|
+
filename: z23.string(),
|
|
3811
|
+
score: z23.number(),
|
|
3812
|
+
text: z23.string()
|
|
3722
3813
|
})
|
|
3723
3814
|
).nullish()
|
|
3724
3815
|
}),
|
|
3725
|
-
|
|
3726
|
-
type:
|
|
3727
|
-
id:
|
|
3728
|
-
call_id:
|
|
3729
|
-
action:
|
|
3730
|
-
type:
|
|
3731
|
-
command:
|
|
3732
|
-
timeout_ms:
|
|
3733
|
-
user:
|
|
3734
|
-
working_directory:
|
|
3735
|
-
env:
|
|
3816
|
+
z23.object({
|
|
3817
|
+
type: z23.literal("local_shell_call"),
|
|
3818
|
+
id: z23.string(),
|
|
3819
|
+
call_id: z23.string(),
|
|
3820
|
+
action: z23.object({
|
|
3821
|
+
type: z23.literal("exec"),
|
|
3822
|
+
command: z23.array(z23.string()),
|
|
3823
|
+
timeout_ms: z23.number().optional(),
|
|
3824
|
+
user: z23.string().optional(),
|
|
3825
|
+
working_directory: z23.string().optional(),
|
|
3826
|
+
env: z23.record(z23.string(), z23.string()).optional()
|
|
3736
3827
|
})
|
|
3737
3828
|
}),
|
|
3738
|
-
|
|
3739
|
-
type:
|
|
3740
|
-
id:
|
|
3741
|
-
status:
|
|
3829
|
+
z23.object({
|
|
3830
|
+
type: z23.literal("computer_call"),
|
|
3831
|
+
id: z23.string(),
|
|
3832
|
+
status: z23.literal("completed")
|
|
3742
3833
|
}),
|
|
3743
|
-
|
|
3744
|
-
type:
|
|
3745
|
-
id:
|
|
3746
|
-
status:
|
|
3747
|
-
arguments:
|
|
3748
|
-
name:
|
|
3749
|
-
server_label:
|
|
3750
|
-
output:
|
|
3751
|
-
error:
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
type:
|
|
3755
|
-
code:
|
|
3756
|
-
message:
|
|
3834
|
+
z23.object({
|
|
3835
|
+
type: z23.literal("mcp_call"),
|
|
3836
|
+
id: z23.string(),
|
|
3837
|
+
status: z23.string(),
|
|
3838
|
+
arguments: z23.string(),
|
|
3839
|
+
name: z23.string(),
|
|
3840
|
+
server_label: z23.string(),
|
|
3841
|
+
output: z23.string().nullish(),
|
|
3842
|
+
error: z23.union([
|
|
3843
|
+
z23.string(),
|
|
3844
|
+
z23.object({
|
|
3845
|
+
type: z23.string().optional(),
|
|
3846
|
+
code: z23.union([z23.number(), z23.string()]).optional(),
|
|
3847
|
+
message: z23.string().optional()
|
|
3757
3848
|
}).loose()
|
|
3758
3849
|
]).nullish(),
|
|
3759
|
-
approval_request_id:
|
|
3850
|
+
approval_request_id: z23.string().nullish()
|
|
3760
3851
|
}),
|
|
3761
|
-
|
|
3762
|
-
type:
|
|
3763
|
-
id:
|
|
3764
|
-
server_label:
|
|
3765
|
-
tools:
|
|
3766
|
-
|
|
3767
|
-
name:
|
|
3768
|
-
description:
|
|
3769
|
-
input_schema:
|
|
3770
|
-
annotations:
|
|
3852
|
+
z23.object({
|
|
3853
|
+
type: z23.literal("mcp_list_tools"),
|
|
3854
|
+
id: z23.string(),
|
|
3855
|
+
server_label: z23.string(),
|
|
3856
|
+
tools: z23.array(
|
|
3857
|
+
z23.object({
|
|
3858
|
+
name: z23.string(),
|
|
3859
|
+
description: z23.string().optional(),
|
|
3860
|
+
input_schema: z23.any(),
|
|
3861
|
+
annotations: z23.record(z23.string(), z23.unknown()).optional()
|
|
3771
3862
|
})
|
|
3772
3863
|
),
|
|
3773
|
-
error:
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
type:
|
|
3777
|
-
code:
|
|
3778
|
-
message:
|
|
3864
|
+
error: z23.union([
|
|
3865
|
+
z23.string(),
|
|
3866
|
+
z23.object({
|
|
3867
|
+
type: z23.string().optional(),
|
|
3868
|
+
code: z23.union([z23.number(), z23.string()]).optional(),
|
|
3869
|
+
message: z23.string().optional()
|
|
3779
3870
|
}).loose()
|
|
3780
3871
|
]).optional()
|
|
3781
3872
|
}),
|
|
3782
|
-
|
|
3783
|
-
type:
|
|
3784
|
-
id:
|
|
3785
|
-
server_label:
|
|
3786
|
-
name:
|
|
3787
|
-
arguments:
|
|
3788
|
-
approval_request_id:
|
|
3873
|
+
z23.object({
|
|
3874
|
+
type: z23.literal("mcp_approval_request"),
|
|
3875
|
+
id: z23.string(),
|
|
3876
|
+
server_label: z23.string(),
|
|
3877
|
+
name: z23.string(),
|
|
3878
|
+
arguments: z23.string(),
|
|
3879
|
+
approval_request_id: z23.string().optional()
|
|
3789
3880
|
}),
|
|
3790
|
-
|
|
3791
|
-
type:
|
|
3792
|
-
id:
|
|
3793
|
-
call_id:
|
|
3794
|
-
status:
|
|
3795
|
-
operation:
|
|
3796
|
-
|
|
3797
|
-
type:
|
|
3798
|
-
path:
|
|
3799
|
-
diff:
|
|
3881
|
+
z23.object({
|
|
3882
|
+
type: z23.literal("apply_patch_call"),
|
|
3883
|
+
id: z23.string(),
|
|
3884
|
+
call_id: z23.string(),
|
|
3885
|
+
status: z23.enum(["in_progress", "completed"]),
|
|
3886
|
+
operation: z23.discriminatedUnion("type", [
|
|
3887
|
+
z23.object({
|
|
3888
|
+
type: z23.literal("create_file"),
|
|
3889
|
+
path: z23.string(),
|
|
3890
|
+
diff: z23.string()
|
|
3800
3891
|
}),
|
|
3801
|
-
|
|
3802
|
-
type:
|
|
3803
|
-
path:
|
|
3892
|
+
z23.object({
|
|
3893
|
+
type: z23.literal("delete_file"),
|
|
3894
|
+
path: z23.string()
|
|
3804
3895
|
}),
|
|
3805
|
-
|
|
3806
|
-
type:
|
|
3807
|
-
path:
|
|
3808
|
-
diff:
|
|
3896
|
+
z23.object({
|
|
3897
|
+
type: z23.literal("update_file"),
|
|
3898
|
+
path: z23.string(),
|
|
3899
|
+
diff: z23.string()
|
|
3809
3900
|
})
|
|
3810
3901
|
])
|
|
3811
3902
|
}),
|
|
3812
|
-
|
|
3813
|
-
type:
|
|
3814
|
-
id:
|
|
3815
|
-
call_id:
|
|
3816
|
-
status:
|
|
3817
|
-
action:
|
|
3818
|
-
commands:
|
|
3903
|
+
z23.object({
|
|
3904
|
+
type: z23.literal("shell_call"),
|
|
3905
|
+
id: z23.string(),
|
|
3906
|
+
call_id: z23.string(),
|
|
3907
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3908
|
+
action: z23.object({
|
|
3909
|
+
commands: z23.array(z23.string())
|
|
3819
3910
|
})
|
|
3820
3911
|
}),
|
|
3821
|
-
|
|
3822
|
-
type:
|
|
3823
|
-
id:
|
|
3824
|
-
encrypted_content:
|
|
3912
|
+
z23.object({
|
|
3913
|
+
type: z23.literal("compaction"),
|
|
3914
|
+
id: z23.string(),
|
|
3915
|
+
encrypted_content: z23.string()
|
|
3825
3916
|
}),
|
|
3826
|
-
|
|
3827
|
-
type:
|
|
3828
|
-
id:
|
|
3829
|
-
call_id:
|
|
3830
|
-
status:
|
|
3831
|
-
output:
|
|
3832
|
-
|
|
3833
|
-
stdout:
|
|
3834
|
-
stderr:
|
|
3835
|
-
outcome:
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
type:
|
|
3839
|
-
exit_code:
|
|
3917
|
+
z23.object({
|
|
3918
|
+
type: z23.literal("shell_call_output"),
|
|
3919
|
+
id: z23.string(),
|
|
3920
|
+
call_id: z23.string(),
|
|
3921
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3922
|
+
output: z23.array(
|
|
3923
|
+
z23.object({
|
|
3924
|
+
stdout: z23.string(),
|
|
3925
|
+
stderr: z23.string(),
|
|
3926
|
+
outcome: z23.discriminatedUnion("type", [
|
|
3927
|
+
z23.object({ type: z23.literal("timeout") }),
|
|
3928
|
+
z23.object({
|
|
3929
|
+
type: z23.literal("exit"),
|
|
3930
|
+
exit_code: z23.number()
|
|
3840
3931
|
})
|
|
3841
3932
|
])
|
|
3842
3933
|
})
|
|
3843
3934
|
)
|
|
3844
3935
|
}),
|
|
3845
|
-
|
|
3846
|
-
type:
|
|
3847
|
-
id:
|
|
3848
|
-
execution:
|
|
3849
|
-
call_id:
|
|
3850
|
-
status:
|
|
3851
|
-
arguments:
|
|
3936
|
+
z23.object({
|
|
3937
|
+
type: z23.literal("tool_search_call"),
|
|
3938
|
+
id: z23.string(),
|
|
3939
|
+
execution: z23.enum(["server", "client"]),
|
|
3940
|
+
call_id: z23.string().nullable(),
|
|
3941
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3942
|
+
arguments: z23.unknown()
|
|
3852
3943
|
}),
|
|
3853
|
-
|
|
3854
|
-
type:
|
|
3855
|
-
id:
|
|
3856
|
-
execution:
|
|
3857
|
-
call_id:
|
|
3858
|
-
status:
|
|
3859
|
-
tools:
|
|
3944
|
+
z23.object({
|
|
3945
|
+
type: z23.literal("tool_search_output"),
|
|
3946
|
+
id: z23.string(),
|
|
3947
|
+
execution: z23.enum(["server", "client"]),
|
|
3948
|
+
call_id: z23.string().nullable(),
|
|
3949
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
3950
|
+
tools: z23.array(z23.record(z23.string(), jsonValueSchema2.optional()))
|
|
3860
3951
|
})
|
|
3861
3952
|
])
|
|
3862
3953
|
}),
|
|
3863
|
-
|
|
3864
|
-
type:
|
|
3865
|
-
item_id:
|
|
3866
|
-
output_index:
|
|
3867
|
-
delta:
|
|
3954
|
+
z23.object({
|
|
3955
|
+
type: z23.literal("response.function_call_arguments.delta"),
|
|
3956
|
+
item_id: z23.string(),
|
|
3957
|
+
output_index: z23.number(),
|
|
3958
|
+
delta: z23.string()
|
|
3868
3959
|
}),
|
|
3869
|
-
|
|
3870
|
-
type:
|
|
3871
|
-
item_id:
|
|
3872
|
-
output_index:
|
|
3873
|
-
delta:
|
|
3960
|
+
z23.object({
|
|
3961
|
+
type: z23.literal("response.custom_tool_call_input.delta"),
|
|
3962
|
+
item_id: z23.string(),
|
|
3963
|
+
output_index: z23.number(),
|
|
3964
|
+
delta: z23.string()
|
|
3874
3965
|
}),
|
|
3875
|
-
|
|
3876
|
-
type:
|
|
3877
|
-
item_id:
|
|
3878
|
-
output_index:
|
|
3879
|
-
partial_image_b64:
|
|
3966
|
+
z23.object({
|
|
3967
|
+
type: z23.literal("response.image_generation_call.partial_image"),
|
|
3968
|
+
item_id: z23.string(),
|
|
3969
|
+
output_index: z23.number(),
|
|
3970
|
+
partial_image_b64: z23.string()
|
|
3880
3971
|
}),
|
|
3881
|
-
|
|
3882
|
-
type:
|
|
3883
|
-
item_id:
|
|
3884
|
-
output_index:
|
|
3885
|
-
delta:
|
|
3972
|
+
z23.object({
|
|
3973
|
+
type: z23.literal("response.code_interpreter_call_code.delta"),
|
|
3974
|
+
item_id: z23.string(),
|
|
3975
|
+
output_index: z23.number(),
|
|
3976
|
+
delta: z23.string()
|
|
3886
3977
|
}),
|
|
3887
|
-
|
|
3888
|
-
type:
|
|
3889
|
-
item_id:
|
|
3890
|
-
output_index:
|
|
3891
|
-
code:
|
|
3978
|
+
z23.object({
|
|
3979
|
+
type: z23.literal("response.code_interpreter_call_code.done"),
|
|
3980
|
+
item_id: z23.string(),
|
|
3981
|
+
output_index: z23.number(),
|
|
3982
|
+
code: z23.string()
|
|
3892
3983
|
}),
|
|
3893
|
-
|
|
3894
|
-
type:
|
|
3895
|
-
annotation:
|
|
3896
|
-
|
|
3897
|
-
type:
|
|
3898
|
-
start_index:
|
|
3899
|
-
end_index:
|
|
3900
|
-
url:
|
|
3901
|
-
title:
|
|
3984
|
+
z23.object({
|
|
3985
|
+
type: z23.literal("response.output_text.annotation.added"),
|
|
3986
|
+
annotation: z23.discriminatedUnion("type", [
|
|
3987
|
+
z23.object({
|
|
3988
|
+
type: z23.literal("url_citation"),
|
|
3989
|
+
start_index: z23.number(),
|
|
3990
|
+
end_index: z23.number(),
|
|
3991
|
+
url: z23.string(),
|
|
3992
|
+
title: z23.string()
|
|
3902
3993
|
}),
|
|
3903
|
-
|
|
3904
|
-
type:
|
|
3905
|
-
file_id:
|
|
3906
|
-
filename:
|
|
3907
|
-
index:
|
|
3994
|
+
z23.object({
|
|
3995
|
+
type: z23.literal("file_citation"),
|
|
3996
|
+
file_id: z23.string(),
|
|
3997
|
+
filename: z23.string(),
|
|
3998
|
+
index: z23.number()
|
|
3908
3999
|
}),
|
|
3909
|
-
|
|
3910
|
-
type:
|
|
3911
|
-
container_id:
|
|
3912
|
-
file_id:
|
|
3913
|
-
filename:
|
|
3914
|
-
start_index:
|
|
3915
|
-
end_index:
|
|
4000
|
+
z23.object({
|
|
4001
|
+
type: z23.literal("container_file_citation"),
|
|
4002
|
+
container_id: z23.string(),
|
|
4003
|
+
file_id: z23.string(),
|
|
4004
|
+
filename: z23.string(),
|
|
4005
|
+
start_index: z23.number(),
|
|
4006
|
+
end_index: z23.number()
|
|
3916
4007
|
}),
|
|
3917
|
-
|
|
3918
|
-
type:
|
|
3919
|
-
file_id:
|
|
3920
|
-
index:
|
|
4008
|
+
z23.object({
|
|
4009
|
+
type: z23.literal("file_path"),
|
|
4010
|
+
file_id: z23.string(),
|
|
4011
|
+
index: z23.number()
|
|
3921
4012
|
})
|
|
3922
4013
|
])
|
|
3923
4014
|
}),
|
|
3924
|
-
|
|
3925
|
-
type:
|
|
3926
|
-
item_id:
|
|
3927
|
-
summary_index:
|
|
4015
|
+
z23.object({
|
|
4016
|
+
type: z23.literal("response.reasoning_summary_part.added"),
|
|
4017
|
+
item_id: z23.string(),
|
|
4018
|
+
summary_index: z23.number()
|
|
3928
4019
|
}),
|
|
3929
|
-
|
|
3930
|
-
type:
|
|
3931
|
-
item_id:
|
|
3932
|
-
summary_index:
|
|
3933
|
-
delta:
|
|
4020
|
+
z23.object({
|
|
4021
|
+
type: z23.literal("response.reasoning_summary_text.delta"),
|
|
4022
|
+
item_id: z23.string(),
|
|
4023
|
+
summary_index: z23.number(),
|
|
4024
|
+
delta: z23.string()
|
|
3934
4025
|
}),
|
|
3935
|
-
|
|
3936
|
-
type:
|
|
3937
|
-
item_id:
|
|
3938
|
-
summary_index:
|
|
4026
|
+
z23.object({
|
|
4027
|
+
type: z23.literal("response.reasoning_summary_part.done"),
|
|
4028
|
+
item_id: z23.string(),
|
|
4029
|
+
summary_index: z23.number()
|
|
3939
4030
|
}),
|
|
3940
|
-
|
|
3941
|
-
type:
|
|
3942
|
-
item_id:
|
|
3943
|
-
output_index:
|
|
3944
|
-
delta:
|
|
3945
|
-
obfuscation:
|
|
4031
|
+
z23.object({
|
|
4032
|
+
type: z23.literal("response.apply_patch_call_operation_diff.delta"),
|
|
4033
|
+
item_id: z23.string(),
|
|
4034
|
+
output_index: z23.number(),
|
|
4035
|
+
delta: z23.string(),
|
|
4036
|
+
obfuscation: z23.string().nullish()
|
|
3946
4037
|
}),
|
|
3947
|
-
|
|
3948
|
-
type:
|
|
3949
|
-
item_id:
|
|
3950
|
-
output_index:
|
|
3951
|
-
diff:
|
|
4038
|
+
z23.object({
|
|
4039
|
+
type: z23.literal("response.apply_patch_call_operation_diff.done"),
|
|
4040
|
+
item_id: z23.string(),
|
|
4041
|
+
output_index: z23.number(),
|
|
4042
|
+
diff: z23.string()
|
|
3952
4043
|
}),
|
|
3953
|
-
|
|
3954
|
-
type:
|
|
3955
|
-
sequence_number:
|
|
3956
|
-
error:
|
|
3957
|
-
type:
|
|
3958
|
-
code:
|
|
3959
|
-
message:
|
|
3960
|
-
param:
|
|
4044
|
+
z23.object({
|
|
4045
|
+
type: z23.literal("error"),
|
|
4046
|
+
sequence_number: z23.number(),
|
|
4047
|
+
error: z23.object({
|
|
4048
|
+
type: z23.string(),
|
|
4049
|
+
code: z23.string(),
|
|
4050
|
+
message: z23.string(),
|
|
4051
|
+
param: z23.string().nullish()
|
|
3961
4052
|
})
|
|
3962
4053
|
}),
|
|
3963
|
-
|
|
4054
|
+
z23.object({ type: z23.string() }).loose().transform((value) => ({
|
|
3964
4055
|
type: "unknown_chunk",
|
|
3965
4056
|
message: value.type
|
|
3966
4057
|
}))
|
|
@@ -3968,315 +4059,315 @@ var openaiResponsesChunkSchema = (0, import_provider_utils29.lazySchema)(
|
|
|
3968
4059
|
])
|
|
3969
4060
|
)
|
|
3970
4061
|
);
|
|
3971
|
-
var openaiResponsesResponseSchema = (
|
|
3972
|
-
() => (
|
|
3973
|
-
|
|
3974
|
-
id:
|
|
3975
|
-
created_at:
|
|
3976
|
-
error:
|
|
3977
|
-
message:
|
|
3978
|
-
type:
|
|
3979
|
-
param:
|
|
3980
|
-
code:
|
|
4062
|
+
var openaiResponsesResponseSchema = lazySchema21(
|
|
4063
|
+
() => zodSchema21(
|
|
4064
|
+
z23.object({
|
|
4065
|
+
id: z23.string().optional(),
|
|
4066
|
+
created_at: z23.number().optional(),
|
|
4067
|
+
error: z23.object({
|
|
4068
|
+
message: z23.string(),
|
|
4069
|
+
type: z23.string(),
|
|
4070
|
+
param: z23.string().nullish(),
|
|
4071
|
+
code: z23.string()
|
|
3981
4072
|
}).nullish(),
|
|
3982
|
-
model:
|
|
3983
|
-
output:
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
type:
|
|
3987
|
-
role:
|
|
3988
|
-
id:
|
|
3989
|
-
phase:
|
|
3990
|
-
content:
|
|
3991
|
-
|
|
3992
|
-
type:
|
|
3993
|
-
text:
|
|
3994
|
-
logprobs:
|
|
3995
|
-
|
|
3996
|
-
token:
|
|
3997
|
-
logprob:
|
|
3998
|
-
top_logprobs:
|
|
3999
|
-
|
|
4000
|
-
token:
|
|
4001
|
-
logprob:
|
|
4073
|
+
model: z23.string().optional(),
|
|
4074
|
+
output: z23.array(
|
|
4075
|
+
z23.discriminatedUnion("type", [
|
|
4076
|
+
z23.object({
|
|
4077
|
+
type: z23.literal("message"),
|
|
4078
|
+
role: z23.literal("assistant"),
|
|
4079
|
+
id: z23.string(),
|
|
4080
|
+
phase: z23.enum(["commentary", "final_answer"]).nullish(),
|
|
4081
|
+
content: z23.array(
|
|
4082
|
+
z23.object({
|
|
4083
|
+
type: z23.literal("output_text"),
|
|
4084
|
+
text: z23.string(),
|
|
4085
|
+
logprobs: z23.array(
|
|
4086
|
+
z23.object({
|
|
4087
|
+
token: z23.string(),
|
|
4088
|
+
logprob: z23.number(),
|
|
4089
|
+
top_logprobs: z23.array(
|
|
4090
|
+
z23.object({
|
|
4091
|
+
token: z23.string(),
|
|
4092
|
+
logprob: z23.number()
|
|
4002
4093
|
})
|
|
4003
4094
|
)
|
|
4004
4095
|
})
|
|
4005
4096
|
).nullish(),
|
|
4006
|
-
annotations:
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
type:
|
|
4010
|
-
start_index:
|
|
4011
|
-
end_index:
|
|
4012
|
-
url:
|
|
4013
|
-
title:
|
|
4097
|
+
annotations: z23.array(
|
|
4098
|
+
z23.discriminatedUnion("type", [
|
|
4099
|
+
z23.object({
|
|
4100
|
+
type: z23.literal("url_citation"),
|
|
4101
|
+
start_index: z23.number(),
|
|
4102
|
+
end_index: z23.number(),
|
|
4103
|
+
url: z23.string(),
|
|
4104
|
+
title: z23.string()
|
|
4014
4105
|
}),
|
|
4015
|
-
|
|
4016
|
-
type:
|
|
4017
|
-
file_id:
|
|
4018
|
-
filename:
|
|
4019
|
-
index:
|
|
4106
|
+
z23.object({
|
|
4107
|
+
type: z23.literal("file_citation"),
|
|
4108
|
+
file_id: z23.string(),
|
|
4109
|
+
filename: z23.string(),
|
|
4110
|
+
index: z23.number()
|
|
4020
4111
|
}),
|
|
4021
|
-
|
|
4022
|
-
type:
|
|
4023
|
-
container_id:
|
|
4024
|
-
file_id:
|
|
4025
|
-
filename:
|
|
4026
|
-
start_index:
|
|
4027
|
-
end_index:
|
|
4112
|
+
z23.object({
|
|
4113
|
+
type: z23.literal("container_file_citation"),
|
|
4114
|
+
container_id: z23.string(),
|
|
4115
|
+
file_id: z23.string(),
|
|
4116
|
+
filename: z23.string(),
|
|
4117
|
+
start_index: z23.number(),
|
|
4118
|
+
end_index: z23.number()
|
|
4028
4119
|
}),
|
|
4029
|
-
|
|
4030
|
-
type:
|
|
4031
|
-
file_id:
|
|
4032
|
-
index:
|
|
4120
|
+
z23.object({
|
|
4121
|
+
type: z23.literal("file_path"),
|
|
4122
|
+
file_id: z23.string(),
|
|
4123
|
+
index: z23.number()
|
|
4033
4124
|
})
|
|
4034
4125
|
])
|
|
4035
4126
|
)
|
|
4036
4127
|
})
|
|
4037
4128
|
)
|
|
4038
4129
|
}),
|
|
4039
|
-
|
|
4040
|
-
type:
|
|
4041
|
-
id:
|
|
4042
|
-
status:
|
|
4043
|
-
action:
|
|
4044
|
-
|
|
4045
|
-
type:
|
|
4046
|
-
query:
|
|
4047
|
-
sources:
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
type:
|
|
4052
|
-
name:
|
|
4130
|
+
z23.object({
|
|
4131
|
+
type: z23.literal("web_search_call"),
|
|
4132
|
+
id: z23.string(),
|
|
4133
|
+
status: z23.string(),
|
|
4134
|
+
action: z23.discriminatedUnion("type", [
|
|
4135
|
+
z23.object({
|
|
4136
|
+
type: z23.literal("search"),
|
|
4137
|
+
query: z23.string().nullish(),
|
|
4138
|
+
sources: z23.array(
|
|
4139
|
+
z23.discriminatedUnion("type", [
|
|
4140
|
+
z23.object({ type: z23.literal("url"), url: z23.string() }),
|
|
4141
|
+
z23.object({
|
|
4142
|
+
type: z23.literal("api"),
|
|
4143
|
+
name: z23.string()
|
|
4053
4144
|
})
|
|
4054
4145
|
])
|
|
4055
4146
|
).nullish()
|
|
4056
4147
|
}),
|
|
4057
|
-
|
|
4058
|
-
type:
|
|
4059
|
-
url:
|
|
4148
|
+
z23.object({
|
|
4149
|
+
type: z23.literal("open_page"),
|
|
4150
|
+
url: z23.string().nullish()
|
|
4060
4151
|
}),
|
|
4061
|
-
|
|
4062
|
-
type:
|
|
4063
|
-
url:
|
|
4064
|
-
pattern:
|
|
4152
|
+
z23.object({
|
|
4153
|
+
type: z23.literal("find_in_page"),
|
|
4154
|
+
url: z23.string().nullish(),
|
|
4155
|
+
pattern: z23.string().nullish()
|
|
4065
4156
|
})
|
|
4066
4157
|
]).nullish()
|
|
4067
4158
|
}),
|
|
4068
|
-
|
|
4069
|
-
type:
|
|
4070
|
-
id:
|
|
4071
|
-
queries:
|
|
4072
|
-
results:
|
|
4073
|
-
|
|
4074
|
-
attributes:
|
|
4075
|
-
|
|
4076
|
-
|
|
4159
|
+
z23.object({
|
|
4160
|
+
type: z23.literal("file_search_call"),
|
|
4161
|
+
id: z23.string(),
|
|
4162
|
+
queries: z23.array(z23.string()),
|
|
4163
|
+
results: z23.array(
|
|
4164
|
+
z23.object({
|
|
4165
|
+
attributes: z23.record(
|
|
4166
|
+
z23.string(),
|
|
4167
|
+
z23.union([z23.string(), z23.number(), z23.boolean()])
|
|
4077
4168
|
),
|
|
4078
|
-
file_id:
|
|
4079
|
-
filename:
|
|
4080
|
-
score:
|
|
4081
|
-
text:
|
|
4169
|
+
file_id: z23.string(),
|
|
4170
|
+
filename: z23.string(),
|
|
4171
|
+
score: z23.number(),
|
|
4172
|
+
text: z23.string()
|
|
4082
4173
|
})
|
|
4083
4174
|
).nullish()
|
|
4084
4175
|
}),
|
|
4085
|
-
|
|
4086
|
-
type:
|
|
4087
|
-
id:
|
|
4088
|
-
code:
|
|
4089
|
-
container_id:
|
|
4090
|
-
outputs:
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4176
|
+
z23.object({
|
|
4177
|
+
type: z23.literal("code_interpreter_call"),
|
|
4178
|
+
id: z23.string(),
|
|
4179
|
+
code: z23.string().nullable(),
|
|
4180
|
+
container_id: z23.string(),
|
|
4181
|
+
outputs: z23.array(
|
|
4182
|
+
z23.discriminatedUnion("type", [
|
|
4183
|
+
z23.object({ type: z23.literal("logs"), logs: z23.string() }),
|
|
4184
|
+
z23.object({ type: z23.literal("image"), url: z23.string() })
|
|
4094
4185
|
])
|
|
4095
4186
|
).nullable()
|
|
4096
4187
|
}),
|
|
4097
|
-
|
|
4098
|
-
type:
|
|
4099
|
-
id:
|
|
4100
|
-
result:
|
|
4188
|
+
z23.object({
|
|
4189
|
+
type: z23.literal("image_generation_call"),
|
|
4190
|
+
id: z23.string(),
|
|
4191
|
+
result: z23.string()
|
|
4101
4192
|
}),
|
|
4102
|
-
|
|
4103
|
-
type:
|
|
4104
|
-
id:
|
|
4105
|
-
call_id:
|
|
4106
|
-
action:
|
|
4107
|
-
type:
|
|
4108
|
-
command:
|
|
4109
|
-
timeout_ms:
|
|
4110
|
-
user:
|
|
4111
|
-
working_directory:
|
|
4112
|
-
env:
|
|
4193
|
+
z23.object({
|
|
4194
|
+
type: z23.literal("local_shell_call"),
|
|
4195
|
+
id: z23.string(),
|
|
4196
|
+
call_id: z23.string(),
|
|
4197
|
+
action: z23.object({
|
|
4198
|
+
type: z23.literal("exec"),
|
|
4199
|
+
command: z23.array(z23.string()),
|
|
4200
|
+
timeout_ms: z23.number().optional(),
|
|
4201
|
+
user: z23.string().optional(),
|
|
4202
|
+
working_directory: z23.string().optional(),
|
|
4203
|
+
env: z23.record(z23.string(), z23.string()).optional()
|
|
4113
4204
|
})
|
|
4114
4205
|
}),
|
|
4115
|
-
|
|
4116
|
-
type:
|
|
4117
|
-
call_id:
|
|
4118
|
-
name:
|
|
4119
|
-
arguments:
|
|
4120
|
-
id:
|
|
4206
|
+
z23.object({
|
|
4207
|
+
type: z23.literal("function_call"),
|
|
4208
|
+
call_id: z23.string(),
|
|
4209
|
+
name: z23.string(),
|
|
4210
|
+
arguments: z23.string(),
|
|
4211
|
+
id: z23.string()
|
|
4121
4212
|
}),
|
|
4122
|
-
|
|
4123
|
-
type:
|
|
4124
|
-
call_id:
|
|
4125
|
-
name:
|
|
4126
|
-
input:
|
|
4127
|
-
id:
|
|
4213
|
+
z23.object({
|
|
4214
|
+
type: z23.literal("custom_tool_call"),
|
|
4215
|
+
call_id: z23.string(),
|
|
4216
|
+
name: z23.string(),
|
|
4217
|
+
input: z23.string(),
|
|
4218
|
+
id: z23.string()
|
|
4128
4219
|
}),
|
|
4129
|
-
|
|
4130
|
-
type:
|
|
4131
|
-
id:
|
|
4132
|
-
status:
|
|
4220
|
+
z23.object({
|
|
4221
|
+
type: z23.literal("computer_call"),
|
|
4222
|
+
id: z23.string(),
|
|
4223
|
+
status: z23.string().optional()
|
|
4133
4224
|
}),
|
|
4134
|
-
|
|
4135
|
-
type:
|
|
4136
|
-
id:
|
|
4137
|
-
encrypted_content:
|
|
4138
|
-
summary:
|
|
4139
|
-
|
|
4140
|
-
type:
|
|
4141
|
-
text:
|
|
4225
|
+
z23.object({
|
|
4226
|
+
type: z23.literal("reasoning"),
|
|
4227
|
+
id: z23.string(),
|
|
4228
|
+
encrypted_content: z23.string().nullish(),
|
|
4229
|
+
summary: z23.array(
|
|
4230
|
+
z23.object({
|
|
4231
|
+
type: z23.literal("summary_text"),
|
|
4232
|
+
text: z23.string()
|
|
4142
4233
|
})
|
|
4143
4234
|
)
|
|
4144
4235
|
}),
|
|
4145
|
-
|
|
4146
|
-
type:
|
|
4147
|
-
id:
|
|
4148
|
-
status:
|
|
4149
|
-
arguments:
|
|
4150
|
-
name:
|
|
4151
|
-
server_label:
|
|
4152
|
-
output:
|
|
4153
|
-
error:
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
type:
|
|
4157
|
-
code:
|
|
4158
|
-
message:
|
|
4236
|
+
z23.object({
|
|
4237
|
+
type: z23.literal("mcp_call"),
|
|
4238
|
+
id: z23.string(),
|
|
4239
|
+
status: z23.string(),
|
|
4240
|
+
arguments: z23.string(),
|
|
4241
|
+
name: z23.string(),
|
|
4242
|
+
server_label: z23.string(),
|
|
4243
|
+
output: z23.string().nullish(),
|
|
4244
|
+
error: z23.union([
|
|
4245
|
+
z23.string(),
|
|
4246
|
+
z23.object({
|
|
4247
|
+
type: z23.string().optional(),
|
|
4248
|
+
code: z23.union([z23.number(), z23.string()]).optional(),
|
|
4249
|
+
message: z23.string().optional()
|
|
4159
4250
|
}).loose()
|
|
4160
4251
|
]).nullish(),
|
|
4161
|
-
approval_request_id:
|
|
4252
|
+
approval_request_id: z23.string().nullish()
|
|
4162
4253
|
}),
|
|
4163
|
-
|
|
4164
|
-
type:
|
|
4165
|
-
id:
|
|
4166
|
-
server_label:
|
|
4167
|
-
tools:
|
|
4168
|
-
|
|
4169
|
-
name:
|
|
4170
|
-
description:
|
|
4171
|
-
input_schema:
|
|
4172
|
-
annotations:
|
|
4254
|
+
z23.object({
|
|
4255
|
+
type: z23.literal("mcp_list_tools"),
|
|
4256
|
+
id: z23.string(),
|
|
4257
|
+
server_label: z23.string(),
|
|
4258
|
+
tools: z23.array(
|
|
4259
|
+
z23.object({
|
|
4260
|
+
name: z23.string(),
|
|
4261
|
+
description: z23.string().optional(),
|
|
4262
|
+
input_schema: z23.any(),
|
|
4263
|
+
annotations: z23.record(z23.string(), z23.unknown()).optional()
|
|
4173
4264
|
})
|
|
4174
4265
|
),
|
|
4175
|
-
error:
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
type:
|
|
4179
|
-
code:
|
|
4180
|
-
message:
|
|
4266
|
+
error: z23.union([
|
|
4267
|
+
z23.string(),
|
|
4268
|
+
z23.object({
|
|
4269
|
+
type: z23.string().optional(),
|
|
4270
|
+
code: z23.union([z23.number(), z23.string()]).optional(),
|
|
4271
|
+
message: z23.string().optional()
|
|
4181
4272
|
}).loose()
|
|
4182
4273
|
]).optional()
|
|
4183
4274
|
}),
|
|
4184
|
-
|
|
4185
|
-
type:
|
|
4186
|
-
id:
|
|
4187
|
-
server_label:
|
|
4188
|
-
name:
|
|
4189
|
-
arguments:
|
|
4190
|
-
approval_request_id:
|
|
4275
|
+
z23.object({
|
|
4276
|
+
type: z23.literal("mcp_approval_request"),
|
|
4277
|
+
id: z23.string(),
|
|
4278
|
+
server_label: z23.string(),
|
|
4279
|
+
name: z23.string(),
|
|
4280
|
+
arguments: z23.string(),
|
|
4281
|
+
approval_request_id: z23.string().optional()
|
|
4191
4282
|
}),
|
|
4192
|
-
|
|
4193
|
-
type:
|
|
4194
|
-
id:
|
|
4195
|
-
call_id:
|
|
4196
|
-
status:
|
|
4197
|
-
operation:
|
|
4198
|
-
|
|
4199
|
-
type:
|
|
4200
|
-
path:
|
|
4201
|
-
diff:
|
|
4283
|
+
z23.object({
|
|
4284
|
+
type: z23.literal("apply_patch_call"),
|
|
4285
|
+
id: z23.string(),
|
|
4286
|
+
call_id: z23.string(),
|
|
4287
|
+
status: z23.enum(["in_progress", "completed"]),
|
|
4288
|
+
operation: z23.discriminatedUnion("type", [
|
|
4289
|
+
z23.object({
|
|
4290
|
+
type: z23.literal("create_file"),
|
|
4291
|
+
path: z23.string(),
|
|
4292
|
+
diff: z23.string()
|
|
4202
4293
|
}),
|
|
4203
|
-
|
|
4204
|
-
type:
|
|
4205
|
-
path:
|
|
4294
|
+
z23.object({
|
|
4295
|
+
type: z23.literal("delete_file"),
|
|
4296
|
+
path: z23.string()
|
|
4206
4297
|
}),
|
|
4207
|
-
|
|
4208
|
-
type:
|
|
4209
|
-
path:
|
|
4210
|
-
diff:
|
|
4298
|
+
z23.object({
|
|
4299
|
+
type: z23.literal("update_file"),
|
|
4300
|
+
path: z23.string(),
|
|
4301
|
+
diff: z23.string()
|
|
4211
4302
|
})
|
|
4212
4303
|
])
|
|
4213
4304
|
}),
|
|
4214
|
-
|
|
4215
|
-
type:
|
|
4216
|
-
id:
|
|
4217
|
-
call_id:
|
|
4218
|
-
status:
|
|
4219
|
-
action:
|
|
4220
|
-
commands:
|
|
4305
|
+
z23.object({
|
|
4306
|
+
type: z23.literal("shell_call"),
|
|
4307
|
+
id: z23.string(),
|
|
4308
|
+
call_id: z23.string(),
|
|
4309
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
4310
|
+
action: z23.object({
|
|
4311
|
+
commands: z23.array(z23.string())
|
|
4221
4312
|
})
|
|
4222
4313
|
}),
|
|
4223
|
-
|
|
4224
|
-
type:
|
|
4225
|
-
id:
|
|
4226
|
-
encrypted_content:
|
|
4314
|
+
z23.object({
|
|
4315
|
+
type: z23.literal("compaction"),
|
|
4316
|
+
id: z23.string(),
|
|
4317
|
+
encrypted_content: z23.string()
|
|
4227
4318
|
}),
|
|
4228
|
-
|
|
4229
|
-
type:
|
|
4230
|
-
id:
|
|
4231
|
-
call_id:
|
|
4232
|
-
status:
|
|
4233
|
-
output:
|
|
4234
|
-
|
|
4235
|
-
stdout:
|
|
4236
|
-
stderr:
|
|
4237
|
-
outcome:
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
type:
|
|
4241
|
-
exit_code:
|
|
4319
|
+
z23.object({
|
|
4320
|
+
type: z23.literal("shell_call_output"),
|
|
4321
|
+
id: z23.string(),
|
|
4322
|
+
call_id: z23.string(),
|
|
4323
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
4324
|
+
output: z23.array(
|
|
4325
|
+
z23.object({
|
|
4326
|
+
stdout: z23.string(),
|
|
4327
|
+
stderr: z23.string(),
|
|
4328
|
+
outcome: z23.discriminatedUnion("type", [
|
|
4329
|
+
z23.object({ type: z23.literal("timeout") }),
|
|
4330
|
+
z23.object({
|
|
4331
|
+
type: z23.literal("exit"),
|
|
4332
|
+
exit_code: z23.number()
|
|
4242
4333
|
})
|
|
4243
4334
|
])
|
|
4244
4335
|
})
|
|
4245
4336
|
)
|
|
4246
4337
|
}),
|
|
4247
|
-
|
|
4248
|
-
type:
|
|
4249
|
-
id:
|
|
4250
|
-
execution:
|
|
4251
|
-
call_id:
|
|
4252
|
-
status:
|
|
4253
|
-
arguments:
|
|
4338
|
+
z23.object({
|
|
4339
|
+
type: z23.literal("tool_search_call"),
|
|
4340
|
+
id: z23.string(),
|
|
4341
|
+
execution: z23.enum(["server", "client"]),
|
|
4342
|
+
call_id: z23.string().nullable(),
|
|
4343
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
4344
|
+
arguments: z23.unknown()
|
|
4254
4345
|
}),
|
|
4255
|
-
|
|
4256
|
-
type:
|
|
4257
|
-
id:
|
|
4258
|
-
execution:
|
|
4259
|
-
call_id:
|
|
4260
|
-
status:
|
|
4261
|
-
tools:
|
|
4346
|
+
z23.object({
|
|
4347
|
+
type: z23.literal("tool_search_output"),
|
|
4348
|
+
id: z23.string(),
|
|
4349
|
+
execution: z23.enum(["server", "client"]),
|
|
4350
|
+
call_id: z23.string().nullable(),
|
|
4351
|
+
status: z23.enum(["in_progress", "completed", "incomplete"]),
|
|
4352
|
+
tools: z23.array(z23.record(z23.string(), jsonValueSchema2.optional()))
|
|
4262
4353
|
})
|
|
4263
4354
|
])
|
|
4264
4355
|
).optional(),
|
|
4265
|
-
service_tier:
|
|
4266
|
-
incomplete_details:
|
|
4267
|
-
usage:
|
|
4268
|
-
input_tokens:
|
|
4269
|
-
input_tokens_details:
|
|
4270
|
-
output_tokens:
|
|
4271
|
-
output_tokens_details:
|
|
4356
|
+
service_tier: z23.string().nullish(),
|
|
4357
|
+
incomplete_details: z23.object({ reason: z23.string() }).nullish(),
|
|
4358
|
+
usage: z23.object({
|
|
4359
|
+
input_tokens: z23.number(),
|
|
4360
|
+
input_tokens_details: z23.object({ cached_tokens: z23.number().nullish() }).nullish(),
|
|
4361
|
+
output_tokens: z23.number(),
|
|
4362
|
+
output_tokens_details: z23.object({ reasoning_tokens: z23.number().nullish() }).nullish()
|
|
4272
4363
|
}).optional()
|
|
4273
4364
|
})
|
|
4274
4365
|
)
|
|
4275
4366
|
);
|
|
4276
4367
|
|
|
4277
4368
|
// src/responses/openai-responses-options.ts
|
|
4278
|
-
|
|
4279
|
-
|
|
4369
|
+
import { lazySchema as lazySchema22, zodSchema as zodSchema22 } from "@ai-sdk/provider-utils";
|
|
4370
|
+
import { z as z24 } from "zod/v4";
|
|
4280
4371
|
var TOP_LOGPROBS_MAX = 20;
|
|
4281
4372
|
var openaiResponsesReasoningModelIds = [
|
|
4282
4373
|
"o1",
|
|
@@ -4341,9 +4432,9 @@ var openaiResponsesModelIds = [
|
|
|
4341
4432
|
"gpt-5-chat-latest",
|
|
4342
4433
|
...openaiResponsesReasoningModelIds
|
|
4343
4434
|
];
|
|
4344
|
-
var openaiLanguageModelResponsesOptionsSchema = (
|
|
4345
|
-
() => (
|
|
4346
|
-
|
|
4435
|
+
var openaiLanguageModelResponsesOptionsSchema = lazySchema22(
|
|
4436
|
+
() => zodSchema22(
|
|
4437
|
+
z24.object({
|
|
4347
4438
|
/**
|
|
4348
4439
|
* The ID of the OpenAI Conversation to continue.
|
|
4349
4440
|
* You must create a conversation first via the OpenAI API.
|
|
@@ -4351,13 +4442,13 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4351
4442
|
* Defaults to `undefined`.
|
|
4352
4443
|
* @see https://platform.openai.com/docs/api-reference/conversations/create
|
|
4353
4444
|
*/
|
|
4354
|
-
conversation:
|
|
4445
|
+
conversation: z24.string().nullish(),
|
|
4355
4446
|
/**
|
|
4356
4447
|
* The set of extra fields to include in the response (advanced, usually not needed).
|
|
4357
4448
|
* Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
|
|
4358
4449
|
*/
|
|
4359
|
-
include:
|
|
4360
|
-
|
|
4450
|
+
include: z24.array(
|
|
4451
|
+
z24.enum([
|
|
4361
4452
|
"reasoning.encrypted_content",
|
|
4362
4453
|
// handled internally by default, only needed for unknown reasoning models
|
|
4363
4454
|
"file_search_call.results",
|
|
@@ -4369,7 +4460,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4369
4460
|
* They can be used to change the system or developer message when continuing a conversation using the `previousResponseId` option.
|
|
4370
4461
|
* Defaults to `undefined`.
|
|
4371
4462
|
*/
|
|
4372
|
-
instructions:
|
|
4463
|
+
instructions: z24.string().nullish(),
|
|
4373
4464
|
/**
|
|
4374
4465
|
* Return the log probabilities of the tokens. Including logprobs will increase
|
|
4375
4466
|
* the response size and can slow down response times. However, it can
|
|
@@ -4384,30 +4475,30 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4384
4475
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
4385
4476
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
4386
4477
|
*/
|
|
4387
|
-
logprobs:
|
|
4478
|
+
logprobs: z24.union([z24.boolean(), z24.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
4388
4479
|
/**
|
|
4389
4480
|
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
4390
4481
|
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
4391
4482
|
* Any further attempts to call a tool by the model will be ignored.
|
|
4392
4483
|
*/
|
|
4393
|
-
maxToolCalls:
|
|
4484
|
+
maxToolCalls: z24.number().nullish(),
|
|
4394
4485
|
/**
|
|
4395
4486
|
* Additional metadata to store with the generation.
|
|
4396
4487
|
*/
|
|
4397
|
-
metadata:
|
|
4488
|
+
metadata: z24.any().nullish(),
|
|
4398
4489
|
/**
|
|
4399
4490
|
* Whether to use parallel tool calls. Defaults to `true`.
|
|
4400
4491
|
*/
|
|
4401
|
-
parallelToolCalls:
|
|
4492
|
+
parallelToolCalls: z24.boolean().nullish(),
|
|
4402
4493
|
/**
|
|
4403
4494
|
* The ID of the previous response. You can use it to continue a conversation.
|
|
4404
4495
|
* Defaults to `undefined`.
|
|
4405
4496
|
*/
|
|
4406
|
-
previousResponseId:
|
|
4497
|
+
previousResponseId: z24.string().nullish(),
|
|
4407
4498
|
/**
|
|
4408
4499
|
* Sets a cache key to tie this prompt to cached prefixes for better caching performance.
|
|
4409
4500
|
*/
|
|
4410
|
-
promptCacheKey:
|
|
4501
|
+
promptCacheKey: z24.string().nullish(),
|
|
4411
4502
|
/**
|
|
4412
4503
|
* The retention policy for the prompt cache.
|
|
4413
4504
|
* - 'in_memory': Default. Standard prompt caching behavior.
|
|
@@ -4416,7 +4507,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4416
4507
|
*
|
|
4417
4508
|
* @default 'in_memory'
|
|
4418
4509
|
*/
|
|
4419
|
-
promptCacheRetention:
|
|
4510
|
+
promptCacheRetention: z24.enum(["in_memory", "24h"]).nullish(),
|
|
4420
4511
|
/**
|
|
4421
4512
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
4422
4513
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
@@ -4427,17 +4518,17 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4427
4518
|
* OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
|
|
4428
4519
|
* an error.
|
|
4429
4520
|
*/
|
|
4430
|
-
reasoningEffort:
|
|
4521
|
+
reasoningEffort: z24.string().nullish(),
|
|
4431
4522
|
/**
|
|
4432
4523
|
* Controls reasoning summary output from the model.
|
|
4433
4524
|
* Set to "auto" to automatically receive the richest level available,
|
|
4434
4525
|
* or "detailed" for comprehensive summaries.
|
|
4435
4526
|
*/
|
|
4436
|
-
reasoningSummary:
|
|
4527
|
+
reasoningSummary: z24.string().nullish(),
|
|
4437
4528
|
/**
|
|
4438
4529
|
* The identifier for safety monitoring and tracking.
|
|
4439
4530
|
*/
|
|
4440
|
-
safetyIdentifier:
|
|
4531
|
+
safetyIdentifier: z24.string().nullish(),
|
|
4441
4532
|
/**
|
|
4442
4533
|
* Service tier for the request.
|
|
4443
4534
|
* Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
|
|
@@ -4445,34 +4536,34 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4445
4536
|
*
|
|
4446
4537
|
* Defaults to 'auto'.
|
|
4447
4538
|
*/
|
|
4448
|
-
serviceTier:
|
|
4539
|
+
serviceTier: z24.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
4449
4540
|
/**
|
|
4450
4541
|
* Whether to store the generation. Defaults to `true`.
|
|
4451
4542
|
*/
|
|
4452
|
-
store:
|
|
4543
|
+
store: z24.boolean().nullish(),
|
|
4453
4544
|
/**
|
|
4454
4545
|
* Whether to use strict JSON schema validation.
|
|
4455
4546
|
* Defaults to `true`.
|
|
4456
4547
|
*/
|
|
4457
|
-
strictJsonSchema:
|
|
4548
|
+
strictJsonSchema: z24.boolean().nullish(),
|
|
4458
4549
|
/**
|
|
4459
4550
|
* Controls the verbosity of the model's responses. Lower values ('low') will result
|
|
4460
4551
|
* in more concise responses, while higher values ('high') will result in more verbose responses.
|
|
4461
4552
|
* Valid values: 'low', 'medium', 'high'.
|
|
4462
4553
|
*/
|
|
4463
|
-
textVerbosity:
|
|
4554
|
+
textVerbosity: z24.enum(["low", "medium", "high"]).nullish(),
|
|
4464
4555
|
/**
|
|
4465
4556
|
* Controls output truncation. 'auto' (default) performs truncation automatically;
|
|
4466
4557
|
* 'disabled' turns truncation off.
|
|
4467
4558
|
*/
|
|
4468
|
-
truncation:
|
|
4559
|
+
truncation: z24.enum(["auto", "disabled"]).nullish(),
|
|
4469
4560
|
/**
|
|
4470
4561
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
4471
4562
|
* monitor and detect abuse.
|
|
4472
4563
|
* Defaults to `undefined`.
|
|
4473
4564
|
* @see https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids
|
|
4474
4565
|
*/
|
|
4475
|
-
user:
|
|
4566
|
+
user: z24.string().nullish(),
|
|
4476
4567
|
/**
|
|
4477
4568
|
* Override the system message mode for this model.
|
|
4478
4569
|
* - 'system': Use the 'system' role for system messages (default for most models)
|
|
@@ -4481,7 +4572,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4481
4572
|
*
|
|
4482
4573
|
* If not specified, the mode is automatically determined based on the model.
|
|
4483
4574
|
*/
|
|
4484
|
-
systemMessageMode:
|
|
4575
|
+
systemMessageMode: z24.enum(["system", "developer", "remove"]).optional(),
|
|
4485
4576
|
/**
|
|
4486
4577
|
* Force treating this model as a reasoning model.
|
|
4487
4578
|
*
|
|
@@ -4491,14 +4582,14 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4491
4582
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4492
4583
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4493
4584
|
*/
|
|
4494
|
-
forceReasoning:
|
|
4585
|
+
forceReasoning: z24.boolean().optional(),
|
|
4495
4586
|
/**
|
|
4496
4587
|
* Enable server-side context management (compaction).
|
|
4497
4588
|
*/
|
|
4498
|
-
contextManagement:
|
|
4499
|
-
|
|
4500
|
-
type:
|
|
4501
|
-
compactThreshold:
|
|
4589
|
+
contextManagement: z24.array(
|
|
4590
|
+
z24.object({
|
|
4591
|
+
type: z24.literal("compaction"),
|
|
4592
|
+
compactThreshold: z24.number()
|
|
4502
4593
|
})
|
|
4503
4594
|
).nullish()
|
|
4504
4595
|
})
|
|
@@ -4506,8 +4597,13 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils30.lazy
|
|
|
4506
4597
|
);
|
|
4507
4598
|
|
|
4508
4599
|
// src/responses/openai-responses-prepare-tools.ts
|
|
4509
|
-
|
|
4510
|
-
|
|
4600
|
+
import {
|
|
4601
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError5
|
|
4602
|
+
} from "@ai-sdk/provider";
|
|
4603
|
+
import {
|
|
4604
|
+
resolveProviderReference as resolveProviderReference3,
|
|
4605
|
+
validateTypes as validateTypes2
|
|
4606
|
+
} from "@ai-sdk/provider-utils";
|
|
4511
4607
|
async function prepareResponsesTools({
|
|
4512
4608
|
tools,
|
|
4513
4609
|
toolChoice,
|
|
@@ -4540,7 +4636,7 @@ async function prepareResponsesTools({
|
|
|
4540
4636
|
case "provider": {
|
|
4541
4637
|
switch (tool.id) {
|
|
4542
4638
|
case "openai.file_search": {
|
|
4543
|
-
const args = await (
|
|
4639
|
+
const args = await validateTypes2({
|
|
4544
4640
|
value: tool.args,
|
|
4545
4641
|
schema: fileSearchArgsSchema
|
|
4546
4642
|
});
|
|
@@ -4563,7 +4659,7 @@ async function prepareResponsesTools({
|
|
|
4563
4659
|
break;
|
|
4564
4660
|
}
|
|
4565
4661
|
case "openai.shell": {
|
|
4566
|
-
const args = await (
|
|
4662
|
+
const args = await validateTypes2({
|
|
4567
4663
|
value: tool.args,
|
|
4568
4664
|
schema: shellArgsSchema
|
|
4569
4665
|
});
|
|
@@ -4582,7 +4678,7 @@ async function prepareResponsesTools({
|
|
|
4582
4678
|
break;
|
|
4583
4679
|
}
|
|
4584
4680
|
case "openai.web_search_preview": {
|
|
4585
|
-
const args = await (
|
|
4681
|
+
const args = await validateTypes2({
|
|
4586
4682
|
value: tool.args,
|
|
4587
4683
|
schema: webSearchPreviewArgsSchema
|
|
4588
4684
|
});
|
|
@@ -4594,7 +4690,7 @@ async function prepareResponsesTools({
|
|
|
4594
4690
|
break;
|
|
4595
4691
|
}
|
|
4596
4692
|
case "openai.web_search": {
|
|
4597
|
-
const args = await (
|
|
4693
|
+
const args = await validateTypes2({
|
|
4598
4694
|
value: tool.args,
|
|
4599
4695
|
schema: webSearchArgsSchema
|
|
4600
4696
|
});
|
|
@@ -4608,7 +4704,7 @@ async function prepareResponsesTools({
|
|
|
4608
4704
|
break;
|
|
4609
4705
|
}
|
|
4610
4706
|
case "openai.code_interpreter": {
|
|
4611
|
-
const args = await (
|
|
4707
|
+
const args = await validateTypes2({
|
|
4612
4708
|
value: tool.args,
|
|
4613
4709
|
schema: codeInterpreterArgsSchema
|
|
4614
4710
|
});
|
|
@@ -4619,7 +4715,7 @@ async function prepareResponsesTools({
|
|
|
4619
4715
|
break;
|
|
4620
4716
|
}
|
|
4621
4717
|
case "openai.image_generation": {
|
|
4622
|
-
const args = await (
|
|
4718
|
+
const args = await validateTypes2({
|
|
4623
4719
|
value: tool.args,
|
|
4624
4720
|
schema: imageGenerationArgsSchema
|
|
4625
4721
|
});
|
|
@@ -4642,7 +4738,7 @@ async function prepareResponsesTools({
|
|
|
4642
4738
|
break;
|
|
4643
4739
|
}
|
|
4644
4740
|
case "openai.mcp": {
|
|
4645
|
-
const args = await (
|
|
4741
|
+
const args = await validateTypes2({
|
|
4646
4742
|
value: tool.args,
|
|
4647
4743
|
schema: mcpArgsSchema
|
|
4648
4744
|
});
|
|
@@ -4668,7 +4764,7 @@ async function prepareResponsesTools({
|
|
|
4668
4764
|
break;
|
|
4669
4765
|
}
|
|
4670
4766
|
case "openai.custom": {
|
|
4671
|
-
const args = await (
|
|
4767
|
+
const args = await validateTypes2({
|
|
4672
4768
|
value: tool.args,
|
|
4673
4769
|
schema: customArgsSchema
|
|
4674
4770
|
});
|
|
@@ -4682,7 +4778,7 @@ async function prepareResponsesTools({
|
|
|
4682
4778
|
break;
|
|
4683
4779
|
}
|
|
4684
4780
|
case "openai.tool_search": {
|
|
4685
|
-
const args = await (
|
|
4781
|
+
const args = await validateTypes2({
|
|
4686
4782
|
value: tool.args,
|
|
4687
4783
|
schema: toolSearchArgsSchema
|
|
4688
4784
|
});
|
|
@@ -4724,7 +4820,7 @@ async function prepareResponsesTools({
|
|
|
4724
4820
|
}
|
|
4725
4821
|
default: {
|
|
4726
4822
|
const _exhaustiveCheck = type;
|
|
4727
|
-
throw new
|
|
4823
|
+
throw new UnsupportedFunctionalityError5({
|
|
4728
4824
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
4729
4825
|
});
|
|
4730
4826
|
}
|
|
@@ -4764,7 +4860,7 @@ function mapShellSkills(skills) {
|
|
|
4764
4860
|
var _a, _b;
|
|
4765
4861
|
return skill.type === "skillReference" ? {
|
|
4766
4862
|
type: "skill_reference",
|
|
4767
|
-
skill_id: (
|
|
4863
|
+
skill_id: resolveProviderReference3({
|
|
4768
4864
|
reference: (_a = skill.providerReference) != null ? _a : {},
|
|
4769
4865
|
provider: "openai"
|
|
4770
4866
|
}),
|
|
@@ -4847,19 +4943,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4847
4943
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
4848
4944
|
}
|
|
4849
4945
|
const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
|
|
4850
|
-
let openaiOptions = await (
|
|
4946
|
+
let openaiOptions = await parseProviderOptions6({
|
|
4851
4947
|
provider: providerOptionsName,
|
|
4852
4948
|
providerOptions,
|
|
4853
4949
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
4854
4950
|
});
|
|
4855
4951
|
if (openaiOptions == null && providerOptionsName !== "openai") {
|
|
4856
|
-
openaiOptions = await (
|
|
4952
|
+
openaiOptions = await parseProviderOptions6({
|
|
4857
4953
|
provider: "openai",
|
|
4858
4954
|
providerOptions,
|
|
4859
4955
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
4860
4956
|
});
|
|
4861
4957
|
}
|
|
4862
|
-
const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : (
|
|
4958
|
+
const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : isCustomReasoning2(reasoning) ? reasoning : void 0;
|
|
4863
4959
|
const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
4864
4960
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
4865
4961
|
warnings.push({
|
|
@@ -4868,7 +4964,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4868
4964
|
details: "conversation and previousResponseId cannot be used together"
|
|
4869
4965
|
});
|
|
4870
4966
|
}
|
|
4871
|
-
const toolNameMapping =
|
|
4967
|
+
const toolNameMapping = createToolNameMapping({
|
|
4872
4968
|
tools,
|
|
4873
4969
|
providerToolNames: {
|
|
4874
4970
|
"openai.code_interpreter": "code_interpreter",
|
|
@@ -5082,19 +5178,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5082
5178
|
responseHeaders,
|
|
5083
5179
|
value: response,
|
|
5084
5180
|
rawValue: rawResponse
|
|
5085
|
-
} = await (
|
|
5181
|
+
} = await postJsonToApi5({
|
|
5086
5182
|
url,
|
|
5087
|
-
headers: (
|
|
5183
|
+
headers: combineHeaders6(this.config.headers(), options.headers),
|
|
5088
5184
|
body,
|
|
5089
5185
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
5090
|
-
successfulResponseHandler: (
|
|
5186
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
5091
5187
|
openaiResponsesResponseSchema
|
|
5092
5188
|
),
|
|
5093
5189
|
abortSignal: options.abortSignal,
|
|
5094
5190
|
fetch: this.config.fetch
|
|
5095
5191
|
});
|
|
5096
5192
|
if (response.error) {
|
|
5097
|
-
throw new
|
|
5193
|
+
throw new APICallError({
|
|
5098
5194
|
message: response.error.message,
|
|
5099
5195
|
url,
|
|
5100
5196
|
requestBodyValues: body,
|
|
@@ -5263,7 +5359,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5263
5359
|
content.push({
|
|
5264
5360
|
type: "source",
|
|
5265
5361
|
sourceType: "url",
|
|
5266
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (
|
|
5362
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
5267
5363
|
url: annotation.url,
|
|
5268
5364
|
title: annotation.title
|
|
5269
5365
|
});
|
|
@@ -5271,7 +5367,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5271
5367
|
content.push({
|
|
5272
5368
|
type: "source",
|
|
5273
5369
|
sourceType: "document",
|
|
5274
|
-
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (
|
|
5370
|
+
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
|
|
5275
5371
|
mediaType: "text/plain",
|
|
5276
5372
|
title: annotation.filename,
|
|
5277
5373
|
filename: annotation.filename,
|
|
@@ -5287,7 +5383,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5287
5383
|
content.push({
|
|
5288
5384
|
type: "source",
|
|
5289
5385
|
sourceType: "document",
|
|
5290
|
-
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (
|
|
5386
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
|
|
5291
5387
|
mediaType: "text/plain",
|
|
5292
5388
|
title: annotation.filename,
|
|
5293
5389
|
filename: annotation.filename,
|
|
@@ -5303,7 +5399,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5303
5399
|
content.push({
|
|
5304
5400
|
type: "source",
|
|
5305
5401
|
sourceType: "document",
|
|
5306
|
-
id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (
|
|
5402
|
+
id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
|
|
5307
5403
|
mediaType: "application/octet-stream",
|
|
5308
5404
|
title: annotation.file_id,
|
|
5309
5405
|
filename: annotation.file_id,
|
|
@@ -5407,7 +5503,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5407
5503
|
}
|
|
5408
5504
|
case "mcp_approval_request": {
|
|
5409
5505
|
const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
|
|
5410
|
-
const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (
|
|
5506
|
+
const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2();
|
|
5411
5507
|
const toolName = `mcp.${part.name}`;
|
|
5412
5508
|
content.push({
|
|
5413
5509
|
type: "tool-call",
|
|
@@ -5562,18 +5658,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5562
5658
|
providerOptionsName,
|
|
5563
5659
|
isShellProviderExecuted
|
|
5564
5660
|
} = await this.getArgs(options);
|
|
5565
|
-
const { responseHeaders, value: response } = await (
|
|
5661
|
+
const { responseHeaders, value: response } = await postJsonToApi5({
|
|
5566
5662
|
url: this.config.url({
|
|
5567
5663
|
path: "/responses",
|
|
5568
5664
|
modelId: this.modelId
|
|
5569
5665
|
}),
|
|
5570
|
-
headers: (
|
|
5666
|
+
headers: combineHeaders6(this.config.headers(), options.headers),
|
|
5571
5667
|
body: {
|
|
5572
5668
|
...body,
|
|
5573
5669
|
stream: true
|
|
5574
5670
|
},
|
|
5575
5671
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
5576
|
-
successfulResponseHandler: (
|
|
5672
|
+
successfulResponseHandler: createEventSourceResponseHandler3(
|
|
5577
5673
|
openaiResponsesChunkSchema
|
|
5578
5674
|
),
|
|
5579
5675
|
abortSignal: options.abortSignal,
|
|
@@ -6053,7 +6149,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6053
6149
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6054
6150
|
} else if (value.item.type === "mcp_approval_request") {
|
|
6055
6151
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6056
|
-
const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (
|
|
6152
|
+
const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2();
|
|
6057
6153
|
const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
|
|
6058
6154
|
approvalRequestIdToDummyToolCallIdFromStream.set(
|
|
6059
6155
|
approvalRequestId,
|
|
@@ -6356,7 +6452,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6356
6452
|
controller.enqueue({
|
|
6357
6453
|
type: "source",
|
|
6358
6454
|
sourceType: "url",
|
|
6359
|
-
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (
|
|
6455
|
+
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
|
|
6360
6456
|
url: value.annotation.url,
|
|
6361
6457
|
title: value.annotation.title
|
|
6362
6458
|
});
|
|
@@ -6364,7 +6460,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6364
6460
|
controller.enqueue({
|
|
6365
6461
|
type: "source",
|
|
6366
6462
|
sourceType: "document",
|
|
6367
|
-
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (
|
|
6463
|
+
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
|
|
6368
6464
|
mediaType: "text/plain",
|
|
6369
6465
|
title: value.annotation.filename,
|
|
6370
6466
|
filename: value.annotation.filename,
|
|
@@ -6380,7 +6476,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6380
6476
|
controller.enqueue({
|
|
6381
6477
|
type: "source",
|
|
6382
6478
|
sourceType: "document",
|
|
6383
|
-
id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (
|
|
6479
|
+
id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
|
|
6384
6480
|
mediaType: "text/plain",
|
|
6385
6481
|
title: value.annotation.filename,
|
|
6386
6482
|
filename: value.annotation.filename,
|
|
@@ -6396,7 +6492,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6396
6492
|
controller.enqueue({
|
|
6397
6493
|
type: "source",
|
|
6398
6494
|
sourceType: "document",
|
|
6399
|
-
id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (
|
|
6495
|
+
id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
|
|
6400
6496
|
mediaType: "application/octet-stream",
|
|
6401
6497
|
title: value.annotation.file_id,
|
|
6402
6498
|
filename: value.annotation.file_id,
|
|
@@ -6509,16 +6605,21 @@ function escapeJSONDelta(delta) {
|
|
|
6509
6605
|
}
|
|
6510
6606
|
|
|
6511
6607
|
// src/speech/openai-speech-model.ts
|
|
6512
|
-
|
|
6608
|
+
import {
|
|
6609
|
+
combineHeaders as combineHeaders7,
|
|
6610
|
+
createBinaryResponseHandler,
|
|
6611
|
+
parseProviderOptions as parseProviderOptions7,
|
|
6612
|
+
postJsonToApi as postJsonToApi6
|
|
6613
|
+
} from "@ai-sdk/provider-utils";
|
|
6513
6614
|
|
|
6514
6615
|
// src/speech/openai-speech-options.ts
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
var openaiSpeechModelOptionsSchema = (
|
|
6518
|
-
() => (
|
|
6519
|
-
|
|
6520
|
-
instructions:
|
|
6521
|
-
speed:
|
|
6616
|
+
import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
|
|
6617
|
+
import { z as z25 } from "zod/v4";
|
|
6618
|
+
var openaiSpeechModelOptionsSchema = lazySchema23(
|
|
6619
|
+
() => zodSchema23(
|
|
6620
|
+
z25.object({
|
|
6621
|
+
instructions: z25.string().nullish(),
|
|
6622
|
+
speed: z25.number().min(0.25).max(4).default(1).nullish()
|
|
6522
6623
|
})
|
|
6523
6624
|
)
|
|
6524
6625
|
);
|
|
@@ -6543,7 +6644,7 @@ var OpenAISpeechModel = class {
|
|
|
6543
6644
|
providerOptions
|
|
6544
6645
|
}) {
|
|
6545
6646
|
const warnings = [];
|
|
6546
|
-
const openAIOptions = await (
|
|
6647
|
+
const openAIOptions = await parseProviderOptions7({
|
|
6547
6648
|
provider: "openai",
|
|
6548
6649
|
providerOptions,
|
|
6549
6650
|
schema: openaiSpeechModelOptionsSchema
|
|
@@ -6596,15 +6697,15 @@ var OpenAISpeechModel = class {
|
|
|
6596
6697
|
value: audio,
|
|
6597
6698
|
responseHeaders,
|
|
6598
6699
|
rawValue: rawResponse
|
|
6599
|
-
} = await (
|
|
6700
|
+
} = await postJsonToApi6({
|
|
6600
6701
|
url: this.config.url({
|
|
6601
6702
|
path: "/audio/speech",
|
|
6602
6703
|
modelId: this.modelId
|
|
6603
6704
|
}),
|
|
6604
|
-
headers: (
|
|
6705
|
+
headers: combineHeaders7(this.config.headers(), options.headers),
|
|
6605
6706
|
body: requestBody,
|
|
6606
6707
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
6607
|
-
successfulResponseHandler:
|
|
6708
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
6608
6709
|
abortSignal: options.abortSignal,
|
|
6609
6710
|
fetch: this.config.fetch
|
|
6610
6711
|
});
|
|
@@ -6625,36 +6726,43 @@ var OpenAISpeechModel = class {
|
|
|
6625
6726
|
};
|
|
6626
6727
|
|
|
6627
6728
|
// src/transcription/openai-transcription-model.ts
|
|
6628
|
-
|
|
6729
|
+
import {
|
|
6730
|
+
combineHeaders as combineHeaders8,
|
|
6731
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
|
6732
|
+
createJsonResponseHandler as createJsonResponseHandler7,
|
|
6733
|
+
mediaTypeToExtension,
|
|
6734
|
+
parseProviderOptions as parseProviderOptions8,
|
|
6735
|
+
postFormDataToApi as postFormDataToApi3
|
|
6736
|
+
} from "@ai-sdk/provider-utils";
|
|
6629
6737
|
|
|
6630
6738
|
// src/transcription/openai-transcription-api.ts
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
var openaiTranscriptionResponseSchema = (
|
|
6634
|
-
() => (
|
|
6635
|
-
|
|
6636
|
-
text:
|
|
6637
|
-
language:
|
|
6638
|
-
duration:
|
|
6639
|
-
words:
|
|
6640
|
-
|
|
6641
|
-
word:
|
|
6642
|
-
start:
|
|
6643
|
-
end:
|
|
6739
|
+
import { lazySchema as lazySchema24, zodSchema as zodSchema24 } from "@ai-sdk/provider-utils";
|
|
6740
|
+
import { z as z26 } from "zod/v4";
|
|
6741
|
+
var openaiTranscriptionResponseSchema = lazySchema24(
|
|
6742
|
+
() => zodSchema24(
|
|
6743
|
+
z26.object({
|
|
6744
|
+
text: z26.string(),
|
|
6745
|
+
language: z26.string().nullish(),
|
|
6746
|
+
duration: z26.number().nullish(),
|
|
6747
|
+
words: z26.array(
|
|
6748
|
+
z26.object({
|
|
6749
|
+
word: z26.string(),
|
|
6750
|
+
start: z26.number(),
|
|
6751
|
+
end: z26.number()
|
|
6644
6752
|
})
|
|
6645
6753
|
).nullish(),
|
|
6646
|
-
segments:
|
|
6647
|
-
|
|
6648
|
-
id:
|
|
6649
|
-
seek:
|
|
6650
|
-
start:
|
|
6651
|
-
end:
|
|
6652
|
-
text:
|
|
6653
|
-
tokens:
|
|
6654
|
-
temperature:
|
|
6655
|
-
avg_logprob:
|
|
6656
|
-
compression_ratio:
|
|
6657
|
-
no_speech_prob:
|
|
6754
|
+
segments: z26.array(
|
|
6755
|
+
z26.object({
|
|
6756
|
+
id: z26.number(),
|
|
6757
|
+
seek: z26.number(),
|
|
6758
|
+
start: z26.number(),
|
|
6759
|
+
end: z26.number(),
|
|
6760
|
+
text: z26.string(),
|
|
6761
|
+
tokens: z26.array(z26.number()),
|
|
6762
|
+
temperature: z26.number(),
|
|
6763
|
+
avg_logprob: z26.number(),
|
|
6764
|
+
compression_ratio: z26.number(),
|
|
6765
|
+
no_speech_prob: z26.number()
|
|
6658
6766
|
})
|
|
6659
6767
|
).nullish()
|
|
6660
6768
|
})
|
|
@@ -6662,33 +6770,33 @@ var openaiTranscriptionResponseSchema = (0, import_provider_utils35.lazySchema)(
|
|
|
6662
6770
|
);
|
|
6663
6771
|
|
|
6664
6772
|
// src/transcription/openai-transcription-options.ts
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
var openAITranscriptionModelOptions = (
|
|
6668
|
-
() => (
|
|
6669
|
-
|
|
6773
|
+
import { lazySchema as lazySchema25, zodSchema as zodSchema25 } from "@ai-sdk/provider-utils";
|
|
6774
|
+
import { z as z27 } from "zod/v4";
|
|
6775
|
+
var openAITranscriptionModelOptions = lazySchema25(
|
|
6776
|
+
() => zodSchema25(
|
|
6777
|
+
z27.object({
|
|
6670
6778
|
/**
|
|
6671
6779
|
* Additional information to include in the transcription response.
|
|
6672
6780
|
*/
|
|
6673
|
-
include:
|
|
6781
|
+
include: z27.array(z27.string()).optional(),
|
|
6674
6782
|
/**
|
|
6675
6783
|
* The language of the input audio in ISO-639-1 format.
|
|
6676
6784
|
*/
|
|
6677
|
-
language:
|
|
6785
|
+
language: z27.string().optional(),
|
|
6678
6786
|
/**
|
|
6679
6787
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
6680
6788
|
*/
|
|
6681
|
-
prompt:
|
|
6789
|
+
prompt: z27.string().optional(),
|
|
6682
6790
|
/**
|
|
6683
6791
|
* The sampling temperature, between 0 and 1.
|
|
6684
6792
|
* @default 0
|
|
6685
6793
|
*/
|
|
6686
|
-
temperature:
|
|
6794
|
+
temperature: z27.number().min(0).max(1).default(0).optional(),
|
|
6687
6795
|
/**
|
|
6688
6796
|
* The timestamp granularities to populate for this transcription.
|
|
6689
6797
|
* @default ['segment']
|
|
6690
6798
|
*/
|
|
6691
|
-
timestampGranularities:
|
|
6799
|
+
timestampGranularities: z27.array(z27.enum(["word", "segment"])).default(["segment"]).optional()
|
|
6692
6800
|
})
|
|
6693
6801
|
)
|
|
6694
6802
|
);
|
|
@@ -6768,15 +6876,15 @@ var OpenAITranscriptionModel = class {
|
|
|
6768
6876
|
providerOptions
|
|
6769
6877
|
}) {
|
|
6770
6878
|
const warnings = [];
|
|
6771
|
-
const openAIOptions = await (
|
|
6879
|
+
const openAIOptions = await parseProviderOptions8({
|
|
6772
6880
|
provider: "openai",
|
|
6773
6881
|
providerOptions,
|
|
6774
6882
|
schema: openAITranscriptionModelOptions
|
|
6775
6883
|
});
|
|
6776
6884
|
const formData = new FormData();
|
|
6777
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(
|
|
6885
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array3(audio)]);
|
|
6778
6886
|
formData.append("model", this.modelId);
|
|
6779
|
-
const fileExtension =
|
|
6887
|
+
const fileExtension = mediaTypeToExtension(mediaType);
|
|
6780
6888
|
formData.append(
|
|
6781
6889
|
"file",
|
|
6782
6890
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -6821,15 +6929,15 @@ var OpenAITranscriptionModel = class {
|
|
|
6821
6929
|
value: response,
|
|
6822
6930
|
responseHeaders,
|
|
6823
6931
|
rawValue: rawResponse
|
|
6824
|
-
} = await (
|
|
6932
|
+
} = await postFormDataToApi3({
|
|
6825
6933
|
url: this.config.url({
|
|
6826
6934
|
path: "/audio/transcriptions",
|
|
6827
6935
|
modelId: this.modelId
|
|
6828
6936
|
}),
|
|
6829
|
-
headers: (
|
|
6937
|
+
headers: combineHeaders8(this.config.headers(), options.headers),
|
|
6830
6938
|
formData,
|
|
6831
6939
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
6832
|
-
successfulResponseHandler: (
|
|
6940
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
6833
6941
|
openaiTranscriptionResponseSchema
|
|
6834
6942
|
),
|
|
6835
6943
|
abortSignal: options.abortSignal,
|
|
@@ -6861,31 +6969,36 @@ var OpenAITranscriptionModel = class {
|
|
|
6861
6969
|
};
|
|
6862
6970
|
|
|
6863
6971
|
// src/skills/openai-skills.ts
|
|
6864
|
-
|
|
6972
|
+
import {
|
|
6973
|
+
combineHeaders as combineHeaders9,
|
|
6974
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array4,
|
|
6975
|
+
createJsonResponseHandler as createJsonResponseHandler8,
|
|
6976
|
+
postFormDataToApi as postFormDataToApi4
|
|
6977
|
+
} from "@ai-sdk/provider-utils";
|
|
6865
6978
|
|
|
6866
6979
|
// src/skills/openai-skills-api.ts
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
var openaiSkillResponseSchema = (
|
|
6870
|
-
() => (
|
|
6871
|
-
|
|
6872
|
-
id:
|
|
6873
|
-
name:
|
|
6874
|
-
description:
|
|
6875
|
-
default_version:
|
|
6876
|
-
latest_version:
|
|
6877
|
-
created_at:
|
|
6878
|
-
updated_at:
|
|
6980
|
+
import { lazySchema as lazySchema26, zodSchema as zodSchema26 } from "@ai-sdk/provider-utils";
|
|
6981
|
+
import { z as z28 } from "zod/v4";
|
|
6982
|
+
var openaiSkillResponseSchema = lazySchema26(
|
|
6983
|
+
() => zodSchema26(
|
|
6984
|
+
z28.object({
|
|
6985
|
+
id: z28.string(),
|
|
6986
|
+
name: z28.string().nullish(),
|
|
6987
|
+
description: z28.string().nullish(),
|
|
6988
|
+
default_version: z28.string().nullish(),
|
|
6989
|
+
latest_version: z28.string().nullish(),
|
|
6990
|
+
created_at: z28.number(),
|
|
6991
|
+
updated_at: z28.number().nullish()
|
|
6879
6992
|
})
|
|
6880
6993
|
)
|
|
6881
6994
|
);
|
|
6882
|
-
var openaiSkillVersionResponseSchema = (
|
|
6883
|
-
() => (
|
|
6884
|
-
|
|
6885
|
-
id:
|
|
6886
|
-
version:
|
|
6887
|
-
name:
|
|
6888
|
-
description:
|
|
6995
|
+
var openaiSkillVersionResponseSchema = lazySchema26(
|
|
6996
|
+
() => zodSchema26(
|
|
6997
|
+
z28.object({
|
|
6998
|
+
id: z28.string(),
|
|
6999
|
+
version: z28.string().nullish(),
|
|
7000
|
+
name: z28.string().nullish(),
|
|
7001
|
+
description: z28.string().nullish()
|
|
6889
7002
|
})
|
|
6890
7003
|
)
|
|
6891
7004
|
);
|
|
@@ -6909,15 +7022,15 @@ var OpenAISkills = class {
|
|
|
6909
7022
|
}
|
|
6910
7023
|
const formData = new FormData();
|
|
6911
7024
|
for (const file of params.files) {
|
|
6912
|
-
const content = typeof file.content === "string" ? (
|
|
7025
|
+
const content = typeof file.content === "string" ? convertBase64ToUint8Array4(file.content) : file.content;
|
|
6913
7026
|
formData.append("files[]", new Blob([content]), file.path);
|
|
6914
7027
|
}
|
|
6915
|
-
const { value: response } = await (
|
|
7028
|
+
const { value: response } = await postFormDataToApi4({
|
|
6916
7029
|
url: this.config.url({ path: "/skills" }),
|
|
6917
|
-
headers: (
|
|
7030
|
+
headers: combineHeaders9(this.config.headers()),
|
|
6918
7031
|
formData,
|
|
6919
7032
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
6920
|
-
successfulResponseHandler: (
|
|
7033
|
+
successfulResponseHandler: createJsonResponseHandler8(
|
|
6921
7034
|
openaiSkillResponseSchema
|
|
6922
7035
|
),
|
|
6923
7036
|
fetch: this.config.fetch
|
|
@@ -6940,21 +7053,21 @@ var OpenAISkills = class {
|
|
|
6940
7053
|
};
|
|
6941
7054
|
|
|
6942
7055
|
// src/version.ts
|
|
6943
|
-
var VERSION = true ? "4.0.0-beta.
|
|
7056
|
+
var VERSION = true ? "4.0.0-beta.30" : "0.0.0-test";
|
|
6944
7057
|
|
|
6945
7058
|
// src/openai-provider.ts
|
|
6946
7059
|
function createOpenAI(options = {}) {
|
|
6947
7060
|
var _a, _b;
|
|
6948
|
-
const baseURL = (_a =
|
|
6949
|
-
|
|
7061
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
7062
|
+
loadOptionalSetting({
|
|
6950
7063
|
settingValue: options.baseURL,
|
|
6951
7064
|
environmentVariableName: "OPENAI_BASE_URL"
|
|
6952
7065
|
})
|
|
6953
7066
|
)) != null ? _a : "https://api.openai.com/v1";
|
|
6954
7067
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
6955
|
-
const getHeaders = () =>
|
|
7068
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
6956
7069
|
{
|
|
6957
|
-
Authorization: `Bearer ${
|
|
7070
|
+
Authorization: `Bearer ${loadApiKey({
|
|
6958
7071
|
apiKey: options.apiKey,
|
|
6959
7072
|
environmentVariableName: "OPENAI_API_KEY",
|
|
6960
7073
|
description: "OpenAI"
|
|
@@ -7055,10 +7168,9 @@ function createOpenAI(options = {}) {
|
|
|
7055
7168
|
return provider;
|
|
7056
7169
|
}
|
|
7057
7170
|
var openai = createOpenAI();
|
|
7058
|
-
|
|
7059
|
-
0 && (module.exports = {
|
|
7171
|
+
export {
|
|
7060
7172
|
VERSION,
|
|
7061
7173
|
createOpenAI,
|
|
7062
7174
|
openai
|
|
7063
|
-
}
|
|
7175
|
+
};
|
|
7064
7176
|
//# sourceMappingURL=index.js.map
|