@hasna/mementos 0.14.59 → 0.14.60
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/cli/commands/storage.d.ts.map +1 -1
- package/dist/cli/commands/system-misc.d.ts.map +1 -1
- package/dist/cli/index.js +2024 -705
- package/dist/db/session-jobs.d.ts.map +1 -1
- package/dist/db/synthesis.d.ts.map +1 -1
- package/dist/index.js +1648 -653
- package/dist/lib/poll.d.ts.map +1 -1
- package/dist/lib/synthesis/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1687 -660
- package/dist/mcp/tools/memory-search.d.ts.map +1 -1
- package/dist/server/index.js +1689 -657
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5967,7 +5967,7 @@ var init_zod = __esm(() => {
|
|
|
5967
5967
|
init_external();
|
|
5968
5968
|
});
|
|
5969
5969
|
|
|
5970
|
-
// node_modules/@ai-sdk/provider/dist/index.mjs
|
|
5970
|
+
// node_modules/.pnpm/@ai-sdk+provider@3.0.13/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
5971
5971
|
function getErrorMessage(error) {
|
|
5972
5972
|
if (error == null) {
|
|
5973
5973
|
return "unknown error";
|
|
@@ -17632,7 +17632,7 @@ var init_v3 = __esm(() => {
|
|
|
17632
17632
|
init_external();
|
|
17633
17633
|
});
|
|
17634
17634
|
|
|
17635
|
-
// node_modules
|
|
17635
|
+
// node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
|
|
17636
17636
|
function noop(_arg) {}
|
|
17637
17637
|
function createParser(config2) {
|
|
17638
17638
|
if (typeof config2 == "function")
|
|
@@ -17792,7 +17792,7 @@ var init_dist2 = __esm(() => {
|
|
|
17792
17792
|
};
|
|
17793
17793
|
});
|
|
17794
17794
|
|
|
17795
|
-
// node_modules
|
|
17795
|
+
// node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
|
|
17796
17796
|
var EventSourceParserStream;
|
|
17797
17797
|
var init_stream = __esm(() => {
|
|
17798
17798
|
init_dist2();
|
|
@@ -17821,7 +17821,7 @@ var init_stream = __esm(() => {
|
|
|
17821
17821
|
};
|
|
17822
17822
|
});
|
|
17823
17823
|
|
|
17824
|
-
// node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
17824
|
+
// node_modules/.pnpm/@ai-sdk+provider-utils@4.0.35_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
17825
17825
|
function combineHeaders(...headers) {
|
|
17826
17826
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
17827
17827
|
...combinedHeaders,
|
|
@@ -17925,57 +17925,14 @@ function convertToFormData(input, options = {}) {
|
|
|
17925
17925
|
}
|
|
17926
17926
|
return formData;
|
|
17927
17927
|
}
|
|
17928
|
-
async function
|
|
17929
|
-
|
|
17930
|
-
url: url2,
|
|
17931
|
-
maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
|
|
17932
|
-
}) {
|
|
17933
|
-
const contentLength = response.headers.get("content-length");
|
|
17934
|
-
if (contentLength != null) {
|
|
17935
|
-
const length = parseInt(contentLength, 10);
|
|
17936
|
-
if (!isNaN(length) && length > maxBytes) {
|
|
17937
|
-
throw new DownloadError({
|
|
17938
|
-
url: url2,
|
|
17939
|
-
message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
17940
|
-
});
|
|
17941
|
-
}
|
|
17942
|
-
}
|
|
17943
|
-
const body = response.body;
|
|
17944
|
-
if (body == null) {
|
|
17945
|
-
return new Uint8Array(0);
|
|
17946
|
-
}
|
|
17947
|
-
const reader = body.getReader();
|
|
17948
|
-
const chunks = [];
|
|
17949
|
-
let totalBytes = 0;
|
|
17928
|
+
async function cancelResponseBody(response) {
|
|
17929
|
+
var _a22;
|
|
17950
17930
|
try {
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
totalBytes += value.length;
|
|
17957
|
-
if (totalBytes > maxBytes) {
|
|
17958
|
-
throw new DownloadError({
|
|
17959
|
-
url: url2,
|
|
17960
|
-
message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
|
|
17961
|
-
});
|
|
17962
|
-
}
|
|
17963
|
-
chunks.push(value);
|
|
17964
|
-
}
|
|
17965
|
-
} finally {
|
|
17966
|
-
try {
|
|
17967
|
-
await reader.cancel();
|
|
17968
|
-
} finally {
|
|
17969
|
-
reader.releaseLock();
|
|
17970
|
-
}
|
|
17971
|
-
}
|
|
17972
|
-
const result = new Uint8Array(totalBytes);
|
|
17973
|
-
let offset = 0;
|
|
17974
|
-
for (const chunk of chunks) {
|
|
17975
|
-
result.set(chunk, offset);
|
|
17976
|
-
offset += chunk.length;
|
|
17977
|
-
}
|
|
17978
|
-
return result;
|
|
17931
|
+
await ((_a22 = response.body) == null ? undefined : _a22.cancel());
|
|
17932
|
+
} catch (e) {}
|
|
17933
|
+
}
|
|
17934
|
+
function isBrowserRuntime(globalThisAny = globalThis) {
|
|
17935
|
+
return globalThisAny.window != null;
|
|
17979
17936
|
}
|
|
17980
17937
|
function validateDownloadUrl(url2) {
|
|
17981
17938
|
let parsed;
|
|
@@ -17996,7 +17953,7 @@ function validateDownloadUrl(url2) {
|
|
|
17996
17953
|
message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
|
|
17997
17954
|
});
|
|
17998
17955
|
}
|
|
17999
|
-
const hostname3 = parsed.hostname;
|
|
17956
|
+
const hostname3 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
|
|
18000
17957
|
if (!hostname3) {
|
|
18001
17958
|
throw new DownloadError({
|
|
18002
17959
|
url: url2,
|
|
@@ -18040,62 +17997,198 @@ function isIPv4(hostname3) {
|
|
|
18040
17997
|
}
|
|
18041
17998
|
function isPrivateIPv4(ip) {
|
|
18042
17999
|
const parts = ip.split(".").map(Number);
|
|
18043
|
-
const [a, b] = parts;
|
|
18000
|
+
const [a, b, c] = parts;
|
|
18044
18001
|
if (a === 0)
|
|
18045
18002
|
return true;
|
|
18046
18003
|
if (a === 10)
|
|
18047
18004
|
return true;
|
|
18005
|
+
if (a === 100 && b >= 64 && b <= 127)
|
|
18006
|
+
return true;
|
|
18048
18007
|
if (a === 127)
|
|
18049
18008
|
return true;
|
|
18050
18009
|
if (a === 169 && b === 254)
|
|
18051
18010
|
return true;
|
|
18052
18011
|
if (a === 172 && b >= 16 && b <= 31)
|
|
18053
18012
|
return true;
|
|
18013
|
+
if (a === 192 && b === 0 && c === 0)
|
|
18014
|
+
return true;
|
|
18054
18015
|
if (a === 192 && b === 168)
|
|
18055
18016
|
return true;
|
|
18017
|
+
if (a === 198 && (b === 18 || b === 19))
|
|
18018
|
+
return true;
|
|
18019
|
+
if (a >= 240)
|
|
18020
|
+
return true;
|
|
18056
18021
|
return false;
|
|
18057
18022
|
}
|
|
18023
|
+
function parseIPv6(ip) {
|
|
18024
|
+
let address = ip.toLowerCase();
|
|
18025
|
+
const zoneIndex = address.indexOf("%");
|
|
18026
|
+
if (zoneIndex !== -1) {
|
|
18027
|
+
address = address.slice(0, zoneIndex);
|
|
18028
|
+
}
|
|
18029
|
+
const halves = address.split("::");
|
|
18030
|
+
if (halves.length > 2)
|
|
18031
|
+
return null;
|
|
18032
|
+
const toGroups = (segment) => {
|
|
18033
|
+
if (segment === "")
|
|
18034
|
+
return [];
|
|
18035
|
+
const groups = [];
|
|
18036
|
+
const parts = segment.split(":");
|
|
18037
|
+
for (let i = 0;i < parts.length; i++) {
|
|
18038
|
+
const part = parts[i];
|
|
18039
|
+
if (part.includes(".")) {
|
|
18040
|
+
if (i !== parts.length - 1 || !isIPv4(part))
|
|
18041
|
+
return null;
|
|
18042
|
+
const [a, b, c, d] = part.split(".").map(Number);
|
|
18043
|
+
groups.push(a << 8 | b, c << 8 | d);
|
|
18044
|
+
continue;
|
|
18045
|
+
}
|
|
18046
|
+
if (!/^[0-9a-f]{1,4}$/.test(part))
|
|
18047
|
+
return null;
|
|
18048
|
+
groups.push(parseInt(part, 16));
|
|
18049
|
+
}
|
|
18050
|
+
return groups;
|
|
18051
|
+
};
|
|
18052
|
+
const head = toGroups(halves[0]);
|
|
18053
|
+
if (head === null)
|
|
18054
|
+
return null;
|
|
18055
|
+
if (halves.length === 2) {
|
|
18056
|
+
const tail = toGroups(halves[1]);
|
|
18057
|
+
if (tail === null)
|
|
18058
|
+
return null;
|
|
18059
|
+
const fill = 8 - head.length - tail.length;
|
|
18060
|
+
if (fill < 0)
|
|
18061
|
+
return null;
|
|
18062
|
+
return [...head, ...new Array(fill).fill(0), ...tail];
|
|
18063
|
+
}
|
|
18064
|
+
return head.length === 8 ? head : null;
|
|
18065
|
+
}
|
|
18058
18066
|
function isPrivateIPv6(ip) {
|
|
18059
|
-
const
|
|
18060
|
-
if (
|
|
18067
|
+
const groups = parseIPv6(ip);
|
|
18068
|
+
if (groups === null)
|
|
18061
18069
|
return true;
|
|
18062
|
-
|
|
18070
|
+
const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
|
|
18071
|
+
if (topZero(7) && (groups[7] === 0 || groups[7] === 1))
|
|
18063
18072
|
return true;
|
|
18064
|
-
if (
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18073
|
+
if ((groups[0] & 65024) === 64512)
|
|
18074
|
+
return true;
|
|
18075
|
+
if ((groups[0] & 65472) === 65152)
|
|
18076
|
+
return true;
|
|
18077
|
+
if ((groups[0] & 65472) === 65216)
|
|
18078
|
+
return true;
|
|
18079
|
+
if ((groups[0] & 65280) === 65280)
|
|
18080
|
+
return true;
|
|
18081
|
+
const embedsIPv4 = topZero(6) || topZero(5) && groups[5] === 65535 || topZero(4) && groups[4] === 65535 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 1;
|
|
18082
|
+
if (embedsIPv4) {
|
|
18083
|
+
const a = groups[6] >> 8 & 255;
|
|
18084
|
+
const b = groups[6] & 255;
|
|
18085
|
+
const c = groups[7] >> 8 & 255;
|
|
18086
|
+
const d = groups[7] & 255;
|
|
18087
|
+
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
18088
|
+
}
|
|
18089
|
+
return false;
|
|
18090
|
+
}
|
|
18091
|
+
async function fetchWithValidatedRedirects({
|
|
18092
|
+
url: url2,
|
|
18093
|
+
headers,
|
|
18094
|
+
abortSignal,
|
|
18095
|
+
maxRedirects = MAX_DOWNLOAD_REDIRECTS
|
|
18096
|
+
}) {
|
|
18097
|
+
const baseInit = { signal: abortSignal };
|
|
18098
|
+
if (headers !== undefined) {
|
|
18099
|
+
baseInit.headers = headers;
|
|
18100
|
+
}
|
|
18101
|
+
let currentUrl = url2;
|
|
18102
|
+
for (let redirectCount = 0;redirectCount <= maxRedirects; redirectCount++) {
|
|
18103
|
+
validateDownloadUrl(currentUrl);
|
|
18104
|
+
const response = await fetch(currentUrl, {
|
|
18105
|
+
...baseInit,
|
|
18106
|
+
redirect: "manual"
|
|
18107
|
+
});
|
|
18108
|
+
if (response.type === "opaqueredirect") {
|
|
18109
|
+
if (!isBrowserRuntime()) {
|
|
18110
|
+
throw new DownloadError({
|
|
18111
|
+
url: url2,
|
|
18112
|
+
message: `Redirect from ${currentUrl} could not be validated and was blocked`
|
|
18113
|
+
});
|
|
18114
|
+
}
|
|
18115
|
+
return await fetch(currentUrl, { ...baseInit, redirect: "follow" });
|
|
18116
|
+
}
|
|
18117
|
+
const location = response.headers.get("location");
|
|
18118
|
+
if (response.status >= 300 && response.status < 400 && location) {
|
|
18119
|
+
await cancelResponseBody(response);
|
|
18120
|
+
currentUrl = new URL(location, currentUrl).toString();
|
|
18121
|
+
continue;
|
|
18122
|
+
}
|
|
18123
|
+
return response;
|
|
18124
|
+
}
|
|
18125
|
+
throw new DownloadError({
|
|
18126
|
+
url: url2,
|
|
18127
|
+
message: `Too many redirects (max ${maxRedirects})`
|
|
18128
|
+
});
|
|
18129
|
+
}
|
|
18130
|
+
async function readResponseWithSizeLimit({
|
|
18131
|
+
response,
|
|
18132
|
+
url: url2,
|
|
18133
|
+
maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
|
|
18134
|
+
}) {
|
|
18135
|
+
const contentLength = response.headers.get("content-length");
|
|
18136
|
+
if (contentLength != null) {
|
|
18137
|
+
const length = parseInt(contentLength, 10);
|
|
18138
|
+
if (!isNaN(length) && length > maxBytes) {
|
|
18139
|
+
await cancelResponseBody(response);
|
|
18140
|
+
throw new DownloadError({
|
|
18141
|
+
url: url2,
|
|
18142
|
+
message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
18143
|
+
});
|
|
18068
18144
|
}
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18145
|
+
}
|
|
18146
|
+
const body = response.body;
|
|
18147
|
+
if (body == null) {
|
|
18148
|
+
return new Uint8Array(0);
|
|
18149
|
+
}
|
|
18150
|
+
const reader = body.getReader();
|
|
18151
|
+
const chunks = [];
|
|
18152
|
+
let totalBytes = 0;
|
|
18153
|
+
try {
|
|
18154
|
+
while (true) {
|
|
18155
|
+
const { done, value } = await reader.read();
|
|
18156
|
+
if (done) {
|
|
18157
|
+
break;
|
|
18079
18158
|
}
|
|
18159
|
+
totalBytes += value.length;
|
|
18160
|
+
if (totalBytes > maxBytes) {
|
|
18161
|
+
throw new DownloadError({
|
|
18162
|
+
url: url2,
|
|
18163
|
+
message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
|
|
18164
|
+
});
|
|
18165
|
+
}
|
|
18166
|
+
chunks.push(value);
|
|
18167
|
+
}
|
|
18168
|
+
} finally {
|
|
18169
|
+
try {
|
|
18170
|
+
await reader.cancel();
|
|
18171
|
+
} finally {
|
|
18172
|
+
reader.releaseLock();
|
|
18080
18173
|
}
|
|
18081
18174
|
}
|
|
18082
|
-
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
18175
|
+
const result = new Uint8Array(totalBytes);
|
|
18176
|
+
let offset = 0;
|
|
18177
|
+
for (const chunk of chunks) {
|
|
18178
|
+
result.set(chunk, offset);
|
|
18179
|
+
offset += chunk.length;
|
|
18180
|
+
}
|
|
18181
|
+
return result;
|
|
18087
18182
|
}
|
|
18088
18183
|
async function downloadBlob(url2, options) {
|
|
18089
18184
|
var _a22, _b22;
|
|
18090
|
-
validateDownloadUrl(url2);
|
|
18091
18185
|
try {
|
|
18092
|
-
const response = await
|
|
18093
|
-
|
|
18186
|
+
const response = await fetchWithValidatedRedirects({
|
|
18187
|
+
url: url2,
|
|
18188
|
+
abortSignal: options == null ? undefined : options.abortSignal
|
|
18094
18189
|
});
|
|
18095
|
-
if (response.redirected) {
|
|
18096
|
-
validateDownloadUrl(response.url);
|
|
18097
|
-
}
|
|
18098
18190
|
if (!response.ok) {
|
|
18191
|
+
await cancelResponseBody(response);
|
|
18099
18192
|
throw new DownloadError({
|
|
18100
18193
|
url: url2,
|
|
18101
18194
|
statusCode: response.status,
|
|
@@ -19342,6 +19435,68 @@ async function resolve3(value) {
|
|
|
19342
19435
|
}
|
|
19343
19436
|
return Promise.resolve(value);
|
|
19344
19437
|
}
|
|
19438
|
+
async function retryWithExponentialBackoffInternal(f, {
|
|
19439
|
+
maxRetries,
|
|
19440
|
+
delayInMs,
|
|
19441
|
+
backoffFactor,
|
|
19442
|
+
abortSignal,
|
|
19443
|
+
shouldRetry,
|
|
19444
|
+
getDelayInMs,
|
|
19445
|
+
createRetryError
|
|
19446
|
+
}, errors4 = []) {
|
|
19447
|
+
try {
|
|
19448
|
+
return await f();
|
|
19449
|
+
} catch (error40) {
|
|
19450
|
+
if (isAbortError(error40)) {
|
|
19451
|
+
throw error40;
|
|
19452
|
+
}
|
|
19453
|
+
if (maxRetries === 0) {
|
|
19454
|
+
throw error40;
|
|
19455
|
+
}
|
|
19456
|
+
const errorMessage = getErrorMessage2(error40);
|
|
19457
|
+
const newErrors = [...errors4, error40];
|
|
19458
|
+
const tryNumber = newErrors.length;
|
|
19459
|
+
if (tryNumber > maxRetries) {
|
|
19460
|
+
throw createRetryError({
|
|
19461
|
+
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
19462
|
+
reason: "maxRetriesExceeded",
|
|
19463
|
+
errors: newErrors
|
|
19464
|
+
});
|
|
19465
|
+
}
|
|
19466
|
+
if (await shouldRetry(error40) && tryNumber <= maxRetries) {
|
|
19467
|
+
await delay(getDelayInMs({
|
|
19468
|
+
error: error40,
|
|
19469
|
+
exponentialBackoffDelay: delayInMs
|
|
19470
|
+
}), { abortSignal });
|
|
19471
|
+
return retryWithExponentialBackoffInternal(f, {
|
|
19472
|
+
maxRetries,
|
|
19473
|
+
delayInMs: backoffFactor * delayInMs,
|
|
19474
|
+
backoffFactor,
|
|
19475
|
+
abortSignal,
|
|
19476
|
+
shouldRetry,
|
|
19477
|
+
getDelayInMs,
|
|
19478
|
+
createRetryError
|
|
19479
|
+
}, newErrors);
|
|
19480
|
+
}
|
|
19481
|
+
if (tryNumber === 1) {
|
|
19482
|
+
throw error40;
|
|
19483
|
+
}
|
|
19484
|
+
throw createRetryError({
|
|
19485
|
+
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
19486
|
+
reason: "errorNotRetryable",
|
|
19487
|
+
errors: newErrors
|
|
19488
|
+
});
|
|
19489
|
+
}
|
|
19490
|
+
}
|
|
19491
|
+
async function readResponseBodyAsText({
|
|
19492
|
+
response,
|
|
19493
|
+
url: url2
|
|
19494
|
+
}) {
|
|
19495
|
+
return textDecoder.decode(await readResponseWithSizeLimit({
|
|
19496
|
+
response,
|
|
19497
|
+
url: url2
|
|
19498
|
+
}));
|
|
19499
|
+
}
|
|
19345
19500
|
function withoutTrailingSlash(url2) {
|
|
19346
19501
|
return url2 == null ? undefined : url2.replace(/\/$/, "");
|
|
19347
19502
|
}
|
|
@@ -19409,7 +19564,7 @@ var DelayedPromise = class {
|
|
|
19409
19564
|
isPending() {
|
|
19410
19565
|
return this.status.type === "pending";
|
|
19411
19566
|
}
|
|
19412
|
-
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
|
|
19567
|
+
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
|
|
19413
19568
|
prefix,
|
|
19414
19569
|
size = 16,
|
|
19415
19570
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -19433,7 +19588,7 @@ var DelayedPromise = class {
|
|
|
19433
19588
|
});
|
|
19434
19589
|
}
|
|
19435
19590
|
return () => `${prefix}${separator}${generator()}`;
|
|
19436
|
-
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
19591
|
+
}, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.35", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
19437
19592
|
url: url2,
|
|
19438
19593
|
headers = {},
|
|
19439
19594
|
successfulResponseHandler,
|
|
@@ -19819,12 +19974,28 @@ var DelayedPromise = class {
|
|
|
19819
19974
|
} catch (error40) {
|
|
19820
19975
|
throw handleFetchError({ error: error40, url: url2, requestBodyValues: body.values });
|
|
19821
19976
|
}
|
|
19822
|
-
},
|
|
19977
|
+
}, retryWithExponentialBackoff = ({
|
|
19978
|
+
maxRetries = 2,
|
|
19979
|
+
initialDelayInMs = 2000,
|
|
19980
|
+
backoffFactor = 2,
|
|
19981
|
+
abortSignal,
|
|
19982
|
+
shouldRetry,
|
|
19983
|
+
getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay,
|
|
19984
|
+
createRetryError = ({ message }) => new Error(message)
|
|
19985
|
+
}) => async (f) => retryWithExponentialBackoffInternal(f, {
|
|
19986
|
+
maxRetries,
|
|
19987
|
+
delayInMs: initialDelayInMs,
|
|
19988
|
+
backoffFactor,
|
|
19989
|
+
abortSignal,
|
|
19990
|
+
shouldRetry,
|
|
19991
|
+
getDelayInMs,
|
|
19992
|
+
createRetryError
|
|
19993
|
+
}), textDecoder, createJsonErrorResponseHandler = ({
|
|
19823
19994
|
errorSchema,
|
|
19824
19995
|
errorToMessage,
|
|
19825
19996
|
isRetryable
|
|
19826
19997
|
}) => async ({ response, url: url2, requestBodyValues }) => {
|
|
19827
|
-
const responseBody = await response
|
|
19998
|
+
const responseBody = await readResponseBodyAsText({ response, url: url2 });
|
|
19828
19999
|
const responseHeaders = extractResponseHeaders(response);
|
|
19829
20000
|
if (responseBody.trim() === "") {
|
|
19830
20001
|
return {
|
|
@@ -19885,7 +20056,7 @@ var DelayedPromise = class {
|
|
|
19885
20056
|
})
|
|
19886
20057
|
};
|
|
19887
20058
|
}, createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
|
|
19888
|
-
const responseBody = await response
|
|
20059
|
+
const responseBody = await readResponseBodyAsText({ response, url: url2 });
|
|
19889
20060
|
const parsedResult = await safeParseJSON({
|
|
19890
20061
|
text: responseBody,
|
|
19891
20062
|
schema: responseSchema
|
|
@@ -20041,9 +20212,10 @@ var init_dist3 = __esm(() => {
|
|
|
20041
20212
|
ZodNull: "null"
|
|
20042
20213
|
};
|
|
20043
20214
|
schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
20215
|
+
textDecoder = new TextDecoder;
|
|
20044
20216
|
});
|
|
20045
20217
|
|
|
20046
|
-
// node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
20218
|
+
// node_modules/.pnpm/@ai-sdk+anthropic@3.0.92_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
20047
20219
|
var exports_dist = {};
|
|
20048
20220
|
__export(exports_dist, {
|
|
20049
20221
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
|
|
@@ -21248,7 +21420,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
21248
21420
|
}
|
|
21249
21421
|
}
|
|
21250
21422
|
}
|
|
21251
|
-
messages.push({
|
|
21423
|
+
messages.push({
|
|
21424
|
+
role: "assistant",
|
|
21425
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
21426
|
+
});
|
|
21252
21427
|
break;
|
|
21253
21428
|
}
|
|
21254
21429
|
default: {
|
|
@@ -21308,6 +21483,24 @@ function groupIntoBlocks(prompt) {
|
|
|
21308
21483
|
}
|
|
21309
21484
|
return blocks;
|
|
21310
21485
|
}
|
|
21486
|
+
function moveToolUseBlocksToEnd(content) {
|
|
21487
|
+
const result = [];
|
|
21488
|
+
let segment = [];
|
|
21489
|
+
function flushSegment() {
|
|
21490
|
+
result.push(...segment.filter((part) => part.type !== "tool_use"), ...segment.filter((part) => part.type === "tool_use"));
|
|
21491
|
+
segment = [];
|
|
21492
|
+
}
|
|
21493
|
+
for (const part of content) {
|
|
21494
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
21495
|
+
flushSegment();
|
|
21496
|
+
result.push(part);
|
|
21497
|
+
} else {
|
|
21498
|
+
segment.push(part);
|
|
21499
|
+
}
|
|
21500
|
+
}
|
|
21501
|
+
flushSegment();
|
|
21502
|
+
return result;
|
|
21503
|
+
}
|
|
21311
21504
|
function mapAnthropicStopReason({
|
|
21312
21505
|
finishReason,
|
|
21313
21506
|
isJsonResponseFromTool
|
|
@@ -21485,7 +21678,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
21485
21678
|
};
|
|
21486
21679
|
}
|
|
21487
21680
|
function getModelCapabilities(modelId) {
|
|
21488
|
-
if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5")) {
|
|
21681
|
+
if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
|
|
21489
21682
|
return {
|
|
21490
21683
|
maxOutputTokens: 128000,
|
|
21491
21684
|
supportsStructuredOutput: true,
|
|
@@ -21676,7 +21869,7 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
21676
21869
|
}
|
|
21677
21870
|
return;
|
|
21678
21871
|
}
|
|
21679
|
-
var VERSION2 = "3.0.
|
|
21872
|
+
var VERSION2 = "3.0.92", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
|
|
21680
21873
|
constructor() {
|
|
21681
21874
|
this.breakpointCount = 0;
|
|
21682
21875
|
this.warnings = [];
|
|
@@ -22828,6 +23021,7 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
22828
23021
|
"bash_code_execution"
|
|
22829
23022
|
].includes(part.name)) {
|
|
22830
23023
|
const providerToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
|
|
23024
|
+
const providerToolInputType = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? part.name : part.name === "code_execution" ? "programmatic-tool-call" : undefined;
|
|
22831
23025
|
const customToolName = toolNameMapping.toCustomToolName(providerToolName);
|
|
22832
23026
|
const finalInput = part.input != null && typeof part.input === "object" && Object.keys(part.input).length > 0 ? JSON.stringify(part.input) : "";
|
|
22833
23027
|
contentBlocks[value.index] = {
|
|
@@ -22837,8 +23031,9 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
22837
23031
|
input: finalInput,
|
|
22838
23032
|
providerExecuted: true,
|
|
22839
23033
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
22840
|
-
firstDelta:
|
|
22841
|
-
providerToolName
|
|
23034
|
+
firstDelta: finalInput.length === 0,
|
|
23035
|
+
providerToolName,
|
|
23036
|
+
providerToolInputType
|
|
22842
23037
|
};
|
|
22843
23038
|
controller.enqueue({
|
|
22844
23039
|
type: "tool-input-start",
|
|
@@ -23256,8 +23451,8 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
23256
23451
|
if ((contentBlock == null ? undefined : contentBlock.type) !== "tool-call") {
|
|
23257
23452
|
return;
|
|
23258
23453
|
}
|
|
23259
|
-
if (contentBlock.firstDelta && contentBlock.
|
|
23260
|
-
delta = `{"type": "
|
|
23454
|
+
if (contentBlock.firstDelta && contentBlock.providerToolInputType != null) {
|
|
23455
|
+
delta = `{"type": "${contentBlock.providerToolInputType}",${delta.substring(1)}`;
|
|
23261
23456
|
}
|
|
23262
23457
|
controller.enqueue({
|
|
23263
23458
|
type: "tool-input-delta",
|
|
@@ -25025,7 +25220,7 @@ var init_dist4 = __esm(() => {
|
|
|
25025
25220
|
anthropic = createAnthropic();
|
|
25026
25221
|
});
|
|
25027
25222
|
|
|
25028
|
-
// node_modules/@ai-sdk/openai/dist/index.mjs
|
|
25223
|
+
// node_modules/.pnpm/@ai-sdk+openai@3.0.80_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
25029
25224
|
var exports_dist2 = {};
|
|
25030
25225
|
__export(exports_dist2, {
|
|
25031
25226
|
openai: () => openai,
|
|
@@ -25571,7 +25766,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
25571
25766
|
hasApplyPatchTool = false,
|
|
25572
25767
|
customProviderToolNames
|
|
25573
25768
|
}) {
|
|
25574
|
-
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
25769
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
25575
25770
|
let input = [];
|
|
25576
25771
|
const warnings = [];
|
|
25577
25772
|
const processedApprovalIds = /* @__PURE__ */ new Set;
|
|
@@ -25704,10 +25899,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
25704
25899
|
}
|
|
25705
25900
|
break;
|
|
25706
25901
|
}
|
|
25707
|
-
if (store && id != null) {
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25902
|
+
if (hasPreviousResponseId && store && id != null) {
|
|
25903
|
+
break;
|
|
25904
|
+
}
|
|
25905
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
25906
|
+
if (store && id != null && isProviderDefinedToolCall) {
|
|
25711
25907
|
input.push({ type: "item_reference", id });
|
|
25712
25908
|
break;
|
|
25713
25909
|
}
|
|
@@ -25778,7 +25974,6 @@ async function convertToOpenAIResponsesInput({
|
|
|
25778
25974
|
call_id: part.toolCallId,
|
|
25779
25975
|
name: resolvedToolName,
|
|
25780
25976
|
arguments: serializeToolCallArguments2(part.input),
|
|
25781
|
-
id,
|
|
25782
25977
|
...namespace != null && { namespace }
|
|
25783
25978
|
});
|
|
25784
25979
|
break;
|
|
@@ -25792,7 +25987,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
25792
25987
|
}
|
|
25793
25988
|
const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
25794
25989
|
if (resolvedResultToolName === "tool_search") {
|
|
25795
|
-
const itemId = (
|
|
25990
|
+
const itemId = (_p = (_o = (_n = part.providerOptions) == null ? undefined : _n[providerOptionsName]) == null ? undefined : _o.itemId) != null ? _p : part.toolCallId;
|
|
25796
25991
|
if (store) {
|
|
25797
25992
|
input.push({ type: "item_reference", id: itemId });
|
|
25798
25993
|
} else if (part.output.type === "json") {
|
|
@@ -25833,7 +26028,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
25833
26028
|
break;
|
|
25834
26029
|
}
|
|
25835
26030
|
if (store) {
|
|
25836
|
-
const itemId = (
|
|
26031
|
+
const itemId = (_s = (_r = (_q = part.providerOptions) == null ? undefined : _q[providerOptionsName]) == null ? undefined : _r.itemId) != null ? _s : part.toolCallId;
|
|
25837
26032
|
input.push({ type: "item_reference", id: itemId });
|
|
25838
26033
|
} else {
|
|
25839
26034
|
warnings.push({
|
|
@@ -25943,7 +26138,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
25943
26138
|
}
|
|
25944
26139
|
const output = part.output;
|
|
25945
26140
|
if (output.type === "execution-denied") {
|
|
25946
|
-
const approvalId = (
|
|
26141
|
+
const approvalId = (_u = (_t = output.providerOptions) == null ? undefined : _t.openai) == null ? undefined : _u.approvalId;
|
|
25947
26142
|
if (approvalId) {
|
|
25948
26143
|
continue;
|
|
25949
26144
|
}
|
|
@@ -26015,7 +26210,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
26015
26210
|
outputValue = output.value;
|
|
26016
26211
|
break;
|
|
26017
26212
|
case "execution-denied":
|
|
26018
|
-
outputValue = (
|
|
26213
|
+
outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
|
|
26019
26214
|
break;
|
|
26020
26215
|
case "json":
|
|
26021
26216
|
case "error-json":
|
|
@@ -26076,7 +26271,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
26076
26271
|
contentValue = output.value;
|
|
26077
26272
|
break;
|
|
26078
26273
|
case "execution-denied":
|
|
26079
|
-
contentValue = (
|
|
26274
|
+
contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
|
|
26080
26275
|
break;
|
|
26081
26276
|
case "json":
|
|
26082
26277
|
case "error-json":
|
|
@@ -26501,6 +26696,31 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
|
|
|
26501
26696
|
function isTextDeltaChunk(chunk) {
|
|
26502
26697
|
return chunk.type === "response.output_text.delta";
|
|
26503
26698
|
}
|
|
26699
|
+
function isOpenAIChatCompletionChunk(value) {
|
|
26700
|
+
const chunk = asRecord(value);
|
|
26701
|
+
return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
|
|
26702
|
+
}
|
|
26703
|
+
function createOpenAIResponsesChatCompletionsMismatchError({
|
|
26704
|
+
value,
|
|
26705
|
+
cause,
|
|
26706
|
+
url: url2,
|
|
26707
|
+
requestBodyValues,
|
|
26708
|
+
responseHeaders
|
|
26709
|
+
}) {
|
|
26710
|
+
return new APICallError({
|
|
26711
|
+
message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
|
|
26712
|
+
url: url2,
|
|
26713
|
+
requestBodyValues,
|
|
26714
|
+
responseHeaders,
|
|
26715
|
+
responseBody: JSON.stringify(value),
|
|
26716
|
+
cause,
|
|
26717
|
+
data: value,
|
|
26718
|
+
isRetryable: false
|
|
26719
|
+
});
|
|
26720
|
+
}
|
|
26721
|
+
function asRecord(value) {
|
|
26722
|
+
return typeof value === "object" && value != null ? value : undefined;
|
|
26723
|
+
}
|
|
26504
26724
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
26505
26725
|
return chunk.type === "response.output_item.done";
|
|
26506
26726
|
}
|
|
@@ -28306,11 +28526,12 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
28306
28526
|
providerOptionsName,
|
|
28307
28527
|
isShellProviderExecuted
|
|
28308
28528
|
} = await this.getArgs(options);
|
|
28529
|
+
const url2 = this.config.url({
|
|
28530
|
+
path: "/responses",
|
|
28531
|
+
modelId: this.modelId
|
|
28532
|
+
});
|
|
28309
28533
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
28310
|
-
url:
|
|
28311
|
-
path: "/responses",
|
|
28312
|
-
modelId: this.modelId
|
|
28313
|
-
}),
|
|
28534
|
+
url: url2,
|
|
28314
28535
|
headers: combineHeaders(this.config.headers(), options.headers),
|
|
28315
28536
|
body: {
|
|
28316
28537
|
...body,
|
|
@@ -28349,8 +28570,15 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
28349
28570
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
28350
28571
|
}
|
|
28351
28572
|
if (!chunk.success) {
|
|
28573
|
+
const error40 = isOpenAIChatCompletionChunk(chunk.rawValue) ? createOpenAIResponsesChatCompletionsMismatchError({
|
|
28574
|
+
value: chunk.rawValue,
|
|
28575
|
+
cause: chunk.error,
|
|
28576
|
+
url: url2,
|
|
28577
|
+
requestBodyValues: body,
|
|
28578
|
+
responseHeaders
|
|
28579
|
+
}) : chunk.error;
|
|
28352
28580
|
finishReason = { unified: "error", raw: undefined };
|
|
28353
|
-
controller.enqueue({ type: "error", error:
|
|
28581
|
+
controller.enqueue({ type: "error", error: error40 });
|
|
28354
28582
|
return;
|
|
28355
28583
|
}
|
|
28356
28584
|
const value = chunk.value;
|
|
@@ -29338,7 +29566,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
29338
29566
|
}
|
|
29339
29567
|
};
|
|
29340
29568
|
}
|
|
29341
|
-
}, VERSION3 = "3.0.
|
|
29569
|
+
}, VERSION3 = "3.0.80", openai;
|
|
29342
29570
|
var init_dist5 = __esm(() => {
|
|
29343
29571
|
init_dist3();
|
|
29344
29572
|
init_dist();
|
|
@@ -30055,9 +30283,16 @@ var init_dist5 = __esm(() => {
|
|
|
30055
30283
|
incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
|
|
30056
30284
|
usage: exports_external2.object({
|
|
30057
30285
|
input_tokens: exports_external2.number(),
|
|
30058
|
-
input_tokens_details: exports_external2.object({
|
|
30286
|
+
input_tokens_details: exports_external2.object({
|
|
30287
|
+
cached_tokens: exports_external2.number().nullish(),
|
|
30288
|
+
orchestration_input_tokens: exports_external2.number().nullish(),
|
|
30289
|
+
orchestration_input_cached_tokens: exports_external2.number().nullish()
|
|
30290
|
+
}).nullish(),
|
|
30059
30291
|
output_tokens: exports_external2.number(),
|
|
30060
|
-
output_tokens_details: exports_external2.object({
|
|
30292
|
+
output_tokens_details: exports_external2.object({
|
|
30293
|
+
reasoning_tokens: exports_external2.number().nullish(),
|
|
30294
|
+
orchestration_output_tokens: exports_external2.number().nullish()
|
|
30295
|
+
}).nullish()
|
|
30061
30296
|
}),
|
|
30062
30297
|
service_tier: exports_external2.string().nullish()
|
|
30063
30298
|
})
|
|
@@ -30072,9 +30307,16 @@ var init_dist5 = __esm(() => {
|
|
|
30072
30307
|
incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
|
|
30073
30308
|
usage: exports_external2.object({
|
|
30074
30309
|
input_tokens: exports_external2.number(),
|
|
30075
|
-
input_tokens_details: exports_external2.object({
|
|
30310
|
+
input_tokens_details: exports_external2.object({
|
|
30311
|
+
cached_tokens: exports_external2.number().nullish(),
|
|
30312
|
+
orchestration_input_tokens: exports_external2.number().nullish(),
|
|
30313
|
+
orchestration_input_cached_tokens: exports_external2.number().nullish()
|
|
30314
|
+
}).nullish(),
|
|
30076
30315
|
output_tokens: exports_external2.number(),
|
|
30077
|
-
output_tokens_details: exports_external2.object({
|
|
30316
|
+
output_tokens_details: exports_external2.object({
|
|
30317
|
+
reasoning_tokens: exports_external2.number().nullish(),
|
|
30318
|
+
orchestration_output_tokens: exports_external2.number().nullish()
|
|
30319
|
+
}).nullish()
|
|
30078
30320
|
}).nullish(),
|
|
30079
30321
|
service_tier: exports_external2.string().nullish()
|
|
30080
30322
|
})
|
|
@@ -30811,9 +31053,16 @@ var init_dist5 = __esm(() => {
|
|
|
30811
31053
|
incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
|
|
30812
31054
|
usage: exports_external2.object({
|
|
30813
31055
|
input_tokens: exports_external2.number(),
|
|
30814
|
-
input_tokens_details: exports_external2.object({
|
|
31056
|
+
input_tokens_details: exports_external2.object({
|
|
31057
|
+
cached_tokens: exports_external2.number().nullish(),
|
|
31058
|
+
orchestration_input_tokens: exports_external2.number().nullish(),
|
|
31059
|
+
orchestration_input_cached_tokens: exports_external2.number().nullish()
|
|
31060
|
+
}).nullish(),
|
|
30815
31061
|
output_tokens: exports_external2.number(),
|
|
30816
|
-
output_tokens_details: exports_external2.object({
|
|
31062
|
+
output_tokens_details: exports_external2.object({
|
|
31063
|
+
reasoning_tokens: exports_external2.number().nullish(),
|
|
31064
|
+
orchestration_output_tokens: exports_external2.number().nullish()
|
|
31065
|
+
}).nullish()
|
|
30817
31066
|
}).optional()
|
|
30818
31067
|
})));
|
|
30819
31068
|
openaiResponsesReasoningModelIds = [
|
|
@@ -30886,6 +31135,7 @@ var init_dist5 = __esm(() => {
|
|
|
30886
31135
|
include: exports_external2.array(exports_external2.enum([
|
|
30887
31136
|
"reasoning.encrypted_content",
|
|
30888
31137
|
"file_search_call.results",
|
|
31138
|
+
"web_search_call.results",
|
|
30889
31139
|
"message.output_text.logprobs"
|
|
30890
31140
|
])).nullish(),
|
|
30891
31141
|
instructions: exports_external2.string().nullish(),
|
|
@@ -31008,7 +31258,7 @@ var init_dist5 = __esm(() => {
|
|
|
31008
31258
|
openai = createOpenAI();
|
|
31009
31259
|
});
|
|
31010
31260
|
|
|
31011
|
-
// node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
31261
|
+
// node_modules/.pnpm/@ai-sdk+openai-compatible@2.0.56_zod@3.25.76/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
31012
31262
|
var exports_dist3 = {};
|
|
31013
31263
|
__export(exports_dist3, {
|
|
31014
31264
|
createOpenAICompatible: () => createOpenAICompatible,
|
|
@@ -32413,7 +32663,7 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
|
|
|
32413
32663
|
}
|
|
32414
32664
|
};
|
|
32415
32665
|
}
|
|
32416
|
-
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.
|
|
32666
|
+
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.56";
|
|
32417
32667
|
var init_dist6 = __esm(() => {
|
|
32418
32668
|
init_dist();
|
|
32419
32669
|
init_dist3();
|
|
@@ -32555,7 +32805,7 @@ var init_dist6 = __esm(() => {
|
|
|
32555
32805
|
});
|
|
32556
32806
|
});
|
|
32557
32807
|
|
|
32558
|
-
// node_modules/@vercel/oidc/dist/get-context.js
|
|
32808
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
|
|
32559
32809
|
var require_get_context = __commonJS((exports, module) => {
|
|
32560
32810
|
var __defProp2 = Object.defineProperty;
|
|
32561
32811
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -32587,7 +32837,7 @@ var require_get_context = __commonJS((exports, module) => {
|
|
|
32587
32837
|
}
|
|
32588
32838
|
});
|
|
32589
32839
|
|
|
32590
|
-
// node_modules/@vercel/oidc/dist/token-error.js
|
|
32840
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-error.js
|
|
32591
32841
|
var require_token_error = __commonJS((exports, module) => {
|
|
32592
32842
|
var __defProp2 = Object.defineProperty;
|
|
32593
32843
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -32627,7 +32877,7 @@ var require_token_error = __commonJS((exports, module) => {
|
|
|
32627
32877
|
}
|
|
32628
32878
|
});
|
|
32629
32879
|
|
|
32630
|
-
// node_modules/@vercel/oidc/dist/token-io.js
|
|
32880
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-io.js
|
|
32631
32881
|
var require_token_io = __commonJS((exports, module) => {
|
|
32632
32882
|
var __create2 = Object.create;
|
|
32633
32883
|
var __defProp2 = Object.defineProperty;
|
|
@@ -32694,7 +32944,7 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
32694
32944
|
}
|
|
32695
32945
|
});
|
|
32696
32946
|
|
|
32697
|
-
// node_modules/@vercel/oidc/dist/auth-config.js
|
|
32947
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-config.js
|
|
32698
32948
|
var require_auth_config = __commonJS((exports, module) => {
|
|
32699
32949
|
var __create2 = Object.create;
|
|
32700
32950
|
var __defProp2 = Object.defineProperty;
|
|
@@ -32767,7 +33017,7 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
32767
33017
|
}
|
|
32768
33018
|
});
|
|
32769
33019
|
|
|
32770
|
-
// node_modules/@vercel/oidc/dist/oauth.js
|
|
33020
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/oauth.js
|
|
32771
33021
|
var require_oauth = __commonJS((exports, module) => {
|
|
32772
33022
|
var __defProp2 = Object.defineProperty;
|
|
32773
33023
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -32853,7 +33103,7 @@ var require_oauth = __commonJS((exports, module) => {
|
|
|
32853
33103
|
}
|
|
32854
33104
|
});
|
|
32855
33105
|
|
|
32856
|
-
// node_modules/@vercel/oidc/dist/auth-errors.js
|
|
33106
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-errors.js
|
|
32857
33107
|
var require_auth_errors = __commonJS((exports, module) => {
|
|
32858
33108
|
var __defProp2 = Object.defineProperty;
|
|
32859
33109
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -32894,7 +33144,7 @@ var require_auth_errors = __commonJS((exports, module) => {
|
|
|
32894
33144
|
}
|
|
32895
33145
|
});
|
|
32896
33146
|
|
|
32897
|
-
// node_modules/@vercel/oidc/dist/token-util.js
|
|
33147
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-util.js
|
|
32898
33148
|
var require_token_util = __commonJS((exports, module) => {
|
|
32899
33149
|
var __create2 = Object.create;
|
|
32900
33150
|
var __defProp2 = Object.defineProperty;
|
|
@@ -33059,7 +33309,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
33059
33309
|
}
|
|
33060
33310
|
});
|
|
33061
33311
|
|
|
33062
|
-
// node_modules/@vercel/oidc/dist/token.js
|
|
33312
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token.js
|
|
33063
33313
|
var require_token = __commonJS((exports, module) => {
|
|
33064
33314
|
var __defProp2 = Object.defineProperty;
|
|
33065
33315
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -33116,7 +33366,7 @@ var require_token = __commonJS((exports, module) => {
|
|
|
33116
33366
|
}
|
|
33117
33367
|
});
|
|
33118
33368
|
|
|
33119
|
-
// node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
|
|
33369
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
|
|
33120
33370
|
var require_get_vercel_oidc_token = __commonJS((exports, module) => {
|
|
33121
33371
|
var __defProp2 = Object.defineProperty;
|
|
33122
33372
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -33182,7 +33432,7 @@ ${error40.message}`;
|
|
|
33182
33432
|
}
|
|
33183
33433
|
});
|
|
33184
33434
|
|
|
33185
|
-
// node_modules/@vercel/oidc/dist/index.js
|
|
33435
|
+
// node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/index.js
|
|
33186
33436
|
var require_dist = __commonJS((exports, module) => {
|
|
33187
33437
|
var __defProp2 = Object.defineProperty;
|
|
33188
33438
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -33217,7 +33467,7 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
33217
33467
|
var import_token_util = require_token_util();
|
|
33218
33468
|
});
|
|
33219
33469
|
|
|
33220
|
-
// node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
33470
|
+
// node_modules/.pnpm/@ai-sdk+gateway@3.0.143_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
33221
33471
|
async function createGatewayErrorFromResponse({
|
|
33222
33472
|
response,
|
|
33223
33473
|
statusCode,
|
|
@@ -33225,7 +33475,7 @@ async function createGatewayErrorFromResponse({
|
|
|
33225
33475
|
cause,
|
|
33226
33476
|
authMethod
|
|
33227
33477
|
}) {
|
|
33228
|
-
var
|
|
33478
|
+
var _a112;
|
|
33229
33479
|
const parseResult = await safeValidateTypes({
|
|
33230
33480
|
value: response,
|
|
33231
33481
|
schema: gatewayErrorResponseSchema
|
|
@@ -33244,7 +33494,7 @@ async function createGatewayErrorFromResponse({
|
|
|
33244
33494
|
const validatedResponse = parseResult.value;
|
|
33245
33495
|
const errorType = validatedResponse.error.type;
|
|
33246
33496
|
const message = validatedResponse.error.message;
|
|
33247
|
-
const generationId = (
|
|
33497
|
+
const generationId = (_a112 = validatedResponse.generationId) != null ? _a112 : undefined;
|
|
33248
33498
|
switch (errorType) {
|
|
33249
33499
|
case "authentication_error":
|
|
33250
33500
|
return GatewayAuthenticationError.createContextualError({
|
|
@@ -33295,6 +33545,13 @@ async function createGatewayErrorFromResponse({
|
|
|
33295
33545
|
cause,
|
|
33296
33546
|
generationId
|
|
33297
33547
|
});
|
|
33548
|
+
case "forbidden":
|
|
33549
|
+
return new GatewayForbiddenError({
|
|
33550
|
+
message,
|
|
33551
|
+
statusCode,
|
|
33552
|
+
cause,
|
|
33553
|
+
generationId
|
|
33554
|
+
});
|
|
33298
33555
|
default:
|
|
33299
33556
|
return new GatewayInternalServerError({
|
|
33300
33557
|
message,
|
|
@@ -33333,7 +33590,7 @@ function isTimeoutError(error40) {
|
|
|
33333
33590
|
return false;
|
|
33334
33591
|
}
|
|
33335
33592
|
async function asGatewayError(error40, authMethod) {
|
|
33336
|
-
var
|
|
33593
|
+
var _a112;
|
|
33337
33594
|
if (GatewayError.isInstance(error40)) {
|
|
33338
33595
|
return error40;
|
|
33339
33596
|
}
|
|
@@ -33352,7 +33609,7 @@ async function asGatewayError(error40, authMethod) {
|
|
|
33352
33609
|
}
|
|
33353
33610
|
return await createGatewayErrorFromResponse({
|
|
33354
33611
|
response: extractApiCallResponse(error40),
|
|
33355
|
-
statusCode: (
|
|
33612
|
+
statusCode: (_a112 = error40.statusCode) != null ? _a112 : 500,
|
|
33356
33613
|
defaultMessage: "Gateway request failed",
|
|
33357
33614
|
cause: error40,
|
|
33358
33615
|
authMethod
|
|
@@ -33392,16 +33649,16 @@ function maybeEncodeVideoFile(file2) {
|
|
|
33392
33649
|
return file2;
|
|
33393
33650
|
}
|
|
33394
33651
|
async function getVercelRequestId() {
|
|
33395
|
-
var
|
|
33396
|
-
return (
|
|
33652
|
+
var _a112;
|
|
33653
|
+
return (_a112 = import_oidc.getContext().headers) == null ? undefined : _a112["x-vercel-id"];
|
|
33397
33654
|
}
|
|
33398
33655
|
function createGatewayProvider(options = {}) {
|
|
33399
|
-
var
|
|
33656
|
+
var _a112, _b112;
|
|
33400
33657
|
let pendingMetadata = null;
|
|
33401
33658
|
let metadataCache = null;
|
|
33402
|
-
const cacheRefreshMillis = (
|
|
33659
|
+
const cacheRefreshMillis = (_a112 = options.metadataCacheRefreshMillis) != null ? _a112 : 1000 * 60 * 5;
|
|
33403
33660
|
let lastFetchTime = 0;
|
|
33404
|
-
const baseURL = (
|
|
33661
|
+
const baseURL = (_b112 = withoutTrailingSlash(options.baseURL)) != null ? _b112 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
33405
33662
|
const getHeaders = async () => {
|
|
33406
33663
|
try {
|
|
33407
33664
|
const auth = await getGatewayAuthToken(options);
|
|
@@ -33458,8 +33715,8 @@ function createGatewayProvider(options = {}) {
|
|
|
33458
33715
|
});
|
|
33459
33716
|
};
|
|
33460
33717
|
const getAvailableModels = async () => {
|
|
33461
|
-
var
|
|
33462
|
-
const now2 = (_c = (
|
|
33718
|
+
var _a122, _b122, _c;
|
|
33719
|
+
const now2 = (_c = (_b122 = (_a122 = options._internal) == null ? undefined : _a122.currentDate) == null ? undefined : _b122.call(_a122).getTime()) != null ? _c : Date.now();
|
|
33463
33720
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
33464
33721
|
lastFetchTime = now2;
|
|
33465
33722
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -33554,6 +33811,28 @@ function createGatewayProvider(options = {}) {
|
|
|
33554
33811
|
};
|
|
33555
33812
|
provider.rerankingModel = createRerankingModel;
|
|
33556
33813
|
provider.reranking = createRerankingModel;
|
|
33814
|
+
const createSpeechModel = (modelId) => {
|
|
33815
|
+
return new GatewaySpeechModel(modelId, {
|
|
33816
|
+
provider: "gateway",
|
|
33817
|
+
baseURL,
|
|
33818
|
+
headers: getHeaders,
|
|
33819
|
+
fetch: options.fetch,
|
|
33820
|
+
o11yHeaders: createO11yHeaders()
|
|
33821
|
+
});
|
|
33822
|
+
};
|
|
33823
|
+
provider.speechModel = createSpeechModel;
|
|
33824
|
+
provider.speech = createSpeechModel;
|
|
33825
|
+
const createTranscriptionModel = (modelId) => {
|
|
33826
|
+
return new GatewayTranscriptionModel(modelId, {
|
|
33827
|
+
provider: "gateway",
|
|
33828
|
+
baseURL,
|
|
33829
|
+
headers: getHeaders,
|
|
33830
|
+
fetch: options.fetch,
|
|
33831
|
+
o11yHeaders: createO11yHeaders()
|
|
33832
|
+
});
|
|
33833
|
+
};
|
|
33834
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
33835
|
+
provider.transcription = createTranscriptionModel;
|
|
33557
33836
|
provider.chat = provider.languageModel;
|
|
33558
33837
|
provider.embedding = provider.embeddingModel;
|
|
33559
33838
|
provider.image = provider.imageModel;
|
|
@@ -33578,7 +33857,7 @@ async function getGatewayAuthToken(options) {
|
|
|
33578
33857
|
authMethod: "oidc"
|
|
33579
33858
|
};
|
|
33580
33859
|
}
|
|
33581
|
-
var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a17, _b17, GatewayError, name16 = "GatewayAuthenticationError", marker22, symbol22, _a22, _b22, GatewayAuthenticationError, name22 = "GatewayInvalidRequestError", marker32, symbol32, _a32, _b32, GatewayInvalidRequestError, name32 = "GatewayRateLimitError", marker42, symbol42, _a42, _b42, GatewayRateLimitError, name42 = "GatewayModelNotFoundError", marker52, symbol52, modelNotFoundParamSchema, _a52, _b52, GatewayModelNotFoundError, name52 = "GatewayInternalServerError", marker62, symbol62, _a62, _b62, GatewayInternalServerError, name62 = "GatewayFailedDependencyError", marker72, symbol72, _a72, _b72, GatewayFailedDependencyError, name72 = "
|
|
33860
|
+
var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a17, _b17, GatewayError, name16 = "GatewayAuthenticationError", marker22, symbol22, _a22, _b22, GatewayAuthenticationError, name22 = "GatewayInvalidRequestError", marker32, symbol32, _a32, _b32, GatewayInvalidRequestError, name32 = "GatewayRateLimitError", marker42, symbol42, _a42, _b42, GatewayRateLimitError, name42 = "GatewayModelNotFoundError", marker52, symbol52, modelNotFoundParamSchema, _a52, _b52, GatewayModelNotFoundError, name52 = "GatewayInternalServerError", marker62, symbol62, _a62, _b62, GatewayInternalServerError, name62 = "GatewayFailedDependencyError", marker72, symbol72, _a72, _b72, GatewayFailedDependencyError, name72 = "GatewayForbiddenError", marker82, symbol82, _a82, _b82, GatewayForbiddenError, name82 = "GatewayResponseError", marker92, symbol92, _a92, _b92, GatewayResponseError, gatewayErrorResponseSchema, name92 = "GatewayTimeoutError", marker102, symbol102, _a102, _b102, GatewayTimeoutError, GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method", gatewayAuthMethodSchema, KNOWN_MODEL_TYPES, GatewayFetchMetadata = class {
|
|
33582
33861
|
constructor(config2) {
|
|
33583
33862
|
this.config = config2;
|
|
33584
33863
|
}
|
|
@@ -33824,7 +34103,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33824
34103
|
abortSignal,
|
|
33825
34104
|
providerOptions
|
|
33826
34105
|
}) {
|
|
33827
|
-
var
|
|
34106
|
+
var _a112, _b112;
|
|
33828
34107
|
const resolvedHeaders = await resolve3(this.config.headers());
|
|
33829
34108
|
try {
|
|
33830
34109
|
const {
|
|
@@ -33848,10 +34127,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33848
34127
|
});
|
|
33849
34128
|
return {
|
|
33850
34129
|
embeddings: responseBody.embeddings,
|
|
33851
|
-
usage: (
|
|
34130
|
+
usage: (_a112 = responseBody.usage) != null ? _a112 : undefined,
|
|
33852
34131
|
providerMetadata: responseBody.providerMetadata,
|
|
33853
34132
|
response: { headers: responseHeaders, body: rawValue },
|
|
33854
|
-
warnings: []
|
|
34133
|
+
warnings: (_b112 = responseBody.warnings) != null ? _b112 : []
|
|
33855
34134
|
};
|
|
33856
34135
|
} catch (error40) {
|
|
33857
34136
|
throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
|
|
@@ -33866,7 +34145,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33866
34145
|
"ai-model-id": this.modelId
|
|
33867
34146
|
};
|
|
33868
34147
|
}
|
|
33869
|
-
}, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
|
|
34148
|
+
}, gatewayEmbeddingWarningSchema, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
|
|
33870
34149
|
constructor(modelId, config2) {
|
|
33871
34150
|
this.modelId = modelId;
|
|
33872
34151
|
this.config = config2;
|
|
@@ -33888,7 +34167,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33888
34167
|
headers,
|
|
33889
34168
|
abortSignal
|
|
33890
34169
|
}) {
|
|
33891
|
-
var
|
|
34170
|
+
var _a112, _b112, _c, _d;
|
|
33892
34171
|
const resolvedHeaders = await resolve3(this.config.headers());
|
|
33893
34172
|
try {
|
|
33894
34173
|
const {
|
|
@@ -33920,7 +34199,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33920
34199
|
});
|
|
33921
34200
|
return {
|
|
33922
34201
|
images: responseBody.images,
|
|
33923
|
-
warnings: (
|
|
34202
|
+
warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
|
|
33924
34203
|
providerMetadata: responseBody.providerMetadata,
|
|
33925
34204
|
response: {
|
|
33926
34205
|
timestamp: /* @__PURE__ */ new Date,
|
|
@@ -33929,7 +34208,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33929
34208
|
},
|
|
33930
34209
|
...responseBody.usage != null && {
|
|
33931
34210
|
usage: {
|
|
33932
|
-
inputTokens: (
|
|
34211
|
+
inputTokens: (_b112 = responseBody.usage.inputTokens) != null ? _b112 : undefined,
|
|
33933
34212
|
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : undefined,
|
|
33934
34213
|
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : undefined
|
|
33935
34214
|
}
|
|
@@ -33966,12 +34245,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33966
34245
|
duration: duration3,
|
|
33967
34246
|
fps,
|
|
33968
34247
|
seed,
|
|
34248
|
+
generateAudio,
|
|
33969
34249
|
image,
|
|
34250
|
+
frameImages,
|
|
34251
|
+
inputReferences,
|
|
33970
34252
|
providerOptions,
|
|
33971
34253
|
headers,
|
|
33972
34254
|
abortSignal
|
|
33973
34255
|
}) {
|
|
33974
|
-
var
|
|
34256
|
+
var _a112;
|
|
33975
34257
|
const resolvedHeaders = await resolve3(this.config.headers());
|
|
33976
34258
|
try {
|
|
33977
34259
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
@@ -33985,8 +34267,18 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
33985
34267
|
...duration3 && { duration: duration3 },
|
|
33986
34268
|
...fps && { fps },
|
|
33987
34269
|
...seed && { seed },
|
|
34270
|
+
...generateAudio !== undefined && { generateAudio },
|
|
33988
34271
|
...providerOptions && { providerOptions },
|
|
33989
|
-
...image && { image: maybeEncodeVideoFile(image) }
|
|
34272
|
+
...image && { image: maybeEncodeVideoFile(image) },
|
|
34273
|
+
...frameImages && {
|
|
34274
|
+
frameImages: frameImages.map((frame) => ({
|
|
34275
|
+
...frame,
|
|
34276
|
+
image: maybeEncodeVideoFile(frame.image)
|
|
34277
|
+
}))
|
|
34278
|
+
},
|
|
34279
|
+
...inputReferences && {
|
|
34280
|
+
inputReferences: inputReferences.map((reference) => maybeEncodeVideoFile(reference))
|
|
34281
|
+
}
|
|
33990
34282
|
},
|
|
33991
34283
|
successfulResponseHandler: async ({
|
|
33992
34284
|
response,
|
|
@@ -34061,7 +34353,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
34061
34353
|
});
|
|
34062
34354
|
return {
|
|
34063
34355
|
videos: responseBody.videos,
|
|
34064
|
-
warnings: (
|
|
34356
|
+
warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
|
|
34065
34357
|
providerMetadata: responseBody.providerMetadata,
|
|
34066
34358
|
response: {
|
|
34067
34359
|
timestamp: /* @__PURE__ */ new Date,
|
|
@@ -34099,6 +34391,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
34099
34391
|
abortSignal,
|
|
34100
34392
|
providerOptions
|
|
34101
34393
|
}) {
|
|
34394
|
+
var _a112;
|
|
34102
34395
|
const resolvedHeaders = await resolve3(this.config.headers());
|
|
34103
34396
|
try {
|
|
34104
34397
|
const {
|
|
@@ -34126,7 +34419,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
34126
34419
|
ranking: responseBody.ranking,
|
|
34127
34420
|
providerMetadata: responseBody.providerMetadata,
|
|
34128
34421
|
response: { headers: responseHeaders, body: rawValue },
|
|
34129
|
-
warnings: []
|
|
34422
|
+
warnings: (_a112 = responseBody.warnings) != null ? _a112 : []
|
|
34130
34423
|
};
|
|
34131
34424
|
} catch (error40) {
|
|
34132
34425
|
throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
|
|
@@ -34141,7 +34434,144 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
34141
34434
|
"ai-model-id": this.modelId
|
|
34142
34435
|
};
|
|
34143
34436
|
}
|
|
34144
|
-
},
|
|
34437
|
+
}, gatewayRerankingWarningSchema, gatewayRerankingResponseSchema, GatewaySpeechModel = class {
|
|
34438
|
+
constructor(modelId, config2) {
|
|
34439
|
+
this.modelId = modelId;
|
|
34440
|
+
this.config = config2;
|
|
34441
|
+
this.specificationVersion = "v3";
|
|
34442
|
+
}
|
|
34443
|
+
get provider() {
|
|
34444
|
+
return this.config.provider;
|
|
34445
|
+
}
|
|
34446
|
+
async doGenerate({
|
|
34447
|
+
text,
|
|
34448
|
+
voice,
|
|
34449
|
+
outputFormat,
|
|
34450
|
+
instructions,
|
|
34451
|
+
speed,
|
|
34452
|
+
language,
|
|
34453
|
+
providerOptions,
|
|
34454
|
+
headers,
|
|
34455
|
+
abortSignal
|
|
34456
|
+
}) {
|
|
34457
|
+
var _a112;
|
|
34458
|
+
const resolvedHeaders = await resolve3(this.config.headers());
|
|
34459
|
+
try {
|
|
34460
|
+
const {
|
|
34461
|
+
responseHeaders,
|
|
34462
|
+
value: responseBody,
|
|
34463
|
+
rawValue
|
|
34464
|
+
} = await postJsonToApi({
|
|
34465
|
+
url: this.getUrl(),
|
|
34466
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve3(this.config.o11yHeaders)),
|
|
34467
|
+
body: {
|
|
34468
|
+
text,
|
|
34469
|
+
...voice && { voice },
|
|
34470
|
+
...outputFormat && { outputFormat },
|
|
34471
|
+
...instructions && { instructions },
|
|
34472
|
+
...speed != null && { speed },
|
|
34473
|
+
...language && { language },
|
|
34474
|
+
...providerOptions && { providerOptions }
|
|
34475
|
+
},
|
|
34476
|
+
successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
|
|
34477
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
34478
|
+
errorSchema: exports_external2.any(),
|
|
34479
|
+
errorToMessage: (data) => data
|
|
34480
|
+
}),
|
|
34481
|
+
...abortSignal && { abortSignal },
|
|
34482
|
+
fetch: this.config.fetch
|
|
34483
|
+
});
|
|
34484
|
+
return {
|
|
34485
|
+
audio: responseBody.audio,
|
|
34486
|
+
warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
|
|
34487
|
+
providerMetadata: responseBody.providerMetadata,
|
|
34488
|
+
response: {
|
|
34489
|
+
timestamp: /* @__PURE__ */ new Date,
|
|
34490
|
+
modelId: this.modelId,
|
|
34491
|
+
headers: responseHeaders,
|
|
34492
|
+
body: rawValue
|
|
34493
|
+
}
|
|
34494
|
+
};
|
|
34495
|
+
} catch (error40) {
|
|
34496
|
+
throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
|
|
34497
|
+
}
|
|
34498
|
+
}
|
|
34499
|
+
getUrl() {
|
|
34500
|
+
return `${this.config.baseURL}/speech-model`;
|
|
34501
|
+
}
|
|
34502
|
+
getModelConfigHeaders() {
|
|
34503
|
+
return {
|
|
34504
|
+
"ai-speech-model-specification-version": "3",
|
|
34505
|
+
"ai-model-id": this.modelId
|
|
34506
|
+
};
|
|
34507
|
+
}
|
|
34508
|
+
}, providerMetadataEntrySchema3, gatewaySpeechWarningSchema, gatewaySpeechResponseSchema, GatewayTranscriptionModel = class {
|
|
34509
|
+
constructor(modelId, config2) {
|
|
34510
|
+
this.modelId = modelId;
|
|
34511
|
+
this.config = config2;
|
|
34512
|
+
this.specificationVersion = "v3";
|
|
34513
|
+
}
|
|
34514
|
+
get provider() {
|
|
34515
|
+
return this.config.provider;
|
|
34516
|
+
}
|
|
34517
|
+
async doGenerate({
|
|
34518
|
+
audio,
|
|
34519
|
+
mediaType,
|
|
34520
|
+
providerOptions,
|
|
34521
|
+
headers,
|
|
34522
|
+
abortSignal
|
|
34523
|
+
}) {
|
|
34524
|
+
var _a112, _b112, _c, _d;
|
|
34525
|
+
const resolvedHeaders = await resolve3(this.config.headers());
|
|
34526
|
+
try {
|
|
34527
|
+
const {
|
|
34528
|
+
responseHeaders,
|
|
34529
|
+
value: responseBody,
|
|
34530
|
+
rawValue
|
|
34531
|
+
} = await postJsonToApi({
|
|
34532
|
+
url: this.getUrl(),
|
|
34533
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve3(this.config.o11yHeaders)),
|
|
34534
|
+
body: {
|
|
34535
|
+
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
|
|
34536
|
+
mediaType,
|
|
34537
|
+
...providerOptions && { providerOptions }
|
|
34538
|
+
},
|
|
34539
|
+
successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
|
|
34540
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
34541
|
+
errorSchema: exports_external2.any(),
|
|
34542
|
+
errorToMessage: (data) => data
|
|
34543
|
+
}),
|
|
34544
|
+
...abortSignal && { abortSignal },
|
|
34545
|
+
fetch: this.config.fetch
|
|
34546
|
+
});
|
|
34547
|
+
return {
|
|
34548
|
+
text: responseBody.text,
|
|
34549
|
+
segments: (_a112 = responseBody.segments) != null ? _a112 : [],
|
|
34550
|
+
language: (_b112 = responseBody.language) != null ? _b112 : undefined,
|
|
34551
|
+
durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : undefined,
|
|
34552
|
+
warnings: (_d = responseBody.warnings) != null ? _d : [],
|
|
34553
|
+
providerMetadata: responseBody.providerMetadata,
|
|
34554
|
+
response: {
|
|
34555
|
+
timestamp: /* @__PURE__ */ new Date,
|
|
34556
|
+
modelId: this.modelId,
|
|
34557
|
+
headers: responseHeaders,
|
|
34558
|
+
body: rawValue
|
|
34559
|
+
}
|
|
34560
|
+
};
|
|
34561
|
+
} catch (error40) {
|
|
34562
|
+
throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
|
|
34563
|
+
}
|
|
34564
|
+
}
|
|
34565
|
+
getUrl() {
|
|
34566
|
+
return `${this.config.baseURL}/transcription-model`;
|
|
34567
|
+
}
|
|
34568
|
+
getModelConfigHeaders() {
|
|
34569
|
+
return {
|
|
34570
|
+
"ai-transcription-model-specification-version": "3",
|
|
34571
|
+
"ai-model-id": this.modelId
|
|
34572
|
+
};
|
|
34573
|
+
}
|
|
34574
|
+
}, providerMetadataEntrySchema4, gatewayTranscriptionWarningSchema, gatewayTranscriptionResponseSchema, exaSearchInputSchema, exaSearchOutputSchema, exaSearchToolFactory, exaSearch = (config2 = {}) => exaSearchToolFactory(config2), parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.143", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
34145
34575
|
var init_dist7 = __esm(() => {
|
|
34146
34576
|
init_dist3();
|
|
34147
34577
|
init_dist();
|
|
@@ -34169,6 +34599,12 @@ var init_dist7 = __esm(() => {
|
|
|
34169
34599
|
init_dist3();
|
|
34170
34600
|
init_v4();
|
|
34171
34601
|
init_dist3();
|
|
34602
|
+
init_v4();
|
|
34603
|
+
init_dist3();
|
|
34604
|
+
init_v4();
|
|
34605
|
+
init_dist3();
|
|
34606
|
+
init_zod();
|
|
34607
|
+
init_dist3();
|
|
34172
34608
|
init_zod();
|
|
34173
34609
|
init_dist3();
|
|
34174
34610
|
init_zod();
|
|
@@ -34350,7 +34786,25 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34350
34786
|
};
|
|
34351
34787
|
marker82 = `vercel.ai.gateway.error.${name72}`;
|
|
34352
34788
|
symbol82 = Symbol.for(marker82);
|
|
34353
|
-
|
|
34789
|
+
GatewayForbiddenError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
|
|
34790
|
+
constructor({
|
|
34791
|
+
message = "Forbidden",
|
|
34792
|
+
statusCode = 403,
|
|
34793
|
+
cause,
|
|
34794
|
+
generationId
|
|
34795
|
+
} = {}) {
|
|
34796
|
+
super({ message, statusCode, cause, generationId });
|
|
34797
|
+
this[_a82] = true;
|
|
34798
|
+
this.name = name72;
|
|
34799
|
+
this.type = "forbidden";
|
|
34800
|
+
}
|
|
34801
|
+
static isInstance(error40) {
|
|
34802
|
+
return GatewayError.hasMarker(error40) && symbol82 in error40;
|
|
34803
|
+
}
|
|
34804
|
+
};
|
|
34805
|
+
marker92 = `vercel.ai.gateway.error.${name82}`;
|
|
34806
|
+
symbol92 = Symbol.for(marker92);
|
|
34807
|
+
GatewayResponseError = class extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
|
|
34354
34808
|
constructor({
|
|
34355
34809
|
message = "Invalid response from Gateway",
|
|
34356
34810
|
statusCode = 502,
|
|
@@ -34360,14 +34814,14 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34360
34814
|
generationId
|
|
34361
34815
|
} = {}) {
|
|
34362
34816
|
super({ message, statusCode, cause, generationId });
|
|
34363
|
-
this[
|
|
34364
|
-
this.name =
|
|
34817
|
+
this[_a92] = true;
|
|
34818
|
+
this.name = name82;
|
|
34365
34819
|
this.type = "response_error";
|
|
34366
34820
|
this.response = response;
|
|
34367
34821
|
this.validationError = validationError;
|
|
34368
34822
|
}
|
|
34369
34823
|
static isInstance(error40) {
|
|
34370
|
-
return GatewayError.hasMarker(error40) &&
|
|
34824
|
+
return GatewayError.hasMarker(error40) && symbol92 in error40;
|
|
34371
34825
|
}
|
|
34372
34826
|
};
|
|
34373
34827
|
gatewayErrorResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
@@ -34379,9 +34833,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34379
34833
|
}),
|
|
34380
34834
|
generationId: exports_external2.string().nullish()
|
|
34381
34835
|
})));
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
GatewayTimeoutError = class _GatewayTimeoutError extends (
|
|
34836
|
+
marker102 = `vercel.ai.gateway.error.${name92}`;
|
|
34837
|
+
symbol102 = Symbol.for(marker102);
|
|
34838
|
+
GatewayTimeoutError = class _GatewayTimeoutError extends (_b102 = GatewayError, _a102 = symbol102, _b102) {
|
|
34385
34839
|
constructor({
|
|
34386
34840
|
message = "Request timed out",
|
|
34387
34841
|
statusCode = 408,
|
|
@@ -34389,12 +34843,12 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34389
34843
|
generationId
|
|
34390
34844
|
} = {}) {
|
|
34391
34845
|
super({ message, statusCode, cause, generationId });
|
|
34392
|
-
this[
|
|
34393
|
-
this.name =
|
|
34846
|
+
this[_a102] = true;
|
|
34847
|
+
this.name = name92;
|
|
34394
34848
|
this.type = "timeout_error";
|
|
34395
34849
|
}
|
|
34396
34850
|
static isInstance(error40) {
|
|
34397
|
-
return GatewayError.hasMarker(error40) &&
|
|
34851
|
+
return GatewayError.hasMarker(error40) && symbol102 in error40;
|
|
34398
34852
|
}
|
|
34399
34853
|
static createTimeoutError({
|
|
34400
34854
|
originalMessage,
|
|
@@ -34419,6 +34873,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34419
34873
|
"image",
|
|
34420
34874
|
"language",
|
|
34421
34875
|
"reranking",
|
|
34876
|
+
"speech",
|
|
34877
|
+
"transcription",
|
|
34422
34878
|
"video"
|
|
34423
34879
|
];
|
|
34424
34880
|
gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
@@ -34545,9 +35001,26 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34545
35001
|
billableWebSearchCalls: billable_web_search_calls
|
|
34546
35002
|
}))
|
|
34547
35003
|
}).transform(({ data }) => data)));
|
|
35004
|
+
gatewayEmbeddingWarningSchema = exports_external2.discriminatedUnion("type", [
|
|
35005
|
+
exports_external2.object({
|
|
35006
|
+
type: exports_external2.literal("unsupported"),
|
|
35007
|
+
feature: exports_external2.string(),
|
|
35008
|
+
details: exports_external2.string().optional()
|
|
35009
|
+
}),
|
|
35010
|
+
exports_external2.object({
|
|
35011
|
+
type: exports_external2.literal("compatibility"),
|
|
35012
|
+
feature: exports_external2.string(),
|
|
35013
|
+
details: exports_external2.string().optional()
|
|
35014
|
+
}),
|
|
35015
|
+
exports_external2.object({
|
|
35016
|
+
type: exports_external2.literal("other"),
|
|
35017
|
+
message: exports_external2.string()
|
|
35018
|
+
})
|
|
35019
|
+
]);
|
|
34548
35020
|
gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
34549
35021
|
embeddings: exports_external2.array(exports_external2.array(exports_external2.number())),
|
|
34550
35022
|
usage: exports_external2.object({ tokens: exports_external2.number() }).nullish(),
|
|
35023
|
+
warnings: exports_external2.array(gatewayEmbeddingWarningSchema).optional(),
|
|
34551
35024
|
providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
|
|
34552
35025
|
})));
|
|
34553
35026
|
providerMetadataEntrySchema = exports_external2.object({
|
|
@@ -34626,22 +35099,198 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34626
35099
|
param: exports_external2.unknown().nullable()
|
|
34627
35100
|
})
|
|
34628
35101
|
]);
|
|
35102
|
+
gatewayRerankingWarningSchema = exports_external2.discriminatedUnion("type", [
|
|
35103
|
+
exports_external2.object({
|
|
35104
|
+
type: exports_external2.literal("unsupported"),
|
|
35105
|
+
feature: exports_external2.string(),
|
|
35106
|
+
details: exports_external2.string().optional()
|
|
35107
|
+
}),
|
|
35108
|
+
exports_external2.object({
|
|
35109
|
+
type: exports_external2.literal("compatibility"),
|
|
35110
|
+
feature: exports_external2.string(),
|
|
35111
|
+
details: exports_external2.string().optional()
|
|
35112
|
+
}),
|
|
35113
|
+
exports_external2.object({
|
|
35114
|
+
type: exports_external2.literal("other"),
|
|
35115
|
+
message: exports_external2.string()
|
|
35116
|
+
})
|
|
35117
|
+
]);
|
|
34629
35118
|
gatewayRerankingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
34630
35119
|
ranking: exports_external2.array(exports_external2.object({
|
|
34631
35120
|
index: exports_external2.number(),
|
|
34632
35121
|
relevanceScore: exports_external2.number()
|
|
34633
35122
|
})),
|
|
35123
|
+
warnings: exports_external2.array(gatewayRerankingWarningSchema).optional(),
|
|
34634
35124
|
providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
|
|
34635
35125
|
})));
|
|
35126
|
+
providerMetadataEntrySchema3 = exports_external2.object({}).catchall(exports_external2.unknown());
|
|
35127
|
+
gatewaySpeechWarningSchema = exports_external2.discriminatedUnion("type", [
|
|
35128
|
+
exports_external2.object({
|
|
35129
|
+
type: exports_external2.literal("unsupported"),
|
|
35130
|
+
feature: exports_external2.string(),
|
|
35131
|
+
details: exports_external2.string().optional()
|
|
35132
|
+
}),
|
|
35133
|
+
exports_external2.object({
|
|
35134
|
+
type: exports_external2.literal("compatibility"),
|
|
35135
|
+
feature: exports_external2.string(),
|
|
35136
|
+
details: exports_external2.string().optional()
|
|
35137
|
+
}),
|
|
35138
|
+
exports_external2.object({
|
|
35139
|
+
type: exports_external2.literal("other"),
|
|
35140
|
+
message: exports_external2.string()
|
|
35141
|
+
})
|
|
35142
|
+
]);
|
|
35143
|
+
gatewaySpeechResponseSchema = exports_external2.object({
|
|
35144
|
+
audio: exports_external2.string(),
|
|
35145
|
+
warnings: exports_external2.array(gatewaySpeechWarningSchema).optional(),
|
|
35146
|
+
providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema3).optional()
|
|
35147
|
+
});
|
|
35148
|
+
providerMetadataEntrySchema4 = exports_external2.object({}).catchall(exports_external2.unknown());
|
|
35149
|
+
gatewayTranscriptionWarningSchema = exports_external2.discriminatedUnion("type", [
|
|
35150
|
+
exports_external2.object({
|
|
35151
|
+
type: exports_external2.literal("unsupported"),
|
|
35152
|
+
feature: exports_external2.string(),
|
|
35153
|
+
details: exports_external2.string().optional()
|
|
35154
|
+
}),
|
|
35155
|
+
exports_external2.object({
|
|
35156
|
+
type: exports_external2.literal("compatibility"),
|
|
35157
|
+
feature: exports_external2.string(),
|
|
35158
|
+
details: exports_external2.string().optional()
|
|
35159
|
+
}),
|
|
35160
|
+
exports_external2.object({
|
|
35161
|
+
type: exports_external2.literal("other"),
|
|
35162
|
+
message: exports_external2.string()
|
|
35163
|
+
})
|
|
35164
|
+
]);
|
|
35165
|
+
gatewayTranscriptionResponseSchema = exports_external2.object({
|
|
35166
|
+
text: exports_external2.string(),
|
|
35167
|
+
segments: exports_external2.array(exports_external2.object({
|
|
35168
|
+
text: exports_external2.string(),
|
|
35169
|
+
startSecond: exports_external2.number(),
|
|
35170
|
+
endSecond: exports_external2.number()
|
|
35171
|
+
})).optional(),
|
|
35172
|
+
language: exports_external2.string().nullish(),
|
|
35173
|
+
durationInSeconds: exports_external2.number().nullish(),
|
|
35174
|
+
warnings: exports_external2.array(gatewayTranscriptionWarningSchema).optional(),
|
|
35175
|
+
providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema4).optional()
|
|
35176
|
+
});
|
|
35177
|
+
exaSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
35178
|
+
query: exports_external.string().describe("Natural-language web search query. This is required."),
|
|
35179
|
+
type: exports_external.enum(["auto", "fast", "instant"]).optional().describe("Search method. Use auto for the default balance of speed and quality."),
|
|
35180
|
+
num_results: exports_external.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
|
|
35181
|
+
category: exports_external.enum([
|
|
35182
|
+
"company",
|
|
35183
|
+
"people",
|
|
35184
|
+
"research paper",
|
|
35185
|
+
"news",
|
|
35186
|
+
"personal site",
|
|
35187
|
+
"financial report"
|
|
35188
|
+
]).optional().describe("Optional content category to focus results."),
|
|
35189
|
+
user_location: exports_external.string().optional().describe("Two-letter ISO country code such as 'US'."),
|
|
35190
|
+
include_domains: exports_external.array(exports_external.string()).optional().describe("Only return results from these domains."),
|
|
35191
|
+
exclude_domains: exports_external.array(exports_external.string()).optional().describe("Exclude results from these domains."),
|
|
35192
|
+
start_published_date: exports_external.string().optional().describe("Only return links published after this ISO 8601 date."),
|
|
35193
|
+
end_published_date: exports_external.string().optional().describe("Only return links published before this ISO 8601 date."),
|
|
35194
|
+
contents: exports_external.object({
|
|
35195
|
+
text: exports_external.union([
|
|
35196
|
+
exports_external.boolean(),
|
|
35197
|
+
exports_external.object({
|
|
35198
|
+
max_characters: exports_external.number().optional(),
|
|
35199
|
+
include_html_tags: exports_external.boolean().optional(),
|
|
35200
|
+
verbosity: exports_external.enum(["compact", "standard", "full"]).optional(),
|
|
35201
|
+
include_sections: exports_external.array(exports_external.enum([
|
|
35202
|
+
"header",
|
|
35203
|
+
"navigation",
|
|
35204
|
+
"banner",
|
|
35205
|
+
"body",
|
|
35206
|
+
"sidebar",
|
|
35207
|
+
"footer",
|
|
35208
|
+
"metadata"
|
|
35209
|
+
])).optional(),
|
|
35210
|
+
exclude_sections: exports_external.array(exports_external.enum([
|
|
35211
|
+
"header",
|
|
35212
|
+
"navigation",
|
|
35213
|
+
"banner",
|
|
35214
|
+
"body",
|
|
35215
|
+
"sidebar",
|
|
35216
|
+
"footer",
|
|
35217
|
+
"metadata"
|
|
35218
|
+
])).optional()
|
|
35219
|
+
})
|
|
35220
|
+
]).optional(),
|
|
35221
|
+
highlights: exports_external.union([
|
|
35222
|
+
exports_external.boolean(),
|
|
35223
|
+
exports_external.object({
|
|
35224
|
+
query: exports_external.string().optional(),
|
|
35225
|
+
max_characters: exports_external.number().optional()
|
|
35226
|
+
})
|
|
35227
|
+
]).optional(),
|
|
35228
|
+
max_age_hours: exports_external.number().optional(),
|
|
35229
|
+
livecrawl_timeout: exports_external.number().optional(),
|
|
35230
|
+
subpages: exports_external.number().optional(),
|
|
35231
|
+
subpage_target: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
|
|
35232
|
+
extras: exports_external.object({
|
|
35233
|
+
links: exports_external.number().optional(),
|
|
35234
|
+
image_links: exports_external.number().optional()
|
|
35235
|
+
}).optional()
|
|
35236
|
+
}).optional().describe("Controls extracted page content and freshness.")
|
|
35237
|
+
})));
|
|
35238
|
+
exaSearchOutputSchema = lazySchema(() => zodSchema(exports_external.union([
|
|
35239
|
+
exports_external.object({
|
|
35240
|
+
requestId: exports_external.string(),
|
|
35241
|
+
searchType: exports_external.string().optional(),
|
|
35242
|
+
resolvedSearchType: exports_external.string().optional(),
|
|
35243
|
+
results: exports_external.array(exports_external.object({
|
|
35244
|
+
title: exports_external.string(),
|
|
35245
|
+
url: exports_external.string(),
|
|
35246
|
+
id: exports_external.string(),
|
|
35247
|
+
publishedDate: exports_external.string().nullable().optional(),
|
|
35248
|
+
author: exports_external.string().nullable().optional(),
|
|
35249
|
+
image: exports_external.string().nullable().optional(),
|
|
35250
|
+
favicon: exports_external.string().nullable().optional(),
|
|
35251
|
+
text: exports_external.string().optional(),
|
|
35252
|
+
highlights: exports_external.array(exports_external.string()).optional(),
|
|
35253
|
+
highlightScores: exports_external.array(exports_external.number()).optional(),
|
|
35254
|
+
summary: exports_external.string().optional(),
|
|
35255
|
+
subpages: exports_external.array(exports_external.any()).optional(),
|
|
35256
|
+
extras: exports_external.object({
|
|
35257
|
+
links: exports_external.array(exports_external.string()).optional(),
|
|
35258
|
+
imageLinks: exports_external.array(exports_external.string()).optional()
|
|
35259
|
+
}).optional()
|
|
35260
|
+
})),
|
|
35261
|
+
costDollars: exports_external.object({
|
|
35262
|
+
total: exports_external.number().optional(),
|
|
35263
|
+
search: exports_external.record(exports_external.number()).optional()
|
|
35264
|
+
}).optional()
|
|
35265
|
+
}),
|
|
35266
|
+
exports_external.object({
|
|
35267
|
+
error: exports_external.enum([
|
|
35268
|
+
"api_error",
|
|
35269
|
+
"rate_limit",
|
|
35270
|
+
"timeout",
|
|
35271
|
+
"invalid_input",
|
|
35272
|
+
"configuration_error",
|
|
35273
|
+
"execution_error",
|
|
35274
|
+
"unknown"
|
|
35275
|
+
]),
|
|
35276
|
+
statusCode: exports_external.number().optional(),
|
|
35277
|
+
message: exports_external.string()
|
|
35278
|
+
})
|
|
35279
|
+
])));
|
|
35280
|
+
exaSearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
35281
|
+
id: "gateway.exa_search",
|
|
35282
|
+
inputSchema: exaSearchInputSchema,
|
|
35283
|
+
outputSchema: exaSearchOutputSchema
|
|
35284
|
+
});
|
|
34636
35285
|
parallelSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
34637
35286
|
objective: exports_external.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
|
|
34638
35287
|
search_queries: exports_external.array(exports_external.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
|
|
34639
35288
|
mode: exports_external.enum(["one-shot", "agentic"]).optional().describe('Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'),
|
|
34640
35289
|
max_results: exports_external.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
|
|
34641
35290
|
source_policy: exports_external.object({
|
|
34642
|
-
include_domains: exports_external.array(exports_external.string()).optional().describe("
|
|
34643
|
-
exclude_domains: exports_external.array(exports_external.string()).optional().describe("
|
|
34644
|
-
after_date: exports_external.string().optional().describe("Only include results published after this date
|
|
35291
|
+
include_domains: exports_external.array(exports_external.string()).optional().describe("Limit results to these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
|
|
35292
|
+
exclude_domains: exports_external.array(exports_external.string()).optional().describe("Exclude results from these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
|
|
35293
|
+
after_date: exports_external.string().optional().describe("Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
|
|
34645
35294
|
}).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
|
|
34646
35295
|
excerpts: exports_external.object({
|
|
34647
35296
|
max_chars_per_result: exports_external.number().optional().describe("Maximum characters per result."),
|
|
@@ -34723,20 +35372,21 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
34723
35372
|
outputSchema: perplexitySearchOutputSchema
|
|
34724
35373
|
});
|
|
34725
35374
|
gatewayTools = {
|
|
35375
|
+
exaSearch,
|
|
34726
35376
|
parallelSearch,
|
|
34727
35377
|
perplexitySearch
|
|
34728
35378
|
};
|
|
34729
35379
|
gateway = createGatewayProvider();
|
|
34730
35380
|
});
|
|
34731
35381
|
|
|
34732
|
-
// node_modules/@opentelemetry/api/build/src/version.js
|
|
35382
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/version.js
|
|
34733
35383
|
var require_version = __commonJS((exports) => {
|
|
34734
35384
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34735
35385
|
exports.VERSION = undefined;
|
|
34736
35386
|
exports.VERSION = "1.9.1";
|
|
34737
35387
|
});
|
|
34738
35388
|
|
|
34739
|
-
// node_modules/@opentelemetry/api/build/src/internal/semver.js
|
|
35389
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/semver.js
|
|
34740
35390
|
var require_semver = __commonJS((exports) => {
|
|
34741
35391
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34742
35392
|
exports.isCompatible = exports._makeCompatibilityCheck = undefined;
|
|
@@ -34807,7 +35457,7 @@ var require_semver = __commonJS((exports) => {
|
|
|
34807
35457
|
exports.isCompatible = _makeCompatibilityCheck(version_1.VERSION);
|
|
34808
35458
|
});
|
|
34809
35459
|
|
|
34810
|
-
// node_modules/@opentelemetry/api/build/src/internal/global-utils.js
|
|
35460
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/global-utils.js
|
|
34811
35461
|
var require_global_utils = __commonJS((exports) => {
|
|
34812
35462
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34813
35463
|
exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
|
|
@@ -34855,7 +35505,7 @@ var require_global_utils = __commonJS((exports) => {
|
|
|
34855
35505
|
exports.unregisterGlobal = unregisterGlobal;
|
|
34856
35506
|
});
|
|
34857
35507
|
|
|
34858
|
-
// node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
|
|
35508
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
|
|
34859
35509
|
var require_ComponentLogger = __commonJS((exports) => {
|
|
34860
35510
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34861
35511
|
exports.DiagComponentLogger = undefined;
|
|
@@ -34891,7 +35541,7 @@ var require_ComponentLogger = __commonJS((exports) => {
|
|
|
34891
35541
|
}
|
|
34892
35542
|
});
|
|
34893
35543
|
|
|
34894
|
-
// node_modules/@opentelemetry/api/build/src/diag/types.js
|
|
35544
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/types.js
|
|
34895
35545
|
var require_types = __commonJS((exports) => {
|
|
34896
35546
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34897
35547
|
exports.DiagLogLevel = undefined;
|
|
@@ -34907,7 +35557,7 @@ var require_types = __commonJS((exports) => {
|
|
|
34907
35557
|
})(DiagLogLevel = exports.DiagLogLevel || (exports.DiagLogLevel = {}));
|
|
34908
35558
|
});
|
|
34909
35559
|
|
|
34910
|
-
// node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
|
|
35560
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
|
|
34911
35561
|
var require_logLevelLogger = __commonJS((exports) => {
|
|
34912
35562
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34913
35563
|
exports.createLogLevelDiagLogger = undefined;
|
|
@@ -34937,7 +35587,7 @@ var require_logLevelLogger = __commonJS((exports) => {
|
|
|
34937
35587
|
exports.createLogLevelDiagLogger = createLogLevelDiagLogger;
|
|
34938
35588
|
});
|
|
34939
35589
|
|
|
34940
|
-
// node_modules/@opentelemetry/api/build/src/api/diag.js
|
|
35590
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/diag.js
|
|
34941
35591
|
var require_diag = __commonJS((exports) => {
|
|
34942
35592
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34943
35593
|
exports.DiagAPI = undefined;
|
|
@@ -35002,7 +35652,7 @@ var require_diag = __commonJS((exports) => {
|
|
|
35002
35652
|
exports.DiagAPI = DiagAPI;
|
|
35003
35653
|
});
|
|
35004
35654
|
|
|
35005
|
-
// node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
|
|
35655
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
|
|
35006
35656
|
var require_baggage_impl = __commonJS((exports) => {
|
|
35007
35657
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35008
35658
|
exports.BaggageImpl = undefined;
|
|
@@ -35045,14 +35695,14 @@ var require_baggage_impl = __commonJS((exports) => {
|
|
|
35045
35695
|
exports.BaggageImpl = BaggageImpl;
|
|
35046
35696
|
});
|
|
35047
35697
|
|
|
35048
|
-
// node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
|
|
35698
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
|
|
35049
35699
|
var require_symbol = __commonJS((exports) => {
|
|
35050
35700
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35051
35701
|
exports.baggageEntryMetadataSymbol = undefined;
|
|
35052
35702
|
exports.baggageEntryMetadataSymbol = Symbol("BaggageEntryMetadata");
|
|
35053
35703
|
});
|
|
35054
35704
|
|
|
35055
|
-
// node_modules/@opentelemetry/api/build/src/baggage/utils.js
|
|
35705
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/utils.js
|
|
35056
35706
|
var require_utils = __commonJS((exports) => {
|
|
35057
35707
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35058
35708
|
exports.baggageEntryMetadataFromString = exports.createBaggage = undefined;
|
|
@@ -35079,7 +35729,7 @@ var require_utils = __commonJS((exports) => {
|
|
|
35079
35729
|
exports.baggageEntryMetadataFromString = baggageEntryMetadataFromString;
|
|
35080
35730
|
});
|
|
35081
35731
|
|
|
35082
|
-
// node_modules/@opentelemetry/api/build/src/context/context.js
|
|
35732
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/context.js
|
|
35083
35733
|
var require_context = __commonJS((exports) => {
|
|
35084
35734
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35085
35735
|
exports.ROOT_CONTEXT = exports.createContextKey = undefined;
|
|
@@ -35108,7 +35758,7 @@ var require_context = __commonJS((exports) => {
|
|
|
35108
35758
|
exports.ROOT_CONTEXT = new BaseContext;
|
|
35109
35759
|
});
|
|
35110
35760
|
|
|
35111
|
-
// node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
|
|
35761
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
|
|
35112
35762
|
var require_consoleLogger = __commonJS((exports) => {
|
|
35113
35763
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35114
35764
|
exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
|
|
@@ -35163,7 +35813,7 @@ var require_consoleLogger = __commonJS((exports) => {
|
|
|
35163
35813
|
exports.DiagConsoleLogger = DiagConsoleLogger;
|
|
35164
35814
|
});
|
|
35165
35815
|
|
|
35166
|
-
// node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
|
|
35816
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
|
|
35167
35817
|
var require_NoopMeter = __commonJS((exports) => {
|
|
35168
35818
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35169
35819
|
exports.createNoopMeter = exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = exports.NOOP_OBSERVABLE_GAUGE_METRIC = exports.NOOP_OBSERVABLE_COUNTER_METRIC = exports.NOOP_UP_DOWN_COUNTER_METRIC = exports.NOOP_HISTOGRAM_METRIC = exports.NOOP_GAUGE_METRIC = exports.NOOP_COUNTER_METRIC = exports.NOOP_METER = exports.NoopObservableUpDownCounterMetric = exports.NoopObservableGaugeMetric = exports.NoopObservableCounterMetric = exports.NoopObservableMetric = exports.NoopHistogramMetric = exports.NoopGaugeMetric = exports.NoopUpDownCounterMetric = exports.NoopCounterMetric = exports.NoopMetric = exports.NoopMeter = undefined;
|
|
@@ -35251,7 +35901,7 @@ var require_NoopMeter = __commonJS((exports) => {
|
|
|
35251
35901
|
exports.createNoopMeter = createNoopMeter;
|
|
35252
35902
|
});
|
|
35253
35903
|
|
|
35254
|
-
// node_modules/@opentelemetry/api/build/src/metrics/Metric.js
|
|
35904
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/Metric.js
|
|
35255
35905
|
var require_Metric = __commonJS((exports) => {
|
|
35256
35906
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35257
35907
|
exports.ValueType = undefined;
|
|
@@ -35262,7 +35912,7 @@ var require_Metric = __commonJS((exports) => {
|
|
|
35262
35912
|
})(ValueType = exports.ValueType || (exports.ValueType = {}));
|
|
35263
35913
|
});
|
|
35264
35914
|
|
|
35265
|
-
// node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
|
|
35915
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
|
|
35266
35916
|
var require_TextMapPropagator = __commonJS((exports) => {
|
|
35267
35917
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35268
35918
|
exports.defaultTextMapSetter = exports.defaultTextMapGetter = undefined;
|
|
@@ -35290,7 +35940,7 @@ var require_TextMapPropagator = __commonJS((exports) => {
|
|
|
35290
35940
|
};
|
|
35291
35941
|
});
|
|
35292
35942
|
|
|
35293
|
-
// node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
|
|
35943
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
|
|
35294
35944
|
var require_NoopContextManager = __commonJS((exports) => {
|
|
35295
35945
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35296
35946
|
exports.NoopContextManager = undefined;
|
|
@@ -35316,7 +35966,7 @@ var require_NoopContextManager = __commonJS((exports) => {
|
|
|
35316
35966
|
exports.NoopContextManager = NoopContextManager;
|
|
35317
35967
|
});
|
|
35318
35968
|
|
|
35319
|
-
// node_modules/@opentelemetry/api/build/src/api/context.js
|
|
35969
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/context.js
|
|
35320
35970
|
var require_context2 = __commonJS((exports) => {
|
|
35321
35971
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35322
35972
|
exports.ContextAPI = undefined;
|
|
@@ -35357,7 +36007,7 @@ var require_context2 = __commonJS((exports) => {
|
|
|
35357
36007
|
exports.ContextAPI = ContextAPI;
|
|
35358
36008
|
});
|
|
35359
36009
|
|
|
35360
|
-
// node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
|
|
36010
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
|
|
35361
36011
|
var require_trace_flags = __commonJS((exports) => {
|
|
35362
36012
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35363
36013
|
exports.TraceFlags = undefined;
|
|
@@ -35368,7 +36018,7 @@ var require_trace_flags = __commonJS((exports) => {
|
|
|
35368
36018
|
})(TraceFlags = exports.TraceFlags || (exports.TraceFlags = {}));
|
|
35369
36019
|
});
|
|
35370
36020
|
|
|
35371
|
-
// node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
|
|
36021
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
|
|
35372
36022
|
var require_invalid_span_constants = __commonJS((exports) => {
|
|
35373
36023
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35374
36024
|
exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = undefined;
|
|
@@ -35382,7 +36032,7 @@ var require_invalid_span_constants = __commonJS((exports) => {
|
|
|
35382
36032
|
};
|
|
35383
36033
|
});
|
|
35384
36034
|
|
|
35385
|
-
// node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
|
|
36035
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
|
|
35386
36036
|
var require_NonRecordingSpan = __commonJS((exports) => {
|
|
35387
36037
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35388
36038
|
exports.NonRecordingSpan = undefined;
|
|
@@ -35425,7 +36075,7 @@ var require_NonRecordingSpan = __commonJS((exports) => {
|
|
|
35425
36075
|
exports.NonRecordingSpan = NonRecordingSpan;
|
|
35426
36076
|
});
|
|
35427
36077
|
|
|
35428
|
-
// node_modules/@opentelemetry/api/build/src/trace/context-utils.js
|
|
36078
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/context-utils.js
|
|
35429
36079
|
var require_context_utils = __commonJS((exports) => {
|
|
35430
36080
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35431
36081
|
exports.getSpanContext = exports.setSpanContext = exports.deleteSpan = exports.setSpan = exports.getActiveSpan = exports.getSpan = undefined;
|
|
@@ -35460,7 +36110,7 @@ var require_context_utils = __commonJS((exports) => {
|
|
|
35460
36110
|
exports.getSpanContext = getSpanContext;
|
|
35461
36111
|
});
|
|
35462
36112
|
|
|
35463
|
-
// node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
|
|
36113
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
|
|
35464
36114
|
var require_spancontext_utils = __commonJS((exports) => {
|
|
35465
36115
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35466
36116
|
exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
|
|
@@ -35598,7 +36248,7 @@ var require_spancontext_utils = __commonJS((exports) => {
|
|
|
35598
36248
|
exports.wrapSpanContext = wrapSpanContext;
|
|
35599
36249
|
});
|
|
35600
36250
|
|
|
35601
|
-
// node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
|
|
36251
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
|
|
35602
36252
|
var require_NoopTracer = __commonJS((exports) => {
|
|
35603
36253
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35604
36254
|
exports.NoopTracer = undefined;
|
|
@@ -35649,7 +36299,7 @@ var require_NoopTracer = __commonJS((exports) => {
|
|
|
35649
36299
|
}
|
|
35650
36300
|
});
|
|
35651
36301
|
|
|
35652
|
-
// node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
|
|
36302
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
|
|
35653
36303
|
var require_ProxyTracer = __commonJS((exports) => {
|
|
35654
36304
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35655
36305
|
exports.ProxyTracer = undefined;
|
|
@@ -35685,7 +36335,7 @@ var require_ProxyTracer = __commonJS((exports) => {
|
|
|
35685
36335
|
exports.ProxyTracer = ProxyTracer;
|
|
35686
36336
|
});
|
|
35687
36337
|
|
|
35688
|
-
// node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
|
|
36338
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
|
|
35689
36339
|
var require_NoopTracerProvider = __commonJS((exports) => {
|
|
35690
36340
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35691
36341
|
exports.NoopTracerProvider = undefined;
|
|
@@ -35699,7 +36349,7 @@ var require_NoopTracerProvider = __commonJS((exports) => {
|
|
|
35699
36349
|
exports.NoopTracerProvider = NoopTracerProvider;
|
|
35700
36350
|
});
|
|
35701
36351
|
|
|
35702
|
-
// node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
|
|
36352
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
|
|
35703
36353
|
var require_ProxyTracerProvider = __commonJS((exports) => {
|
|
35704
36354
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35705
36355
|
exports.ProxyTracerProvider = undefined;
|
|
@@ -35727,7 +36377,7 @@ var require_ProxyTracerProvider = __commonJS((exports) => {
|
|
|
35727
36377
|
exports.ProxyTracerProvider = ProxyTracerProvider;
|
|
35728
36378
|
});
|
|
35729
36379
|
|
|
35730
|
-
// node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
|
|
36380
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
|
|
35731
36381
|
var require_SamplingResult = __commonJS((exports) => {
|
|
35732
36382
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35733
36383
|
exports.SamplingDecision = undefined;
|
|
@@ -35739,7 +36389,7 @@ var require_SamplingResult = __commonJS((exports) => {
|
|
|
35739
36389
|
})(SamplingDecision = exports.SamplingDecision || (exports.SamplingDecision = {}));
|
|
35740
36390
|
});
|
|
35741
36391
|
|
|
35742
|
-
// node_modules/@opentelemetry/api/build/src/trace/span_kind.js
|
|
36392
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/span_kind.js
|
|
35743
36393
|
var require_span_kind = __commonJS((exports) => {
|
|
35744
36394
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35745
36395
|
exports.SpanKind = undefined;
|
|
@@ -35753,7 +36403,7 @@ var require_span_kind = __commonJS((exports) => {
|
|
|
35753
36403
|
})(SpanKind = exports.SpanKind || (exports.SpanKind = {}));
|
|
35754
36404
|
});
|
|
35755
36405
|
|
|
35756
|
-
// node_modules/@opentelemetry/api/build/src/trace/status.js
|
|
36406
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/status.js
|
|
35757
36407
|
var require_status = __commonJS((exports) => {
|
|
35758
36408
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35759
36409
|
exports.SpanStatusCode = undefined;
|
|
@@ -35765,7 +36415,7 @@ var require_status = __commonJS((exports) => {
|
|
|
35765
36415
|
})(SpanStatusCode = exports.SpanStatusCode || (exports.SpanStatusCode = {}));
|
|
35766
36416
|
});
|
|
35767
36417
|
|
|
35768
|
-
// node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
|
|
36418
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
|
|
35769
36419
|
var require_tracestate_validators = __commonJS((exports) => {
|
|
35770
36420
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35771
36421
|
exports.validateValue = exports.validateKey = undefined;
|
|
@@ -35785,7 +36435,7 @@ var require_tracestate_validators = __commonJS((exports) => {
|
|
|
35785
36435
|
exports.validateValue = validateValue;
|
|
35786
36436
|
});
|
|
35787
36437
|
|
|
35788
|
-
// node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
|
|
36438
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
|
|
35789
36439
|
var require_tracestate_impl = __commonJS((exports) => {
|
|
35790
36440
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35791
36441
|
exports.TraceStateImpl = undefined;
|
|
@@ -35854,7 +36504,7 @@ var require_tracestate_impl = __commonJS((exports) => {
|
|
|
35854
36504
|
exports.TraceStateImpl = TraceStateImpl;
|
|
35855
36505
|
});
|
|
35856
36506
|
|
|
35857
|
-
// node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
|
|
36507
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
|
|
35858
36508
|
var require_utils2 = __commonJS((exports) => {
|
|
35859
36509
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35860
36510
|
exports.createTraceState = undefined;
|
|
@@ -35865,7 +36515,7 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
35865
36515
|
exports.createTraceState = createTraceState;
|
|
35866
36516
|
});
|
|
35867
36517
|
|
|
35868
|
-
// node_modules/@opentelemetry/api/build/src/context-api.js
|
|
36518
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context-api.js
|
|
35869
36519
|
var require_context_api = __commonJS((exports) => {
|
|
35870
36520
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35871
36521
|
exports.context = undefined;
|
|
@@ -35873,7 +36523,7 @@ var require_context_api = __commonJS((exports) => {
|
|
|
35873
36523
|
exports.context = context_1.ContextAPI.getInstance();
|
|
35874
36524
|
});
|
|
35875
36525
|
|
|
35876
|
-
// node_modules/@opentelemetry/api/build/src/diag-api.js
|
|
36526
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag-api.js
|
|
35877
36527
|
var require_diag_api = __commonJS((exports) => {
|
|
35878
36528
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35879
36529
|
exports.diag = undefined;
|
|
@@ -35881,7 +36531,7 @@ var require_diag_api = __commonJS((exports) => {
|
|
|
35881
36531
|
exports.diag = diag_1.DiagAPI.instance();
|
|
35882
36532
|
});
|
|
35883
36533
|
|
|
35884
|
-
// node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
|
|
36534
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
|
|
35885
36535
|
var require_NoopMeterProvider = __commonJS((exports) => {
|
|
35886
36536
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35887
36537
|
exports.NOOP_METER_PROVIDER = exports.NoopMeterProvider = undefined;
|
|
@@ -35896,7 +36546,7 @@ var require_NoopMeterProvider = __commonJS((exports) => {
|
|
|
35896
36546
|
exports.NOOP_METER_PROVIDER = new NoopMeterProvider;
|
|
35897
36547
|
});
|
|
35898
36548
|
|
|
35899
|
-
// node_modules/@opentelemetry/api/build/src/api/metrics.js
|
|
36549
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/metrics.js
|
|
35900
36550
|
var require_metrics = __commonJS((exports) => {
|
|
35901
36551
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35902
36552
|
exports.MetricsAPI = undefined;
|
|
@@ -35929,7 +36579,7 @@ var require_metrics = __commonJS((exports) => {
|
|
|
35929
36579
|
exports.MetricsAPI = MetricsAPI;
|
|
35930
36580
|
});
|
|
35931
36581
|
|
|
35932
|
-
// node_modules/@opentelemetry/api/build/src/metrics-api.js
|
|
36582
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics-api.js
|
|
35933
36583
|
var require_metrics_api = __commonJS((exports) => {
|
|
35934
36584
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35935
36585
|
exports.metrics = undefined;
|
|
@@ -35937,7 +36587,7 @@ var require_metrics_api = __commonJS((exports) => {
|
|
|
35937
36587
|
exports.metrics = metrics_1.MetricsAPI.getInstance();
|
|
35938
36588
|
});
|
|
35939
36589
|
|
|
35940
|
-
// node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
|
|
36590
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
|
|
35941
36591
|
var require_NoopTextMapPropagator = __commonJS((exports) => {
|
|
35942
36592
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35943
36593
|
exports.NoopTextMapPropagator = undefined;
|
|
@@ -35954,7 +36604,7 @@ var require_NoopTextMapPropagator = __commonJS((exports) => {
|
|
|
35954
36604
|
exports.NoopTextMapPropagator = NoopTextMapPropagator;
|
|
35955
36605
|
});
|
|
35956
36606
|
|
|
35957
|
-
// node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
|
|
36607
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
|
|
35958
36608
|
var require_context_helpers = __commonJS((exports) => {
|
|
35959
36609
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35960
36610
|
exports.deleteBaggage = exports.setBaggage = exports.getActiveBaggage = exports.getBaggage = undefined;
|
|
@@ -35979,7 +36629,7 @@ var require_context_helpers = __commonJS((exports) => {
|
|
|
35979
36629
|
exports.deleteBaggage = deleteBaggage;
|
|
35980
36630
|
});
|
|
35981
36631
|
|
|
35982
|
-
// node_modules/@opentelemetry/api/build/src/api/propagation.js
|
|
36632
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/propagation.js
|
|
35983
36633
|
var require_propagation = __commonJS((exports) => {
|
|
35984
36634
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35985
36635
|
exports.PropagationAPI = undefined;
|
|
@@ -36028,7 +36678,7 @@ var require_propagation = __commonJS((exports) => {
|
|
|
36028
36678
|
exports.PropagationAPI = PropagationAPI;
|
|
36029
36679
|
});
|
|
36030
36680
|
|
|
36031
|
-
// node_modules/@opentelemetry/api/build/src/propagation-api.js
|
|
36681
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation-api.js
|
|
36032
36682
|
var require_propagation_api = __commonJS((exports) => {
|
|
36033
36683
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36034
36684
|
exports.propagation = undefined;
|
|
@@ -36036,7 +36686,7 @@ var require_propagation_api = __commonJS((exports) => {
|
|
|
36036
36686
|
exports.propagation = propagation_1.PropagationAPI.getInstance();
|
|
36037
36687
|
});
|
|
36038
36688
|
|
|
36039
|
-
// node_modules/@opentelemetry/api/build/src/api/trace.js
|
|
36689
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/trace.js
|
|
36040
36690
|
var require_trace = __commonJS((exports) => {
|
|
36041
36691
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36042
36692
|
exports.TraceAPI = undefined;
|
|
@@ -36086,7 +36736,7 @@ var require_trace = __commonJS((exports) => {
|
|
|
36086
36736
|
exports.TraceAPI = TraceAPI;
|
|
36087
36737
|
});
|
|
36088
36738
|
|
|
36089
|
-
// node_modules/@opentelemetry/api/build/src/trace-api.js
|
|
36739
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace-api.js
|
|
36090
36740
|
var require_trace_api = __commonJS((exports) => {
|
|
36091
36741
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36092
36742
|
exports.trace = undefined;
|
|
@@ -36094,7 +36744,7 @@ var require_trace_api = __commonJS((exports) => {
|
|
|
36094
36744
|
exports.trace = trace_1.TraceAPI.getInstance();
|
|
36095
36745
|
});
|
|
36096
36746
|
|
|
36097
|
-
// node_modules/@opentelemetry/api/build/src/index.js
|
|
36747
|
+
// node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/index.js
|
|
36098
36748
|
var require_src = __commonJS((exports) => {
|
|
36099
36749
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36100
36750
|
exports.trace = exports.propagation = exports.metrics = exports.diag = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.createTraceState = exports.TraceFlags = exports.SpanStatusCode = exports.SpanKind = exports.SamplingDecision = exports.ProxyTracerProvider = exports.ProxyTracer = exports.defaultTextMapSetter = exports.defaultTextMapGetter = exports.ValueType = exports.createNoopMeter = exports.DiagLogLevel = exports.DiagConsoleLogger = exports.ROOT_CONTEXT = exports.createContextKey = exports.baggageEntryMetadataFromString = undefined;
|
|
@@ -36209,7 +36859,7 @@ var require_src = __commonJS((exports) => {
|
|
|
36209
36859
|
};
|
|
36210
36860
|
});
|
|
36211
36861
|
|
|
36212
|
-
// node_modules/ai/dist/index.mjs
|
|
36862
|
+
// node_modules/.pnpm/ai@6.0.219_zod@3.25.76/node_modules/ai/dist/index.mjs
|
|
36213
36863
|
var exports_dist4 = {};
|
|
36214
36864
|
__export(exports_dist4, {
|
|
36215
36865
|
zodSchema: () => zodSchema,
|
|
@@ -36324,6 +36974,7 @@ __export(exports_dist4, {
|
|
|
36324
36974
|
JsonToSseTransformStream: () => JsonToSseTransformStream,
|
|
36325
36975
|
JSONParseError: () => JSONParseError,
|
|
36326
36976
|
InvalidToolInputError: () => InvalidToolInputError,
|
|
36977
|
+
InvalidToolApprovalSignatureError: () => InvalidToolApprovalSignatureError,
|
|
36327
36978
|
InvalidToolApprovalError: () => InvalidToolApprovalError,
|
|
36328
36979
|
InvalidStreamPartError: () => InvalidStreamPartError,
|
|
36329
36980
|
InvalidResponseDataError: () => InvalidResponseDataError,
|
|
@@ -36567,7 +37218,7 @@ function resolveEmbeddingModel(model) {
|
|
|
36567
37218
|
return getGlobalProvider().embeddingModel(model);
|
|
36568
37219
|
}
|
|
36569
37220
|
function resolveTranscriptionModel(model) {
|
|
36570
|
-
var
|
|
37221
|
+
var _a222, _b16;
|
|
36571
37222
|
if (typeof model !== "string") {
|
|
36572
37223
|
if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
|
|
36573
37224
|
const unsupportedModel = model;
|
|
@@ -36579,10 +37230,10 @@ function resolveTranscriptionModel(model) {
|
|
|
36579
37230
|
}
|
|
36580
37231
|
return asTranscriptionModelV3(model);
|
|
36581
37232
|
}
|
|
36582
|
-
return (_b16 = (
|
|
37233
|
+
return (_b16 = (_a222 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a222, model);
|
|
36583
37234
|
}
|
|
36584
37235
|
function resolveSpeechModel(model) {
|
|
36585
|
-
var
|
|
37236
|
+
var _a222, _b16;
|
|
36586
37237
|
if (typeof model !== "string") {
|
|
36587
37238
|
if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
|
|
36588
37239
|
const unsupportedModel = model;
|
|
@@ -36594,7 +37245,7 @@ function resolveSpeechModel(model) {
|
|
|
36594
37245
|
}
|
|
36595
37246
|
return asSpeechModelV3(model);
|
|
36596
37247
|
}
|
|
36597
|
-
return (_b16 = (
|
|
37248
|
+
return (_b16 = (_a222 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a222, model);
|
|
36598
37249
|
}
|
|
36599
37250
|
function resolveImageModel(model) {
|
|
36600
37251
|
if (typeof model !== "string") {
|
|
@@ -36649,8 +37300,8 @@ function resolveRerankingModel(model) {
|
|
|
36649
37300
|
return model;
|
|
36650
37301
|
}
|
|
36651
37302
|
function getGlobalProvider() {
|
|
36652
|
-
var
|
|
36653
|
-
return (
|
|
37303
|
+
var _a222;
|
|
37304
|
+
return (_a222 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a222 : gateway;
|
|
36654
37305
|
}
|
|
36655
37306
|
function getTotalTimeoutMs(timeout) {
|
|
36656
37307
|
if (timeout == null) {
|
|
@@ -36975,7 +37626,7 @@ function convertToLanguageModelMessage({
|
|
|
36975
37626
|
}
|
|
36976
37627
|
}
|
|
36977
37628
|
async function downloadAssets(messages, download2, supportedUrls) {
|
|
36978
|
-
var
|
|
37629
|
+
var _a222;
|
|
36979
37630
|
const downloadableFiles = [];
|
|
36980
37631
|
for (const message of messages) {
|
|
36981
37632
|
if (message.role === "user" && Array.isArray(message.content)) {
|
|
@@ -36983,7 +37634,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
36983
37634
|
if (part.type === "image" || part.type === "file") {
|
|
36984
37635
|
downloadableFiles.push({
|
|
36985
37636
|
data: part.type === "image" ? part.image : part.data,
|
|
36986
|
-
mediaType: (
|
|
37637
|
+
mediaType: (_a222 = part.mediaType) != null ? _a222 : part.type === "image" ? "image/*" : undefined
|
|
36987
37638
|
});
|
|
36988
37639
|
}
|
|
36989
37640
|
}
|
|
@@ -37029,7 +37680,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
37029
37680
|
]).filter((file2) => file2 != null));
|
|
37030
37681
|
}
|
|
37031
37682
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
37032
|
-
var
|
|
37683
|
+
var _a222;
|
|
37033
37684
|
if (part.type === "text") {
|
|
37034
37685
|
return {
|
|
37035
37686
|
type: "text",
|
|
@@ -37062,7 +37713,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
|
37062
37713
|
switch (type) {
|
|
37063
37714
|
case "image": {
|
|
37064
37715
|
if (data instanceof Uint8Array || typeof data === "string") {
|
|
37065
|
-
mediaType = (
|
|
37716
|
+
mediaType = (_a222 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a222 : mediaType;
|
|
37066
37717
|
}
|
|
37067
37718
|
return {
|
|
37068
37719
|
type: "file",
|
|
@@ -37096,14 +37747,14 @@ function mapToolResultOutput({
|
|
|
37096
37747
|
return {
|
|
37097
37748
|
type: "content",
|
|
37098
37749
|
value: output.value.map((item) => {
|
|
37099
|
-
var
|
|
37750
|
+
var _a222, _b16;
|
|
37100
37751
|
if (item.type === "image-url") {
|
|
37101
37752
|
const downloadedFile = downloadedAssets[new URL(item.url).toString()];
|
|
37102
37753
|
if (downloadedFile) {
|
|
37103
37754
|
return {
|
|
37104
37755
|
type: "image-data",
|
|
37105
37756
|
data: convertDataContentToBase64String(downloadedFile.data),
|
|
37106
|
-
mediaType: (
|
|
37757
|
+
mediaType: (_a222 = downloadedFile.mediaType) != null ? _a222 : "image/*",
|
|
37107
37758
|
providerOptions: item.providerOptions
|
|
37108
37759
|
};
|
|
37109
37760
|
}
|
|
@@ -37264,9 +37915,9 @@ async function prepareToolsAndToolChoice({
|
|
|
37264
37915
|
toolChoice: undefined
|
|
37265
37916
|
};
|
|
37266
37917
|
}
|
|
37267
|
-
const filteredTools = activeTools != null ? Object.entries(tools).filter(([
|
|
37918
|
+
const filteredTools = activeTools != null ? Object.entries(tools).filter(([name222]) => activeTools.includes(name222)) : Object.entries(tools);
|
|
37268
37919
|
const languageModelTools = [];
|
|
37269
|
-
for (const [
|
|
37920
|
+
for (const [name222, tool2] of filteredTools) {
|
|
37270
37921
|
const toolType = tool2.type;
|
|
37271
37922
|
switch (toolType) {
|
|
37272
37923
|
case undefined:
|
|
@@ -37274,7 +37925,7 @@ async function prepareToolsAndToolChoice({
|
|
|
37274
37925
|
case "function":
|
|
37275
37926
|
languageModelTools.push({
|
|
37276
37927
|
type: "function",
|
|
37277
|
-
name:
|
|
37928
|
+
name: name222,
|
|
37278
37929
|
description: tool2.description,
|
|
37279
37930
|
inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
|
|
37280
37931
|
...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
|
|
@@ -37285,7 +37936,7 @@ async function prepareToolsAndToolChoice({
|
|
|
37285
37936
|
case "provider":
|
|
37286
37937
|
languageModelTools.push({
|
|
37287
37938
|
type: "provider",
|
|
37288
|
-
name:
|
|
37939
|
+
name: name222,
|
|
37289
37940
|
id: tool2.id,
|
|
37290
37941
|
args: tool2.args
|
|
37291
37942
|
});
|
|
@@ -37403,7 +38054,7 @@ function getBaseTelemetryAttributes({
|
|
|
37403
38054
|
telemetry,
|
|
37404
38055
|
headers
|
|
37405
38056
|
}) {
|
|
37406
|
-
var
|
|
38057
|
+
var _a222;
|
|
37407
38058
|
return {
|
|
37408
38059
|
"ai.model.provider": model.provider,
|
|
37409
38060
|
"ai.model.id": model.modelId,
|
|
@@ -37418,7 +38069,7 @@ function getBaseTelemetryAttributes({
|
|
|
37418
38069
|
}
|
|
37419
38070
|
return attributes;
|
|
37420
38071
|
}, {}),
|
|
37421
|
-
...Object.entries((
|
|
38072
|
+
...Object.entries((_a222 = telemetry == null ? undefined : telemetry.metadata) != null ? _a222 : {}).reduce((attributes, [key, value]) => {
|
|
37422
38073
|
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
37423
38074
|
return attributes;
|
|
37424
38075
|
}, {}),
|
|
@@ -37443,13 +38094,13 @@ function getTracer({
|
|
|
37443
38094
|
return import_api2.trace.getTracer("ai");
|
|
37444
38095
|
}
|
|
37445
38096
|
async function recordSpan({
|
|
37446
|
-
name:
|
|
38097
|
+
name: name222,
|
|
37447
38098
|
tracer,
|
|
37448
38099
|
attributes,
|
|
37449
38100
|
fn,
|
|
37450
38101
|
endWhenDone = true
|
|
37451
38102
|
}) {
|
|
37452
|
-
return tracer.startActiveSpan(
|
|
38103
|
+
return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
|
|
37453
38104
|
const ctx = import_api3.context.active();
|
|
37454
38105
|
try {
|
|
37455
38106
|
const result = await import_api3.context.with(ctx, () => fn(span));
|
|
@@ -37482,6 +38133,26 @@ function recordErrorOnSpan(span, error40) {
|
|
|
37482
38133
|
span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
|
|
37483
38134
|
}
|
|
37484
38135
|
}
|
|
38136
|
+
function isPrimitiveAttributeValue(value) {
|
|
38137
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
38138
|
+
}
|
|
38139
|
+
function sanitizeAttributeValue(value) {
|
|
38140
|
+
if (!Array.isArray(value)) {
|
|
38141
|
+
return value;
|
|
38142
|
+
}
|
|
38143
|
+
const primitiveTypes2 = new Set(value.filter(isPrimitiveAttributeValue).map((item) => typeof item));
|
|
38144
|
+
if (primitiveTypes2.size !== 1) {
|
|
38145
|
+
return;
|
|
38146
|
+
}
|
|
38147
|
+
const [primitiveType] = primitiveTypes2;
|
|
38148
|
+
if (primitiveType === "string") {
|
|
38149
|
+
return value.filter((item) => typeof item === "string");
|
|
38150
|
+
}
|
|
38151
|
+
if (primitiveType === "number") {
|
|
38152
|
+
return value.filter((item) => typeof item === "number");
|
|
38153
|
+
}
|
|
38154
|
+
return value.filter((item) => typeof item === "boolean");
|
|
38155
|
+
}
|
|
37485
38156
|
async function selectTelemetryAttributes({
|
|
37486
38157
|
telemetry,
|
|
37487
38158
|
attributes
|
|
@@ -37500,7 +38171,9 @@ async function selectTelemetryAttributes({
|
|
|
37500
38171
|
}
|
|
37501
38172
|
const result = await value.input();
|
|
37502
38173
|
if (result != null) {
|
|
37503
|
-
|
|
38174
|
+
const sanitized2 = sanitizeAttributeValue(result);
|
|
38175
|
+
if (sanitized2 != null)
|
|
38176
|
+
resultAttributes[key] = sanitized2;
|
|
37504
38177
|
}
|
|
37505
38178
|
continue;
|
|
37506
38179
|
}
|
|
@@ -37510,11 +38183,15 @@ async function selectTelemetryAttributes({
|
|
|
37510
38183
|
}
|
|
37511
38184
|
const result = await value.output();
|
|
37512
38185
|
if (result != null) {
|
|
37513
|
-
|
|
38186
|
+
const sanitized2 = sanitizeAttributeValue(result);
|
|
38187
|
+
if (sanitized2 != null)
|
|
38188
|
+
resultAttributes[key] = sanitized2;
|
|
37514
38189
|
}
|
|
37515
38190
|
continue;
|
|
37516
38191
|
}
|
|
37517
|
-
|
|
38192
|
+
const sanitized = sanitizeAttributeValue(value);
|
|
38193
|
+
if (sanitized != null)
|
|
38194
|
+
resultAttributes[key] = sanitized;
|
|
37518
38195
|
}
|
|
37519
38196
|
return resultAttributes;
|
|
37520
38197
|
}
|
|
@@ -37534,13 +38211,13 @@ function registerTelemetryIntegration(integration) {
|
|
|
37534
38211
|
globalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(integration);
|
|
37535
38212
|
}
|
|
37536
38213
|
function getGlobalTelemetryIntegrations() {
|
|
37537
|
-
var
|
|
37538
|
-
return (
|
|
38214
|
+
var _a222;
|
|
38215
|
+
return (_a222 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a222 : [];
|
|
37539
38216
|
}
|
|
37540
38217
|
function bindTelemetryIntegration(integration) {
|
|
37541
|
-
var
|
|
38218
|
+
var _a222, _b16, _c, _d, _e, _f;
|
|
37542
38219
|
return {
|
|
37543
|
-
onStart: (
|
|
38220
|
+
onStart: (_a222 = integration.onStart) == null ? undefined : _a222.bind(integration),
|
|
37544
38221
|
onStepStart: (_b16 = integration.onStepStart) == null ? undefined : _b16.bind(integration),
|
|
37545
38222
|
onToolCallStart: (_c = integration.onToolCallStart) == null ? undefined : _c.bind(integration),
|
|
37546
38223
|
onToolCallFinish: (_d = integration.onToolCallFinish) == null ? undefined : _d.bind(integration),
|
|
@@ -37610,11 +38287,11 @@ function createNullLanguageModelUsage() {
|
|
|
37610
38287
|
};
|
|
37611
38288
|
}
|
|
37612
38289
|
function addLanguageModelUsage(usage1, usage2) {
|
|
37613
|
-
var
|
|
38290
|
+
var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
37614
38291
|
return {
|
|
37615
38292
|
inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
|
|
37616
38293
|
inputTokenDetails: {
|
|
37617
|
-
noCacheTokens: addTokenCounts((
|
|
38294
|
+
noCacheTokens: addTokenCounts((_a222 = usage1.inputTokenDetails) == null ? undefined : _a222.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
|
|
37618
38295
|
cacheReadTokens: addTokenCounts((_c = usage1.inputTokenDetails) == null ? undefined : _c.cacheReadTokens, (_d = usage2.inputTokenDetails) == null ? undefined : _d.cacheReadTokens),
|
|
37619
38296
|
cacheWriteTokens: addTokenCounts((_e = usage1.inputTokenDetails) == null ? undefined : _e.cacheWriteTokens, (_f = usage2.inputTokenDetails) == null ? undefined : _f.cacheWriteTokens)
|
|
37620
38297
|
},
|
|
@@ -37698,53 +38375,6 @@ function getRetryDelayInMs({
|
|
|
37698
38375
|
}
|
|
37699
38376
|
return exponentialBackoffDelay;
|
|
37700
38377
|
}
|
|
37701
|
-
async function _retryWithExponentialBackoff(f, {
|
|
37702
|
-
maxRetries,
|
|
37703
|
-
delayInMs,
|
|
37704
|
-
backoffFactor,
|
|
37705
|
-
abortSignal
|
|
37706
|
-
}, errors4 = []) {
|
|
37707
|
-
try {
|
|
37708
|
-
return await f();
|
|
37709
|
-
} catch (error40) {
|
|
37710
|
-
if (isAbortError(error40)) {
|
|
37711
|
-
throw error40;
|
|
37712
|
-
}
|
|
37713
|
-
if (maxRetries === 0) {
|
|
37714
|
-
throw error40;
|
|
37715
|
-
}
|
|
37716
|
-
const errorMessage = getErrorMessage2(error40);
|
|
37717
|
-
const newErrors = [...errors4, error40];
|
|
37718
|
-
const tryNumber = newErrors.length;
|
|
37719
|
-
if (tryNumber > maxRetries) {
|
|
37720
|
-
throw new RetryError({
|
|
37721
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
37722
|
-
reason: "maxRetriesExceeded",
|
|
37723
|
-
errors: newErrors
|
|
37724
|
-
});
|
|
37725
|
-
}
|
|
37726
|
-
if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
|
|
37727
|
-
await delay(getRetryDelayInMs({
|
|
37728
|
-
error: error40,
|
|
37729
|
-
exponentialBackoffDelay: delayInMs
|
|
37730
|
-
}), { abortSignal });
|
|
37731
|
-
return _retryWithExponentialBackoff(f, {
|
|
37732
|
-
maxRetries,
|
|
37733
|
-
delayInMs: backoffFactor * delayInMs,
|
|
37734
|
-
backoffFactor,
|
|
37735
|
-
abortSignal
|
|
37736
|
-
}, newErrors);
|
|
37737
|
-
}
|
|
37738
|
-
if (tryNumber === 1) {
|
|
37739
|
-
throw error40;
|
|
37740
|
-
}
|
|
37741
|
-
throw new RetryError({
|
|
37742
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
37743
|
-
reason: "errorNotRetryable",
|
|
37744
|
-
errors: newErrors
|
|
37745
|
-
});
|
|
37746
|
-
}
|
|
37747
|
-
}
|
|
37748
38378
|
function prepareRetries({
|
|
37749
38379
|
maxRetries,
|
|
37750
38380
|
abortSignal
|
|
@@ -37846,8 +38476,8 @@ function collectToolApprovals({
|
|
|
37846
38476
|
return { approvedToolApprovals, deniedToolApprovals };
|
|
37847
38477
|
}
|
|
37848
38478
|
function now2() {
|
|
37849
|
-
var
|
|
37850
|
-
return (_b16 = (
|
|
38479
|
+
var _a222, _b16;
|
|
38480
|
+
return (_b16 = (_a222 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a222.now()) != null ? _b16 : Date.now();
|
|
37851
38481
|
}
|
|
37852
38482
|
async function executeToolCall({
|
|
37853
38483
|
toolCall,
|
|
@@ -38008,10 +38638,158 @@ async function isApprovalNeeded({
|
|
|
38008
38638
|
experimental_context
|
|
38009
38639
|
});
|
|
38010
38640
|
}
|
|
38641
|
+
function canonicalJSON(value) {
|
|
38642
|
+
if (value === null || value === undefined) {
|
|
38643
|
+
return JSON.stringify(value);
|
|
38644
|
+
}
|
|
38645
|
+
if (typeof value !== "object") {
|
|
38646
|
+
return JSON.stringify(value);
|
|
38647
|
+
}
|
|
38648
|
+
if (Array.isArray(value)) {
|
|
38649
|
+
return `[${value.map(canonicalJSON).join(",")}]`;
|
|
38650
|
+
}
|
|
38651
|
+
const keys = Object.keys(value).sort();
|
|
38652
|
+
const entries = keys.map((k) => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`);
|
|
38653
|
+
return `{${entries.join(",")}}`;
|
|
38654
|
+
}
|
|
38655
|
+
function toBase64url(bytes) {
|
|
38656
|
+
return convertUint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
38657
|
+
}
|
|
38658
|
+
function fromBase64url(str) {
|
|
38659
|
+
return convertBase64ToUint8Array(str);
|
|
38660
|
+
}
|
|
38661
|
+
async function importKey(secret) {
|
|
38662
|
+
const keyData = typeof secret === "string" ? encoder.encode(secret) : secret;
|
|
38663
|
+
return crypto.subtle.importKey("raw", keyData, { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]);
|
|
38664
|
+
}
|
|
38665
|
+
async function hashInput(input) {
|
|
38666
|
+
const canonical = canonicalJSON(input);
|
|
38667
|
+
const digest = await crypto.subtle.digest("SHA-256", encoder.encode(canonical));
|
|
38668
|
+
return toBase64url(new Uint8Array(digest));
|
|
38669
|
+
}
|
|
38670
|
+
function buildPayload(approvalId, toolCallId, toolName, inputDigest) {
|
|
38671
|
+
return encoder.encode(`${approvalId}
|
|
38672
|
+
${toolCallId}
|
|
38673
|
+
${toolName}
|
|
38674
|
+
${inputDigest}`);
|
|
38675
|
+
}
|
|
38676
|
+
async function signToolApproval({
|
|
38677
|
+
secret,
|
|
38678
|
+
approvalId,
|
|
38679
|
+
toolCallId,
|
|
38680
|
+
toolName,
|
|
38681
|
+
input
|
|
38682
|
+
}) {
|
|
38683
|
+
const key = await importKey(secret);
|
|
38684
|
+
const inputDigest = await hashInput(input);
|
|
38685
|
+
const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
|
|
38686
|
+
const sig = await crypto.subtle.sign("HMAC", key, payload);
|
|
38687
|
+
return toBase64url(new Uint8Array(sig));
|
|
38688
|
+
}
|
|
38689
|
+
async function verifyToolApprovalSignature({
|
|
38690
|
+
secret,
|
|
38691
|
+
signature,
|
|
38692
|
+
approvalId,
|
|
38693
|
+
toolCallId,
|
|
38694
|
+
toolName,
|
|
38695
|
+
input
|
|
38696
|
+
}) {
|
|
38697
|
+
const key = await importKey(secret);
|
|
38698
|
+
const inputDigest = await hashInput(input);
|
|
38699
|
+
const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
|
|
38700
|
+
const sigBytes = fromBase64url(signature);
|
|
38701
|
+
return crypto.subtle.verify("HMAC", key, sigBytes, payload);
|
|
38702
|
+
}
|
|
38703
|
+
async function maybeSignApproval({
|
|
38704
|
+
secret,
|
|
38705
|
+
approvalId,
|
|
38706
|
+
toolCallId,
|
|
38707
|
+
toolName,
|
|
38708
|
+
input
|
|
38709
|
+
}) {
|
|
38710
|
+
if (secret == null)
|
|
38711
|
+
return;
|
|
38712
|
+
return signToolApproval({ secret, approvalId, toolCallId, toolName, input });
|
|
38713
|
+
}
|
|
38714
|
+
async function validateApprovedToolApprovals({
|
|
38715
|
+
approvedToolApprovals,
|
|
38716
|
+
tools,
|
|
38717
|
+
messages,
|
|
38718
|
+
experimental_context,
|
|
38719
|
+
toolApprovalSecret
|
|
38720
|
+
}) {
|
|
38721
|
+
var _a222;
|
|
38722
|
+
const approved = [];
|
|
38723
|
+
const denied = [];
|
|
38724
|
+
for (const approval of approvedToolApprovals) {
|
|
38725
|
+
const { toolCall, approvalRequest } = approval;
|
|
38726
|
+
const tool2 = tools == null ? undefined : tools[toolCall.toolName];
|
|
38727
|
+
if (toolApprovalSecret != null) {
|
|
38728
|
+
if (approvalRequest.signature == null) {
|
|
38729
|
+
throw new InvalidToolApprovalSignatureError({
|
|
38730
|
+
approvalId: approvalRequest.approvalId,
|
|
38731
|
+
toolCallId: toolCall.toolCallId,
|
|
38732
|
+
reason: "missing signature"
|
|
38733
|
+
});
|
|
38734
|
+
}
|
|
38735
|
+
const valid = await verifyToolApprovalSignature({
|
|
38736
|
+
secret: toolApprovalSecret,
|
|
38737
|
+
signature: approvalRequest.signature,
|
|
38738
|
+
approvalId: approvalRequest.approvalId,
|
|
38739
|
+
toolCallId: toolCall.toolCallId,
|
|
38740
|
+
toolName: toolCall.toolName,
|
|
38741
|
+
input: toolCall.input
|
|
38742
|
+
});
|
|
38743
|
+
if (!valid) {
|
|
38744
|
+
throw new InvalidToolApprovalSignatureError({
|
|
38745
|
+
approvalId: approvalRequest.approvalId,
|
|
38746
|
+
toolCallId: toolCall.toolCallId,
|
|
38747
|
+
reason: "invalid signature"
|
|
38748
|
+
});
|
|
38749
|
+
}
|
|
38750
|
+
}
|
|
38751
|
+
if (tool2 != null && typeof tool2.execute === "function" && tool2.inputSchema != null) {
|
|
38752
|
+
const validation = await safeValidateTypes({
|
|
38753
|
+
value: toolCall.input,
|
|
38754
|
+
schema: asSchema(tool2.inputSchema)
|
|
38755
|
+
});
|
|
38756
|
+
if (!validation.success) {
|
|
38757
|
+
throw new InvalidToolInputError({
|
|
38758
|
+
toolName: toolCall.toolName,
|
|
38759
|
+
toolInput: JSON.stringify(toolCall.input),
|
|
38760
|
+
cause: validation.error
|
|
38761
|
+
});
|
|
38762
|
+
}
|
|
38763
|
+
}
|
|
38764
|
+
const approvalNeeded = tool2 != null && await isApprovalNeeded({
|
|
38765
|
+
tool: tool2,
|
|
38766
|
+
toolCall,
|
|
38767
|
+
messages,
|
|
38768
|
+
experimental_context
|
|
38769
|
+
});
|
|
38770
|
+
if (approvalNeeded) {
|
|
38771
|
+
approved.push(approval);
|
|
38772
|
+
} else {
|
|
38773
|
+
denied.push({
|
|
38774
|
+
...approval,
|
|
38775
|
+
approvalResponse: {
|
|
38776
|
+
...approval.approvalResponse,
|
|
38777
|
+
approved: false,
|
|
38778
|
+
reason: (_a222 = approval.approvalResponse.reason) != null ? _a222 : `Tool "${toolCall.toolName}" does not require approval`
|
|
38779
|
+
}
|
|
38780
|
+
});
|
|
38781
|
+
}
|
|
38782
|
+
}
|
|
38783
|
+
return { approvedToolApprovals: approved, deniedToolApprovals: denied };
|
|
38784
|
+
}
|
|
38011
38785
|
function fixJson(input) {
|
|
38012
38786
|
const stack = ["ROOT"];
|
|
38013
38787
|
let lastValidIndex = -1;
|
|
38014
38788
|
let literalStart = null;
|
|
38789
|
+
let unicodeEscapeDigits = 0;
|
|
38790
|
+
function isHexDigit(char) {
|
|
38791
|
+
return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
|
|
38792
|
+
}
|
|
38015
38793
|
function processValueStart(char, i, swapState) {
|
|
38016
38794
|
{
|
|
38017
38795
|
switch (char) {
|
|
@@ -38216,7 +38994,22 @@ function fixJson(input) {
|
|
|
38216
38994
|
}
|
|
38217
38995
|
case "INSIDE_STRING_ESCAPE": {
|
|
38218
38996
|
stack.pop();
|
|
38219
|
-
|
|
38997
|
+
if (char === "u") {
|
|
38998
|
+
unicodeEscapeDigits = 0;
|
|
38999
|
+
stack.push("INSIDE_STRING_UNICODE_ESCAPE");
|
|
39000
|
+
} else {
|
|
39001
|
+
lastValidIndex = i;
|
|
39002
|
+
}
|
|
39003
|
+
break;
|
|
39004
|
+
}
|
|
39005
|
+
case "INSIDE_STRING_UNICODE_ESCAPE": {
|
|
39006
|
+
if (isHexDigit(char)) {
|
|
39007
|
+
unicodeEscapeDigits++;
|
|
39008
|
+
if (unicodeEscapeDigits === 4) {
|
|
39009
|
+
stack.pop();
|
|
39010
|
+
lastValidIndex = i;
|
|
39011
|
+
}
|
|
39012
|
+
}
|
|
38220
39013
|
break;
|
|
38221
39014
|
}
|
|
38222
39015
|
case "INSIDE_NUMBER": {
|
|
@@ -38473,8 +39266,8 @@ function isLoopFinished() {
|
|
|
38473
39266
|
}
|
|
38474
39267
|
function hasToolCall(toolName) {
|
|
38475
39268
|
return ({ steps }) => {
|
|
38476
|
-
var
|
|
38477
|
-
return (_c = (_b16 = (
|
|
39269
|
+
var _a222, _b16, _c;
|
|
39270
|
+
return (_c = (_b16 = (_a222 = steps[steps.length - 1]) == null ? undefined : _a222.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
|
|
38478
39271
|
};
|
|
38479
39272
|
}
|
|
38480
39273
|
async function isStopConditionMet({
|
|
@@ -38570,7 +39363,8 @@ async function toResponseMessages({
|
|
|
38570
39363
|
content.push({
|
|
38571
39364
|
type: "tool-approval-request",
|
|
38572
39365
|
approvalId: part.approvalId,
|
|
38573
|
-
toolCallId: part.toolCall.toolCallId
|
|
39366
|
+
toolCallId: part.toolCall.toolCallId,
|
|
39367
|
+
...part.signature != null ? { signature: part.signature } : {}
|
|
38574
39368
|
});
|
|
38575
39369
|
break;
|
|
38576
39370
|
}
|
|
@@ -38653,6 +39447,7 @@ async function generateText({
|
|
|
38653
39447
|
experimental_repairToolCall: repairToolCall,
|
|
38654
39448
|
experimental_download: download2,
|
|
38655
39449
|
experimental_context,
|
|
39450
|
+
experimental_toolApprovalSecret,
|
|
38656
39451
|
experimental_include: include,
|
|
38657
39452
|
_internal: { generateId: generateId2 = originalGenerateId } = {},
|
|
38658
39453
|
experimental_onStart: onStart,
|
|
@@ -38745,11 +39540,27 @@ async function generateText({
|
|
|
38745
39540
|
}),
|
|
38746
39541
|
tracer,
|
|
38747
39542
|
fn: async (span) => {
|
|
38748
|
-
var
|
|
39543
|
+
var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
38749
39544
|
const initialMessages = initialPrompt.messages;
|
|
38750
39545
|
const responseMessages = [];
|
|
38751
|
-
const {
|
|
38752
|
-
|
|
39546
|
+
const {
|
|
39547
|
+
approvedToolApprovals,
|
|
39548
|
+
deniedToolApprovals: collectedDeniedToolApprovals
|
|
39549
|
+
} = collectToolApprovals({ messages: initialMessages });
|
|
39550
|
+
const {
|
|
39551
|
+
approvedToolApprovals: localApprovedToolApprovals,
|
|
39552
|
+
deniedToolApprovals: revalidationDeniedToolApprovals
|
|
39553
|
+
} = await validateApprovedToolApprovals({
|
|
39554
|
+
approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
|
|
39555
|
+
tools,
|
|
39556
|
+
messages: initialMessages,
|
|
39557
|
+
experimental_context,
|
|
39558
|
+
toolApprovalSecret: experimental_toolApprovalSecret
|
|
39559
|
+
});
|
|
39560
|
+
const deniedToolApprovals = [
|
|
39561
|
+
...collectedDeniedToolApprovals,
|
|
39562
|
+
...revalidationDeniedToolApprovals
|
|
39563
|
+
];
|
|
38753
39564
|
if (deniedToolApprovals.length > 0 || localApprovedToolApprovals.length > 0) {
|
|
38754
39565
|
const toolOutputs = await executeTools({
|
|
38755
39566
|
toolCalls: localApprovedToolApprovals.map((toolApproval) => toolApproval.toolCall),
|
|
@@ -38826,7 +39637,7 @@ async function generateText({
|
|
|
38826
39637
|
messages: stepInputMessages,
|
|
38827
39638
|
experimental_context
|
|
38828
39639
|
}));
|
|
38829
|
-
const stepModel = resolveLanguageModel((
|
|
39640
|
+
const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
|
|
38830
39641
|
const stepModelInfo = {
|
|
38831
39642
|
provider: stepModel.provider,
|
|
38832
39643
|
modelId: stepModel.modelId
|
|
@@ -38876,7 +39687,7 @@ async function generateText({
|
|
|
38876
39687
|
]
|
|
38877
39688
|
});
|
|
38878
39689
|
currentModelResponse = await retry(() => {
|
|
38879
|
-
var
|
|
39690
|
+
var _a232;
|
|
38880
39691
|
return recordSpan({
|
|
38881
39692
|
name: "ai.generateText.doGenerate",
|
|
38882
39693
|
attributes: selectTelemetryAttributes({
|
|
@@ -38904,14 +39715,14 @@ async function generateText({
|
|
|
38904
39715
|
"gen_ai.request.max_tokens": settings.maxOutputTokens,
|
|
38905
39716
|
"gen_ai.request.presence_penalty": settings.presencePenalty,
|
|
38906
39717
|
"gen_ai.request.stop_sequences": settings.stopSequences,
|
|
38907
|
-
"gen_ai.request.temperature": (
|
|
39718
|
+
"gen_ai.request.temperature": (_a232 = settings.temperature) != null ? _a232 : undefined,
|
|
38908
39719
|
"gen_ai.request.top_k": settings.topK,
|
|
38909
39720
|
"gen_ai.request.top_p": settings.topP
|
|
38910
39721
|
}
|
|
38911
39722
|
}),
|
|
38912
39723
|
tracer,
|
|
38913
39724
|
fn: async (span2) => {
|
|
38914
|
-
var
|
|
39725
|
+
var _a24, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
38915
39726
|
const result = await stepModel.doGenerate({
|
|
38916
39727
|
...callSettings2,
|
|
38917
39728
|
tools: stepTools,
|
|
@@ -38923,7 +39734,7 @@ async function generateText({
|
|
|
38923
39734
|
headers: headersWithUserAgent
|
|
38924
39735
|
});
|
|
38925
39736
|
const responseData = {
|
|
38926
|
-
id: (_b23 = (
|
|
39737
|
+
id: (_b23 = (_a24 = result.response) == null ? undefined : _a24.id) != null ? _b23 : generateId2(),
|
|
38927
39738
|
timestamp: (_d2 = (_c2 = result.response) == null ? undefined : _c2.timestamp) != null ? _d2 : /* @__PURE__ */ new Date,
|
|
38928
39739
|
modelId: (_f2 = (_e2 = result.response) == null ? undefined : _e2.modelId) != null ? _f2 : stepModel.modelId,
|
|
38929
39740
|
headers: (_g2 = result.response) == null ? undefined : _g2.headers,
|
|
@@ -39004,10 +39815,19 @@ async function generateText({
|
|
|
39004
39815
|
messages: stepInputMessages,
|
|
39005
39816
|
experimental_context
|
|
39006
39817
|
})) {
|
|
39818
|
+
const approvalId = generateId2();
|
|
39819
|
+
const signature = await maybeSignApproval({
|
|
39820
|
+
secret: experimental_toolApprovalSecret,
|
|
39821
|
+
approvalId,
|
|
39822
|
+
toolCallId: toolCall.toolCallId,
|
|
39823
|
+
toolName: toolCall.toolName,
|
|
39824
|
+
input: toolCall.input
|
|
39825
|
+
});
|
|
39007
39826
|
toolApprovalRequests[toolCall.toolCallId] = {
|
|
39008
39827
|
type: "tool-approval-request",
|
|
39009
|
-
approvalId
|
|
39010
|
-
toolCall
|
|
39828
|
+
approvalId,
|
|
39829
|
+
toolCall,
|
|
39830
|
+
...signature != null ? { signature } : {}
|
|
39011
39831
|
};
|
|
39012
39832
|
}
|
|
39013
39833
|
}
|
|
@@ -39464,6 +40284,9 @@ function getResponseUIMessageId({
|
|
|
39464
40284
|
function isDataUIMessageChunk(chunk) {
|
|
39465
40285
|
return chunk.type.startsWith("data-");
|
|
39466
40286
|
}
|
|
40287
|
+
function createIdMap() {
|
|
40288
|
+
return /* @__PURE__ */ Object.create(null);
|
|
40289
|
+
}
|
|
39467
40290
|
function isDataUIPart(part) {
|
|
39468
40291
|
return part.type.startsWith("data-");
|
|
39469
40292
|
}
|
|
@@ -39502,9 +40325,9 @@ function createStreamingUIMessageState({
|
|
|
39502
40325
|
role: "assistant",
|
|
39503
40326
|
parts: []
|
|
39504
40327
|
},
|
|
39505
|
-
activeTextParts:
|
|
39506
|
-
activeReasoningParts:
|
|
39507
|
-
partialToolCalls:
|
|
40328
|
+
activeTextParts: createIdMap(),
|
|
40329
|
+
activeReasoningParts: createIdMap(),
|
|
40330
|
+
partialToolCalls: createIdMap()
|
|
39508
40331
|
};
|
|
39509
40332
|
}
|
|
39510
40333
|
function processUIMessageStream({
|
|
@@ -39519,7 +40342,7 @@ function processUIMessageStream({
|
|
|
39519
40342
|
return stream.pipeThrough(new TransformStream({
|
|
39520
40343
|
async transform(chunk, controller) {
|
|
39521
40344
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
39522
|
-
var
|
|
40345
|
+
var _a222, _b16, _c, _d;
|
|
39523
40346
|
function getToolInvocation(toolCallId) {
|
|
39524
40347
|
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
|
39525
40348
|
const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
|
|
@@ -39533,7 +40356,7 @@ function processUIMessageStream({
|
|
|
39533
40356
|
return toolInvocation;
|
|
39534
40357
|
}
|
|
39535
40358
|
function updateToolPart(options) {
|
|
39536
|
-
var
|
|
40359
|
+
var _a232;
|
|
39537
40360
|
const part = state.message.parts.find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);
|
|
39538
40361
|
const anyOptions = options;
|
|
39539
40362
|
const anyPart = part;
|
|
@@ -39550,7 +40373,7 @@ function processUIMessageStream({
|
|
|
39550
40373
|
if (options.toolMetadata !== undefined) {
|
|
39551
40374
|
anyPart.toolMetadata = options.toolMetadata;
|
|
39552
40375
|
}
|
|
39553
|
-
anyPart.providerExecuted = (
|
|
40376
|
+
anyPart.providerExecuted = (_a232 = anyOptions.providerExecuted) != null ? _a232 : part.providerExecuted;
|
|
39554
40377
|
const providerMetadata = anyOptions.providerMetadata;
|
|
39555
40378
|
if (providerMetadata != null) {
|
|
39556
40379
|
if (options.state === "output-available" || options.state === "output-error") {
|
|
@@ -39579,7 +40402,7 @@ function processUIMessageStream({
|
|
|
39579
40402
|
}
|
|
39580
40403
|
}
|
|
39581
40404
|
function updateDynamicToolPart(options) {
|
|
39582
|
-
var
|
|
40405
|
+
var _a232, _b23;
|
|
39583
40406
|
const part = state.message.parts.find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
39584
40407
|
const anyOptions = options;
|
|
39585
40408
|
const anyPart = part;
|
|
@@ -39589,7 +40412,7 @@ function processUIMessageStream({
|
|
|
39589
40412
|
anyPart.input = anyOptions.input;
|
|
39590
40413
|
anyPart.output = anyOptions.output;
|
|
39591
40414
|
anyPart.errorText = anyOptions.errorText;
|
|
39592
|
-
anyPart.rawInput = (
|
|
40415
|
+
anyPart.rawInput = (_a232 = anyOptions.rawInput) != null ? _a232 : anyPart.rawInput;
|
|
39593
40416
|
anyPart.preliminary = anyOptions.preliminary;
|
|
39594
40417
|
if (options.title !== undefined) {
|
|
39595
40418
|
anyPart.title = options.title;
|
|
@@ -39664,7 +40487,7 @@ function processUIMessageStream({
|
|
|
39664
40487
|
});
|
|
39665
40488
|
}
|
|
39666
40489
|
textPart.text += chunk.delta;
|
|
39667
|
-
textPart.providerMetadata = (
|
|
40490
|
+
textPart.providerMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textPart.providerMetadata;
|
|
39668
40491
|
write();
|
|
39669
40492
|
break;
|
|
39670
40493
|
}
|
|
@@ -39891,7 +40714,10 @@ function processUIMessageStream({
|
|
|
39891
40714
|
case "tool-approval-request": {
|
|
39892
40715
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
39893
40716
|
toolInvocation.state = "approval-requested";
|
|
39894
|
-
toolInvocation.approval = {
|
|
40717
|
+
toolInvocation.approval = {
|
|
40718
|
+
id: chunk.approvalId,
|
|
40719
|
+
...chunk.signature != null ? { signature: chunk.signature } : {}
|
|
40720
|
+
};
|
|
39895
40721
|
write();
|
|
39896
40722
|
break;
|
|
39897
40723
|
}
|
|
@@ -39969,8 +40795,8 @@ function processUIMessageStream({
|
|
|
39969
40795
|
break;
|
|
39970
40796
|
}
|
|
39971
40797
|
case "finish-step": {
|
|
39972
|
-
state.activeTextParts =
|
|
39973
|
-
state.activeReasoningParts =
|
|
40798
|
+
state.activeTextParts = createIdMap();
|
|
40799
|
+
state.activeReasoningParts = createIdMap();
|
|
39974
40800
|
break;
|
|
39975
40801
|
}
|
|
39976
40802
|
case "start": {
|
|
@@ -40162,13 +40988,13 @@ function createAsyncIterableStream(source) {
|
|
|
40162
40988
|
const reader = this.getReader();
|
|
40163
40989
|
let finished = false;
|
|
40164
40990
|
async function cleanup(cancelStream) {
|
|
40165
|
-
var
|
|
40991
|
+
var _a222;
|
|
40166
40992
|
if (finished)
|
|
40167
40993
|
return;
|
|
40168
40994
|
finished = true;
|
|
40169
40995
|
try {
|
|
40170
40996
|
if (cancelStream) {
|
|
40171
|
-
await ((
|
|
40997
|
+
await ((_a222 = reader.cancel) == null ? undefined : _a222.call(reader));
|
|
40172
40998
|
}
|
|
40173
40999
|
} finally {
|
|
40174
41000
|
try {
|
|
@@ -40311,6 +41137,7 @@ function runToolsTransformation({
|
|
|
40311
41137
|
abortSignal,
|
|
40312
41138
|
repairToolCall,
|
|
40313
41139
|
experimental_context,
|
|
41140
|
+
toolApprovalSecret,
|
|
40314
41141
|
generateId: generateId2,
|
|
40315
41142
|
stepNumber,
|
|
40316
41143
|
model,
|
|
@@ -40440,10 +41267,19 @@ function runToolsTransformation({
|
|
|
40440
41267
|
messages,
|
|
40441
41268
|
experimental_context
|
|
40442
41269
|
})) {
|
|
41270
|
+
const approvalId = generateId2();
|
|
41271
|
+
const signature = await maybeSignApproval({
|
|
41272
|
+
secret: toolApprovalSecret,
|
|
41273
|
+
approvalId,
|
|
41274
|
+
toolCallId: toolCall.toolCallId,
|
|
41275
|
+
toolName: toolCall.toolName,
|
|
41276
|
+
input: toolCall.input
|
|
41277
|
+
});
|
|
40443
41278
|
toolResultsStreamController.enqueue({
|
|
40444
41279
|
type: "tool-approval-request",
|
|
40445
|
-
approvalId
|
|
40446
|
-
toolCall
|
|
41280
|
+
approvalId,
|
|
41281
|
+
toolCall,
|
|
41282
|
+
...signature != null ? { signature } : {}
|
|
40447
41283
|
});
|
|
40448
41284
|
break;
|
|
40449
41285
|
}
|
|
@@ -40581,6 +41417,7 @@ function streamText({
|
|
|
40581
41417
|
experimental_onToolCallStart: onToolCallStart,
|
|
40582
41418
|
experimental_onToolCallFinish: onToolCallFinish,
|
|
40583
41419
|
experimental_context,
|
|
41420
|
+
experimental_toolApprovalSecret,
|
|
40584
41421
|
experimental_include: include,
|
|
40585
41422
|
_internal: { now: now22 = now2, generateId: generateId2 = originalGenerateId2 } = {},
|
|
40586
41423
|
...settings
|
|
@@ -40630,6 +41467,7 @@ function streamText({
|
|
|
40630
41467
|
now: now22,
|
|
40631
41468
|
generateId: generateId2,
|
|
40632
41469
|
experimental_context,
|
|
41470
|
+
experimental_toolApprovalSecret,
|
|
40633
41471
|
download: download2,
|
|
40634
41472
|
include
|
|
40635
41473
|
});
|
|
@@ -40657,7 +41495,7 @@ function createOutputTransformStream(output) {
|
|
|
40657
41495
|
}
|
|
40658
41496
|
return new TransformStream({
|
|
40659
41497
|
async transform(chunk, controller) {
|
|
40660
|
-
var
|
|
41498
|
+
var _a222;
|
|
40661
41499
|
if (chunk.type === "finish-step" && textChunk.length > 0) {
|
|
40662
41500
|
publishTextChunk({ controller });
|
|
40663
41501
|
}
|
|
@@ -40684,7 +41522,7 @@ function createOutputTransformStream(output) {
|
|
|
40684
41522
|
}
|
|
40685
41523
|
text2 += chunk.text;
|
|
40686
41524
|
textChunk += chunk.text;
|
|
40687
|
-
textProviderMetadata = (
|
|
41525
|
+
textProviderMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textProviderMetadata;
|
|
40688
41526
|
const result = await output.parsePartialOutput({ text: text2 });
|
|
40689
41527
|
if (result !== undefined) {
|
|
40690
41528
|
const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
|
|
@@ -40698,7 +41536,7 @@ function createOutputTransformStream(output) {
|
|
|
40698
41536
|
}
|
|
40699
41537
|
function createUIMessageStream({
|
|
40700
41538
|
execute,
|
|
40701
|
-
onError =
|
|
41539
|
+
onError = () => "An error occurred.",
|
|
40702
41540
|
originalMessages,
|
|
40703
41541
|
onStepFinish,
|
|
40704
41542
|
onFinish,
|
|
@@ -40781,7 +41619,7 @@ function readUIMessageStream({
|
|
|
40781
41619
|
onError,
|
|
40782
41620
|
terminateOnError = false
|
|
40783
41621
|
}) {
|
|
40784
|
-
var
|
|
41622
|
+
var _a222;
|
|
40785
41623
|
let controller;
|
|
40786
41624
|
let hasErrored = false;
|
|
40787
41625
|
const outputStream = new ReadableStream({
|
|
@@ -40790,7 +41628,7 @@ function readUIMessageStream({
|
|
|
40790
41628
|
}
|
|
40791
41629
|
});
|
|
40792
41630
|
const state = createStreamingUIMessageState({
|
|
40793
|
-
messageId: (
|
|
41631
|
+
messageId: (_a222 = message == null ? undefined : message.id) != null ? _a222 : "",
|
|
40794
41632
|
lastMessage: message
|
|
40795
41633
|
});
|
|
40796
41634
|
const handleError = (error40) => {
|
|
@@ -40850,7 +41688,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
40850
41688
|
modelMessages.push({
|
|
40851
41689
|
role: "user",
|
|
40852
41690
|
content: message.parts.map((part) => {
|
|
40853
|
-
var
|
|
41691
|
+
var _a222;
|
|
40854
41692
|
if (isTextUIPart(part)) {
|
|
40855
41693
|
return {
|
|
40856
41694
|
type: "text",
|
|
@@ -40868,7 +41706,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
40868
41706
|
};
|
|
40869
41707
|
}
|
|
40870
41708
|
if (isDataUIPart(part)) {
|
|
40871
|
-
return (
|
|
41709
|
+
return (_a222 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a222.call(options, part);
|
|
40872
41710
|
}
|
|
40873
41711
|
}).filter(isNonNullable)
|
|
40874
41712
|
});
|
|
@@ -40878,7 +41716,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
40878
41716
|
if (message.parts != null) {
|
|
40879
41717
|
let block = [];
|
|
40880
41718
|
async function processBlock() {
|
|
40881
|
-
var
|
|
41719
|
+
var _a222, _b16, _c, _d, _e, _f, _g, _h;
|
|
40882
41720
|
if (block.length === 0) {
|
|
40883
41721
|
return;
|
|
40884
41722
|
}
|
|
@@ -40911,7 +41749,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
40911
41749
|
type: "tool-call",
|
|
40912
41750
|
toolCallId: part.toolCallId,
|
|
40913
41751
|
toolName,
|
|
40914
|
-
input: part.state === "output-error" ? (
|
|
41752
|
+
input: part.state === "output-error" ? (_a222 = part.input) != null ? _a222 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
|
|
40915
41753
|
providerExecuted: part.providerExecuted,
|
|
40916
41754
|
...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
|
|
40917
41755
|
});
|
|
@@ -40919,7 +41757,8 @@ async function convertToModelMessages(messages, options) {
|
|
|
40919
41757
|
content.push({
|
|
40920
41758
|
type: "tool-approval-request",
|
|
40921
41759
|
approvalId: part.approval.id,
|
|
40922
|
-
toolCallId: part.toolCallId
|
|
41760
|
+
toolCallId: part.toolCallId,
|
|
41761
|
+
...part.approval.signature != null ? { signature: part.approval.signature } : {}
|
|
40923
41762
|
});
|
|
40924
41763
|
}
|
|
40925
41764
|
if (part.providerExecuted === true && part.state !== "approval-responded" && (part.state === "output-available" || part.state === "output-error")) {
|
|
@@ -40954,8 +41793,8 @@ async function convertToModelMessages(messages, options) {
|
|
|
40954
41793
|
content
|
|
40955
41794
|
});
|
|
40956
41795
|
const toolParts = block.filter((part) => {
|
|
40957
|
-
var
|
|
40958
|
-
return isToolUIPart(part) && (part.providerExecuted !== true || ((
|
|
41796
|
+
var _a232;
|
|
41797
|
+
return isToolUIPart(part) && (part.providerExecuted !== true || ((_a232 = part.approval) == null ? undefined : _a232.approved) != null);
|
|
40959
41798
|
});
|
|
40960
41799
|
if (toolParts.length > 0) {
|
|
40961
41800
|
{
|
|
@@ -41189,7 +42028,7 @@ async function createAgentUIStream({
|
|
|
41189
42028
|
onStepFinish,
|
|
41190
42029
|
...uiMessageStreamOptions
|
|
41191
42030
|
}) {
|
|
41192
|
-
var
|
|
42031
|
+
var _a222;
|
|
41193
42032
|
const validatedMessages = await validateUIMessages({
|
|
41194
42033
|
messages: uiMessages,
|
|
41195
42034
|
tools: agent.tools
|
|
@@ -41207,7 +42046,7 @@ async function createAgentUIStream({
|
|
|
41207
42046
|
});
|
|
41208
42047
|
return result.toUIMessageStream({
|
|
41209
42048
|
...uiMessageStreamOptions,
|
|
41210
|
-
originalMessages: (
|
|
42049
|
+
originalMessages: (_a222 = uiMessageStreamOptions.originalMessages) != null ? _a222 : validatedMessages
|
|
41211
42050
|
});
|
|
41212
42051
|
}
|
|
41213
42052
|
async function createAgentUIStreamResponse({
|
|
@@ -41291,7 +42130,7 @@ async function embed({
|
|
|
41291
42130
|
}),
|
|
41292
42131
|
tracer,
|
|
41293
42132
|
fn: async (doEmbedSpan) => {
|
|
41294
|
-
var
|
|
42133
|
+
var _a222, _b16;
|
|
41295
42134
|
const modelResponse = await model.doEmbed({
|
|
41296
42135
|
values: [value],
|
|
41297
42136
|
abortSignal,
|
|
@@ -41299,7 +42138,7 @@ async function embed({
|
|
|
41299
42138
|
providerOptions
|
|
41300
42139
|
});
|
|
41301
42140
|
const embedding2 = modelResponse.embeddings[0];
|
|
41302
|
-
const usage2 = (
|
|
42141
|
+
const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
|
|
41303
42142
|
doEmbedSpan.setAttributes(await selectTelemetryAttributes({
|
|
41304
42143
|
telemetry,
|
|
41305
42144
|
attributes: {
|
|
@@ -41384,7 +42223,7 @@ async function embedMany({
|
|
|
41384
42223
|
}),
|
|
41385
42224
|
tracer,
|
|
41386
42225
|
fn: async (span) => {
|
|
41387
|
-
var
|
|
42226
|
+
var _a222;
|
|
41388
42227
|
const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
|
|
41389
42228
|
model.maxEmbeddingsPerCall,
|
|
41390
42229
|
model.supportsParallelCalls
|
|
@@ -41408,7 +42247,7 @@ async function embedMany({
|
|
|
41408
42247
|
}),
|
|
41409
42248
|
tracer,
|
|
41410
42249
|
fn: async (doEmbedSpan) => {
|
|
41411
|
-
var
|
|
42250
|
+
var _a232, _b16;
|
|
41412
42251
|
const modelResponse = await model.doEmbed({
|
|
41413
42252
|
values,
|
|
41414
42253
|
abortSignal,
|
|
@@ -41416,7 +42255,7 @@ async function embedMany({
|
|
|
41416
42255
|
providerOptions
|
|
41417
42256
|
});
|
|
41418
42257
|
const embeddings3 = modelResponse.embeddings;
|
|
41419
|
-
const usage2 = (
|
|
42258
|
+
const usage2 = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
|
|
41420
42259
|
doEmbedSpan.setAttributes(await selectTelemetryAttributes({
|
|
41421
42260
|
telemetry,
|
|
41422
42261
|
attributes: {
|
|
@@ -41486,7 +42325,7 @@ async function embedMany({
|
|
|
41486
42325
|
}),
|
|
41487
42326
|
tracer,
|
|
41488
42327
|
fn: async (doEmbedSpan) => {
|
|
41489
|
-
var
|
|
42328
|
+
var _a232, _b16;
|
|
41490
42329
|
const modelResponse = await model.doEmbed({
|
|
41491
42330
|
values: chunk,
|
|
41492
42331
|
abortSignal,
|
|
@@ -41494,7 +42333,7 @@ async function embedMany({
|
|
|
41494
42333
|
providerOptions
|
|
41495
42334
|
});
|
|
41496
42335
|
const embeddings2 = modelResponse.embeddings;
|
|
41497
|
-
const usage = (
|
|
42336
|
+
const usage = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
|
|
41498
42337
|
doEmbedSpan.setAttributes(await selectTelemetryAttributes({
|
|
41499
42338
|
telemetry,
|
|
41500
42339
|
attributes: {
|
|
@@ -41526,7 +42365,7 @@ async function embedMany({
|
|
|
41526
42365
|
} else {
|
|
41527
42366
|
for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
|
|
41528
42367
|
providerMetadata[providerName] = {
|
|
41529
|
-
...(
|
|
42368
|
+
...(_a222 = providerMetadata[providerName]) != null ? _a222 : {},
|
|
41530
42369
|
...metadata
|
|
41531
42370
|
};
|
|
41532
42371
|
}
|
|
@@ -41572,14 +42411,14 @@ async function generateImage({
|
|
|
41572
42411
|
abortSignal,
|
|
41573
42412
|
headers
|
|
41574
42413
|
}) {
|
|
41575
|
-
var
|
|
42414
|
+
var _a222, _b16;
|
|
41576
42415
|
const model = resolveImageModel(modelArg);
|
|
41577
42416
|
const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
|
|
41578
42417
|
const { retry } = prepareRetries({
|
|
41579
42418
|
maxRetries: maxRetriesArg,
|
|
41580
42419
|
abortSignal
|
|
41581
42420
|
});
|
|
41582
|
-
const maxImagesPerCallWithDefault = (
|
|
42421
|
+
const maxImagesPerCallWithDefault = (_a222 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a222 : 1;
|
|
41583
42422
|
const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
|
|
41584
42423
|
const callImageCounts = Array.from({ length: callCount }, (_, i) => {
|
|
41585
42424
|
if (i < callCount - 1) {
|
|
@@ -41614,13 +42453,13 @@ async function generateImage({
|
|
|
41614
42453
|
};
|
|
41615
42454
|
for (const result of results) {
|
|
41616
42455
|
images.push(...result.images.map((image) => {
|
|
41617
|
-
var
|
|
42456
|
+
var _a232;
|
|
41618
42457
|
return new DefaultGeneratedFile({
|
|
41619
42458
|
data: image,
|
|
41620
|
-
mediaType: (
|
|
42459
|
+
mediaType: (_a232 = detectMediaType({
|
|
41621
42460
|
data: image,
|
|
41622
42461
|
signatures: imageMediaTypeSignatures
|
|
41623
|
-
})) != null ?
|
|
42462
|
+
})) != null ? _a232 : "image/png"
|
|
41624
42463
|
});
|
|
41625
42464
|
}));
|
|
41626
42465
|
warnings.push(...result.warnings);
|
|
@@ -41971,7 +42810,7 @@ async function generateObject(options) {
|
|
|
41971
42810
|
}),
|
|
41972
42811
|
tracer,
|
|
41973
42812
|
fn: async (span) => {
|
|
41974
|
-
var
|
|
42813
|
+
var _a222;
|
|
41975
42814
|
let result;
|
|
41976
42815
|
let finishReason;
|
|
41977
42816
|
let usage;
|
|
@@ -42016,7 +42855,7 @@ async function generateObject(options) {
|
|
|
42016
42855
|
}),
|
|
42017
42856
|
tracer,
|
|
42018
42857
|
fn: async (span2) => {
|
|
42019
|
-
var
|
|
42858
|
+
var _a232, _b16, _c, _d, _e, _f, _g, _h;
|
|
42020
42859
|
const result2 = await model.doGenerate({
|
|
42021
42860
|
responseFormat: {
|
|
42022
42861
|
type: "json",
|
|
@@ -42031,7 +42870,7 @@ async function generateObject(options) {
|
|
|
42031
42870
|
headers: headersWithUserAgent
|
|
42032
42871
|
});
|
|
42033
42872
|
const responseData = {
|
|
42034
|
-
id: (_b16 = (
|
|
42873
|
+
id: (_b16 = (_a232 = result2.response) == null ? undefined : _a232.id) != null ? _b16 : generateId2(),
|
|
42035
42874
|
timestamp: (_d = (_c = result2.response) == null ? undefined : _c.timestamp) != null ? _d : currentDate(),
|
|
42036
42875
|
modelId: (_f = (_e = result2.response) == null ? undefined : _e.modelId) != null ? _f : model.modelId,
|
|
42037
42876
|
headers: (_g = result2.response) == null ? undefined : _g.headers,
|
|
@@ -42080,7 +42919,7 @@ async function generateObject(options) {
|
|
|
42080
42919
|
usage = asLanguageModelUsage(generateResult.usage);
|
|
42081
42920
|
warnings = generateResult.warnings;
|
|
42082
42921
|
resultProviderMetadata = generateResult.providerMetadata;
|
|
42083
|
-
request = (
|
|
42922
|
+
request = (_a222 = generateResult.request) != null ? _a222 : {};
|
|
42084
42923
|
response = generateResult.responseData;
|
|
42085
42924
|
reasoning = generateResult.reasoning;
|
|
42086
42925
|
logWarnings({
|
|
@@ -42199,8 +43038,8 @@ function simulateReadableStream({
|
|
|
42199
43038
|
chunkDelayInMs = 0,
|
|
42200
43039
|
_internal
|
|
42201
43040
|
}) {
|
|
42202
|
-
var
|
|
42203
|
-
const delay2 = (
|
|
43041
|
+
var _a222;
|
|
43042
|
+
const delay2 = (_a222 = _internal == null ? undefined : _internal.delay) != null ? _a222 : delay;
|
|
42204
43043
|
let index = 0;
|
|
42205
43044
|
return new ReadableStream({
|
|
42206
43045
|
async pull(controller) {
|
|
@@ -42294,7 +43133,7 @@ async function generateSpeech({
|
|
|
42294
43133
|
abortSignal,
|
|
42295
43134
|
headers
|
|
42296
43135
|
}) {
|
|
42297
|
-
var
|
|
43136
|
+
var _a222;
|
|
42298
43137
|
const resolvedModel = resolveSpeechModel(model);
|
|
42299
43138
|
if (!resolvedModel) {
|
|
42300
43139
|
throw new Error("Model could not be resolved");
|
|
@@ -42326,10 +43165,10 @@ async function generateSpeech({
|
|
|
42326
43165
|
return new DefaultSpeechResult({
|
|
42327
43166
|
audio: new DefaultGeneratedAudioFile({
|
|
42328
43167
|
data: result.audio,
|
|
42329
|
-
mediaType: (
|
|
43168
|
+
mediaType: (_a222 = detectMediaType({
|
|
42330
43169
|
data: result.audio,
|
|
42331
43170
|
signatures: audioMediaTypeSignatures
|
|
42332
|
-
})) != null ?
|
|
43171
|
+
})) != null ? _a222 : "audio/mp3"
|
|
42333
43172
|
}),
|
|
42334
43173
|
warnings: result.warnings,
|
|
42335
43174
|
responses: [result.response],
|
|
@@ -42379,27 +43218,44 @@ function pruneMessages({
|
|
|
42379
43218
|
}
|
|
42380
43219
|
}
|
|
42381
43220
|
}
|
|
43221
|
+
const toolCallIdToToolName = /* @__PURE__ */ new Map;
|
|
43222
|
+
for (const message of messages) {
|
|
43223
|
+
if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
|
|
43224
|
+
for (const part of message.content) {
|
|
43225
|
+
if (part.type === "tool-call" || part.type === "tool-result") {
|
|
43226
|
+
toolCallIdToToolName.set(part.toolCallId, part.toolName);
|
|
43227
|
+
}
|
|
43228
|
+
}
|
|
43229
|
+
}
|
|
43230
|
+
}
|
|
43231
|
+
const approvalIdToToolName = /* @__PURE__ */ new Map;
|
|
43232
|
+
for (const message of messages) {
|
|
43233
|
+
if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
|
|
43234
|
+
for (const part of message.content) {
|
|
43235
|
+
if (part.type === "tool-approval-request") {
|
|
43236
|
+
const toolName = toolCallIdToToolName.get(part.toolCallId);
|
|
43237
|
+
if (toolName != null) {
|
|
43238
|
+
approvalIdToToolName.set(part.approvalId, toolName);
|
|
43239
|
+
}
|
|
43240
|
+
}
|
|
43241
|
+
}
|
|
43242
|
+
}
|
|
43243
|
+
}
|
|
42382
43244
|
messages = messages.map((message, messageIndex) => {
|
|
42383
43245
|
if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
|
|
42384
43246
|
return message;
|
|
42385
43247
|
}
|
|
42386
|
-
const toolCallIdToToolName = {};
|
|
42387
|
-
const approvalIdToToolName = {};
|
|
42388
43248
|
return {
|
|
42389
43249
|
...message,
|
|
42390
43250
|
content: message.content.filter((part) => {
|
|
42391
43251
|
if (part.type !== "tool-call" && part.type !== "tool-result" && part.type !== "tool-approval-request" && part.type !== "tool-approval-response") {
|
|
42392
43252
|
return true;
|
|
42393
43253
|
}
|
|
42394
|
-
if (part.type === "tool-call") {
|
|
42395
|
-
toolCallIdToToolName[part.toolCallId] = part.toolName;
|
|
42396
|
-
} else if (part.type === "tool-approval-request") {
|
|
42397
|
-
approvalIdToToolName[part.approvalId] = toolCallIdToToolName[part.toolCallId];
|
|
42398
|
-
}
|
|
42399
43254
|
if ((part.type === "tool-call" || part.type === "tool-result") && keptToolCallIds.has(part.toolCallId) || (part.type === "tool-approval-request" || part.type === "tool-approval-response") && keptApprovalIds.has(part.approvalId)) {
|
|
42400
43255
|
return true;
|
|
42401
43256
|
}
|
|
42402
|
-
|
|
43257
|
+
const partToolName = part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName.get(part.approvalId);
|
|
43258
|
+
return toolCall.tools != null && partToolName != null && !toolCall.tools.includes(partToolName);
|
|
42403
43259
|
})
|
|
42404
43260
|
};
|
|
42405
43261
|
});
|
|
@@ -42507,13 +43363,16 @@ async function experimental_generateVideo({
|
|
|
42507
43363
|
duration: duration3,
|
|
42508
43364
|
fps,
|
|
42509
43365
|
seed,
|
|
43366
|
+
frameImages,
|
|
43367
|
+
inputReferences,
|
|
43368
|
+
generateAudio,
|
|
42510
43369
|
providerOptions,
|
|
42511
43370
|
maxRetries: maxRetriesArg,
|
|
42512
43371
|
abortSignal,
|
|
42513
43372
|
headers,
|
|
42514
43373
|
download: downloadFn = defaultDownload
|
|
42515
43374
|
}) {
|
|
42516
|
-
var
|
|
43375
|
+
var _a222, _b16;
|
|
42517
43376
|
const model = resolveVideoModel(modelArg);
|
|
42518
43377
|
const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
|
|
42519
43378
|
const { retry } = prepareRetries({
|
|
@@ -42521,13 +43380,34 @@ async function experimental_generateVideo({
|
|
|
42521
43380
|
abortSignal
|
|
42522
43381
|
});
|
|
42523
43382
|
const { prompt, image } = normalizePrompt2(promptArg);
|
|
42524
|
-
const
|
|
43383
|
+
const normalizedFrameImages = frameImages == null ? undefined : frameImages.map((frame) => ({
|
|
43384
|
+
image: normalizeImageData(frame.image),
|
|
43385
|
+
frameType: frame.frameType
|
|
43386
|
+
}));
|
|
43387
|
+
const normalizedInputReferences = inputReferences == null ? undefined : inputReferences.map((reference) => normalizeImageData(reference));
|
|
43388
|
+
const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? undefined : normalizedInputReferences;
|
|
43389
|
+
const warnings = [];
|
|
43390
|
+
if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
|
|
43391
|
+
warnings.push({
|
|
43392
|
+
type: "other",
|
|
43393
|
+
message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
|
|
43394
|
+
});
|
|
43395
|
+
}
|
|
43396
|
+
const firstFrameImage = (_a222 = normalizedFrameImages == null ? undefined : normalizedFrameImages.find((frame) => frame.frameType === "first_frame")) == null ? undefined : _a222.image;
|
|
43397
|
+
if (image != null && firstFrameImage != null) {
|
|
43398
|
+
warnings.push({
|
|
43399
|
+
type: "other",
|
|
43400
|
+
message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
|
|
43401
|
+
});
|
|
43402
|
+
}
|
|
43403
|
+
const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
|
|
43404
|
+
const maxVideosPerCallWithDefault = (_b16 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b16 : 1;
|
|
42525
43405
|
const callCount = Math.ceil(n / maxVideosPerCallWithDefault);
|
|
42526
43406
|
const callVideoCounts = Array.from({ length: callCount }, (_, index) => {
|
|
42527
43407
|
const remaining = n - index * maxVideosPerCallWithDefault;
|
|
42528
43408
|
return Math.min(remaining, maxVideosPerCallWithDefault);
|
|
42529
43409
|
});
|
|
42530
|
-
const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => retry(() => model.doGenerate({
|
|
43410
|
+
const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => await retry(() => model.doGenerate({
|
|
42531
43411
|
prompt,
|
|
42532
43412
|
n: callVideoCount,
|
|
42533
43413
|
aspectRatio,
|
|
@@ -42535,13 +43415,15 @@ async function experimental_generateVideo({
|
|
|
42535
43415
|
duration: duration3,
|
|
42536
43416
|
fps,
|
|
42537
43417
|
seed,
|
|
42538
|
-
image,
|
|
43418
|
+
image: resolvedImage,
|
|
43419
|
+
frameImages: normalizedFrameImages,
|
|
43420
|
+
inputReferences: effectiveInputReferences,
|
|
43421
|
+
generateAudio,
|
|
42539
43422
|
providerOptions: providerOptions != null ? providerOptions : {},
|
|
42540
43423
|
headers: headersWithUserAgent,
|
|
42541
43424
|
abortSignal
|
|
42542
43425
|
}))));
|
|
42543
43426
|
const videos = [];
|
|
42544
|
-
const warnings = [];
|
|
42545
43427
|
const responses = [];
|
|
42546
43428
|
const providerMetadata = {};
|
|
42547
43429
|
for (const result of results) {
|
|
@@ -42629,56 +43511,49 @@ async function experimental_generateVideo({
|
|
|
42629
43511
|
};
|
|
42630
43512
|
}
|
|
42631
43513
|
function normalizePrompt2(promptArg) {
|
|
42632
|
-
var _a21, _b16;
|
|
42633
43514
|
if (typeof promptArg === "string") {
|
|
42634
43515
|
return {
|
|
42635
43516
|
prompt: promptArg,
|
|
42636
43517
|
image: undefined
|
|
42637
43518
|
};
|
|
42638
43519
|
}
|
|
42639
|
-
|
|
42640
|
-
|
|
42641
|
-
|
|
42642
|
-
|
|
42643
|
-
|
|
42644
|
-
|
|
42645
|
-
|
|
42646
|
-
|
|
42647
|
-
|
|
42648
|
-
|
|
42649
|
-
|
|
42650
|
-
|
|
42651
|
-
|
|
42652
|
-
|
|
42653
|
-
|
|
42654
|
-
|
|
42655
|
-
|
|
42656
|
-
const bytes = convertBase64ToUint8Array(dataContent);
|
|
42657
|
-
const mediaType = (_a21 = detectMediaType({
|
|
42658
|
-
data: bytes,
|
|
42659
|
-
signatures: imageMediaTypeSignatures
|
|
42660
|
-
})) != null ? _a21 : "image/png";
|
|
42661
|
-
image = {
|
|
42662
|
-
type: "file",
|
|
42663
|
-
mediaType,
|
|
42664
|
-
data: bytes
|
|
42665
|
-
};
|
|
42666
|
-
}
|
|
42667
|
-
} else if (dataContent instanceof Uint8Array) {
|
|
42668
|
-
const mediaType = (_b16 = detectMediaType({
|
|
42669
|
-
data: dataContent,
|
|
42670
|
-
signatures: imageMediaTypeSignatures
|
|
42671
|
-
})) != null ? _b16 : "image/png";
|
|
42672
|
-
image = {
|
|
43520
|
+
return {
|
|
43521
|
+
prompt: promptArg.text,
|
|
43522
|
+
image: promptArg.image != null ? normalizeImageData(promptArg.image) : undefined
|
|
43523
|
+
};
|
|
43524
|
+
}
|
|
43525
|
+
function normalizeImageData(dataContent) {
|
|
43526
|
+
var _a222, _b16;
|
|
43527
|
+
if (typeof dataContent === "string") {
|
|
43528
|
+
if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
|
|
43529
|
+
return {
|
|
43530
|
+
type: "url",
|
|
43531
|
+
url: dataContent
|
|
43532
|
+
};
|
|
43533
|
+
}
|
|
43534
|
+
if (dataContent.startsWith("data:")) {
|
|
43535
|
+
const { mediaType, base64Content } = splitDataUrl(dataContent);
|
|
43536
|
+
return {
|
|
42673
43537
|
type: "file",
|
|
42674
|
-
mediaType,
|
|
42675
|
-
data:
|
|
43538
|
+
mediaType: mediaType != null ? mediaType : "image/png",
|
|
43539
|
+
data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
|
|
42676
43540
|
};
|
|
42677
43541
|
}
|
|
43542
|
+
const bytes2 = convertBase64ToUint8Array(dataContent);
|
|
43543
|
+
return {
|
|
43544
|
+
type: "file",
|
|
43545
|
+
mediaType: (_a222 = detectMediaType({
|
|
43546
|
+
data: bytes2,
|
|
43547
|
+
signatures: imageMediaTypeSignatures
|
|
43548
|
+
})) != null ? _a222 : "image/png",
|
|
43549
|
+
data: bytes2
|
|
43550
|
+
};
|
|
42678
43551
|
}
|
|
43552
|
+
const bytes = convertDataContentToUint8Array(dataContent);
|
|
42679
43553
|
return {
|
|
42680
|
-
|
|
42681
|
-
image
|
|
43554
|
+
type: "file",
|
|
43555
|
+
mediaType: (_b16 = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b16 : "image/png",
|
|
43556
|
+
data: bytes
|
|
42682
43557
|
};
|
|
42683
43558
|
}
|
|
42684
43559
|
async function invokeModelMaxVideosPerCall(model) {
|
|
@@ -42711,8 +43586,8 @@ function defaultTransform(text2) {
|
|
|
42711
43586
|
return text2.replace(/^```(?:json)?\s*\n?/, "").replace(/\n?```\s*$/, "").trim();
|
|
42712
43587
|
}
|
|
42713
43588
|
function extractJsonMiddleware(options) {
|
|
42714
|
-
var
|
|
42715
|
-
const transform2 = (
|
|
43589
|
+
var _a222;
|
|
43590
|
+
const transform2 = (_a222 = options == null ? undefined : options.transform) != null ? _a222 : defaultTransform;
|
|
42716
43591
|
const hasCustomTransform = (options == null ? undefined : options.transform) !== undefined;
|
|
42717
43592
|
return {
|
|
42718
43593
|
specificationVersion: "v3",
|
|
@@ -42733,7 +43608,7 @@ function extractJsonMiddleware(options) {
|
|
|
42733
43608
|
},
|
|
42734
43609
|
wrapStream: async ({ doStream }) => {
|
|
42735
43610
|
const { stream, ...rest } = await doStream();
|
|
42736
|
-
const textBlocks =
|
|
43611
|
+
const textBlocks = createIdMap();
|
|
42737
43612
|
const SUFFIX_BUFFER_SIZE = 12;
|
|
42738
43613
|
return {
|
|
42739
43614
|
stream: stream.pipeThrough(new TransformStream({
|
|
@@ -42887,7 +43762,7 @@ function extractReasoningMiddleware({
|
|
|
42887
43762
|
},
|
|
42888
43763
|
wrapStream: async ({ doStream }) => {
|
|
42889
43764
|
const { stream, ...rest } = await doStream();
|
|
42890
|
-
const reasoningExtractions =
|
|
43765
|
+
const reasoningExtractions = createIdMap();
|
|
42891
43766
|
let delayedTextStart;
|
|
42892
43767
|
return {
|
|
42893
43768
|
stream: stream.pipeThrough(new TransformStream({
|
|
@@ -43066,13 +43941,13 @@ function addToolInputExamplesMiddleware({
|
|
|
43066
43941
|
return {
|
|
43067
43942
|
specificationVersion: "v3",
|
|
43068
43943
|
transformParams: async ({ params }) => {
|
|
43069
|
-
var
|
|
43070
|
-
if (!((
|
|
43944
|
+
var _a222;
|
|
43945
|
+
if (!((_a222 = params.tools) == null ? undefined : _a222.length)) {
|
|
43071
43946
|
return params;
|
|
43072
43947
|
}
|
|
43073
43948
|
const transformedTools = params.tools.map((tool2) => {
|
|
43074
|
-
var
|
|
43075
|
-
if (tool2.type !== "function" || !((
|
|
43949
|
+
var _a232;
|
|
43950
|
+
if (tool2.type !== "function" || !((_a232 = tool2.inputExamples) == null ? undefined : _a232.length)) {
|
|
43076
43951
|
return tool2;
|
|
43077
43952
|
}
|
|
43078
43953
|
const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join(`
|
|
@@ -43278,7 +44153,7 @@ async function rerank({
|
|
|
43278
44153
|
}),
|
|
43279
44154
|
tracer,
|
|
43280
44155
|
fn: async () => {
|
|
43281
|
-
var
|
|
44156
|
+
var _a222, _b16;
|
|
43282
44157
|
const { ranking, response, providerMetadata, warnings } = await retry(() => recordSpan({
|
|
43283
44158
|
name: "ai.rerank.doRerank",
|
|
43284
44159
|
attributes: selectTelemetryAttributes({
|
|
@@ -43337,7 +44212,7 @@ async function rerank({
|
|
|
43337
44212
|
providerMetadata,
|
|
43338
44213
|
response: {
|
|
43339
44214
|
id: response == null ? undefined : response.id,
|
|
43340
|
-
timestamp: (
|
|
44215
|
+
timestamp: (_a222 = response == null ? undefined : response.timestamp) != null ? _a222 : /* @__PURE__ */ new Date,
|
|
43341
44216
|
modelId: (_b16 = response == null ? undefined : response.modelId) != null ? _b16 : model.modelId,
|
|
43342
44217
|
headers: response == null ? undefined : response.headers,
|
|
43343
44218
|
body: response == null ? undefined : response.body
|
|
@@ -43366,16 +44241,16 @@ async function transcribe({
|
|
|
43366
44241
|
const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
|
|
43367
44242
|
const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
|
|
43368
44243
|
const result = await retry(() => {
|
|
43369
|
-
var
|
|
44244
|
+
var _a222;
|
|
43370
44245
|
return resolvedModel.doGenerate({
|
|
43371
44246
|
audio: audioData,
|
|
43372
44247
|
abortSignal,
|
|
43373
44248
|
headers: headersWithUserAgent,
|
|
43374
44249
|
providerOptions,
|
|
43375
|
-
mediaType: (
|
|
44250
|
+
mediaType: (_a222 = detectMediaType({
|
|
43376
44251
|
data: audioData,
|
|
43377
44252
|
signatures: audioMediaTypeSignatures
|
|
43378
|
-
})) != null ?
|
|
44253
|
+
})) != null ? _a222 : "audio/wav"
|
|
43379
44254
|
});
|
|
43380
44255
|
});
|
|
43381
44256
|
logWarnings({
|
|
@@ -43424,7 +44299,7 @@ async function callCompletionApi({
|
|
|
43424
44299
|
onError,
|
|
43425
44300
|
fetch: fetch2 = getOriginalFetch3()
|
|
43426
44301
|
}) {
|
|
43427
|
-
var
|
|
44302
|
+
var _a222;
|
|
43428
44303
|
try {
|
|
43429
44304
|
setLoading(true);
|
|
43430
44305
|
setError(undefined);
|
|
@@ -43447,7 +44322,7 @@ async function callCompletionApi({
|
|
|
43447
44322
|
throw err;
|
|
43448
44323
|
});
|
|
43449
44324
|
if (!response.ok) {
|
|
43450
|
-
throw new Error((
|
|
44325
|
+
throw new Error((_a222 = await response.text()) != null ? _a222 : "Failed to fetch the chat response.");
|
|
43451
44326
|
}
|
|
43452
44327
|
if (!response.body) {
|
|
43453
44328
|
throw new Error("The response body is empty.");
|
|
@@ -43522,12 +44397,12 @@ async function convertFileListToFileUIParts(files) {
|
|
|
43522
44397
|
throw new Error("FileList is not supported in the current environment");
|
|
43523
44398
|
}
|
|
43524
44399
|
return Promise.all(Array.from(files).map(async (file2) => {
|
|
43525
|
-
const { name:
|
|
44400
|
+
const { name: name222, type } = file2;
|
|
43526
44401
|
const dataUrl = await new Promise((resolve32, reject) => {
|
|
43527
44402
|
const reader = new FileReader;
|
|
43528
44403
|
reader.onload = (readerEvent) => {
|
|
43529
|
-
var
|
|
43530
|
-
resolve32((
|
|
44404
|
+
var _a222;
|
|
44405
|
+
resolve32((_a222 = readerEvent.target) == null ? undefined : _a222.result);
|
|
43531
44406
|
};
|
|
43532
44407
|
reader.onerror = (error40) => reject(error40);
|
|
43533
44408
|
reader.readAsDataURL(file2);
|
|
@@ -43535,7 +44410,7 @@ async function convertFileListToFileUIParts(files) {
|
|
|
43535
44410
|
return {
|
|
43536
44411
|
type: "file",
|
|
43537
44412
|
mediaType: type,
|
|
43538
|
-
filename:
|
|
44413
|
+
filename: name222,
|
|
43539
44414
|
url: dataUrl
|
|
43540
44415
|
};
|
|
43541
44416
|
}));
|
|
@@ -43592,9 +44467,9 @@ function transformTextToUiMessageStream({
|
|
|
43592
44467
|
}));
|
|
43593
44468
|
}
|
|
43594
44469
|
var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
43595
|
-
for (var
|
|
43596
|
-
__defProp2(target,
|
|
43597
|
-
}, name17 = "AI_InvalidArgumentError", marker18, symbol19, _a18, InvalidArgumentError2, name23 = "AI_InvalidStreamPartError", marker23, symbol23, _a23, InvalidStreamPartError, name33 = "AI_InvalidToolApprovalError", marker33, symbol33, _a33, InvalidToolApprovalError, name43 = "
|
|
44470
|
+
for (var name222 in all)
|
|
44471
|
+
__defProp2(target, name222, { get: all[name222], enumerable: true });
|
|
44472
|
+
}, name17 = "AI_InvalidArgumentError", marker18, symbol19, _a18, InvalidArgumentError2, name23 = "AI_InvalidStreamPartError", marker23, symbol23, _a23, InvalidStreamPartError, name33 = "AI_InvalidToolApprovalError", marker33, symbol33, _a33, InvalidToolApprovalError, name43 = "AI_InvalidToolApprovalSignatureError", marker43, symbol43, _a43, InvalidToolApprovalSignatureError, name53 = "AI_InvalidToolInputError", marker53, symbol53, _a53, InvalidToolInputError, name63 = "AI_ToolCallNotFoundForApprovalError", marker63, symbol63, _a63, ToolCallNotFoundForApprovalError, name73 = "AI_MissingToolResultsError", marker73, symbol73, _a73, MissingToolResultsError, name83 = "AI_NoImageGeneratedError", marker83, symbol83, _a83, NoImageGeneratedError, name93 = "AI_NoObjectGeneratedError", marker93, symbol93, _a93, NoObjectGeneratedError, name102 = "AI_NoOutputGeneratedError", marker103, symbol103, _a103, NoOutputGeneratedError, name112 = "AI_NoSpeechGeneratedError", marker112, symbol112, _a112, NoSpeechGeneratedError, name122 = "AI_NoTranscriptGeneratedError", marker122, symbol122, _a122, NoTranscriptGeneratedError, name132 = "AI_NoVideoGeneratedError", marker132, symbol132, _a132, NoVideoGeneratedError, name142 = "AI_NoSuchToolError", marker142, symbol142, _a142, NoSuchToolError, name15 = "AI_ToolCallRepairError", marker152, symbol152, _a152, ToolCallRepairError, UnsupportedModelVersionError, name162 = "AI_UIMessageStreamError", marker16, symbol16, _a16, UIMessageStreamError, name172 = "AI_InvalidDataContentError", marker172, symbol172, _a172, InvalidDataContentError, name18 = "AI_InvalidMessageRoleError", marker182, symbol182, _a182, InvalidMessageRoleError, name19 = "AI_MessageConversionError", marker19, symbol192, _a19, MessageConversionError, name20 = "AI_RetryError", marker20, symbol20, _a20, RetryError, FIRST_WARNING_INFO_MESSAGE = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.", hasLoggedBefore = false, logWarnings = (options) => {
|
|
43598
44473
|
if (options.warnings.length === 0) {
|
|
43599
44474
|
return;
|
|
43600
44475
|
}
|
|
@@ -43621,23 +44496,22 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43621
44496
|
const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
|
|
43622
44497
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
43623
44498
|
return bytes.slice(id3Size + 10);
|
|
43624
|
-
}, VERSION6 = "6.0.
|
|
44499
|
+
}, VERSION6 = "6.0.219", download = async ({
|
|
43625
44500
|
url: url2,
|
|
43626
44501
|
maxBytes,
|
|
43627
44502
|
abortSignal
|
|
43628
44503
|
}) => {
|
|
43629
|
-
var
|
|
44504
|
+
var _a222;
|
|
43630
44505
|
const urlText = url2.toString();
|
|
43631
|
-
validateDownloadUrl(urlText);
|
|
43632
44506
|
try {
|
|
43633
|
-
const
|
|
43634
|
-
|
|
43635
|
-
|
|
44507
|
+
const headers = withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent());
|
|
44508
|
+
const response = await fetchWithValidatedRedirects({
|
|
44509
|
+
url: urlText,
|
|
44510
|
+
headers,
|
|
44511
|
+
abortSignal
|
|
43636
44512
|
});
|
|
43637
|
-
if (response.redirected) {
|
|
43638
|
-
validateDownloadUrl(response.url);
|
|
43639
|
-
}
|
|
43640
44513
|
if (!response.ok) {
|
|
44514
|
+
await cancelResponseBody(response);
|
|
43641
44515
|
throw new DownloadError({
|
|
43642
44516
|
url: urlText,
|
|
43643
44517
|
statusCode: response.status,
|
|
@@ -43651,7 +44525,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43651
44525
|
});
|
|
43652
44526
|
return {
|
|
43653
44527
|
data,
|
|
43654
|
-
mediaType: (
|
|
44528
|
+
mediaType: (_a222 = response.headers.get("content-type")) != null ? _a222 : undefined
|
|
43655
44529
|
};
|
|
43656
44530
|
} catch (error40) {
|
|
43657
44531
|
if (DownloadError.isInstance(error40)) {
|
|
@@ -43664,11 +44538,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43664
44538
|
initialDelayInMs = 2000,
|
|
43665
44539
|
backoffFactor = 2,
|
|
43666
44540
|
abortSignal
|
|
43667
|
-
} = {}) =>
|
|
44541
|
+
} = {}) => retryWithExponentialBackoff({
|
|
43668
44542
|
maxRetries,
|
|
43669
|
-
|
|
44543
|
+
initialDelayInMs,
|
|
43670
44544
|
backoffFactor,
|
|
43671
|
-
abortSignal
|
|
44545
|
+
abortSignal,
|
|
44546
|
+
shouldRetry: (error40) => error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true),
|
|
44547
|
+
getDelayInMs: ({ error: error40, exponentialBackoffDelay }) => getRetryDelayInMs({
|
|
44548
|
+
error: error40,
|
|
44549
|
+
exponentialBackoffDelay
|
|
44550
|
+
}),
|
|
44551
|
+
createRetryError: ({ message, reason, errors: errors4 }) => new RetryError({ message, reason, errors: errors4 })
|
|
43672
44552
|
}), DefaultGeneratedFile = class {
|
|
43673
44553
|
constructor({
|
|
43674
44554
|
data,
|
|
@@ -43691,7 +44571,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43691
44571
|
}
|
|
43692
44572
|
return this.uint8ArrayData;
|
|
43693
44573
|
}
|
|
43694
|
-
}, DefaultGeneratedFileWithType, output_exports, text = () => ({
|
|
44574
|
+
}, DefaultGeneratedFileWithType, encoder, output_exports, text = () => ({
|
|
43695
44575
|
name: "text",
|
|
43696
44576
|
responseFormat: Promise.resolve({ type: "text" }),
|
|
43697
44577
|
async parseCompleteOutput({ text: text2 }) {
|
|
@@ -43705,7 +44585,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43705
44585
|
}
|
|
43706
44586
|
}), object2 = ({
|
|
43707
44587
|
schema: inputSchema,
|
|
43708
|
-
name:
|
|
44588
|
+
name: name222,
|
|
43709
44589
|
description
|
|
43710
44590
|
}) => {
|
|
43711
44591
|
const schema = asSchema(inputSchema);
|
|
@@ -43714,7 +44594,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43714
44594
|
responseFormat: resolve3(schema.jsonSchema).then((jsonSchema2) => ({
|
|
43715
44595
|
type: "json",
|
|
43716
44596
|
schema: jsonSchema2,
|
|
43717
|
-
...
|
|
44597
|
+
...name222 != null && { name: name222 },
|
|
43718
44598
|
...description != null && { description }
|
|
43719
44599
|
})),
|
|
43720
44600
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
@@ -43766,7 +44646,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43766
44646
|
};
|
|
43767
44647
|
}, array2 = ({
|
|
43768
44648
|
element: inputElementSchema,
|
|
43769
|
-
name:
|
|
44649
|
+
name: name222,
|
|
43770
44650
|
description
|
|
43771
44651
|
}) => {
|
|
43772
44652
|
const elementSchema = asSchema(inputElementSchema);
|
|
@@ -43785,7 +44665,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43785
44665
|
required: ["elements"],
|
|
43786
44666
|
additionalProperties: false
|
|
43787
44667
|
},
|
|
43788
|
-
...
|
|
44668
|
+
...name222 != null && { name: name222 },
|
|
43789
44669
|
...description != null && { description }
|
|
43790
44670
|
};
|
|
43791
44671
|
}),
|
|
@@ -43876,7 +44756,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43876
44756
|
};
|
|
43877
44757
|
}, choice = ({
|
|
43878
44758
|
options: choiceOptions,
|
|
43879
|
-
name:
|
|
44759
|
+
name: name222,
|
|
43880
44760
|
description
|
|
43881
44761
|
}) => {
|
|
43882
44762
|
return {
|
|
@@ -43892,7 +44772,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43892
44772
|
required: ["result"],
|
|
43893
44773
|
additionalProperties: false
|
|
43894
44774
|
},
|
|
43895
|
-
...
|
|
44775
|
+
...name222 != null && { name: name222 },
|
|
43896
44776
|
...description != null && { description }
|
|
43897
44777
|
}),
|
|
43898
44778
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
@@ -43950,14 +44830,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
43950
44830
|
}
|
|
43951
44831
|
};
|
|
43952
44832
|
}, json2 = ({
|
|
43953
|
-
name:
|
|
44833
|
+
name: name222,
|
|
43954
44834
|
description
|
|
43955
44835
|
} = {}) => {
|
|
43956
44836
|
return {
|
|
43957
44837
|
name: "json",
|
|
43958
44838
|
responseFormat: Promise.resolve({
|
|
43959
44839
|
type: "json",
|
|
43960
|
-
...
|
|
44840
|
+
...name222 != null && { name: name222 },
|
|
43961
44841
|
...description != null && { description }
|
|
43962
44842
|
}),
|
|
43963
44843
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
@@ -44129,7 +45009,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44129
45009
|
}
|
|
44130
45010
|
return this._output;
|
|
44131
45011
|
}
|
|
44132
|
-
}, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
|
|
45012
|
+
}, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, isOutputChunkType, DefaultStreamTextResult = class {
|
|
44133
45013
|
constructor({
|
|
44134
45014
|
model,
|
|
44135
45015
|
telemetry,
|
|
@@ -44170,6 +45050,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44170
45050
|
onToolCallStart,
|
|
44171
45051
|
onToolCallFinish,
|
|
44172
45052
|
experimental_context,
|
|
45053
|
+
experimental_toolApprovalSecret,
|
|
44173
45054
|
download: download2,
|
|
44174
45055
|
include
|
|
44175
45056
|
}) {
|
|
@@ -44191,20 +45072,25 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44191
45072
|
let recordedRequest = {};
|
|
44192
45073
|
let recordedWarnings = [];
|
|
44193
45074
|
const recordedSteps = [];
|
|
45075
|
+
let recordedNoOutputError;
|
|
44194
45076
|
const pendingDeferredToolCalls = /* @__PURE__ */ new Map;
|
|
44195
45077
|
let rootSpan;
|
|
44196
|
-
let activeTextContent =
|
|
44197
|
-
let activeReasoningContent =
|
|
45078
|
+
let activeTextContent = createIdMap();
|
|
45079
|
+
let activeReasoningContent = createIdMap();
|
|
44198
45080
|
const eventProcessor = new TransformStream({
|
|
44199
45081
|
async transform(chunk, controller) {
|
|
44200
|
-
var
|
|
45082
|
+
var _a222, _b16, _c, _d;
|
|
44201
45083
|
controller.enqueue(chunk);
|
|
44202
45084
|
const { part } = chunk;
|
|
44203
45085
|
if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
|
|
44204
45086
|
await (onChunk == null ? undefined : onChunk({ chunk: part }));
|
|
44205
45087
|
}
|
|
44206
45088
|
if (part.type === "error") {
|
|
44207
|
-
|
|
45089
|
+
const error40 = wrapGatewayError(part.error);
|
|
45090
|
+
if (NoOutputGeneratedError.isInstance(error40)) {
|
|
45091
|
+
recordedNoOutputError = error40;
|
|
45092
|
+
}
|
|
45093
|
+
await onError({ error: error40 });
|
|
44208
45094
|
}
|
|
44209
45095
|
if (part.type === "text-start") {
|
|
44210
45096
|
activeTextContent[part.id] = {
|
|
@@ -44227,7 +45113,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44227
45113
|
return;
|
|
44228
45114
|
}
|
|
44229
45115
|
activeText.text += part.text;
|
|
44230
|
-
activeText.providerMetadata = (
|
|
45116
|
+
activeText.providerMetadata = (_a222 = part.providerMetadata) != null ? _a222 : activeText.providerMetadata;
|
|
44231
45117
|
}
|
|
44232
45118
|
if (part.type === "text-end") {
|
|
44233
45119
|
const activeText = activeTextContent[part.id];
|
|
@@ -44306,8 +45192,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44306
45192
|
}
|
|
44307
45193
|
if (part.type === "start-step") {
|
|
44308
45194
|
recordedContent = [];
|
|
44309
|
-
activeReasoningContent =
|
|
44310
|
-
activeTextContent =
|
|
45195
|
+
activeReasoningContent = createIdMap();
|
|
45196
|
+
activeTextContent = createIdMap();
|
|
44311
45197
|
recordedRequest = part.request;
|
|
44312
45198
|
recordedWarnings = part.warnings;
|
|
44313
45199
|
}
|
|
@@ -44353,10 +45239,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44353
45239
|
}
|
|
44354
45240
|
},
|
|
44355
45241
|
async flush(controller) {
|
|
44356
|
-
var
|
|
45242
|
+
var _a222, _b16, _c, _d, _e, _f, _g;
|
|
44357
45243
|
try {
|
|
44358
|
-
if (recordedSteps.length === 0) {
|
|
44359
|
-
const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
|
|
45244
|
+
if (recordedSteps.length === 0 || recordedNoOutputError != null) {
|
|
45245
|
+
const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : recordedNoOutputError != null ? recordedNoOutputError : new NoOutputGeneratedError({
|
|
44360
45246
|
message: "No output generated. Check the stream for errors."
|
|
44361
45247
|
});
|
|
44362
45248
|
self2._finishReason.reject(error40);
|
|
@@ -44416,13 +45302,13 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44416
45302
|
},
|
|
44417
45303
|
"ai.response.toolCalls": {
|
|
44418
45304
|
output: () => {
|
|
44419
|
-
var
|
|
44420
|
-
return ((
|
|
45305
|
+
var _a232;
|
|
45306
|
+
return ((_a232 = finalStep.toolCalls) == null ? undefined : _a232.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
|
|
44421
45307
|
}
|
|
44422
45308
|
},
|
|
44423
45309
|
"ai.response.providerMetadata": JSON.stringify(finalStep.providerMetadata),
|
|
44424
45310
|
"ai.usage.inputTokens": totalUsage.inputTokens,
|
|
44425
|
-
"ai.usage.inputTokenDetails.noCacheTokens": (
|
|
45311
|
+
"ai.usage.inputTokenDetails.noCacheTokens": (_a222 = totalUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
|
|
44426
45312
|
"ai.usage.inputTokenDetails.cacheReadTokens": (_b16 = totalUsage.inputTokenDetails) == null ? undefined : _b16.cacheReadTokens,
|
|
44427
45313
|
"ai.usage.inputTokenDetails.cacheWriteTokens": (_c = totalUsage.inputTokenDetails) == null ? undefined : _c.cacheWriteTokens,
|
|
44428
45314
|
"ai.usage.outputTokens": totalUsage.outputTokens,
|
|
@@ -44566,8 +45452,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44566
45452
|
const initialResponseMessages = [];
|
|
44567
45453
|
const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
|
|
44568
45454
|
if (deniedToolApprovals.length > 0 || approvedToolApprovals.length > 0) {
|
|
44569
|
-
const
|
|
44570
|
-
|
|
45455
|
+
const {
|
|
45456
|
+
approvedToolApprovals: localApprovedToolApprovals,
|
|
45457
|
+
deniedToolApprovals: revalidationDeniedToolApprovals
|
|
45458
|
+
} = await validateApprovedToolApprovals({
|
|
45459
|
+
approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
|
|
45460
|
+
tools,
|
|
45461
|
+
messages: initialMessages,
|
|
45462
|
+
experimental_context,
|
|
45463
|
+
toolApprovalSecret: experimental_toolApprovalSecret
|
|
45464
|
+
});
|
|
45465
|
+
const localDeniedToolApprovals = [
|
|
45466
|
+
...deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
|
|
45467
|
+
...revalidationDeniedToolApprovals
|
|
45468
|
+
];
|
|
44571
45469
|
const deniedProviderExecutedToolApprovals = deniedToolApprovals.filter((toolApproval) => toolApproval.toolCall.providerExecuted);
|
|
44572
45470
|
let toolExecutionStepStreamController;
|
|
44573
45471
|
const toolExecutionStepStream = new ReadableStream({
|
|
@@ -44658,7 +45556,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44658
45556
|
responseMessages,
|
|
44659
45557
|
usage
|
|
44660
45558
|
}) {
|
|
44661
|
-
var
|
|
45559
|
+
var _a222, _b16, _c, _d, _e, _f, _g, _h, _i;
|
|
44662
45560
|
const includeRawChunks2 = self2.includeRawChunks;
|
|
44663
45561
|
const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : undefined;
|
|
44664
45562
|
let chunkTimeoutId = undefined;
|
|
@@ -44691,7 +45589,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44691
45589
|
messages: stepInputMessages,
|
|
44692
45590
|
experimental_context
|
|
44693
45591
|
}));
|
|
44694
|
-
const stepModel = resolveLanguageModel((
|
|
45592
|
+
const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
|
|
44695
45593
|
const stepModelInfo = {
|
|
44696
45594
|
provider: stepModel.provider,
|
|
44697
45595
|
modelId: stepModel.modelId
|
|
@@ -44803,6 +45701,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44803
45701
|
repairToolCall,
|
|
44804
45702
|
abortSignal,
|
|
44805
45703
|
experimental_context,
|
|
45704
|
+
toolApprovalSecret: experimental_toolApprovalSecret,
|
|
44806
45705
|
generateId: generateId2,
|
|
44807
45706
|
stepNumber: recordedSteps.length,
|
|
44808
45707
|
model: stepModelInfo,
|
|
@@ -44822,6 +45721,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44822
45721
|
const activeToolCallToolNames = {};
|
|
44823
45722
|
let stepFinishReason = "other";
|
|
44824
45723
|
let stepRawFinishReason = undefined;
|
|
45724
|
+
let hasReceivedTerminalChunk = false;
|
|
45725
|
+
let hasReceivedOutputChunk = false;
|
|
44825
45726
|
let stepUsage = createNullLanguageModelUsage();
|
|
44826
45727
|
let stepProviderMetadata;
|
|
44827
45728
|
let stepFirstChunk = true;
|
|
@@ -44833,7 +45734,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44833
45734
|
let activeText = "";
|
|
44834
45735
|
self2.addStream(streamWithToolResults.pipeThrough(new TransformStream({
|
|
44835
45736
|
async transform(chunk, controller) {
|
|
44836
|
-
var
|
|
45737
|
+
var _a232, _b23, _c2, _d2, _e2;
|
|
44837
45738
|
resetChunkTimeout();
|
|
44838
45739
|
if (chunk.type === "stream-start") {
|
|
44839
45740
|
warnings = chunk.warnings;
|
|
@@ -44855,6 +45756,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44855
45756
|
});
|
|
44856
45757
|
}
|
|
44857
45758
|
const chunkType = chunk.type;
|
|
45759
|
+
if (isOutputChunkType[chunkType]) {
|
|
45760
|
+
hasReceivedOutputChunk = true;
|
|
45761
|
+
}
|
|
44858
45762
|
switch (chunkType) {
|
|
44859
45763
|
case "tool-approval-request":
|
|
44860
45764
|
case "text-start":
|
|
@@ -44907,13 +45811,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44907
45811
|
}
|
|
44908
45812
|
case "response-metadata": {
|
|
44909
45813
|
stepResponse = {
|
|
44910
|
-
id: (
|
|
45814
|
+
id: (_a232 = chunk.id) != null ? _a232 : stepResponse.id,
|
|
44911
45815
|
timestamp: (_b23 = chunk.timestamp) != null ? _b23 : stepResponse.timestamp,
|
|
44912
45816
|
modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
|
|
44913
45817
|
};
|
|
44914
45818
|
break;
|
|
44915
45819
|
}
|
|
44916
45820
|
case "finish": {
|
|
45821
|
+
hasReceivedTerminalChunk = true;
|
|
44917
45822
|
stepUsage = chunk.usage;
|
|
44918
45823
|
stepFinishReason = chunk.finishReason;
|
|
44919
45824
|
stepRawFinishReason = chunk.rawFinishReason;
|
|
@@ -44973,6 +45878,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44973
45878
|
break;
|
|
44974
45879
|
}
|
|
44975
45880
|
case "error": {
|
|
45881
|
+
hasReceivedTerminalChunk = true;
|
|
44976
45882
|
controller.enqueue(chunk);
|
|
44977
45883
|
stepFinishReason = "error";
|
|
44978
45884
|
break;
|
|
@@ -44990,7 +45896,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
44990
45896
|
}
|
|
44991
45897
|
},
|
|
44992
45898
|
async flush(controller) {
|
|
44993
|
-
var
|
|
45899
|
+
var _a232, _b23, _c2, _d2, _e2, _f2, _g2;
|
|
45900
|
+
if (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {
|
|
45901
|
+
controller.enqueue({
|
|
45902
|
+
type: "error",
|
|
45903
|
+
error: new NoOutputGeneratedError({
|
|
45904
|
+
message: "No output generated. The model stream ended without a finish chunk."
|
|
45905
|
+
})
|
|
45906
|
+
});
|
|
45907
|
+
doStreamSpan.end();
|
|
45908
|
+
clearStepTimeout();
|
|
45909
|
+
clearChunkTimeout();
|
|
45910
|
+
self2.closeStream();
|
|
45911
|
+
return;
|
|
45912
|
+
}
|
|
44994
45913
|
const stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : undefined;
|
|
44995
45914
|
try {
|
|
44996
45915
|
doStreamSpan.setAttributes(await selectTelemetryAttributes({
|
|
@@ -45004,7 +45923,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45004
45923
|
"ai.response.model": stepResponse.modelId,
|
|
45005
45924
|
"ai.response.timestamp": stepResponse.timestamp.toISOString(),
|
|
45006
45925
|
"ai.usage.inputTokens": stepUsage.inputTokens,
|
|
45007
|
-
"ai.usage.inputTokenDetails.noCacheTokens": (
|
|
45926
|
+
"ai.usage.inputTokenDetails.noCacheTokens": (_a232 = stepUsage.inputTokenDetails) == null ? undefined : _a232.noCacheTokens,
|
|
45008
45927
|
"ai.usage.inputTokenDetails.cacheReadTokens": (_b23 = stepUsage.inputTokenDetails) == null ? undefined : _b23.cacheReadTokens,
|
|
45009
45928
|
"ai.usage.inputTokenDetails.cacheWriteTokens": (_c2 = stepUsage.inputTokenDetails) == null ? undefined : _c2.cacheWriteTokens,
|
|
45010
45929
|
"ai.usage.outputTokens": stepUsage.outputTokens,
|
|
@@ -45219,15 +46138,30 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45219
46138
|
}
|
|
45220
46139
|
})));
|
|
45221
46140
|
}
|
|
46141
|
+
rejectResultPromises(error40) {
|
|
46142
|
+
if (this._finishReason.isPending())
|
|
46143
|
+
this._finishReason.reject(error40);
|
|
46144
|
+
if (this._rawFinishReason.isPending())
|
|
46145
|
+
this._rawFinishReason.reject(error40);
|
|
46146
|
+
if (this._totalUsage.isPending())
|
|
46147
|
+
this._totalUsage.reject(error40);
|
|
46148
|
+
if (this._steps.isPending())
|
|
46149
|
+
this._steps.reject(error40);
|
|
46150
|
+
}
|
|
45222
46151
|
async consumeStream(options) {
|
|
45223
|
-
var
|
|
46152
|
+
var _a222;
|
|
45224
46153
|
try {
|
|
45225
46154
|
await consumeStream({
|
|
45226
46155
|
stream: this.fullStream,
|
|
45227
|
-
onError:
|
|
46156
|
+
onError: (error40) => {
|
|
46157
|
+
var _a232;
|
|
46158
|
+
this.rejectResultPromises(error40);
|
|
46159
|
+
(_a232 = options == null ? undefined : options.onError) == null || _a232.call(options, error40);
|
|
46160
|
+
}
|
|
45228
46161
|
});
|
|
45229
46162
|
} catch (error40) {
|
|
45230
|
-
|
|
46163
|
+
this.rejectResultPromises(error40);
|
|
46164
|
+
(_a222 = options == null ? undefined : options.onError) == null || _a222.call(options, error40);
|
|
45231
46165
|
}
|
|
45232
46166
|
}
|
|
45233
46167
|
get experimental_partialOutputStream() {
|
|
@@ -45243,8 +46177,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45243
46177
|
})));
|
|
45244
46178
|
}
|
|
45245
46179
|
get elementStream() {
|
|
45246
|
-
var
|
|
45247
|
-
const transform2 = (
|
|
46180
|
+
var _a222, _b16, _c;
|
|
46181
|
+
const transform2 = (_a222 = this.outputSpecification) == null ? undefined : _a222.createElementStreamTransform();
|
|
45248
46182
|
if (transform2 == null) {
|
|
45249
46183
|
throw new UnsupportedFunctionalityError({
|
|
45250
46184
|
functionality: `element streams in ${(_c = (_b16 = this.outputSpecification) == null ? undefined : _b16.name) != null ? _c : "text"} mode`
|
|
@@ -45254,8 +46188,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45254
46188
|
}
|
|
45255
46189
|
get output() {
|
|
45256
46190
|
return this.finalStep.then((step) => {
|
|
45257
|
-
var
|
|
45258
|
-
const output = (
|
|
46191
|
+
var _a222;
|
|
46192
|
+
const output = (_a222 = this.outputSpecification) != null ? _a222 : text();
|
|
45259
46193
|
return output.parseCompleteOutput({ text: step.text }, {
|
|
45260
46194
|
response: step.response,
|
|
45261
46195
|
usage: step.usage,
|
|
@@ -45272,15 +46206,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45272
46206
|
sendSources = false,
|
|
45273
46207
|
sendStart = true,
|
|
45274
46208
|
sendFinish = true,
|
|
45275
|
-
onError =
|
|
46209
|
+
onError = () => "An error occurred."
|
|
45276
46210
|
} = {}) {
|
|
45277
46211
|
const responseMessageId = generateMessageId != null ? getResponseUIMessageId({
|
|
45278
46212
|
originalMessages,
|
|
45279
46213
|
responseMessageId: generateMessageId
|
|
45280
46214
|
}) : undefined;
|
|
45281
46215
|
const isDynamic = (part) => {
|
|
45282
|
-
var
|
|
45283
|
-
const tool2 = (
|
|
46216
|
+
var _a222;
|
|
46217
|
+
const tool2 = (_a222 = this.tools) == null ? undefined : _a222[part.toolName];
|
|
45284
46218
|
if (tool2 == null) {
|
|
45285
46219
|
return part.dynamic;
|
|
45286
46220
|
}
|
|
@@ -45425,7 +46359,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45425
46359
|
controller.enqueue({
|
|
45426
46360
|
type: "tool-approval-request",
|
|
45427
46361
|
approvalId: part.approvalId,
|
|
45428
|
-
toolCallId: part.toolCall.toolCallId
|
|
46362
|
+
toolCallId: part.toolCall.toolCallId,
|
|
46363
|
+
...part.signature != null ? { signature: part.signature } : {}
|
|
45429
46364
|
});
|
|
45430
46365
|
break;
|
|
45431
46366
|
}
|
|
@@ -45434,7 +46369,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45434
46369
|
controller.enqueue({
|
|
45435
46370
|
type: "tool-output-available",
|
|
45436
46371
|
toolCallId: part.toolCallId,
|
|
45437
|
-
output: part.output,
|
|
46372
|
+
output: part.output === undefined ? null : part.output,
|
|
45438
46373
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
45439
46374
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
45440
46375
|
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
@@ -45609,7 +46544,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45609
46544
|
return this.settings.tools;
|
|
45610
46545
|
}
|
|
45611
46546
|
async prepareCall(options) {
|
|
45612
|
-
var
|
|
46547
|
+
var _a222, _b16, _c, _d;
|
|
45613
46548
|
if (this.settings.callOptionsSchema != null && options.options !== undefined) {
|
|
45614
46549
|
const validatedOptions = await validateTypes({
|
|
45615
46550
|
value: options.options,
|
|
@@ -45621,7 +46556,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45621
46556
|
const { onStepFinish: _settingsOnStepFinish, ...settingsWithoutCallback } = this.settings;
|
|
45622
46557
|
const baseCallArgs = {
|
|
45623
46558
|
...settingsWithoutCallback,
|
|
45624
|
-
stopWhen: (
|
|
46559
|
+
stopWhen: (_a222 = this.settings.stopWhen) != null ? _a222 : stepCountIs(20),
|
|
45625
46560
|
...options
|
|
45626
46561
|
};
|
|
45627
46562
|
const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
|
|
@@ -45750,7 +46685,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45750
46685
|
isFirstDelta,
|
|
45751
46686
|
isFinalDelta
|
|
45752
46687
|
}) {
|
|
45753
|
-
var
|
|
46688
|
+
var _a222;
|
|
45754
46689
|
if (!isJSONObject(value) || !isJSONArray(value.elements)) {
|
|
45755
46690
|
return {
|
|
45756
46691
|
success: false,
|
|
@@ -45773,7 +46708,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45773
46708
|
}
|
|
45774
46709
|
resultArray.push(result.value);
|
|
45775
46710
|
}
|
|
45776
|
-
const publishedElementCount = (
|
|
46711
|
+
const publishedElementCount = (_a222 = latestObject == null ? undefined : latestObject.length) != null ? _a222 : 0;
|
|
45777
46712
|
let textDelta = "";
|
|
45778
46713
|
if (isFirstDelta) {
|
|
45779
46714
|
textDelta += "[";
|
|
@@ -45804,13 +46739,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45804
46739
|
};
|
|
45805
46740
|
}
|
|
45806
46741
|
const inputArray = value.elements;
|
|
46742
|
+
const resultArray = [];
|
|
45807
46743
|
for (const element of inputArray) {
|
|
45808
46744
|
const result = await safeValidateTypes({ value: element, schema });
|
|
45809
46745
|
if (!result.success) {
|
|
45810
46746
|
return result;
|
|
45811
46747
|
}
|
|
46748
|
+
resultArray.push(result.value);
|
|
45812
46749
|
}
|
|
45813
|
-
return { success: true, value:
|
|
46750
|
+
return { success: true, value: resultArray };
|
|
45814
46751
|
},
|
|
45815
46752
|
createElementStream(originalStream) {
|
|
45816
46753
|
let publishedElements = 0;
|
|
@@ -45915,9 +46852,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
45915
46852
|
this.reasoning = options.reasoning;
|
|
45916
46853
|
}
|
|
45917
46854
|
toJsonResponse(init) {
|
|
45918
|
-
var
|
|
46855
|
+
var _a222;
|
|
45919
46856
|
return new Response(JSON.stringify(this.object), {
|
|
45920
|
-
status: (
|
|
46857
|
+
status: (_a222 = init == null ? undefined : init.status) != null ? _a222 : 200,
|
|
45921
46858
|
headers: prepareHeaders(init == null ? undefined : init.headers, {
|
|
45922
46859
|
"content-type": "application/json; charset=utf-8"
|
|
45923
46860
|
})
|
|
@@ -46125,7 +47062,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46125
47062
|
let isFirstDelta = true;
|
|
46126
47063
|
const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({
|
|
46127
47064
|
async transform(chunk, controller) {
|
|
46128
|
-
var
|
|
47065
|
+
var _a222, _b16, _c;
|
|
46129
47066
|
if (typeof chunk === "object" && chunk.type === "stream-start") {
|
|
46130
47067
|
warnings = chunk.warnings;
|
|
46131
47068
|
return;
|
|
@@ -46172,7 +47109,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46172
47109
|
switch (chunk.type) {
|
|
46173
47110
|
case "response-metadata": {
|
|
46174
47111
|
fullResponse = {
|
|
46175
|
-
id: (
|
|
47112
|
+
id: (_a222 = chunk.id) != null ? _a222 : fullResponse.id,
|
|
46176
47113
|
timestamp: (_b16 = chunk.timestamp) != null ? _b16 : fullResponse.timestamp,
|
|
46177
47114
|
modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
|
|
46178
47115
|
};
|
|
@@ -46380,11 +47317,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46380
47317
|
}
|
|
46381
47318
|
}, DefaultGeneratedAudioFile, DefaultSpeechResult = class {
|
|
46382
47319
|
constructor(options) {
|
|
46383
|
-
var
|
|
47320
|
+
var _a222;
|
|
46384
47321
|
this.audio = options.audio;
|
|
46385
47322
|
this.warnings = options.warnings;
|
|
46386
47323
|
this.responses = options.responses;
|
|
46387
|
-
this.providerMetadata = (
|
|
47324
|
+
this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
|
|
46388
47325
|
}
|
|
46389
47326
|
}, CHUNKING_REGEXPS, defaultDownload, wrapLanguageModel = ({
|
|
46390
47327
|
model,
|
|
@@ -46408,7 +47345,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46408
47345
|
modelId,
|
|
46409
47346
|
providerId
|
|
46410
47347
|
}) => {
|
|
46411
|
-
var
|
|
47348
|
+
var _a222, _b16, _c;
|
|
46412
47349
|
async function doTransform({
|
|
46413
47350
|
params,
|
|
46414
47351
|
type
|
|
@@ -46417,7 +47354,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46417
47354
|
}
|
|
46418
47355
|
return {
|
|
46419
47356
|
specificationVersion: "v3",
|
|
46420
|
-
provider: (
|
|
47357
|
+
provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
|
|
46421
47358
|
modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
|
|
46422
47359
|
supportedUrls: (_c = overrideSupportedUrls == null ? undefined : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
|
|
46423
47360
|
async doGenerate(params) {
|
|
@@ -46460,7 +47397,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46460
47397
|
modelId,
|
|
46461
47398
|
providerId
|
|
46462
47399
|
}) => {
|
|
46463
|
-
var
|
|
47400
|
+
var _a222, _b16, _c, _d;
|
|
46464
47401
|
async function doTransform({
|
|
46465
47402
|
params
|
|
46466
47403
|
}) {
|
|
@@ -46468,7 +47405,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46468
47405
|
}
|
|
46469
47406
|
return {
|
|
46470
47407
|
specificationVersion: "v3",
|
|
46471
|
-
provider: (
|
|
47408
|
+
provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
|
|
46472
47409
|
modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
|
|
46473
47410
|
maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? undefined : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
|
|
46474
47411
|
supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? undefined : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
|
|
@@ -46503,11 +47440,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46503
47440
|
modelId,
|
|
46504
47441
|
providerId
|
|
46505
47442
|
}) => {
|
|
46506
|
-
var
|
|
47443
|
+
var _a222, _b16, _c;
|
|
46507
47444
|
async function doTransform({ params }) {
|
|
46508
47445
|
return transformParams ? await transformParams({ params, model }) : params;
|
|
46509
47446
|
}
|
|
46510
|
-
const maxImagesPerCallRaw = (
|
|
47447
|
+
const maxImagesPerCallRaw = (_a222 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a222 : model.maxImagesPerCall;
|
|
46511
47448
|
const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
|
|
46512
47449
|
return {
|
|
46513
47450
|
specificationVersion: "v3",
|
|
@@ -46524,7 +47461,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46524
47461
|
}) : doGenerate();
|
|
46525
47462
|
}
|
|
46526
47463
|
};
|
|
46527
|
-
}, experimental_customProvider,
|
|
47464
|
+
}, experimental_customProvider, name21 = "AI_NoSuchProviderError", marker21, symbol21, _a21, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
|
|
46528
47465
|
constructor({
|
|
46529
47466
|
separator,
|
|
46530
47467
|
languageModelMiddleware,
|
|
@@ -46565,9 +47502,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46565
47502
|
return [id.slice(0, index), id.slice(index + this.separator.length)];
|
|
46566
47503
|
}
|
|
46567
47504
|
languageModel(id) {
|
|
46568
|
-
var
|
|
47505
|
+
var _a222, _b16;
|
|
46569
47506
|
const [providerId, modelId] = this.splitId(id, "languageModel");
|
|
46570
|
-
let model = (_b16 = (
|
|
47507
|
+
let model = (_b16 = (_a222 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a222, modelId);
|
|
46571
47508
|
if (model == null) {
|
|
46572
47509
|
throw new NoSuchModelError({ modelId: id, modelType: "languageModel" });
|
|
46573
47510
|
}
|
|
@@ -46580,10 +47517,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46580
47517
|
return model;
|
|
46581
47518
|
}
|
|
46582
47519
|
embeddingModel(id) {
|
|
46583
|
-
var
|
|
47520
|
+
var _a222;
|
|
46584
47521
|
const [providerId, modelId] = this.splitId(id, "embeddingModel");
|
|
46585
47522
|
const provider = this.getProvider(providerId, "embeddingModel");
|
|
46586
|
-
const model = (
|
|
47523
|
+
const model = (_a222 = provider.embeddingModel) == null ? undefined : _a222.call(provider, modelId);
|
|
46587
47524
|
if (model == null) {
|
|
46588
47525
|
throw new NoSuchModelError({
|
|
46589
47526
|
modelId: id,
|
|
@@ -46593,10 +47530,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46593
47530
|
return model;
|
|
46594
47531
|
}
|
|
46595
47532
|
imageModel(id) {
|
|
46596
|
-
var
|
|
47533
|
+
var _a222;
|
|
46597
47534
|
const [providerId, modelId] = this.splitId(id, "imageModel");
|
|
46598
47535
|
const provider = this.getProvider(providerId, "imageModel");
|
|
46599
|
-
let model = (
|
|
47536
|
+
let model = (_a222 = provider.imageModel) == null ? undefined : _a222.call(provider, modelId);
|
|
46600
47537
|
if (model == null) {
|
|
46601
47538
|
throw new NoSuchModelError({ modelId: id, modelType: "imageModel" });
|
|
46602
47539
|
}
|
|
@@ -46609,10 +47546,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46609
47546
|
return model;
|
|
46610
47547
|
}
|
|
46611
47548
|
transcriptionModel(id) {
|
|
46612
|
-
var
|
|
47549
|
+
var _a222;
|
|
46613
47550
|
const [providerId, modelId] = this.splitId(id, "transcriptionModel");
|
|
46614
47551
|
const provider = this.getProvider(providerId, "transcriptionModel");
|
|
46615
|
-
const model = (
|
|
47552
|
+
const model = (_a222 = provider.transcriptionModel) == null ? undefined : _a222.call(provider, modelId);
|
|
46616
47553
|
if (model == null) {
|
|
46617
47554
|
throw new NoSuchModelError({
|
|
46618
47555
|
modelId: id,
|
|
@@ -46622,20 +47559,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46622
47559
|
return model;
|
|
46623
47560
|
}
|
|
46624
47561
|
speechModel(id) {
|
|
46625
|
-
var
|
|
47562
|
+
var _a222;
|
|
46626
47563
|
const [providerId, modelId] = this.splitId(id, "speechModel");
|
|
46627
47564
|
const provider = this.getProvider(providerId, "speechModel");
|
|
46628
|
-
const model = (
|
|
47565
|
+
const model = (_a222 = provider.speechModel) == null ? undefined : _a222.call(provider, modelId);
|
|
46629
47566
|
if (model == null) {
|
|
46630
47567
|
throw new NoSuchModelError({ modelId: id, modelType: "speechModel" });
|
|
46631
47568
|
}
|
|
46632
47569
|
return model;
|
|
46633
47570
|
}
|
|
46634
47571
|
rerankingModel(id) {
|
|
46635
|
-
var
|
|
47572
|
+
var _a222;
|
|
46636
47573
|
const [providerId, modelId] = this.splitId(id, "rerankingModel");
|
|
46637
47574
|
const provider = this.getProvider(providerId, "rerankingModel");
|
|
46638
|
-
const model = (
|
|
47575
|
+
const model = (_a222 = provider.rerankingModel) == null ? undefined : _a222.call(provider, modelId);
|
|
46639
47576
|
if (model == null) {
|
|
46640
47577
|
throw new NoSuchModelError({ modelId: id, modelType: "rerankingModel" });
|
|
46641
47578
|
}
|
|
@@ -46653,14 +47590,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46653
47590
|
}
|
|
46654
47591
|
}, defaultDownload2, DefaultTranscriptionResult = class {
|
|
46655
47592
|
constructor(options) {
|
|
46656
|
-
var
|
|
47593
|
+
var _a222;
|
|
46657
47594
|
this.text = options.text;
|
|
46658
47595
|
this.segments = options.segments;
|
|
46659
47596
|
this.language = options.language;
|
|
46660
47597
|
this.durationInSeconds = options.durationInSeconds;
|
|
46661
47598
|
this.warnings = options.warnings;
|
|
46662
47599
|
this.responses = options.responses;
|
|
46663
|
-
this.providerMetadata = (
|
|
47600
|
+
this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
|
|
46664
47601
|
}
|
|
46665
47602
|
}, getOriginalFetch3 = () => fetch, HttpChatTransport = class {
|
|
46666
47603
|
constructor({
|
|
@@ -46684,7 +47621,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46684
47621
|
abortSignal,
|
|
46685
47622
|
...options
|
|
46686
47623
|
}) {
|
|
46687
|
-
var
|
|
47624
|
+
var _a222, _b16, _c, _d, _e;
|
|
46688
47625
|
const resolvedBody = await resolve3(this.body);
|
|
46689
47626
|
const resolvedHeaders = await resolve3(this.headers);
|
|
46690
47627
|
const resolvedCredentials = await resolve3(this.credentials);
|
|
@@ -46692,7 +47629,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46692
47629
|
...normalizeHeaders(resolvedHeaders),
|
|
46693
47630
|
...normalizeHeaders(options.headers)
|
|
46694
47631
|
};
|
|
46695
|
-
const preparedRequest = await ((
|
|
47632
|
+
const preparedRequest = await ((_a222 = this.prepareSendMessagesRequest) == null ? undefined : _a222.call(this, {
|
|
46696
47633
|
api: this.api,
|
|
46697
47634
|
id: options.chatId,
|
|
46698
47635
|
messages: options.messages,
|
|
@@ -46734,7 +47671,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46734
47671
|
return this.processResponseStream(response.body);
|
|
46735
47672
|
}
|
|
46736
47673
|
async reconnectToStream(options) {
|
|
46737
|
-
var
|
|
47674
|
+
var _a222, _b16, _c, _d, _e;
|
|
46738
47675
|
const resolvedBody = await resolve3(this.body);
|
|
46739
47676
|
const resolvedHeaders = await resolve3(this.headers);
|
|
46740
47677
|
const resolvedCredentials = await resolve3(this.credentials);
|
|
@@ -46742,7 +47679,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46742
47679
|
...normalizeHeaders(resolvedHeaders),
|
|
46743
47680
|
...normalizeHeaders(options.headers)
|
|
46744
47681
|
};
|
|
46745
|
-
const preparedRequest = await ((
|
|
47682
|
+
const preparedRequest = await ((_a222 = this.prepareReconnectToStreamRequest) == null ? undefined : _a222.call(this, {
|
|
46746
47683
|
api: this.api,
|
|
46747
47684
|
id: options.chatId,
|
|
46748
47685
|
body: { ...resolvedBody, ...options.body },
|
|
@@ -46787,11 +47724,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46787
47724
|
this.activeResponse = undefined;
|
|
46788
47725
|
this.jobExecutor = new SerialJobExecutor;
|
|
46789
47726
|
this.sendMessage = async (message, options) => {
|
|
46790
|
-
var
|
|
47727
|
+
var _a222, _b16, _c, _d;
|
|
46791
47728
|
if (message == null) {
|
|
46792
47729
|
await this.makeRequest({
|
|
46793
47730
|
trigger: "submit-message",
|
|
46794
|
-
messageId: (
|
|
47731
|
+
messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
|
|
46795
47732
|
...options
|
|
46796
47733
|
});
|
|
46797
47734
|
return;
|
|
@@ -46883,11 +47820,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46883
47820
|
}
|
|
46884
47821
|
if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
|
|
46885
47822
|
this.shouldSendAutomatically().then((shouldSend) => {
|
|
46886
|
-
var
|
|
47823
|
+
var _a222;
|
|
46887
47824
|
if (shouldSend) {
|
|
46888
47825
|
this.makeRequest({
|
|
46889
47826
|
trigger: "submit-message",
|
|
46890
|
-
messageId: (
|
|
47827
|
+
messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
|
|
46891
47828
|
...options
|
|
46892
47829
|
});
|
|
46893
47830
|
}
|
|
@@ -46913,11 +47850,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46913
47850
|
}
|
|
46914
47851
|
if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
|
|
46915
47852
|
this.shouldSendAutomatically().then((shouldSend) => {
|
|
46916
|
-
var
|
|
47853
|
+
var _a222;
|
|
46917
47854
|
if (shouldSend) {
|
|
46918
47855
|
this.makeRequest({
|
|
46919
47856
|
trigger: "submit-message",
|
|
46920
|
-
messageId: (
|
|
47857
|
+
messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
|
|
46921
47858
|
...options
|
|
46922
47859
|
});
|
|
46923
47860
|
}
|
|
@@ -46926,10 +47863,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46926
47863
|
});
|
|
46927
47864
|
this.addToolResult = this.addToolOutput;
|
|
46928
47865
|
this.stop = async () => {
|
|
46929
|
-
var
|
|
47866
|
+
var _a222;
|
|
46930
47867
|
if (this.status !== "streaming" && this.status !== "submitted")
|
|
46931
47868
|
return;
|
|
46932
|
-
if ((
|
|
47869
|
+
if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
|
|
46933
47870
|
this.activeResponse.abortController.abort();
|
|
46934
47871
|
}
|
|
46935
47872
|
};
|
|
@@ -46987,7 +47924,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
46987
47924
|
body,
|
|
46988
47925
|
messageId
|
|
46989
47926
|
}) {
|
|
46990
|
-
var
|
|
47927
|
+
var _a222, _b16, _c;
|
|
46991
47928
|
let resumeStream;
|
|
46992
47929
|
if (trigger === "resume-stream") {
|
|
46993
47930
|
try {
|
|
@@ -47044,9 +47981,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
47044
47981
|
const runUpdateMessageJob = (job) => this.jobExecutor.run(() => job({
|
|
47045
47982
|
state: activeResponse.state,
|
|
47046
47983
|
write: () => {
|
|
47047
|
-
var
|
|
47984
|
+
var _a232;
|
|
47048
47985
|
this.setStatus({ status: "streaming" });
|
|
47049
|
-
const replaceLastMessage = activeResponse.state.message.id === ((
|
|
47986
|
+
const replaceLastMessage = activeResponse.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
47050
47987
|
if (replaceLastMessage) {
|
|
47051
47988
|
this.state.replaceMessage(this.state.messages.length - 1, activeResponse.state.message);
|
|
47052
47989
|
} else {
|
|
@@ -47093,7 +48030,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
47093
48030
|
isAbort,
|
|
47094
48031
|
isDisconnect,
|
|
47095
48032
|
isError,
|
|
47096
|
-
finishReason: (
|
|
48033
|
+
finishReason: (_a222 = this.activeResponse) == null ? undefined : _a222.state.finishReason
|
|
47097
48034
|
});
|
|
47098
48035
|
} catch (err) {
|
|
47099
48036
|
console.error(err);
|
|
@@ -47167,6 +48104,7 @@ var init_dist8 = __esm(() => {
|
|
|
47167
48104
|
init_dist();
|
|
47168
48105
|
init_dist();
|
|
47169
48106
|
init_dist();
|
|
48107
|
+
init_dist();
|
|
47170
48108
|
init_dist3();
|
|
47171
48109
|
init_dist();
|
|
47172
48110
|
init_dist7();
|
|
@@ -47192,6 +48130,8 @@ var init_dist8 = __esm(() => {
|
|
|
47192
48130
|
init_dist3();
|
|
47193
48131
|
init_dist3();
|
|
47194
48132
|
init_dist3();
|
|
48133
|
+
init_dist3();
|
|
48134
|
+
init_dist3();
|
|
47195
48135
|
init_dist();
|
|
47196
48136
|
init_dist3();
|
|
47197
48137
|
init_dist3();
|
|
@@ -47287,6 +48227,27 @@ var init_dist8 = __esm(() => {
|
|
|
47287
48227
|
_a33 = symbol33;
|
|
47288
48228
|
marker43 = `vercel.ai.error.${name43}`;
|
|
47289
48229
|
symbol43 = Symbol.for(marker43);
|
|
48230
|
+
InvalidToolApprovalSignatureError = class extends AISDKError {
|
|
48231
|
+
constructor({
|
|
48232
|
+
approvalId,
|
|
48233
|
+
toolCallId,
|
|
48234
|
+
reason
|
|
48235
|
+
}) {
|
|
48236
|
+
super({
|
|
48237
|
+
name: name43,
|
|
48238
|
+
message: `Tool approval signature verification failed for approval "${approvalId}" (tool call "${toolCallId}"): ${reason}`
|
|
48239
|
+
});
|
|
48240
|
+
this[_a43] = true;
|
|
48241
|
+
this.approvalId = approvalId;
|
|
48242
|
+
this.toolCallId = toolCallId;
|
|
48243
|
+
}
|
|
48244
|
+
static isInstance(error40) {
|
|
48245
|
+
return AISDKError.hasMarker(error40, marker43);
|
|
48246
|
+
}
|
|
48247
|
+
};
|
|
48248
|
+
_a43 = symbol43;
|
|
48249
|
+
marker53 = `vercel.ai.error.${name53}`;
|
|
48250
|
+
symbol53 = Symbol.for(marker53);
|
|
47290
48251
|
InvalidToolInputError = class extends AISDKError {
|
|
47291
48252
|
constructor({
|
|
47292
48253
|
toolInput,
|
|
@@ -47294,71 +48255,71 @@ var init_dist8 = __esm(() => {
|
|
|
47294
48255
|
cause,
|
|
47295
48256
|
message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
|
|
47296
48257
|
}) {
|
|
47297
|
-
super({ name:
|
|
47298
|
-
this[
|
|
48258
|
+
super({ name: name53, message, cause });
|
|
48259
|
+
this[_a53] = true;
|
|
47299
48260
|
this.toolInput = toolInput;
|
|
47300
48261
|
this.toolName = toolName;
|
|
47301
48262
|
}
|
|
47302
48263
|
static isInstance(error40) {
|
|
47303
|
-
return AISDKError.hasMarker(error40,
|
|
48264
|
+
return AISDKError.hasMarker(error40, marker53);
|
|
47304
48265
|
}
|
|
47305
48266
|
};
|
|
47306
|
-
|
|
47307
|
-
|
|
47308
|
-
|
|
48267
|
+
_a53 = symbol53;
|
|
48268
|
+
marker63 = `vercel.ai.error.${name63}`;
|
|
48269
|
+
symbol63 = Symbol.for(marker63);
|
|
47309
48270
|
ToolCallNotFoundForApprovalError = class extends AISDKError {
|
|
47310
48271
|
constructor({
|
|
47311
48272
|
toolCallId,
|
|
47312
48273
|
approvalId
|
|
47313
48274
|
}) {
|
|
47314
48275
|
super({
|
|
47315
|
-
name:
|
|
48276
|
+
name: name63,
|
|
47316
48277
|
message: `Tool call "${toolCallId}" not found for approval request "${approvalId}".`
|
|
47317
48278
|
});
|
|
47318
|
-
this[
|
|
48279
|
+
this[_a63] = true;
|
|
47319
48280
|
this.toolCallId = toolCallId;
|
|
47320
48281
|
this.approvalId = approvalId;
|
|
47321
48282
|
}
|
|
47322
48283
|
static isInstance(error40) {
|
|
47323
|
-
return AISDKError.hasMarker(error40,
|
|
48284
|
+
return AISDKError.hasMarker(error40, marker63);
|
|
47324
48285
|
}
|
|
47325
48286
|
};
|
|
47326
|
-
|
|
47327
|
-
|
|
47328
|
-
|
|
48287
|
+
_a63 = symbol63;
|
|
48288
|
+
marker73 = `vercel.ai.error.${name73}`;
|
|
48289
|
+
symbol73 = Symbol.for(marker73);
|
|
47329
48290
|
MissingToolResultsError = class extends AISDKError {
|
|
47330
48291
|
constructor({ toolCallIds }) {
|
|
47331
48292
|
super({
|
|
47332
|
-
name:
|
|
48293
|
+
name: name73,
|
|
47333
48294
|
message: `Tool result${toolCallIds.length > 1 ? "s are" : " is"} missing for tool call${toolCallIds.length > 1 ? "s" : ""} ${toolCallIds.join(", ")}.`
|
|
47334
48295
|
});
|
|
47335
|
-
this[
|
|
48296
|
+
this[_a73] = true;
|
|
47336
48297
|
this.toolCallIds = toolCallIds;
|
|
47337
48298
|
}
|
|
47338
48299
|
static isInstance(error40) {
|
|
47339
|
-
return AISDKError.hasMarker(error40,
|
|
48300
|
+
return AISDKError.hasMarker(error40, marker73);
|
|
47340
48301
|
}
|
|
47341
48302
|
};
|
|
47342
|
-
|
|
47343
|
-
|
|
47344
|
-
|
|
48303
|
+
_a73 = symbol73;
|
|
48304
|
+
marker83 = `vercel.ai.error.${name83}`;
|
|
48305
|
+
symbol83 = Symbol.for(marker83);
|
|
47345
48306
|
NoImageGeneratedError = class extends AISDKError {
|
|
47346
48307
|
constructor({
|
|
47347
48308
|
message = "No image generated.",
|
|
47348
48309
|
cause,
|
|
47349
48310
|
responses
|
|
47350
48311
|
}) {
|
|
47351
|
-
super({ name:
|
|
47352
|
-
this[
|
|
48312
|
+
super({ name: name83, message, cause });
|
|
48313
|
+
this[_a83] = true;
|
|
47353
48314
|
this.responses = responses;
|
|
47354
48315
|
}
|
|
47355
48316
|
static isInstance(error40) {
|
|
47356
|
-
return AISDKError.hasMarker(error40,
|
|
48317
|
+
return AISDKError.hasMarker(error40, marker83);
|
|
47357
48318
|
}
|
|
47358
48319
|
};
|
|
47359
|
-
|
|
47360
|
-
|
|
47361
|
-
|
|
48320
|
+
_a83 = symbol83;
|
|
48321
|
+
marker93 = `vercel.ai.error.${name93}`;
|
|
48322
|
+
symbol93 = Symbol.for(marker93);
|
|
47362
48323
|
NoObjectGeneratedError = class extends AISDKError {
|
|
47363
48324
|
constructor({
|
|
47364
48325
|
message = "No object generated.",
|
|
@@ -47368,82 +48329,82 @@ var init_dist8 = __esm(() => {
|
|
|
47368
48329
|
usage,
|
|
47369
48330
|
finishReason
|
|
47370
48331
|
}) {
|
|
47371
|
-
super({ name:
|
|
47372
|
-
this[
|
|
48332
|
+
super({ name: name93, message, cause });
|
|
48333
|
+
this[_a93] = true;
|
|
47373
48334
|
this.text = text2;
|
|
47374
48335
|
this.response = response;
|
|
47375
48336
|
this.usage = usage;
|
|
47376
48337
|
this.finishReason = finishReason;
|
|
47377
48338
|
}
|
|
47378
48339
|
static isInstance(error40) {
|
|
47379
|
-
return AISDKError.hasMarker(error40,
|
|
48340
|
+
return AISDKError.hasMarker(error40, marker93);
|
|
47380
48341
|
}
|
|
47381
48342
|
};
|
|
47382
|
-
|
|
47383
|
-
|
|
47384
|
-
|
|
48343
|
+
_a93 = symbol93;
|
|
48344
|
+
marker103 = `vercel.ai.error.${name102}`;
|
|
48345
|
+
symbol103 = Symbol.for(marker103);
|
|
47385
48346
|
NoOutputGeneratedError = class extends AISDKError {
|
|
47386
48347
|
constructor({
|
|
47387
48348
|
message = "No output generated.",
|
|
47388
48349
|
cause
|
|
47389
48350
|
} = {}) {
|
|
47390
|
-
super({ name:
|
|
47391
|
-
this[
|
|
48351
|
+
super({ name: name102, message, cause });
|
|
48352
|
+
this[_a103] = true;
|
|
47392
48353
|
}
|
|
47393
48354
|
static isInstance(error40) {
|
|
47394
|
-
return AISDKError.hasMarker(error40,
|
|
48355
|
+
return AISDKError.hasMarker(error40, marker103);
|
|
47395
48356
|
}
|
|
47396
48357
|
};
|
|
47397
|
-
|
|
47398
|
-
|
|
47399
|
-
|
|
48358
|
+
_a103 = symbol103;
|
|
48359
|
+
marker112 = `vercel.ai.error.${name112}`;
|
|
48360
|
+
symbol112 = Symbol.for(marker112);
|
|
47400
48361
|
NoSpeechGeneratedError = class extends AISDKError {
|
|
47401
48362
|
constructor(options) {
|
|
47402
48363
|
super({
|
|
47403
|
-
name:
|
|
48364
|
+
name: name112,
|
|
47404
48365
|
message: "No speech audio generated."
|
|
47405
48366
|
});
|
|
47406
|
-
this[
|
|
48367
|
+
this[_a112] = true;
|
|
47407
48368
|
this.responses = options.responses;
|
|
47408
48369
|
}
|
|
47409
48370
|
static isInstance(error40) {
|
|
47410
|
-
return AISDKError.hasMarker(error40,
|
|
48371
|
+
return AISDKError.hasMarker(error40, marker112);
|
|
47411
48372
|
}
|
|
47412
48373
|
};
|
|
47413
|
-
|
|
47414
|
-
|
|
47415
|
-
|
|
48374
|
+
_a112 = symbol112;
|
|
48375
|
+
marker122 = `vercel.ai.error.${name122}`;
|
|
48376
|
+
symbol122 = Symbol.for(marker122);
|
|
47416
48377
|
NoTranscriptGeneratedError = class extends AISDKError {
|
|
47417
48378
|
constructor(options) {
|
|
47418
48379
|
super({
|
|
47419
|
-
name:
|
|
48380
|
+
name: name122,
|
|
47420
48381
|
message: "No transcript generated."
|
|
47421
48382
|
});
|
|
47422
|
-
this[
|
|
48383
|
+
this[_a122] = true;
|
|
47423
48384
|
this.responses = options.responses;
|
|
47424
48385
|
}
|
|
47425
48386
|
static isInstance(error40) {
|
|
47426
|
-
return AISDKError.hasMarker(error40,
|
|
48387
|
+
return AISDKError.hasMarker(error40, marker122);
|
|
47427
48388
|
}
|
|
47428
48389
|
};
|
|
47429
|
-
|
|
47430
|
-
|
|
47431
|
-
|
|
48390
|
+
_a122 = symbol122;
|
|
48391
|
+
marker132 = `vercel.ai.error.${name132}`;
|
|
48392
|
+
symbol132 = Symbol.for(marker132);
|
|
47432
48393
|
NoVideoGeneratedError = class extends AISDKError {
|
|
47433
48394
|
constructor({
|
|
47434
48395
|
message = "No video generated.",
|
|
47435
48396
|
cause,
|
|
47436
48397
|
responses
|
|
47437
48398
|
}) {
|
|
47438
|
-
super({ name:
|
|
47439
|
-
this[
|
|
48399
|
+
super({ name: name132, message, cause });
|
|
48400
|
+
this[_a132] = true;
|
|
47440
48401
|
this.responses = responses;
|
|
47441
48402
|
}
|
|
47442
48403
|
static isInstance(error40) {
|
|
47443
|
-
return AISDKError.hasMarker(error40,
|
|
48404
|
+
return AISDKError.hasMarker(error40, marker132);
|
|
47444
48405
|
}
|
|
47445
48406
|
static isNoVideoGeneratedError(error40) {
|
|
47446
|
-
return error40 instanceof Error && error40.name ===
|
|
48407
|
+
return error40 instanceof Error && error40.name === name132 && typeof error40.responses !== "undefined" ? true : false;
|
|
47447
48408
|
}
|
|
47448
48409
|
toJSON() {
|
|
47449
48410
|
return {
|
|
@@ -47455,42 +48416,42 @@ var init_dist8 = __esm(() => {
|
|
|
47455
48416
|
};
|
|
47456
48417
|
}
|
|
47457
48418
|
};
|
|
47458
|
-
|
|
47459
|
-
|
|
47460
|
-
|
|
48419
|
+
_a132 = symbol132;
|
|
48420
|
+
marker142 = `vercel.ai.error.${name142}`;
|
|
48421
|
+
symbol142 = Symbol.for(marker142);
|
|
47461
48422
|
NoSuchToolError = class extends AISDKError {
|
|
47462
48423
|
constructor({
|
|
47463
48424
|
toolName,
|
|
47464
48425
|
availableTools = undefined,
|
|
47465
48426
|
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
|
47466
48427
|
}) {
|
|
47467
|
-
super({ name:
|
|
47468
|
-
this[
|
|
48428
|
+
super({ name: name142, message });
|
|
48429
|
+
this[_a142] = true;
|
|
47469
48430
|
this.toolName = toolName;
|
|
47470
48431
|
this.availableTools = availableTools;
|
|
47471
48432
|
}
|
|
47472
48433
|
static isInstance(error40) {
|
|
47473
|
-
return AISDKError.hasMarker(error40,
|
|
48434
|
+
return AISDKError.hasMarker(error40, marker142);
|
|
47474
48435
|
}
|
|
47475
48436
|
};
|
|
47476
|
-
|
|
47477
|
-
|
|
47478
|
-
|
|
48437
|
+
_a142 = symbol142;
|
|
48438
|
+
marker152 = `vercel.ai.error.${name15}`;
|
|
48439
|
+
symbol152 = Symbol.for(marker152);
|
|
47479
48440
|
ToolCallRepairError = class extends AISDKError {
|
|
47480
48441
|
constructor({
|
|
47481
48442
|
cause,
|
|
47482
48443
|
originalError,
|
|
47483
48444
|
message = `Error repairing tool call: ${getErrorMessage(cause)}`
|
|
47484
48445
|
}) {
|
|
47485
|
-
super({ name:
|
|
47486
|
-
this[
|
|
48446
|
+
super({ name: name15, message, cause });
|
|
48447
|
+
this[_a152] = true;
|
|
47487
48448
|
this.originalError = originalError;
|
|
47488
48449
|
}
|
|
47489
48450
|
static isInstance(error40) {
|
|
47490
|
-
return AISDKError.hasMarker(error40,
|
|
48451
|
+
return AISDKError.hasMarker(error40, marker152);
|
|
47491
48452
|
}
|
|
47492
48453
|
};
|
|
47493
|
-
|
|
48454
|
+
_a152 = symbol152;
|
|
47494
48455
|
UnsupportedModelVersionError = class extends AISDKError {
|
|
47495
48456
|
constructor(options) {
|
|
47496
48457
|
super({
|
|
@@ -47502,92 +48463,92 @@ var init_dist8 = __esm(() => {
|
|
|
47502
48463
|
this.modelId = options.modelId;
|
|
47503
48464
|
}
|
|
47504
48465
|
};
|
|
47505
|
-
|
|
47506
|
-
|
|
48466
|
+
marker16 = `vercel.ai.error.${name162}`;
|
|
48467
|
+
symbol16 = Symbol.for(marker16);
|
|
47507
48468
|
UIMessageStreamError = class extends AISDKError {
|
|
47508
48469
|
constructor({
|
|
47509
48470
|
chunkType,
|
|
47510
48471
|
chunkId,
|
|
47511
48472
|
message
|
|
47512
48473
|
}) {
|
|
47513
|
-
super({ name:
|
|
47514
|
-
this[
|
|
48474
|
+
super({ name: name162, message });
|
|
48475
|
+
this[_a16] = true;
|
|
47515
48476
|
this.chunkType = chunkType;
|
|
47516
48477
|
this.chunkId = chunkId;
|
|
47517
48478
|
}
|
|
47518
48479
|
static isInstance(error40) {
|
|
47519
|
-
return AISDKError.hasMarker(error40,
|
|
48480
|
+
return AISDKError.hasMarker(error40, marker16);
|
|
47520
48481
|
}
|
|
47521
48482
|
};
|
|
47522
|
-
|
|
47523
|
-
|
|
47524
|
-
|
|
48483
|
+
_a16 = symbol16;
|
|
48484
|
+
marker172 = `vercel.ai.error.${name172}`;
|
|
48485
|
+
symbol172 = Symbol.for(marker172);
|
|
47525
48486
|
InvalidDataContentError = class extends AISDKError {
|
|
47526
48487
|
constructor({
|
|
47527
48488
|
content,
|
|
47528
48489
|
cause,
|
|
47529
48490
|
message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
|
|
47530
48491
|
}) {
|
|
47531
|
-
super({ name:
|
|
47532
|
-
this[
|
|
48492
|
+
super({ name: name172, message, cause });
|
|
48493
|
+
this[_a172] = true;
|
|
47533
48494
|
this.content = content;
|
|
47534
48495
|
}
|
|
47535
48496
|
static isInstance(error40) {
|
|
47536
|
-
return AISDKError.hasMarker(error40,
|
|
48497
|
+
return AISDKError.hasMarker(error40, marker172);
|
|
47537
48498
|
}
|
|
47538
48499
|
};
|
|
47539
|
-
|
|
47540
|
-
|
|
47541
|
-
|
|
48500
|
+
_a172 = symbol172;
|
|
48501
|
+
marker182 = `vercel.ai.error.${name18}`;
|
|
48502
|
+
symbol182 = Symbol.for(marker182);
|
|
47542
48503
|
InvalidMessageRoleError = class extends AISDKError {
|
|
47543
48504
|
constructor({
|
|
47544
48505
|
role,
|
|
47545
48506
|
message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
|
|
47546
48507
|
}) {
|
|
47547
|
-
super({ name:
|
|
47548
|
-
this[
|
|
48508
|
+
super({ name: name18, message });
|
|
48509
|
+
this[_a182] = true;
|
|
47549
48510
|
this.role = role;
|
|
47550
48511
|
}
|
|
47551
48512
|
static isInstance(error40) {
|
|
47552
|
-
return AISDKError.hasMarker(error40,
|
|
48513
|
+
return AISDKError.hasMarker(error40, marker182);
|
|
47553
48514
|
}
|
|
47554
48515
|
};
|
|
47555
|
-
|
|
47556
|
-
|
|
47557
|
-
|
|
48516
|
+
_a182 = symbol182;
|
|
48517
|
+
marker19 = `vercel.ai.error.${name19}`;
|
|
48518
|
+
symbol192 = Symbol.for(marker19);
|
|
47558
48519
|
MessageConversionError = class extends AISDKError {
|
|
47559
48520
|
constructor({
|
|
47560
48521
|
originalMessage,
|
|
47561
48522
|
message
|
|
47562
48523
|
}) {
|
|
47563
|
-
super({ name:
|
|
47564
|
-
this[
|
|
48524
|
+
super({ name: name19, message });
|
|
48525
|
+
this[_a19] = true;
|
|
47565
48526
|
this.originalMessage = originalMessage;
|
|
47566
48527
|
}
|
|
47567
48528
|
static isInstance(error40) {
|
|
47568
|
-
return AISDKError.hasMarker(error40,
|
|
48529
|
+
return AISDKError.hasMarker(error40, marker19);
|
|
47569
48530
|
}
|
|
47570
48531
|
};
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
48532
|
+
_a19 = symbol192;
|
|
48533
|
+
marker20 = `vercel.ai.error.${name20}`;
|
|
48534
|
+
symbol20 = Symbol.for(marker20);
|
|
47574
48535
|
RetryError = class extends AISDKError {
|
|
47575
48536
|
constructor({
|
|
47576
48537
|
message,
|
|
47577
48538
|
reason,
|
|
47578
48539
|
errors: errors4
|
|
47579
48540
|
}) {
|
|
47580
|
-
super({ name:
|
|
47581
|
-
this[
|
|
48541
|
+
super({ name: name20, message });
|
|
48542
|
+
this[_a20] = true;
|
|
47582
48543
|
this.reason = reason;
|
|
47583
48544
|
this.errors = errors4;
|
|
47584
48545
|
this.lastError = errors4[errors4.length - 1];
|
|
47585
48546
|
}
|
|
47586
48547
|
static isInstance(error40) {
|
|
47587
|
-
return AISDKError.hasMarker(error40,
|
|
48548
|
+
return AISDKError.hasMarker(error40, marker20);
|
|
47588
48549
|
}
|
|
47589
48550
|
};
|
|
47590
|
-
|
|
48551
|
+
_a20 = symbol20;
|
|
47591
48552
|
imageMediaTypeSignatures = [
|
|
47592
48553
|
{
|
|
47593
48554
|
mediaType: "image/gif",
|
|
@@ -47771,8 +48732,8 @@ var init_dist8 = __esm(() => {
|
|
|
47771
48732
|
exports_external2.instanceof(Uint8Array),
|
|
47772
48733
|
exports_external2.instanceof(ArrayBuffer),
|
|
47773
48734
|
exports_external2.custom((value) => {
|
|
47774
|
-
var
|
|
47775
|
-
return (_b16 = (
|
|
48735
|
+
var _a222, _b16;
|
|
48736
|
+
return (_b16 = (_a222 = globalThis.Buffer) == null ? undefined : _a222.isBuffer(value)) != null ? _b16 : false;
|
|
47776
48737
|
}, { message: "Must be a Buffer" })
|
|
47777
48738
|
]);
|
|
47778
48739
|
jsonValueSchema3 = exports_external2.lazy(() => exports_external2.union([
|
|
@@ -47955,7 +48916,7 @@ var init_dist8 = __esm(() => {
|
|
|
47955
48916
|
startSpan() {
|
|
47956
48917
|
return noopSpan;
|
|
47957
48918
|
},
|
|
47958
|
-
startActiveSpan(
|
|
48919
|
+
startActiveSpan(name222, arg1, arg2, arg3) {
|
|
47959
48920
|
if (typeof arg1 === "function") {
|
|
47960
48921
|
return arg1(noopSpan);
|
|
47961
48922
|
}
|
|
@@ -48013,6 +48974,7 @@ var init_dist8 = __esm(() => {
|
|
|
48013
48974
|
this.type = "file";
|
|
48014
48975
|
}
|
|
48015
48976
|
};
|
|
48977
|
+
encoder = new TextEncoder;
|
|
48016
48978
|
output_exports = {};
|
|
48017
48979
|
__export2(output_exports, {
|
|
48018
48980
|
array: () => array2,
|
|
@@ -48111,7 +49073,8 @@ var init_dist8 = __esm(() => {
|
|
|
48111
49073
|
exports_external2.strictObject({
|
|
48112
49074
|
type: exports_external2.literal("tool-approval-request"),
|
|
48113
49075
|
approvalId: exports_external2.string(),
|
|
48114
|
-
toolCallId: exports_external2.string()
|
|
49076
|
+
toolCallId: exports_external2.string(),
|
|
49077
|
+
signature: exports_external2.string().optional()
|
|
48115
49078
|
}),
|
|
48116
49079
|
exports_external2.strictObject({
|
|
48117
49080
|
type: exports_external2.literal("tool-output-available"),
|
|
@@ -48217,6 +49180,28 @@ var init_dist8 = __esm(() => {
|
|
|
48217
49180
|
prefix: "aitxt",
|
|
48218
49181
|
size: 24
|
|
48219
49182
|
});
|
|
49183
|
+
isOutputChunkType = {
|
|
49184
|
+
file: true,
|
|
49185
|
+
source: true,
|
|
49186
|
+
"text-start": true,
|
|
49187
|
+
"text-end": true,
|
|
49188
|
+
"text-delta": true,
|
|
49189
|
+
"reasoning-start": true,
|
|
49190
|
+
"reasoning-end": true,
|
|
49191
|
+
"reasoning-delta": true,
|
|
49192
|
+
"tool-input-start": true,
|
|
49193
|
+
"tool-input-end": true,
|
|
49194
|
+
"tool-input-delta": true,
|
|
49195
|
+
"tool-approval-request": true,
|
|
49196
|
+
"tool-call": true,
|
|
49197
|
+
"tool-result": true,
|
|
49198
|
+
"tool-error": true,
|
|
49199
|
+
"stream-start": false,
|
|
49200
|
+
"response-metadata": false,
|
|
49201
|
+
finish: false,
|
|
49202
|
+
error: false,
|
|
49203
|
+
raw: false
|
|
49204
|
+
};
|
|
48220
49205
|
toolMetadataSchema2 = exports_external2.record(exports_external2.string(), jsonValueSchema3.optional());
|
|
48221
49206
|
uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(exports_external2.object({
|
|
48222
49207
|
id: exports_external2.string(),
|
|
@@ -48305,7 +49290,8 @@ var init_dist8 = __esm(() => {
|
|
|
48305
49290
|
approval: exports_external2.object({
|
|
48306
49291
|
id: exports_external2.string(),
|
|
48307
49292
|
approved: exports_external2.never().optional(),
|
|
48308
|
-
reason: exports_external2.never().optional()
|
|
49293
|
+
reason: exports_external2.never().optional(),
|
|
49294
|
+
signature: exports_external2.string().optional()
|
|
48309
49295
|
})
|
|
48310
49296
|
}),
|
|
48311
49297
|
exports_external2.object({
|
|
@@ -48322,7 +49308,8 @@ var init_dist8 = __esm(() => {
|
|
|
48322
49308
|
approval: exports_external2.object({
|
|
48323
49309
|
id: exports_external2.string(),
|
|
48324
49310
|
approved: exports_external2.boolean(),
|
|
48325
|
-
reason: exports_external2.string().optional()
|
|
49311
|
+
reason: exports_external2.string().optional(),
|
|
49312
|
+
signature: exports_external2.string().optional()
|
|
48326
49313
|
})
|
|
48327
49314
|
}),
|
|
48328
49315
|
exports_external2.object({
|
|
@@ -48341,7 +49328,8 @@ var init_dist8 = __esm(() => {
|
|
|
48341
49328
|
approval: exports_external2.object({
|
|
48342
49329
|
id: exports_external2.string(),
|
|
48343
49330
|
approved: exports_external2.literal(true),
|
|
48344
|
-
reason: exports_external2.string().optional()
|
|
49331
|
+
reason: exports_external2.string().optional(),
|
|
49332
|
+
signature: exports_external2.string().optional()
|
|
48345
49333
|
}).optional()
|
|
48346
49334
|
}),
|
|
48347
49335
|
exports_external2.object({
|
|
@@ -48360,7 +49348,8 @@ var init_dist8 = __esm(() => {
|
|
|
48360
49348
|
approval: exports_external2.object({
|
|
48361
49349
|
id: exports_external2.string(),
|
|
48362
49350
|
approved: exports_external2.literal(true),
|
|
48363
|
-
reason: exports_external2.string().optional()
|
|
49351
|
+
reason: exports_external2.string().optional(),
|
|
49352
|
+
signature: exports_external2.string().optional()
|
|
48364
49353
|
}).optional()
|
|
48365
49354
|
}),
|
|
48366
49355
|
exports_external2.object({
|
|
@@ -48377,7 +49366,8 @@ var init_dist8 = __esm(() => {
|
|
|
48377
49366
|
approval: exports_external2.object({
|
|
48378
49367
|
id: exports_external2.string(),
|
|
48379
49368
|
approved: exports_external2.literal(false),
|
|
48380
|
-
reason: exports_external2.string().optional()
|
|
49369
|
+
reason: exports_external2.string().optional(),
|
|
49370
|
+
signature: exports_external2.string().optional()
|
|
48381
49371
|
})
|
|
48382
49372
|
}),
|
|
48383
49373
|
exports_external2.object({
|
|
@@ -48417,7 +49407,8 @@ var init_dist8 = __esm(() => {
|
|
|
48417
49407
|
approval: exports_external2.object({
|
|
48418
49408
|
id: exports_external2.string(),
|
|
48419
49409
|
approved: exports_external2.never().optional(),
|
|
48420
|
-
reason: exports_external2.never().optional()
|
|
49410
|
+
reason: exports_external2.never().optional(),
|
|
49411
|
+
signature: exports_external2.string().optional()
|
|
48421
49412
|
})
|
|
48422
49413
|
}),
|
|
48423
49414
|
exports_external2.object({
|
|
@@ -48433,7 +49424,8 @@ var init_dist8 = __esm(() => {
|
|
|
48433
49424
|
approval: exports_external2.object({
|
|
48434
49425
|
id: exports_external2.string(),
|
|
48435
49426
|
approved: exports_external2.boolean(),
|
|
48436
|
-
reason: exports_external2.string().optional()
|
|
49427
|
+
reason: exports_external2.string().optional(),
|
|
49428
|
+
signature: exports_external2.string().optional()
|
|
48437
49429
|
})
|
|
48438
49430
|
}),
|
|
48439
49431
|
exports_external2.object({
|
|
@@ -48451,7 +49443,8 @@ var init_dist8 = __esm(() => {
|
|
|
48451
49443
|
approval: exports_external2.object({
|
|
48452
49444
|
id: exports_external2.string(),
|
|
48453
49445
|
approved: exports_external2.literal(true),
|
|
48454
|
-
reason: exports_external2.string().optional()
|
|
49446
|
+
reason: exports_external2.string().optional(),
|
|
49447
|
+
signature: exports_external2.string().optional()
|
|
48455
49448
|
}).optional()
|
|
48456
49449
|
}),
|
|
48457
49450
|
exports_external2.object({
|
|
@@ -48469,7 +49462,8 @@ var init_dist8 = __esm(() => {
|
|
|
48469
49462
|
approval: exports_external2.object({
|
|
48470
49463
|
id: exports_external2.string(),
|
|
48471
49464
|
approved: exports_external2.literal(true),
|
|
48472
|
-
reason: exports_external2.string().optional()
|
|
49465
|
+
reason: exports_external2.string().optional(),
|
|
49466
|
+
signature: exports_external2.string().optional()
|
|
48473
49467
|
}).optional()
|
|
48474
49468
|
}),
|
|
48475
49469
|
exports_external2.object({
|
|
@@ -48485,7 +49479,8 @@ var init_dist8 = __esm(() => {
|
|
|
48485
49479
|
approval: exports_external2.object({
|
|
48486
49480
|
id: exports_external2.string(),
|
|
48487
49481
|
approved: exports_external2.literal(false),
|
|
48488
|
-
reason: exports_external2.string().optional()
|
|
49482
|
+
reason: exports_external2.string().optional(),
|
|
49483
|
+
signature: exports_external2.string().optional()
|
|
48489
49484
|
})
|
|
48490
49485
|
})
|
|
48491
49486
|
])).nonempty("Message must contain at least one part")
|
|
@@ -48546,8 +49541,8 @@ var init_dist8 = __esm(() => {
|
|
|
48546
49541
|
};
|
|
48547
49542
|
defaultDownload = createDownload();
|
|
48548
49543
|
experimental_customProvider = customProvider;
|
|
48549
|
-
|
|
48550
|
-
|
|
49544
|
+
marker21 = `vercel.ai.error.${name21}`;
|
|
49545
|
+
symbol21 = Symbol.for(marker21);
|
|
48551
49546
|
NoSuchProviderError = class extends NoSuchModelError {
|
|
48552
49547
|
constructor({
|
|
48553
49548
|
modelId,
|
|
@@ -48556,16 +49551,16 @@ var init_dist8 = __esm(() => {
|
|
|
48556
49551
|
availableProviders,
|
|
48557
49552
|
message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
|
|
48558
49553
|
}) {
|
|
48559
|
-
super({ errorName:
|
|
48560
|
-
this[
|
|
49554
|
+
super({ errorName: name21, modelId, modelType, message });
|
|
49555
|
+
this[_a21] = true;
|
|
48561
49556
|
this.providerId = providerId;
|
|
48562
49557
|
this.availableProviders = availableProviders;
|
|
48563
49558
|
}
|
|
48564
49559
|
static isInstance(error40) {
|
|
48565
|
-
return AISDKError.hasMarker(error40,
|
|
49560
|
+
return AISDKError.hasMarker(error40, marker21);
|
|
48566
49561
|
}
|
|
48567
49562
|
};
|
|
48568
|
-
|
|
49563
|
+
_a21 = symbol21;
|
|
48569
49564
|
experimental_createProviderRegistry = createProviderRegistry;
|
|
48570
49565
|
defaultDownload2 = createDownload();
|
|
48571
49566
|
DefaultChatTransport = class extends HttpChatTransport {
|