@ai-sdk/openai 2.0.49 → 2.0.51
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.d.mts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +64 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -69
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +62 -63
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +66 -67
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1954,7 +1954,7 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
|
1954
1954
|
|
|
1955
1955
|
// src/tool/web-search.ts
|
|
1956
1956
|
import {
|
|
1957
|
-
|
|
1957
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
|
|
1958
1958
|
lazySchema as lazySchema5,
|
|
1959
1959
|
zodSchema as zodSchema12
|
|
1960
1960
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1962,9 +1962,7 @@ import { z as z13 } from "zod/v4";
|
|
|
1962
1962
|
var webSearchArgsSchema = lazySchema5(
|
|
1963
1963
|
() => zodSchema12(
|
|
1964
1964
|
z13.object({
|
|
1965
|
-
filters: z13.object({
|
|
1966
|
-
allowedDomains: z13.array(z13.string()).optional()
|
|
1967
|
-
}).optional(),
|
|
1965
|
+
filters: z13.object({ allowedDomains: z13.array(z13.string()).optional() }).optional(),
|
|
1968
1966
|
searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
|
|
1969
1967
|
userLocation: z13.object({
|
|
1970
1968
|
type: z13.literal("approximate"),
|
|
@@ -1976,16 +1974,17 @@ var webSearchArgsSchema = lazySchema5(
|
|
|
1976
1974
|
})
|
|
1977
1975
|
)
|
|
1978
1976
|
);
|
|
1979
|
-
var webSearchInputSchema = lazySchema5(
|
|
1977
|
+
var webSearchInputSchema = lazySchema5(() => zodSchema12(z13.object({})));
|
|
1978
|
+
var webSearchOutputSchema = lazySchema5(
|
|
1980
1979
|
() => zodSchema12(
|
|
1981
1980
|
z13.object({
|
|
1982
1981
|
action: z13.discriminatedUnion("type", [
|
|
1983
1982
|
z13.object({
|
|
1984
1983
|
type: z13.literal("search"),
|
|
1985
|
-
query: z13.string().
|
|
1984
|
+
query: z13.string().optional()
|
|
1986
1985
|
}),
|
|
1987
1986
|
z13.object({
|
|
1988
|
-
type: z13.literal("
|
|
1987
|
+
type: z13.literal("openPage"),
|
|
1989
1988
|
url: z13.string()
|
|
1990
1989
|
}),
|
|
1991
1990
|
z13.object({
|
|
@@ -1993,22 +1992,21 @@ var webSearchInputSchema = lazySchema5(
|
|
|
1993
1992
|
url: z13.string(),
|
|
1994
1993
|
pattern: z13.string()
|
|
1995
1994
|
})
|
|
1996
|
-
])
|
|
1995
|
+
])
|
|
1997
1996
|
})
|
|
1998
1997
|
)
|
|
1999
1998
|
);
|
|
2000
|
-
var webSearchToolFactory =
|
|
1999
|
+
var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema5({
|
|
2001
2000
|
id: "openai.web_search",
|
|
2002
2001
|
name: "web_search",
|
|
2003
|
-
inputSchema: webSearchInputSchema
|
|
2002
|
+
inputSchema: webSearchInputSchema,
|
|
2003
|
+
outputSchema: webSearchOutputSchema
|
|
2004
2004
|
});
|
|
2005
|
-
var webSearch = (args = {}) =>
|
|
2006
|
-
return webSearchToolFactory(args);
|
|
2007
|
-
};
|
|
2005
|
+
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
2008
2006
|
|
|
2009
2007
|
// src/tool/web-search-preview.ts
|
|
2010
2008
|
import {
|
|
2011
|
-
|
|
2009
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
|
|
2012
2010
|
lazySchema as lazySchema6,
|
|
2013
2011
|
zodSchema as zodSchema13
|
|
2014
2012
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2016,51 +2014,30 @@ import { z as z14 } from "zod/v4";
|
|
|
2016
2014
|
var webSearchPreviewArgsSchema = lazySchema6(
|
|
2017
2015
|
() => zodSchema13(
|
|
2018
2016
|
z14.object({
|
|
2019
|
-
/**
|
|
2020
|
-
* Search context size to use for the web search.
|
|
2021
|
-
* - high: Most comprehensive context, highest cost, slower response
|
|
2022
|
-
* - medium: Balanced context, cost, and latency (default)
|
|
2023
|
-
* - low: Least context, lowest cost, fastest response
|
|
2024
|
-
*/
|
|
2025
2017
|
searchContextSize: z14.enum(["low", "medium", "high"]).optional(),
|
|
2026
|
-
/**
|
|
2027
|
-
* User location information to provide geographically relevant search results.
|
|
2028
|
-
*/
|
|
2029
2018
|
userLocation: z14.object({
|
|
2030
|
-
/**
|
|
2031
|
-
* Type of location (always 'approximate')
|
|
2032
|
-
*/
|
|
2033
2019
|
type: z14.literal("approximate"),
|
|
2034
|
-
/**
|
|
2035
|
-
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2036
|
-
*/
|
|
2037
2020
|
country: z14.string().optional(),
|
|
2038
|
-
/**
|
|
2039
|
-
* City name (free text, e.g., 'Minneapolis')
|
|
2040
|
-
*/
|
|
2041
2021
|
city: z14.string().optional(),
|
|
2042
|
-
/**
|
|
2043
|
-
* Region name (free text, e.g., 'Minnesota')
|
|
2044
|
-
*/
|
|
2045
2022
|
region: z14.string().optional(),
|
|
2046
|
-
/**
|
|
2047
|
-
* IANA timezone (e.g., 'America/Chicago')
|
|
2048
|
-
*/
|
|
2049
2023
|
timezone: z14.string().optional()
|
|
2050
2024
|
}).optional()
|
|
2051
2025
|
})
|
|
2052
2026
|
)
|
|
2053
2027
|
);
|
|
2054
2028
|
var webSearchPreviewInputSchema = lazySchema6(
|
|
2029
|
+
() => zodSchema13(z14.object({}))
|
|
2030
|
+
);
|
|
2031
|
+
var webSearchPreviewOutputSchema = lazySchema6(
|
|
2055
2032
|
() => zodSchema13(
|
|
2056
2033
|
z14.object({
|
|
2057
2034
|
action: z14.discriminatedUnion("type", [
|
|
2058
2035
|
z14.object({
|
|
2059
2036
|
type: z14.literal("search"),
|
|
2060
|
-
query: z14.string().
|
|
2037
|
+
query: z14.string().optional()
|
|
2061
2038
|
}),
|
|
2062
2039
|
z14.object({
|
|
2063
|
-
type: z14.literal("
|
|
2040
|
+
type: z14.literal("openPage"),
|
|
2064
2041
|
url: z14.string()
|
|
2065
2042
|
}),
|
|
2066
2043
|
z14.object({
|
|
@@ -2068,14 +2045,15 @@ var webSearchPreviewInputSchema = lazySchema6(
|
|
|
2068
2045
|
url: z14.string(),
|
|
2069
2046
|
pattern: z14.string()
|
|
2070
2047
|
})
|
|
2071
|
-
])
|
|
2048
|
+
])
|
|
2072
2049
|
})
|
|
2073
2050
|
)
|
|
2074
2051
|
);
|
|
2075
|
-
var webSearchPreview =
|
|
2052
|
+
var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema6({
|
|
2076
2053
|
id: "openai.web_search_preview",
|
|
2077
2054
|
name: "web_search_preview",
|
|
2078
|
-
inputSchema: webSearchPreviewInputSchema
|
|
2055
|
+
inputSchema: webSearchPreviewInputSchema,
|
|
2056
|
+
outputSchema: webSearchPreviewOutputSchema
|
|
2079
2057
|
});
|
|
2080
2058
|
|
|
2081
2059
|
// src/openai-tools.ts
|
|
@@ -2185,7 +2163,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2185
2163
|
store,
|
|
2186
2164
|
hasLocalShellTool = false
|
|
2187
2165
|
}) {
|
|
2188
|
-
var _a, _b, _c, _d
|
|
2166
|
+
var _a, _b, _c, _d;
|
|
2189
2167
|
const input = [];
|
|
2190
2168
|
const warnings = [];
|
|
2191
2169
|
for (const { role, content } of prompt) {
|
|
@@ -2266,10 +2244,15 @@ async function convertToOpenAIResponsesInput({
|
|
|
2266
2244
|
for (const part of content) {
|
|
2267
2245
|
switch (part.type) {
|
|
2268
2246
|
case "text": {
|
|
2247
|
+
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
2248
|
+
if (store && id != null) {
|
|
2249
|
+
input.push({ type: "item_reference", id });
|
|
2250
|
+
break;
|
|
2251
|
+
}
|
|
2269
2252
|
input.push({
|
|
2270
2253
|
role: "assistant",
|
|
2271
2254
|
content: [{ type: "output_text", text: part.text }],
|
|
2272
|
-
id
|
|
2255
|
+
id
|
|
2273
2256
|
});
|
|
2274
2257
|
break;
|
|
2275
2258
|
}
|
|
@@ -2278,6 +2261,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2278
2261
|
if (part.providerExecuted) {
|
|
2279
2262
|
break;
|
|
2280
2263
|
}
|
|
2264
|
+
const id = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.itemId;
|
|
2265
|
+
if (store && id != null) {
|
|
2266
|
+
input.push({ type: "item_reference", id });
|
|
2267
|
+
break;
|
|
2268
|
+
}
|
|
2281
2269
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2282
2270
|
const parsedInput = await validateTypes({
|
|
2283
2271
|
value: part.input,
|
|
@@ -2286,7 +2274,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2286
2274
|
input.push({
|
|
2287
2275
|
type: "local_shell_call",
|
|
2288
2276
|
call_id: part.toolCallId,
|
|
2289
|
-
id
|
|
2277
|
+
id,
|
|
2290
2278
|
action: {
|
|
2291
2279
|
type: "exec",
|
|
2292
2280
|
command: parsedInput.action.command,
|
|
@@ -2303,7 +2291,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2303
2291
|
call_id: part.toolCallId,
|
|
2304
2292
|
name: part.toolName,
|
|
2305
2293
|
arguments: JSON.stringify(part.input),
|
|
2306
|
-
id
|
|
2294
|
+
id
|
|
2307
2295
|
});
|
|
2308
2296
|
break;
|
|
2309
2297
|
}
|
|
@@ -2529,11 +2517,7 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2529
2517
|
z16.object({
|
|
2530
2518
|
type: z16.literal("web_search_call"),
|
|
2531
2519
|
id: z16.string(),
|
|
2532
|
-
status: z16.string()
|
|
2533
|
-
action: z16.object({
|
|
2534
|
-
type: z16.literal("search"),
|
|
2535
|
-
query: z16.string().optional()
|
|
2536
|
-
}).nullish()
|
|
2520
|
+
status: z16.string()
|
|
2537
2521
|
}),
|
|
2538
2522
|
z16.object({
|
|
2539
2523
|
type: z16.literal("computer_call"),
|
|
@@ -2619,7 +2603,7 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2619
2603
|
url: z16.string(),
|
|
2620
2604
|
pattern: z16.string()
|
|
2621
2605
|
})
|
|
2622
|
-
])
|
|
2606
|
+
])
|
|
2623
2607
|
}),
|
|
2624
2608
|
z16.object({
|
|
2625
2609
|
type: z16.literal("file_search_call"),
|
|
@@ -2800,7 +2784,7 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2800
2784
|
url: z16.string(),
|
|
2801
2785
|
pattern: z16.string()
|
|
2802
2786
|
})
|
|
2803
|
-
])
|
|
2787
|
+
])
|
|
2804
2788
|
}),
|
|
2805
2789
|
z16.object({
|
|
2806
2790
|
type: z16.literal("file_search_call"),
|
|
@@ -3503,14 +3487,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3503
3487
|
type: "tool-call",
|
|
3504
3488
|
toolCallId: part.id,
|
|
3505
3489
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3506
|
-
input: JSON.stringify({
|
|
3490
|
+
input: JSON.stringify({}),
|
|
3507
3491
|
providerExecuted: true
|
|
3508
3492
|
});
|
|
3509
3493
|
content.push({
|
|
3510
3494
|
type: "tool-result",
|
|
3511
3495
|
toolCallId: part.id,
|
|
3512
3496
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3513
|
-
result:
|
|
3497
|
+
result: mapWebSearchOutput(part.action),
|
|
3514
3498
|
providerExecuted: true
|
|
3515
3499
|
});
|
|
3516
3500
|
break;
|
|
@@ -3694,6 +3678,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3694
3678
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3695
3679
|
providerExecuted: true
|
|
3696
3680
|
});
|
|
3681
|
+
controller.enqueue({
|
|
3682
|
+
type: "tool-input-end",
|
|
3683
|
+
id: value.item.id
|
|
3684
|
+
});
|
|
3685
|
+
controller.enqueue({
|
|
3686
|
+
type: "tool-call",
|
|
3687
|
+
toolCallId: value.item.id,
|
|
3688
|
+
toolName: "web_search",
|
|
3689
|
+
input: JSON.stringify({}),
|
|
3690
|
+
providerExecuted: true
|
|
3691
|
+
});
|
|
3697
3692
|
} else if (value.item.type === "computer_call") {
|
|
3698
3693
|
ongoingToolCalls[value.output_index] = {
|
|
3699
3694
|
toolName: "computer_use",
|
|
@@ -3787,22 +3782,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3787
3782
|
});
|
|
3788
3783
|
} else if (value.item.type === "web_search_call") {
|
|
3789
3784
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3790
|
-
controller.enqueue({
|
|
3791
|
-
type: "tool-input-end",
|
|
3792
|
-
id: value.item.id
|
|
3793
|
-
});
|
|
3794
|
-
controller.enqueue({
|
|
3795
|
-
type: "tool-call",
|
|
3796
|
-
toolCallId: value.item.id,
|
|
3797
|
-
toolName: "web_search",
|
|
3798
|
-
input: JSON.stringify({ action: value.item.action }),
|
|
3799
|
-
providerExecuted: true
|
|
3800
|
-
});
|
|
3801
3785
|
controller.enqueue({
|
|
3802
3786
|
type: "tool-result",
|
|
3803
3787
|
toolCallId: value.item.id,
|
|
3804
3788
|
toolName: "web_search",
|
|
3805
|
-
result:
|
|
3789
|
+
result: mapWebSearchOutput(value.item.action),
|
|
3806
3790
|
providerExecuted: true
|
|
3807
3791
|
});
|
|
3808
3792
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4133,6 +4117,19 @@ function getResponsesModelConfig(modelId) {
|
|
|
4133
4117
|
isReasoningModel: false
|
|
4134
4118
|
};
|
|
4135
4119
|
}
|
|
4120
|
+
function mapWebSearchOutput(action) {
|
|
4121
|
+
var _a;
|
|
4122
|
+
switch (action.type) {
|
|
4123
|
+
case "search":
|
|
4124
|
+
return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
|
|
4125
|
+
case "open_page":
|
|
4126
|
+
return { action: { type: "openPage", url: action.url } };
|
|
4127
|
+
case "find":
|
|
4128
|
+
return {
|
|
4129
|
+
action: { type: "find", url: action.url, pattern: action.pattern }
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4136
4133
|
|
|
4137
4134
|
// src/speech/openai-speech-model.ts
|
|
4138
4135
|
import {
|
|
@@ -4505,7 +4502,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4505
4502
|
};
|
|
4506
4503
|
|
|
4507
4504
|
// src/version.ts
|
|
4508
|
-
var VERSION = true ? "2.0.
|
|
4505
|
+
var VERSION = true ? "2.0.51" : "0.0.0-test";
|
|
4509
4506
|
|
|
4510
4507
|
// src/openai-provider.ts
|
|
4511
4508
|
function createOpenAI(options = {}) {
|