@ai-sdk/provider-utils 4.0.0-beta.37 → 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/CHANGELOG.md +14 -0
- package/dist/index.d.mts +59 -11
- package/dist/index.d.ts +59 -11
- package/dist/index.js +78 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -5
- 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-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) {
|
|
@@ -77,6 +103,53 @@ function createAbortError() {
|
|
|
77
103
|
return new DOMException("Delay was aborted", "AbortError");
|
|
78
104
|
}
|
|
79
105
|
|
|
106
|
+
// src/delayed-promise.ts
|
|
107
|
+
var DelayedPromise = class {
|
|
108
|
+
constructor() {
|
|
109
|
+
this.status = { type: "pending" };
|
|
110
|
+
this._resolve = void 0;
|
|
111
|
+
this._reject = void 0;
|
|
112
|
+
}
|
|
113
|
+
get promise() {
|
|
114
|
+
if (this._promise) {
|
|
115
|
+
return this._promise;
|
|
116
|
+
}
|
|
117
|
+
this._promise = new Promise((resolve2, reject) => {
|
|
118
|
+
if (this.status.type === "resolved") {
|
|
119
|
+
resolve2(this.status.value);
|
|
120
|
+
} else if (this.status.type === "rejected") {
|
|
121
|
+
reject(this.status.error);
|
|
122
|
+
}
|
|
123
|
+
this._resolve = resolve2;
|
|
124
|
+
this._reject = reject;
|
|
125
|
+
});
|
|
126
|
+
return this._promise;
|
|
127
|
+
}
|
|
128
|
+
resolve(value) {
|
|
129
|
+
var _a;
|
|
130
|
+
this.status = { type: "resolved", value };
|
|
131
|
+
if (this._promise) {
|
|
132
|
+
(_a = this._resolve) == null ? void 0 : _a.call(this, value);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
reject(error) {
|
|
136
|
+
var _a;
|
|
137
|
+
this.status = { type: "rejected", error };
|
|
138
|
+
if (this._promise) {
|
|
139
|
+
(_a = this._reject) == null ? void 0 : _a.call(this, error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
isResolved() {
|
|
143
|
+
return this.status.type === "resolved";
|
|
144
|
+
}
|
|
145
|
+
isRejected() {
|
|
146
|
+
return this.status.type === "rejected";
|
|
147
|
+
}
|
|
148
|
+
isPending() {
|
|
149
|
+
return this.status.type === "pending";
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
80
153
|
// src/extract-response-headers.ts
|
|
81
154
|
function extractResponseHeaders(response) {
|
|
82
155
|
return Object.fromEntries([...response.headers]);
|
|
@@ -216,7 +289,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
216
289
|
}
|
|
217
290
|
|
|
218
291
|
// src/version.ts
|
|
219
|
-
var VERSION = true ? "4.0.0-beta.
|
|
292
|
+
var VERSION = true ? "4.0.0-beta.39" : "0.0.0-test";
|
|
220
293
|
|
|
221
294
|
// src/get-from-api.ts
|
|
222
295
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2098,7 +2171,6 @@ function dynamicTool(tool2) {
|
|
|
2098
2171
|
// src/provider-defined-tool-factory.ts
|
|
2099
2172
|
function createProviderDefinedToolFactory({
|
|
2100
2173
|
id,
|
|
2101
|
-
name,
|
|
2102
2174
|
inputSchema
|
|
2103
2175
|
}) {
|
|
2104
2176
|
return ({
|
|
@@ -2113,7 +2185,6 @@ function createProviderDefinedToolFactory({
|
|
|
2113
2185
|
}) => tool({
|
|
2114
2186
|
type: "provider-defined",
|
|
2115
2187
|
id,
|
|
2116
|
-
name,
|
|
2117
2188
|
args,
|
|
2118
2189
|
inputSchema,
|
|
2119
2190
|
outputSchema,
|
|
@@ -2127,7 +2198,6 @@ function createProviderDefinedToolFactory({
|
|
|
2127
2198
|
}
|
|
2128
2199
|
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
2129
2200
|
id,
|
|
2130
|
-
name,
|
|
2131
2201
|
inputSchema,
|
|
2132
2202
|
outputSchema
|
|
2133
2203
|
}) {
|
|
@@ -2142,7 +2212,6 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
2142
2212
|
}) => tool({
|
|
2143
2213
|
type: "provider-defined",
|
|
2144
2214
|
id,
|
|
2145
|
-
name,
|
|
2146
2215
|
args,
|
|
2147
2216
|
inputSchema,
|
|
2148
2217
|
outputSchema,
|
|
@@ -2362,6 +2431,7 @@ import {
|
|
|
2362
2431
|
EventSourceParserStream as EventSourceParserStream2
|
|
2363
2432
|
} from "eventsource-parser/stream";
|
|
2364
2433
|
export {
|
|
2434
|
+
DelayedPromise,
|
|
2365
2435
|
EventSourceParserStream2 as EventSourceParserStream,
|
|
2366
2436
|
VERSION,
|
|
2367
2437
|
asSchema,
|
|
@@ -2378,6 +2448,7 @@ export {
|
|
|
2378
2448
|
createProviderDefinedToolFactory,
|
|
2379
2449
|
createProviderDefinedToolFactoryWithOutputSchema,
|
|
2380
2450
|
createStatusCodeErrorResponseHandler,
|
|
2451
|
+
createToolNameMapping,
|
|
2381
2452
|
delay,
|
|
2382
2453
|
dynamicTool,
|
|
2383
2454
|
executeTool,
|