@ai-sdk/openai 3.0.124 → 3.0.126
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 +13 -0
- package/dist/index.d.mts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +84 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +15 -15
- package/dist/internal/index.d.ts +15 -15
- package/dist/internal/index.js +975 -899
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +967 -890
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/responses/convert-to-openai-responses-input.ts +89 -0
- package/src/responses/openai-responses-api.ts +9 -1
- package/src/responses/openai-responses-language-model.ts +15 -1
package/dist/index.mjs
CHANGED
|
@@ -3169,6 +3169,7 @@ import {
|
|
|
3169
3169
|
isNonNullable,
|
|
3170
3170
|
parseJSON,
|
|
3171
3171
|
parseProviderOptions as parseProviderOptions5,
|
|
3172
|
+
safeValidateTypes,
|
|
3172
3173
|
validateTypes
|
|
3173
3174
|
} from "@ai-sdk/provider-utils";
|
|
3174
3175
|
import { z as z22 } from "zod/v4";
|
|
@@ -3558,6 +3559,57 @@ async function expandParallelToolCall({
|
|
|
3558
3559
|
function serializeToolCallArguments2(input) {
|
|
3559
3560
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
3560
3561
|
}
|
|
3562
|
+
async function convertWebSearchToolResultOutput({
|
|
3563
|
+
output,
|
|
3564
|
+
id
|
|
3565
|
+
}) {
|
|
3566
|
+
if (output.type !== "json") {
|
|
3567
|
+
return void 0;
|
|
3568
|
+
}
|
|
3569
|
+
const validation = await safeValidateTypes({
|
|
3570
|
+
value: output.value,
|
|
3571
|
+
schema: webSearchOutputSchema
|
|
3572
|
+
});
|
|
3573
|
+
if (!validation.success || validation.value.action == null) {
|
|
3574
|
+
return void 0;
|
|
3575
|
+
}
|
|
3576
|
+
const { action, sources } = validation.value;
|
|
3577
|
+
switch (action.type) {
|
|
3578
|
+
case "search":
|
|
3579
|
+
return {
|
|
3580
|
+
type: "web_search_call",
|
|
3581
|
+
id,
|
|
3582
|
+
status: "completed",
|
|
3583
|
+
action: {
|
|
3584
|
+
type: "search",
|
|
3585
|
+
...action.query != null && { query: action.query },
|
|
3586
|
+
...action.queries != null && { queries: action.queries },
|
|
3587
|
+
...sources != null && { sources }
|
|
3588
|
+
}
|
|
3589
|
+
};
|
|
3590
|
+
case "openPage":
|
|
3591
|
+
return {
|
|
3592
|
+
type: "web_search_call",
|
|
3593
|
+
id,
|
|
3594
|
+
status: "completed",
|
|
3595
|
+
action: {
|
|
3596
|
+
type: "open_page",
|
|
3597
|
+
url: action.url
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3600
|
+
case "findInPage":
|
|
3601
|
+
return {
|
|
3602
|
+
type: "web_search_call",
|
|
3603
|
+
id,
|
|
3604
|
+
status: "completed",
|
|
3605
|
+
action: {
|
|
3606
|
+
type: "find_in_page",
|
|
3607
|
+
url: action.url,
|
|
3608
|
+
pattern: action.pattern
|
|
3609
|
+
}
|
|
3610
|
+
};
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3561
3613
|
async function convertFunctionToolResultOutput({
|
|
3562
3614
|
output,
|
|
3563
3615
|
promptCacheBreakpoint,
|
|
@@ -3764,7 +3816,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3764
3816
|
toolSearchToolName,
|
|
3765
3817
|
customProviderToolNames
|
|
3766
3818
|
}) {
|
|
3767
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
3819
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
|
|
3768
3820
|
let input = [];
|
|
3769
3821
|
const warnings = [];
|
|
3770
3822
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -4110,8 +4162,23 @@ async function convertToOpenAIResponsesInput({
|
|
|
4110
4162
|
const resolvedResultToolName = toolNameMapping.toProviderToolName(
|
|
4111
4163
|
part.toolName
|
|
4112
4164
|
);
|
|
4165
|
+
if (resolvedResultToolName === "web_search" || resolvedResultToolName === "web_search_preview") {
|
|
4166
|
+
const itemId = (_u = (_t = (_s = part.providerOptions) == null ? void 0 : _s[providerOptionsName]) == null ? void 0 : _t.itemId) != null ? _u : part.toolCallId;
|
|
4167
|
+
if (store) {
|
|
4168
|
+
input.push({ type: "item_reference", id: itemId });
|
|
4169
|
+
break;
|
|
4170
|
+
}
|
|
4171
|
+
const webSearchCall = await convertWebSearchToolResultOutput({
|
|
4172
|
+
output: part.output,
|
|
4173
|
+
id: itemId
|
|
4174
|
+
});
|
|
4175
|
+
if (webSearchCall != null) {
|
|
4176
|
+
input.push(webSearchCall);
|
|
4177
|
+
break;
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4113
4180
|
if (part.toolName === toolSearchToolName) {
|
|
4114
|
-
const itemId = (
|
|
4181
|
+
const itemId = (_A = (_z = (_w = (_v = part.providerOptions) == null ? void 0 : _v[providerOptionsName]) == null ? void 0 : _w.itemId) != null ? _z : (_y = (_x = part.providerMetadata) == null ? void 0 : _x[providerOptionsName]) == null ? void 0 : _y.itemId) != null ? _A : part.toolCallId;
|
|
4115
4182
|
if (store) {
|
|
4116
4183
|
input.push({ type: "item_reference", id: itemId });
|
|
4117
4184
|
} else if (part.output.type === "json") {
|
|
@@ -4152,7 +4219,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4152
4219
|
break;
|
|
4153
4220
|
}
|
|
4154
4221
|
if (store) {
|
|
4155
|
-
const itemId = (
|
|
4222
|
+
const itemId = (_D = (_C = (_B = part.providerOptions) == null ? void 0 : _B[providerOptionsName]) == null ? void 0 : _C.itemId) != null ? _D : part.toolCallId;
|
|
4156
4223
|
input.push({ type: "item_reference", id: itemId });
|
|
4157
4224
|
} else {
|
|
4158
4225
|
warnings.push({
|
|
@@ -4319,7 +4386,7 @@ ${text}`,
|
|
|
4319
4386
|
}
|
|
4320
4387
|
const output = part.output;
|
|
4321
4388
|
if (output.type === "execution-denied") {
|
|
4322
|
-
const approvalId = (
|
|
4389
|
+
const approvalId = (_F = (_E = output.providerOptions) == null ? void 0 : _E.openai) == null ? void 0 : _F.approvalId;
|
|
4323
4390
|
if (approvalId) {
|
|
4324
4391
|
continue;
|
|
4325
4392
|
}
|
|
@@ -4406,7 +4473,7 @@ ${text}`,
|
|
|
4406
4473
|
break;
|
|
4407
4474
|
case "execution-denied":
|
|
4408
4475
|
outputValue = convertScalarOutput(
|
|
4409
|
-
(
|
|
4476
|
+
(_G = output.reason) != null ? _G : "Tool call execution denied."
|
|
4410
4477
|
);
|
|
4411
4478
|
break;
|
|
4412
4479
|
case "json":
|
|
@@ -4605,7 +4672,7 @@ var openaiResponsesNestedErrorChunkSchema = z23.object({
|
|
|
4605
4672
|
sequence_number: z23.number(),
|
|
4606
4673
|
error: z23.object({
|
|
4607
4674
|
type: z23.string(),
|
|
4608
|
-
code: z23.string(),
|
|
4675
|
+
code: z23.string().nullish(),
|
|
4609
4676
|
message: z23.string(),
|
|
4610
4677
|
param: z23.string().nullish()
|
|
4611
4678
|
})
|
|
@@ -6961,6 +7028,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6961
7028
|
id: value.item.call_id,
|
|
6962
7029
|
toolName
|
|
6963
7030
|
});
|
|
7031
|
+
controller.enqueue({
|
|
7032
|
+
type: "tool-input-delta",
|
|
7033
|
+
id: value.item.call_id,
|
|
7034
|
+
delta: '"'
|
|
7035
|
+
});
|
|
6964
7036
|
} else if (value.item.type === "web_search_call") {
|
|
6965
7037
|
ongoingToolCalls[value.output_index] = {
|
|
6966
7038
|
toolName: toolNameMapping.toCustomToolName(
|
|
@@ -7249,6 +7321,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7249
7321
|
const toolName = toolNameMapping.toCustomToolName(
|
|
7250
7322
|
value.item.name
|
|
7251
7323
|
);
|
|
7324
|
+
controller.enqueue({
|
|
7325
|
+
type: "tool-input-delta",
|
|
7326
|
+
id: value.item.call_id,
|
|
7327
|
+
delta: '"'
|
|
7328
|
+
});
|
|
7252
7329
|
controller.enqueue({
|
|
7253
7330
|
type: "tool-input-end",
|
|
7254
7331
|
id: value.item.call_id
|
|
@@ -7575,7 +7652,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7575
7652
|
controller.enqueue({
|
|
7576
7653
|
type: "tool-input-delta",
|
|
7577
7654
|
id: toolCall.toolCallId,
|
|
7578
|
-
delta: value.delta
|
|
7655
|
+
delta: escapeJSONDelta(value.delta)
|
|
7579
7656
|
});
|
|
7580
7657
|
}
|
|
7581
7658
|
} else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
|
|
@@ -8358,7 +8435,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8358
8435
|
};
|
|
8359
8436
|
|
|
8360
8437
|
// src/version.ts
|
|
8361
|
-
var VERSION = true ? "3.0.
|
|
8438
|
+
var VERSION = true ? "3.0.126" : "0.0.0-test";
|
|
8362
8439
|
|
|
8363
8440
|
// src/openai-provider.ts
|
|
8364
8441
|
function createOpenAI(options = {}) {
|