@ai-sdk/provider-utils 4.0.0-beta.38 → 4.0.0-beta.39

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/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-defined" && 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.38" : "0.0.0-test";
292
+ var VERSION = true ? "4.0.0-beta.39" : "0.0.0-test";
267
293
 
268
294
  // src/get-from-api.ts
269
295
  var getOriginalFetch = () => globalThis.fetch;
@@ -2145,7 +2171,6 @@ function dynamicTool(tool2) {
2145
2171
  // src/provider-defined-tool-factory.ts
2146
2172
  function createProviderDefinedToolFactory({
2147
2173
  id,
2148
- name,
2149
2174
  inputSchema
2150
2175
  }) {
2151
2176
  return ({
@@ -2160,7 +2185,6 @@ function createProviderDefinedToolFactory({
2160
2185
  }) => tool({
2161
2186
  type: "provider-defined",
2162
2187
  id,
2163
- name,
2164
2188
  args,
2165
2189
  inputSchema,
2166
2190
  outputSchema,
@@ -2174,7 +2198,6 @@ function createProviderDefinedToolFactory({
2174
2198
  }
2175
2199
  function createProviderDefinedToolFactoryWithOutputSchema({
2176
2200
  id,
2177
- name,
2178
2201
  inputSchema,
2179
2202
  outputSchema
2180
2203
  }) {
@@ -2189,7 +2212,6 @@ function createProviderDefinedToolFactoryWithOutputSchema({
2189
2212
  }) => tool({
2190
2213
  type: "provider-defined",
2191
2214
  id,
2192
- name,
2193
2215
  args,
2194
2216
  inputSchema,
2195
2217
  outputSchema,
@@ -2426,6 +2448,7 @@ export {
2426
2448
  createProviderDefinedToolFactory,
2427
2449
  createProviderDefinedToolFactoryWithOutputSchema,
2428
2450
  createStatusCodeErrorResponseHandler,
2451
+ createToolNameMapping,
2429
2452
  delay,
2430
2453
  dynamicTool,
2431
2454
  executeTool,