@ai-sdk/openai 3.0.0-beta.26 → 3.0.0-beta.28
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 +65 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -70
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +63 -64
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +67 -68
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1943,7 +1943,7 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
|
1943
1943
|
|
|
1944
1944
|
// src/tool/web-search.ts
|
|
1945
1945
|
import {
|
|
1946
|
-
|
|
1946
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
|
|
1947
1947
|
lazySchema as lazySchema12,
|
|
1948
1948
|
zodSchema as zodSchema12
|
|
1949
1949
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1951,9 +1951,7 @@ import { z as z13 } from "zod/v4";
|
|
|
1951
1951
|
var webSearchArgsSchema = lazySchema12(
|
|
1952
1952
|
() => zodSchema12(
|
|
1953
1953
|
z13.object({
|
|
1954
|
-
filters: z13.object({
|
|
1955
|
-
allowedDomains: z13.array(z13.string()).optional()
|
|
1956
|
-
}).optional(),
|
|
1954
|
+
filters: z13.object({ allowedDomains: z13.array(z13.string()).optional() }).optional(),
|
|
1957
1955
|
searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
|
|
1958
1956
|
userLocation: z13.object({
|
|
1959
1957
|
type: z13.literal("approximate"),
|
|
@@ -1965,16 +1963,17 @@ var webSearchArgsSchema = lazySchema12(
|
|
|
1965
1963
|
})
|
|
1966
1964
|
)
|
|
1967
1965
|
);
|
|
1968
|
-
var webSearchInputSchema = lazySchema12(
|
|
1966
|
+
var webSearchInputSchema = lazySchema12(() => zodSchema12(z13.object({})));
|
|
1967
|
+
var webSearchOutputSchema = lazySchema12(
|
|
1969
1968
|
() => zodSchema12(
|
|
1970
1969
|
z13.object({
|
|
1971
1970
|
action: z13.discriminatedUnion("type", [
|
|
1972
1971
|
z13.object({
|
|
1973
1972
|
type: z13.literal("search"),
|
|
1974
|
-
query: z13.string().
|
|
1973
|
+
query: z13.string().optional()
|
|
1975
1974
|
}),
|
|
1976
1975
|
z13.object({
|
|
1977
|
-
type: z13.literal("
|
|
1976
|
+
type: z13.literal("openPage"),
|
|
1978
1977
|
url: z13.string()
|
|
1979
1978
|
}),
|
|
1980
1979
|
z13.object({
|
|
@@ -1982,22 +1981,21 @@ var webSearchInputSchema = lazySchema12(
|
|
|
1982
1981
|
url: z13.string(),
|
|
1983
1982
|
pattern: z13.string()
|
|
1984
1983
|
})
|
|
1985
|
-
])
|
|
1984
|
+
])
|
|
1986
1985
|
})
|
|
1987
1986
|
)
|
|
1988
1987
|
);
|
|
1989
|
-
var webSearchToolFactory =
|
|
1988
|
+
var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema5({
|
|
1990
1989
|
id: "openai.web_search",
|
|
1991
1990
|
name: "web_search",
|
|
1992
|
-
inputSchema: webSearchInputSchema
|
|
1991
|
+
inputSchema: webSearchInputSchema,
|
|
1992
|
+
outputSchema: webSearchOutputSchema
|
|
1993
1993
|
});
|
|
1994
|
-
var webSearch = (args = {}) =>
|
|
1995
|
-
return webSearchToolFactory(args);
|
|
1996
|
-
};
|
|
1994
|
+
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
1997
1995
|
|
|
1998
1996
|
// src/tool/web-search-preview.ts
|
|
1999
1997
|
import {
|
|
2000
|
-
|
|
1998
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
|
|
2001
1999
|
lazySchema as lazySchema13,
|
|
2002
2000
|
zodSchema as zodSchema13
|
|
2003
2001
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2005,51 +2003,30 @@ import { z as z14 } from "zod/v4";
|
|
|
2005
2003
|
var webSearchPreviewArgsSchema = lazySchema13(
|
|
2006
2004
|
() => zodSchema13(
|
|
2007
2005
|
z14.object({
|
|
2008
|
-
/**
|
|
2009
|
-
* Search context size to use for the web search.
|
|
2010
|
-
* - high: Most comprehensive context, highest cost, slower response
|
|
2011
|
-
* - medium: Balanced context, cost, and latency (default)
|
|
2012
|
-
* - low: Least context, lowest cost, fastest response
|
|
2013
|
-
*/
|
|
2014
2006
|
searchContextSize: z14.enum(["low", "medium", "high"]).optional(),
|
|
2015
|
-
/**
|
|
2016
|
-
* User location information to provide geographically relevant search results.
|
|
2017
|
-
*/
|
|
2018
2007
|
userLocation: z14.object({
|
|
2019
|
-
/**
|
|
2020
|
-
* Type of location (always 'approximate')
|
|
2021
|
-
*/
|
|
2022
2008
|
type: z14.literal("approximate"),
|
|
2023
|
-
/**
|
|
2024
|
-
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2025
|
-
*/
|
|
2026
2009
|
country: z14.string().optional(),
|
|
2027
|
-
/**
|
|
2028
|
-
* City name (free text, e.g., 'Minneapolis')
|
|
2029
|
-
*/
|
|
2030
2010
|
city: z14.string().optional(),
|
|
2031
|
-
/**
|
|
2032
|
-
* Region name (free text, e.g., 'Minnesota')
|
|
2033
|
-
*/
|
|
2034
2011
|
region: z14.string().optional(),
|
|
2035
|
-
/**
|
|
2036
|
-
* IANA timezone (e.g., 'America/Chicago')
|
|
2037
|
-
*/
|
|
2038
2012
|
timezone: z14.string().optional()
|
|
2039
2013
|
}).optional()
|
|
2040
2014
|
})
|
|
2041
2015
|
)
|
|
2042
2016
|
);
|
|
2043
2017
|
var webSearchPreviewInputSchema = lazySchema13(
|
|
2018
|
+
() => zodSchema13(z14.object({}))
|
|
2019
|
+
);
|
|
2020
|
+
var webSearchPreviewOutputSchema = lazySchema13(
|
|
2044
2021
|
() => zodSchema13(
|
|
2045
2022
|
z14.object({
|
|
2046
2023
|
action: z14.discriminatedUnion("type", [
|
|
2047
2024
|
z14.object({
|
|
2048
2025
|
type: z14.literal("search"),
|
|
2049
|
-
query: z14.string().
|
|
2026
|
+
query: z14.string().optional()
|
|
2050
2027
|
}),
|
|
2051
2028
|
z14.object({
|
|
2052
|
-
type: z14.literal("
|
|
2029
|
+
type: z14.literal("openPage"),
|
|
2053
2030
|
url: z14.string()
|
|
2054
2031
|
}),
|
|
2055
2032
|
z14.object({
|
|
@@ -2057,14 +2034,15 @@ var webSearchPreviewInputSchema = lazySchema13(
|
|
|
2057
2034
|
url: z14.string(),
|
|
2058
2035
|
pattern: z14.string()
|
|
2059
2036
|
})
|
|
2060
|
-
])
|
|
2037
|
+
])
|
|
2061
2038
|
})
|
|
2062
2039
|
)
|
|
2063
2040
|
);
|
|
2064
|
-
var webSearchPreview =
|
|
2041
|
+
var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema6({
|
|
2065
2042
|
id: "openai.web_search_preview",
|
|
2066
2043
|
name: "web_search_preview",
|
|
2067
|
-
inputSchema: webSearchPreviewInputSchema
|
|
2044
|
+
inputSchema: webSearchPreviewInputSchema,
|
|
2045
|
+
outputSchema: webSearchPreviewOutputSchema
|
|
2068
2046
|
});
|
|
2069
2047
|
|
|
2070
2048
|
// src/openai-tools.ts
|
|
@@ -2179,7 +2157,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2179
2157
|
store,
|
|
2180
2158
|
hasLocalShellTool = false
|
|
2181
2159
|
}) {
|
|
2182
|
-
var _a, _b, _c, _d, _e
|
|
2160
|
+
var _a, _b, _c, _d, _e;
|
|
2183
2161
|
const input = [];
|
|
2184
2162
|
const warnings = [];
|
|
2185
2163
|
for (const { role, content } of prompt) {
|
|
@@ -2260,10 +2238,15 @@ async function convertToOpenAIResponsesInput({
|
|
|
2260
2238
|
for (const part of content) {
|
|
2261
2239
|
switch (part.type) {
|
|
2262
2240
|
case "text": {
|
|
2241
|
+
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
2242
|
+
if (store && id != null) {
|
|
2243
|
+
input.push({ type: "item_reference", id });
|
|
2244
|
+
break;
|
|
2245
|
+
}
|
|
2263
2246
|
input.push({
|
|
2264
2247
|
role: "assistant",
|
|
2265
2248
|
content: [{ type: "output_text", text: part.text }],
|
|
2266
|
-
id
|
|
2249
|
+
id
|
|
2267
2250
|
});
|
|
2268
2251
|
break;
|
|
2269
2252
|
}
|
|
@@ -2272,6 +2255,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2272
2255
|
if (part.providerExecuted) {
|
|
2273
2256
|
break;
|
|
2274
2257
|
}
|
|
2258
|
+
const id = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.itemId;
|
|
2259
|
+
if (store && id != null) {
|
|
2260
|
+
input.push({ type: "item_reference", id });
|
|
2261
|
+
break;
|
|
2262
|
+
}
|
|
2275
2263
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2276
2264
|
const parsedInput = await validateTypes({
|
|
2277
2265
|
value: part.input,
|
|
@@ -2280,7 +2268,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2280
2268
|
input.push({
|
|
2281
2269
|
type: "local_shell_call",
|
|
2282
2270
|
call_id: part.toolCallId,
|
|
2283
|
-
id
|
|
2271
|
+
id,
|
|
2284
2272
|
action: {
|
|
2285
2273
|
type: "exec",
|
|
2286
2274
|
command: parsedInput.action.command,
|
|
@@ -2297,7 +2285,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2297
2285
|
call_id: part.toolCallId,
|
|
2298
2286
|
name: part.toolName,
|
|
2299
2287
|
arguments: JSON.stringify(part.input),
|
|
2300
|
-
id
|
|
2288
|
+
id
|
|
2301
2289
|
});
|
|
2302
2290
|
break;
|
|
2303
2291
|
}
|
|
@@ -2390,7 +2378,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2390
2378
|
contentValue = output.value;
|
|
2391
2379
|
break;
|
|
2392
2380
|
case "execution-denied":
|
|
2393
|
-
contentValue = (
|
|
2381
|
+
contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
|
|
2394
2382
|
break;
|
|
2395
2383
|
case "json":
|
|
2396
2384
|
case "error-json":
|
|
@@ -2523,11 +2511,7 @@ var openaiResponsesChunkSchema = lazySchema14(
|
|
|
2523
2511
|
z16.object({
|
|
2524
2512
|
type: z16.literal("web_search_call"),
|
|
2525
2513
|
id: z16.string(),
|
|
2526
|
-
status: z16.string()
|
|
2527
|
-
action: z16.object({
|
|
2528
|
-
type: z16.literal("search"),
|
|
2529
|
-
query: z16.string().optional()
|
|
2530
|
-
}).nullish()
|
|
2514
|
+
status: z16.string()
|
|
2531
2515
|
}),
|
|
2532
2516
|
z16.object({
|
|
2533
2517
|
type: z16.literal("computer_call"),
|
|
@@ -2613,7 +2597,7 @@ var openaiResponsesChunkSchema = lazySchema14(
|
|
|
2613
2597
|
url: z16.string(),
|
|
2614
2598
|
pattern: z16.string()
|
|
2615
2599
|
})
|
|
2616
|
-
])
|
|
2600
|
+
])
|
|
2617
2601
|
}),
|
|
2618
2602
|
z16.object({
|
|
2619
2603
|
type: z16.literal("file_search_call"),
|
|
@@ -2794,7 +2778,7 @@ var openaiResponsesResponseSchema = lazySchema14(
|
|
|
2794
2778
|
url: z16.string(),
|
|
2795
2779
|
pattern: z16.string()
|
|
2796
2780
|
})
|
|
2797
|
-
])
|
|
2781
|
+
])
|
|
2798
2782
|
}),
|
|
2799
2783
|
z16.object({
|
|
2800
2784
|
type: z16.literal("file_search_call"),
|
|
@@ -3495,14 +3479,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3495
3479
|
type: "tool-call",
|
|
3496
3480
|
toolCallId: part.id,
|
|
3497
3481
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3498
|
-
input: JSON.stringify({
|
|
3482
|
+
input: JSON.stringify({}),
|
|
3499
3483
|
providerExecuted: true
|
|
3500
3484
|
});
|
|
3501
3485
|
content.push({
|
|
3502
3486
|
type: "tool-result",
|
|
3503
3487
|
toolCallId: part.id,
|
|
3504
3488
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3505
|
-
result:
|
|
3489
|
+
result: mapWebSearchOutput(part.action),
|
|
3506
3490
|
providerExecuted: true
|
|
3507
3491
|
});
|
|
3508
3492
|
break;
|
|
@@ -3686,6 +3670,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3686
3670
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3687
3671
|
providerExecuted: true
|
|
3688
3672
|
});
|
|
3673
|
+
controller.enqueue({
|
|
3674
|
+
type: "tool-input-end",
|
|
3675
|
+
id: value.item.id
|
|
3676
|
+
});
|
|
3677
|
+
controller.enqueue({
|
|
3678
|
+
type: "tool-call",
|
|
3679
|
+
toolCallId: value.item.id,
|
|
3680
|
+
toolName: "web_search",
|
|
3681
|
+
input: JSON.stringify({}),
|
|
3682
|
+
providerExecuted: true
|
|
3683
|
+
});
|
|
3689
3684
|
} else if (value.item.type === "computer_call") {
|
|
3690
3685
|
ongoingToolCalls[value.output_index] = {
|
|
3691
3686
|
toolName: "computer_use",
|
|
@@ -3779,22 +3774,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3779
3774
|
});
|
|
3780
3775
|
} else if (value.item.type === "web_search_call") {
|
|
3781
3776
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3782
|
-
controller.enqueue({
|
|
3783
|
-
type: "tool-input-end",
|
|
3784
|
-
id: value.item.id
|
|
3785
|
-
});
|
|
3786
|
-
controller.enqueue({
|
|
3787
|
-
type: "tool-call",
|
|
3788
|
-
toolCallId: value.item.id,
|
|
3789
|
-
toolName: "web_search",
|
|
3790
|
-
input: JSON.stringify({ action: value.item.action }),
|
|
3791
|
-
providerExecuted: true
|
|
3792
|
-
});
|
|
3793
3777
|
controller.enqueue({
|
|
3794
3778
|
type: "tool-result",
|
|
3795
3779
|
toolCallId: value.item.id,
|
|
3796
3780
|
toolName: "web_search",
|
|
3797
|
-
result:
|
|
3781
|
+
result: mapWebSearchOutput(value.item.action),
|
|
3798
3782
|
providerExecuted: true
|
|
3799
3783
|
});
|
|
3800
3784
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4139,6 +4123,19 @@ function getResponsesModelConfig(modelId) {
|
|
|
4139
4123
|
isReasoningModel: false
|
|
4140
4124
|
};
|
|
4141
4125
|
}
|
|
4126
|
+
function mapWebSearchOutput(action) {
|
|
4127
|
+
var _a;
|
|
4128
|
+
switch (action.type) {
|
|
4129
|
+
case "search":
|
|
4130
|
+
return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
|
|
4131
|
+
case "open_page":
|
|
4132
|
+
return { action: { type: "openPage", url: action.url } };
|
|
4133
|
+
case "find":
|
|
4134
|
+
return {
|
|
4135
|
+
action: { type: "find", url: action.url, pattern: action.pattern }
|
|
4136
|
+
};
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4142
4139
|
|
|
4143
4140
|
// src/speech/openai-speech-model.ts
|
|
4144
4141
|
import {
|
|
@@ -4505,7 +4502,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4505
4502
|
};
|
|
4506
4503
|
|
|
4507
4504
|
// src/version.ts
|
|
4508
|
-
var VERSION = true ? "3.0.0-beta.
|
|
4505
|
+
var VERSION = true ? "3.0.0-beta.28" : "0.0.0-test";
|
|
4509
4506
|
|
|
4510
4507
|
// src/openai-provider.ts
|
|
4511
4508
|
function createOpenAI(options = {}) {
|