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