@ai-sdk/provider-utils 4.0.0-beta.38 → 4.0.0-beta.40
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 +16 -0
- package/dist/index.d.mts +46 -16
- package/dist/index.d.ts +46 -16
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -47,6 +47,32 @@ function convertAsyncIteratorToReadableStream(iterator) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// src/create-tool-name-mapping.ts
|
|
51
|
+
function createToolNameMapping({
|
|
52
|
+
tools = [],
|
|
53
|
+
providerToolNames
|
|
54
|
+
}) {
|
|
55
|
+
const customToolNameToProviderToolName = {};
|
|
56
|
+
const providerToolNameToCustomToolName = {};
|
|
57
|
+
for (const tool2 of tools) {
|
|
58
|
+
if (tool2.type === "provider" && tool2.id in providerToolNames) {
|
|
59
|
+
const providerToolName = providerToolNames[tool2.id];
|
|
60
|
+
customToolNameToProviderToolName[tool2.name] = providerToolName;
|
|
61
|
+
providerToolNameToCustomToolName[providerToolName] = tool2.name;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
toProviderToolName: (customToolName) => {
|
|
66
|
+
var _a;
|
|
67
|
+
return (_a = customToolNameToProviderToolName[customToolName]) != null ? _a : customToolName;
|
|
68
|
+
},
|
|
69
|
+
toCustomToolName: (providerToolName) => {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = providerToolNameToCustomToolName[providerToolName]) != null ? _a : providerToolName;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
50
76
|
// src/delay.ts
|
|
51
77
|
async function delay(delayInMs, options) {
|
|
52
78
|
if (delayInMs == null) {
|
|
@@ -263,7 +289,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
263
289
|
}
|
|
264
290
|
|
|
265
291
|
// src/version.ts
|
|
266
|
-
var VERSION = true ? "4.0.0-beta.
|
|
292
|
+
var VERSION = true ? "4.0.0-beta.40" : "0.0.0-test";
|
|
267
293
|
|
|
268
294
|
// src/get-from-api.ts
|
|
269
295
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2142,10 +2168,9 @@ function dynamicTool(tool2) {
|
|
|
2142
2168
|
return { ...tool2, type: "dynamic" };
|
|
2143
2169
|
}
|
|
2144
2170
|
|
|
2145
|
-
// src/provider-
|
|
2146
|
-
function
|
|
2171
|
+
// src/provider-tool-factory.ts
|
|
2172
|
+
function createProviderToolFactory({
|
|
2147
2173
|
id,
|
|
2148
|
-
name,
|
|
2149
2174
|
inputSchema
|
|
2150
2175
|
}) {
|
|
2151
2176
|
return ({
|
|
@@ -2158,9 +2183,8 @@ function createProviderDefinedToolFactory({
|
|
|
2158
2183
|
onInputAvailable,
|
|
2159
2184
|
...args
|
|
2160
2185
|
}) => tool({
|
|
2161
|
-
type: "provider
|
|
2186
|
+
type: "provider",
|
|
2162
2187
|
id,
|
|
2163
|
-
name,
|
|
2164
2188
|
args,
|
|
2165
2189
|
inputSchema,
|
|
2166
2190
|
outputSchema,
|
|
@@ -2172,9 +2196,8 @@ function createProviderDefinedToolFactory({
|
|
|
2172
2196
|
onInputAvailable
|
|
2173
2197
|
});
|
|
2174
2198
|
}
|
|
2175
|
-
function
|
|
2199
|
+
function createProviderToolFactoryWithOutputSchema({
|
|
2176
2200
|
id,
|
|
2177
|
-
name,
|
|
2178
2201
|
inputSchema,
|
|
2179
2202
|
outputSchema
|
|
2180
2203
|
}) {
|
|
@@ -2187,9 +2210,8 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
2187
2210
|
onInputAvailable,
|
|
2188
2211
|
...args
|
|
2189
2212
|
}) => tool({
|
|
2190
|
-
type: "provider
|
|
2213
|
+
type: "provider",
|
|
2191
2214
|
id,
|
|
2192
|
-
name,
|
|
2193
2215
|
args,
|
|
2194
2216
|
inputSchema,
|
|
2195
2217
|
outputSchema,
|
|
@@ -2423,9 +2445,10 @@ export {
|
|
|
2423
2445
|
createIdGenerator,
|
|
2424
2446
|
createJsonErrorResponseHandler,
|
|
2425
2447
|
createJsonResponseHandler,
|
|
2426
|
-
|
|
2427
|
-
|
|
2448
|
+
createProviderToolFactory,
|
|
2449
|
+
createProviderToolFactoryWithOutputSchema,
|
|
2428
2450
|
createStatusCodeErrorResponseHandler,
|
|
2451
|
+
createToolNameMapping,
|
|
2429
2452
|
delay,
|
|
2430
2453
|
dynamicTool,
|
|
2431
2454
|
executeTool,
|