@ai-sdk/openai 2.0.50 → 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 +6 -0
- package/dist/index.d.mts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +50 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -65
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +48 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +52 -63
- 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
|
|
@@ -2539,11 +2517,7 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2539
2517
|
z16.object({
|
|
2540
2518
|
type: z16.literal("web_search_call"),
|
|
2541
2519
|
id: z16.string(),
|
|
2542
|
-
status: z16.string()
|
|
2543
|
-
action: z16.object({
|
|
2544
|
-
type: z16.literal("search"),
|
|
2545
|
-
query: z16.string().optional()
|
|
2546
|
-
}).nullish()
|
|
2520
|
+
status: z16.string()
|
|
2547
2521
|
}),
|
|
2548
2522
|
z16.object({
|
|
2549
2523
|
type: z16.literal("computer_call"),
|
|
@@ -2629,7 +2603,7 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2629
2603
|
url: z16.string(),
|
|
2630
2604
|
pattern: z16.string()
|
|
2631
2605
|
})
|
|
2632
|
-
])
|
|
2606
|
+
])
|
|
2633
2607
|
}),
|
|
2634
2608
|
z16.object({
|
|
2635
2609
|
type: z16.literal("file_search_call"),
|
|
@@ -2810,7 +2784,7 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2810
2784
|
url: z16.string(),
|
|
2811
2785
|
pattern: z16.string()
|
|
2812
2786
|
})
|
|
2813
|
-
])
|
|
2787
|
+
])
|
|
2814
2788
|
}),
|
|
2815
2789
|
z16.object({
|
|
2816
2790
|
type: z16.literal("file_search_call"),
|
|
@@ -3513,14 +3487,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3513
3487
|
type: "tool-call",
|
|
3514
3488
|
toolCallId: part.id,
|
|
3515
3489
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3516
|
-
input: JSON.stringify({
|
|
3490
|
+
input: JSON.stringify({}),
|
|
3517
3491
|
providerExecuted: true
|
|
3518
3492
|
});
|
|
3519
3493
|
content.push({
|
|
3520
3494
|
type: "tool-result",
|
|
3521
3495
|
toolCallId: part.id,
|
|
3522
3496
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3523
|
-
result:
|
|
3497
|
+
result: mapWebSearchOutput(part.action),
|
|
3524
3498
|
providerExecuted: true
|
|
3525
3499
|
});
|
|
3526
3500
|
break;
|
|
@@ -3704,6 +3678,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3704
3678
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3705
3679
|
providerExecuted: true
|
|
3706
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
|
+
});
|
|
3707
3692
|
} else if (value.item.type === "computer_call") {
|
|
3708
3693
|
ongoingToolCalls[value.output_index] = {
|
|
3709
3694
|
toolName: "computer_use",
|
|
@@ -3797,22 +3782,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3797
3782
|
});
|
|
3798
3783
|
} else if (value.item.type === "web_search_call") {
|
|
3799
3784
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3800
|
-
controller.enqueue({
|
|
3801
|
-
type: "tool-input-end",
|
|
3802
|
-
id: value.item.id
|
|
3803
|
-
});
|
|
3804
|
-
controller.enqueue({
|
|
3805
|
-
type: "tool-call",
|
|
3806
|
-
toolCallId: value.item.id,
|
|
3807
|
-
toolName: "web_search",
|
|
3808
|
-
input: JSON.stringify({ action: value.item.action }),
|
|
3809
|
-
providerExecuted: true
|
|
3810
|
-
});
|
|
3811
3785
|
controller.enqueue({
|
|
3812
3786
|
type: "tool-result",
|
|
3813
3787
|
toolCallId: value.item.id,
|
|
3814
3788
|
toolName: "web_search",
|
|
3815
|
-
result:
|
|
3789
|
+
result: mapWebSearchOutput(value.item.action),
|
|
3816
3790
|
providerExecuted: true
|
|
3817
3791
|
});
|
|
3818
3792
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4143,6 +4117,19 @@ function getResponsesModelConfig(modelId) {
|
|
|
4143
4117
|
isReasoningModel: false
|
|
4144
4118
|
};
|
|
4145
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
|
+
}
|
|
4146
4133
|
|
|
4147
4134
|
// src/speech/openai-speech-model.ts
|
|
4148
4135
|
import {
|
|
@@ -4515,7 +4502,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4515
4502
|
};
|
|
4516
4503
|
|
|
4517
4504
|
// src/version.ts
|
|
4518
|
-
var VERSION = true ? "2.0.
|
|
4505
|
+
var VERSION = true ? "2.0.51" : "0.0.0-test";
|
|
4519
4506
|
|
|
4520
4507
|
// src/openai-provider.ts
|
|
4521
4508
|
function createOpenAI(options = {}) {
|