@mastra/memory 1.23.0-alpha.3 → 1.23.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-WZKTIB4U.cjs → chunk-42LZUXJ3.cjs} +1942 -1148
- package/dist/chunk-42LZUXJ3.cjs.map +1 -0
- package/dist/{chunk-FNWCP2TI.js → chunk-6ACCFKAN.js} +1942 -1148
- package/dist/chunk-6ACCFKAN.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +47 -47
- package/dist/index.cjs +15 -15
- package/dist/index.js +1 -1
- package/dist/{observational-memory-HZP3D5IO.cjs → observational-memory-2F4GJOP2.cjs} +29 -29
- package/dist/{observational-memory-HZP3D5IO.cjs.map → observational-memory-2F4GJOP2.cjs.map} +1 -1
- package/dist/{observational-memory-GAYCVM5R.js → observational-memory-OJN26RQ4.js} +3 -3
- package/dist/{observational-memory-GAYCVM5R.js.map → observational-memory-OJN26RQ4.js.map} +1 -1
- package/dist/processors/index.cjs +27 -27
- package/dist/processors/index.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-FNWCP2TI.js.map +0 -1
- package/dist/chunk-WZKTIB4U.cjs.map +0 -1
|
@@ -299,10 +299,10 @@ var BUILT_IN_EXTRACTOR_SLUGS = [...BUILT_IN_SLUGS];
|
|
|
299
299
|
function isBuiltInExtractorSlug(slug) {
|
|
300
300
|
return BUILT_IN_SLUGS.has(slug);
|
|
301
301
|
}
|
|
302
|
-
function slugifyExtractorName(
|
|
302
|
+
function slugifyExtractorName(name28) {
|
|
303
303
|
let normalized = "";
|
|
304
304
|
let previousWasSeparator = false;
|
|
305
|
-
for (const char of
|
|
305
|
+
for (const char of name28.trim().toLowerCase()) {
|
|
306
306
|
const code = char.charCodeAt(0);
|
|
307
307
|
const isLetter = code >= 97 && code <= 122;
|
|
308
308
|
const isNumber = code >= 48 && code <= 57;
|
|
@@ -321,9 +321,9 @@ function slugifyExtractorName(name21) {
|
|
|
321
321
|
}
|
|
322
322
|
return normalized.endsWith("-") ? normalized.slice(0, -1) : normalized;
|
|
323
323
|
}
|
|
324
|
-
function assertValidSlug(slug,
|
|
324
|
+
function assertValidSlug(slug, name28) {
|
|
325
325
|
if (!slug) {
|
|
326
|
-
throw new Error(`Extractor name "${
|
|
326
|
+
throw new Error(`Extractor name "${name28}" must produce a non-empty slug.`);
|
|
327
327
|
}
|
|
328
328
|
const first = slug.charCodeAt(0);
|
|
329
329
|
const last = slug.charCodeAt(slug.length - 1);
|
|
@@ -334,7 +334,7 @@ function assertValidSlug(slug, name21) {
|
|
|
334
334
|
return code >= 97 && code <= 122 || code >= 48 && code <= 57 || char === "-";
|
|
335
335
|
});
|
|
336
336
|
if (!startsWithLetter || !endsWithLetterOrNumber || !hasOnlySlugCharacters) {
|
|
337
|
-
throw new Error(`Extractor name "${
|
|
337
|
+
throw new Error(`Extractor name "${name28}" produced invalid slug "${slug}".`);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
var Extractor = class _Extractor {
|
|
@@ -351,20 +351,20 @@ var Extractor = class _Extractor {
|
|
|
351
351
|
instructionsConfig;
|
|
352
352
|
schemaConfig;
|
|
353
353
|
constructor(config, internal = false) {
|
|
354
|
-
const
|
|
354
|
+
const name28 = config.name.trim();
|
|
355
355
|
const instructions = typeof config.instructions === "string" ? config.instructions.trim() : void 0;
|
|
356
|
-
const slug = slugifyExtractorName(
|
|
357
|
-
if (!
|
|
356
|
+
const slug = slugifyExtractorName(name28);
|
|
357
|
+
if (!name28) {
|
|
358
358
|
throw new Error("Extractor name is required.");
|
|
359
359
|
}
|
|
360
360
|
if (instructions !== void 0 && !instructions) {
|
|
361
|
-
throw new Error(`Extractor "${
|
|
361
|
+
throw new Error(`Extractor "${name28}" must include instructions.`);
|
|
362
362
|
}
|
|
363
|
-
assertValidSlug(slug,
|
|
363
|
+
assertValidSlug(slug, name28);
|
|
364
364
|
if (!internal && RESERVED_XML_TAGS.has(slug)) {
|
|
365
365
|
throw new Error(`Extractor slug "${slug}" is reserved by Observational Memory.`);
|
|
366
366
|
}
|
|
367
|
-
this.name =
|
|
367
|
+
this.name = name28;
|
|
368
368
|
this.slug = slug;
|
|
369
369
|
this.instructionsConfig = config.instructions;
|
|
370
370
|
this.schemaConfig = config.schema;
|
|
@@ -1721,13 +1721,13 @@ var ObservationStrategy = class _ObservationStrategy {
|
|
|
1721
1721
|
generateCycleId() {
|
|
1722
1722
|
return crypto.randomUUID();
|
|
1723
1723
|
}
|
|
1724
|
-
async streamMarker(
|
|
1724
|
+
async streamMarker(marker28) {
|
|
1725
1725
|
if (this.opts.writer) {
|
|
1726
|
-
await this.opts.writer.custom({ ...
|
|
1726
|
+
await this.opts.writer.custom({ ...marker28, transient: true }).catch(() => {
|
|
1727
1727
|
});
|
|
1728
1728
|
}
|
|
1729
|
-
const markerThreadId =
|
|
1730
|
-
await this.persistMarkerToStorage(
|
|
1729
|
+
const markerThreadId = marker28.data?.threadId ?? this.opts.threadId;
|
|
1730
|
+
await this.persistMarkerToStorage(marker28, markerThreadId, this.opts.resourceId);
|
|
1731
1731
|
}
|
|
1732
1732
|
getObservationMarkerConfig() {
|
|
1733
1733
|
return {
|
|
@@ -1865,7 +1865,7 @@ ${threadClose}`;
|
|
|
1865
1865
|
* Fetches messages directly from the DB so it works even when
|
|
1866
1866
|
* no MessageList is available (e.g. async buffering ops).
|
|
1867
1867
|
*/
|
|
1868
|
-
async persistMarkerToStorage(
|
|
1868
|
+
async persistMarkerToStorage(marker28, threadId, resourceId) {
|
|
1869
1869
|
try {
|
|
1870
1870
|
const result = await this.storage.listMessages({
|
|
1871
1871
|
threadId,
|
|
@@ -1875,10 +1875,10 @@ ${threadClose}`;
|
|
|
1875
1875
|
const messages = result?.messages ?? [];
|
|
1876
1876
|
for (const msg of messages) {
|
|
1877
1877
|
if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
|
|
1878
|
-
const markerData =
|
|
1879
|
-
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type ===
|
|
1878
|
+
const markerData = marker28.data;
|
|
1879
|
+
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type === marker28.type && p?.data?.cycleId === markerData.cycleId);
|
|
1880
1880
|
if (!alreadyPresent) {
|
|
1881
|
-
msg.content.parts.push(
|
|
1881
|
+
msg.content.parts.push(marker28);
|
|
1882
1882
|
}
|
|
1883
1883
|
await this.messageHistory.persistMessages({
|
|
1884
1884
|
messages: [msg],
|
|
@@ -1896,16 +1896,16 @@ ${threadClose}`;
|
|
|
1896
1896
|
* Persist a marker part on the last assistant message in a MessageList
|
|
1897
1897
|
* AND save the updated message to the DB.
|
|
1898
1898
|
*/
|
|
1899
|
-
async persistMarkerToMessage(
|
|
1899
|
+
async persistMarkerToMessage(marker28, messageList, threadId, resourceId) {
|
|
1900
1900
|
if (!messageList) return;
|
|
1901
1901
|
const allMsgs = messageList.get.all.db();
|
|
1902
1902
|
for (let i = allMsgs.length - 1; i >= 0; i--) {
|
|
1903
1903
|
const msg = allMsgs[i];
|
|
1904
1904
|
if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
|
|
1905
|
-
const markerData =
|
|
1906
|
-
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type ===
|
|
1905
|
+
const markerData = marker28.data;
|
|
1906
|
+
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type === marker28.type && p?.data?.cycleId === markerData.cycleId);
|
|
1907
1907
|
if (!alreadyPresent) {
|
|
1908
|
-
msg.content.parts.push(
|
|
1908
|
+
msg.content.parts.push(marker28);
|
|
1909
1909
|
}
|
|
1910
1910
|
try {
|
|
1911
1911
|
await this.messageHistory.persistMessages({
|
|
@@ -2299,13 +2299,13 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
|
|
|
2299
2299
|
metadata: newMetadata
|
|
2300
2300
|
});
|
|
2301
2301
|
if (shouldUpdateThreadTitle) {
|
|
2302
|
-
const
|
|
2302
|
+
const marker28 = createThreadUpdateMarker({
|
|
2303
2303
|
cycleId: this.cycleId,
|
|
2304
2304
|
threadId,
|
|
2305
2305
|
oldTitle,
|
|
2306
2306
|
newTitle
|
|
2307
2307
|
});
|
|
2308
|
-
await this.streamMarker(
|
|
2308
|
+
await this.streamMarker(marker28);
|
|
2309
2309
|
}
|
|
2310
2310
|
}
|
|
2311
2311
|
}
|
|
@@ -2689,8 +2689,8 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
|
|
|
2689
2689
|
}
|
|
2690
2690
|
}
|
|
2691
2691
|
}
|
|
2692
|
-
for (const
|
|
2693
|
-
await this.streamMarker(
|
|
2692
|
+
for (const marker28 of threadUpdateMarkers) {
|
|
2693
|
+
await this.streamMarker(marker28);
|
|
2694
2694
|
}
|
|
2695
2695
|
await this.storage.updateActiveObservations({
|
|
2696
2696
|
id: record.id,
|
|
@@ -4884,7 +4884,7 @@ async function withRetry(fn, opts) {
|
|
|
4884
4884
|
}
|
|
4885
4885
|
}
|
|
4886
4886
|
|
|
4887
|
-
// ../_vendored/ai_v4/dist/chunk-
|
|
4887
|
+
// ../_vendored/ai_v4/dist/chunk-SJKFJOR6.js
|
|
4888
4888
|
var __create = Object.create;
|
|
4889
4889
|
var __defProp = Object.defineProperty;
|
|
4890
4890
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7392,15 +7392,15 @@ var DiagAPI = (
|
|
|
7392
7392
|
return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
|
|
7393
7393
|
};
|
|
7394
7394
|
}
|
|
7395
|
-
var
|
|
7395
|
+
var self2 = this;
|
|
7396
7396
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
7397
7397
|
var _a173, _b19, _c;
|
|
7398
7398
|
if (optionsOrLogLevel === void 0) {
|
|
7399
7399
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
7400
7400
|
}
|
|
7401
|
-
if (logger ===
|
|
7401
|
+
if (logger === self2) {
|
|
7402
7402
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
7403
|
-
|
|
7403
|
+
self2.error((_a173 = err.stack) !== null && _a173 !== void 0 ? _a173 : err.message);
|
|
7404
7404
|
return false;
|
|
7405
7405
|
}
|
|
7406
7406
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -7415,20 +7415,20 @@ var DiagAPI = (
|
|
|
7415
7415
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
7416
7416
|
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
7417
7417
|
}
|
|
7418
|
-
return registerGlobal("diag", newLogger,
|
|
7418
|
+
return registerGlobal("diag", newLogger, self2, true);
|
|
7419
7419
|
};
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
unregisterGlobal(API_NAME,
|
|
7420
|
+
self2.setLogger = setLogger;
|
|
7421
|
+
self2.disable = function() {
|
|
7422
|
+
unregisterGlobal(API_NAME, self2);
|
|
7423
7423
|
};
|
|
7424
|
-
|
|
7424
|
+
self2.createComponentLogger = function(options) {
|
|
7425
7425
|
return new DiagComponentLogger(options);
|
|
7426
7426
|
};
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7427
|
+
self2.verbose = _logProxy("verbose");
|
|
7428
|
+
self2.debug = _logProxy("debug");
|
|
7429
|
+
self2.info = _logProxy("info");
|
|
7430
|
+
self2.warn = _logProxy("warn");
|
|
7431
|
+
self2.error = _logProxy("error");
|
|
7432
7432
|
}
|
|
7433
7433
|
DiagAPI22.instance = function() {
|
|
7434
7434
|
if (!this._instance) {
|
|
@@ -7446,18 +7446,18 @@ var BaseContext = (
|
|
|
7446
7446
|
/** @class */
|
|
7447
7447
|
/* @__PURE__ */ (function() {
|
|
7448
7448
|
function BaseContext22(parentContext) {
|
|
7449
|
-
var
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
return
|
|
7449
|
+
var self2 = this;
|
|
7450
|
+
self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
7451
|
+
self2.getValue = function(key) {
|
|
7452
|
+
return self2._currentContext.get(key);
|
|
7453
7453
|
};
|
|
7454
|
-
|
|
7455
|
-
var context2 = new BaseContext22(
|
|
7454
|
+
self2.setValue = function(key, value) {
|
|
7455
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
7456
7456
|
context2._currentContext.set(key, value);
|
|
7457
7457
|
return context2;
|
|
7458
7458
|
};
|
|
7459
|
-
|
|
7460
|
-
var context2 = new BaseContext22(
|
|
7459
|
+
self2.deleteValue = function(key) {
|
|
7460
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
7461
7461
|
context2._currentContext.delete(key);
|
|
7462
7462
|
return context2;
|
|
7463
7463
|
};
|
|
@@ -9378,6 +9378,90 @@ function createAbortError() {
|
|
|
9378
9378
|
function extractResponseHeaders(response) {
|
|
9379
9379
|
return Object.fromEntries([...response.headers]);
|
|
9380
9380
|
}
|
|
9381
|
+
var name142 = "AI_DownloadError";
|
|
9382
|
+
var marker152 = `vercel.ai.error.${name142}`;
|
|
9383
|
+
var symbol152 = Symbol.for(marker152);
|
|
9384
|
+
var _a152;
|
|
9385
|
+
var _b15;
|
|
9386
|
+
var DownloadError = class extends (_b15 = AISDKError2, _a152 = symbol152, _b15) {
|
|
9387
|
+
constructor({
|
|
9388
|
+
url,
|
|
9389
|
+
statusCode,
|
|
9390
|
+
statusText,
|
|
9391
|
+
cause,
|
|
9392
|
+
message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
|
|
9393
|
+
}) {
|
|
9394
|
+
super({ name: name142, message, cause });
|
|
9395
|
+
this[_a152] = true;
|
|
9396
|
+
this.url = url;
|
|
9397
|
+
this.statusCode = statusCode;
|
|
9398
|
+
this.statusText = statusText;
|
|
9399
|
+
}
|
|
9400
|
+
static isInstance(error) {
|
|
9401
|
+
return AISDKError2.hasMarker(error, marker152);
|
|
9402
|
+
}
|
|
9403
|
+
};
|
|
9404
|
+
async function cancelResponseBody(response) {
|
|
9405
|
+
var _a223;
|
|
9406
|
+
try {
|
|
9407
|
+
await ((_a223 = response.body) == null ? void 0 : _a223.cancel());
|
|
9408
|
+
} catch (e) {
|
|
9409
|
+
}
|
|
9410
|
+
}
|
|
9411
|
+
var DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
|
|
9412
|
+
async function readResponseWithSizeLimit({
|
|
9413
|
+
response,
|
|
9414
|
+
url,
|
|
9415
|
+
maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
|
|
9416
|
+
}) {
|
|
9417
|
+
const contentLength = response.headers.get("content-length");
|
|
9418
|
+
if (contentLength != null) {
|
|
9419
|
+
const length = parseInt(contentLength, 10);
|
|
9420
|
+
if (!isNaN(length) && length > maxBytes) {
|
|
9421
|
+
await cancelResponseBody(response);
|
|
9422
|
+
throw new DownloadError({
|
|
9423
|
+
url,
|
|
9424
|
+
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
9425
|
+
});
|
|
9426
|
+
}
|
|
9427
|
+
}
|
|
9428
|
+
const body = response.body;
|
|
9429
|
+
if (body == null) {
|
|
9430
|
+
return new Uint8Array(0);
|
|
9431
|
+
}
|
|
9432
|
+
const reader = body.getReader();
|
|
9433
|
+
const chunks = [];
|
|
9434
|
+
let totalBytes = 0;
|
|
9435
|
+
try {
|
|
9436
|
+
while (true) {
|
|
9437
|
+
const { done, value } = await reader.read();
|
|
9438
|
+
if (done) {
|
|
9439
|
+
break;
|
|
9440
|
+
}
|
|
9441
|
+
totalBytes += value.length;
|
|
9442
|
+
if (totalBytes > maxBytes) {
|
|
9443
|
+
throw new DownloadError({
|
|
9444
|
+
url,
|
|
9445
|
+
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes.`
|
|
9446
|
+
});
|
|
9447
|
+
}
|
|
9448
|
+
chunks.push(value);
|
|
9449
|
+
}
|
|
9450
|
+
} finally {
|
|
9451
|
+
try {
|
|
9452
|
+
await reader.cancel();
|
|
9453
|
+
} finally {
|
|
9454
|
+
reader.releaseLock();
|
|
9455
|
+
}
|
|
9456
|
+
}
|
|
9457
|
+
const result = new Uint8Array(totalBytes);
|
|
9458
|
+
let offset = 0;
|
|
9459
|
+
for (const chunk of chunks) {
|
|
9460
|
+
result.set(chunk, offset);
|
|
9461
|
+
offset += chunk.length;
|
|
9462
|
+
}
|
|
9463
|
+
return result;
|
|
9464
|
+
}
|
|
9381
9465
|
var createIdGenerator2 = ({
|
|
9382
9466
|
prefix,
|
|
9383
9467
|
size = 16,
|
|
@@ -9445,11 +9529,11 @@ function handleFetchError({
|
|
|
9445
9529
|
return error;
|
|
9446
9530
|
}
|
|
9447
9531
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
9448
|
-
var
|
|
9532
|
+
var _a223, _b222, _c;
|
|
9449
9533
|
if (globalThisAny.window) {
|
|
9450
9534
|
return `runtime/browser`;
|
|
9451
9535
|
}
|
|
9452
|
-
if ((
|
|
9536
|
+
if ((_a223 = globalThisAny.navigator) == null ? void 0 : _a223.userAgent) {
|
|
9453
9537
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
9454
9538
|
}
|
|
9455
9539
|
if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
|
|
@@ -9490,7 +9574,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
9490
9574
|
);
|
|
9491
9575
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9492
9576
|
}
|
|
9493
|
-
var VERSION2 = "3.0.
|
|
9577
|
+
var VERSION2 = "3.0.28";
|
|
9494
9578
|
var getOriginalFetch = () => globalThis.fetch;
|
|
9495
9579
|
var getFromApi = async ({
|
|
9496
9580
|
url,
|
|
@@ -9837,7 +9921,7 @@ function tool(tool22) {
|
|
|
9837
9921
|
}
|
|
9838
9922
|
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
9839
9923
|
id,
|
|
9840
|
-
name:
|
|
9924
|
+
name: name223,
|
|
9841
9925
|
inputSchema,
|
|
9842
9926
|
outputSchema: outputSchema3
|
|
9843
9927
|
}) {
|
|
@@ -9851,7 +9935,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
9851
9935
|
}) => tool({
|
|
9852
9936
|
type: "provider-defined",
|
|
9853
9937
|
id,
|
|
9854
|
-
name:
|
|
9938
|
+
name: name223,
|
|
9855
9939
|
args,
|
|
9856
9940
|
inputSchema,
|
|
9857
9941
|
outputSchema: outputSchema3,
|
|
@@ -9868,12 +9952,24 @@ async function resolve(value) {
|
|
|
9868
9952
|
}
|
|
9869
9953
|
return Promise.resolve(value);
|
|
9870
9954
|
}
|
|
9955
|
+
var textDecoder = new TextDecoder();
|
|
9956
|
+
async function readResponseBodyAsText({
|
|
9957
|
+
response,
|
|
9958
|
+
url
|
|
9959
|
+
}) {
|
|
9960
|
+
return textDecoder.decode(
|
|
9961
|
+
await readResponseWithSizeLimit({
|
|
9962
|
+
response,
|
|
9963
|
+
url
|
|
9964
|
+
})
|
|
9965
|
+
);
|
|
9966
|
+
}
|
|
9871
9967
|
var createJsonErrorResponseHandler = ({
|
|
9872
9968
|
errorSchema,
|
|
9873
9969
|
errorToMessage,
|
|
9874
9970
|
isRetryable
|
|
9875
9971
|
}) => async ({ response, url, requestBodyValues }) => {
|
|
9876
|
-
const responseBody = await response
|
|
9972
|
+
const responseBody = await readResponseBodyAsText({ response, url });
|
|
9877
9973
|
const responseHeaders = extractResponseHeaders(response);
|
|
9878
9974
|
if (responseBody.trim() === "") {
|
|
9879
9975
|
return {
|
|
@@ -9936,7 +10032,7 @@ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) =>
|
|
|
9936
10032
|
};
|
|
9937
10033
|
};
|
|
9938
10034
|
var createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
|
|
9939
|
-
const responseBody = await response
|
|
10035
|
+
const responseBody = await readResponseBodyAsText({ response, url });
|
|
9940
10036
|
const parsedResult = await safeParseJSON2({
|
|
9941
10037
|
text: responseBody,
|
|
9942
10038
|
schema: responseSchema
|
|
@@ -10046,11 +10142,11 @@ function parseAnyDef2() {
|
|
|
10046
10142
|
return {};
|
|
10047
10143
|
}
|
|
10048
10144
|
function parseArrayDef2(def, refs) {
|
|
10049
|
-
var
|
|
10145
|
+
var _a223, _b222, _c;
|
|
10050
10146
|
const res = {
|
|
10051
10147
|
type: "array"
|
|
10052
10148
|
};
|
|
10053
|
-
if (((
|
|
10149
|
+
if (((_a223 = def.type) == null ? void 0 : _a223._def) && ((_c = (_b222 = def.type) == null ? void 0 : _b222._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
10054
10150
|
res.items = parseDef2(def.type._def, {
|
|
10055
10151
|
...refs,
|
|
10056
10152
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -10409,8 +10505,8 @@ function escapeNonAlphaNumeric2(source) {
|
|
|
10409
10505
|
return result;
|
|
10410
10506
|
}
|
|
10411
10507
|
function addFormat2(schema, value, message, refs) {
|
|
10412
|
-
var
|
|
10413
|
-
if (schema.format || ((
|
|
10508
|
+
var _a223;
|
|
10509
|
+
if (schema.format || ((_a223 = schema.anyOf) == null ? void 0 : _a223.some((x) => x.format))) {
|
|
10414
10510
|
if (!schema.anyOf) {
|
|
10415
10511
|
schema.anyOf = [];
|
|
10416
10512
|
}
|
|
@@ -10429,8 +10525,8 @@ function addFormat2(schema, value, message, refs) {
|
|
|
10429
10525
|
}
|
|
10430
10526
|
}
|
|
10431
10527
|
function addPattern2(schema, regex, message, refs) {
|
|
10432
|
-
var
|
|
10433
|
-
if (schema.pattern || ((
|
|
10528
|
+
var _a223;
|
|
10529
|
+
if (schema.pattern || ((_a223 = schema.allOf) == null ? void 0 : _a223.some((x) => x.pattern))) {
|
|
10434
10530
|
if (!schema.allOf) {
|
|
10435
10531
|
schema.allOf = [];
|
|
10436
10532
|
}
|
|
@@ -10449,7 +10545,7 @@ function addPattern2(schema, regex, message, refs) {
|
|
|
10449
10545
|
}
|
|
10450
10546
|
}
|
|
10451
10547
|
function stringifyRegExpWithFlags2(regex, refs) {
|
|
10452
|
-
var
|
|
10548
|
+
var _a223;
|
|
10453
10549
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
10454
10550
|
return regex.source;
|
|
10455
10551
|
}
|
|
@@ -10479,7 +10575,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
10479
10575
|
pattern += source[i];
|
|
10480
10576
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10481
10577
|
inCharRange = false;
|
|
10482
|
-
} else if (source[i + 1] === "-" && ((
|
|
10578
|
+
} else if (source[i + 1] === "-" && ((_a223 = source[i + 2]) == null ? void 0 : _a223.match(/[a-z]/))) {
|
|
10483
10579
|
pattern += source[i];
|
|
10484
10580
|
inCharRange = true;
|
|
10485
10581
|
} else {
|
|
@@ -10521,13 +10617,13 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
10521
10617
|
return pattern;
|
|
10522
10618
|
}
|
|
10523
10619
|
function parseRecordDef2(def, refs) {
|
|
10524
|
-
var
|
|
10620
|
+
var _a223, _b222, _c, _d, _e, _f;
|
|
10525
10621
|
const schema = {
|
|
10526
10622
|
type: "object",
|
|
10527
|
-
additionalProperties: (
|
|
10623
|
+
additionalProperties: (_a223 = parseDef2(def.valueType._def, {
|
|
10528
10624
|
...refs,
|
|
10529
10625
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10530
|
-
})) != null ?
|
|
10626
|
+
})) != null ? _a223 : refs.allowedAdditionalProperties
|
|
10531
10627
|
};
|
|
10532
10628
|
if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
10533
10629
|
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
@@ -10784,8 +10880,8 @@ function safeIsOptional2(schema) {
|
|
|
10784
10880
|
}
|
|
10785
10881
|
}
|
|
10786
10882
|
var parseOptionalDef2 = (def, refs) => {
|
|
10787
|
-
var
|
|
10788
|
-
if (refs.currentPath.toString() === ((
|
|
10883
|
+
var _a223;
|
|
10884
|
+
if (refs.currentPath.toString() === ((_a223 = refs.propertyPath) == null ? void 0 : _a223.toString())) {
|
|
10789
10885
|
return parseDef2(def.innerType._def, refs);
|
|
10790
10886
|
}
|
|
10791
10887
|
const innerSchema = parseDef2(def.innerType._def, {
|
|
@@ -10962,10 +11058,10 @@ var getRelativePath2 = (pathA, pathB) => {
|
|
|
10962
11058
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
10963
11059
|
};
|
|
10964
11060
|
function parseDef2(def, refs, forceResolution = false) {
|
|
10965
|
-
var
|
|
11061
|
+
var _a223;
|
|
10966
11062
|
const seenItem = refs.seen.get(def);
|
|
10967
11063
|
if (refs.override) {
|
|
10968
|
-
const overrideResult = (
|
|
11064
|
+
const overrideResult = (_a223 = refs.override) == null ? void 0 : _a223.call(
|
|
10969
11065
|
refs,
|
|
10970
11066
|
def,
|
|
10971
11067
|
refs,
|
|
@@ -11031,11 +11127,11 @@ var getRefs2 = (options) => {
|
|
|
11031
11127
|
currentPath,
|
|
11032
11128
|
propertyPath: void 0,
|
|
11033
11129
|
seen: new Map(
|
|
11034
|
-
Object.entries(_options.definitions).map(([
|
|
11130
|
+
Object.entries(_options.definitions).map(([name223, def]) => [
|
|
11035
11131
|
def._def,
|
|
11036
11132
|
{
|
|
11037
11133
|
def: def._def,
|
|
11038
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
11134
|
+
path: [..._options.basePath, _options.definitionPath, name223],
|
|
11039
11135
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
11040
11136
|
jsonSchema: void 0
|
|
11041
11137
|
}
|
|
@@ -11044,50 +11140,50 @@ var getRefs2 = (options) => {
|
|
|
11044
11140
|
};
|
|
11045
11141
|
};
|
|
11046
11142
|
var zodToJsonSchema2 = (schema, options) => {
|
|
11047
|
-
var
|
|
11143
|
+
var _a223;
|
|
11048
11144
|
const refs = getRefs2(options);
|
|
11049
11145
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
11050
|
-
(acc, [
|
|
11051
|
-
var
|
|
11146
|
+
(acc, [name323, schema2]) => {
|
|
11147
|
+
var _a323;
|
|
11052
11148
|
return {
|
|
11053
11149
|
...acc,
|
|
11054
|
-
[
|
|
11150
|
+
[name323]: (_a323 = parseDef2(
|
|
11055
11151
|
schema2._def,
|
|
11056
11152
|
{
|
|
11057
11153
|
...refs,
|
|
11058
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
11154
|
+
currentPath: [...refs.basePath, refs.definitionPath, name323]
|
|
11059
11155
|
},
|
|
11060
11156
|
true
|
|
11061
|
-
)) != null ?
|
|
11157
|
+
)) != null ? _a323 : parseAnyDef2()
|
|
11062
11158
|
};
|
|
11063
11159
|
},
|
|
11064
11160
|
{}
|
|
11065
11161
|
) : void 0;
|
|
11066
|
-
const
|
|
11067
|
-
const main = (
|
|
11162
|
+
const name223 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
11163
|
+
const main = (_a223 = parseDef2(
|
|
11068
11164
|
schema._def,
|
|
11069
|
-
|
|
11165
|
+
name223 === void 0 ? refs : {
|
|
11070
11166
|
...refs,
|
|
11071
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
11167
|
+
currentPath: [...refs.basePath, refs.definitionPath, name223]
|
|
11072
11168
|
},
|
|
11073
11169
|
false
|
|
11074
|
-
)) != null ?
|
|
11170
|
+
)) != null ? _a223 : parseAnyDef2();
|
|
11075
11171
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
11076
11172
|
if (title !== void 0) {
|
|
11077
11173
|
main.title = title;
|
|
11078
11174
|
}
|
|
11079
|
-
const combined =
|
|
11175
|
+
const combined = name223 === void 0 ? definitions ? {
|
|
11080
11176
|
...main,
|
|
11081
11177
|
[refs.definitionPath]: definitions
|
|
11082
11178
|
} : main : {
|
|
11083
11179
|
$ref: [
|
|
11084
11180
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
11085
11181
|
refs.definitionPath,
|
|
11086
|
-
|
|
11182
|
+
name223
|
|
11087
11183
|
].join("/"),
|
|
11088
11184
|
[refs.definitionPath]: {
|
|
11089
11185
|
...definitions,
|
|
11090
|
-
[
|
|
11186
|
+
[name223]: main
|
|
11091
11187
|
}
|
|
11092
11188
|
};
|
|
11093
11189
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -11095,8 +11191,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
11095
11191
|
};
|
|
11096
11192
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
11097
11193
|
function zod3Schema(zodSchema22, options) {
|
|
11098
|
-
var
|
|
11099
|
-
const useReferences = (
|
|
11194
|
+
var _a223;
|
|
11195
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
11100
11196
|
return jsonSchema2(
|
|
11101
11197
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
11102
11198
|
() => zod_to_json_schema_default(zodSchema22, {
|
|
@@ -11111,8 +11207,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
11111
11207
|
);
|
|
11112
11208
|
}
|
|
11113
11209
|
function zod4Schema(zodSchema22, options) {
|
|
11114
|
-
var
|
|
11115
|
-
const useReferences = (
|
|
11210
|
+
var _a223;
|
|
11211
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
11116
11212
|
return jsonSchema2(
|
|
11117
11213
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
11118
11214
|
() => addAdditionalPropertiesToJsonSchema(
|
|
@@ -11249,101 +11345,121 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11249
11345
|
});
|
|
11250
11346
|
}
|
|
11251
11347
|
};
|
|
11252
|
-
var name24 = "
|
|
11348
|
+
var name24 = "GatewayForbiddenError";
|
|
11253
11349
|
var marker34 = `vercel.ai.gateway.error.${name24}`;
|
|
11254
11350
|
var symbol34 = Symbol.for(marker34);
|
|
11255
11351
|
var _a34;
|
|
11256
11352
|
var _b32;
|
|
11257
|
-
var
|
|
11353
|
+
var GatewayForbiddenError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
|
|
11258
11354
|
constructor({
|
|
11259
|
-
message = "
|
|
11260
|
-
statusCode =
|
|
11355
|
+
message = "Forbidden",
|
|
11356
|
+
statusCode = 403,
|
|
11261
11357
|
cause
|
|
11262
11358
|
} = {}) {
|
|
11263
11359
|
super({ message, statusCode, cause });
|
|
11264
11360
|
this[_a34] = true;
|
|
11265
11361
|
this.name = name24;
|
|
11266
|
-
this.type = "
|
|
11362
|
+
this.type = "forbidden";
|
|
11267
11363
|
}
|
|
11268
11364
|
static isInstance(error) {
|
|
11269
11365
|
return GatewayError.hasMarker(error) && symbol34 in error;
|
|
11270
11366
|
}
|
|
11271
11367
|
};
|
|
11272
|
-
var name34 = "
|
|
11368
|
+
var name34 = "GatewayInvalidRequestError";
|
|
11273
11369
|
var marker44 = `vercel.ai.gateway.error.${name34}`;
|
|
11274
11370
|
var symbol44 = Symbol.for(marker44);
|
|
11275
11371
|
var _a44;
|
|
11276
11372
|
var _b42;
|
|
11277
|
-
var
|
|
11373
|
+
var GatewayInvalidRequestError = class extends (_b42 = GatewayError, _a44 = symbol44, _b42) {
|
|
11278
11374
|
constructor({
|
|
11279
|
-
message = "
|
|
11280
|
-
statusCode =
|
|
11375
|
+
message = "Invalid request",
|
|
11376
|
+
statusCode = 400,
|
|
11281
11377
|
cause
|
|
11282
11378
|
} = {}) {
|
|
11283
11379
|
super({ message, statusCode, cause });
|
|
11284
11380
|
this[_a44] = true;
|
|
11285
11381
|
this.name = name34;
|
|
11286
|
-
this.type = "
|
|
11382
|
+
this.type = "invalid_request_error";
|
|
11287
11383
|
}
|
|
11288
11384
|
static isInstance(error) {
|
|
11289
11385
|
return GatewayError.hasMarker(error) && symbol44 in error;
|
|
11290
11386
|
}
|
|
11291
11387
|
};
|
|
11292
|
-
var name44 = "
|
|
11388
|
+
var name44 = "GatewayRateLimitError";
|
|
11293
11389
|
var marker54 = `vercel.ai.gateway.error.${name44}`;
|
|
11294
11390
|
var symbol54 = Symbol.for(marker54);
|
|
11295
|
-
var modelNotFoundParamSchema = lazyValidator(
|
|
11296
|
-
() => zodSchema2(
|
|
11297
|
-
z42.z.object({
|
|
11298
|
-
modelId: z42.z.string()
|
|
11299
|
-
})
|
|
11300
|
-
)
|
|
11301
|
-
);
|
|
11302
11391
|
var _a54;
|
|
11303
11392
|
var _b52;
|
|
11304
|
-
var
|
|
11393
|
+
var GatewayRateLimitError = class extends (_b52 = GatewayError, _a54 = symbol54, _b52) {
|
|
11305
11394
|
constructor({
|
|
11306
|
-
message = "
|
|
11307
|
-
statusCode =
|
|
11308
|
-
modelId,
|
|
11395
|
+
message = "Rate limit exceeded",
|
|
11396
|
+
statusCode = 429,
|
|
11309
11397
|
cause
|
|
11310
11398
|
} = {}) {
|
|
11311
11399
|
super({ message, statusCode, cause });
|
|
11312
11400
|
this[_a54] = true;
|
|
11313
11401
|
this.name = name44;
|
|
11314
|
-
this.type = "
|
|
11315
|
-
this.modelId = modelId;
|
|
11402
|
+
this.type = "rate_limit_exceeded";
|
|
11316
11403
|
}
|
|
11317
11404
|
static isInstance(error) {
|
|
11318
11405
|
return GatewayError.hasMarker(error) && symbol54 in error;
|
|
11319
11406
|
}
|
|
11320
11407
|
};
|
|
11321
|
-
var name54 = "
|
|
11408
|
+
var name54 = "GatewayModelNotFoundError";
|
|
11322
11409
|
var marker64 = `vercel.ai.gateway.error.${name54}`;
|
|
11323
11410
|
var symbol64 = Symbol.for(marker64);
|
|
11411
|
+
var modelNotFoundParamSchema = lazyValidator(
|
|
11412
|
+
() => zodSchema2(
|
|
11413
|
+
z42.z.object({
|
|
11414
|
+
modelId: z42.z.string()
|
|
11415
|
+
})
|
|
11416
|
+
)
|
|
11417
|
+
);
|
|
11324
11418
|
var _a64;
|
|
11325
11419
|
var _b62;
|
|
11326
|
-
var
|
|
11420
|
+
var GatewayModelNotFoundError = class extends (_b62 = GatewayError, _a64 = symbol64, _b62) {
|
|
11327
11421
|
constructor({
|
|
11328
|
-
message = "
|
|
11329
|
-
statusCode =
|
|
11422
|
+
message = "Model not found",
|
|
11423
|
+
statusCode = 404,
|
|
11424
|
+
modelId,
|
|
11330
11425
|
cause
|
|
11331
11426
|
} = {}) {
|
|
11332
11427
|
super({ message, statusCode, cause });
|
|
11333
11428
|
this[_a64] = true;
|
|
11334
11429
|
this.name = name54;
|
|
11335
|
-
this.type = "
|
|
11430
|
+
this.type = "model_not_found";
|
|
11431
|
+
this.modelId = modelId;
|
|
11336
11432
|
}
|
|
11337
11433
|
static isInstance(error) {
|
|
11338
11434
|
return GatewayError.hasMarker(error) && symbol64 in error;
|
|
11339
11435
|
}
|
|
11340
11436
|
};
|
|
11341
|
-
var name64 = "
|
|
11437
|
+
var name64 = "GatewayInternalServerError";
|
|
11342
11438
|
var marker74 = `vercel.ai.gateway.error.${name64}`;
|
|
11343
11439
|
var symbol74 = Symbol.for(marker74);
|
|
11344
11440
|
var _a74;
|
|
11345
11441
|
var _b72;
|
|
11346
|
-
var
|
|
11442
|
+
var GatewayInternalServerError = class extends (_b72 = GatewayError, _a74 = symbol74, _b72) {
|
|
11443
|
+
constructor({
|
|
11444
|
+
message = "Internal server error",
|
|
11445
|
+
statusCode = 500,
|
|
11446
|
+
cause
|
|
11447
|
+
} = {}) {
|
|
11448
|
+
super({ message, statusCode, cause });
|
|
11449
|
+
this[_a74] = true;
|
|
11450
|
+
this.name = name64;
|
|
11451
|
+
this.type = "internal_server_error";
|
|
11452
|
+
}
|
|
11453
|
+
static isInstance(error) {
|
|
11454
|
+
return GatewayError.hasMarker(error) && symbol74 in error;
|
|
11455
|
+
}
|
|
11456
|
+
};
|
|
11457
|
+
var name74 = "GatewayResponseError";
|
|
11458
|
+
var marker84 = `vercel.ai.gateway.error.${name74}`;
|
|
11459
|
+
var symbol84 = Symbol.for(marker84);
|
|
11460
|
+
var _a84;
|
|
11461
|
+
var _b82;
|
|
11462
|
+
var GatewayResponseError = class extends (_b82 = GatewayError, _a84 = symbol84, _b82) {
|
|
11347
11463
|
constructor({
|
|
11348
11464
|
message = "Invalid response from Gateway",
|
|
11349
11465
|
statusCode = 502,
|
|
@@ -11352,14 +11468,14 @@ var GatewayResponseError = class extends (_b72 = GatewayError, _a74 = symbol74,
|
|
|
11352
11468
|
cause
|
|
11353
11469
|
} = {}) {
|
|
11354
11470
|
super({ message, statusCode, cause });
|
|
11355
|
-
this[
|
|
11356
|
-
this.name =
|
|
11471
|
+
this[_a84] = true;
|
|
11472
|
+
this.name = name74;
|
|
11357
11473
|
this.type = "response_error";
|
|
11358
11474
|
this.response = response;
|
|
11359
11475
|
this.validationError = validationError;
|
|
11360
11476
|
}
|
|
11361
11477
|
static isInstance(error) {
|
|
11362
|
-
return GatewayError.hasMarker(error) &&
|
|
11478
|
+
return GatewayError.hasMarker(error) && symbol84 in error;
|
|
11363
11479
|
}
|
|
11364
11480
|
};
|
|
11365
11481
|
async function createGatewayErrorFromResponse({
|
|
@@ -11411,6 +11527,8 @@ async function createGatewayErrorFromResponse({
|
|
|
11411
11527
|
}
|
|
11412
11528
|
case "internal_server_error":
|
|
11413
11529
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
11530
|
+
case "forbidden":
|
|
11531
|
+
return new GatewayForbiddenError({ message, statusCode, cause });
|
|
11414
11532
|
default:
|
|
11415
11533
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
11416
11534
|
}
|
|
@@ -11440,24 +11558,24 @@ function extractApiCallResponse(error) {
|
|
|
11440
11558
|
}
|
|
11441
11559
|
return {};
|
|
11442
11560
|
}
|
|
11443
|
-
var
|
|
11444
|
-
var
|
|
11445
|
-
var
|
|
11446
|
-
var
|
|
11447
|
-
var
|
|
11448
|
-
var GatewayTimeoutError = class _GatewayTimeoutError extends (
|
|
11561
|
+
var name84 = "GatewayTimeoutError";
|
|
11562
|
+
var marker94 = `vercel.ai.gateway.error.${name84}`;
|
|
11563
|
+
var symbol94 = Symbol.for(marker94);
|
|
11564
|
+
var _a94;
|
|
11565
|
+
var _b92;
|
|
11566
|
+
var GatewayTimeoutError = class _GatewayTimeoutError extends (_b92 = GatewayError, _a94 = symbol94, _b92) {
|
|
11449
11567
|
constructor({
|
|
11450
11568
|
message = "Request timed out",
|
|
11451
11569
|
statusCode = 408,
|
|
11452
11570
|
cause
|
|
11453
11571
|
} = {}) {
|
|
11454
11572
|
super({ message, statusCode, cause });
|
|
11455
|
-
this[
|
|
11456
|
-
this.name =
|
|
11573
|
+
this[_a94] = true;
|
|
11574
|
+
this.name = name84;
|
|
11457
11575
|
this.type = "timeout_error";
|
|
11458
11576
|
}
|
|
11459
11577
|
static isInstance(error) {
|
|
11460
|
-
return GatewayError.hasMarker(error) &&
|
|
11578
|
+
return GatewayError.hasMarker(error) && symbol94 in error;
|
|
11461
11579
|
}
|
|
11462
11580
|
/**
|
|
11463
11581
|
* Creates a helpful timeout error message with troubleshooting guidance
|
|
@@ -11493,7 +11611,7 @@ function isTimeoutError(error) {
|
|
|
11493
11611
|
return false;
|
|
11494
11612
|
}
|
|
11495
11613
|
async function asGatewayError(error, authMethod) {
|
|
11496
|
-
var
|
|
11614
|
+
var _a1032;
|
|
11497
11615
|
if (GatewayError.isInstance(error)) {
|
|
11498
11616
|
return error;
|
|
11499
11617
|
}
|
|
@@ -11512,7 +11630,7 @@ async function asGatewayError(error, authMethod) {
|
|
|
11512
11630
|
}
|
|
11513
11631
|
return await createGatewayErrorFromResponse({
|
|
11514
11632
|
response: extractApiCallResponse(error),
|
|
11515
|
-
statusCode: (
|
|
11633
|
+
statusCode: (_a1032 = error.statusCode) != null ? _a1032 : 500,
|
|
11516
11634
|
defaultMessage: "Gateway request failed",
|
|
11517
11635
|
cause: error,
|
|
11518
11636
|
authMethod
|
|
@@ -11972,7 +12090,7 @@ var GatewayEmbeddingModel = class {
|
|
|
11972
12090
|
abortSignal,
|
|
11973
12091
|
providerOptions
|
|
11974
12092
|
}) {
|
|
11975
|
-
var
|
|
12093
|
+
var _a1032;
|
|
11976
12094
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
11977
12095
|
try {
|
|
11978
12096
|
const {
|
|
@@ -12003,7 +12121,7 @@ var GatewayEmbeddingModel = class {
|
|
|
12003
12121
|
});
|
|
12004
12122
|
return {
|
|
12005
12123
|
embeddings: responseBody.embeddings,
|
|
12006
|
-
usage: (
|
|
12124
|
+
usage: (_a1032 = responseBody.usage) != null ? _a1032 : void 0,
|
|
12007
12125
|
providerMetadata: responseBody.providerMetadata,
|
|
12008
12126
|
response: { headers: responseHeaders, body: rawValue }
|
|
12009
12127
|
};
|
|
@@ -12050,7 +12168,7 @@ var GatewayImageModel = class {
|
|
|
12050
12168
|
headers,
|
|
12051
12169
|
abortSignal
|
|
12052
12170
|
}) {
|
|
12053
|
-
var
|
|
12171
|
+
var _a1032, _b104, _c, _d;
|
|
12054
12172
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
12055
12173
|
try {
|
|
12056
12174
|
const {
|
|
@@ -12085,7 +12203,7 @@ var GatewayImageModel = class {
|
|
|
12085
12203
|
return {
|
|
12086
12204
|
images: responseBody.images,
|
|
12087
12205
|
// Always base64 strings from server
|
|
12088
|
-
warnings: (
|
|
12206
|
+
warnings: (_a1032 = responseBody.warnings) != null ? _a1032 : [],
|
|
12089
12207
|
providerMetadata: responseBody.providerMetadata,
|
|
12090
12208
|
response: {
|
|
12091
12209
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -12094,7 +12212,7 @@ var GatewayImageModel = class {
|
|
|
12094
12212
|
},
|
|
12095
12213
|
...responseBody.usage != null && {
|
|
12096
12214
|
usage: {
|
|
12097
|
-
inputTokens: (
|
|
12215
|
+
inputTokens: (_b104 = responseBody.usage.inputTokens) != null ? _b104 : void 0,
|
|
12098
12216
|
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
|
|
12099
12217
|
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
|
|
12100
12218
|
}
|
|
@@ -12309,18 +12427,18 @@ var gatewayTools = {
|
|
|
12309
12427
|
perplexitySearch
|
|
12310
12428
|
};
|
|
12311
12429
|
async function getVercelRequestId() {
|
|
12312
|
-
var
|
|
12313
|
-
return (
|
|
12430
|
+
var _a1032;
|
|
12431
|
+
return (_a1032 = getContext().headers) == null ? void 0 : _a1032["x-vercel-id"];
|
|
12314
12432
|
}
|
|
12315
|
-
var VERSION3 = "2.0.
|
|
12433
|
+
var VERSION3 = "2.0.109";
|
|
12316
12434
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
12317
12435
|
function createGatewayProvider(options = {}) {
|
|
12318
|
-
var
|
|
12436
|
+
var _a1032, _b104;
|
|
12319
12437
|
let pendingMetadata = null;
|
|
12320
12438
|
let metadataCache = null;
|
|
12321
|
-
const cacheRefreshMillis = (
|
|
12439
|
+
const cacheRefreshMillis = (_a1032 = options.metadataCacheRefreshMillis) != null ? _a1032 : 1e3 * 60 * 5;
|
|
12322
12440
|
let lastFetchTime = 0;
|
|
12323
|
-
const baseURL = (
|
|
12441
|
+
const baseURL = (_b104 = withoutTrailingSlash(options.baseURL)) != null ? _b104 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
12324
12442
|
const getHeaders = async () => {
|
|
12325
12443
|
const auth = await getGatewayAuthToken(options);
|
|
12326
12444
|
if (auth) {
|
|
@@ -12378,8 +12496,8 @@ function createGatewayProvider(options = {}) {
|
|
|
12378
12496
|
});
|
|
12379
12497
|
};
|
|
12380
12498
|
const getAvailableModels = async () => {
|
|
12381
|
-
var
|
|
12382
|
-
const now2 = (_c = (
|
|
12499
|
+
var _a1122, _b113, _c;
|
|
12500
|
+
const now2 = (_c = (_b113 = (_a1122 = options._internal) == null ? void 0 : _a1122.currentDate) == null ? void 0 : _b113.call(_a1122).getTime()) != null ? _c : Date.now();
|
|
12383
12501
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
12384
12502
|
lastFetchTime = now2;
|
|
12385
12503
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -12583,12 +12701,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
|
|
|
12583
12701
|
return true;
|
|
12584
12702
|
}
|
|
12585
12703
|
function getGlobal2(type) {
|
|
12586
|
-
var _a163,
|
|
12704
|
+
var _a163, _b104;
|
|
12587
12705
|
var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
|
|
12588
12706
|
if (!globalVersion || !isCompatible2(globalVersion)) {
|
|
12589
12707
|
return;
|
|
12590
12708
|
}
|
|
12591
|
-
return (
|
|
12709
|
+
return (_b104 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b104 === void 0 ? void 0 : _b104[type];
|
|
12592
12710
|
}
|
|
12593
12711
|
function unregisterGlobal2(type, diag) {
|
|
12594
12712
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
|
|
@@ -12751,15 +12869,15 @@ var DiagAPI2 = (
|
|
|
12751
12869
|
return logger[funcName].apply(logger, __spreadArray22([], __read22(args), false));
|
|
12752
12870
|
};
|
|
12753
12871
|
}
|
|
12754
|
-
var
|
|
12872
|
+
var self2 = this;
|
|
12755
12873
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
12756
|
-
var _a163,
|
|
12874
|
+
var _a163, _b104, _c;
|
|
12757
12875
|
if (optionsOrLogLevel === void 0) {
|
|
12758
12876
|
optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
|
|
12759
12877
|
}
|
|
12760
|
-
if (logger ===
|
|
12878
|
+
if (logger === self2) {
|
|
12761
12879
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
12762
|
-
|
|
12880
|
+
self2.error((_a163 = err.stack) !== null && _a163 !== void 0 ? _a163 : err.message);
|
|
12763
12881
|
return false;
|
|
12764
12882
|
}
|
|
12765
12883
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -12768,26 +12886,26 @@ var DiagAPI2 = (
|
|
|
12768
12886
|
};
|
|
12769
12887
|
}
|
|
12770
12888
|
var oldLogger = getGlobal2("diag");
|
|
12771
|
-
var newLogger = createLogLevelDiagLogger2((
|
|
12889
|
+
var newLogger = createLogLevelDiagLogger2((_b104 = optionsOrLogLevel.logLevel) !== null && _b104 !== void 0 ? _b104 : DiagLogLevel2.INFO, logger);
|
|
12772
12890
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
12773
12891
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
12774
12892
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
12775
12893
|
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
12776
12894
|
}
|
|
12777
|
-
return registerGlobal2("diag", newLogger,
|
|
12895
|
+
return registerGlobal2("diag", newLogger, self2, true);
|
|
12778
12896
|
};
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
unregisterGlobal2(API_NAME4,
|
|
12897
|
+
self2.setLogger = setLogger;
|
|
12898
|
+
self2.disable = function() {
|
|
12899
|
+
unregisterGlobal2(API_NAME4, self2);
|
|
12782
12900
|
};
|
|
12783
|
-
|
|
12901
|
+
self2.createComponentLogger = function(options) {
|
|
12784
12902
|
return new DiagComponentLogger2(options);
|
|
12785
12903
|
};
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12904
|
+
self2.verbose = _logProxy("verbose");
|
|
12905
|
+
self2.debug = _logProxy("debug");
|
|
12906
|
+
self2.info = _logProxy("info");
|
|
12907
|
+
self2.warn = _logProxy("warn");
|
|
12908
|
+
self2.error = _logProxy("error");
|
|
12791
12909
|
}
|
|
12792
12910
|
DiagAPI22.instance = function() {
|
|
12793
12911
|
if (!this._instance) {
|
|
@@ -12805,18 +12923,18 @@ var BaseContext2 = (
|
|
|
12805
12923
|
/** @class */
|
|
12806
12924
|
/* @__PURE__ */ (function() {
|
|
12807
12925
|
function BaseContext22(parentContext) {
|
|
12808
|
-
var
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
return
|
|
12926
|
+
var self2 = this;
|
|
12927
|
+
self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
12928
|
+
self2.getValue = function(key) {
|
|
12929
|
+
return self2._currentContext.get(key);
|
|
12812
12930
|
};
|
|
12813
|
-
|
|
12814
|
-
var context2 = new BaseContext22(
|
|
12931
|
+
self2.setValue = function(key, value) {
|
|
12932
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
12815
12933
|
context2._currentContext.set(key, value);
|
|
12816
12934
|
return context2;
|
|
12817
12935
|
};
|
|
12818
|
-
|
|
12819
|
-
var context2 = new BaseContext22(
|
|
12936
|
+
self2.deleteValue = function(key) {
|
|
12937
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
12820
12938
|
context2._currentContext.delete(key);
|
|
12821
12939
|
return context2;
|
|
12822
12940
|
};
|
|
@@ -13299,7 +13417,7 @@ function getGlobalProvider() {
|
|
|
13299
13417
|
var _a163;
|
|
13300
13418
|
return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
|
|
13301
13419
|
}
|
|
13302
|
-
var VERSION32 = "5.0.
|
|
13420
|
+
var VERSION32 = "5.0.210";
|
|
13303
13421
|
var dataContentSchema2 = z42.z.union([
|
|
13304
13422
|
z42.z.string(),
|
|
13305
13423
|
z42.z.instanceof(Uint8Array),
|
|
@@ -13307,8 +13425,8 @@ var dataContentSchema2 = z42.z.union([
|
|
|
13307
13425
|
z42.z.custom(
|
|
13308
13426
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
13309
13427
|
(value) => {
|
|
13310
|
-
var _a163,
|
|
13311
|
-
return (
|
|
13428
|
+
var _a163, _b104;
|
|
13429
|
+
return (_b104 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b104 : false;
|
|
13312
13430
|
},
|
|
13313
13431
|
{ message: "Must be a Buffer" }
|
|
13314
13432
|
)
|
|
@@ -14832,6 +14950,90 @@ function convertUint8ArrayToBase643(array2) {
|
|
|
14832
14950
|
}
|
|
14833
14951
|
return btoa3(latin1string);
|
|
14834
14952
|
}
|
|
14953
|
+
async function cancelResponseBody2(response) {
|
|
14954
|
+
var _a223;
|
|
14955
|
+
try {
|
|
14956
|
+
await ((_a223 = response.body) == null ? void 0 : _a223.cancel());
|
|
14957
|
+
} catch (e) {
|
|
14958
|
+
}
|
|
14959
|
+
}
|
|
14960
|
+
var name144 = "AI_DownloadError";
|
|
14961
|
+
var marker154 = `vercel.ai.error.${name144}`;
|
|
14962
|
+
var symbol154 = Symbol.for(marker154);
|
|
14963
|
+
var _a154;
|
|
14964
|
+
var _b152;
|
|
14965
|
+
var DownloadError2 = class extends (_b152 = AISDKError3, _a154 = symbol154, _b152) {
|
|
14966
|
+
constructor({
|
|
14967
|
+
url,
|
|
14968
|
+
statusCode,
|
|
14969
|
+
statusText,
|
|
14970
|
+
cause,
|
|
14971
|
+
message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
|
|
14972
|
+
}) {
|
|
14973
|
+
super({ name: name144, message, cause });
|
|
14974
|
+
this[_a154] = true;
|
|
14975
|
+
this.url = url;
|
|
14976
|
+
this.statusCode = statusCode;
|
|
14977
|
+
this.statusText = statusText;
|
|
14978
|
+
}
|
|
14979
|
+
static isInstance(error) {
|
|
14980
|
+
return AISDKError3.hasMarker(error, marker154);
|
|
14981
|
+
}
|
|
14982
|
+
};
|
|
14983
|
+
var DEFAULT_MAX_DOWNLOAD_SIZE2 = 2 * 1024 * 1024 * 1024;
|
|
14984
|
+
async function readResponseWithSizeLimit2({
|
|
14985
|
+
response,
|
|
14986
|
+
url,
|
|
14987
|
+
maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE2
|
|
14988
|
+
}) {
|
|
14989
|
+
const contentLength = response.headers.get("content-length");
|
|
14990
|
+
if (contentLength != null) {
|
|
14991
|
+
const length = parseInt(contentLength, 10);
|
|
14992
|
+
if (!isNaN(length) && length > maxBytes) {
|
|
14993
|
+
await cancelResponseBody2(response);
|
|
14994
|
+
throw new DownloadError2({
|
|
14995
|
+
url,
|
|
14996
|
+
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
14997
|
+
});
|
|
14998
|
+
}
|
|
14999
|
+
}
|
|
15000
|
+
const body = response.body;
|
|
15001
|
+
if (body == null) {
|
|
15002
|
+
return new Uint8Array(0);
|
|
15003
|
+
}
|
|
15004
|
+
const reader = body.getReader();
|
|
15005
|
+
const chunks = [];
|
|
15006
|
+
let totalBytes = 0;
|
|
15007
|
+
try {
|
|
15008
|
+
while (true) {
|
|
15009
|
+
const { done, value } = await reader.read();
|
|
15010
|
+
if (done) {
|
|
15011
|
+
break;
|
|
15012
|
+
}
|
|
15013
|
+
totalBytes += value.length;
|
|
15014
|
+
if (totalBytes > maxBytes) {
|
|
15015
|
+
throw new DownloadError2({
|
|
15016
|
+
url,
|
|
15017
|
+
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes.`
|
|
15018
|
+
});
|
|
15019
|
+
}
|
|
15020
|
+
chunks.push(value);
|
|
15021
|
+
}
|
|
15022
|
+
} finally {
|
|
15023
|
+
try {
|
|
15024
|
+
await reader.cancel();
|
|
15025
|
+
} finally {
|
|
15026
|
+
reader.releaseLock();
|
|
15027
|
+
}
|
|
15028
|
+
}
|
|
15029
|
+
const result = new Uint8Array(totalBytes);
|
|
15030
|
+
let offset = 0;
|
|
15031
|
+
for (const chunk of chunks) {
|
|
15032
|
+
result.set(chunk, offset);
|
|
15033
|
+
offset += chunk.length;
|
|
15034
|
+
}
|
|
15035
|
+
return result;
|
|
15036
|
+
}
|
|
14835
15037
|
var createIdGenerator3 = ({
|
|
14836
15038
|
prefix,
|
|
14837
15039
|
size = 16,
|
|
@@ -14927,11 +15129,11 @@ function handleFetchError2({
|
|
|
14927
15129
|
return error;
|
|
14928
15130
|
}
|
|
14929
15131
|
function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
|
|
14930
|
-
var
|
|
15132
|
+
var _a223, _b222, _c;
|
|
14931
15133
|
if (globalThisAny.window) {
|
|
14932
15134
|
return `runtime/browser`;
|
|
14933
15135
|
}
|
|
14934
|
-
if ((
|
|
15136
|
+
if ((_a223 = globalThisAny.navigator) == null ? void 0 : _a223.userAgent) {
|
|
14935
15137
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
14936
15138
|
}
|
|
14937
15139
|
if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
|
|
@@ -14972,7 +15174,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
14972
15174
|
);
|
|
14973
15175
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
14974
15176
|
}
|
|
14975
|
-
var VERSION4 = "4.0.
|
|
15177
|
+
var VERSION4 = "4.0.38";
|
|
14976
15178
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
14977
15179
|
var getFromApi2 = async ({
|
|
14978
15180
|
url,
|
|
@@ -15173,11 +15375,11 @@ function parseAnyDef3() {
|
|
|
15173
15375
|
return {};
|
|
15174
15376
|
}
|
|
15175
15377
|
function parseArrayDef3(def, refs) {
|
|
15176
|
-
var
|
|
15378
|
+
var _a223, _b222, _c;
|
|
15177
15379
|
const res = {
|
|
15178
15380
|
type: "array"
|
|
15179
15381
|
};
|
|
15180
|
-
if (((
|
|
15382
|
+
if (((_a223 = def.type) == null ? void 0 : _a223._def) && ((_c = (_b222 = def.type) == null ? void 0 : _b222._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
15181
15383
|
res.items = parseDef3(def.type._def, {
|
|
15182
15384
|
...refs,
|
|
15183
15385
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -15536,8 +15738,8 @@ function escapeNonAlphaNumeric3(source) {
|
|
|
15536
15738
|
return result;
|
|
15537
15739
|
}
|
|
15538
15740
|
function addFormat3(schema, value, message, refs) {
|
|
15539
|
-
var
|
|
15540
|
-
if (schema.format || ((
|
|
15741
|
+
var _a223;
|
|
15742
|
+
if (schema.format || ((_a223 = schema.anyOf) == null ? void 0 : _a223.some((x) => x.format))) {
|
|
15541
15743
|
if (!schema.anyOf) {
|
|
15542
15744
|
schema.anyOf = [];
|
|
15543
15745
|
}
|
|
@@ -15556,8 +15758,8 @@ function addFormat3(schema, value, message, refs) {
|
|
|
15556
15758
|
}
|
|
15557
15759
|
}
|
|
15558
15760
|
function addPattern3(schema, regex, message, refs) {
|
|
15559
|
-
var
|
|
15560
|
-
if (schema.pattern || ((
|
|
15761
|
+
var _a223;
|
|
15762
|
+
if (schema.pattern || ((_a223 = schema.allOf) == null ? void 0 : _a223.some((x) => x.pattern))) {
|
|
15561
15763
|
if (!schema.allOf) {
|
|
15562
15764
|
schema.allOf = [];
|
|
15563
15765
|
}
|
|
@@ -15576,7 +15778,7 @@ function addPattern3(schema, regex, message, refs) {
|
|
|
15576
15778
|
}
|
|
15577
15779
|
}
|
|
15578
15780
|
function stringifyRegExpWithFlags3(regex, refs) {
|
|
15579
|
-
var
|
|
15781
|
+
var _a223;
|
|
15580
15782
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
15581
15783
|
return regex.source;
|
|
15582
15784
|
}
|
|
@@ -15606,7 +15808,7 @@ function stringifyRegExpWithFlags3(regex, refs) {
|
|
|
15606
15808
|
pattern += source[i];
|
|
15607
15809
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
15608
15810
|
inCharRange = false;
|
|
15609
|
-
} else if (source[i + 1] === "-" && ((
|
|
15811
|
+
} else if (source[i + 1] === "-" && ((_a223 = source[i + 2]) == null ? void 0 : _a223.match(/[a-z]/))) {
|
|
15610
15812
|
pattern += source[i];
|
|
15611
15813
|
inCharRange = true;
|
|
15612
15814
|
} else {
|
|
@@ -15648,13 +15850,13 @@ function stringifyRegExpWithFlags3(regex, refs) {
|
|
|
15648
15850
|
return pattern;
|
|
15649
15851
|
}
|
|
15650
15852
|
function parseRecordDef3(def, refs) {
|
|
15651
|
-
var
|
|
15853
|
+
var _a223, _b222, _c, _d, _e, _f;
|
|
15652
15854
|
const schema = {
|
|
15653
15855
|
type: "object",
|
|
15654
|
-
additionalProperties: (
|
|
15856
|
+
additionalProperties: (_a223 = parseDef3(def.valueType._def, {
|
|
15655
15857
|
...refs,
|
|
15656
15858
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
15657
|
-
})) != null ?
|
|
15859
|
+
})) != null ? _a223 : refs.allowedAdditionalProperties
|
|
15658
15860
|
};
|
|
15659
15861
|
if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
15660
15862
|
const { type, ...keyType } = parseStringDef3(def.keyType._def, refs);
|
|
@@ -15911,8 +16113,8 @@ function safeIsOptional3(schema) {
|
|
|
15911
16113
|
}
|
|
15912
16114
|
}
|
|
15913
16115
|
var parseOptionalDef3 = (def, refs) => {
|
|
15914
|
-
var
|
|
15915
|
-
if (refs.currentPath.toString() === ((
|
|
16116
|
+
var _a223;
|
|
16117
|
+
if (refs.currentPath.toString() === ((_a223 = refs.propertyPath) == null ? void 0 : _a223.toString())) {
|
|
15916
16118
|
return parseDef3(def.innerType._def, refs);
|
|
15917
16119
|
}
|
|
15918
16120
|
const innerSchema = parseDef3(def.innerType._def, {
|
|
@@ -16089,10 +16291,10 @@ var getRelativePath3 = (pathA, pathB) => {
|
|
|
16089
16291
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
16090
16292
|
};
|
|
16091
16293
|
function parseDef3(def, refs, forceResolution = false) {
|
|
16092
|
-
var
|
|
16294
|
+
var _a223;
|
|
16093
16295
|
const seenItem = refs.seen.get(def);
|
|
16094
16296
|
if (refs.override) {
|
|
16095
|
-
const overrideResult = (
|
|
16297
|
+
const overrideResult = (_a223 = refs.override) == null ? void 0 : _a223.call(
|
|
16096
16298
|
refs,
|
|
16097
16299
|
def,
|
|
16098
16300
|
refs,
|
|
@@ -16158,11 +16360,11 @@ var getRefs3 = (options) => {
|
|
|
16158
16360
|
currentPath,
|
|
16159
16361
|
propertyPath: void 0,
|
|
16160
16362
|
seen: new Map(
|
|
16161
|
-
Object.entries(_options.definitions).map(([
|
|
16363
|
+
Object.entries(_options.definitions).map(([name223, def]) => [
|
|
16162
16364
|
def._def,
|
|
16163
16365
|
{
|
|
16164
16366
|
def: def._def,
|
|
16165
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
16367
|
+
path: [..._options.basePath, _options.definitionPath, name223],
|
|
16166
16368
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
16167
16369
|
jsonSchema: void 0
|
|
16168
16370
|
}
|
|
@@ -16171,50 +16373,50 @@ var getRefs3 = (options) => {
|
|
|
16171
16373
|
};
|
|
16172
16374
|
};
|
|
16173
16375
|
var zod3ToJsonSchema = (schema, options) => {
|
|
16174
|
-
var
|
|
16376
|
+
var _a223;
|
|
16175
16377
|
const refs = getRefs3(options);
|
|
16176
16378
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
16177
|
-
(acc, [
|
|
16178
|
-
var
|
|
16379
|
+
(acc, [name323, schema2]) => {
|
|
16380
|
+
var _a323;
|
|
16179
16381
|
return {
|
|
16180
16382
|
...acc,
|
|
16181
|
-
[
|
|
16383
|
+
[name323]: (_a323 = parseDef3(
|
|
16182
16384
|
schema2._def,
|
|
16183
16385
|
{
|
|
16184
16386
|
...refs,
|
|
16185
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
16387
|
+
currentPath: [...refs.basePath, refs.definitionPath, name323]
|
|
16186
16388
|
},
|
|
16187
16389
|
true
|
|
16188
|
-
)) != null ?
|
|
16390
|
+
)) != null ? _a323 : parseAnyDef3()
|
|
16189
16391
|
};
|
|
16190
16392
|
},
|
|
16191
16393
|
{}
|
|
16192
16394
|
) : void 0;
|
|
16193
|
-
const
|
|
16194
|
-
const main = (
|
|
16395
|
+
const name223 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
16396
|
+
const main = (_a223 = parseDef3(
|
|
16195
16397
|
schema._def,
|
|
16196
|
-
|
|
16398
|
+
name223 === void 0 ? refs : {
|
|
16197
16399
|
...refs,
|
|
16198
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
16400
|
+
currentPath: [...refs.basePath, refs.definitionPath, name223]
|
|
16199
16401
|
},
|
|
16200
16402
|
false
|
|
16201
|
-
)) != null ?
|
|
16403
|
+
)) != null ? _a223 : parseAnyDef3();
|
|
16202
16404
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
16203
16405
|
if (title !== void 0) {
|
|
16204
16406
|
main.title = title;
|
|
16205
16407
|
}
|
|
16206
|
-
const combined =
|
|
16408
|
+
const combined = name223 === void 0 ? definitions ? {
|
|
16207
16409
|
...main,
|
|
16208
16410
|
[refs.definitionPath]: definitions
|
|
16209
16411
|
} : main : {
|
|
16210
16412
|
$ref: [
|
|
16211
16413
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
16212
16414
|
refs.definitionPath,
|
|
16213
|
-
|
|
16415
|
+
name223
|
|
16214
16416
|
].join("/"),
|
|
16215
16417
|
[refs.definitionPath]: {
|
|
16216
16418
|
...definitions,
|
|
16217
|
-
[
|
|
16419
|
+
[name223]: main
|
|
16218
16420
|
}
|
|
16219
16421
|
};
|
|
16220
16422
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -16250,7 +16452,11 @@ function isSchema3(value) {
|
|
|
16250
16452
|
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
16251
16453
|
}
|
|
16252
16454
|
function asSchema3(schema) {
|
|
16253
|
-
return schema == null ? jsonSchema3({
|
|
16455
|
+
return schema == null ? jsonSchema3({
|
|
16456
|
+
type: "object",
|
|
16457
|
+
properties: {},
|
|
16458
|
+
additionalProperties: false
|
|
16459
|
+
}) : isSchema3(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema3(schema) : standardSchema(schema) : schema();
|
|
16254
16460
|
}
|
|
16255
16461
|
function standardSchema(standardSchema2) {
|
|
16256
16462
|
return jsonSchema3(
|
|
@@ -16274,8 +16480,8 @@ function standardSchema(standardSchema2) {
|
|
|
16274
16480
|
);
|
|
16275
16481
|
}
|
|
16276
16482
|
function zod3Schema2(zodSchema22, options) {
|
|
16277
|
-
var
|
|
16278
|
-
const useReferences = (
|
|
16483
|
+
var _a223;
|
|
16484
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
16279
16485
|
return jsonSchema3(
|
|
16280
16486
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
16281
16487
|
() => zod3ToJsonSchema(zodSchema22, {
|
|
@@ -16290,8 +16496,8 @@ function zod3Schema2(zodSchema22, options) {
|
|
|
16290
16496
|
);
|
|
16291
16497
|
}
|
|
16292
16498
|
function zod4Schema2(zodSchema22, options) {
|
|
16293
|
-
var
|
|
16294
|
-
const useReferences = (
|
|
16499
|
+
var _a223;
|
|
16500
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
16295
16501
|
return jsonSchema3(
|
|
16296
16502
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
16297
16503
|
() => addAdditionalPropertiesToJsonSchema2(
|
|
@@ -16538,12 +16744,101 @@ async function resolve2(value) {
|
|
|
16538
16744
|
}
|
|
16539
16745
|
return Promise.resolve(value);
|
|
16540
16746
|
}
|
|
16747
|
+
var retryWithExponentialBackoff2 = ({
|
|
16748
|
+
maxRetries = 2,
|
|
16749
|
+
initialDelayInMs = 2e3,
|
|
16750
|
+
backoffFactor = 2,
|
|
16751
|
+
abortSignal,
|
|
16752
|
+
shouldRetry,
|
|
16753
|
+
getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay,
|
|
16754
|
+
createRetryError = ({ message }) => new Error(message)
|
|
16755
|
+
}) => async (f) => retryWithExponentialBackoffInternal(f, {
|
|
16756
|
+
maxRetries,
|
|
16757
|
+
delayInMs: initialDelayInMs,
|
|
16758
|
+
backoffFactor,
|
|
16759
|
+
abortSignal,
|
|
16760
|
+
shouldRetry,
|
|
16761
|
+
getDelayInMs,
|
|
16762
|
+
createRetryError
|
|
16763
|
+
});
|
|
16764
|
+
async function retryWithExponentialBackoffInternal(f, {
|
|
16765
|
+
maxRetries,
|
|
16766
|
+
delayInMs,
|
|
16767
|
+
backoffFactor,
|
|
16768
|
+
abortSignal,
|
|
16769
|
+
shouldRetry,
|
|
16770
|
+
getDelayInMs,
|
|
16771
|
+
createRetryError
|
|
16772
|
+
}, errors = []) {
|
|
16773
|
+
try {
|
|
16774
|
+
return await f();
|
|
16775
|
+
} catch (error) {
|
|
16776
|
+
if (isAbortError5(error)) {
|
|
16777
|
+
throw error;
|
|
16778
|
+
}
|
|
16779
|
+
if (maxRetries === 0) {
|
|
16780
|
+
throw error;
|
|
16781
|
+
}
|
|
16782
|
+
const errorMessage = getErrorMessage23(error);
|
|
16783
|
+
const newErrors = [...errors, error];
|
|
16784
|
+
const tryNumber = newErrors.length;
|
|
16785
|
+
if (tryNumber > maxRetries) {
|
|
16786
|
+
throw createRetryError({
|
|
16787
|
+
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
16788
|
+
reason: "maxRetriesExceeded",
|
|
16789
|
+
errors: newErrors
|
|
16790
|
+
});
|
|
16791
|
+
}
|
|
16792
|
+
if (await shouldRetry(error) && tryNumber <= maxRetries) {
|
|
16793
|
+
await delay3(
|
|
16794
|
+
getDelayInMs({
|
|
16795
|
+
error,
|
|
16796
|
+
exponentialBackoffDelay: delayInMs
|
|
16797
|
+
}),
|
|
16798
|
+
{ abortSignal }
|
|
16799
|
+
);
|
|
16800
|
+
return retryWithExponentialBackoffInternal(
|
|
16801
|
+
f,
|
|
16802
|
+
{
|
|
16803
|
+
maxRetries,
|
|
16804
|
+
delayInMs: backoffFactor * delayInMs,
|
|
16805
|
+
backoffFactor,
|
|
16806
|
+
abortSignal,
|
|
16807
|
+
shouldRetry,
|
|
16808
|
+
getDelayInMs,
|
|
16809
|
+
createRetryError
|
|
16810
|
+
},
|
|
16811
|
+
newErrors
|
|
16812
|
+
);
|
|
16813
|
+
}
|
|
16814
|
+
if (tryNumber === 1) {
|
|
16815
|
+
throw error;
|
|
16816
|
+
}
|
|
16817
|
+
throw createRetryError({
|
|
16818
|
+
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
16819
|
+
reason: "errorNotRetryable",
|
|
16820
|
+
errors: newErrors
|
|
16821
|
+
});
|
|
16822
|
+
}
|
|
16823
|
+
}
|
|
16824
|
+
var textDecoder2 = new TextDecoder();
|
|
16825
|
+
async function readResponseBodyAsText2({
|
|
16826
|
+
response,
|
|
16827
|
+
url
|
|
16828
|
+
}) {
|
|
16829
|
+
return textDecoder2.decode(
|
|
16830
|
+
await readResponseWithSizeLimit2({
|
|
16831
|
+
response,
|
|
16832
|
+
url
|
|
16833
|
+
})
|
|
16834
|
+
);
|
|
16835
|
+
}
|
|
16541
16836
|
var createJsonErrorResponseHandler2 = ({
|
|
16542
16837
|
errorSchema,
|
|
16543
16838
|
errorToMessage,
|
|
16544
16839
|
isRetryable
|
|
16545
16840
|
}) => async ({ response, url, requestBodyValues }) => {
|
|
16546
|
-
const responseBody = await response
|
|
16841
|
+
const responseBody = await readResponseBodyAsText2({ response, url });
|
|
16547
16842
|
const responseHeaders = extractResponseHeaders2(response);
|
|
16548
16843
|
if (responseBody.trim() === "") {
|
|
16549
16844
|
return {
|
|
@@ -16606,7 +16901,7 @@ var createEventSourceResponseHandler2 = (chunkSchema) => async ({ response }) =>
|
|
|
16606
16901
|
};
|
|
16607
16902
|
};
|
|
16608
16903
|
var createJsonResponseHandler2 = (responseSchema) => async ({ response, url, requestBodyValues }) => {
|
|
16609
|
-
const responseBody = await response
|
|
16904
|
+
const responseBody = await readResponseBodyAsText2({ response, url });
|
|
16610
16905
|
const parsedResult = await safeParseJSON3({
|
|
16611
16906
|
text: responseBody,
|
|
16612
16907
|
schema: responseSchema
|
|
@@ -16652,13 +16947,19 @@ var GatewayError2 = class _GatewayError2 extends (_b18 = Error, _a20 = symbol20,
|
|
|
16652
16947
|
message,
|
|
16653
16948
|
statusCode = 500,
|
|
16654
16949
|
cause,
|
|
16655
|
-
generationId
|
|
16950
|
+
generationId,
|
|
16951
|
+
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
|
|
16952
|
+
statusCode === 409 || // conflict
|
|
16953
|
+
statusCode === 429 || // too many requests
|
|
16954
|
+
statusCode >= 500)
|
|
16955
|
+
// server error
|
|
16656
16956
|
}) {
|
|
16657
16957
|
super(generationId ? `${message} [${generationId}]` : message);
|
|
16658
16958
|
this[_a20] = true;
|
|
16659
16959
|
this.statusCode = statusCode;
|
|
16660
16960
|
this.cause = cause;
|
|
16661
16961
|
this.generationId = generationId;
|
|
16962
|
+
this.isRetryable = isRetryable;
|
|
16662
16963
|
}
|
|
16663
16964
|
/**
|
|
16664
16965
|
* Checks if the given error is a Gateway Error.
|
|
@@ -16827,58 +17128,109 @@ var GatewayInternalServerError2 = class extends (_b64 = GatewayError2, _a66 = sy
|
|
|
16827
17128
|
return GatewayError2.hasMarker(error) && symbol66 in error;
|
|
16828
17129
|
}
|
|
16829
17130
|
};
|
|
16830
|
-
var name66 = "
|
|
17131
|
+
var name66 = "GatewayFailedDependencyError";
|
|
16831
17132
|
var marker76 = `vercel.ai.gateway.error.${name66}`;
|
|
16832
17133
|
var symbol76 = Symbol.for(marker76);
|
|
16833
17134
|
var _a76;
|
|
16834
17135
|
var _b74;
|
|
16835
|
-
var
|
|
17136
|
+
var GatewayFailedDependencyError = class extends (_b74 = GatewayError2, _a76 = symbol76, _b74) {
|
|
16836
17137
|
constructor({
|
|
16837
|
-
message = "
|
|
16838
|
-
statusCode =
|
|
16839
|
-
response,
|
|
16840
|
-
validationError,
|
|
17138
|
+
message = "Failed dependency",
|
|
17139
|
+
statusCode = 424,
|
|
16841
17140
|
cause,
|
|
16842
17141
|
generationId
|
|
16843
17142
|
} = {}) {
|
|
16844
17143
|
super({ message, statusCode, cause, generationId });
|
|
16845
17144
|
this[_a76] = true;
|
|
16846
17145
|
this.name = name66;
|
|
16847
|
-
this.type = "
|
|
16848
|
-
this.response = response;
|
|
16849
|
-
this.validationError = validationError;
|
|
17146
|
+
this.type = "failed_dependency";
|
|
16850
17147
|
}
|
|
16851
17148
|
static isInstance(error) {
|
|
16852
17149
|
return GatewayError2.hasMarker(error) && symbol76 in error;
|
|
16853
17150
|
}
|
|
16854
17151
|
};
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
16876
|
-
|
|
17152
|
+
var name76 = "GatewayForbiddenError";
|
|
17153
|
+
var marker86 = `vercel.ai.gateway.error.${name76}`;
|
|
17154
|
+
var symbol86 = Symbol.for(marker86);
|
|
17155
|
+
var forbiddenParamSchema = lazySchema2(
|
|
17156
|
+
() => zodSchema3(
|
|
17157
|
+
z42.z.object({
|
|
17158
|
+
ruleId: z42.z.string()
|
|
17159
|
+
})
|
|
17160
|
+
)
|
|
17161
|
+
);
|
|
17162
|
+
var _a86;
|
|
17163
|
+
var _b84;
|
|
17164
|
+
var GatewayForbiddenError2 = class extends (_b84 = GatewayError2, _a86 = symbol86, _b84) {
|
|
17165
|
+
constructor({
|
|
17166
|
+
message = "Forbidden",
|
|
17167
|
+
statusCode = 403,
|
|
17168
|
+
cause,
|
|
17169
|
+
generationId,
|
|
17170
|
+
ruleId
|
|
17171
|
+
} = {}) {
|
|
17172
|
+
super({ message, statusCode, cause, generationId });
|
|
17173
|
+
this[_a86] = true;
|
|
17174
|
+
this.name = name76;
|
|
17175
|
+
this.type = "forbidden";
|
|
17176
|
+
this.ruleId = ruleId;
|
|
17177
|
+
}
|
|
17178
|
+
static isInstance(error) {
|
|
17179
|
+
return GatewayError2.hasMarker(error) && symbol86 in error;
|
|
17180
|
+
}
|
|
17181
|
+
};
|
|
17182
|
+
var name86 = "GatewayResponseError";
|
|
17183
|
+
var marker96 = `vercel.ai.gateway.error.${name86}`;
|
|
17184
|
+
var symbol96 = Symbol.for(marker96);
|
|
17185
|
+
var _a96;
|
|
17186
|
+
var _b94;
|
|
17187
|
+
var GatewayResponseError2 = class extends (_b94 = GatewayError2, _a96 = symbol96, _b94) {
|
|
17188
|
+
constructor({
|
|
17189
|
+
message = "Invalid response from Gateway",
|
|
17190
|
+
statusCode = 502,
|
|
17191
|
+
response,
|
|
17192
|
+
validationError,
|
|
17193
|
+
cause,
|
|
17194
|
+
generationId
|
|
17195
|
+
} = {}) {
|
|
17196
|
+
super({ message, statusCode, cause, generationId });
|
|
17197
|
+
this[_a96] = true;
|
|
17198
|
+
this.name = name86;
|
|
17199
|
+
this.type = "response_error";
|
|
17200
|
+
this.response = response;
|
|
17201
|
+
this.validationError = validationError;
|
|
17202
|
+
}
|
|
17203
|
+
static isInstance(error) {
|
|
17204
|
+
return GatewayError2.hasMarker(error) && symbol96 in error;
|
|
17205
|
+
}
|
|
17206
|
+
};
|
|
17207
|
+
async function createGatewayErrorFromResponse2({
|
|
17208
|
+
response,
|
|
17209
|
+
statusCode,
|
|
17210
|
+
defaultMessage = "Gateway request failed",
|
|
17211
|
+
cause,
|
|
17212
|
+
authMethod
|
|
17213
|
+
}) {
|
|
17214
|
+
var _a117;
|
|
17215
|
+
const parseResult = await safeValidateTypes3({
|
|
17216
|
+
value: response,
|
|
17217
|
+
schema: gatewayErrorResponseSchema2
|
|
17218
|
+
});
|
|
17219
|
+
if (!parseResult.success) {
|
|
17220
|
+
const rawGenerationId = typeof response === "object" && response !== null && "generationId" in response ? response.generationId : void 0;
|
|
17221
|
+
return new GatewayResponseError2({
|
|
17222
|
+
message: `Invalid error response format: ${defaultMessage}`,
|
|
17223
|
+
statusCode,
|
|
17224
|
+
response,
|
|
17225
|
+
validationError: parseResult.error,
|
|
17226
|
+
cause,
|
|
17227
|
+
generationId: rawGenerationId
|
|
17228
|
+
});
|
|
16877
17229
|
}
|
|
16878
17230
|
const validatedResponse = parseResult.value;
|
|
16879
17231
|
const errorType = validatedResponse.error.type;
|
|
16880
17232
|
const message = validatedResponse.error.message;
|
|
16881
|
-
const generationId = (
|
|
17233
|
+
const generationId = (_a117 = validatedResponse.generationId) != null ? _a117 : void 0;
|
|
16882
17234
|
switch (errorType) {
|
|
16883
17235
|
case "authentication_error":
|
|
16884
17236
|
return GatewayAuthenticationError2.createContextualError({
|
|
@@ -16922,6 +17274,26 @@ async function createGatewayErrorFromResponse2({
|
|
|
16922
17274
|
cause,
|
|
16923
17275
|
generationId
|
|
16924
17276
|
});
|
|
17277
|
+
case "failed_dependency":
|
|
17278
|
+
return new GatewayFailedDependencyError({
|
|
17279
|
+
message,
|
|
17280
|
+
statusCode,
|
|
17281
|
+
cause,
|
|
17282
|
+
generationId
|
|
17283
|
+
});
|
|
17284
|
+
case "forbidden": {
|
|
17285
|
+
const ruleResult = await safeValidateTypes3({
|
|
17286
|
+
value: validatedResponse.error.param,
|
|
17287
|
+
schema: forbiddenParamSchema
|
|
17288
|
+
});
|
|
17289
|
+
return new GatewayForbiddenError2({
|
|
17290
|
+
message,
|
|
17291
|
+
statusCode,
|
|
17292
|
+
cause,
|
|
17293
|
+
generationId,
|
|
17294
|
+
ruleId: ruleResult.success ? ruleResult.value.ruleId : void 0
|
|
17295
|
+
});
|
|
17296
|
+
}
|
|
16925
17297
|
default:
|
|
16926
17298
|
return new GatewayInternalServerError2({
|
|
16927
17299
|
message,
|
|
@@ -16950,19 +17322,19 @@ function extractApiCallResponse2(error) {
|
|
|
16950
17322
|
}
|
|
16951
17323
|
if (error.responseBody != null) {
|
|
16952
17324
|
try {
|
|
16953
|
-
return
|
|
17325
|
+
return secureJsonParse2(error.responseBody);
|
|
16954
17326
|
} catch (e) {
|
|
16955
17327
|
return error.responseBody;
|
|
16956
17328
|
}
|
|
16957
17329
|
}
|
|
16958
17330
|
return {};
|
|
16959
17331
|
}
|
|
16960
|
-
var
|
|
16961
|
-
var
|
|
16962
|
-
var
|
|
16963
|
-
var
|
|
16964
|
-
var
|
|
16965
|
-
var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (
|
|
17332
|
+
var name96 = "GatewayTimeoutError";
|
|
17333
|
+
var marker106 = `vercel.ai.gateway.error.${name96}`;
|
|
17334
|
+
var symbol106 = Symbol.for(marker106);
|
|
17335
|
+
var _a106;
|
|
17336
|
+
var _b103;
|
|
17337
|
+
var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (_b103 = GatewayError2, _a106 = symbol106, _b103) {
|
|
16966
17338
|
constructor({
|
|
16967
17339
|
message = "Request timed out",
|
|
16968
17340
|
statusCode = 408,
|
|
@@ -16970,12 +17342,12 @@ var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (_b84 = GatewayEr
|
|
|
16970
17342
|
generationId
|
|
16971
17343
|
} = {}) {
|
|
16972
17344
|
super({ message, statusCode, cause, generationId });
|
|
16973
|
-
this[
|
|
16974
|
-
this.name =
|
|
17345
|
+
this[_a106] = true;
|
|
17346
|
+
this.name = name96;
|
|
16975
17347
|
this.type = "timeout_error";
|
|
16976
17348
|
}
|
|
16977
17349
|
static isInstance(error) {
|
|
16978
|
-
return GatewayError2.hasMarker(error) &&
|
|
17350
|
+
return GatewayError2.hasMarker(error) && symbol106 in error;
|
|
16979
17351
|
}
|
|
16980
17352
|
/**
|
|
16981
17353
|
* Creates a helpful timeout error message with troubleshooting guidance
|
|
@@ -17013,7 +17385,7 @@ function isTimeoutError2(error) {
|
|
|
17013
17385
|
return false;
|
|
17014
17386
|
}
|
|
17015
17387
|
async function asGatewayError2(error, authMethod) {
|
|
17016
|
-
var
|
|
17388
|
+
var _a117;
|
|
17017
17389
|
if (GatewayError2.isInstance(error)) {
|
|
17018
17390
|
return error;
|
|
17019
17391
|
}
|
|
@@ -17032,7 +17404,7 @@ async function asGatewayError2(error, authMethod) {
|
|
|
17032
17404
|
}
|
|
17033
17405
|
return await createGatewayErrorFromResponse2({
|
|
17034
17406
|
response: extractApiCallResponse2(error),
|
|
17035
|
-
statusCode: (
|
|
17407
|
+
statusCode: (_a117 = error.statusCode) != null ? _a117 : 500,
|
|
17036
17408
|
defaultMessage: "Gateway request failed",
|
|
17037
17409
|
cause: error,
|
|
17038
17410
|
authMethod
|
|
@@ -17062,6 +17434,8 @@ var KNOWN_MODEL_TYPES2 = [
|
|
|
17062
17434
|
"image",
|
|
17063
17435
|
"language",
|
|
17064
17436
|
"reranking",
|
|
17437
|
+
"speech",
|
|
17438
|
+
"transcription",
|
|
17065
17439
|
"video"
|
|
17066
17440
|
];
|
|
17067
17441
|
var GatewayFetchMetadata2 = class {
|
|
@@ -17498,7 +17872,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
17498
17872
|
abortSignal,
|
|
17499
17873
|
providerOptions
|
|
17500
17874
|
}) {
|
|
17501
|
-
var
|
|
17875
|
+
var _a117, _b113;
|
|
17502
17876
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17503
17877
|
try {
|
|
17504
17878
|
const {
|
|
@@ -17529,10 +17903,10 @@ var GatewayEmbeddingModel2 = class {
|
|
|
17529
17903
|
});
|
|
17530
17904
|
return {
|
|
17531
17905
|
embeddings: responseBody.embeddings,
|
|
17532
|
-
usage: (
|
|
17906
|
+
usage: (_a117 = responseBody.usage) != null ? _a117 : void 0,
|
|
17533
17907
|
providerMetadata: responseBody.providerMetadata,
|
|
17534
17908
|
response: { headers: responseHeaders, body: rawValue },
|
|
17535
|
-
warnings: []
|
|
17909
|
+
warnings: (_b113 = responseBody.warnings) != null ? _b113 : []
|
|
17536
17910
|
};
|
|
17537
17911
|
} catch (error) {
|
|
17538
17912
|
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
@@ -17548,15 +17922,37 @@ var GatewayEmbeddingModel2 = class {
|
|
|
17548
17922
|
};
|
|
17549
17923
|
}
|
|
17550
17924
|
};
|
|
17925
|
+
var gatewayEmbeddingWarningSchema = z42.z.discriminatedUnion("type", [
|
|
17926
|
+
z42.z.object({
|
|
17927
|
+
type: z42.z.literal("unsupported"),
|
|
17928
|
+
feature: z42.z.string(),
|
|
17929
|
+
details: z42.z.string().optional()
|
|
17930
|
+
}),
|
|
17931
|
+
z42.z.object({
|
|
17932
|
+
type: z42.z.literal("compatibility"),
|
|
17933
|
+
feature: z42.z.string(),
|
|
17934
|
+
details: z42.z.string().optional()
|
|
17935
|
+
}),
|
|
17936
|
+
z42.z.object({
|
|
17937
|
+
type: z42.z.literal("other"),
|
|
17938
|
+
message: z42.z.string()
|
|
17939
|
+
})
|
|
17940
|
+
]);
|
|
17551
17941
|
var gatewayEmbeddingResponseSchema2 = lazySchema2(
|
|
17552
17942
|
() => zodSchema3(
|
|
17553
17943
|
z42.z.object({
|
|
17554
17944
|
embeddings: z42.z.array(z42.z.array(z42.z.number())),
|
|
17555
17945
|
usage: z42.z.object({ tokens: z42.z.number() }).nullish(),
|
|
17946
|
+
warnings: z42.z.array(gatewayEmbeddingWarningSchema).optional(),
|
|
17556
17947
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
17557
17948
|
})
|
|
17558
17949
|
)
|
|
17559
17950
|
);
|
|
17951
|
+
function mapGatewayWarnings(warnings) {
|
|
17952
|
+
return (warnings != null ? warnings : []).map(
|
|
17953
|
+
(warning) => warning.type === "deprecated" ? { type: "other", message: warning.message } : warning
|
|
17954
|
+
);
|
|
17955
|
+
}
|
|
17560
17956
|
var GatewayImageModel2 = class {
|
|
17561
17957
|
constructor(modelId, config) {
|
|
17562
17958
|
this.modelId = modelId;
|
|
@@ -17579,7 +17975,7 @@ var GatewayImageModel2 = class {
|
|
|
17579
17975
|
headers,
|
|
17580
17976
|
abortSignal
|
|
17581
17977
|
}) {
|
|
17582
|
-
var
|
|
17978
|
+
var _a117, _b113, _c;
|
|
17583
17979
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17584
17980
|
try {
|
|
17585
17981
|
const {
|
|
@@ -17618,7 +18014,7 @@ var GatewayImageModel2 = class {
|
|
|
17618
18014
|
return {
|
|
17619
18015
|
images: responseBody.images,
|
|
17620
18016
|
// Always base64 strings from server
|
|
17621
|
-
warnings: (
|
|
18017
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
17622
18018
|
providerMetadata: responseBody.providerMetadata,
|
|
17623
18019
|
response: {
|
|
17624
18020
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -17627,9 +18023,9 @@ var GatewayImageModel2 = class {
|
|
|
17627
18023
|
},
|
|
17628
18024
|
...responseBody.usage != null && {
|
|
17629
18025
|
usage: {
|
|
17630
|
-
inputTokens: (
|
|
17631
|
-
outputTokens: (
|
|
17632
|
-
totalTokens: (
|
|
18026
|
+
inputTokens: (_a117 = responseBody.usage.inputTokens) != null ? _a117 : void 0,
|
|
18027
|
+
outputTokens: (_b113 = responseBody.usage.outputTokens) != null ? _b113 : void 0,
|
|
18028
|
+
totalTokens: (_c = responseBody.usage.totalTokens) != null ? _c : void 0
|
|
17633
18029
|
}
|
|
17634
18030
|
}
|
|
17635
18031
|
};
|
|
@@ -17670,6 +18066,11 @@ var gatewayImageWarningSchema = z42.z.discriminatedUnion("type", [
|
|
|
17670
18066
|
feature: z42.z.string(),
|
|
17671
18067
|
details: z42.z.string().optional()
|
|
17672
18068
|
}),
|
|
18069
|
+
z42.z.object({
|
|
18070
|
+
type: z42.z.literal("deprecated"),
|
|
18071
|
+
setting: z42.z.string(),
|
|
18072
|
+
message: z42.z.string()
|
|
18073
|
+
}),
|
|
17673
18074
|
z42.z.object({
|
|
17674
18075
|
type: z42.z.literal("other"),
|
|
17675
18076
|
message: z42.z.string()
|
|
@@ -17705,12 +18106,14 @@ var GatewayVideoModel = class {
|
|
|
17705
18106
|
duration,
|
|
17706
18107
|
fps,
|
|
17707
18108
|
seed,
|
|
18109
|
+
generateAudio,
|
|
17708
18110
|
image,
|
|
18111
|
+
frameImages,
|
|
18112
|
+
inputReferences,
|
|
17709
18113
|
providerOptions,
|
|
17710
18114
|
headers,
|
|
17711
18115
|
abortSignal
|
|
17712
18116
|
}) {
|
|
17713
|
-
var _a932;
|
|
17714
18117
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17715
18118
|
try {
|
|
17716
18119
|
const { responseHeaders, value: responseBody } = await postJsonToApi2({
|
|
@@ -17730,8 +18133,20 @@ var GatewayVideoModel = class {
|
|
|
17730
18133
|
...duration && { duration },
|
|
17731
18134
|
...fps && { fps },
|
|
17732
18135
|
...seed && { seed },
|
|
18136
|
+
...generateAudio !== void 0 && { generateAudio },
|
|
17733
18137
|
...providerOptions && { providerOptions },
|
|
17734
|
-
...image && { image: maybeEncodeVideoFile(image) }
|
|
18138
|
+
...image && { image: maybeEncodeVideoFile(image) },
|
|
18139
|
+
...frameImages && {
|
|
18140
|
+
frameImages: frameImages.map((frame) => ({
|
|
18141
|
+
...frame,
|
|
18142
|
+
image: maybeEncodeVideoFile(frame.image)
|
|
18143
|
+
}))
|
|
18144
|
+
},
|
|
18145
|
+
...inputReferences && {
|
|
18146
|
+
inputReferences: inputReferences.map(
|
|
18147
|
+
(reference) => maybeEncodeVideoFile(reference)
|
|
18148
|
+
)
|
|
18149
|
+
}
|
|
17735
18150
|
},
|
|
17736
18151
|
successfulResponseHandler: async ({
|
|
17737
18152
|
response,
|
|
@@ -17806,7 +18221,7 @@ var GatewayVideoModel = class {
|
|
|
17806
18221
|
});
|
|
17807
18222
|
return {
|
|
17808
18223
|
videos: responseBody.videos,
|
|
17809
|
-
warnings: (
|
|
18224
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
17810
18225
|
providerMetadata: responseBody.providerMetadata,
|
|
17811
18226
|
response: {
|
|
17812
18227
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -17863,6 +18278,11 @@ var gatewayVideoWarningSchema = z42.z.discriminatedUnion("type", [
|
|
|
17863
18278
|
feature: z42.z.string(),
|
|
17864
18279
|
details: z42.z.string().optional()
|
|
17865
18280
|
}),
|
|
18281
|
+
z42.z.object({
|
|
18282
|
+
type: z42.z.literal("deprecated"),
|
|
18283
|
+
setting: z42.z.string(),
|
|
18284
|
+
message: z42.z.string()
|
|
18285
|
+
}),
|
|
17866
18286
|
z42.z.object({
|
|
17867
18287
|
type: z42.z.literal("other"),
|
|
17868
18288
|
message: z42.z.string()
|
|
@@ -17900,6 +18320,7 @@ var GatewayRerankingModel = class {
|
|
|
17900
18320
|
abortSignal,
|
|
17901
18321
|
providerOptions
|
|
17902
18322
|
}) {
|
|
18323
|
+
var _a117;
|
|
17903
18324
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17904
18325
|
try {
|
|
17905
18326
|
const {
|
|
@@ -17934,7 +18355,7 @@ var GatewayRerankingModel = class {
|
|
|
17934
18355
|
ranking: responseBody.ranking,
|
|
17935
18356
|
providerMetadata: responseBody.providerMetadata,
|
|
17936
18357
|
response: { headers: responseHeaders, body: rawValue },
|
|
17937
|
-
warnings: []
|
|
18358
|
+
warnings: (_a117 = responseBody.warnings) != null ? _a117 : []
|
|
17938
18359
|
};
|
|
17939
18360
|
} catch (error) {
|
|
17940
18361
|
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
@@ -17950,6 +18371,22 @@ var GatewayRerankingModel = class {
|
|
|
17950
18371
|
};
|
|
17951
18372
|
}
|
|
17952
18373
|
};
|
|
18374
|
+
var gatewayRerankingWarningSchema = z42.z.discriminatedUnion("type", [
|
|
18375
|
+
z42.z.object({
|
|
18376
|
+
type: z42.z.literal("unsupported"),
|
|
18377
|
+
feature: z42.z.string(),
|
|
18378
|
+
details: z42.z.string().optional()
|
|
18379
|
+
}),
|
|
18380
|
+
z42.z.object({
|
|
18381
|
+
type: z42.z.literal("compatibility"),
|
|
18382
|
+
feature: z42.z.string(),
|
|
18383
|
+
details: z42.z.string().optional()
|
|
18384
|
+
}),
|
|
18385
|
+
z42.z.object({
|
|
18386
|
+
type: z42.z.literal("other"),
|
|
18387
|
+
message: z42.z.string()
|
|
18388
|
+
})
|
|
18389
|
+
]);
|
|
17953
18390
|
var gatewayRerankingResponseSchema = lazySchema2(
|
|
17954
18391
|
() => zodSchema3(
|
|
17955
18392
|
z42.z.object({
|
|
@@ -17959,144 +18396,495 @@ var gatewayRerankingResponseSchema = lazySchema2(
|
|
|
17959
18396
|
relevanceScore: z42.z.number()
|
|
17960
18397
|
})
|
|
17961
18398
|
),
|
|
18399
|
+
warnings: z42.z.array(gatewayRerankingWarningSchema).optional(),
|
|
17962
18400
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
17963
18401
|
})
|
|
17964
18402
|
)
|
|
17965
18403
|
);
|
|
17966
|
-
var
|
|
17967
|
-
()
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
17978
|
-
|
|
17979
|
-
|
|
17980
|
-
|
|
17981
|
-
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
|
|
17986
|
-
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
|
|
18033
|
-
)
|
|
18034
|
-
|
|
18035
|
-
|
|
18036
|
-
|
|
18037
|
-
|
|
18038
|
-
}
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18043
|
-
|
|
18044
|
-
|
|
18045
|
-
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
|
|
18049
|
-
|
|
18050
|
-
|
|
18051
|
-
|
|
18052
|
-
|
|
18053
|
-
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18079
|
-
|
|
18080
|
-
)
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
18096
|
-
|
|
18097
|
-
}
|
|
18098
|
-
|
|
18099
|
-
|
|
18404
|
+
var GatewaySpeechModel = class {
|
|
18405
|
+
constructor(modelId, config) {
|
|
18406
|
+
this.modelId = modelId;
|
|
18407
|
+
this.config = config;
|
|
18408
|
+
this.specificationVersion = "v3";
|
|
18409
|
+
}
|
|
18410
|
+
get provider() {
|
|
18411
|
+
return this.config.provider;
|
|
18412
|
+
}
|
|
18413
|
+
async doGenerate({
|
|
18414
|
+
text: text4,
|
|
18415
|
+
voice,
|
|
18416
|
+
outputFormat,
|
|
18417
|
+
instructions,
|
|
18418
|
+
speed,
|
|
18419
|
+
language,
|
|
18420
|
+
providerOptions,
|
|
18421
|
+
headers,
|
|
18422
|
+
abortSignal
|
|
18423
|
+
}) {
|
|
18424
|
+
const resolvedHeaders = await resolve2(this.config.headers());
|
|
18425
|
+
try {
|
|
18426
|
+
const {
|
|
18427
|
+
responseHeaders,
|
|
18428
|
+
value: responseBody,
|
|
18429
|
+
rawValue
|
|
18430
|
+
} = await postJsonToApi2({
|
|
18431
|
+
url: this.getUrl(),
|
|
18432
|
+
headers: combineHeaders2(
|
|
18433
|
+
resolvedHeaders,
|
|
18434
|
+
headers != null ? headers : {},
|
|
18435
|
+
this.getModelConfigHeaders(),
|
|
18436
|
+
await resolve2(this.config.o11yHeaders)
|
|
18437
|
+
),
|
|
18438
|
+
body: {
|
|
18439
|
+
text: text4,
|
|
18440
|
+
...voice && { voice },
|
|
18441
|
+
...outputFormat && { outputFormat },
|
|
18442
|
+
...instructions && { instructions },
|
|
18443
|
+
...speed != null && { speed },
|
|
18444
|
+
...language && { language },
|
|
18445
|
+
...providerOptions && { providerOptions }
|
|
18446
|
+
},
|
|
18447
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
18448
|
+
gatewaySpeechResponseSchema
|
|
18449
|
+
),
|
|
18450
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
18451
|
+
errorSchema: z42.z.any(),
|
|
18452
|
+
errorToMessage: (data) => data
|
|
18453
|
+
}),
|
|
18454
|
+
...abortSignal && { abortSignal },
|
|
18455
|
+
fetch: this.config.fetch
|
|
18456
|
+
});
|
|
18457
|
+
return {
|
|
18458
|
+
audio: responseBody.audio,
|
|
18459
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
18460
|
+
providerMetadata: responseBody.providerMetadata,
|
|
18461
|
+
response: {
|
|
18462
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
18463
|
+
modelId: this.modelId,
|
|
18464
|
+
headers: responseHeaders,
|
|
18465
|
+
body: rawValue
|
|
18466
|
+
}
|
|
18467
|
+
};
|
|
18468
|
+
} catch (error) {
|
|
18469
|
+
throw await asGatewayError2(
|
|
18470
|
+
error,
|
|
18471
|
+
await parseAuthMethod2(resolvedHeaders != null ? resolvedHeaders : {})
|
|
18472
|
+
);
|
|
18473
|
+
}
|
|
18474
|
+
}
|
|
18475
|
+
getUrl() {
|
|
18476
|
+
return `${this.config.baseURL}/speech-model`;
|
|
18477
|
+
}
|
|
18478
|
+
getModelConfigHeaders() {
|
|
18479
|
+
return {
|
|
18480
|
+
"ai-speech-model-specification-version": "3",
|
|
18481
|
+
"ai-model-id": this.modelId
|
|
18482
|
+
};
|
|
18483
|
+
}
|
|
18484
|
+
};
|
|
18485
|
+
var providerMetadataEntrySchema3 = z42.z.object({}).catchall(z42.z.unknown());
|
|
18486
|
+
var gatewaySpeechWarningSchema = z42.z.discriminatedUnion("type", [
|
|
18487
|
+
z42.z.object({
|
|
18488
|
+
type: z42.z.literal("unsupported"),
|
|
18489
|
+
feature: z42.z.string(),
|
|
18490
|
+
details: z42.z.string().optional()
|
|
18491
|
+
}),
|
|
18492
|
+
z42.z.object({
|
|
18493
|
+
type: z42.z.literal("compatibility"),
|
|
18494
|
+
feature: z42.z.string(),
|
|
18495
|
+
details: z42.z.string().optional()
|
|
18496
|
+
}),
|
|
18497
|
+
z42.z.object({
|
|
18498
|
+
type: z42.z.literal("deprecated"),
|
|
18499
|
+
setting: z42.z.string(),
|
|
18500
|
+
message: z42.z.string()
|
|
18501
|
+
}),
|
|
18502
|
+
z42.z.object({
|
|
18503
|
+
type: z42.z.literal("other"),
|
|
18504
|
+
message: z42.z.string()
|
|
18505
|
+
})
|
|
18506
|
+
]);
|
|
18507
|
+
var gatewaySpeechResponseSchema = z42.z.object({
|
|
18508
|
+
audio: z42.z.string(),
|
|
18509
|
+
warnings: z42.z.array(gatewaySpeechWarningSchema).optional(),
|
|
18510
|
+
providerMetadata: z42.z.record(z42.z.string(), providerMetadataEntrySchema3).optional()
|
|
18511
|
+
});
|
|
18512
|
+
var GatewayTranscriptionModel = class {
|
|
18513
|
+
constructor(modelId, config) {
|
|
18514
|
+
this.modelId = modelId;
|
|
18515
|
+
this.config = config;
|
|
18516
|
+
this.specificationVersion = "v3";
|
|
18517
|
+
}
|
|
18518
|
+
get provider() {
|
|
18519
|
+
return this.config.provider;
|
|
18520
|
+
}
|
|
18521
|
+
async doGenerate({
|
|
18522
|
+
audio,
|
|
18523
|
+
mediaType,
|
|
18524
|
+
providerOptions,
|
|
18525
|
+
headers,
|
|
18526
|
+
abortSignal
|
|
18527
|
+
}) {
|
|
18528
|
+
var _a117, _b113, _c;
|
|
18529
|
+
const resolvedHeaders = await resolve2(this.config.headers());
|
|
18530
|
+
try {
|
|
18531
|
+
const {
|
|
18532
|
+
responseHeaders,
|
|
18533
|
+
value: responseBody,
|
|
18534
|
+
rawValue
|
|
18535
|
+
} = await postJsonToApi2({
|
|
18536
|
+
url: this.getUrl(),
|
|
18537
|
+
headers: combineHeaders2(
|
|
18538
|
+
resolvedHeaders,
|
|
18539
|
+
headers != null ? headers : {},
|
|
18540
|
+
this.getModelConfigHeaders(),
|
|
18541
|
+
await resolve2(this.config.o11yHeaders)
|
|
18542
|
+
),
|
|
18543
|
+
body: {
|
|
18544
|
+
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase643(audio) : audio,
|
|
18545
|
+
mediaType,
|
|
18546
|
+
...providerOptions && { providerOptions }
|
|
18547
|
+
},
|
|
18548
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
18549
|
+
gatewayTranscriptionResponseSchema
|
|
18550
|
+
),
|
|
18551
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
18552
|
+
errorSchema: z42.z.any(),
|
|
18553
|
+
errorToMessage: (data) => data
|
|
18554
|
+
}),
|
|
18555
|
+
...abortSignal && { abortSignal },
|
|
18556
|
+
fetch: this.config.fetch
|
|
18557
|
+
});
|
|
18558
|
+
return {
|
|
18559
|
+
text: responseBody.text,
|
|
18560
|
+
segments: (_a117 = responseBody.segments) != null ? _a117 : [],
|
|
18561
|
+
language: (_b113 = responseBody.language) != null ? _b113 : void 0,
|
|
18562
|
+
durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : void 0,
|
|
18563
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
18564
|
+
providerMetadata: responseBody.providerMetadata,
|
|
18565
|
+
response: {
|
|
18566
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
18567
|
+
modelId: this.modelId,
|
|
18568
|
+
headers: responseHeaders,
|
|
18569
|
+
body: rawValue
|
|
18570
|
+
}
|
|
18571
|
+
};
|
|
18572
|
+
} catch (error) {
|
|
18573
|
+
throw await asGatewayError2(
|
|
18574
|
+
error,
|
|
18575
|
+
await parseAuthMethod2(resolvedHeaders != null ? resolvedHeaders : {})
|
|
18576
|
+
);
|
|
18577
|
+
}
|
|
18578
|
+
}
|
|
18579
|
+
getUrl() {
|
|
18580
|
+
return `${this.config.baseURL}/transcription-model`;
|
|
18581
|
+
}
|
|
18582
|
+
getModelConfigHeaders() {
|
|
18583
|
+
return {
|
|
18584
|
+
"ai-transcription-model-specification-version": "3",
|
|
18585
|
+
"ai-model-id": this.modelId
|
|
18586
|
+
};
|
|
18587
|
+
}
|
|
18588
|
+
};
|
|
18589
|
+
var providerMetadataEntrySchema4 = z42.z.object({}).catchall(z42.z.unknown());
|
|
18590
|
+
var gatewayTranscriptionWarningSchema = z42.z.discriminatedUnion("type", [
|
|
18591
|
+
z42.z.object({
|
|
18592
|
+
type: z42.z.literal("unsupported"),
|
|
18593
|
+
feature: z42.z.string(),
|
|
18594
|
+
details: z42.z.string().optional()
|
|
18595
|
+
}),
|
|
18596
|
+
z42.z.object({
|
|
18597
|
+
type: z42.z.literal("compatibility"),
|
|
18598
|
+
feature: z42.z.string(),
|
|
18599
|
+
details: z42.z.string().optional()
|
|
18600
|
+
}),
|
|
18601
|
+
z42.z.object({
|
|
18602
|
+
type: z42.z.literal("deprecated"),
|
|
18603
|
+
setting: z42.z.string(),
|
|
18604
|
+
message: z42.z.string()
|
|
18605
|
+
}),
|
|
18606
|
+
z42.z.object({
|
|
18607
|
+
type: z42.z.literal("other"),
|
|
18608
|
+
message: z42.z.string()
|
|
18609
|
+
})
|
|
18610
|
+
]);
|
|
18611
|
+
var gatewayTranscriptionResponseSchema = z42.z.object({
|
|
18612
|
+
text: z42.z.string(),
|
|
18613
|
+
segments: z42.z.array(
|
|
18614
|
+
z42.z.object({
|
|
18615
|
+
text: z42.z.string(),
|
|
18616
|
+
startSecond: z42.z.number(),
|
|
18617
|
+
endSecond: z42.z.number()
|
|
18618
|
+
})
|
|
18619
|
+
).optional(),
|
|
18620
|
+
language: z42.z.string().nullish(),
|
|
18621
|
+
durationInSeconds: z42.z.number().nullish(),
|
|
18622
|
+
warnings: z42.z.array(gatewayTranscriptionWarningSchema).optional(),
|
|
18623
|
+
providerMetadata: z42.z.record(z42.z.string(), providerMetadataEntrySchema4).optional()
|
|
18624
|
+
});
|
|
18625
|
+
var exaSearchInputSchema = lazySchema2(
|
|
18626
|
+
() => zodSchema3(
|
|
18627
|
+
zod.z.object({
|
|
18628
|
+
query: zod.z.string().describe("Natural-language web search query. This is required."),
|
|
18629
|
+
type: zod.z.enum(["auto", "fast", "instant"]).optional().describe(
|
|
18630
|
+
"Search method. Use auto for the default balance of speed and quality."
|
|
18631
|
+
),
|
|
18632
|
+
num_results: zod.z.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
|
|
18633
|
+
category: zod.z.enum([
|
|
18634
|
+
"company",
|
|
18635
|
+
"people",
|
|
18636
|
+
"research paper",
|
|
18637
|
+
"news",
|
|
18638
|
+
"personal site",
|
|
18639
|
+
"financial report"
|
|
18640
|
+
]).optional().describe("Optional content category to focus results."),
|
|
18641
|
+
user_location: zod.z.string().optional().describe("Two-letter ISO country code such as 'US'."),
|
|
18642
|
+
include_domains: zod.z.array(zod.z.string()).optional().describe("Only return results from these domains."),
|
|
18643
|
+
exclude_domains: zod.z.array(zod.z.string()).optional().describe("Exclude results from these domains."),
|
|
18644
|
+
start_published_date: zod.z.string().optional().describe("Only return links published after this ISO 8601 date."),
|
|
18645
|
+
end_published_date: zod.z.string().optional().describe("Only return links published before this ISO 8601 date."),
|
|
18646
|
+
contents: zod.z.object({
|
|
18647
|
+
text: zod.z.union([
|
|
18648
|
+
zod.z.boolean(),
|
|
18649
|
+
zod.z.object({
|
|
18650
|
+
max_characters: zod.z.number().optional(),
|
|
18651
|
+
include_html_tags: zod.z.boolean().optional(),
|
|
18652
|
+
verbosity: zod.z.enum(["compact", "standard", "full"]).optional(),
|
|
18653
|
+
include_sections: zod.z.array(
|
|
18654
|
+
zod.z.enum([
|
|
18655
|
+
"header",
|
|
18656
|
+
"navigation",
|
|
18657
|
+
"banner",
|
|
18658
|
+
"body",
|
|
18659
|
+
"sidebar",
|
|
18660
|
+
"footer",
|
|
18661
|
+
"metadata"
|
|
18662
|
+
])
|
|
18663
|
+
).optional(),
|
|
18664
|
+
exclude_sections: zod.z.array(
|
|
18665
|
+
zod.z.enum([
|
|
18666
|
+
"header",
|
|
18667
|
+
"navigation",
|
|
18668
|
+
"banner",
|
|
18669
|
+
"body",
|
|
18670
|
+
"sidebar",
|
|
18671
|
+
"footer",
|
|
18672
|
+
"metadata"
|
|
18673
|
+
])
|
|
18674
|
+
).optional()
|
|
18675
|
+
})
|
|
18676
|
+
]).optional(),
|
|
18677
|
+
highlights: zod.z.union([
|
|
18678
|
+
zod.z.boolean(),
|
|
18679
|
+
zod.z.object({
|
|
18680
|
+
query: zod.z.string().optional(),
|
|
18681
|
+
max_characters: zod.z.number().optional()
|
|
18682
|
+
})
|
|
18683
|
+
]).optional(),
|
|
18684
|
+
max_age_hours: zod.z.number().optional(),
|
|
18685
|
+
livecrawl_timeout: zod.z.number().optional(),
|
|
18686
|
+
subpages: zod.z.number().optional(),
|
|
18687
|
+
subpage_target: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).optional(),
|
|
18688
|
+
extras: zod.z.object({
|
|
18689
|
+
links: zod.z.number().optional(),
|
|
18690
|
+
image_links: zod.z.number().optional()
|
|
18691
|
+
}).optional()
|
|
18692
|
+
}).optional().describe("Controls extracted page content and freshness.")
|
|
18693
|
+
})
|
|
18694
|
+
)
|
|
18695
|
+
);
|
|
18696
|
+
var exaSearchOutputSchema = lazySchema2(
|
|
18697
|
+
() => zodSchema3(
|
|
18698
|
+
zod.z.union([
|
|
18699
|
+
zod.z.object({
|
|
18700
|
+
requestId: zod.z.string(),
|
|
18701
|
+
searchType: zod.z.string().optional(),
|
|
18702
|
+
resolvedSearchType: zod.z.string().optional(),
|
|
18703
|
+
results: zod.z.array(
|
|
18704
|
+
zod.z.object({
|
|
18705
|
+
title: zod.z.string(),
|
|
18706
|
+
url: zod.z.string(),
|
|
18707
|
+
id: zod.z.string(),
|
|
18708
|
+
publishedDate: zod.z.string().nullable().optional(),
|
|
18709
|
+
author: zod.z.string().nullable().optional(),
|
|
18710
|
+
image: zod.z.string().nullable().optional(),
|
|
18711
|
+
favicon: zod.z.string().nullable().optional(),
|
|
18712
|
+
text: zod.z.string().optional(),
|
|
18713
|
+
highlights: zod.z.array(zod.z.string()).optional(),
|
|
18714
|
+
highlightScores: zod.z.array(zod.z.number()).optional(),
|
|
18715
|
+
summary: zod.z.string().optional(),
|
|
18716
|
+
subpages: zod.z.array(zod.z.any()).optional(),
|
|
18717
|
+
extras: zod.z.object({
|
|
18718
|
+
links: zod.z.array(zod.z.string()).optional(),
|
|
18719
|
+
imageLinks: zod.z.array(zod.z.string()).optional()
|
|
18720
|
+
}).optional()
|
|
18721
|
+
})
|
|
18722
|
+
),
|
|
18723
|
+
costDollars: zod.z.object({
|
|
18724
|
+
total: zod.z.number().optional(),
|
|
18725
|
+
search: zod.z.record(zod.z.number()).optional()
|
|
18726
|
+
}).optional()
|
|
18727
|
+
}),
|
|
18728
|
+
zod.z.object({
|
|
18729
|
+
error: zod.z.enum([
|
|
18730
|
+
"api_error",
|
|
18731
|
+
"rate_limit",
|
|
18732
|
+
"timeout",
|
|
18733
|
+
"invalid_input",
|
|
18734
|
+
"configuration_error",
|
|
18735
|
+
"execution_error",
|
|
18736
|
+
"unknown"
|
|
18737
|
+
]),
|
|
18738
|
+
statusCode: zod.z.number().optional(),
|
|
18739
|
+
message: zod.z.string()
|
|
18740
|
+
})
|
|
18741
|
+
])
|
|
18742
|
+
)
|
|
18743
|
+
);
|
|
18744
|
+
var exaSearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
18745
|
+
id: "gateway.exa_search",
|
|
18746
|
+
inputSchema: exaSearchInputSchema,
|
|
18747
|
+
outputSchema: exaSearchOutputSchema
|
|
18748
|
+
});
|
|
18749
|
+
var exaSearch = (config = {}) => exaSearchToolFactory(config);
|
|
18750
|
+
var parallelSearchInputSchema2 = lazySchema2(
|
|
18751
|
+
() => zodSchema3(
|
|
18752
|
+
zod.z.object({
|
|
18753
|
+
objective: zod.z.string().describe(
|
|
18754
|
+
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
18755
|
+
),
|
|
18756
|
+
search_queries: zod.z.array(zod.z.string()).optional().describe(
|
|
18757
|
+
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
18758
|
+
),
|
|
18759
|
+
mode: zod.z.enum(["one-shot", "agentic"]).optional().describe(
|
|
18760
|
+
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
18761
|
+
),
|
|
18762
|
+
max_results: zod.z.number().optional().describe(
|
|
18763
|
+
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
18764
|
+
),
|
|
18765
|
+
source_policy: zod.z.object({
|
|
18766
|
+
include_domains: zod.z.array(zod.z.string()).optional().describe(
|
|
18767
|
+
"Limit results to these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."
|
|
18768
|
+
),
|
|
18769
|
+
exclude_domains: zod.z.array(zod.z.string()).optional().describe(
|
|
18770
|
+
"Exclude results from these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."
|
|
18771
|
+
),
|
|
18772
|
+
after_date: zod.z.string().optional().describe(
|
|
18773
|
+
"Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time."
|
|
18774
|
+
)
|
|
18775
|
+
}).optional().describe(
|
|
18776
|
+
"Source policy for controlling which domains to include/exclude and freshness."
|
|
18777
|
+
),
|
|
18778
|
+
excerpts: zod.z.object({
|
|
18779
|
+
max_chars_per_result: zod.z.number().optional().describe("Maximum characters per result."),
|
|
18780
|
+
max_chars_total: zod.z.number().optional().describe("Maximum total characters across all results.")
|
|
18781
|
+
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
18782
|
+
fetch_policy: zod.z.object({
|
|
18783
|
+
max_age_seconds: zod.z.number().optional().describe(
|
|
18784
|
+
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
18785
|
+
)
|
|
18786
|
+
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
18787
|
+
})
|
|
18788
|
+
)
|
|
18789
|
+
);
|
|
18790
|
+
var parallelSearchOutputSchema2 = lazySchema2(
|
|
18791
|
+
() => zodSchema3(
|
|
18792
|
+
zod.z.union([
|
|
18793
|
+
// Success response
|
|
18794
|
+
zod.z.object({
|
|
18795
|
+
searchId: zod.z.string(),
|
|
18796
|
+
results: zod.z.array(
|
|
18797
|
+
zod.z.object({
|
|
18798
|
+
url: zod.z.string(),
|
|
18799
|
+
title: zod.z.string(),
|
|
18800
|
+
excerpt: zod.z.string(),
|
|
18801
|
+
publishDate: zod.z.string().nullable().optional(),
|
|
18802
|
+
relevanceScore: zod.z.number().optional()
|
|
18803
|
+
})
|
|
18804
|
+
)
|
|
18805
|
+
}),
|
|
18806
|
+
// Error response
|
|
18807
|
+
zod.z.object({
|
|
18808
|
+
error: zod.z.enum([
|
|
18809
|
+
"api_error",
|
|
18810
|
+
"rate_limit",
|
|
18811
|
+
"timeout",
|
|
18812
|
+
"invalid_input",
|
|
18813
|
+
"configuration_error",
|
|
18814
|
+
"unknown"
|
|
18815
|
+
]),
|
|
18816
|
+
statusCode: zod.z.number().optional(),
|
|
18817
|
+
message: zod.z.string()
|
|
18818
|
+
})
|
|
18819
|
+
])
|
|
18820
|
+
)
|
|
18821
|
+
);
|
|
18822
|
+
var parallelSearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
|
|
18823
|
+
id: "gateway.parallel_search",
|
|
18824
|
+
inputSchema: parallelSearchInputSchema2,
|
|
18825
|
+
outputSchema: parallelSearchOutputSchema2
|
|
18826
|
+
});
|
|
18827
|
+
var parallelSearch2 = (config = {}) => parallelSearchToolFactory2(config);
|
|
18828
|
+
var perplexitySearchInputSchema2 = lazySchema2(
|
|
18829
|
+
() => zodSchema3(
|
|
18830
|
+
zod.z.object({
|
|
18831
|
+
query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
|
|
18832
|
+
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
18833
|
+
),
|
|
18834
|
+
max_results: zod.z.number().optional().describe(
|
|
18835
|
+
"Maximum number of search results to return (1-20, default: 10)"
|
|
18836
|
+
),
|
|
18837
|
+
max_tokens_per_page: zod.z.number().optional().describe(
|
|
18838
|
+
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
18839
|
+
),
|
|
18840
|
+
max_tokens: zod.z.number().optional().describe(
|
|
18841
|
+
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
18842
|
+
),
|
|
18843
|
+
country: zod.z.string().optional().describe(
|
|
18844
|
+
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
18845
|
+
),
|
|
18846
|
+
search_domain_filter: zod.z.array(zod.z.string()).optional().describe(
|
|
18847
|
+
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
18848
|
+
),
|
|
18849
|
+
search_language_filter: zod.z.array(zod.z.string()).optional().describe(
|
|
18850
|
+
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
18851
|
+
),
|
|
18852
|
+
search_after_date: zod.z.string().optional().describe(
|
|
18853
|
+
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
18854
|
+
),
|
|
18855
|
+
search_before_date: zod.z.string().optional().describe(
|
|
18856
|
+
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
18857
|
+
),
|
|
18858
|
+
last_updated_after_filter: zod.z.string().optional().describe(
|
|
18859
|
+
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
18860
|
+
),
|
|
18861
|
+
last_updated_before_filter: zod.z.string().optional().describe(
|
|
18862
|
+
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
18863
|
+
),
|
|
18864
|
+
search_recency_filter: zod.z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
18865
|
+
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
18866
|
+
)
|
|
18867
|
+
})
|
|
18868
|
+
)
|
|
18869
|
+
);
|
|
18870
|
+
var perplexitySearchOutputSchema2 = lazySchema2(
|
|
18871
|
+
() => zodSchema3(
|
|
18872
|
+
zod.z.union([
|
|
18873
|
+
// Success response
|
|
18874
|
+
zod.z.object({
|
|
18875
|
+
results: zod.z.array(
|
|
18876
|
+
zod.z.object({
|
|
18877
|
+
title: zod.z.string(),
|
|
18878
|
+
url: zod.z.string(),
|
|
18879
|
+
snippet: zod.z.string(),
|
|
18880
|
+
date: zod.z.string().optional(),
|
|
18881
|
+
lastUpdated: zod.z.string().optional()
|
|
18882
|
+
})
|
|
18883
|
+
),
|
|
18884
|
+
id: zod.z.string()
|
|
18885
|
+
}),
|
|
18886
|
+
// Error response
|
|
18887
|
+
zod.z.object({
|
|
18100
18888
|
error: zod.z.enum([
|
|
18101
18889
|
"api_error",
|
|
18102
18890
|
"rate_limit",
|
|
@@ -18117,6 +18905,14 @@ var perplexitySearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
|
|
|
18117
18905
|
});
|
|
18118
18906
|
var perplexitySearch2 = (config = {}) => perplexitySearchToolFactory2(config);
|
|
18119
18907
|
var gatewayTools2 = {
|
|
18908
|
+
/**
|
|
18909
|
+
* Search the web using Exa for current information and token-efficient
|
|
18910
|
+
* excerpts optimized for agent workflows.
|
|
18911
|
+
*
|
|
18912
|
+
* Supports search type, category, domain, date, location, and content
|
|
18913
|
+
* extraction controls.
|
|
18914
|
+
*/
|
|
18915
|
+
exaSearch,
|
|
18120
18916
|
/**
|
|
18121
18917
|
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
18122
18918
|
*
|
|
@@ -18136,18 +18932,18 @@ var gatewayTools2 = {
|
|
|
18136
18932
|
perplexitySearch: perplexitySearch2
|
|
18137
18933
|
};
|
|
18138
18934
|
async function getVercelRequestId2() {
|
|
18139
|
-
var
|
|
18140
|
-
return (
|
|
18935
|
+
var _a117;
|
|
18936
|
+
return (_a117 = getContext2().headers) == null ? void 0 : _a117["x-vercel-id"];
|
|
18141
18937
|
}
|
|
18142
|
-
var VERSION5 = "3.0.
|
|
18938
|
+
var VERSION5 = "3.0.148";
|
|
18143
18939
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
18144
18940
|
function createGatewayProvider2(options = {}) {
|
|
18145
|
-
var
|
|
18941
|
+
var _a117, _b113;
|
|
18146
18942
|
let pendingMetadata = null;
|
|
18147
18943
|
let metadataCache = null;
|
|
18148
|
-
const cacheRefreshMillis = (
|
|
18944
|
+
const cacheRefreshMillis = (_a117 = options.metadataCacheRefreshMillis) != null ? _a117 : 1e3 * 60 * 5;
|
|
18149
18945
|
let lastFetchTime = 0;
|
|
18150
|
-
const baseURL = (
|
|
18946
|
+
const baseURL = (_b113 = withoutTrailingSlash2(options.baseURL)) != null ? _b113 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
18151
18947
|
const getHeaders = async () => {
|
|
18152
18948
|
try {
|
|
18153
18949
|
const auth = await getGatewayAuthToken2(options);
|
|
@@ -18207,10 +19003,10 @@ function createGatewayProvider2(options = {}) {
|
|
|
18207
19003
|
});
|
|
18208
19004
|
};
|
|
18209
19005
|
const getAvailableModels = async () => {
|
|
18210
|
-
var
|
|
18211
|
-
const
|
|
18212
|
-
if (!pendingMetadata ||
|
|
18213
|
-
lastFetchTime =
|
|
19006
|
+
var _a126, _b123, _c;
|
|
19007
|
+
const now = (_c = (_b123 = (_a126 = options._internal) == null ? void 0 : _a126.currentDate) == null ? void 0 : _b123.call(_a126).getTime()) != null ? _c : Date.now();
|
|
19008
|
+
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
19009
|
+
lastFetchTime = now;
|
|
18214
19010
|
pendingMetadata = new GatewayFetchMetadata2({
|
|
18215
19011
|
baseURL,
|
|
18216
19012
|
headers: getHeaders,
|
|
@@ -18317,6 +19113,28 @@ function createGatewayProvider2(options = {}) {
|
|
|
18317
19113
|
};
|
|
18318
19114
|
provider.rerankingModel = createRerankingModel;
|
|
18319
19115
|
provider.reranking = createRerankingModel;
|
|
19116
|
+
const createSpeechModel = (modelId) => {
|
|
19117
|
+
return new GatewaySpeechModel(modelId, {
|
|
19118
|
+
provider: "gateway",
|
|
19119
|
+
baseURL,
|
|
19120
|
+
headers: getHeaders,
|
|
19121
|
+
fetch: options.fetch,
|
|
19122
|
+
o11yHeaders: createO11yHeaders()
|
|
19123
|
+
});
|
|
19124
|
+
};
|
|
19125
|
+
provider.speechModel = createSpeechModel;
|
|
19126
|
+
provider.speech = createSpeechModel;
|
|
19127
|
+
const createTranscriptionModel = (modelId) => {
|
|
19128
|
+
return new GatewayTranscriptionModel(modelId, {
|
|
19129
|
+
provider: "gateway",
|
|
19130
|
+
baseURL,
|
|
19131
|
+
headers: getHeaders,
|
|
19132
|
+
fetch: options.fetch,
|
|
19133
|
+
o11yHeaders: createO11yHeaders()
|
|
19134
|
+
});
|
|
19135
|
+
};
|
|
19136
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
19137
|
+
provider.transcription = createTranscriptionModel;
|
|
18320
19138
|
provider.chat = provider.languageModel;
|
|
18321
19139
|
provider.embedding = provider.embeddingModel;
|
|
18322
19140
|
provider.image = provider.imageModel;
|
|
@@ -18342,19 +19160,16 @@ async function getGatewayAuthToken2(options) {
|
|
|
18342
19160
|
authMethod: "oidc"
|
|
18343
19161
|
};
|
|
18344
19162
|
}
|
|
18345
|
-
var
|
|
18346
|
-
var VERSION23 = "1.9.0";
|
|
19163
|
+
var VERSION6 = "1.9.1";
|
|
18347
19164
|
var re3 = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
18348
19165
|
function _makeCompatibilityCheck3(ownVersion) {
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
19166
|
+
const acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
|
|
19167
|
+
const rejectedVersions = /* @__PURE__ */ new Set();
|
|
19168
|
+
const myVersionMatch = ownVersion.match(re3);
|
|
18352
19169
|
if (!myVersionMatch) {
|
|
18353
|
-
return
|
|
18354
|
-
return false;
|
|
18355
|
-
};
|
|
19170
|
+
return () => false;
|
|
18356
19171
|
}
|
|
18357
|
-
|
|
19172
|
+
const ownVersionParsed = {
|
|
18358
19173
|
major: +myVersionMatch[1],
|
|
18359
19174
|
minor: +myVersionMatch[2],
|
|
18360
19175
|
patch: +myVersionMatch[3],
|
|
@@ -18380,11 +19195,11 @@ function _makeCompatibilityCheck3(ownVersion) {
|
|
|
18380
19195
|
if (rejectedVersions.has(globalVersion)) {
|
|
18381
19196
|
return false;
|
|
18382
19197
|
}
|
|
18383
|
-
|
|
19198
|
+
const globalVersionMatch = globalVersion.match(re3);
|
|
18384
19199
|
if (!globalVersionMatch) {
|
|
18385
19200
|
return _reject(globalVersion);
|
|
18386
19201
|
}
|
|
18387
|
-
|
|
19202
|
+
const globalVersionParsed = {
|
|
18388
19203
|
major: +globalVersionMatch[1],
|
|
18389
19204
|
minor: +globalVersionMatch[2],
|
|
18390
19205
|
patch: +globalVersionMatch[3],
|
|
@@ -18400,457 +19215,326 @@ function _makeCompatibilityCheck3(ownVersion) {
|
|
|
18400
19215
|
if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
|
|
18401
19216
|
return _accept(globalVersion);
|
|
18402
19217
|
}
|
|
18403
|
-
return _reject(globalVersion);
|
|
18404
|
-
}
|
|
18405
|
-
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
18406
|
-
return _accept(globalVersion);
|
|
18407
|
-
}
|
|
18408
|
-
return _reject(globalVersion);
|
|
18409
|
-
};
|
|
18410
|
-
}
|
|
18411
|
-
var isCompatible3 = _makeCompatibilityCheck3(VERSION23);
|
|
18412
|
-
var major3 = VERSION23.split(".")[0];
|
|
18413
|
-
var GLOBAL_OPENTELEMETRY_API_KEY3 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major3);
|
|
18414
|
-
var _global3 = _globalThis3;
|
|
18415
|
-
function registerGlobal3(type, instance, diag, allowOverride) {
|
|
18416
|
-
var _a21;
|
|
18417
|
-
if (allowOverride === void 0) {
|
|
18418
|
-
allowOverride = false;
|
|
18419
|
-
}
|
|
18420
|
-
var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a21 !== void 0 ? _a21 : {
|
|
18421
|
-
version: VERSION23
|
|
18422
|
-
};
|
|
18423
|
-
if (!allowOverride && api[type]) {
|
|
18424
|
-
var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
|
|
18425
|
-
diag.error(err.stack || err.message);
|
|
18426
|
-
return false;
|
|
18427
|
-
}
|
|
18428
|
-
if (api.version !== VERSION23) {
|
|
18429
|
-
var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION23);
|
|
18430
|
-
diag.error(err.stack || err.message);
|
|
18431
|
-
return false;
|
|
18432
|
-
}
|
|
18433
|
-
api[type] = instance;
|
|
18434
|
-
diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION23 + ".");
|
|
18435
|
-
return true;
|
|
18436
|
-
}
|
|
18437
|
-
function getGlobal3(type) {
|
|
18438
|
-
var _a21, _b93;
|
|
18439
|
-
var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
|
|
18440
|
-
if (!globalVersion || !isCompatible3(globalVersion)) {
|
|
18441
|
-
return;
|
|
18442
|
-
}
|
|
18443
|
-
return (_b93 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b93 === void 0 ? void 0 : _b93[type];
|
|
18444
|
-
}
|
|
18445
|
-
function unregisterGlobal3(type, diag) {
|
|
18446
|
-
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
|
|
18447
|
-
var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3];
|
|
18448
|
-
if (api) {
|
|
18449
|
-
delete api[type];
|
|
18450
|
-
}
|
|
18451
|
-
}
|
|
18452
|
-
var __read6 = function(o, n) {
|
|
18453
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18454
|
-
if (!m) return o;
|
|
18455
|
-
var i = m.call(o), r, ar = [], e;
|
|
18456
|
-
try {
|
|
18457
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18458
|
-
} catch (error) {
|
|
18459
|
-
e = { error };
|
|
18460
|
-
} finally {
|
|
18461
|
-
try {
|
|
18462
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18463
|
-
} finally {
|
|
18464
|
-
if (e) throw e.error;
|
|
18465
|
-
}
|
|
18466
|
-
}
|
|
18467
|
-
return ar;
|
|
18468
|
-
};
|
|
18469
|
-
var __spreadArray6 = function(to, from, pack) {
|
|
18470
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18471
|
-
if (ar || !(i in from)) {
|
|
18472
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
18473
|
-
ar[i] = from[i];
|
|
18474
|
-
}
|
|
18475
|
-
}
|
|
18476
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18477
|
-
};
|
|
18478
|
-
var DiagComponentLogger3 = (
|
|
18479
|
-
/** @class */
|
|
18480
|
-
(function() {
|
|
18481
|
-
function DiagComponentLogger22(props) {
|
|
18482
|
-
this._namespace = props.namespace || "DiagComponentLogger";
|
|
18483
|
-
}
|
|
18484
|
-
DiagComponentLogger22.prototype.debug = function() {
|
|
18485
|
-
var args = [];
|
|
18486
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18487
|
-
args[_i] = arguments[_i];
|
|
18488
|
-
}
|
|
18489
|
-
return logProxy3("debug", this._namespace, args);
|
|
18490
|
-
};
|
|
18491
|
-
DiagComponentLogger22.prototype.error = function() {
|
|
18492
|
-
var args = [];
|
|
18493
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18494
|
-
args[_i] = arguments[_i];
|
|
18495
|
-
}
|
|
18496
|
-
return logProxy3("error", this._namespace, args);
|
|
18497
|
-
};
|
|
18498
|
-
DiagComponentLogger22.prototype.info = function() {
|
|
18499
|
-
var args = [];
|
|
18500
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18501
|
-
args[_i] = arguments[_i];
|
|
18502
|
-
}
|
|
18503
|
-
return logProxy3("info", this._namespace, args);
|
|
18504
|
-
};
|
|
18505
|
-
DiagComponentLogger22.prototype.warn = function() {
|
|
18506
|
-
var args = [];
|
|
18507
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18508
|
-
args[_i] = arguments[_i];
|
|
18509
|
-
}
|
|
18510
|
-
return logProxy3("warn", this._namespace, args);
|
|
18511
|
-
};
|
|
18512
|
-
DiagComponentLogger22.prototype.verbose = function() {
|
|
18513
|
-
var args = [];
|
|
18514
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18515
|
-
args[_i] = arguments[_i];
|
|
18516
|
-
}
|
|
18517
|
-
return logProxy3("verbose", this._namespace, args);
|
|
18518
|
-
};
|
|
18519
|
-
return DiagComponentLogger22;
|
|
18520
|
-
})()
|
|
18521
|
-
);
|
|
18522
|
-
function logProxy3(funcName, namespace, args) {
|
|
18523
|
-
var logger = getGlobal3("diag");
|
|
18524
|
-
if (!logger) {
|
|
18525
|
-
return;
|
|
18526
|
-
}
|
|
18527
|
-
args.unshift(namespace);
|
|
18528
|
-
return logger[funcName].apply(logger, __spreadArray6([], __read6(args), false));
|
|
18529
|
-
}
|
|
18530
|
-
var DiagLogLevel3;
|
|
18531
|
-
(function(DiagLogLevel22) {
|
|
18532
|
-
DiagLogLevel22[DiagLogLevel22["NONE"] = 0] = "NONE";
|
|
18533
|
-
DiagLogLevel22[DiagLogLevel22["ERROR"] = 30] = "ERROR";
|
|
18534
|
-
DiagLogLevel22[DiagLogLevel22["WARN"] = 50] = "WARN";
|
|
18535
|
-
DiagLogLevel22[DiagLogLevel22["INFO"] = 60] = "INFO";
|
|
18536
|
-
DiagLogLevel22[DiagLogLevel22["DEBUG"] = 70] = "DEBUG";
|
|
18537
|
-
DiagLogLevel22[DiagLogLevel22["VERBOSE"] = 80] = "VERBOSE";
|
|
18538
|
-
DiagLogLevel22[DiagLogLevel22["ALL"] = 9999] = "ALL";
|
|
18539
|
-
})(DiagLogLevel3 || (DiagLogLevel3 = {}));
|
|
18540
|
-
function createLogLevelDiagLogger3(maxLevel, logger) {
|
|
18541
|
-
if (maxLevel < DiagLogLevel3.NONE) {
|
|
18542
|
-
maxLevel = DiagLogLevel3.NONE;
|
|
18543
|
-
} else if (maxLevel > DiagLogLevel3.ALL) {
|
|
18544
|
-
maxLevel = DiagLogLevel3.ALL;
|
|
18545
|
-
}
|
|
18546
|
-
logger = logger || {};
|
|
18547
|
-
function _filterFunc(funcName, theLevel) {
|
|
18548
|
-
var theFunc = logger[funcName];
|
|
18549
|
-
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
18550
|
-
return theFunc.bind(logger);
|
|
18551
|
-
}
|
|
18552
|
-
return function() {
|
|
18553
|
-
};
|
|
18554
|
-
}
|
|
18555
|
-
return {
|
|
18556
|
-
error: _filterFunc("error", DiagLogLevel3.ERROR),
|
|
18557
|
-
warn: _filterFunc("warn", DiagLogLevel3.WARN),
|
|
18558
|
-
info: _filterFunc("info", DiagLogLevel3.INFO),
|
|
18559
|
-
debug: _filterFunc("debug", DiagLogLevel3.DEBUG),
|
|
18560
|
-
verbose: _filterFunc("verbose", DiagLogLevel3.VERBOSE)
|
|
18561
|
-
};
|
|
18562
|
-
}
|
|
18563
|
-
var __read23 = function(o, n) {
|
|
18564
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18565
|
-
if (!m) return o;
|
|
18566
|
-
var i = m.call(o), r, ar = [], e;
|
|
18567
|
-
try {
|
|
18568
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18569
|
-
} catch (error) {
|
|
18570
|
-
e = { error };
|
|
18571
|
-
} finally {
|
|
18572
|
-
try {
|
|
18573
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18574
|
-
} finally {
|
|
18575
|
-
if (e) throw e.error;
|
|
18576
|
-
}
|
|
18577
|
-
}
|
|
18578
|
-
return ar;
|
|
18579
|
-
};
|
|
18580
|
-
var __spreadArray23 = function(to, from, pack) {
|
|
18581
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18582
|
-
if (ar || !(i in from)) {
|
|
18583
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
18584
|
-
ar[i] = from[i];
|
|
18585
|
-
}
|
|
18586
|
-
}
|
|
18587
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18588
|
-
};
|
|
18589
|
-
var API_NAME5 = "diag";
|
|
18590
|
-
var DiagAPI3 = (
|
|
18591
|
-
/** @class */
|
|
18592
|
-
(function() {
|
|
18593
|
-
function DiagAPI22() {
|
|
18594
|
-
function _logProxy(funcName) {
|
|
18595
|
-
return function() {
|
|
18596
|
-
var args = [];
|
|
18597
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18598
|
-
args[_i] = arguments[_i];
|
|
18599
|
-
}
|
|
18600
|
-
var logger = getGlobal3("diag");
|
|
18601
|
-
if (!logger)
|
|
18602
|
-
return;
|
|
18603
|
-
return logger[funcName].apply(logger, __spreadArray23([], __read23(args), false));
|
|
18604
|
-
};
|
|
18605
|
-
}
|
|
18606
|
-
var self = this;
|
|
18607
|
-
var setLogger = function(logger, optionsOrLogLevel) {
|
|
18608
|
-
var _a21, _b93, _c;
|
|
18609
|
-
if (optionsOrLogLevel === void 0) {
|
|
18610
|
-
optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
|
|
18611
|
-
}
|
|
18612
|
-
if (logger === self) {
|
|
18613
|
-
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
18614
|
-
self.error((_a21 = err.stack) !== null && _a21 !== void 0 ? _a21 : err.message);
|
|
18615
|
-
return false;
|
|
18616
|
-
}
|
|
18617
|
-
if (typeof optionsOrLogLevel === "number") {
|
|
18618
|
-
optionsOrLogLevel = {
|
|
18619
|
-
logLevel: optionsOrLogLevel
|
|
18620
|
-
};
|
|
18621
|
-
}
|
|
18622
|
-
var oldLogger = getGlobal3("diag");
|
|
18623
|
-
var newLogger = createLogLevelDiagLogger3((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel3.INFO, logger);
|
|
18624
|
-
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
18625
|
-
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
18626
|
-
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
18627
|
-
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
18628
|
-
}
|
|
18629
|
-
return registerGlobal3("diag", newLogger, self, true);
|
|
18630
|
-
};
|
|
18631
|
-
self.setLogger = setLogger;
|
|
18632
|
-
self.disable = function() {
|
|
18633
|
-
unregisterGlobal3(API_NAME5, self);
|
|
18634
|
-
};
|
|
18635
|
-
self.createComponentLogger = function(options) {
|
|
18636
|
-
return new DiagComponentLogger3(options);
|
|
18637
|
-
};
|
|
18638
|
-
self.verbose = _logProxy("verbose");
|
|
18639
|
-
self.debug = _logProxy("debug");
|
|
18640
|
-
self.info = _logProxy("info");
|
|
18641
|
-
self.warn = _logProxy("warn");
|
|
18642
|
-
self.error = _logProxy("error");
|
|
18643
|
-
}
|
|
18644
|
-
DiagAPI22.instance = function() {
|
|
18645
|
-
if (!this._instance) {
|
|
18646
|
-
this._instance = new DiagAPI22();
|
|
18647
|
-
}
|
|
18648
|
-
return this._instance;
|
|
18649
|
-
};
|
|
18650
|
-
return DiagAPI22;
|
|
18651
|
-
})()
|
|
18652
|
-
);
|
|
18653
|
-
function createContextKey3(description) {
|
|
18654
|
-
return Symbol.for(description);
|
|
18655
|
-
}
|
|
18656
|
-
var BaseContext3 = (
|
|
18657
|
-
/** @class */
|
|
18658
|
-
/* @__PURE__ */ (function() {
|
|
18659
|
-
function BaseContext22(parentContext) {
|
|
18660
|
-
var self = this;
|
|
18661
|
-
self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
18662
|
-
self.getValue = function(key) {
|
|
18663
|
-
return self._currentContext.get(key);
|
|
18664
|
-
};
|
|
18665
|
-
self.setValue = function(key, value) {
|
|
18666
|
-
var context2 = new BaseContext22(self._currentContext);
|
|
18667
|
-
context2._currentContext.set(key, value);
|
|
18668
|
-
return context2;
|
|
18669
|
-
};
|
|
18670
|
-
self.deleteValue = function(key) {
|
|
18671
|
-
var context2 = new BaseContext22(self._currentContext);
|
|
18672
|
-
context2._currentContext.delete(key);
|
|
18673
|
-
return context2;
|
|
18674
|
-
};
|
|
19218
|
+
return _reject(globalVersion);
|
|
18675
19219
|
}
|
|
18676
|
-
|
|
18677
|
-
|
|
18678
|
-
);
|
|
18679
|
-
var ROOT_CONTEXT3 = new BaseContext3();
|
|
18680
|
-
var __read33 = function(o, n) {
|
|
18681
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18682
|
-
if (!m) return o;
|
|
18683
|
-
var i = m.call(o), r, ar = [], e;
|
|
18684
|
-
try {
|
|
18685
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18686
|
-
} catch (error) {
|
|
18687
|
-
e = { error };
|
|
18688
|
-
} finally {
|
|
18689
|
-
try {
|
|
18690
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18691
|
-
} finally {
|
|
18692
|
-
if (e) throw e.error;
|
|
19220
|
+
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
19221
|
+
return _accept(globalVersion);
|
|
18693
19222
|
}
|
|
19223
|
+
return _reject(globalVersion);
|
|
19224
|
+
};
|
|
19225
|
+
}
|
|
19226
|
+
var isCompatible3 = _makeCompatibilityCheck3(VERSION6);
|
|
19227
|
+
var major3 = VERSION6.split(".")[0];
|
|
19228
|
+
var GLOBAL_OPENTELEMETRY_API_KEY3 = /* @__PURE__ */ Symbol.for(`opentelemetry.js.api.${major3}`);
|
|
19229
|
+
var _global3 = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
|
|
19230
|
+
function registerGlobal3(type, instance, diag, allowOverride = false) {
|
|
19231
|
+
var _a223;
|
|
19232
|
+
const api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a223 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a223 !== void 0 ? _a223 : {
|
|
19233
|
+
version: VERSION6
|
|
19234
|
+
};
|
|
19235
|
+
if (!allowOverride && api[type]) {
|
|
19236
|
+
const err = new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
|
|
19237
|
+
diag.error(err.stack || err.message);
|
|
19238
|
+
return false;
|
|
18694
19239
|
}
|
|
18695
|
-
|
|
18696
|
-
};
|
|
18697
|
-
|
|
18698
|
-
|
|
18699
|
-
|
|
18700
|
-
|
|
18701
|
-
|
|
18702
|
-
|
|
19240
|
+
if (api.version !== VERSION6) {
|
|
19241
|
+
const err = new Error(`@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION6}`);
|
|
19242
|
+
diag.error(err.stack || err.message);
|
|
19243
|
+
return false;
|
|
19244
|
+
}
|
|
19245
|
+
api[type] = instance;
|
|
19246
|
+
diag.debug(`@opentelemetry/api: Registered a global for ${type} v${VERSION6}.`);
|
|
19247
|
+
return true;
|
|
19248
|
+
}
|
|
19249
|
+
function getGlobal3(type) {
|
|
19250
|
+
var _a223, _b19;
|
|
19251
|
+
const globalVersion = (_a223 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a223 === void 0 ? void 0 : _a223.version;
|
|
19252
|
+
if (!globalVersion || !isCompatible3(globalVersion)) {
|
|
19253
|
+
return;
|
|
19254
|
+
}
|
|
19255
|
+
return (_b19 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b19 === void 0 ? void 0 : _b19[type];
|
|
19256
|
+
}
|
|
19257
|
+
function unregisterGlobal3(type, diag) {
|
|
19258
|
+
diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${VERSION6}.`);
|
|
19259
|
+
const api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3];
|
|
19260
|
+
if (api) {
|
|
19261
|
+
delete api[type];
|
|
19262
|
+
}
|
|
19263
|
+
}
|
|
19264
|
+
var DiagComponentLogger3 = class {
|
|
19265
|
+
constructor(props) {
|
|
19266
|
+
this._namespace = props.namespace || "DiagComponentLogger";
|
|
19267
|
+
}
|
|
19268
|
+
debug(...args) {
|
|
19269
|
+
return logProxy3("debug", this._namespace, args);
|
|
19270
|
+
}
|
|
19271
|
+
error(...args) {
|
|
19272
|
+
return logProxy3("error", this._namespace, args);
|
|
19273
|
+
}
|
|
19274
|
+
info(...args) {
|
|
19275
|
+
return logProxy3("info", this._namespace, args);
|
|
19276
|
+
}
|
|
19277
|
+
warn(...args) {
|
|
19278
|
+
return logProxy3("warn", this._namespace, args);
|
|
19279
|
+
}
|
|
19280
|
+
verbose(...args) {
|
|
19281
|
+
return logProxy3("verbose", this._namespace, args);
|
|
18703
19282
|
}
|
|
18704
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18705
19283
|
};
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
(
|
|
18709
|
-
|
|
19284
|
+
function logProxy3(funcName, namespace, args) {
|
|
19285
|
+
const logger = getGlobal3("diag");
|
|
19286
|
+
if (!logger) {
|
|
19287
|
+
return;
|
|
19288
|
+
}
|
|
19289
|
+
return logger[funcName](namespace, ...args);
|
|
19290
|
+
}
|
|
19291
|
+
var DiagLogLevel3;
|
|
19292
|
+
(function(DiagLogLevel22) {
|
|
19293
|
+
DiagLogLevel22[DiagLogLevel22["NONE"] = 0] = "NONE";
|
|
19294
|
+
DiagLogLevel22[DiagLogLevel22["ERROR"] = 30] = "ERROR";
|
|
19295
|
+
DiagLogLevel22[DiagLogLevel22["WARN"] = 50] = "WARN";
|
|
19296
|
+
DiagLogLevel22[DiagLogLevel22["INFO"] = 60] = "INFO";
|
|
19297
|
+
DiagLogLevel22[DiagLogLevel22["DEBUG"] = 70] = "DEBUG";
|
|
19298
|
+
DiagLogLevel22[DiagLogLevel22["VERBOSE"] = 80] = "VERBOSE";
|
|
19299
|
+
DiagLogLevel22[DiagLogLevel22["ALL"] = 9999] = "ALL";
|
|
19300
|
+
})(DiagLogLevel3 || (DiagLogLevel3 = {}));
|
|
19301
|
+
function createLogLevelDiagLogger3(maxLevel, logger) {
|
|
19302
|
+
if (maxLevel < DiagLogLevel3.NONE) {
|
|
19303
|
+
maxLevel = DiagLogLevel3.NONE;
|
|
19304
|
+
} else if (maxLevel > DiagLogLevel3.ALL) {
|
|
19305
|
+
maxLevel = DiagLogLevel3.ALL;
|
|
19306
|
+
}
|
|
19307
|
+
logger = logger || {};
|
|
19308
|
+
function _filterFunc(funcName, theLevel) {
|
|
19309
|
+
const theFunc = logger[funcName];
|
|
19310
|
+
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
19311
|
+
return theFunc.bind(logger);
|
|
18710
19312
|
}
|
|
18711
|
-
|
|
18712
|
-
return ROOT_CONTEXT3;
|
|
18713
|
-
};
|
|
18714
|
-
NoopContextManager22.prototype.with = function(_context, fn, thisArg) {
|
|
18715
|
-
var args = [];
|
|
18716
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
18717
|
-
args[_i - 3] = arguments[_i];
|
|
18718
|
-
}
|
|
18719
|
-
return fn.call.apply(fn, __spreadArray33([thisArg], __read33(args), false));
|
|
18720
|
-
};
|
|
18721
|
-
NoopContextManager22.prototype.bind = function(_context, target) {
|
|
18722
|
-
return target;
|
|
18723
|
-
};
|
|
18724
|
-
NoopContextManager22.prototype.enable = function() {
|
|
18725
|
-
return this;
|
|
18726
|
-
};
|
|
18727
|
-
NoopContextManager22.prototype.disable = function() {
|
|
18728
|
-
return this;
|
|
19313
|
+
return function() {
|
|
18729
19314
|
};
|
|
18730
|
-
return NoopContextManager22;
|
|
18731
|
-
})()
|
|
18732
|
-
);
|
|
18733
|
-
var __read43 = function(o, n) {
|
|
18734
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18735
|
-
if (!m) return o;
|
|
18736
|
-
var i = m.call(o), r, ar = [], e;
|
|
18737
|
-
try {
|
|
18738
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18739
|
-
} catch (error) {
|
|
18740
|
-
e = { error };
|
|
18741
|
-
} finally {
|
|
18742
|
-
try {
|
|
18743
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18744
|
-
} finally {
|
|
18745
|
-
if (e) throw e.error;
|
|
18746
|
-
}
|
|
18747
19315
|
}
|
|
18748
|
-
return
|
|
18749
|
-
|
|
18750
|
-
|
|
18751
|
-
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
19316
|
+
return {
|
|
19317
|
+
error: _filterFunc("error", DiagLogLevel3.ERROR),
|
|
19318
|
+
warn: _filterFunc("warn", DiagLogLevel3.WARN),
|
|
19319
|
+
info: _filterFunc("info", DiagLogLevel3.INFO),
|
|
19320
|
+
debug: _filterFunc("debug", DiagLogLevel3.DEBUG),
|
|
19321
|
+
verbose: _filterFunc("verbose", DiagLogLevel3.VERBOSE)
|
|
19322
|
+
};
|
|
19323
|
+
}
|
|
19324
|
+
var API_NAME5 = "diag";
|
|
19325
|
+
var DiagAPI3 = class _DiagAPI {
|
|
19326
|
+
/** Get the singleton instance of the DiagAPI API */
|
|
19327
|
+
static instance() {
|
|
19328
|
+
if (!this._instance) {
|
|
19329
|
+
this._instance = new _DiagAPI();
|
|
18755
19330
|
}
|
|
19331
|
+
return this._instance;
|
|
18756
19332
|
}
|
|
18757
|
-
|
|
18758
|
-
|
|
18759
|
-
|
|
18760
|
-
|
|
18761
|
-
|
|
18762
|
-
|
|
18763
|
-
|
|
18764
|
-
|
|
19333
|
+
/**
|
|
19334
|
+
* Private internal constructor
|
|
19335
|
+
* @private
|
|
19336
|
+
*/
|
|
19337
|
+
constructor() {
|
|
19338
|
+
function _logProxy(funcName) {
|
|
19339
|
+
return function(...args) {
|
|
19340
|
+
const logger = getGlobal3("diag");
|
|
19341
|
+
if (!logger)
|
|
19342
|
+
return;
|
|
19343
|
+
return logger[funcName](...args);
|
|
19344
|
+
};
|
|
18765
19345
|
}
|
|
18766
|
-
|
|
18767
|
-
|
|
18768
|
-
|
|
19346
|
+
const self2 = this;
|
|
19347
|
+
const setLogger = (logger, optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO }) => {
|
|
19348
|
+
var _a223, _b19, _c;
|
|
19349
|
+
if (logger === self2) {
|
|
19350
|
+
const err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
19351
|
+
self2.error((_a223 = err.stack) !== null && _a223 !== void 0 ? _a223 : err.message);
|
|
19352
|
+
return false;
|
|
19353
|
+
}
|
|
19354
|
+
if (typeof optionsOrLogLevel === "number") {
|
|
19355
|
+
optionsOrLogLevel = {
|
|
19356
|
+
logLevel: optionsOrLogLevel
|
|
19357
|
+
};
|
|
18769
19358
|
}
|
|
18770
|
-
|
|
18771
|
-
|
|
18772
|
-
|
|
18773
|
-
|
|
18774
|
-
|
|
18775
|
-
|
|
18776
|
-
return this._getContextManager().active();
|
|
18777
|
-
};
|
|
18778
|
-
ContextAPI22.prototype.with = function(context2, fn, thisArg) {
|
|
18779
|
-
var _a21;
|
|
18780
|
-
var args = [];
|
|
18781
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
18782
|
-
args[_i - 3] = arguments[_i];
|
|
19359
|
+
const oldLogger = getGlobal3("diag");
|
|
19360
|
+
const newLogger = createLogLevelDiagLogger3((_b19 = optionsOrLogLevel.logLevel) !== null && _b19 !== void 0 ? _b19 : DiagLogLevel3.INFO, logger);
|
|
19361
|
+
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
19362
|
+
const stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
19363
|
+
oldLogger.warn(`Current logger will be overwritten from ${stack}`);
|
|
19364
|
+
newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
|
|
18783
19365
|
}
|
|
18784
|
-
return (
|
|
18785
|
-
};
|
|
18786
|
-
ContextAPI22.prototype.bind = function(context2, target) {
|
|
18787
|
-
return this._getContextManager().bind(context2, target);
|
|
19366
|
+
return registerGlobal3("diag", newLogger, self2, true);
|
|
18788
19367
|
};
|
|
18789
|
-
|
|
18790
|
-
|
|
19368
|
+
self2.setLogger = setLogger;
|
|
19369
|
+
self2.disable = () => {
|
|
19370
|
+
unregisterGlobal3(API_NAME5, self2);
|
|
18791
19371
|
};
|
|
18792
|
-
|
|
18793
|
-
|
|
18794
|
-
unregisterGlobal3(API_NAME23, DiagAPI3.instance());
|
|
19372
|
+
self2.createComponentLogger = (options) => {
|
|
19373
|
+
return new DiagComponentLogger3(options);
|
|
18795
19374
|
};
|
|
18796
|
-
|
|
18797
|
-
|
|
18798
|
-
);
|
|
18799
|
-
|
|
18800
|
-
(
|
|
18801
|
-
|
|
18802
|
-
TraceFlags22[TraceFlags22["SAMPLED"] = 1] = "SAMPLED";
|
|
18803
|
-
})(TraceFlags3 || (TraceFlags3 = {}));
|
|
18804
|
-
var INVALID_SPANID3 = "0000000000000000";
|
|
18805
|
-
var INVALID_TRACEID3 = "00000000000000000000000000000000";
|
|
18806
|
-
var INVALID_SPAN_CONTEXT3 = {
|
|
18807
|
-
traceId: INVALID_TRACEID3,
|
|
18808
|
-
spanId: INVALID_SPANID3,
|
|
18809
|
-
traceFlags: TraceFlags3.NONE
|
|
19375
|
+
self2.verbose = _logProxy("verbose");
|
|
19376
|
+
self2.debug = _logProxy("debug");
|
|
19377
|
+
self2.info = _logProxy("info");
|
|
19378
|
+
self2.warn = _logProxy("warn");
|
|
19379
|
+
self2.error = _logProxy("error");
|
|
19380
|
+
}
|
|
18810
19381
|
};
|
|
18811
|
-
|
|
18812
|
-
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18819
|
-
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
return
|
|
18828
|
-
};
|
|
18829
|
-
NonRecordingSpan22.prototype.addEvent = function(_name, _attributes) {
|
|
18830
|
-
return this;
|
|
18831
|
-
};
|
|
18832
|
-
NonRecordingSpan22.prototype.addLink = function(_link) {
|
|
18833
|
-
return this;
|
|
18834
|
-
};
|
|
18835
|
-
NonRecordingSpan22.prototype.addLinks = function(_links) {
|
|
18836
|
-
return this;
|
|
18837
|
-
};
|
|
18838
|
-
NonRecordingSpan22.prototype.setStatus = function(_status) {
|
|
18839
|
-
return this;
|
|
18840
|
-
};
|
|
18841
|
-
NonRecordingSpan22.prototype.updateName = function(_name) {
|
|
18842
|
-
return this;
|
|
18843
|
-
};
|
|
18844
|
-
NonRecordingSpan22.prototype.end = function(_endTime) {
|
|
18845
|
-
};
|
|
18846
|
-
NonRecordingSpan22.prototype.isRecording = function() {
|
|
18847
|
-
return false;
|
|
19382
|
+
function createContextKey3(description) {
|
|
19383
|
+
return Symbol.for(description);
|
|
19384
|
+
}
|
|
19385
|
+
var BaseContext3 = class _BaseContext {
|
|
19386
|
+
/**
|
|
19387
|
+
* Construct a new context which inherits values from an optional parent context.
|
|
19388
|
+
*
|
|
19389
|
+
* @param parentContext a context from which to inherit values
|
|
19390
|
+
*/
|
|
19391
|
+
constructor(parentContext) {
|
|
19392
|
+
const self2 = this;
|
|
19393
|
+
self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
19394
|
+
self2.getValue = (key) => self2._currentContext.get(key);
|
|
19395
|
+
self2.setValue = (key, value) => {
|
|
19396
|
+
const context2 = new _BaseContext(self2._currentContext);
|
|
19397
|
+
context2._currentContext.set(key, value);
|
|
19398
|
+
return context2;
|
|
18848
19399
|
};
|
|
18849
|
-
|
|
19400
|
+
self2.deleteValue = (key) => {
|
|
19401
|
+
const context2 = new _BaseContext(self2._currentContext);
|
|
19402
|
+
context2._currentContext.delete(key);
|
|
19403
|
+
return context2;
|
|
18850
19404
|
};
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
);
|
|
19405
|
+
}
|
|
19406
|
+
};
|
|
19407
|
+
var ROOT_CONTEXT3 = new BaseContext3();
|
|
19408
|
+
var NoopContextManager3 = class {
|
|
19409
|
+
active() {
|
|
19410
|
+
return ROOT_CONTEXT3;
|
|
19411
|
+
}
|
|
19412
|
+
with(_context, fn, thisArg, ...args) {
|
|
19413
|
+
return fn.call(thisArg, ...args);
|
|
19414
|
+
}
|
|
19415
|
+
bind(_context, target) {
|
|
19416
|
+
return target;
|
|
19417
|
+
}
|
|
19418
|
+
enable() {
|
|
19419
|
+
return this;
|
|
19420
|
+
}
|
|
19421
|
+
disable() {
|
|
19422
|
+
return this;
|
|
19423
|
+
}
|
|
19424
|
+
};
|
|
19425
|
+
var API_NAME23 = "context";
|
|
19426
|
+
var NOOP_CONTEXT_MANAGER3 = new NoopContextManager3();
|
|
19427
|
+
var ContextAPI3 = class _ContextAPI {
|
|
19428
|
+
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
19429
|
+
constructor() {
|
|
19430
|
+
}
|
|
19431
|
+
/** Get the singleton instance of the Context API */
|
|
19432
|
+
static getInstance() {
|
|
19433
|
+
if (!this._instance) {
|
|
19434
|
+
this._instance = new _ContextAPI();
|
|
19435
|
+
}
|
|
19436
|
+
return this._instance;
|
|
19437
|
+
}
|
|
19438
|
+
/**
|
|
19439
|
+
* Set the current context manager.
|
|
19440
|
+
*
|
|
19441
|
+
* @returns true if the context manager was successfully registered, else false
|
|
19442
|
+
*/
|
|
19443
|
+
setGlobalContextManager(contextManager) {
|
|
19444
|
+
return registerGlobal3(API_NAME23, contextManager, DiagAPI3.instance());
|
|
19445
|
+
}
|
|
19446
|
+
/**
|
|
19447
|
+
* Get the currently active context
|
|
19448
|
+
*/
|
|
19449
|
+
active() {
|
|
19450
|
+
return this._getContextManager().active();
|
|
19451
|
+
}
|
|
19452
|
+
/**
|
|
19453
|
+
* Execute a function with an active context
|
|
19454
|
+
*
|
|
19455
|
+
* @param context context to be active during function execution
|
|
19456
|
+
* @param fn function to execute in a context
|
|
19457
|
+
* @param thisArg optional receiver to be used for calling fn
|
|
19458
|
+
* @param args optional arguments forwarded to fn
|
|
19459
|
+
*/
|
|
19460
|
+
with(context2, fn, thisArg, ...args) {
|
|
19461
|
+
return this._getContextManager().with(context2, fn, thisArg, ...args);
|
|
19462
|
+
}
|
|
19463
|
+
/**
|
|
19464
|
+
* Bind a context to a target function or event emitter
|
|
19465
|
+
*
|
|
19466
|
+
* @param context context to bind to the event emitter or function. Defaults to the currently active context
|
|
19467
|
+
* @param target function or event emitter to bind
|
|
19468
|
+
*/
|
|
19469
|
+
bind(context2, target) {
|
|
19470
|
+
return this._getContextManager().bind(context2, target);
|
|
19471
|
+
}
|
|
19472
|
+
_getContextManager() {
|
|
19473
|
+
return getGlobal3(API_NAME23) || NOOP_CONTEXT_MANAGER3;
|
|
19474
|
+
}
|
|
19475
|
+
/** Disable and remove the global context manager */
|
|
19476
|
+
disable() {
|
|
19477
|
+
this._getContextManager().disable();
|
|
19478
|
+
unregisterGlobal3(API_NAME23, DiagAPI3.instance());
|
|
19479
|
+
}
|
|
19480
|
+
};
|
|
19481
|
+
var TraceFlags3;
|
|
19482
|
+
(function(TraceFlags22) {
|
|
19483
|
+
TraceFlags22[TraceFlags22["NONE"] = 0] = "NONE";
|
|
19484
|
+
TraceFlags22[TraceFlags22["SAMPLED"] = 1] = "SAMPLED";
|
|
19485
|
+
})(TraceFlags3 || (TraceFlags3 = {}));
|
|
19486
|
+
var INVALID_SPANID3 = "0000000000000000";
|
|
19487
|
+
var INVALID_TRACEID3 = "00000000000000000000000000000000";
|
|
19488
|
+
var INVALID_SPAN_CONTEXT3 = {
|
|
19489
|
+
traceId: INVALID_TRACEID3,
|
|
19490
|
+
spanId: INVALID_SPANID3,
|
|
19491
|
+
traceFlags: TraceFlags3.NONE
|
|
19492
|
+
};
|
|
19493
|
+
var NonRecordingSpan3 = class {
|
|
19494
|
+
constructor(spanContext = INVALID_SPAN_CONTEXT3) {
|
|
19495
|
+
this._spanContext = spanContext;
|
|
19496
|
+
}
|
|
19497
|
+
// Returns a SpanContext.
|
|
19498
|
+
spanContext() {
|
|
19499
|
+
return this._spanContext;
|
|
19500
|
+
}
|
|
19501
|
+
// By default does nothing
|
|
19502
|
+
setAttribute(_key, _value) {
|
|
19503
|
+
return this;
|
|
19504
|
+
}
|
|
19505
|
+
// By default does nothing
|
|
19506
|
+
setAttributes(_attributes) {
|
|
19507
|
+
return this;
|
|
19508
|
+
}
|
|
19509
|
+
// By default does nothing
|
|
19510
|
+
addEvent(_name, _attributes) {
|
|
19511
|
+
return this;
|
|
19512
|
+
}
|
|
19513
|
+
addLink(_link) {
|
|
19514
|
+
return this;
|
|
19515
|
+
}
|
|
19516
|
+
addLinks(_links) {
|
|
19517
|
+
return this;
|
|
19518
|
+
}
|
|
19519
|
+
// By default does nothing
|
|
19520
|
+
setStatus(_status) {
|
|
19521
|
+
return this;
|
|
19522
|
+
}
|
|
19523
|
+
// By default does nothing
|
|
19524
|
+
updateName(_name) {
|
|
19525
|
+
return this;
|
|
19526
|
+
}
|
|
19527
|
+
// By default does nothing
|
|
19528
|
+
end(_endTime) {
|
|
19529
|
+
}
|
|
19530
|
+
// isRecording always returns false for NonRecordingSpan.
|
|
19531
|
+
isRecording() {
|
|
19532
|
+
return false;
|
|
19533
|
+
}
|
|
19534
|
+
// By default does nothing
|
|
19535
|
+
recordException(_exception, _time) {
|
|
19536
|
+
}
|
|
19537
|
+
};
|
|
18854
19538
|
var SPAN_KEY3 = createContextKey3("OpenTelemetry Context Key SPAN");
|
|
18855
19539
|
function getSpan3(context2) {
|
|
18856
19540
|
return context2.getValue(SPAN_KEY3) || void 0;
|
|
@@ -18868,16 +19552,128 @@ function setSpanContext3(context2, spanContext) {
|
|
|
18868
19552
|
return setSpan3(context2, new NonRecordingSpan3(spanContext));
|
|
18869
19553
|
}
|
|
18870
19554
|
function getSpanContext3(context2) {
|
|
18871
|
-
var
|
|
18872
|
-
return (
|
|
19555
|
+
var _a223;
|
|
19556
|
+
return (_a223 = getSpan3(context2)) === null || _a223 === void 0 ? void 0 : _a223.spanContext();
|
|
19557
|
+
}
|
|
19558
|
+
var isHex = new Uint8Array([
|
|
19559
|
+
0,
|
|
19560
|
+
0,
|
|
19561
|
+
0,
|
|
19562
|
+
0,
|
|
19563
|
+
0,
|
|
19564
|
+
0,
|
|
19565
|
+
0,
|
|
19566
|
+
0,
|
|
19567
|
+
0,
|
|
19568
|
+
0,
|
|
19569
|
+
0,
|
|
19570
|
+
0,
|
|
19571
|
+
0,
|
|
19572
|
+
0,
|
|
19573
|
+
0,
|
|
19574
|
+
0,
|
|
19575
|
+
0,
|
|
19576
|
+
0,
|
|
19577
|
+
0,
|
|
19578
|
+
0,
|
|
19579
|
+
0,
|
|
19580
|
+
0,
|
|
19581
|
+
0,
|
|
19582
|
+
0,
|
|
19583
|
+
0,
|
|
19584
|
+
0,
|
|
19585
|
+
0,
|
|
19586
|
+
0,
|
|
19587
|
+
0,
|
|
19588
|
+
0,
|
|
19589
|
+
0,
|
|
19590
|
+
0,
|
|
19591
|
+
0,
|
|
19592
|
+
0,
|
|
19593
|
+
0,
|
|
19594
|
+
0,
|
|
19595
|
+
0,
|
|
19596
|
+
0,
|
|
19597
|
+
0,
|
|
19598
|
+
0,
|
|
19599
|
+
0,
|
|
19600
|
+
0,
|
|
19601
|
+
0,
|
|
19602
|
+
0,
|
|
19603
|
+
0,
|
|
19604
|
+
0,
|
|
19605
|
+
0,
|
|
19606
|
+
0,
|
|
19607
|
+
1,
|
|
19608
|
+
1,
|
|
19609
|
+
1,
|
|
19610
|
+
1,
|
|
19611
|
+
1,
|
|
19612
|
+
1,
|
|
19613
|
+
1,
|
|
19614
|
+
1,
|
|
19615
|
+
1,
|
|
19616
|
+
1,
|
|
19617
|
+
0,
|
|
19618
|
+
0,
|
|
19619
|
+
0,
|
|
19620
|
+
0,
|
|
19621
|
+
0,
|
|
19622
|
+
0,
|
|
19623
|
+
0,
|
|
19624
|
+
1,
|
|
19625
|
+
1,
|
|
19626
|
+
1,
|
|
19627
|
+
1,
|
|
19628
|
+
1,
|
|
19629
|
+
1,
|
|
19630
|
+
0,
|
|
19631
|
+
0,
|
|
19632
|
+
0,
|
|
19633
|
+
0,
|
|
19634
|
+
0,
|
|
19635
|
+
0,
|
|
19636
|
+
0,
|
|
19637
|
+
0,
|
|
19638
|
+
0,
|
|
19639
|
+
0,
|
|
19640
|
+
0,
|
|
19641
|
+
0,
|
|
19642
|
+
0,
|
|
19643
|
+
0,
|
|
19644
|
+
0,
|
|
19645
|
+
0,
|
|
19646
|
+
0,
|
|
19647
|
+
0,
|
|
19648
|
+
0,
|
|
19649
|
+
0,
|
|
19650
|
+
0,
|
|
19651
|
+
0,
|
|
19652
|
+
0,
|
|
19653
|
+
0,
|
|
19654
|
+
0,
|
|
19655
|
+
0,
|
|
19656
|
+
1,
|
|
19657
|
+
1,
|
|
19658
|
+
1,
|
|
19659
|
+
1,
|
|
19660
|
+
1,
|
|
19661
|
+
1
|
|
19662
|
+
]);
|
|
19663
|
+
function isValidHex(id, length) {
|
|
19664
|
+
if (typeof id !== "string" || id.length !== length)
|
|
19665
|
+
return false;
|
|
19666
|
+
let r = 0;
|
|
19667
|
+
for (let i = 0; i < id.length; i += 4) {
|
|
19668
|
+
r += (isHex[id.charCodeAt(i)] | 0) + (isHex[id.charCodeAt(i + 1)] | 0) + (isHex[id.charCodeAt(i + 2)] | 0) + (isHex[id.charCodeAt(i + 3)] | 0);
|
|
19669
|
+
}
|
|
19670
|
+
return r === length;
|
|
18873
19671
|
}
|
|
18874
|
-
var VALID_TRACEID_REGEX3 = /^([0-9a-f]{32})$/i;
|
|
18875
|
-
var VALID_SPANID_REGEX3 = /^[0-9a-f]{16}$/i;
|
|
18876
19672
|
function isValidTraceId3(traceId) {
|
|
18877
|
-
return
|
|
19673
|
+
return isValidHex(traceId, 32) && traceId !== INVALID_TRACEID3;
|
|
18878
19674
|
}
|
|
18879
19675
|
function isValidSpanId3(spanId) {
|
|
18880
|
-
return
|
|
19676
|
+
return isValidHex(spanId, 16) && spanId !== INVALID_SPANID3;
|
|
18881
19677
|
}
|
|
18882
19678
|
function isSpanContextValid3(spanContext) {
|
|
18883
19679
|
return isValidTraceId3(spanContext.traceId) && isValidSpanId3(spanContext.spanId);
|
|
@@ -18886,119 +19682,105 @@ function wrapSpanContext3(spanContext) {
|
|
|
18886
19682
|
return new NonRecordingSpan3(spanContext);
|
|
18887
19683
|
}
|
|
18888
19684
|
var contextApi3 = ContextAPI3.getInstance();
|
|
18889
|
-
var NoopTracer3 =
|
|
18890
|
-
|
|
18891
|
-
(
|
|
18892
|
-
|
|
19685
|
+
var NoopTracer3 = class {
|
|
19686
|
+
// startSpan starts a noop span.
|
|
19687
|
+
startSpan(name223, options, context2 = contextApi3.active()) {
|
|
19688
|
+
const root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
19689
|
+
if (root) {
|
|
19690
|
+
return new NonRecordingSpan3();
|
|
19691
|
+
}
|
|
19692
|
+
const parentFromContext = context2 && getSpanContext3(context2);
|
|
19693
|
+
if (isSpanContext3(parentFromContext) && isSpanContextValid3(parentFromContext)) {
|
|
19694
|
+
return new NonRecordingSpan3(parentFromContext);
|
|
19695
|
+
} else {
|
|
19696
|
+
return new NonRecordingSpan3();
|
|
18893
19697
|
}
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
18897
|
-
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
} else if (arguments.length === 3) {
|
|
18918
|
-
opts = arg2;
|
|
18919
|
-
fn = arg3;
|
|
18920
|
-
} else {
|
|
18921
|
-
opts = arg2;
|
|
18922
|
-
ctx = arg3;
|
|
18923
|
-
fn = arg4;
|
|
18924
|
-
}
|
|
18925
|
-
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi3.active();
|
|
18926
|
-
var span = this.startSpan(name21, opts, parentContext);
|
|
18927
|
-
var contextWithSpanSet = setSpan3(parentContext, span);
|
|
18928
|
-
return contextApi3.with(contextWithSpanSet, fn, void 0, span);
|
|
18929
|
-
};
|
|
18930
|
-
return NoopTracer22;
|
|
18931
|
-
})()
|
|
18932
|
-
);
|
|
19698
|
+
}
|
|
19699
|
+
startActiveSpan(name223, arg2, arg3, arg4) {
|
|
19700
|
+
let opts;
|
|
19701
|
+
let ctx;
|
|
19702
|
+
let fn;
|
|
19703
|
+
if (arguments.length < 2) {
|
|
19704
|
+
return;
|
|
19705
|
+
} else if (arguments.length === 2) {
|
|
19706
|
+
fn = arg2;
|
|
19707
|
+
} else if (arguments.length === 3) {
|
|
19708
|
+
opts = arg2;
|
|
19709
|
+
fn = arg3;
|
|
19710
|
+
} else {
|
|
19711
|
+
opts = arg2;
|
|
19712
|
+
ctx = arg3;
|
|
19713
|
+
fn = arg4;
|
|
19714
|
+
}
|
|
19715
|
+
const parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi3.active();
|
|
19716
|
+
const span = this.startSpan(name223, opts, parentContext);
|
|
19717
|
+
const contextWithSpanSet = setSpan3(parentContext, span);
|
|
19718
|
+
return contextApi3.with(contextWithSpanSet, fn, void 0, span);
|
|
19719
|
+
}
|
|
19720
|
+
};
|
|
18933
19721
|
function isSpanContext3(spanContext) {
|
|
18934
|
-
return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
|
|
19722
|
+
return spanContext !== null && typeof spanContext === "object" && "spanId" in spanContext && typeof spanContext["spanId"] === "string" && "traceId" in spanContext && typeof spanContext["traceId"] === "string" && "traceFlags" in spanContext && typeof spanContext["traceFlags"] === "number";
|
|
18935
19723
|
}
|
|
18936
19724
|
var NOOP_TRACER3 = new NoopTracer3();
|
|
18937
|
-
var ProxyTracer3 =
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
|
|
18953
|
-
|
|
18954
|
-
|
|
18955
|
-
|
|
18956
|
-
|
|
18957
|
-
var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
18958
|
-
if (!tracer) {
|
|
18959
|
-
return NOOP_TRACER3;
|
|
18960
|
-
}
|
|
18961
|
-
this._delegate = tracer;
|
|
19725
|
+
var ProxyTracer3 = class {
|
|
19726
|
+
constructor(provider, name223, version, options) {
|
|
19727
|
+
this._provider = provider;
|
|
19728
|
+
this.name = name223;
|
|
19729
|
+
this.version = version;
|
|
19730
|
+
this.options = options;
|
|
19731
|
+
}
|
|
19732
|
+
startSpan(name223, options, context2) {
|
|
19733
|
+
return this._getTracer().startSpan(name223, options, context2);
|
|
19734
|
+
}
|
|
19735
|
+
startActiveSpan(_name, _options, _context, _fn) {
|
|
19736
|
+
const tracer = this._getTracer();
|
|
19737
|
+
return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
|
|
19738
|
+
}
|
|
19739
|
+
/**
|
|
19740
|
+
* Try to get a tracer from the proxy tracer provider.
|
|
19741
|
+
* If the proxy tracer provider has no delegate, return a noop tracer.
|
|
19742
|
+
*/
|
|
19743
|
+
_getTracer() {
|
|
19744
|
+
if (this._delegate) {
|
|
18962
19745
|
return this._delegate;
|
|
18963
|
-
};
|
|
18964
|
-
return ProxyTracer22;
|
|
18965
|
-
})()
|
|
18966
|
-
);
|
|
18967
|
-
var NoopTracerProvider3 = (
|
|
18968
|
-
/** @class */
|
|
18969
|
-
(function() {
|
|
18970
|
-
function NoopTracerProvider22() {
|
|
18971
19746
|
}
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
return NoopTracerProvider22;
|
|
18976
|
-
})()
|
|
18977
|
-
);
|
|
18978
|
-
var NOOP_TRACER_PROVIDER3 = new NoopTracerProvider3();
|
|
18979
|
-
var ProxyTracerProvider3 = (
|
|
18980
|
-
/** @class */
|
|
18981
|
-
(function() {
|
|
18982
|
-
function ProxyTracerProvider22() {
|
|
19747
|
+
const tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
19748
|
+
if (!tracer) {
|
|
19749
|
+
return NOOP_TRACER3;
|
|
18983
19750
|
}
|
|
18984
|
-
|
|
18985
|
-
|
|
18986
|
-
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19751
|
+
this._delegate = tracer;
|
|
19752
|
+
return this._delegate;
|
|
19753
|
+
}
|
|
19754
|
+
};
|
|
19755
|
+
var NoopTracerProvider3 = class {
|
|
19756
|
+
getTracer(_name, _version, _options) {
|
|
19757
|
+
return new NoopTracer3();
|
|
19758
|
+
}
|
|
19759
|
+
};
|
|
19760
|
+
var NOOP_TRACER_PROVIDER3 = new NoopTracerProvider3();
|
|
19761
|
+
var ProxyTracerProvider3 = class {
|
|
19762
|
+
/**
|
|
19763
|
+
* Get a {@link ProxyTracer}
|
|
19764
|
+
*/
|
|
19765
|
+
getTracer(name223, version, options) {
|
|
19766
|
+
var _a223;
|
|
19767
|
+
return (_a223 = this.getDelegateTracer(name223, version, options)) !== null && _a223 !== void 0 ? _a223 : new ProxyTracer3(this, name223, version, options);
|
|
19768
|
+
}
|
|
19769
|
+
getDelegate() {
|
|
19770
|
+
var _a223;
|
|
19771
|
+
return (_a223 = this._delegate) !== null && _a223 !== void 0 ? _a223 : NOOP_TRACER_PROVIDER3;
|
|
19772
|
+
}
|
|
19773
|
+
/**
|
|
19774
|
+
* Set the delegate tracer provider
|
|
19775
|
+
*/
|
|
19776
|
+
setDelegate(delegate) {
|
|
19777
|
+
this._delegate = delegate;
|
|
19778
|
+
}
|
|
19779
|
+
getDelegateTracer(name223, version, options) {
|
|
19780
|
+
var _a223;
|
|
19781
|
+
return (_a223 = this._delegate) === null || _a223 === void 0 ? void 0 : _a223.getTracer(name223, version, options);
|
|
19782
|
+
}
|
|
19783
|
+
};
|
|
19002
19784
|
var SpanStatusCode3;
|
|
19003
19785
|
(function(SpanStatusCode22) {
|
|
19004
19786
|
SpanStatusCode22[SpanStatusCode22["UNSET"] = 0] = "UNSET";
|
|
@@ -19007,56 +19789,66 @@ var SpanStatusCode3;
|
|
|
19007
19789
|
})(SpanStatusCode3 || (SpanStatusCode3 = {}));
|
|
19008
19790
|
var context = ContextAPI3.getInstance();
|
|
19009
19791
|
var API_NAME33 = "trace";
|
|
19010
|
-
var TraceAPI3 =
|
|
19011
|
-
/**
|
|
19012
|
-
(
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19792
|
+
var TraceAPI3 = class _TraceAPI {
|
|
19793
|
+
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
19794
|
+
constructor() {
|
|
19795
|
+
this._proxyTracerProvider = new ProxyTracerProvider3();
|
|
19796
|
+
this.wrapSpanContext = wrapSpanContext3;
|
|
19797
|
+
this.isSpanContextValid = isSpanContextValid3;
|
|
19798
|
+
this.deleteSpan = deleteSpan3;
|
|
19799
|
+
this.getSpan = getSpan3;
|
|
19800
|
+
this.getActiveSpan = getActiveSpan3;
|
|
19801
|
+
this.getSpanContext = getSpanContext3;
|
|
19802
|
+
this.setSpan = setSpan3;
|
|
19803
|
+
this.setSpanContext = setSpanContext3;
|
|
19804
|
+
}
|
|
19805
|
+
/** Get the singleton instance of the Trace API */
|
|
19806
|
+
static getInstance() {
|
|
19807
|
+
if (!this._instance) {
|
|
19808
|
+
this._instance = new _TraceAPI();
|
|
19809
|
+
}
|
|
19810
|
+
return this._instance;
|
|
19811
|
+
}
|
|
19812
|
+
/**
|
|
19813
|
+
* Set the current global tracer.
|
|
19814
|
+
*
|
|
19815
|
+
* @returns true if the tracer provider was successfully registered, else false
|
|
19816
|
+
*/
|
|
19817
|
+
setGlobalTracerProvider(provider) {
|
|
19818
|
+
const success = registerGlobal3(API_NAME33, this._proxyTracerProvider, DiagAPI3.instance());
|
|
19819
|
+
if (success) {
|
|
19820
|
+
this._proxyTracerProvider.setDelegate(provider);
|
|
19023
19821
|
}
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
unregisterGlobal3(API_NAME33, DiagAPI3.instance());
|
|
19045
|
-
this._proxyTracerProvider = new ProxyTracerProvider3();
|
|
19046
|
-
};
|
|
19047
|
-
return TraceAPI22;
|
|
19048
|
-
})()
|
|
19049
|
-
);
|
|
19822
|
+
return success;
|
|
19823
|
+
}
|
|
19824
|
+
/**
|
|
19825
|
+
* Returns the global tracer provider.
|
|
19826
|
+
*/
|
|
19827
|
+
getTracerProvider() {
|
|
19828
|
+
return getGlobal3(API_NAME33) || this._proxyTracerProvider;
|
|
19829
|
+
}
|
|
19830
|
+
/**
|
|
19831
|
+
* Returns a tracer from the global tracer provider.
|
|
19832
|
+
*/
|
|
19833
|
+
getTracer(name223, version) {
|
|
19834
|
+
return this.getTracerProvider().getTracer(name223, version);
|
|
19835
|
+
}
|
|
19836
|
+
/** Remove the global tracer provider */
|
|
19837
|
+
disable() {
|
|
19838
|
+
unregisterGlobal3(API_NAME33, DiagAPI3.instance());
|
|
19839
|
+
this._proxyTracerProvider = new ProxyTracerProvider3();
|
|
19840
|
+
}
|
|
19841
|
+
};
|
|
19050
19842
|
var trace3 = TraceAPI3.getInstance();
|
|
19051
19843
|
var __defProp4 = Object.defineProperty;
|
|
19052
19844
|
var __export3 = (target, all) => {
|
|
19053
|
-
for (var
|
|
19054
|
-
__defProp4(target,
|
|
19845
|
+
for (var name223 in all)
|
|
19846
|
+
__defProp4(target, name223, { get: all[name223], enumerable: true });
|
|
19055
19847
|
};
|
|
19056
|
-
var
|
|
19057
|
-
var
|
|
19058
|
-
var
|
|
19059
|
-
var
|
|
19848
|
+
var name21 = "AI_InvalidArgumentError";
|
|
19849
|
+
var marker21 = `vercel.ai.error.${name21}`;
|
|
19850
|
+
var symbol21 = Symbol.for(marker21);
|
|
19851
|
+
var _a21;
|
|
19060
19852
|
var InvalidArgumentError23 = class extends AISDKError3 {
|
|
19061
19853
|
constructor({
|
|
19062
19854
|
parameter,
|
|
@@ -19064,22 +19856,22 @@ var InvalidArgumentError23 = class extends AISDKError3 {
|
|
|
19064
19856
|
message
|
|
19065
19857
|
}) {
|
|
19066
19858
|
super({
|
|
19067
|
-
name:
|
|
19859
|
+
name: name21,
|
|
19068
19860
|
message: `Invalid argument for parameter ${parameter}: ${message}`
|
|
19069
19861
|
});
|
|
19070
|
-
this[
|
|
19862
|
+
this[_a21] = true;
|
|
19071
19863
|
this.parameter = parameter;
|
|
19072
19864
|
this.value = value;
|
|
19073
19865
|
}
|
|
19074
19866
|
static isInstance(error) {
|
|
19075
|
-
return AISDKError3.hasMarker(error,
|
|
19867
|
+
return AISDKError3.hasMarker(error, marker21);
|
|
19076
19868
|
}
|
|
19077
19869
|
};
|
|
19078
|
-
|
|
19079
|
-
var
|
|
19080
|
-
var
|
|
19081
|
-
var
|
|
19082
|
-
var
|
|
19870
|
+
_a21 = symbol21;
|
|
19871
|
+
var name97 = "AI_NoObjectGeneratedError";
|
|
19872
|
+
var marker97 = `vercel.ai.error.${name97}`;
|
|
19873
|
+
var symbol97 = Symbol.for(marker97);
|
|
19874
|
+
var _a97;
|
|
19083
19875
|
var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
19084
19876
|
constructor({
|
|
19085
19877
|
message = "No object generated.",
|
|
@@ -19089,18 +19881,18 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
|
19089
19881
|
usage,
|
|
19090
19882
|
finishReason
|
|
19091
19883
|
}) {
|
|
19092
|
-
super({ name:
|
|
19093
|
-
this[
|
|
19884
|
+
super({ name: name97, message, cause });
|
|
19885
|
+
this[_a97] = true;
|
|
19094
19886
|
this.text = text22;
|
|
19095
19887
|
this.response = response;
|
|
19096
19888
|
this.usage = usage;
|
|
19097
19889
|
this.finishReason = finishReason;
|
|
19098
19890
|
}
|
|
19099
19891
|
static isInstance(error) {
|
|
19100
|
-
return AISDKError3.hasMarker(error,
|
|
19892
|
+
return AISDKError3.hasMarker(error, marker97);
|
|
19101
19893
|
}
|
|
19102
19894
|
};
|
|
19103
|
-
|
|
19895
|
+
_a97 = symbol97;
|
|
19104
19896
|
var UnsupportedModelVersionError3 = class extends AISDKError3 {
|
|
19105
19897
|
constructor(options) {
|
|
19106
19898
|
super({
|
|
@@ -19112,27 +19904,27 @@ var UnsupportedModelVersionError3 = class extends AISDKError3 {
|
|
|
19112
19904
|
this.modelId = options.modelId;
|
|
19113
19905
|
}
|
|
19114
19906
|
};
|
|
19115
|
-
var
|
|
19116
|
-
var
|
|
19117
|
-
var
|
|
19118
|
-
var
|
|
19907
|
+
var name202 = "AI_RetryError";
|
|
19908
|
+
var marker202 = `vercel.ai.error.${name202}`;
|
|
19909
|
+
var symbol202 = Symbol.for(marker202);
|
|
19910
|
+
var _a202;
|
|
19119
19911
|
var RetryError3 = class extends AISDKError3 {
|
|
19120
19912
|
constructor({
|
|
19121
19913
|
message,
|
|
19122
19914
|
reason,
|
|
19123
19915
|
errors
|
|
19124
19916
|
}) {
|
|
19125
|
-
super({ name:
|
|
19126
|
-
this[
|
|
19917
|
+
super({ name: name202, message });
|
|
19918
|
+
this[_a202] = true;
|
|
19127
19919
|
this.reason = reason;
|
|
19128
19920
|
this.errors = errors;
|
|
19129
19921
|
this.lastError = errors[errors.length - 1];
|
|
19130
19922
|
}
|
|
19131
19923
|
static isInstance(error) {
|
|
19132
|
-
return AISDKError3.hasMarker(error,
|
|
19924
|
+
return AISDKError3.hasMarker(error, marker202);
|
|
19133
19925
|
}
|
|
19134
19926
|
};
|
|
19135
|
-
|
|
19927
|
+
_a202 = symbol202;
|
|
19136
19928
|
function formatWarning({
|
|
19137
19929
|
warning,
|
|
19138
19930
|
provider,
|
|
@@ -19237,8 +20029,8 @@ function resolveEmbeddingModel2(model) {
|
|
|
19237
20029
|
return getGlobalProvider2().embeddingModel(model);
|
|
19238
20030
|
}
|
|
19239
20031
|
function getGlobalProvider2() {
|
|
19240
|
-
var
|
|
19241
|
-
return (
|
|
20032
|
+
var _a223;
|
|
20033
|
+
return (_a223 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a223 : gateway2;
|
|
19242
20034
|
}
|
|
19243
20035
|
function getTotalTimeoutMs(timeout) {
|
|
19244
20036
|
if (timeout == null) {
|
|
@@ -19249,7 +20041,7 @@ function getTotalTimeoutMs(timeout) {
|
|
|
19249
20041
|
}
|
|
19250
20042
|
return timeout.totalMs;
|
|
19251
20043
|
}
|
|
19252
|
-
var
|
|
20044
|
+
var VERSION23 = "6.0.224";
|
|
19253
20045
|
var dataContentSchema3 = z42.z.union([
|
|
19254
20046
|
z42.z.string(),
|
|
19255
20047
|
z42.z.instanceof(Uint8Array),
|
|
@@ -19257,8 +20049,8 @@ var dataContentSchema3 = z42.z.union([
|
|
|
19257
20049
|
z42.z.custom(
|
|
19258
20050
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
19259
20051
|
(value) => {
|
|
19260
|
-
var
|
|
19261
|
-
return (
|
|
20052
|
+
var _a223, _b19;
|
|
20053
|
+
return (_b19 = (_a223 = globalThis.Buffer) == null ? void 0 : _a223.isBuffer(value)) != null ? _b19 : false;
|
|
19262
20054
|
},
|
|
19263
20055
|
{ message: "Must be a Buffer" }
|
|
19264
20056
|
)
|
|
@@ -19472,7 +20264,7 @@ function getBaseTelemetryAttributes3({
|
|
|
19472
20264
|
telemetry,
|
|
19473
20265
|
headers
|
|
19474
20266
|
}) {
|
|
19475
|
-
var
|
|
20267
|
+
var _a223;
|
|
19476
20268
|
return {
|
|
19477
20269
|
"ai.model.provider": model.provider,
|
|
19478
20270
|
"ai.model.id": model.modelId,
|
|
@@ -19491,7 +20283,7 @@ function getBaseTelemetryAttributes3({
|
|
|
19491
20283
|
return attributes;
|
|
19492
20284
|
}, {}),
|
|
19493
20285
|
// add metadata as attributes:
|
|
19494
|
-
...Object.entries((
|
|
20286
|
+
...Object.entries((_a223 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a223 : {}).reduce(
|
|
19495
20287
|
(attributes, [key, value]) => {
|
|
19496
20288
|
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
19497
20289
|
return attributes;
|
|
@@ -19511,7 +20303,7 @@ var noopTracer3 = {
|
|
|
19511
20303
|
startSpan() {
|
|
19512
20304
|
return noopSpan3;
|
|
19513
20305
|
},
|
|
19514
|
-
startActiveSpan(
|
|
20306
|
+
startActiveSpan(name223, arg1, arg2, arg3) {
|
|
19515
20307
|
if (typeof arg1 === "function") {
|
|
19516
20308
|
return arg1(noopSpan3);
|
|
19517
20309
|
}
|
|
@@ -19576,14 +20368,14 @@ function getTracer3({
|
|
|
19576
20368
|
return trace3.getTracer("ai");
|
|
19577
20369
|
}
|
|
19578
20370
|
async function recordSpan3({
|
|
19579
|
-
name:
|
|
20371
|
+
name: name223,
|
|
19580
20372
|
tracer,
|
|
19581
20373
|
attributes,
|
|
19582
20374
|
fn,
|
|
19583
20375
|
endWhenDone = true
|
|
19584
20376
|
}) {
|
|
19585
20377
|
return tracer.startActiveSpan(
|
|
19586
|
-
|
|
20378
|
+
name223,
|
|
19587
20379
|
{ attributes: await attributes },
|
|
19588
20380
|
async (span) => {
|
|
19589
20381
|
const ctx = context.active();
|
|
@@ -19619,6 +20411,28 @@ function recordErrorOnSpan3(span, error) {
|
|
|
19619
20411
|
span.setStatus({ code: SpanStatusCode3.ERROR });
|
|
19620
20412
|
}
|
|
19621
20413
|
}
|
|
20414
|
+
function isPrimitiveAttributeValue(value) {
|
|
20415
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
20416
|
+
}
|
|
20417
|
+
function sanitizeAttributeValue(value) {
|
|
20418
|
+
if (!Array.isArray(value)) {
|
|
20419
|
+
return value;
|
|
20420
|
+
}
|
|
20421
|
+
const primitiveTypes = new Set(
|
|
20422
|
+
value.filter(isPrimitiveAttributeValue).map((item) => typeof item)
|
|
20423
|
+
);
|
|
20424
|
+
if (primitiveTypes.size !== 1) {
|
|
20425
|
+
return void 0;
|
|
20426
|
+
}
|
|
20427
|
+
const [primitiveType] = primitiveTypes;
|
|
20428
|
+
if (primitiveType === "string") {
|
|
20429
|
+
return value.filter((item) => typeof item === "string");
|
|
20430
|
+
}
|
|
20431
|
+
if (primitiveType === "number") {
|
|
20432
|
+
return value.filter((item) => typeof item === "number");
|
|
20433
|
+
}
|
|
20434
|
+
return value.filter((item) => typeof item === "boolean");
|
|
20435
|
+
}
|
|
19622
20436
|
async function selectTelemetryAttributes3({
|
|
19623
20437
|
telemetry,
|
|
19624
20438
|
attributes
|
|
@@ -19637,7 +20451,9 @@ async function selectTelemetryAttributes3({
|
|
|
19637
20451
|
}
|
|
19638
20452
|
const result = await value.input();
|
|
19639
20453
|
if (result != null) {
|
|
19640
|
-
|
|
20454
|
+
const sanitized2 = sanitizeAttributeValue(result);
|
|
20455
|
+
if (sanitized2 != null)
|
|
20456
|
+
resultAttributes[key] = sanitized2;
|
|
19641
20457
|
}
|
|
19642
20458
|
continue;
|
|
19643
20459
|
}
|
|
@@ -19647,11 +20463,15 @@ async function selectTelemetryAttributes3({
|
|
|
19647
20463
|
}
|
|
19648
20464
|
const result = await value.output();
|
|
19649
20465
|
if (result != null) {
|
|
19650
|
-
|
|
20466
|
+
const sanitized2 = sanitizeAttributeValue(result);
|
|
20467
|
+
if (sanitized2 != null)
|
|
20468
|
+
resultAttributes[key] = sanitized2;
|
|
19651
20469
|
}
|
|
19652
20470
|
continue;
|
|
19653
20471
|
}
|
|
19654
|
-
|
|
20472
|
+
const sanitized = sanitizeAttributeValue(value);
|
|
20473
|
+
if (sanitized != null)
|
|
20474
|
+
resultAttributes[key] = sanitized;
|
|
19655
20475
|
}
|
|
19656
20476
|
return resultAttributes;
|
|
19657
20477
|
}
|
|
@@ -19659,7 +20479,7 @@ function getRetryDelayInMs2({
|
|
|
19659
20479
|
error,
|
|
19660
20480
|
exponentialBackoffDelay
|
|
19661
20481
|
}) {
|
|
19662
|
-
const headers = error.responseHeaders;
|
|
20482
|
+
const headers = APICallError3.isInstance(error) ? error.responseHeaders : APICallError3.isInstance(error.cause) ? error.cause.responseHeaders : void 0;
|
|
19663
20483
|
if (!headers)
|
|
19664
20484
|
return exponentialBackoffDelay;
|
|
19665
20485
|
let ms;
|
|
@@ -19689,66 +20509,18 @@ var retryWithExponentialBackoffRespectingRetryHeaders2 = ({
|
|
|
19689
20509
|
initialDelayInMs = 2e3,
|
|
19690
20510
|
backoffFactor = 2,
|
|
19691
20511
|
abortSignal
|
|
19692
|
-
} = {}) =>
|
|
20512
|
+
} = {}) => retryWithExponentialBackoff2({
|
|
19693
20513
|
maxRetries,
|
|
19694
|
-
|
|
20514
|
+
initialDelayInMs,
|
|
19695
20515
|
backoffFactor,
|
|
19696
|
-
abortSignal
|
|
20516
|
+
abortSignal,
|
|
20517
|
+
shouldRetry: (error) => error instanceof Error && (APICallError3.isInstance(error) && error.isRetryable === true || GatewayError2.isInstance(error) && error.isRetryable === true),
|
|
20518
|
+
getDelayInMs: ({ error, exponentialBackoffDelay }) => getRetryDelayInMs2({
|
|
20519
|
+
error,
|
|
20520
|
+
exponentialBackoffDelay
|
|
20521
|
+
}),
|
|
20522
|
+
createRetryError: ({ message, reason, errors }) => new RetryError3({ message, reason, errors })
|
|
19697
20523
|
});
|
|
19698
|
-
async function _retryWithExponentialBackoff3(f, {
|
|
19699
|
-
maxRetries,
|
|
19700
|
-
delayInMs,
|
|
19701
|
-
backoffFactor,
|
|
19702
|
-
abortSignal
|
|
19703
|
-
}, errors = []) {
|
|
19704
|
-
try {
|
|
19705
|
-
return await f();
|
|
19706
|
-
} catch (error) {
|
|
19707
|
-
if (isAbortError5(error)) {
|
|
19708
|
-
throw error;
|
|
19709
|
-
}
|
|
19710
|
-
if (maxRetries === 0) {
|
|
19711
|
-
throw error;
|
|
19712
|
-
}
|
|
19713
|
-
const errorMessage = getErrorMessage23(error);
|
|
19714
|
-
const newErrors = [...errors, error];
|
|
19715
|
-
const tryNumber = newErrors.length;
|
|
19716
|
-
if (tryNumber > maxRetries) {
|
|
19717
|
-
throw new RetryError3({
|
|
19718
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
19719
|
-
reason: "maxRetriesExceeded",
|
|
19720
|
-
errors: newErrors
|
|
19721
|
-
});
|
|
19722
|
-
}
|
|
19723
|
-
if (error instanceof Error && APICallError3.isInstance(error) && error.isRetryable === true && tryNumber <= maxRetries) {
|
|
19724
|
-
await delay3(
|
|
19725
|
-
getRetryDelayInMs2({
|
|
19726
|
-
error,
|
|
19727
|
-
exponentialBackoffDelay: delayInMs
|
|
19728
|
-
}),
|
|
19729
|
-
{ abortSignal }
|
|
19730
|
-
);
|
|
19731
|
-
return _retryWithExponentialBackoff3(
|
|
19732
|
-
f,
|
|
19733
|
-
{
|
|
19734
|
-
maxRetries,
|
|
19735
|
-
delayInMs: backoffFactor * delayInMs,
|
|
19736
|
-
backoffFactor,
|
|
19737
|
-
abortSignal
|
|
19738
|
-
},
|
|
19739
|
-
newErrors
|
|
19740
|
-
);
|
|
19741
|
-
}
|
|
19742
|
-
if (tryNumber === 1) {
|
|
19743
|
-
throw error;
|
|
19744
|
-
}
|
|
19745
|
-
throw new RetryError3({
|
|
19746
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
19747
|
-
reason: "errorNotRetryable",
|
|
19748
|
-
errors: newErrors
|
|
19749
|
-
});
|
|
19750
|
-
}
|
|
19751
|
-
}
|
|
19752
20524
|
function prepareRetries3({
|
|
19753
20525
|
maxRetries,
|
|
19754
20526
|
abortSignal
|
|
@@ -19778,6 +20550,7 @@ function prepareRetries3({
|
|
|
19778
20550
|
})
|
|
19779
20551
|
};
|
|
19780
20552
|
}
|
|
20553
|
+
new TextEncoder();
|
|
19781
20554
|
var output_exports3 = {};
|
|
19782
20555
|
__export3(output_exports3, {
|
|
19783
20556
|
array: () => array,
|
|
@@ -19790,6 +20563,10 @@ function fixJson3(input) {
|
|
|
19790
20563
|
const stack = ["ROOT"];
|
|
19791
20564
|
let lastValidIndex = -1;
|
|
19792
20565
|
let literalStart = null;
|
|
20566
|
+
let unicodeEscapeDigits = 0;
|
|
20567
|
+
function isHexDigit(char) {
|
|
20568
|
+
return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
|
|
20569
|
+
}
|
|
19793
20570
|
function processValueStart(char, i, swapState) {
|
|
19794
20571
|
{
|
|
19795
20572
|
switch (char) {
|
|
@@ -19994,7 +20771,22 @@ function fixJson3(input) {
|
|
|
19994
20771
|
}
|
|
19995
20772
|
case "INSIDE_STRING_ESCAPE": {
|
|
19996
20773
|
stack.pop();
|
|
19997
|
-
|
|
20774
|
+
if (char === "u") {
|
|
20775
|
+
unicodeEscapeDigits = 0;
|
|
20776
|
+
stack.push("INSIDE_STRING_UNICODE_ESCAPE");
|
|
20777
|
+
} else {
|
|
20778
|
+
lastValidIndex = i;
|
|
20779
|
+
}
|
|
20780
|
+
break;
|
|
20781
|
+
}
|
|
20782
|
+
case "INSIDE_STRING_UNICODE_ESCAPE": {
|
|
20783
|
+
if (isHexDigit(char)) {
|
|
20784
|
+
unicodeEscapeDigits++;
|
|
20785
|
+
if (unicodeEscapeDigits === 4) {
|
|
20786
|
+
stack.pop();
|
|
20787
|
+
lastValidIndex = i;
|
|
20788
|
+
}
|
|
20789
|
+
}
|
|
19998
20790
|
break;
|
|
19999
20791
|
}
|
|
20000
20792
|
case "INSIDE_NUMBER": {
|
|
@@ -20131,7 +20923,7 @@ var text3 = () => ({
|
|
|
20131
20923
|
});
|
|
20132
20924
|
var object3 = ({
|
|
20133
20925
|
schema: inputSchema,
|
|
20134
|
-
name:
|
|
20926
|
+
name: name223,
|
|
20135
20927
|
description
|
|
20136
20928
|
}) => {
|
|
20137
20929
|
const schema = asSchema3(inputSchema);
|
|
@@ -20140,7 +20932,7 @@ var object3 = ({
|
|
|
20140
20932
|
responseFormat: resolve2(schema.jsonSchema).then((jsonSchema22) => ({
|
|
20141
20933
|
type: "json",
|
|
20142
20934
|
schema: jsonSchema22,
|
|
20143
|
-
...
|
|
20935
|
+
...name223 != null && { name: name223 },
|
|
20144
20936
|
...description != null && { description }
|
|
20145
20937
|
})),
|
|
20146
20938
|
async parseCompleteOutput({ text: text22 }, context2) {
|
|
@@ -20194,7 +20986,7 @@ var object3 = ({
|
|
|
20194
20986
|
};
|
|
20195
20987
|
var array = ({
|
|
20196
20988
|
element: inputElementSchema,
|
|
20197
|
-
name:
|
|
20989
|
+
name: name223,
|
|
20198
20990
|
description
|
|
20199
20991
|
}) => {
|
|
20200
20992
|
const elementSchema = asSchema3(inputElementSchema);
|
|
@@ -20214,7 +21006,7 @@ var array = ({
|
|
|
20214
21006
|
required: ["elements"],
|
|
20215
21007
|
additionalProperties: false
|
|
20216
21008
|
},
|
|
20217
|
-
...
|
|
21009
|
+
...name223 != null && { name: name223 },
|
|
20218
21010
|
...description != null && { description }
|
|
20219
21011
|
};
|
|
20220
21012
|
}),
|
|
@@ -20244,6 +21036,7 @@ var array = ({
|
|
|
20244
21036
|
finishReason: context2.finishReason
|
|
20245
21037
|
});
|
|
20246
21038
|
}
|
|
21039
|
+
const validatedElements = [];
|
|
20247
21040
|
for (const element of outerValue.elements) {
|
|
20248
21041
|
const validationResult = await safeValidateTypes3({
|
|
20249
21042
|
value: element,
|
|
@@ -20259,8 +21052,9 @@ var array = ({
|
|
|
20259
21052
|
finishReason: context2.finishReason
|
|
20260
21053
|
});
|
|
20261
21054
|
}
|
|
21055
|
+
validatedElements.push(validationResult.value);
|
|
20262
21056
|
}
|
|
20263
|
-
return
|
|
21057
|
+
return validatedElements;
|
|
20264
21058
|
},
|
|
20265
21059
|
async parsePartialOutput({ text: text22 }) {
|
|
20266
21060
|
const result = await parsePartialJson3(text22);
|
|
@@ -20306,7 +21100,7 @@ var array = ({
|
|
|
20306
21100
|
};
|
|
20307
21101
|
var choice = ({
|
|
20308
21102
|
options: choiceOptions,
|
|
20309
|
-
name:
|
|
21103
|
+
name: name223,
|
|
20310
21104
|
description
|
|
20311
21105
|
}) => {
|
|
20312
21106
|
return {
|
|
@@ -20323,7 +21117,7 @@ var choice = ({
|
|
|
20323
21117
|
required: ["result"],
|
|
20324
21118
|
additionalProperties: false
|
|
20325
21119
|
},
|
|
20326
|
-
...
|
|
21120
|
+
...name223 != null && { name: name223 },
|
|
20327
21121
|
...description != null && { description }
|
|
20328
21122
|
}),
|
|
20329
21123
|
async parseCompleteOutput({ text: text22 }, context2) {
|
|
@@ -20384,14 +21178,14 @@ var choice = ({
|
|
|
20384
21178
|
};
|
|
20385
21179
|
};
|
|
20386
21180
|
var json = ({
|
|
20387
|
-
name:
|
|
21181
|
+
name: name223,
|
|
20388
21182
|
description
|
|
20389
21183
|
} = {}) => {
|
|
20390
21184
|
return {
|
|
20391
21185
|
name: "json",
|
|
20392
21186
|
responseFormat: Promise.resolve({
|
|
20393
21187
|
type: "json",
|
|
20394
|
-
...
|
|
21188
|
+
...name223 != null && { name: name223 },
|
|
20395
21189
|
...description != null && { description }
|
|
20396
21190
|
}),
|
|
20397
21191
|
async parseCompleteOutput({ text: text22 }, context2) {
|
|
@@ -20469,7 +21263,7 @@ async function embedMany3({
|
|
|
20469
21263
|
});
|
|
20470
21264
|
const headersWithUserAgent = withUserAgentSuffix2(
|
|
20471
21265
|
headers != null ? headers : {},
|
|
20472
|
-
`ai/${
|
|
21266
|
+
`ai/${VERSION23}`
|
|
20473
21267
|
);
|
|
20474
21268
|
const baseTelemetryAttributes = getBaseTelemetryAttributes3({
|
|
20475
21269
|
model,
|
|
@@ -20493,7 +21287,7 @@ async function embedMany3({
|
|
|
20493
21287
|
}),
|
|
20494
21288
|
tracer,
|
|
20495
21289
|
fn: async (span) => {
|
|
20496
|
-
var
|
|
21290
|
+
var _a223;
|
|
20497
21291
|
const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
|
|
20498
21292
|
model.maxEmbeddingsPerCall,
|
|
20499
21293
|
model.supportsParallelCalls
|
|
@@ -20518,7 +21312,7 @@ async function embedMany3({
|
|
|
20518
21312
|
}),
|
|
20519
21313
|
tracer,
|
|
20520
21314
|
fn: async (doEmbedSpan) => {
|
|
20521
|
-
var
|
|
21315
|
+
var _a232, _b19;
|
|
20522
21316
|
const modelResponse = await model.doEmbed({
|
|
20523
21317
|
values,
|
|
20524
21318
|
abortSignal,
|
|
@@ -20526,7 +21320,7 @@ async function embedMany3({
|
|
|
20526
21320
|
providerOptions
|
|
20527
21321
|
});
|
|
20528
21322
|
const embeddings3 = modelResponse.embeddings;
|
|
20529
|
-
const usage2 = (
|
|
21323
|
+
const usage2 = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
|
|
20530
21324
|
doEmbedSpan.setAttributes(
|
|
20531
21325
|
await selectTelemetryAttributes3({
|
|
20532
21326
|
telemetry,
|
|
@@ -20543,7 +21337,7 @@ async function embedMany3({
|
|
|
20543
21337
|
return {
|
|
20544
21338
|
embeddings: embeddings3,
|
|
20545
21339
|
usage: usage2,
|
|
20546
|
-
warnings: modelResponse.warnings,
|
|
21340
|
+
warnings: (_b19 = modelResponse.warnings) != null ? _b19 : [],
|
|
20547
21341
|
providerMetadata: modelResponse.providerMetadata,
|
|
20548
21342
|
response: modelResponse.response
|
|
20549
21343
|
};
|
|
@@ -20607,7 +21401,7 @@ async function embedMany3({
|
|
|
20607
21401
|
}),
|
|
20608
21402
|
tracer,
|
|
20609
21403
|
fn: async (doEmbedSpan) => {
|
|
20610
|
-
var
|
|
21404
|
+
var _a232, _b19;
|
|
20611
21405
|
const modelResponse = await model.doEmbed({
|
|
20612
21406
|
values: chunk,
|
|
20613
21407
|
abortSignal,
|
|
@@ -20615,7 +21409,7 @@ async function embedMany3({
|
|
|
20615
21409
|
providerOptions
|
|
20616
21410
|
});
|
|
20617
21411
|
const embeddings2 = modelResponse.embeddings;
|
|
20618
|
-
const usage = (
|
|
21412
|
+
const usage = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
|
|
20619
21413
|
doEmbedSpan.setAttributes(
|
|
20620
21414
|
await selectTelemetryAttributes3({
|
|
20621
21415
|
telemetry,
|
|
@@ -20632,7 +21426,7 @@ async function embedMany3({
|
|
|
20632
21426
|
return {
|
|
20633
21427
|
embeddings: embeddings2,
|
|
20634
21428
|
usage,
|
|
20635
|
-
warnings: modelResponse.warnings,
|
|
21429
|
+
warnings: (_b19 = modelResponse.warnings) != null ? _b19 : [],
|
|
20636
21430
|
providerMetadata: modelResponse.providerMetadata,
|
|
20637
21431
|
response: modelResponse.response
|
|
20638
21432
|
};
|
|
@@ -20654,7 +21448,7 @@ async function embedMany3({
|
|
|
20654
21448
|
result.providerMetadata
|
|
20655
21449
|
)) {
|
|
20656
21450
|
providerMetadata[providerName] = {
|
|
20657
|
-
...(
|
|
21451
|
+
...(_a223 = providerMetadata[providerName]) != null ? _a223 : {},
|
|
20658
21452
|
...metadata
|
|
20659
21453
|
};
|
|
20660
21454
|
}
|
|
@@ -22373,8 +23167,8 @@ async function listThreadsForResource({
|
|
|
22373
23167
|
const title = thread.title || "(untitled)";
|
|
22374
23168
|
const updated = formatTimestamp(thread.updatedAt);
|
|
22375
23169
|
const created = formatTimestamp(thread.createdAt);
|
|
22376
|
-
const
|
|
22377
|
-
lines.push(`- **${title}**${
|
|
23170
|
+
const marker28 = isCurrent ? " \u2190 current" : "";
|
|
23171
|
+
lines.push(`- **${title}**${marker28}`);
|
|
22378
23172
|
lines.push(` id: ${thread.id}`);
|
|
22379
23173
|
lines.push(` updated: ${updated} | created: ${created}`);
|
|
22380
23174
|
}
|
|
@@ -23533,8 +24327,8 @@ var __experimental_updateWorkingMemoryToolVNext = (config) => {
|
|
|
23533
24327
|
function createWorkingMemoryTool(config, options = {}) {
|
|
23534
24328
|
const useStateSignals = config.workingMemory?.useStateSignals === true;
|
|
23535
24329
|
const tool3 = options.vNext ? __experimental_updateWorkingMemoryToolVNext(config) : updateWorkingMemoryTool(config);
|
|
23536
|
-
const
|
|
23537
|
-
return { name:
|
|
24330
|
+
const name28 = useStateSignals ? SET_WORKING_MEMORY_TOOL_NAME : UPDATE_WORKING_MEMORY_TOOL_NAME;
|
|
24331
|
+
return { name: name28, tool: tool3 };
|
|
23538
24332
|
}
|
|
23539
24333
|
var WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
23540
24334
|
var WORKING_MEMORY_END_TAG = "</working_memory>";
|
|
@@ -23959,7 +24753,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
23959
24753
|
const separator = this.vector.indexSeparator ?? "_";
|
|
23960
24754
|
const prefix = `memory${separator}messages`;
|
|
23961
24755
|
const indexes = await this.vector.listIndexes();
|
|
23962
|
-
return indexes.filter((
|
|
24756
|
+
return indexes.filter((name28) => name28.startsWith(prefix));
|
|
23963
24757
|
}
|
|
23964
24758
|
/**
|
|
23965
24759
|
* Deletes all vector embeddings associated with a thread.
|
|
@@ -24623,7 +25417,7 @@ ${workingMemory}`;
|
|
|
24623
25417
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
24624
25418
|
);
|
|
24625
25419
|
}
|
|
24626
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
25420
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-2F4GJOP2.cjs');
|
|
24627
25421
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
24628
25422
|
await this.indexObservation(observation);
|
|
24629
25423
|
} : void 0;
|
|
@@ -25081,10 +25875,10 @@ Notes:
|
|
|
25081
25875
|
const tools = {};
|
|
25082
25876
|
const workingMemoryConfig = mergedConfig.workingMemory;
|
|
25083
25877
|
if (workingMemoryConfig?.enabled && workingMemoryConfig.agentManaged !== false && !mergedConfig.readOnly) {
|
|
25084
|
-
const { name:
|
|
25878
|
+
const { name: name28, tool: tool3 } = createWorkingMemoryTool(mergedConfig, {
|
|
25085
25879
|
vNext: this.isVNextWorkingMemoryConfig(mergedConfig)
|
|
25086
25880
|
});
|
|
25087
|
-
tools[
|
|
25881
|
+
tools[name28] = tool3;
|
|
25088
25882
|
}
|
|
25089
25883
|
const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
|
|
25090
25884
|
if (omConfig?.retrieval) {
|
|
@@ -25671,7 +26465,7 @@ Notes:
|
|
|
25671
26465
|
if (!effectiveConfig) return null;
|
|
25672
26466
|
const engine = await this.omEngine;
|
|
25673
26467
|
if (!engine) return null;
|
|
25674
|
-
const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-
|
|
26468
|
+
const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-2F4GJOP2.cjs');
|
|
25675
26469
|
return new ObservationalMemoryProcessor2(engine, this, {
|
|
25676
26470
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
25677
26471
|
});
|
|
@@ -28328,16 +29122,16 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
28328
29122
|
* (data-* parts are filtered out before sending to the LLM, so they don't affect model calls.)
|
|
28329
29123
|
* @internal Used by ReflectorRunner. Do not call directly.
|
|
28330
29124
|
*/
|
|
28331
|
-
async persistMarkerToMessage(
|
|
29125
|
+
async persistMarkerToMessage(marker28, messageList, threadId, resourceId) {
|
|
28332
29126
|
if (!messageList) return;
|
|
28333
29127
|
const allMsgs = messageList.get.all.db();
|
|
28334
29128
|
for (let i = allMsgs.length - 1; i >= 0; i--) {
|
|
28335
29129
|
const msg = allMsgs[i];
|
|
28336
29130
|
if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
|
|
28337
|
-
const markerData =
|
|
28338
|
-
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type ===
|
|
29131
|
+
const markerData = marker28.data;
|
|
29132
|
+
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type === marker28.type && p?.data?.cycleId === markerData.cycleId);
|
|
28339
29133
|
if (!alreadyPresent) {
|
|
28340
|
-
msg.content.parts.push(
|
|
29134
|
+
msg.content.parts.push(marker28);
|
|
28341
29135
|
}
|
|
28342
29136
|
try {
|
|
28343
29137
|
await this.messageHistory.persistMessages({
|
|
@@ -28358,7 +29152,7 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
28358
29152
|
* so it works even when no MessageList is available (e.g. async buffering ops).
|
|
28359
29153
|
* @internal Used by observation strategies. Do not call directly.
|
|
28360
29154
|
*/
|
|
28361
|
-
async persistMarkerToStorage(
|
|
29155
|
+
async persistMarkerToStorage(marker28, threadId, resourceId) {
|
|
28362
29156
|
try {
|
|
28363
29157
|
const result = await this.storage.listMessages({
|
|
28364
29158
|
threadId,
|
|
@@ -28368,10 +29162,10 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
28368
29162
|
const messages = result?.messages ?? [];
|
|
28369
29163
|
for (const msg of messages) {
|
|
28370
29164
|
if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
|
|
28371
|
-
const markerData =
|
|
28372
|
-
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type ===
|
|
29165
|
+
const markerData = marker28.data;
|
|
29166
|
+
const alreadyPresent = markerData?.cycleId && msg.content.parts.some((p) => p?.type === marker28.type && p?.data?.cycleId === markerData.cycleId);
|
|
28373
29167
|
if (!alreadyPresent) {
|
|
28374
|
-
msg.content.parts.push(
|
|
29168
|
+
msg.content.parts.push(marker28);
|
|
28375
29169
|
}
|
|
28376
29170
|
await this.messageHistory.persistMessages({
|
|
28377
29171
|
messages: [msg],
|
|
@@ -30667,5 +31461,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
30667
31461
|
exports.stripObservationGroups = stripObservationGroups;
|
|
30668
31462
|
exports.summarizeConversation = summarizeConversation;
|
|
30669
31463
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
30670
|
-
//# sourceMappingURL=chunk-
|
|
30671
|
-
//# sourceMappingURL=chunk-
|
|
31464
|
+
//# sourceMappingURL=chunk-42LZUXJ3.cjs.map
|
|
31465
|
+
//# sourceMappingURL=chunk-42LZUXJ3.cjs.map
|