@mastra/memory 1.23.0-alpha.2 → 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 +19 -0
- package/dist/{chunk-2ZR7CKDV.cjs → chunk-42LZUXJ3.cjs} +1985 -1149
- package/dist/chunk-42LZUXJ3.cjs.map +1 -0
- package/dist/{chunk-GHFCSEEP.js → chunk-6ACCFKAN.js} +1985 -1149
- package/dist/chunk-6ACCFKAN.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +57 -57
- package/dist/docs/references/docs-agents-supervisor-agents.md +1 -3
- package/dist/docs/references/docs-evals-evals-with-memory.md +1 -3
- package/dist/docs/references/docs-long-running-agents-background-tasks.md +1 -1
- package/dist/docs/references/docs-long-running-agents-goals.md +1 -3
- package/dist/docs/references/docs-memory-overview.md +4 -4
- package/dist/index.cjs +15 -15
- package/dist/index.js +1 -1
- package/dist/{observational-memory-RJL2PW6O.cjs → observational-memory-2F4GJOP2.cjs} +29 -29
- package/dist/{observational-memory-RJL2PW6O.cjs.map → observational-memory-2F4GJOP2.cjs.map} +1 -1
- package/dist/{observational-memory-HUPMKPOX.js → observational-memory-OJN26RQ4.js} +3 -3
- package/dist/{observational-memory-HUPMKPOX.js.map → observational-memory-OJN26RQ4.js.map} +1 -1
- package/dist/processors/index.cjs +27 -27
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts +13 -0
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +25 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-2ZR7CKDV.cjs.map +0 -1
- package/dist/chunk-GHFCSEEP.js.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,
|
|
@@ -2807,6 +2807,18 @@ var ObservationStep = class {
|
|
|
2807
2807
|
get prepared() {
|
|
2808
2808
|
return this._prepared;
|
|
2809
2809
|
}
|
|
2810
|
+
/**
|
|
2811
|
+
* Serialize to a minimal, acyclic snapshot.
|
|
2812
|
+
*
|
|
2813
|
+
* The `turn` back-reference exists only so a step can read context off its parent turn at
|
|
2814
|
+
* runtime. It closes the `ObservationTurn._currentStep -> ObservationStep.turn` cycle, so
|
|
2815
|
+
* serializing it throws "Converting circular structure to JSON" (e.g. when a turn is stashed
|
|
2816
|
+
* in processor state that flows into a processor-workflow snapshot). The parent turn fully
|
|
2817
|
+
* owns the step, so omitting the back-reference is lossless.
|
|
2818
|
+
*/
|
|
2819
|
+
toJSON() {
|
|
2820
|
+
return { stepNumber: this.stepNumber, prepared: this._prepared };
|
|
2821
|
+
}
|
|
2810
2822
|
/** Step context from prepare(). Throws if prepare() hasn't been called. */
|
|
2811
2823
|
get context() {
|
|
2812
2824
|
if (!this._context) throw new Error("Step not prepared yet \u2014 call prepare() first");
|
|
@@ -3270,6 +3282,33 @@ var ObservationTurn = class {
|
|
|
3270
3282
|
}
|
|
3271
3283
|
return this._context?.otherThreadsContext;
|
|
3272
3284
|
}
|
|
3285
|
+
/**
|
|
3286
|
+
* Serialize to a minimal, acyclic snapshot of the turn's identity and lifecycle.
|
|
3287
|
+
*
|
|
3288
|
+
* `ObservationTurn` is a request-scoped runtime orchestration object: it holds live
|
|
3289
|
+
* references (the `ObservationalMemory` engine, the `MessageList`, the stream writer, the
|
|
3290
|
+
* memory provider, lifecycle hooks) and a back-reference to its current `ObservationStep`,
|
|
3291
|
+
* which points back at the turn — a cycle. None of that is persistable state. The turn is
|
|
3292
|
+
* stashed in the shared processor-state map (`state.__omTurn`) only so the input and output
|
|
3293
|
+
* OM processor instances can reach the *live* object within a single request; that map is
|
|
3294
|
+
* also threaded into processor workflows, whose snapshots the storage layer serializes with
|
|
3295
|
+
* `JSON.stringify`. Without this projection, that serialization throws "Converting circular
|
|
3296
|
+
* structure to JSON" via `_currentStep` <-> `turn`.
|
|
3297
|
+
*
|
|
3298
|
+
* The projection is lossless: the dropped fields are live runtime objects that cannot and
|
|
3299
|
+
* should not round-trip through storage, and OM never reads the turn back from a snapshot —
|
|
3300
|
+
* it always reads the live `__omTurn` from the in-memory map and re-establishes a fresh turn
|
|
3301
|
+
* when a deserialized `MessageList` no longer matches (see the processor's turn handling).
|
|
3302
|
+
*/
|
|
3303
|
+
toJSON() {
|
|
3304
|
+
return {
|
|
3305
|
+
threadId: this.threadId,
|
|
3306
|
+
resourceId: this.resourceId,
|
|
3307
|
+
started: this._started,
|
|
3308
|
+
ended: this._ended,
|
|
3309
|
+
currentStepNumber: this._currentStep?.stepNumber
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3273
3312
|
};
|
|
3274
3313
|
|
|
3275
3314
|
// src/processors/observational-memory/anchor-ids.ts
|
|
@@ -4845,7 +4884,7 @@ async function withRetry(fn, opts) {
|
|
|
4845
4884
|
}
|
|
4846
4885
|
}
|
|
4847
4886
|
|
|
4848
|
-
// ../_vendored/ai_v4/dist/chunk-
|
|
4887
|
+
// ../_vendored/ai_v4/dist/chunk-SJKFJOR6.js
|
|
4849
4888
|
var __create = Object.create;
|
|
4850
4889
|
var __defProp = Object.defineProperty;
|
|
4851
4890
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7353,15 +7392,15 @@ var DiagAPI = (
|
|
|
7353
7392
|
return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
|
|
7354
7393
|
};
|
|
7355
7394
|
}
|
|
7356
|
-
var
|
|
7395
|
+
var self2 = this;
|
|
7357
7396
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
7358
7397
|
var _a173, _b19, _c;
|
|
7359
7398
|
if (optionsOrLogLevel === void 0) {
|
|
7360
7399
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
7361
7400
|
}
|
|
7362
|
-
if (logger ===
|
|
7401
|
+
if (logger === self2) {
|
|
7363
7402
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
7364
|
-
|
|
7403
|
+
self2.error((_a173 = err.stack) !== null && _a173 !== void 0 ? _a173 : err.message);
|
|
7365
7404
|
return false;
|
|
7366
7405
|
}
|
|
7367
7406
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -7376,20 +7415,20 @@ var DiagAPI = (
|
|
|
7376
7415
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
7377
7416
|
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
7378
7417
|
}
|
|
7379
|
-
return registerGlobal("diag", newLogger,
|
|
7418
|
+
return registerGlobal("diag", newLogger, self2, true);
|
|
7380
7419
|
};
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
unregisterGlobal(API_NAME,
|
|
7420
|
+
self2.setLogger = setLogger;
|
|
7421
|
+
self2.disable = function() {
|
|
7422
|
+
unregisterGlobal(API_NAME, self2);
|
|
7384
7423
|
};
|
|
7385
|
-
|
|
7424
|
+
self2.createComponentLogger = function(options) {
|
|
7386
7425
|
return new DiagComponentLogger(options);
|
|
7387
7426
|
};
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
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");
|
|
7393
7432
|
}
|
|
7394
7433
|
DiagAPI22.instance = function() {
|
|
7395
7434
|
if (!this._instance) {
|
|
@@ -7407,18 +7446,18 @@ var BaseContext = (
|
|
|
7407
7446
|
/** @class */
|
|
7408
7447
|
/* @__PURE__ */ (function() {
|
|
7409
7448
|
function BaseContext22(parentContext) {
|
|
7410
|
-
var
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
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);
|
|
7414
7453
|
};
|
|
7415
|
-
|
|
7416
|
-
var context2 = new BaseContext22(
|
|
7454
|
+
self2.setValue = function(key, value) {
|
|
7455
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
7417
7456
|
context2._currentContext.set(key, value);
|
|
7418
7457
|
return context2;
|
|
7419
7458
|
};
|
|
7420
|
-
|
|
7421
|
-
var context2 = new BaseContext22(
|
|
7459
|
+
self2.deleteValue = function(key) {
|
|
7460
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
7422
7461
|
context2._currentContext.delete(key);
|
|
7423
7462
|
return context2;
|
|
7424
7463
|
};
|
|
@@ -9339,6 +9378,90 @@ function createAbortError() {
|
|
|
9339
9378
|
function extractResponseHeaders(response) {
|
|
9340
9379
|
return Object.fromEntries([...response.headers]);
|
|
9341
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
|
+
}
|
|
9342
9465
|
var createIdGenerator2 = ({
|
|
9343
9466
|
prefix,
|
|
9344
9467
|
size = 16,
|
|
@@ -9406,11 +9529,11 @@ function handleFetchError({
|
|
|
9406
9529
|
return error;
|
|
9407
9530
|
}
|
|
9408
9531
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
9409
|
-
var
|
|
9532
|
+
var _a223, _b222, _c;
|
|
9410
9533
|
if (globalThisAny.window) {
|
|
9411
9534
|
return `runtime/browser`;
|
|
9412
9535
|
}
|
|
9413
|
-
if ((
|
|
9536
|
+
if ((_a223 = globalThisAny.navigator) == null ? void 0 : _a223.userAgent) {
|
|
9414
9537
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
9415
9538
|
}
|
|
9416
9539
|
if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
|
|
@@ -9451,7 +9574,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
9451
9574
|
);
|
|
9452
9575
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9453
9576
|
}
|
|
9454
|
-
var VERSION2 = "3.0.
|
|
9577
|
+
var VERSION2 = "3.0.28";
|
|
9455
9578
|
var getOriginalFetch = () => globalThis.fetch;
|
|
9456
9579
|
var getFromApi = async ({
|
|
9457
9580
|
url,
|
|
@@ -9798,7 +9921,7 @@ function tool(tool22) {
|
|
|
9798
9921
|
}
|
|
9799
9922
|
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
9800
9923
|
id,
|
|
9801
|
-
name:
|
|
9924
|
+
name: name223,
|
|
9802
9925
|
inputSchema,
|
|
9803
9926
|
outputSchema: outputSchema3
|
|
9804
9927
|
}) {
|
|
@@ -9812,7 +9935,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
9812
9935
|
}) => tool({
|
|
9813
9936
|
type: "provider-defined",
|
|
9814
9937
|
id,
|
|
9815
|
-
name:
|
|
9938
|
+
name: name223,
|
|
9816
9939
|
args,
|
|
9817
9940
|
inputSchema,
|
|
9818
9941
|
outputSchema: outputSchema3,
|
|
@@ -9829,12 +9952,24 @@ async function resolve(value) {
|
|
|
9829
9952
|
}
|
|
9830
9953
|
return Promise.resolve(value);
|
|
9831
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
|
+
}
|
|
9832
9967
|
var createJsonErrorResponseHandler = ({
|
|
9833
9968
|
errorSchema,
|
|
9834
9969
|
errorToMessage,
|
|
9835
9970
|
isRetryable
|
|
9836
9971
|
}) => async ({ response, url, requestBodyValues }) => {
|
|
9837
|
-
const responseBody = await response
|
|
9972
|
+
const responseBody = await readResponseBodyAsText({ response, url });
|
|
9838
9973
|
const responseHeaders = extractResponseHeaders(response);
|
|
9839
9974
|
if (responseBody.trim() === "") {
|
|
9840
9975
|
return {
|
|
@@ -9897,7 +10032,7 @@ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) =>
|
|
|
9897
10032
|
};
|
|
9898
10033
|
};
|
|
9899
10034
|
var createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
|
|
9900
|
-
const responseBody = await response
|
|
10035
|
+
const responseBody = await readResponseBodyAsText({ response, url });
|
|
9901
10036
|
const parsedResult = await safeParseJSON2({
|
|
9902
10037
|
text: responseBody,
|
|
9903
10038
|
schema: responseSchema
|
|
@@ -10007,11 +10142,11 @@ function parseAnyDef2() {
|
|
|
10007
10142
|
return {};
|
|
10008
10143
|
}
|
|
10009
10144
|
function parseArrayDef2(def, refs) {
|
|
10010
|
-
var
|
|
10145
|
+
var _a223, _b222, _c;
|
|
10011
10146
|
const res = {
|
|
10012
10147
|
type: "array"
|
|
10013
10148
|
};
|
|
10014
|
-
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) {
|
|
10015
10150
|
res.items = parseDef2(def.type._def, {
|
|
10016
10151
|
...refs,
|
|
10017
10152
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -10370,8 +10505,8 @@ function escapeNonAlphaNumeric2(source) {
|
|
|
10370
10505
|
return result;
|
|
10371
10506
|
}
|
|
10372
10507
|
function addFormat2(schema, value, message, refs) {
|
|
10373
|
-
var
|
|
10374
|
-
if (schema.format || ((
|
|
10508
|
+
var _a223;
|
|
10509
|
+
if (schema.format || ((_a223 = schema.anyOf) == null ? void 0 : _a223.some((x) => x.format))) {
|
|
10375
10510
|
if (!schema.anyOf) {
|
|
10376
10511
|
schema.anyOf = [];
|
|
10377
10512
|
}
|
|
@@ -10390,8 +10525,8 @@ function addFormat2(schema, value, message, refs) {
|
|
|
10390
10525
|
}
|
|
10391
10526
|
}
|
|
10392
10527
|
function addPattern2(schema, regex, message, refs) {
|
|
10393
|
-
var
|
|
10394
|
-
if (schema.pattern || ((
|
|
10528
|
+
var _a223;
|
|
10529
|
+
if (schema.pattern || ((_a223 = schema.allOf) == null ? void 0 : _a223.some((x) => x.pattern))) {
|
|
10395
10530
|
if (!schema.allOf) {
|
|
10396
10531
|
schema.allOf = [];
|
|
10397
10532
|
}
|
|
@@ -10410,7 +10545,7 @@ function addPattern2(schema, regex, message, refs) {
|
|
|
10410
10545
|
}
|
|
10411
10546
|
}
|
|
10412
10547
|
function stringifyRegExpWithFlags2(regex, refs) {
|
|
10413
|
-
var
|
|
10548
|
+
var _a223;
|
|
10414
10549
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
10415
10550
|
return regex.source;
|
|
10416
10551
|
}
|
|
@@ -10440,7 +10575,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
10440
10575
|
pattern += source[i];
|
|
10441
10576
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10442
10577
|
inCharRange = false;
|
|
10443
|
-
} else if (source[i + 1] === "-" && ((
|
|
10578
|
+
} else if (source[i + 1] === "-" && ((_a223 = source[i + 2]) == null ? void 0 : _a223.match(/[a-z]/))) {
|
|
10444
10579
|
pattern += source[i];
|
|
10445
10580
|
inCharRange = true;
|
|
10446
10581
|
} else {
|
|
@@ -10482,13 +10617,13 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
10482
10617
|
return pattern;
|
|
10483
10618
|
}
|
|
10484
10619
|
function parseRecordDef2(def, refs) {
|
|
10485
|
-
var
|
|
10620
|
+
var _a223, _b222, _c, _d, _e, _f;
|
|
10486
10621
|
const schema = {
|
|
10487
10622
|
type: "object",
|
|
10488
|
-
additionalProperties: (
|
|
10623
|
+
additionalProperties: (_a223 = parseDef2(def.valueType._def, {
|
|
10489
10624
|
...refs,
|
|
10490
10625
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10491
|
-
})) != null ?
|
|
10626
|
+
})) != null ? _a223 : refs.allowedAdditionalProperties
|
|
10492
10627
|
};
|
|
10493
10628
|
if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
10494
10629
|
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
@@ -10745,8 +10880,8 @@ function safeIsOptional2(schema) {
|
|
|
10745
10880
|
}
|
|
10746
10881
|
}
|
|
10747
10882
|
var parseOptionalDef2 = (def, refs) => {
|
|
10748
|
-
var
|
|
10749
|
-
if (refs.currentPath.toString() === ((
|
|
10883
|
+
var _a223;
|
|
10884
|
+
if (refs.currentPath.toString() === ((_a223 = refs.propertyPath) == null ? void 0 : _a223.toString())) {
|
|
10750
10885
|
return parseDef2(def.innerType._def, refs);
|
|
10751
10886
|
}
|
|
10752
10887
|
const innerSchema = parseDef2(def.innerType._def, {
|
|
@@ -10923,10 +11058,10 @@ var getRelativePath2 = (pathA, pathB) => {
|
|
|
10923
11058
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
10924
11059
|
};
|
|
10925
11060
|
function parseDef2(def, refs, forceResolution = false) {
|
|
10926
|
-
var
|
|
11061
|
+
var _a223;
|
|
10927
11062
|
const seenItem = refs.seen.get(def);
|
|
10928
11063
|
if (refs.override) {
|
|
10929
|
-
const overrideResult = (
|
|
11064
|
+
const overrideResult = (_a223 = refs.override) == null ? void 0 : _a223.call(
|
|
10930
11065
|
refs,
|
|
10931
11066
|
def,
|
|
10932
11067
|
refs,
|
|
@@ -10992,11 +11127,11 @@ var getRefs2 = (options) => {
|
|
|
10992
11127
|
currentPath,
|
|
10993
11128
|
propertyPath: void 0,
|
|
10994
11129
|
seen: new Map(
|
|
10995
|
-
Object.entries(_options.definitions).map(([
|
|
11130
|
+
Object.entries(_options.definitions).map(([name223, def]) => [
|
|
10996
11131
|
def._def,
|
|
10997
11132
|
{
|
|
10998
11133
|
def: def._def,
|
|
10999
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
11134
|
+
path: [..._options.basePath, _options.definitionPath, name223],
|
|
11000
11135
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
11001
11136
|
jsonSchema: void 0
|
|
11002
11137
|
}
|
|
@@ -11005,50 +11140,50 @@ var getRefs2 = (options) => {
|
|
|
11005
11140
|
};
|
|
11006
11141
|
};
|
|
11007
11142
|
var zodToJsonSchema2 = (schema, options) => {
|
|
11008
|
-
var
|
|
11143
|
+
var _a223;
|
|
11009
11144
|
const refs = getRefs2(options);
|
|
11010
11145
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
11011
|
-
(acc, [
|
|
11012
|
-
var
|
|
11146
|
+
(acc, [name323, schema2]) => {
|
|
11147
|
+
var _a323;
|
|
11013
11148
|
return {
|
|
11014
11149
|
...acc,
|
|
11015
|
-
[
|
|
11150
|
+
[name323]: (_a323 = parseDef2(
|
|
11016
11151
|
schema2._def,
|
|
11017
11152
|
{
|
|
11018
11153
|
...refs,
|
|
11019
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
11154
|
+
currentPath: [...refs.basePath, refs.definitionPath, name323]
|
|
11020
11155
|
},
|
|
11021
11156
|
true
|
|
11022
|
-
)) != null ?
|
|
11157
|
+
)) != null ? _a323 : parseAnyDef2()
|
|
11023
11158
|
};
|
|
11024
11159
|
},
|
|
11025
11160
|
{}
|
|
11026
11161
|
) : void 0;
|
|
11027
|
-
const
|
|
11028
|
-
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(
|
|
11029
11164
|
schema._def,
|
|
11030
|
-
|
|
11165
|
+
name223 === void 0 ? refs : {
|
|
11031
11166
|
...refs,
|
|
11032
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
11167
|
+
currentPath: [...refs.basePath, refs.definitionPath, name223]
|
|
11033
11168
|
},
|
|
11034
11169
|
false
|
|
11035
|
-
)) != null ?
|
|
11170
|
+
)) != null ? _a223 : parseAnyDef2();
|
|
11036
11171
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
11037
11172
|
if (title !== void 0) {
|
|
11038
11173
|
main.title = title;
|
|
11039
11174
|
}
|
|
11040
|
-
const combined =
|
|
11175
|
+
const combined = name223 === void 0 ? definitions ? {
|
|
11041
11176
|
...main,
|
|
11042
11177
|
[refs.definitionPath]: definitions
|
|
11043
11178
|
} : main : {
|
|
11044
11179
|
$ref: [
|
|
11045
11180
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
11046
11181
|
refs.definitionPath,
|
|
11047
|
-
|
|
11182
|
+
name223
|
|
11048
11183
|
].join("/"),
|
|
11049
11184
|
[refs.definitionPath]: {
|
|
11050
11185
|
...definitions,
|
|
11051
|
-
[
|
|
11186
|
+
[name223]: main
|
|
11052
11187
|
}
|
|
11053
11188
|
};
|
|
11054
11189
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -11056,8 +11191,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
11056
11191
|
};
|
|
11057
11192
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
11058
11193
|
function zod3Schema(zodSchema22, options) {
|
|
11059
|
-
var
|
|
11060
|
-
const useReferences = (
|
|
11194
|
+
var _a223;
|
|
11195
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
11061
11196
|
return jsonSchema2(
|
|
11062
11197
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
11063
11198
|
() => zod_to_json_schema_default(zodSchema22, {
|
|
@@ -11072,8 +11207,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
11072
11207
|
);
|
|
11073
11208
|
}
|
|
11074
11209
|
function zod4Schema(zodSchema22, options) {
|
|
11075
|
-
var
|
|
11076
|
-
const useReferences = (
|
|
11210
|
+
var _a223;
|
|
11211
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
11077
11212
|
return jsonSchema2(
|
|
11078
11213
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
11079
11214
|
() => addAdditionalPropertiesToJsonSchema(
|
|
@@ -11210,101 +11345,121 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11210
11345
|
});
|
|
11211
11346
|
}
|
|
11212
11347
|
};
|
|
11213
|
-
var name24 = "
|
|
11348
|
+
var name24 = "GatewayForbiddenError";
|
|
11214
11349
|
var marker34 = `vercel.ai.gateway.error.${name24}`;
|
|
11215
11350
|
var symbol34 = Symbol.for(marker34);
|
|
11216
11351
|
var _a34;
|
|
11217
11352
|
var _b32;
|
|
11218
|
-
var
|
|
11353
|
+
var GatewayForbiddenError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
|
|
11219
11354
|
constructor({
|
|
11220
|
-
message = "
|
|
11221
|
-
statusCode =
|
|
11355
|
+
message = "Forbidden",
|
|
11356
|
+
statusCode = 403,
|
|
11222
11357
|
cause
|
|
11223
11358
|
} = {}) {
|
|
11224
11359
|
super({ message, statusCode, cause });
|
|
11225
11360
|
this[_a34] = true;
|
|
11226
11361
|
this.name = name24;
|
|
11227
|
-
this.type = "
|
|
11362
|
+
this.type = "forbidden";
|
|
11228
11363
|
}
|
|
11229
11364
|
static isInstance(error) {
|
|
11230
11365
|
return GatewayError.hasMarker(error) && symbol34 in error;
|
|
11231
11366
|
}
|
|
11232
11367
|
};
|
|
11233
|
-
var name34 = "
|
|
11368
|
+
var name34 = "GatewayInvalidRequestError";
|
|
11234
11369
|
var marker44 = `vercel.ai.gateway.error.${name34}`;
|
|
11235
11370
|
var symbol44 = Symbol.for(marker44);
|
|
11236
11371
|
var _a44;
|
|
11237
11372
|
var _b42;
|
|
11238
|
-
var
|
|
11373
|
+
var GatewayInvalidRequestError = class extends (_b42 = GatewayError, _a44 = symbol44, _b42) {
|
|
11239
11374
|
constructor({
|
|
11240
|
-
message = "
|
|
11241
|
-
statusCode =
|
|
11375
|
+
message = "Invalid request",
|
|
11376
|
+
statusCode = 400,
|
|
11242
11377
|
cause
|
|
11243
11378
|
} = {}) {
|
|
11244
11379
|
super({ message, statusCode, cause });
|
|
11245
11380
|
this[_a44] = true;
|
|
11246
11381
|
this.name = name34;
|
|
11247
|
-
this.type = "
|
|
11382
|
+
this.type = "invalid_request_error";
|
|
11248
11383
|
}
|
|
11249
11384
|
static isInstance(error) {
|
|
11250
11385
|
return GatewayError.hasMarker(error) && symbol44 in error;
|
|
11251
11386
|
}
|
|
11252
11387
|
};
|
|
11253
|
-
var name44 = "
|
|
11388
|
+
var name44 = "GatewayRateLimitError";
|
|
11254
11389
|
var marker54 = `vercel.ai.gateway.error.${name44}`;
|
|
11255
11390
|
var symbol54 = Symbol.for(marker54);
|
|
11256
|
-
var modelNotFoundParamSchema = lazyValidator(
|
|
11257
|
-
() => zodSchema2(
|
|
11258
|
-
z42.z.object({
|
|
11259
|
-
modelId: z42.z.string()
|
|
11260
|
-
})
|
|
11261
|
-
)
|
|
11262
|
-
);
|
|
11263
11391
|
var _a54;
|
|
11264
11392
|
var _b52;
|
|
11265
|
-
var
|
|
11393
|
+
var GatewayRateLimitError = class extends (_b52 = GatewayError, _a54 = symbol54, _b52) {
|
|
11266
11394
|
constructor({
|
|
11267
|
-
message = "
|
|
11268
|
-
statusCode =
|
|
11269
|
-
modelId,
|
|
11395
|
+
message = "Rate limit exceeded",
|
|
11396
|
+
statusCode = 429,
|
|
11270
11397
|
cause
|
|
11271
11398
|
} = {}) {
|
|
11272
11399
|
super({ message, statusCode, cause });
|
|
11273
11400
|
this[_a54] = true;
|
|
11274
11401
|
this.name = name44;
|
|
11275
|
-
this.type = "
|
|
11276
|
-
this.modelId = modelId;
|
|
11402
|
+
this.type = "rate_limit_exceeded";
|
|
11277
11403
|
}
|
|
11278
11404
|
static isInstance(error) {
|
|
11279
11405
|
return GatewayError.hasMarker(error) && symbol54 in error;
|
|
11280
11406
|
}
|
|
11281
11407
|
};
|
|
11282
|
-
var name54 = "
|
|
11408
|
+
var name54 = "GatewayModelNotFoundError";
|
|
11283
11409
|
var marker64 = `vercel.ai.gateway.error.${name54}`;
|
|
11284
11410
|
var symbol64 = Symbol.for(marker64);
|
|
11411
|
+
var modelNotFoundParamSchema = lazyValidator(
|
|
11412
|
+
() => zodSchema2(
|
|
11413
|
+
z42.z.object({
|
|
11414
|
+
modelId: z42.z.string()
|
|
11415
|
+
})
|
|
11416
|
+
)
|
|
11417
|
+
);
|
|
11285
11418
|
var _a64;
|
|
11286
11419
|
var _b62;
|
|
11287
|
-
var
|
|
11420
|
+
var GatewayModelNotFoundError = class extends (_b62 = GatewayError, _a64 = symbol64, _b62) {
|
|
11288
11421
|
constructor({
|
|
11289
|
-
message = "
|
|
11290
|
-
statusCode =
|
|
11422
|
+
message = "Model not found",
|
|
11423
|
+
statusCode = 404,
|
|
11424
|
+
modelId,
|
|
11291
11425
|
cause
|
|
11292
11426
|
} = {}) {
|
|
11293
11427
|
super({ message, statusCode, cause });
|
|
11294
11428
|
this[_a64] = true;
|
|
11295
11429
|
this.name = name54;
|
|
11296
|
-
this.type = "
|
|
11430
|
+
this.type = "model_not_found";
|
|
11431
|
+
this.modelId = modelId;
|
|
11297
11432
|
}
|
|
11298
11433
|
static isInstance(error) {
|
|
11299
11434
|
return GatewayError.hasMarker(error) && symbol64 in error;
|
|
11300
11435
|
}
|
|
11301
11436
|
};
|
|
11302
|
-
var name64 = "
|
|
11437
|
+
var name64 = "GatewayInternalServerError";
|
|
11303
11438
|
var marker74 = `vercel.ai.gateway.error.${name64}`;
|
|
11304
11439
|
var symbol74 = Symbol.for(marker74);
|
|
11305
11440
|
var _a74;
|
|
11306
11441
|
var _b72;
|
|
11307
|
-
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) {
|
|
11308
11463
|
constructor({
|
|
11309
11464
|
message = "Invalid response from Gateway",
|
|
11310
11465
|
statusCode = 502,
|
|
@@ -11313,14 +11468,14 @@ var GatewayResponseError = class extends (_b72 = GatewayError, _a74 = symbol74,
|
|
|
11313
11468
|
cause
|
|
11314
11469
|
} = {}) {
|
|
11315
11470
|
super({ message, statusCode, cause });
|
|
11316
|
-
this[
|
|
11317
|
-
this.name =
|
|
11471
|
+
this[_a84] = true;
|
|
11472
|
+
this.name = name74;
|
|
11318
11473
|
this.type = "response_error";
|
|
11319
11474
|
this.response = response;
|
|
11320
11475
|
this.validationError = validationError;
|
|
11321
11476
|
}
|
|
11322
11477
|
static isInstance(error) {
|
|
11323
|
-
return GatewayError.hasMarker(error) &&
|
|
11478
|
+
return GatewayError.hasMarker(error) && symbol84 in error;
|
|
11324
11479
|
}
|
|
11325
11480
|
};
|
|
11326
11481
|
async function createGatewayErrorFromResponse({
|
|
@@ -11372,6 +11527,8 @@ async function createGatewayErrorFromResponse({
|
|
|
11372
11527
|
}
|
|
11373
11528
|
case "internal_server_error":
|
|
11374
11529
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
11530
|
+
case "forbidden":
|
|
11531
|
+
return new GatewayForbiddenError({ message, statusCode, cause });
|
|
11375
11532
|
default:
|
|
11376
11533
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
11377
11534
|
}
|
|
@@ -11401,24 +11558,24 @@ function extractApiCallResponse(error) {
|
|
|
11401
11558
|
}
|
|
11402
11559
|
return {};
|
|
11403
11560
|
}
|
|
11404
|
-
var
|
|
11405
|
-
var
|
|
11406
|
-
var
|
|
11407
|
-
var
|
|
11408
|
-
var
|
|
11409
|
-
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) {
|
|
11410
11567
|
constructor({
|
|
11411
11568
|
message = "Request timed out",
|
|
11412
11569
|
statusCode = 408,
|
|
11413
11570
|
cause
|
|
11414
11571
|
} = {}) {
|
|
11415
11572
|
super({ message, statusCode, cause });
|
|
11416
|
-
this[
|
|
11417
|
-
this.name =
|
|
11573
|
+
this[_a94] = true;
|
|
11574
|
+
this.name = name84;
|
|
11418
11575
|
this.type = "timeout_error";
|
|
11419
11576
|
}
|
|
11420
11577
|
static isInstance(error) {
|
|
11421
|
-
return GatewayError.hasMarker(error) &&
|
|
11578
|
+
return GatewayError.hasMarker(error) && symbol94 in error;
|
|
11422
11579
|
}
|
|
11423
11580
|
/**
|
|
11424
11581
|
* Creates a helpful timeout error message with troubleshooting guidance
|
|
@@ -11454,7 +11611,7 @@ function isTimeoutError(error) {
|
|
|
11454
11611
|
return false;
|
|
11455
11612
|
}
|
|
11456
11613
|
async function asGatewayError(error, authMethod) {
|
|
11457
|
-
var
|
|
11614
|
+
var _a1032;
|
|
11458
11615
|
if (GatewayError.isInstance(error)) {
|
|
11459
11616
|
return error;
|
|
11460
11617
|
}
|
|
@@ -11473,7 +11630,7 @@ async function asGatewayError(error, authMethod) {
|
|
|
11473
11630
|
}
|
|
11474
11631
|
return await createGatewayErrorFromResponse({
|
|
11475
11632
|
response: extractApiCallResponse(error),
|
|
11476
|
-
statusCode: (
|
|
11633
|
+
statusCode: (_a1032 = error.statusCode) != null ? _a1032 : 500,
|
|
11477
11634
|
defaultMessage: "Gateway request failed",
|
|
11478
11635
|
cause: error,
|
|
11479
11636
|
authMethod
|
|
@@ -11933,7 +12090,7 @@ var GatewayEmbeddingModel = class {
|
|
|
11933
12090
|
abortSignal,
|
|
11934
12091
|
providerOptions
|
|
11935
12092
|
}) {
|
|
11936
|
-
var
|
|
12093
|
+
var _a1032;
|
|
11937
12094
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
11938
12095
|
try {
|
|
11939
12096
|
const {
|
|
@@ -11964,7 +12121,7 @@ var GatewayEmbeddingModel = class {
|
|
|
11964
12121
|
});
|
|
11965
12122
|
return {
|
|
11966
12123
|
embeddings: responseBody.embeddings,
|
|
11967
|
-
usage: (
|
|
12124
|
+
usage: (_a1032 = responseBody.usage) != null ? _a1032 : void 0,
|
|
11968
12125
|
providerMetadata: responseBody.providerMetadata,
|
|
11969
12126
|
response: { headers: responseHeaders, body: rawValue }
|
|
11970
12127
|
};
|
|
@@ -12011,7 +12168,7 @@ var GatewayImageModel = class {
|
|
|
12011
12168
|
headers,
|
|
12012
12169
|
abortSignal
|
|
12013
12170
|
}) {
|
|
12014
|
-
var
|
|
12171
|
+
var _a1032, _b104, _c, _d;
|
|
12015
12172
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
12016
12173
|
try {
|
|
12017
12174
|
const {
|
|
@@ -12046,7 +12203,7 @@ var GatewayImageModel = class {
|
|
|
12046
12203
|
return {
|
|
12047
12204
|
images: responseBody.images,
|
|
12048
12205
|
// Always base64 strings from server
|
|
12049
|
-
warnings: (
|
|
12206
|
+
warnings: (_a1032 = responseBody.warnings) != null ? _a1032 : [],
|
|
12050
12207
|
providerMetadata: responseBody.providerMetadata,
|
|
12051
12208
|
response: {
|
|
12052
12209
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -12055,7 +12212,7 @@ var GatewayImageModel = class {
|
|
|
12055
12212
|
},
|
|
12056
12213
|
...responseBody.usage != null && {
|
|
12057
12214
|
usage: {
|
|
12058
|
-
inputTokens: (
|
|
12215
|
+
inputTokens: (_b104 = responseBody.usage.inputTokens) != null ? _b104 : void 0,
|
|
12059
12216
|
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
|
|
12060
12217
|
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
|
|
12061
12218
|
}
|
|
@@ -12270,18 +12427,18 @@ var gatewayTools = {
|
|
|
12270
12427
|
perplexitySearch
|
|
12271
12428
|
};
|
|
12272
12429
|
async function getVercelRequestId() {
|
|
12273
|
-
var
|
|
12274
|
-
return (
|
|
12430
|
+
var _a1032;
|
|
12431
|
+
return (_a1032 = getContext().headers) == null ? void 0 : _a1032["x-vercel-id"];
|
|
12275
12432
|
}
|
|
12276
|
-
var VERSION3 = "2.0.
|
|
12433
|
+
var VERSION3 = "2.0.109";
|
|
12277
12434
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
12278
12435
|
function createGatewayProvider(options = {}) {
|
|
12279
|
-
var
|
|
12436
|
+
var _a1032, _b104;
|
|
12280
12437
|
let pendingMetadata = null;
|
|
12281
12438
|
let metadataCache = null;
|
|
12282
|
-
const cacheRefreshMillis = (
|
|
12439
|
+
const cacheRefreshMillis = (_a1032 = options.metadataCacheRefreshMillis) != null ? _a1032 : 1e3 * 60 * 5;
|
|
12283
12440
|
let lastFetchTime = 0;
|
|
12284
|
-
const baseURL = (
|
|
12441
|
+
const baseURL = (_b104 = withoutTrailingSlash(options.baseURL)) != null ? _b104 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
12285
12442
|
const getHeaders = async () => {
|
|
12286
12443
|
const auth = await getGatewayAuthToken(options);
|
|
12287
12444
|
if (auth) {
|
|
@@ -12339,8 +12496,8 @@ function createGatewayProvider(options = {}) {
|
|
|
12339
12496
|
});
|
|
12340
12497
|
};
|
|
12341
12498
|
const getAvailableModels = async () => {
|
|
12342
|
-
var
|
|
12343
|
-
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();
|
|
12344
12501
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
12345
12502
|
lastFetchTime = now2;
|
|
12346
12503
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -12544,12 +12701,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
|
|
|
12544
12701
|
return true;
|
|
12545
12702
|
}
|
|
12546
12703
|
function getGlobal2(type) {
|
|
12547
|
-
var _a163,
|
|
12704
|
+
var _a163, _b104;
|
|
12548
12705
|
var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
|
|
12549
12706
|
if (!globalVersion || !isCompatible2(globalVersion)) {
|
|
12550
12707
|
return;
|
|
12551
12708
|
}
|
|
12552
|
-
return (
|
|
12709
|
+
return (_b104 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b104 === void 0 ? void 0 : _b104[type];
|
|
12553
12710
|
}
|
|
12554
12711
|
function unregisterGlobal2(type, diag) {
|
|
12555
12712
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
|
|
@@ -12712,15 +12869,15 @@ var DiagAPI2 = (
|
|
|
12712
12869
|
return logger[funcName].apply(logger, __spreadArray22([], __read22(args), false));
|
|
12713
12870
|
};
|
|
12714
12871
|
}
|
|
12715
|
-
var
|
|
12872
|
+
var self2 = this;
|
|
12716
12873
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
12717
|
-
var _a163,
|
|
12874
|
+
var _a163, _b104, _c;
|
|
12718
12875
|
if (optionsOrLogLevel === void 0) {
|
|
12719
12876
|
optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
|
|
12720
12877
|
}
|
|
12721
|
-
if (logger ===
|
|
12878
|
+
if (logger === self2) {
|
|
12722
12879
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
12723
|
-
|
|
12880
|
+
self2.error((_a163 = err.stack) !== null && _a163 !== void 0 ? _a163 : err.message);
|
|
12724
12881
|
return false;
|
|
12725
12882
|
}
|
|
12726
12883
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -12729,26 +12886,26 @@ var DiagAPI2 = (
|
|
|
12729
12886
|
};
|
|
12730
12887
|
}
|
|
12731
12888
|
var oldLogger = getGlobal2("diag");
|
|
12732
|
-
var newLogger = createLogLevelDiagLogger2((
|
|
12889
|
+
var newLogger = createLogLevelDiagLogger2((_b104 = optionsOrLogLevel.logLevel) !== null && _b104 !== void 0 ? _b104 : DiagLogLevel2.INFO, logger);
|
|
12733
12890
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
12734
12891
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
12735
12892
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
12736
12893
|
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
12737
12894
|
}
|
|
12738
|
-
return registerGlobal2("diag", newLogger,
|
|
12895
|
+
return registerGlobal2("diag", newLogger, self2, true);
|
|
12739
12896
|
};
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
unregisterGlobal2(API_NAME4,
|
|
12897
|
+
self2.setLogger = setLogger;
|
|
12898
|
+
self2.disable = function() {
|
|
12899
|
+
unregisterGlobal2(API_NAME4, self2);
|
|
12743
12900
|
};
|
|
12744
|
-
|
|
12901
|
+
self2.createComponentLogger = function(options) {
|
|
12745
12902
|
return new DiagComponentLogger2(options);
|
|
12746
12903
|
};
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
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");
|
|
12752
12909
|
}
|
|
12753
12910
|
DiagAPI22.instance = function() {
|
|
12754
12911
|
if (!this._instance) {
|
|
@@ -12766,18 +12923,18 @@ var BaseContext2 = (
|
|
|
12766
12923
|
/** @class */
|
|
12767
12924
|
/* @__PURE__ */ (function() {
|
|
12768
12925
|
function BaseContext22(parentContext) {
|
|
12769
|
-
var
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
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);
|
|
12773
12930
|
};
|
|
12774
|
-
|
|
12775
|
-
var context2 = new BaseContext22(
|
|
12931
|
+
self2.setValue = function(key, value) {
|
|
12932
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
12776
12933
|
context2._currentContext.set(key, value);
|
|
12777
12934
|
return context2;
|
|
12778
12935
|
};
|
|
12779
|
-
|
|
12780
|
-
var context2 = new BaseContext22(
|
|
12936
|
+
self2.deleteValue = function(key) {
|
|
12937
|
+
var context2 = new BaseContext22(self2._currentContext);
|
|
12781
12938
|
context2._currentContext.delete(key);
|
|
12782
12939
|
return context2;
|
|
12783
12940
|
};
|
|
@@ -13260,7 +13417,7 @@ function getGlobalProvider() {
|
|
|
13260
13417
|
var _a163;
|
|
13261
13418
|
return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
|
|
13262
13419
|
}
|
|
13263
|
-
var VERSION32 = "5.0.
|
|
13420
|
+
var VERSION32 = "5.0.210";
|
|
13264
13421
|
var dataContentSchema2 = z42.z.union([
|
|
13265
13422
|
z42.z.string(),
|
|
13266
13423
|
z42.z.instanceof(Uint8Array),
|
|
@@ -13268,8 +13425,8 @@ var dataContentSchema2 = z42.z.union([
|
|
|
13268
13425
|
z42.z.custom(
|
|
13269
13426
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
13270
13427
|
(value) => {
|
|
13271
|
-
var _a163,
|
|
13272
|
-
return (
|
|
13428
|
+
var _a163, _b104;
|
|
13429
|
+
return (_b104 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b104 : false;
|
|
13273
13430
|
},
|
|
13274
13431
|
{ message: "Must be a Buffer" }
|
|
13275
13432
|
)
|
|
@@ -14793,6 +14950,90 @@ function convertUint8ArrayToBase643(array2) {
|
|
|
14793
14950
|
}
|
|
14794
14951
|
return btoa3(latin1string);
|
|
14795
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
|
+
}
|
|
14796
15037
|
var createIdGenerator3 = ({
|
|
14797
15038
|
prefix,
|
|
14798
15039
|
size = 16,
|
|
@@ -14888,11 +15129,11 @@ function handleFetchError2({
|
|
|
14888
15129
|
return error;
|
|
14889
15130
|
}
|
|
14890
15131
|
function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
|
|
14891
|
-
var
|
|
15132
|
+
var _a223, _b222, _c;
|
|
14892
15133
|
if (globalThisAny.window) {
|
|
14893
15134
|
return `runtime/browser`;
|
|
14894
15135
|
}
|
|
14895
|
-
if ((
|
|
15136
|
+
if ((_a223 = globalThisAny.navigator) == null ? void 0 : _a223.userAgent) {
|
|
14896
15137
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
14897
15138
|
}
|
|
14898
15139
|
if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
|
|
@@ -14933,7 +15174,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
14933
15174
|
);
|
|
14934
15175
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
14935
15176
|
}
|
|
14936
|
-
var VERSION4 = "4.0.
|
|
15177
|
+
var VERSION4 = "4.0.38";
|
|
14937
15178
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
14938
15179
|
var getFromApi2 = async ({
|
|
14939
15180
|
url,
|
|
@@ -15134,11 +15375,11 @@ function parseAnyDef3() {
|
|
|
15134
15375
|
return {};
|
|
15135
15376
|
}
|
|
15136
15377
|
function parseArrayDef3(def, refs) {
|
|
15137
|
-
var
|
|
15378
|
+
var _a223, _b222, _c;
|
|
15138
15379
|
const res = {
|
|
15139
15380
|
type: "array"
|
|
15140
15381
|
};
|
|
15141
|
-
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) {
|
|
15142
15383
|
res.items = parseDef3(def.type._def, {
|
|
15143
15384
|
...refs,
|
|
15144
15385
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -15497,8 +15738,8 @@ function escapeNonAlphaNumeric3(source) {
|
|
|
15497
15738
|
return result;
|
|
15498
15739
|
}
|
|
15499
15740
|
function addFormat3(schema, value, message, refs) {
|
|
15500
|
-
var
|
|
15501
|
-
if (schema.format || ((
|
|
15741
|
+
var _a223;
|
|
15742
|
+
if (schema.format || ((_a223 = schema.anyOf) == null ? void 0 : _a223.some((x) => x.format))) {
|
|
15502
15743
|
if (!schema.anyOf) {
|
|
15503
15744
|
schema.anyOf = [];
|
|
15504
15745
|
}
|
|
@@ -15517,8 +15758,8 @@ function addFormat3(schema, value, message, refs) {
|
|
|
15517
15758
|
}
|
|
15518
15759
|
}
|
|
15519
15760
|
function addPattern3(schema, regex, message, refs) {
|
|
15520
|
-
var
|
|
15521
|
-
if (schema.pattern || ((
|
|
15761
|
+
var _a223;
|
|
15762
|
+
if (schema.pattern || ((_a223 = schema.allOf) == null ? void 0 : _a223.some((x) => x.pattern))) {
|
|
15522
15763
|
if (!schema.allOf) {
|
|
15523
15764
|
schema.allOf = [];
|
|
15524
15765
|
}
|
|
@@ -15537,7 +15778,7 @@ function addPattern3(schema, regex, message, refs) {
|
|
|
15537
15778
|
}
|
|
15538
15779
|
}
|
|
15539
15780
|
function stringifyRegExpWithFlags3(regex, refs) {
|
|
15540
|
-
var
|
|
15781
|
+
var _a223;
|
|
15541
15782
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
15542
15783
|
return regex.source;
|
|
15543
15784
|
}
|
|
@@ -15567,7 +15808,7 @@ function stringifyRegExpWithFlags3(regex, refs) {
|
|
|
15567
15808
|
pattern += source[i];
|
|
15568
15809
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
15569
15810
|
inCharRange = false;
|
|
15570
|
-
} else if (source[i + 1] === "-" && ((
|
|
15811
|
+
} else if (source[i + 1] === "-" && ((_a223 = source[i + 2]) == null ? void 0 : _a223.match(/[a-z]/))) {
|
|
15571
15812
|
pattern += source[i];
|
|
15572
15813
|
inCharRange = true;
|
|
15573
15814
|
} else {
|
|
@@ -15609,13 +15850,13 @@ function stringifyRegExpWithFlags3(regex, refs) {
|
|
|
15609
15850
|
return pattern;
|
|
15610
15851
|
}
|
|
15611
15852
|
function parseRecordDef3(def, refs) {
|
|
15612
|
-
var
|
|
15853
|
+
var _a223, _b222, _c, _d, _e, _f;
|
|
15613
15854
|
const schema = {
|
|
15614
15855
|
type: "object",
|
|
15615
|
-
additionalProperties: (
|
|
15856
|
+
additionalProperties: (_a223 = parseDef3(def.valueType._def, {
|
|
15616
15857
|
...refs,
|
|
15617
15858
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
15618
|
-
})) != null ?
|
|
15859
|
+
})) != null ? _a223 : refs.allowedAdditionalProperties
|
|
15619
15860
|
};
|
|
15620
15861
|
if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
15621
15862
|
const { type, ...keyType } = parseStringDef3(def.keyType._def, refs);
|
|
@@ -15872,8 +16113,8 @@ function safeIsOptional3(schema) {
|
|
|
15872
16113
|
}
|
|
15873
16114
|
}
|
|
15874
16115
|
var parseOptionalDef3 = (def, refs) => {
|
|
15875
|
-
var
|
|
15876
|
-
if (refs.currentPath.toString() === ((
|
|
16116
|
+
var _a223;
|
|
16117
|
+
if (refs.currentPath.toString() === ((_a223 = refs.propertyPath) == null ? void 0 : _a223.toString())) {
|
|
15877
16118
|
return parseDef3(def.innerType._def, refs);
|
|
15878
16119
|
}
|
|
15879
16120
|
const innerSchema = parseDef3(def.innerType._def, {
|
|
@@ -16050,10 +16291,10 @@ var getRelativePath3 = (pathA, pathB) => {
|
|
|
16050
16291
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
16051
16292
|
};
|
|
16052
16293
|
function parseDef3(def, refs, forceResolution = false) {
|
|
16053
|
-
var
|
|
16294
|
+
var _a223;
|
|
16054
16295
|
const seenItem = refs.seen.get(def);
|
|
16055
16296
|
if (refs.override) {
|
|
16056
|
-
const overrideResult = (
|
|
16297
|
+
const overrideResult = (_a223 = refs.override) == null ? void 0 : _a223.call(
|
|
16057
16298
|
refs,
|
|
16058
16299
|
def,
|
|
16059
16300
|
refs,
|
|
@@ -16119,11 +16360,11 @@ var getRefs3 = (options) => {
|
|
|
16119
16360
|
currentPath,
|
|
16120
16361
|
propertyPath: void 0,
|
|
16121
16362
|
seen: new Map(
|
|
16122
|
-
Object.entries(_options.definitions).map(([
|
|
16363
|
+
Object.entries(_options.definitions).map(([name223, def]) => [
|
|
16123
16364
|
def._def,
|
|
16124
16365
|
{
|
|
16125
16366
|
def: def._def,
|
|
16126
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
16367
|
+
path: [..._options.basePath, _options.definitionPath, name223],
|
|
16127
16368
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
16128
16369
|
jsonSchema: void 0
|
|
16129
16370
|
}
|
|
@@ -16132,50 +16373,50 @@ var getRefs3 = (options) => {
|
|
|
16132
16373
|
};
|
|
16133
16374
|
};
|
|
16134
16375
|
var zod3ToJsonSchema = (schema, options) => {
|
|
16135
|
-
var
|
|
16376
|
+
var _a223;
|
|
16136
16377
|
const refs = getRefs3(options);
|
|
16137
16378
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
16138
|
-
(acc, [
|
|
16139
|
-
var
|
|
16379
|
+
(acc, [name323, schema2]) => {
|
|
16380
|
+
var _a323;
|
|
16140
16381
|
return {
|
|
16141
16382
|
...acc,
|
|
16142
|
-
[
|
|
16383
|
+
[name323]: (_a323 = parseDef3(
|
|
16143
16384
|
schema2._def,
|
|
16144
16385
|
{
|
|
16145
16386
|
...refs,
|
|
16146
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
16387
|
+
currentPath: [...refs.basePath, refs.definitionPath, name323]
|
|
16147
16388
|
},
|
|
16148
16389
|
true
|
|
16149
|
-
)) != null ?
|
|
16390
|
+
)) != null ? _a323 : parseAnyDef3()
|
|
16150
16391
|
};
|
|
16151
16392
|
},
|
|
16152
16393
|
{}
|
|
16153
16394
|
) : void 0;
|
|
16154
|
-
const
|
|
16155
|
-
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(
|
|
16156
16397
|
schema._def,
|
|
16157
|
-
|
|
16398
|
+
name223 === void 0 ? refs : {
|
|
16158
16399
|
...refs,
|
|
16159
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
16400
|
+
currentPath: [...refs.basePath, refs.definitionPath, name223]
|
|
16160
16401
|
},
|
|
16161
16402
|
false
|
|
16162
|
-
)) != null ?
|
|
16403
|
+
)) != null ? _a223 : parseAnyDef3();
|
|
16163
16404
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
16164
16405
|
if (title !== void 0) {
|
|
16165
16406
|
main.title = title;
|
|
16166
16407
|
}
|
|
16167
|
-
const combined =
|
|
16408
|
+
const combined = name223 === void 0 ? definitions ? {
|
|
16168
16409
|
...main,
|
|
16169
16410
|
[refs.definitionPath]: definitions
|
|
16170
16411
|
} : main : {
|
|
16171
16412
|
$ref: [
|
|
16172
16413
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
16173
16414
|
refs.definitionPath,
|
|
16174
|
-
|
|
16415
|
+
name223
|
|
16175
16416
|
].join("/"),
|
|
16176
16417
|
[refs.definitionPath]: {
|
|
16177
16418
|
...definitions,
|
|
16178
|
-
[
|
|
16419
|
+
[name223]: main
|
|
16179
16420
|
}
|
|
16180
16421
|
};
|
|
16181
16422
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -16211,7 +16452,11 @@ function isSchema3(value) {
|
|
|
16211
16452
|
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
16212
16453
|
}
|
|
16213
16454
|
function asSchema3(schema) {
|
|
16214
|
-
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();
|
|
16215
16460
|
}
|
|
16216
16461
|
function standardSchema(standardSchema2) {
|
|
16217
16462
|
return jsonSchema3(
|
|
@@ -16235,8 +16480,8 @@ function standardSchema(standardSchema2) {
|
|
|
16235
16480
|
);
|
|
16236
16481
|
}
|
|
16237
16482
|
function zod3Schema2(zodSchema22, options) {
|
|
16238
|
-
var
|
|
16239
|
-
const useReferences = (
|
|
16483
|
+
var _a223;
|
|
16484
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
16240
16485
|
return jsonSchema3(
|
|
16241
16486
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
16242
16487
|
() => zod3ToJsonSchema(zodSchema22, {
|
|
@@ -16251,8 +16496,8 @@ function zod3Schema2(zodSchema22, options) {
|
|
|
16251
16496
|
);
|
|
16252
16497
|
}
|
|
16253
16498
|
function zod4Schema2(zodSchema22, options) {
|
|
16254
|
-
var
|
|
16255
|
-
const useReferences = (
|
|
16499
|
+
var _a223;
|
|
16500
|
+
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
16256
16501
|
return jsonSchema3(
|
|
16257
16502
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
16258
16503
|
() => addAdditionalPropertiesToJsonSchema2(
|
|
@@ -16499,12 +16744,101 @@ async function resolve2(value) {
|
|
|
16499
16744
|
}
|
|
16500
16745
|
return Promise.resolve(value);
|
|
16501
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
|
+
}
|
|
16502
16836
|
var createJsonErrorResponseHandler2 = ({
|
|
16503
16837
|
errorSchema,
|
|
16504
16838
|
errorToMessage,
|
|
16505
16839
|
isRetryable
|
|
16506
16840
|
}) => async ({ response, url, requestBodyValues }) => {
|
|
16507
|
-
const responseBody = await response
|
|
16841
|
+
const responseBody = await readResponseBodyAsText2({ response, url });
|
|
16508
16842
|
const responseHeaders = extractResponseHeaders2(response);
|
|
16509
16843
|
if (responseBody.trim() === "") {
|
|
16510
16844
|
return {
|
|
@@ -16567,7 +16901,7 @@ var createEventSourceResponseHandler2 = (chunkSchema) => async ({ response }) =>
|
|
|
16567
16901
|
};
|
|
16568
16902
|
};
|
|
16569
16903
|
var createJsonResponseHandler2 = (responseSchema) => async ({ response, url, requestBodyValues }) => {
|
|
16570
|
-
const responseBody = await response
|
|
16904
|
+
const responseBody = await readResponseBodyAsText2({ response, url });
|
|
16571
16905
|
const parsedResult = await safeParseJSON3({
|
|
16572
16906
|
text: responseBody,
|
|
16573
16907
|
schema: responseSchema
|
|
@@ -16613,13 +16947,19 @@ var GatewayError2 = class _GatewayError2 extends (_b18 = Error, _a20 = symbol20,
|
|
|
16613
16947
|
message,
|
|
16614
16948
|
statusCode = 500,
|
|
16615
16949
|
cause,
|
|
16616
|
-
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
|
|
16617
16956
|
}) {
|
|
16618
16957
|
super(generationId ? `${message} [${generationId}]` : message);
|
|
16619
16958
|
this[_a20] = true;
|
|
16620
16959
|
this.statusCode = statusCode;
|
|
16621
16960
|
this.cause = cause;
|
|
16622
16961
|
this.generationId = generationId;
|
|
16962
|
+
this.isRetryable = isRetryable;
|
|
16623
16963
|
}
|
|
16624
16964
|
/**
|
|
16625
16965
|
* Checks if the given error is a Gateway Error.
|
|
@@ -16788,41 +17128,92 @@ var GatewayInternalServerError2 = class extends (_b64 = GatewayError2, _a66 = sy
|
|
|
16788
17128
|
return GatewayError2.hasMarker(error) && symbol66 in error;
|
|
16789
17129
|
}
|
|
16790
17130
|
};
|
|
16791
|
-
var name66 = "
|
|
17131
|
+
var name66 = "GatewayFailedDependencyError";
|
|
16792
17132
|
var marker76 = `vercel.ai.gateway.error.${name66}`;
|
|
16793
17133
|
var symbol76 = Symbol.for(marker76);
|
|
16794
17134
|
var _a76;
|
|
16795
17135
|
var _b74;
|
|
16796
|
-
var
|
|
17136
|
+
var GatewayFailedDependencyError = class extends (_b74 = GatewayError2, _a76 = symbol76, _b74) {
|
|
16797
17137
|
constructor({
|
|
16798
|
-
message = "
|
|
16799
|
-
statusCode =
|
|
16800
|
-
response,
|
|
16801
|
-
validationError,
|
|
17138
|
+
message = "Failed dependency",
|
|
17139
|
+
statusCode = 424,
|
|
16802
17140
|
cause,
|
|
16803
17141
|
generationId
|
|
16804
17142
|
} = {}) {
|
|
16805
17143
|
super({ message, statusCode, cause, generationId });
|
|
16806
17144
|
this[_a76] = true;
|
|
16807
17145
|
this.name = name66;
|
|
16808
|
-
this.type = "
|
|
16809
|
-
this.response = response;
|
|
16810
|
-
this.validationError = validationError;
|
|
17146
|
+
this.type = "failed_dependency";
|
|
16811
17147
|
}
|
|
16812
17148
|
static isInstance(error) {
|
|
16813
17149
|
return GatewayError2.hasMarker(error) && symbol76 in error;
|
|
16814
17150
|
}
|
|
16815
17151
|
};
|
|
16816
|
-
|
|
16817
|
-
|
|
16818
|
-
|
|
16819
|
-
|
|
16820
|
-
|
|
16821
|
-
|
|
16822
|
-
|
|
16823
|
-
|
|
16824
|
-
|
|
16825
|
-
|
|
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,
|
|
16826
17217
|
schema: gatewayErrorResponseSchema2
|
|
16827
17218
|
});
|
|
16828
17219
|
if (!parseResult.success) {
|
|
@@ -16839,7 +17230,7 @@ async function createGatewayErrorFromResponse2({
|
|
|
16839
17230
|
const validatedResponse = parseResult.value;
|
|
16840
17231
|
const errorType = validatedResponse.error.type;
|
|
16841
17232
|
const message = validatedResponse.error.message;
|
|
16842
|
-
const generationId = (
|
|
17233
|
+
const generationId = (_a117 = validatedResponse.generationId) != null ? _a117 : void 0;
|
|
16843
17234
|
switch (errorType) {
|
|
16844
17235
|
case "authentication_error":
|
|
16845
17236
|
return GatewayAuthenticationError2.createContextualError({
|
|
@@ -16883,6 +17274,26 @@ async function createGatewayErrorFromResponse2({
|
|
|
16883
17274
|
cause,
|
|
16884
17275
|
generationId
|
|
16885
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
|
+
}
|
|
16886
17297
|
default:
|
|
16887
17298
|
return new GatewayInternalServerError2({
|
|
16888
17299
|
message,
|
|
@@ -16911,19 +17322,19 @@ function extractApiCallResponse2(error) {
|
|
|
16911
17322
|
}
|
|
16912
17323
|
if (error.responseBody != null) {
|
|
16913
17324
|
try {
|
|
16914
|
-
return
|
|
17325
|
+
return secureJsonParse2(error.responseBody);
|
|
16915
17326
|
} catch (e) {
|
|
16916
17327
|
return error.responseBody;
|
|
16917
17328
|
}
|
|
16918
17329
|
}
|
|
16919
17330
|
return {};
|
|
16920
17331
|
}
|
|
16921
|
-
var
|
|
16922
|
-
var
|
|
16923
|
-
var
|
|
16924
|
-
var
|
|
16925
|
-
var
|
|
16926
|
-
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) {
|
|
16927
17338
|
constructor({
|
|
16928
17339
|
message = "Request timed out",
|
|
16929
17340
|
statusCode = 408,
|
|
@@ -16931,12 +17342,12 @@ var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (_b84 = GatewayEr
|
|
|
16931
17342
|
generationId
|
|
16932
17343
|
} = {}) {
|
|
16933
17344
|
super({ message, statusCode, cause, generationId });
|
|
16934
|
-
this[
|
|
16935
|
-
this.name =
|
|
17345
|
+
this[_a106] = true;
|
|
17346
|
+
this.name = name96;
|
|
16936
17347
|
this.type = "timeout_error";
|
|
16937
17348
|
}
|
|
16938
17349
|
static isInstance(error) {
|
|
16939
|
-
return GatewayError2.hasMarker(error) &&
|
|
17350
|
+
return GatewayError2.hasMarker(error) && symbol106 in error;
|
|
16940
17351
|
}
|
|
16941
17352
|
/**
|
|
16942
17353
|
* Creates a helpful timeout error message with troubleshooting guidance
|
|
@@ -16974,7 +17385,7 @@ function isTimeoutError2(error) {
|
|
|
16974
17385
|
return false;
|
|
16975
17386
|
}
|
|
16976
17387
|
async function asGatewayError2(error, authMethod) {
|
|
16977
|
-
var
|
|
17388
|
+
var _a117;
|
|
16978
17389
|
if (GatewayError2.isInstance(error)) {
|
|
16979
17390
|
return error;
|
|
16980
17391
|
}
|
|
@@ -16993,7 +17404,7 @@ async function asGatewayError2(error, authMethod) {
|
|
|
16993
17404
|
}
|
|
16994
17405
|
return await createGatewayErrorFromResponse2({
|
|
16995
17406
|
response: extractApiCallResponse2(error),
|
|
16996
|
-
statusCode: (
|
|
17407
|
+
statusCode: (_a117 = error.statusCode) != null ? _a117 : 500,
|
|
16997
17408
|
defaultMessage: "Gateway request failed",
|
|
16998
17409
|
cause: error,
|
|
16999
17410
|
authMethod
|
|
@@ -17023,6 +17434,8 @@ var KNOWN_MODEL_TYPES2 = [
|
|
|
17023
17434
|
"image",
|
|
17024
17435
|
"language",
|
|
17025
17436
|
"reranking",
|
|
17437
|
+
"speech",
|
|
17438
|
+
"transcription",
|
|
17026
17439
|
"video"
|
|
17027
17440
|
];
|
|
17028
17441
|
var GatewayFetchMetadata2 = class {
|
|
@@ -17459,7 +17872,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
17459
17872
|
abortSignal,
|
|
17460
17873
|
providerOptions
|
|
17461
17874
|
}) {
|
|
17462
|
-
var
|
|
17875
|
+
var _a117, _b113;
|
|
17463
17876
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17464
17877
|
try {
|
|
17465
17878
|
const {
|
|
@@ -17490,10 +17903,10 @@ var GatewayEmbeddingModel2 = class {
|
|
|
17490
17903
|
});
|
|
17491
17904
|
return {
|
|
17492
17905
|
embeddings: responseBody.embeddings,
|
|
17493
|
-
usage: (
|
|
17906
|
+
usage: (_a117 = responseBody.usage) != null ? _a117 : void 0,
|
|
17494
17907
|
providerMetadata: responseBody.providerMetadata,
|
|
17495
17908
|
response: { headers: responseHeaders, body: rawValue },
|
|
17496
|
-
warnings: []
|
|
17909
|
+
warnings: (_b113 = responseBody.warnings) != null ? _b113 : []
|
|
17497
17910
|
};
|
|
17498
17911
|
} catch (error) {
|
|
17499
17912
|
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
@@ -17509,15 +17922,37 @@ var GatewayEmbeddingModel2 = class {
|
|
|
17509
17922
|
};
|
|
17510
17923
|
}
|
|
17511
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
|
+
]);
|
|
17512
17941
|
var gatewayEmbeddingResponseSchema2 = lazySchema2(
|
|
17513
17942
|
() => zodSchema3(
|
|
17514
17943
|
z42.z.object({
|
|
17515
17944
|
embeddings: z42.z.array(z42.z.array(z42.z.number())),
|
|
17516
17945
|
usage: z42.z.object({ tokens: z42.z.number() }).nullish(),
|
|
17946
|
+
warnings: z42.z.array(gatewayEmbeddingWarningSchema).optional(),
|
|
17517
17947
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
17518
17948
|
})
|
|
17519
17949
|
)
|
|
17520
17950
|
);
|
|
17951
|
+
function mapGatewayWarnings(warnings) {
|
|
17952
|
+
return (warnings != null ? warnings : []).map(
|
|
17953
|
+
(warning) => warning.type === "deprecated" ? { type: "other", message: warning.message } : warning
|
|
17954
|
+
);
|
|
17955
|
+
}
|
|
17521
17956
|
var GatewayImageModel2 = class {
|
|
17522
17957
|
constructor(modelId, config) {
|
|
17523
17958
|
this.modelId = modelId;
|
|
@@ -17540,7 +17975,7 @@ var GatewayImageModel2 = class {
|
|
|
17540
17975
|
headers,
|
|
17541
17976
|
abortSignal
|
|
17542
17977
|
}) {
|
|
17543
|
-
var
|
|
17978
|
+
var _a117, _b113, _c;
|
|
17544
17979
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17545
17980
|
try {
|
|
17546
17981
|
const {
|
|
@@ -17579,7 +18014,7 @@ var GatewayImageModel2 = class {
|
|
|
17579
18014
|
return {
|
|
17580
18015
|
images: responseBody.images,
|
|
17581
18016
|
// Always base64 strings from server
|
|
17582
|
-
warnings: (
|
|
18017
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
17583
18018
|
providerMetadata: responseBody.providerMetadata,
|
|
17584
18019
|
response: {
|
|
17585
18020
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -17588,9 +18023,9 @@ var GatewayImageModel2 = class {
|
|
|
17588
18023
|
},
|
|
17589
18024
|
...responseBody.usage != null && {
|
|
17590
18025
|
usage: {
|
|
17591
|
-
inputTokens: (
|
|
17592
|
-
outputTokens: (
|
|
17593
|
-
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
|
|
17594
18029
|
}
|
|
17595
18030
|
}
|
|
17596
18031
|
};
|
|
@@ -17631,6 +18066,11 @@ var gatewayImageWarningSchema = z42.z.discriminatedUnion("type", [
|
|
|
17631
18066
|
feature: z42.z.string(),
|
|
17632
18067
|
details: z42.z.string().optional()
|
|
17633
18068
|
}),
|
|
18069
|
+
z42.z.object({
|
|
18070
|
+
type: z42.z.literal("deprecated"),
|
|
18071
|
+
setting: z42.z.string(),
|
|
18072
|
+
message: z42.z.string()
|
|
18073
|
+
}),
|
|
17634
18074
|
z42.z.object({
|
|
17635
18075
|
type: z42.z.literal("other"),
|
|
17636
18076
|
message: z42.z.string()
|
|
@@ -17666,12 +18106,14 @@ var GatewayVideoModel = class {
|
|
|
17666
18106
|
duration,
|
|
17667
18107
|
fps,
|
|
17668
18108
|
seed,
|
|
18109
|
+
generateAudio,
|
|
17669
18110
|
image,
|
|
18111
|
+
frameImages,
|
|
18112
|
+
inputReferences,
|
|
17670
18113
|
providerOptions,
|
|
17671
18114
|
headers,
|
|
17672
18115
|
abortSignal
|
|
17673
18116
|
}) {
|
|
17674
|
-
var _a932;
|
|
17675
18117
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17676
18118
|
try {
|
|
17677
18119
|
const { responseHeaders, value: responseBody } = await postJsonToApi2({
|
|
@@ -17691,8 +18133,20 @@ var GatewayVideoModel = class {
|
|
|
17691
18133
|
...duration && { duration },
|
|
17692
18134
|
...fps && { fps },
|
|
17693
18135
|
...seed && { seed },
|
|
18136
|
+
...generateAudio !== void 0 && { generateAudio },
|
|
17694
18137
|
...providerOptions && { providerOptions },
|
|
17695
|
-
...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
|
+
}
|
|
17696
18150
|
},
|
|
17697
18151
|
successfulResponseHandler: async ({
|
|
17698
18152
|
response,
|
|
@@ -17767,7 +18221,7 @@ var GatewayVideoModel = class {
|
|
|
17767
18221
|
});
|
|
17768
18222
|
return {
|
|
17769
18223
|
videos: responseBody.videos,
|
|
17770
|
-
warnings: (
|
|
18224
|
+
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
17771
18225
|
providerMetadata: responseBody.providerMetadata,
|
|
17772
18226
|
response: {
|
|
17773
18227
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -17824,6 +18278,11 @@ var gatewayVideoWarningSchema = z42.z.discriminatedUnion("type", [
|
|
|
17824
18278
|
feature: z42.z.string(),
|
|
17825
18279
|
details: z42.z.string().optional()
|
|
17826
18280
|
}),
|
|
18281
|
+
z42.z.object({
|
|
18282
|
+
type: z42.z.literal("deprecated"),
|
|
18283
|
+
setting: z42.z.string(),
|
|
18284
|
+
message: z42.z.string()
|
|
18285
|
+
}),
|
|
17827
18286
|
z42.z.object({
|
|
17828
18287
|
type: z42.z.literal("other"),
|
|
17829
18288
|
message: z42.z.string()
|
|
@@ -17861,6 +18320,7 @@ var GatewayRerankingModel = class {
|
|
|
17861
18320
|
abortSignal,
|
|
17862
18321
|
providerOptions
|
|
17863
18322
|
}) {
|
|
18323
|
+
var _a117;
|
|
17864
18324
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
17865
18325
|
try {
|
|
17866
18326
|
const {
|
|
@@ -17895,7 +18355,7 @@ var GatewayRerankingModel = class {
|
|
|
17895
18355
|
ranking: responseBody.ranking,
|
|
17896
18356
|
providerMetadata: responseBody.providerMetadata,
|
|
17897
18357
|
response: { headers: responseHeaders, body: rawValue },
|
|
17898
|
-
warnings: []
|
|
18358
|
+
warnings: (_a117 = responseBody.warnings) != null ? _a117 : []
|
|
17899
18359
|
};
|
|
17900
18360
|
} catch (error) {
|
|
17901
18361
|
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
@@ -17911,6 +18371,22 @@ var GatewayRerankingModel = class {
|
|
|
17911
18371
|
};
|
|
17912
18372
|
}
|
|
17913
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
|
+
]);
|
|
17914
18390
|
var gatewayRerankingResponseSchema = lazySchema2(
|
|
17915
18391
|
() => zodSchema3(
|
|
17916
18392
|
z42.z.object({
|
|
@@ -17920,156 +18396,507 @@ var gatewayRerankingResponseSchema = lazySchema2(
|
|
|
17920
18396
|
relevanceScore: z42.z.number()
|
|
17921
18397
|
})
|
|
17922
18398
|
),
|
|
18399
|
+
warnings: z42.z.array(gatewayRerankingWarningSchema).optional(),
|
|
17923
18400
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
17924
18401
|
})
|
|
17925
18402
|
)
|
|
17926
18403
|
);
|
|
17927
|
-
var
|
|
17928
|
-
()
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
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
|
-
|
|
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({
|
|
18888
|
+
error: zod.z.enum([
|
|
18889
|
+
"api_error",
|
|
18890
|
+
"rate_limit",
|
|
18891
|
+
"timeout",
|
|
18892
|
+
"invalid_input",
|
|
18893
|
+
"unknown"
|
|
18894
|
+
]),
|
|
18895
|
+
statusCode: zod.z.number().optional(),
|
|
18896
|
+
message: zod.z.string()
|
|
18897
|
+
})
|
|
18898
|
+
])
|
|
18899
|
+
)
|
|
18073
18900
|
);
|
|
18074
18901
|
var perplexitySearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
|
|
18075
18902
|
id: "gateway.perplexity_search",
|
|
@@ -18078,6 +18905,14 @@ var perplexitySearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
|
|
|
18078
18905
|
});
|
|
18079
18906
|
var perplexitySearch2 = (config = {}) => perplexitySearchToolFactory2(config);
|
|
18080
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,
|
|
18081
18916
|
/**
|
|
18082
18917
|
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
18083
18918
|
*
|
|
@@ -18097,18 +18932,18 @@ var gatewayTools2 = {
|
|
|
18097
18932
|
perplexitySearch: perplexitySearch2
|
|
18098
18933
|
};
|
|
18099
18934
|
async function getVercelRequestId2() {
|
|
18100
|
-
var
|
|
18101
|
-
return (
|
|
18935
|
+
var _a117;
|
|
18936
|
+
return (_a117 = getContext2().headers) == null ? void 0 : _a117["x-vercel-id"];
|
|
18102
18937
|
}
|
|
18103
|
-
var VERSION5 = "3.0.
|
|
18938
|
+
var VERSION5 = "3.0.148";
|
|
18104
18939
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
18105
18940
|
function createGatewayProvider2(options = {}) {
|
|
18106
|
-
var
|
|
18941
|
+
var _a117, _b113;
|
|
18107
18942
|
let pendingMetadata = null;
|
|
18108
18943
|
let metadataCache = null;
|
|
18109
|
-
const cacheRefreshMillis = (
|
|
18944
|
+
const cacheRefreshMillis = (_a117 = options.metadataCacheRefreshMillis) != null ? _a117 : 1e3 * 60 * 5;
|
|
18110
18945
|
let lastFetchTime = 0;
|
|
18111
|
-
const baseURL = (
|
|
18946
|
+
const baseURL = (_b113 = withoutTrailingSlash2(options.baseURL)) != null ? _b113 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
18112
18947
|
const getHeaders = async () => {
|
|
18113
18948
|
try {
|
|
18114
18949
|
const auth = await getGatewayAuthToken2(options);
|
|
@@ -18168,10 +19003,10 @@ function createGatewayProvider2(options = {}) {
|
|
|
18168
19003
|
});
|
|
18169
19004
|
};
|
|
18170
19005
|
const getAvailableModels = async () => {
|
|
18171
|
-
var
|
|
18172
|
-
const
|
|
18173
|
-
if (!pendingMetadata ||
|
|
18174
|
-
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;
|
|
18175
19010
|
pendingMetadata = new GatewayFetchMetadata2({
|
|
18176
19011
|
baseURL,
|
|
18177
19012
|
headers: getHeaders,
|
|
@@ -18278,6 +19113,28 @@ function createGatewayProvider2(options = {}) {
|
|
|
18278
19113
|
};
|
|
18279
19114
|
provider.rerankingModel = createRerankingModel;
|
|
18280
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;
|
|
18281
19138
|
provider.chat = provider.languageModel;
|
|
18282
19139
|
provider.embedding = provider.embeddingModel;
|
|
18283
19140
|
provider.image = provider.imageModel;
|
|
@@ -18303,19 +19160,16 @@ async function getGatewayAuthToken2(options) {
|
|
|
18303
19160
|
authMethod: "oidc"
|
|
18304
19161
|
};
|
|
18305
19162
|
}
|
|
18306
|
-
var
|
|
18307
|
-
var VERSION23 = "1.9.0";
|
|
19163
|
+
var VERSION6 = "1.9.1";
|
|
18308
19164
|
var re3 = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
18309
19165
|
function _makeCompatibilityCheck3(ownVersion) {
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
19166
|
+
const acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
|
|
19167
|
+
const rejectedVersions = /* @__PURE__ */ new Set();
|
|
19168
|
+
const myVersionMatch = ownVersion.match(re3);
|
|
18313
19169
|
if (!myVersionMatch) {
|
|
18314
|
-
return
|
|
18315
|
-
return false;
|
|
18316
|
-
};
|
|
19170
|
+
return () => false;
|
|
18317
19171
|
}
|
|
18318
|
-
|
|
19172
|
+
const ownVersionParsed = {
|
|
18319
19173
|
major: +myVersionMatch[1],
|
|
18320
19174
|
minor: +myVersionMatch[2],
|
|
18321
19175
|
patch: +myVersionMatch[3],
|
|
@@ -18341,11 +19195,11 @@ function _makeCompatibilityCheck3(ownVersion) {
|
|
|
18341
19195
|
if (rejectedVersions.has(globalVersion)) {
|
|
18342
19196
|
return false;
|
|
18343
19197
|
}
|
|
18344
|
-
|
|
19198
|
+
const globalVersionMatch = globalVersion.match(re3);
|
|
18345
19199
|
if (!globalVersionMatch) {
|
|
18346
19200
|
return _reject(globalVersion);
|
|
18347
19201
|
}
|
|
18348
|
-
|
|
19202
|
+
const globalVersionParsed = {
|
|
18349
19203
|
major: +globalVersionMatch[1],
|
|
18350
19204
|
minor: +globalVersionMatch[2],
|
|
18351
19205
|
patch: +globalVersionMatch[3],
|
|
@@ -18363,455 +19217,324 @@ function _makeCompatibilityCheck3(ownVersion) {
|
|
|
18363
19217
|
}
|
|
18364
19218
|
return _reject(globalVersion);
|
|
18365
19219
|
}
|
|
18366
|
-
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
18367
|
-
return _accept(globalVersion);
|
|
18368
|
-
}
|
|
18369
|
-
return _reject(globalVersion);
|
|
18370
|
-
};
|
|
18371
|
-
}
|
|
18372
|
-
var isCompatible3 = _makeCompatibilityCheck3(VERSION23);
|
|
18373
|
-
var major3 = VERSION23.split(".")[0];
|
|
18374
|
-
var GLOBAL_OPENTELEMETRY_API_KEY3 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major3);
|
|
18375
|
-
var _global3 = _globalThis3;
|
|
18376
|
-
function registerGlobal3(type, instance, diag, allowOverride) {
|
|
18377
|
-
var _a21;
|
|
18378
|
-
if (allowOverride === void 0) {
|
|
18379
|
-
allowOverride = false;
|
|
18380
|
-
}
|
|
18381
|
-
var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a21 !== void 0 ? _a21 : {
|
|
18382
|
-
version: VERSION23
|
|
18383
|
-
};
|
|
18384
|
-
if (!allowOverride && api[type]) {
|
|
18385
|
-
var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
|
|
18386
|
-
diag.error(err.stack || err.message);
|
|
18387
|
-
return false;
|
|
18388
|
-
}
|
|
18389
|
-
if (api.version !== VERSION23) {
|
|
18390
|
-
var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION23);
|
|
18391
|
-
diag.error(err.stack || err.message);
|
|
18392
|
-
return false;
|
|
18393
|
-
}
|
|
18394
|
-
api[type] = instance;
|
|
18395
|
-
diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION23 + ".");
|
|
18396
|
-
return true;
|
|
18397
|
-
}
|
|
18398
|
-
function getGlobal3(type) {
|
|
18399
|
-
var _a21, _b93;
|
|
18400
|
-
var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
|
|
18401
|
-
if (!globalVersion || !isCompatible3(globalVersion)) {
|
|
18402
|
-
return;
|
|
18403
|
-
}
|
|
18404
|
-
return (_b93 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b93 === void 0 ? void 0 : _b93[type];
|
|
18405
|
-
}
|
|
18406
|
-
function unregisterGlobal3(type, diag) {
|
|
18407
|
-
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
|
|
18408
|
-
var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3];
|
|
18409
|
-
if (api) {
|
|
18410
|
-
delete api[type];
|
|
18411
|
-
}
|
|
18412
|
-
}
|
|
18413
|
-
var __read6 = function(o, n) {
|
|
18414
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18415
|
-
if (!m) return o;
|
|
18416
|
-
var i = m.call(o), r, ar = [], e;
|
|
18417
|
-
try {
|
|
18418
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18419
|
-
} catch (error) {
|
|
18420
|
-
e = { error };
|
|
18421
|
-
} finally {
|
|
18422
|
-
try {
|
|
18423
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18424
|
-
} finally {
|
|
18425
|
-
if (e) throw e.error;
|
|
18426
|
-
}
|
|
18427
|
-
}
|
|
18428
|
-
return ar;
|
|
18429
|
-
};
|
|
18430
|
-
var __spreadArray6 = function(to, from, pack) {
|
|
18431
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18432
|
-
if (ar || !(i in from)) {
|
|
18433
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
18434
|
-
ar[i] = from[i];
|
|
18435
|
-
}
|
|
18436
|
-
}
|
|
18437
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18438
|
-
};
|
|
18439
|
-
var DiagComponentLogger3 = (
|
|
18440
|
-
/** @class */
|
|
18441
|
-
(function() {
|
|
18442
|
-
function DiagComponentLogger22(props) {
|
|
18443
|
-
this._namespace = props.namespace || "DiagComponentLogger";
|
|
18444
|
-
}
|
|
18445
|
-
DiagComponentLogger22.prototype.debug = function() {
|
|
18446
|
-
var args = [];
|
|
18447
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18448
|
-
args[_i] = arguments[_i];
|
|
18449
|
-
}
|
|
18450
|
-
return logProxy3("debug", this._namespace, args);
|
|
18451
|
-
};
|
|
18452
|
-
DiagComponentLogger22.prototype.error = function() {
|
|
18453
|
-
var args = [];
|
|
18454
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18455
|
-
args[_i] = arguments[_i];
|
|
18456
|
-
}
|
|
18457
|
-
return logProxy3("error", this._namespace, args);
|
|
18458
|
-
};
|
|
18459
|
-
DiagComponentLogger22.prototype.info = function() {
|
|
18460
|
-
var args = [];
|
|
18461
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18462
|
-
args[_i] = arguments[_i];
|
|
18463
|
-
}
|
|
18464
|
-
return logProxy3("info", this._namespace, args);
|
|
18465
|
-
};
|
|
18466
|
-
DiagComponentLogger22.prototype.warn = function() {
|
|
18467
|
-
var args = [];
|
|
18468
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18469
|
-
args[_i] = arguments[_i];
|
|
18470
|
-
}
|
|
18471
|
-
return logProxy3("warn", this._namespace, args);
|
|
18472
|
-
};
|
|
18473
|
-
DiagComponentLogger22.prototype.verbose = function() {
|
|
18474
|
-
var args = [];
|
|
18475
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18476
|
-
args[_i] = arguments[_i];
|
|
18477
|
-
}
|
|
18478
|
-
return logProxy3("verbose", this._namespace, args);
|
|
18479
|
-
};
|
|
18480
|
-
return DiagComponentLogger22;
|
|
18481
|
-
})()
|
|
18482
|
-
);
|
|
18483
|
-
function logProxy3(funcName, namespace, args) {
|
|
18484
|
-
var logger = getGlobal3("diag");
|
|
18485
|
-
if (!logger) {
|
|
18486
|
-
return;
|
|
18487
|
-
}
|
|
18488
|
-
args.unshift(namespace);
|
|
18489
|
-
return logger[funcName].apply(logger, __spreadArray6([], __read6(args), false));
|
|
18490
|
-
}
|
|
18491
|
-
var DiagLogLevel3;
|
|
18492
|
-
(function(DiagLogLevel22) {
|
|
18493
|
-
DiagLogLevel22[DiagLogLevel22["NONE"] = 0] = "NONE";
|
|
18494
|
-
DiagLogLevel22[DiagLogLevel22["ERROR"] = 30] = "ERROR";
|
|
18495
|
-
DiagLogLevel22[DiagLogLevel22["WARN"] = 50] = "WARN";
|
|
18496
|
-
DiagLogLevel22[DiagLogLevel22["INFO"] = 60] = "INFO";
|
|
18497
|
-
DiagLogLevel22[DiagLogLevel22["DEBUG"] = 70] = "DEBUG";
|
|
18498
|
-
DiagLogLevel22[DiagLogLevel22["VERBOSE"] = 80] = "VERBOSE";
|
|
18499
|
-
DiagLogLevel22[DiagLogLevel22["ALL"] = 9999] = "ALL";
|
|
18500
|
-
})(DiagLogLevel3 || (DiagLogLevel3 = {}));
|
|
18501
|
-
function createLogLevelDiagLogger3(maxLevel, logger) {
|
|
18502
|
-
if (maxLevel < DiagLogLevel3.NONE) {
|
|
18503
|
-
maxLevel = DiagLogLevel3.NONE;
|
|
18504
|
-
} else if (maxLevel > DiagLogLevel3.ALL) {
|
|
18505
|
-
maxLevel = DiagLogLevel3.ALL;
|
|
18506
|
-
}
|
|
18507
|
-
logger = logger || {};
|
|
18508
|
-
function _filterFunc(funcName, theLevel) {
|
|
18509
|
-
var theFunc = logger[funcName];
|
|
18510
|
-
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
18511
|
-
return theFunc.bind(logger);
|
|
18512
|
-
}
|
|
18513
|
-
return function() {
|
|
18514
|
-
};
|
|
18515
|
-
}
|
|
18516
|
-
return {
|
|
18517
|
-
error: _filterFunc("error", DiagLogLevel3.ERROR),
|
|
18518
|
-
warn: _filterFunc("warn", DiagLogLevel3.WARN),
|
|
18519
|
-
info: _filterFunc("info", DiagLogLevel3.INFO),
|
|
18520
|
-
debug: _filterFunc("debug", DiagLogLevel3.DEBUG),
|
|
18521
|
-
verbose: _filterFunc("verbose", DiagLogLevel3.VERBOSE)
|
|
18522
|
-
};
|
|
18523
|
-
}
|
|
18524
|
-
var __read23 = function(o, n) {
|
|
18525
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18526
|
-
if (!m) return o;
|
|
18527
|
-
var i = m.call(o), r, ar = [], e;
|
|
18528
|
-
try {
|
|
18529
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18530
|
-
} catch (error) {
|
|
18531
|
-
e = { error };
|
|
18532
|
-
} finally {
|
|
18533
|
-
try {
|
|
18534
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18535
|
-
} finally {
|
|
18536
|
-
if (e) throw e.error;
|
|
18537
|
-
}
|
|
18538
|
-
}
|
|
18539
|
-
return ar;
|
|
18540
|
-
};
|
|
18541
|
-
var __spreadArray23 = function(to, from, pack) {
|
|
18542
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18543
|
-
if (ar || !(i in from)) {
|
|
18544
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
18545
|
-
ar[i] = from[i];
|
|
18546
|
-
}
|
|
18547
|
-
}
|
|
18548
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18549
|
-
};
|
|
18550
|
-
var API_NAME5 = "diag";
|
|
18551
|
-
var DiagAPI3 = (
|
|
18552
|
-
/** @class */
|
|
18553
|
-
(function() {
|
|
18554
|
-
function DiagAPI22() {
|
|
18555
|
-
function _logProxy(funcName) {
|
|
18556
|
-
return function() {
|
|
18557
|
-
var args = [];
|
|
18558
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18559
|
-
args[_i] = arguments[_i];
|
|
18560
|
-
}
|
|
18561
|
-
var logger = getGlobal3("diag");
|
|
18562
|
-
if (!logger)
|
|
18563
|
-
return;
|
|
18564
|
-
return logger[funcName].apply(logger, __spreadArray23([], __read23(args), false));
|
|
18565
|
-
};
|
|
18566
|
-
}
|
|
18567
|
-
var self = this;
|
|
18568
|
-
var setLogger = function(logger, optionsOrLogLevel) {
|
|
18569
|
-
var _a21, _b93, _c;
|
|
18570
|
-
if (optionsOrLogLevel === void 0) {
|
|
18571
|
-
optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
|
|
18572
|
-
}
|
|
18573
|
-
if (logger === self) {
|
|
18574
|
-
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
18575
|
-
self.error((_a21 = err.stack) !== null && _a21 !== void 0 ? _a21 : err.message);
|
|
18576
|
-
return false;
|
|
18577
|
-
}
|
|
18578
|
-
if (typeof optionsOrLogLevel === "number") {
|
|
18579
|
-
optionsOrLogLevel = {
|
|
18580
|
-
logLevel: optionsOrLogLevel
|
|
18581
|
-
};
|
|
18582
|
-
}
|
|
18583
|
-
var oldLogger = getGlobal3("diag");
|
|
18584
|
-
var newLogger = createLogLevelDiagLogger3((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel3.INFO, logger);
|
|
18585
|
-
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
18586
|
-
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
18587
|
-
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
18588
|
-
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
18589
|
-
}
|
|
18590
|
-
return registerGlobal3("diag", newLogger, self, true);
|
|
18591
|
-
};
|
|
18592
|
-
self.setLogger = setLogger;
|
|
18593
|
-
self.disable = function() {
|
|
18594
|
-
unregisterGlobal3(API_NAME5, self);
|
|
18595
|
-
};
|
|
18596
|
-
self.createComponentLogger = function(options) {
|
|
18597
|
-
return new DiagComponentLogger3(options);
|
|
18598
|
-
};
|
|
18599
|
-
self.verbose = _logProxy("verbose");
|
|
18600
|
-
self.debug = _logProxy("debug");
|
|
18601
|
-
self.info = _logProxy("info");
|
|
18602
|
-
self.warn = _logProxy("warn");
|
|
18603
|
-
self.error = _logProxy("error");
|
|
18604
|
-
}
|
|
18605
|
-
DiagAPI22.instance = function() {
|
|
18606
|
-
if (!this._instance) {
|
|
18607
|
-
this._instance = new DiagAPI22();
|
|
18608
|
-
}
|
|
18609
|
-
return this._instance;
|
|
18610
|
-
};
|
|
18611
|
-
return DiagAPI22;
|
|
18612
|
-
})()
|
|
18613
|
-
);
|
|
18614
|
-
function createContextKey3(description) {
|
|
18615
|
-
return Symbol.for(description);
|
|
18616
|
-
}
|
|
18617
|
-
var BaseContext3 = (
|
|
18618
|
-
/** @class */
|
|
18619
|
-
/* @__PURE__ */ (function() {
|
|
18620
|
-
function BaseContext22(parentContext) {
|
|
18621
|
-
var self = this;
|
|
18622
|
-
self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
18623
|
-
self.getValue = function(key) {
|
|
18624
|
-
return self._currentContext.get(key);
|
|
18625
|
-
};
|
|
18626
|
-
self.setValue = function(key, value) {
|
|
18627
|
-
var context2 = new BaseContext22(self._currentContext);
|
|
18628
|
-
context2._currentContext.set(key, value);
|
|
18629
|
-
return context2;
|
|
18630
|
-
};
|
|
18631
|
-
self.deleteValue = function(key) {
|
|
18632
|
-
var context2 = new BaseContext22(self._currentContext);
|
|
18633
|
-
context2._currentContext.delete(key);
|
|
18634
|
-
return context2;
|
|
18635
|
-
};
|
|
18636
|
-
}
|
|
18637
|
-
return BaseContext22;
|
|
18638
|
-
})()
|
|
18639
|
-
);
|
|
18640
|
-
var ROOT_CONTEXT3 = new BaseContext3();
|
|
18641
|
-
var __read33 = function(o, n) {
|
|
18642
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18643
|
-
if (!m) return o;
|
|
18644
|
-
var i = m.call(o), r, ar = [], e;
|
|
18645
|
-
try {
|
|
18646
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18647
|
-
} catch (error) {
|
|
18648
|
-
e = { error };
|
|
18649
|
-
} finally {
|
|
18650
|
-
try {
|
|
18651
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18652
|
-
} finally {
|
|
18653
|
-
if (e) throw e.error;
|
|
19220
|
+
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
19221
|
+
return _accept(globalVersion);
|
|
18654
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;
|
|
18655
19239
|
}
|
|
18656
|
-
|
|
18657
|
-
};
|
|
18658
|
-
|
|
18659
|
-
|
|
18660
|
-
|
|
18661
|
-
|
|
18662
|
-
|
|
18663
|
-
|
|
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);
|
|
18664
19282
|
}
|
|
18665
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18666
19283
|
};
|
|
18667
|
-
|
|
18668
|
-
|
|
18669
|
-
(
|
|
18670
|
-
|
|
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);
|
|
18671
19312
|
}
|
|
18672
|
-
|
|
18673
|
-
return ROOT_CONTEXT3;
|
|
18674
|
-
};
|
|
18675
|
-
NoopContextManager22.prototype.with = function(_context, fn, thisArg) {
|
|
18676
|
-
var args = [];
|
|
18677
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
18678
|
-
args[_i - 3] = arguments[_i];
|
|
18679
|
-
}
|
|
18680
|
-
return fn.call.apply(fn, __spreadArray33([thisArg], __read33(args), false));
|
|
18681
|
-
};
|
|
18682
|
-
NoopContextManager22.prototype.bind = function(_context, target) {
|
|
18683
|
-
return target;
|
|
18684
|
-
};
|
|
18685
|
-
NoopContextManager22.prototype.enable = function() {
|
|
18686
|
-
return this;
|
|
18687
|
-
};
|
|
18688
|
-
NoopContextManager22.prototype.disable = function() {
|
|
18689
|
-
return this;
|
|
19313
|
+
return function() {
|
|
18690
19314
|
};
|
|
18691
|
-
return NoopContextManager22;
|
|
18692
|
-
})()
|
|
18693
|
-
);
|
|
18694
|
-
var __read43 = function(o, n) {
|
|
18695
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18696
|
-
if (!m) return o;
|
|
18697
|
-
var i = m.call(o), r, ar = [], e;
|
|
18698
|
-
try {
|
|
18699
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
18700
|
-
} catch (error) {
|
|
18701
|
-
e = { error };
|
|
18702
|
-
} finally {
|
|
18703
|
-
try {
|
|
18704
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
18705
|
-
} finally {
|
|
18706
|
-
if (e) throw e.error;
|
|
18707
|
-
}
|
|
18708
19315
|
}
|
|
18709
|
-
return
|
|
18710
|
-
|
|
18711
|
-
|
|
18712
|
-
|
|
18713
|
-
|
|
18714
|
-
|
|
18715
|
-
|
|
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();
|
|
18716
19330
|
}
|
|
19331
|
+
return this._instance;
|
|
18717
19332
|
}
|
|
18718
|
-
|
|
18719
|
-
|
|
18720
|
-
|
|
18721
|
-
|
|
18722
|
-
|
|
18723
|
-
|
|
18724
|
-
|
|
18725
|
-
|
|
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
|
+
};
|
|
18726
19345
|
}
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
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
|
+
};
|
|
18730
19358
|
}
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
|
|
18735
|
-
|
|
18736
|
-
|
|
18737
|
-
return this._getContextManager().active();
|
|
18738
|
-
};
|
|
18739
|
-
ContextAPI22.prototype.with = function(context2, fn, thisArg) {
|
|
18740
|
-
var _a21;
|
|
18741
|
-
var args = [];
|
|
18742
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
18743
|
-
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}`);
|
|
18744
19365
|
}
|
|
18745
|
-
return (
|
|
18746
|
-
};
|
|
18747
|
-
ContextAPI22.prototype.bind = function(context2, target) {
|
|
18748
|
-
return this._getContextManager().bind(context2, target);
|
|
19366
|
+
return registerGlobal3("diag", newLogger, self2, true);
|
|
18749
19367
|
};
|
|
18750
|
-
|
|
18751
|
-
|
|
19368
|
+
self2.setLogger = setLogger;
|
|
19369
|
+
self2.disable = () => {
|
|
19370
|
+
unregisterGlobal3(API_NAME5, self2);
|
|
18752
19371
|
};
|
|
18753
|
-
|
|
18754
|
-
|
|
18755
|
-
unregisterGlobal3(API_NAME23, DiagAPI3.instance());
|
|
19372
|
+
self2.createComponentLogger = (options) => {
|
|
19373
|
+
return new DiagComponentLogger3(options);
|
|
18756
19374
|
};
|
|
18757
|
-
|
|
18758
|
-
|
|
18759
|
-
);
|
|
18760
|
-
|
|
18761
|
-
(
|
|
18762
|
-
|
|
18763
|
-
TraceFlags22[TraceFlags22["SAMPLED"] = 1] = "SAMPLED";
|
|
18764
|
-
})(TraceFlags3 || (TraceFlags3 = {}));
|
|
18765
|
-
var INVALID_SPANID3 = "0000000000000000";
|
|
18766
|
-
var INVALID_TRACEID3 = "00000000000000000000000000000000";
|
|
18767
|
-
var INVALID_SPAN_CONTEXT3 = {
|
|
18768
|
-
traceId: INVALID_TRACEID3,
|
|
18769
|
-
spanId: INVALID_SPANID3,
|
|
18770
|
-
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
|
+
}
|
|
18771
19381
|
};
|
|
18772
|
-
|
|
18773
|
-
|
|
18774
|
-
|
|
18775
|
-
|
|
18776
|
-
|
|
18777
|
-
|
|
18778
|
-
|
|
18779
|
-
|
|
18780
|
-
|
|
18781
|
-
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
|
|
18785
|
-
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
return
|
|
18789
|
-
};
|
|
18790
|
-
NonRecordingSpan22.prototype.addEvent = function(_name, _attributes) {
|
|
18791
|
-
return this;
|
|
18792
|
-
};
|
|
18793
|
-
NonRecordingSpan22.prototype.addLink = function(_link) {
|
|
18794
|
-
return this;
|
|
18795
|
-
};
|
|
18796
|
-
NonRecordingSpan22.prototype.addLinks = function(_links) {
|
|
18797
|
-
return this;
|
|
18798
|
-
};
|
|
18799
|
-
NonRecordingSpan22.prototype.setStatus = function(_status) {
|
|
18800
|
-
return this;
|
|
18801
|
-
};
|
|
18802
|
-
NonRecordingSpan22.prototype.updateName = function(_name) {
|
|
18803
|
-
return this;
|
|
18804
|
-
};
|
|
18805
|
-
NonRecordingSpan22.prototype.end = function(_endTime) {
|
|
18806
|
-
};
|
|
18807
|
-
NonRecordingSpan22.prototype.isRecording = function() {
|
|
18808
|
-
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;
|
|
18809
19399
|
};
|
|
18810
|
-
|
|
19400
|
+
self2.deleteValue = (key) => {
|
|
19401
|
+
const context2 = new _BaseContext(self2._currentContext);
|
|
19402
|
+
context2._currentContext.delete(key);
|
|
19403
|
+
return context2;
|
|
18811
19404
|
};
|
|
18812
|
-
|
|
18813
|
-
|
|
18814
|
-
);
|
|
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
|
+
};
|
|
18815
19538
|
var SPAN_KEY3 = createContextKey3("OpenTelemetry Context Key SPAN");
|
|
18816
19539
|
function getSpan3(context2) {
|
|
18817
19540
|
return context2.getValue(SPAN_KEY3) || void 0;
|
|
@@ -18829,16 +19552,128 @@ function setSpanContext3(context2, spanContext) {
|
|
|
18829
19552
|
return setSpan3(context2, new NonRecordingSpan3(spanContext));
|
|
18830
19553
|
}
|
|
18831
19554
|
function getSpanContext3(context2) {
|
|
18832
|
-
var
|
|
18833
|
-
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;
|
|
18834
19671
|
}
|
|
18835
|
-
var VALID_TRACEID_REGEX3 = /^([0-9a-f]{32})$/i;
|
|
18836
|
-
var VALID_SPANID_REGEX3 = /^[0-9a-f]{16}$/i;
|
|
18837
19672
|
function isValidTraceId3(traceId) {
|
|
18838
|
-
return
|
|
19673
|
+
return isValidHex(traceId, 32) && traceId !== INVALID_TRACEID3;
|
|
18839
19674
|
}
|
|
18840
19675
|
function isValidSpanId3(spanId) {
|
|
18841
|
-
return
|
|
19676
|
+
return isValidHex(spanId, 16) && spanId !== INVALID_SPANID3;
|
|
18842
19677
|
}
|
|
18843
19678
|
function isSpanContextValid3(spanContext) {
|
|
18844
19679
|
return isValidTraceId3(spanContext.traceId) && isValidSpanId3(spanContext.spanId);
|
|
@@ -18847,119 +19682,105 @@ function wrapSpanContext3(spanContext) {
|
|
|
18847
19682
|
return new NonRecordingSpan3(spanContext);
|
|
18848
19683
|
}
|
|
18849
19684
|
var contextApi3 = ContextAPI3.getInstance();
|
|
18850
|
-
var NoopTracer3 =
|
|
18851
|
-
|
|
18852
|
-
(
|
|
18853
|
-
|
|
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();
|
|
18854
19697
|
}
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
|
|
18865
|
-
|
|
18866
|
-
|
|
18867
|
-
|
|
18868
|
-
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
} else if (arguments.length === 3) {
|
|
18879
|
-
opts = arg2;
|
|
18880
|
-
fn = arg3;
|
|
18881
|
-
} else {
|
|
18882
|
-
opts = arg2;
|
|
18883
|
-
ctx = arg3;
|
|
18884
|
-
fn = arg4;
|
|
18885
|
-
}
|
|
18886
|
-
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi3.active();
|
|
18887
|
-
var span = this.startSpan(name21, opts, parentContext);
|
|
18888
|
-
var contextWithSpanSet = setSpan3(parentContext, span);
|
|
18889
|
-
return contextApi3.with(contextWithSpanSet, fn, void 0, span);
|
|
18890
|
-
};
|
|
18891
|
-
return NoopTracer22;
|
|
18892
|
-
})()
|
|
18893
|
-
);
|
|
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
|
+
};
|
|
18894
19721
|
function isSpanContext3(spanContext) {
|
|
18895
|
-
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";
|
|
18896
19723
|
}
|
|
18897
19724
|
var NOOP_TRACER3 = new NoopTracer3();
|
|
18898
|
-
var ProxyTracer3 =
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
18919
|
-
if (!tracer) {
|
|
18920
|
-
return NOOP_TRACER3;
|
|
18921
|
-
}
|
|
18922
|
-
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) {
|
|
18923
19745
|
return this._delegate;
|
|
18924
|
-
};
|
|
18925
|
-
return ProxyTracer22;
|
|
18926
|
-
})()
|
|
18927
|
-
);
|
|
18928
|
-
var NoopTracerProvider3 = (
|
|
18929
|
-
/** @class */
|
|
18930
|
-
(function() {
|
|
18931
|
-
function NoopTracerProvider22() {
|
|
18932
19746
|
}
|
|
18933
|
-
|
|
18934
|
-
|
|
18935
|
-
|
|
18936
|
-
return NoopTracerProvider22;
|
|
18937
|
-
})()
|
|
18938
|
-
);
|
|
18939
|
-
var NOOP_TRACER_PROVIDER3 = new NoopTracerProvider3();
|
|
18940
|
-
var ProxyTracerProvider3 = (
|
|
18941
|
-
/** @class */
|
|
18942
|
-
(function() {
|
|
18943
|
-
function ProxyTracerProvider22() {
|
|
19747
|
+
const tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
19748
|
+
if (!tracer) {
|
|
19749
|
+
return NOOP_TRACER3;
|
|
18944
19750
|
}
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
|
|
18953
|
-
|
|
18954
|
-
|
|
18955
|
-
|
|
18956
|
-
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
|
|
18960
|
-
|
|
18961
|
-
|
|
18962
|
-
|
|
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
|
+
};
|
|
18963
19784
|
var SpanStatusCode3;
|
|
18964
19785
|
(function(SpanStatusCode22) {
|
|
18965
19786
|
SpanStatusCode22[SpanStatusCode22["UNSET"] = 0] = "UNSET";
|
|
@@ -18968,56 +19789,66 @@ var SpanStatusCode3;
|
|
|
18968
19789
|
})(SpanStatusCode3 || (SpanStatusCode3 = {}));
|
|
18969
19790
|
var context = ContextAPI3.getInstance();
|
|
18970
19791
|
var API_NAME33 = "trace";
|
|
18971
|
-
var TraceAPI3 =
|
|
18972
|
-
/**
|
|
18973
|
-
(
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
18982
|
-
|
|
18983
|
-
|
|
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);
|
|
18984
19821
|
}
|
|
18985
|
-
|
|
18986
|
-
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
unregisterGlobal3(API_NAME33, DiagAPI3.instance());
|
|
19006
|
-
this._proxyTracerProvider = new ProxyTracerProvider3();
|
|
19007
|
-
};
|
|
19008
|
-
return TraceAPI22;
|
|
19009
|
-
})()
|
|
19010
|
-
);
|
|
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
|
+
};
|
|
19011
19842
|
var trace3 = TraceAPI3.getInstance();
|
|
19012
19843
|
var __defProp4 = Object.defineProperty;
|
|
19013
19844
|
var __export3 = (target, all) => {
|
|
19014
|
-
for (var
|
|
19015
|
-
__defProp4(target,
|
|
19845
|
+
for (var name223 in all)
|
|
19846
|
+
__defProp4(target, name223, { get: all[name223], enumerable: true });
|
|
19016
19847
|
};
|
|
19017
|
-
var
|
|
19018
|
-
var
|
|
19019
|
-
var
|
|
19020
|
-
var
|
|
19848
|
+
var name21 = "AI_InvalidArgumentError";
|
|
19849
|
+
var marker21 = `vercel.ai.error.${name21}`;
|
|
19850
|
+
var symbol21 = Symbol.for(marker21);
|
|
19851
|
+
var _a21;
|
|
19021
19852
|
var InvalidArgumentError23 = class extends AISDKError3 {
|
|
19022
19853
|
constructor({
|
|
19023
19854
|
parameter,
|
|
@@ -19025,22 +19856,22 @@ var InvalidArgumentError23 = class extends AISDKError3 {
|
|
|
19025
19856
|
message
|
|
19026
19857
|
}) {
|
|
19027
19858
|
super({
|
|
19028
|
-
name:
|
|
19859
|
+
name: name21,
|
|
19029
19860
|
message: `Invalid argument for parameter ${parameter}: ${message}`
|
|
19030
19861
|
});
|
|
19031
|
-
this[
|
|
19862
|
+
this[_a21] = true;
|
|
19032
19863
|
this.parameter = parameter;
|
|
19033
19864
|
this.value = value;
|
|
19034
19865
|
}
|
|
19035
19866
|
static isInstance(error) {
|
|
19036
|
-
return AISDKError3.hasMarker(error,
|
|
19867
|
+
return AISDKError3.hasMarker(error, marker21);
|
|
19037
19868
|
}
|
|
19038
19869
|
};
|
|
19039
|
-
|
|
19040
|
-
var
|
|
19041
|
-
var
|
|
19042
|
-
var
|
|
19043
|
-
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;
|
|
19044
19875
|
var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
19045
19876
|
constructor({
|
|
19046
19877
|
message = "No object generated.",
|
|
@@ -19050,18 +19881,18 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
|
19050
19881
|
usage,
|
|
19051
19882
|
finishReason
|
|
19052
19883
|
}) {
|
|
19053
|
-
super({ name:
|
|
19054
|
-
this[
|
|
19884
|
+
super({ name: name97, message, cause });
|
|
19885
|
+
this[_a97] = true;
|
|
19055
19886
|
this.text = text22;
|
|
19056
19887
|
this.response = response;
|
|
19057
19888
|
this.usage = usage;
|
|
19058
19889
|
this.finishReason = finishReason;
|
|
19059
19890
|
}
|
|
19060
19891
|
static isInstance(error) {
|
|
19061
|
-
return AISDKError3.hasMarker(error,
|
|
19892
|
+
return AISDKError3.hasMarker(error, marker97);
|
|
19062
19893
|
}
|
|
19063
19894
|
};
|
|
19064
|
-
|
|
19895
|
+
_a97 = symbol97;
|
|
19065
19896
|
var UnsupportedModelVersionError3 = class extends AISDKError3 {
|
|
19066
19897
|
constructor(options) {
|
|
19067
19898
|
super({
|
|
@@ -19073,27 +19904,27 @@ var UnsupportedModelVersionError3 = class extends AISDKError3 {
|
|
|
19073
19904
|
this.modelId = options.modelId;
|
|
19074
19905
|
}
|
|
19075
19906
|
};
|
|
19076
|
-
var
|
|
19077
|
-
var
|
|
19078
|
-
var
|
|
19079
|
-
var
|
|
19907
|
+
var name202 = "AI_RetryError";
|
|
19908
|
+
var marker202 = `vercel.ai.error.${name202}`;
|
|
19909
|
+
var symbol202 = Symbol.for(marker202);
|
|
19910
|
+
var _a202;
|
|
19080
19911
|
var RetryError3 = class extends AISDKError3 {
|
|
19081
19912
|
constructor({
|
|
19082
19913
|
message,
|
|
19083
19914
|
reason,
|
|
19084
19915
|
errors
|
|
19085
19916
|
}) {
|
|
19086
|
-
super({ name:
|
|
19087
|
-
this[
|
|
19917
|
+
super({ name: name202, message });
|
|
19918
|
+
this[_a202] = true;
|
|
19088
19919
|
this.reason = reason;
|
|
19089
19920
|
this.errors = errors;
|
|
19090
19921
|
this.lastError = errors[errors.length - 1];
|
|
19091
19922
|
}
|
|
19092
19923
|
static isInstance(error) {
|
|
19093
|
-
return AISDKError3.hasMarker(error,
|
|
19924
|
+
return AISDKError3.hasMarker(error, marker202);
|
|
19094
19925
|
}
|
|
19095
19926
|
};
|
|
19096
|
-
|
|
19927
|
+
_a202 = symbol202;
|
|
19097
19928
|
function formatWarning({
|
|
19098
19929
|
warning,
|
|
19099
19930
|
provider,
|
|
@@ -19198,8 +20029,8 @@ function resolveEmbeddingModel2(model) {
|
|
|
19198
20029
|
return getGlobalProvider2().embeddingModel(model);
|
|
19199
20030
|
}
|
|
19200
20031
|
function getGlobalProvider2() {
|
|
19201
|
-
var
|
|
19202
|
-
return (
|
|
20032
|
+
var _a223;
|
|
20033
|
+
return (_a223 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a223 : gateway2;
|
|
19203
20034
|
}
|
|
19204
20035
|
function getTotalTimeoutMs(timeout) {
|
|
19205
20036
|
if (timeout == null) {
|
|
@@ -19210,7 +20041,7 @@ function getTotalTimeoutMs(timeout) {
|
|
|
19210
20041
|
}
|
|
19211
20042
|
return timeout.totalMs;
|
|
19212
20043
|
}
|
|
19213
|
-
var
|
|
20044
|
+
var VERSION23 = "6.0.224";
|
|
19214
20045
|
var dataContentSchema3 = z42.z.union([
|
|
19215
20046
|
z42.z.string(),
|
|
19216
20047
|
z42.z.instanceof(Uint8Array),
|
|
@@ -19218,8 +20049,8 @@ var dataContentSchema3 = z42.z.union([
|
|
|
19218
20049
|
z42.z.custom(
|
|
19219
20050
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
19220
20051
|
(value) => {
|
|
19221
|
-
var
|
|
19222
|
-
return (
|
|
20052
|
+
var _a223, _b19;
|
|
20053
|
+
return (_b19 = (_a223 = globalThis.Buffer) == null ? void 0 : _a223.isBuffer(value)) != null ? _b19 : false;
|
|
19223
20054
|
},
|
|
19224
20055
|
{ message: "Must be a Buffer" }
|
|
19225
20056
|
)
|
|
@@ -19433,7 +20264,7 @@ function getBaseTelemetryAttributes3({
|
|
|
19433
20264
|
telemetry,
|
|
19434
20265
|
headers
|
|
19435
20266
|
}) {
|
|
19436
|
-
var
|
|
20267
|
+
var _a223;
|
|
19437
20268
|
return {
|
|
19438
20269
|
"ai.model.provider": model.provider,
|
|
19439
20270
|
"ai.model.id": model.modelId,
|
|
@@ -19452,7 +20283,7 @@ function getBaseTelemetryAttributes3({
|
|
|
19452
20283
|
return attributes;
|
|
19453
20284
|
}, {}),
|
|
19454
20285
|
// add metadata as attributes:
|
|
19455
|
-
...Object.entries((
|
|
20286
|
+
...Object.entries((_a223 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a223 : {}).reduce(
|
|
19456
20287
|
(attributes, [key, value]) => {
|
|
19457
20288
|
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
19458
20289
|
return attributes;
|
|
@@ -19472,7 +20303,7 @@ var noopTracer3 = {
|
|
|
19472
20303
|
startSpan() {
|
|
19473
20304
|
return noopSpan3;
|
|
19474
20305
|
},
|
|
19475
|
-
startActiveSpan(
|
|
20306
|
+
startActiveSpan(name223, arg1, arg2, arg3) {
|
|
19476
20307
|
if (typeof arg1 === "function") {
|
|
19477
20308
|
return arg1(noopSpan3);
|
|
19478
20309
|
}
|
|
@@ -19537,14 +20368,14 @@ function getTracer3({
|
|
|
19537
20368
|
return trace3.getTracer("ai");
|
|
19538
20369
|
}
|
|
19539
20370
|
async function recordSpan3({
|
|
19540
|
-
name:
|
|
20371
|
+
name: name223,
|
|
19541
20372
|
tracer,
|
|
19542
20373
|
attributes,
|
|
19543
20374
|
fn,
|
|
19544
20375
|
endWhenDone = true
|
|
19545
20376
|
}) {
|
|
19546
20377
|
return tracer.startActiveSpan(
|
|
19547
|
-
|
|
20378
|
+
name223,
|
|
19548
20379
|
{ attributes: await attributes },
|
|
19549
20380
|
async (span) => {
|
|
19550
20381
|
const ctx = context.active();
|
|
@@ -19580,6 +20411,28 @@ function recordErrorOnSpan3(span, error) {
|
|
|
19580
20411
|
span.setStatus({ code: SpanStatusCode3.ERROR });
|
|
19581
20412
|
}
|
|
19582
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
|
+
}
|
|
19583
20436
|
async function selectTelemetryAttributes3({
|
|
19584
20437
|
telemetry,
|
|
19585
20438
|
attributes
|
|
@@ -19598,7 +20451,9 @@ async function selectTelemetryAttributes3({
|
|
|
19598
20451
|
}
|
|
19599
20452
|
const result = await value.input();
|
|
19600
20453
|
if (result != null) {
|
|
19601
|
-
|
|
20454
|
+
const sanitized2 = sanitizeAttributeValue(result);
|
|
20455
|
+
if (sanitized2 != null)
|
|
20456
|
+
resultAttributes[key] = sanitized2;
|
|
19602
20457
|
}
|
|
19603
20458
|
continue;
|
|
19604
20459
|
}
|
|
@@ -19608,11 +20463,15 @@ async function selectTelemetryAttributes3({
|
|
|
19608
20463
|
}
|
|
19609
20464
|
const result = await value.output();
|
|
19610
20465
|
if (result != null) {
|
|
19611
|
-
|
|
20466
|
+
const sanitized2 = sanitizeAttributeValue(result);
|
|
20467
|
+
if (sanitized2 != null)
|
|
20468
|
+
resultAttributes[key] = sanitized2;
|
|
19612
20469
|
}
|
|
19613
20470
|
continue;
|
|
19614
20471
|
}
|
|
19615
|
-
|
|
20472
|
+
const sanitized = sanitizeAttributeValue(value);
|
|
20473
|
+
if (sanitized != null)
|
|
20474
|
+
resultAttributes[key] = sanitized;
|
|
19616
20475
|
}
|
|
19617
20476
|
return resultAttributes;
|
|
19618
20477
|
}
|
|
@@ -19620,7 +20479,7 @@ function getRetryDelayInMs2({
|
|
|
19620
20479
|
error,
|
|
19621
20480
|
exponentialBackoffDelay
|
|
19622
20481
|
}) {
|
|
19623
|
-
const headers = error.responseHeaders;
|
|
20482
|
+
const headers = APICallError3.isInstance(error) ? error.responseHeaders : APICallError3.isInstance(error.cause) ? error.cause.responseHeaders : void 0;
|
|
19624
20483
|
if (!headers)
|
|
19625
20484
|
return exponentialBackoffDelay;
|
|
19626
20485
|
let ms;
|
|
@@ -19650,66 +20509,18 @@ var retryWithExponentialBackoffRespectingRetryHeaders2 = ({
|
|
|
19650
20509
|
initialDelayInMs = 2e3,
|
|
19651
20510
|
backoffFactor = 2,
|
|
19652
20511
|
abortSignal
|
|
19653
|
-
} = {}) =>
|
|
20512
|
+
} = {}) => retryWithExponentialBackoff2({
|
|
19654
20513
|
maxRetries,
|
|
19655
|
-
|
|
20514
|
+
initialDelayInMs,
|
|
19656
20515
|
backoffFactor,
|
|
19657
|
-
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 })
|
|
19658
20523
|
});
|
|
19659
|
-
async function _retryWithExponentialBackoff3(f, {
|
|
19660
|
-
maxRetries,
|
|
19661
|
-
delayInMs,
|
|
19662
|
-
backoffFactor,
|
|
19663
|
-
abortSignal
|
|
19664
|
-
}, errors = []) {
|
|
19665
|
-
try {
|
|
19666
|
-
return await f();
|
|
19667
|
-
} catch (error) {
|
|
19668
|
-
if (isAbortError5(error)) {
|
|
19669
|
-
throw error;
|
|
19670
|
-
}
|
|
19671
|
-
if (maxRetries === 0) {
|
|
19672
|
-
throw error;
|
|
19673
|
-
}
|
|
19674
|
-
const errorMessage = getErrorMessage23(error);
|
|
19675
|
-
const newErrors = [...errors, error];
|
|
19676
|
-
const tryNumber = newErrors.length;
|
|
19677
|
-
if (tryNumber > maxRetries) {
|
|
19678
|
-
throw new RetryError3({
|
|
19679
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
19680
|
-
reason: "maxRetriesExceeded",
|
|
19681
|
-
errors: newErrors
|
|
19682
|
-
});
|
|
19683
|
-
}
|
|
19684
|
-
if (error instanceof Error && APICallError3.isInstance(error) && error.isRetryable === true && tryNumber <= maxRetries) {
|
|
19685
|
-
await delay3(
|
|
19686
|
-
getRetryDelayInMs2({
|
|
19687
|
-
error,
|
|
19688
|
-
exponentialBackoffDelay: delayInMs
|
|
19689
|
-
}),
|
|
19690
|
-
{ abortSignal }
|
|
19691
|
-
);
|
|
19692
|
-
return _retryWithExponentialBackoff3(
|
|
19693
|
-
f,
|
|
19694
|
-
{
|
|
19695
|
-
maxRetries,
|
|
19696
|
-
delayInMs: backoffFactor * delayInMs,
|
|
19697
|
-
backoffFactor,
|
|
19698
|
-
abortSignal
|
|
19699
|
-
},
|
|
19700
|
-
newErrors
|
|
19701
|
-
);
|
|
19702
|
-
}
|
|
19703
|
-
if (tryNumber === 1) {
|
|
19704
|
-
throw error;
|
|
19705
|
-
}
|
|
19706
|
-
throw new RetryError3({
|
|
19707
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
19708
|
-
reason: "errorNotRetryable",
|
|
19709
|
-
errors: newErrors
|
|
19710
|
-
});
|
|
19711
|
-
}
|
|
19712
|
-
}
|
|
19713
20524
|
function prepareRetries3({
|
|
19714
20525
|
maxRetries,
|
|
19715
20526
|
abortSignal
|
|
@@ -19739,6 +20550,7 @@ function prepareRetries3({
|
|
|
19739
20550
|
})
|
|
19740
20551
|
};
|
|
19741
20552
|
}
|
|
20553
|
+
new TextEncoder();
|
|
19742
20554
|
var output_exports3 = {};
|
|
19743
20555
|
__export3(output_exports3, {
|
|
19744
20556
|
array: () => array,
|
|
@@ -19751,6 +20563,10 @@ function fixJson3(input) {
|
|
|
19751
20563
|
const stack = ["ROOT"];
|
|
19752
20564
|
let lastValidIndex = -1;
|
|
19753
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
|
+
}
|
|
19754
20570
|
function processValueStart(char, i, swapState) {
|
|
19755
20571
|
{
|
|
19756
20572
|
switch (char) {
|
|
@@ -19955,7 +20771,22 @@ function fixJson3(input) {
|
|
|
19955
20771
|
}
|
|
19956
20772
|
case "INSIDE_STRING_ESCAPE": {
|
|
19957
20773
|
stack.pop();
|
|
19958
|
-
|
|
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
|
+
}
|
|
19959
20790
|
break;
|
|
19960
20791
|
}
|
|
19961
20792
|
case "INSIDE_NUMBER": {
|
|
@@ -20092,7 +20923,7 @@ var text3 = () => ({
|
|
|
20092
20923
|
});
|
|
20093
20924
|
var object3 = ({
|
|
20094
20925
|
schema: inputSchema,
|
|
20095
|
-
name:
|
|
20926
|
+
name: name223,
|
|
20096
20927
|
description
|
|
20097
20928
|
}) => {
|
|
20098
20929
|
const schema = asSchema3(inputSchema);
|
|
@@ -20101,7 +20932,7 @@ var object3 = ({
|
|
|
20101
20932
|
responseFormat: resolve2(schema.jsonSchema).then((jsonSchema22) => ({
|
|
20102
20933
|
type: "json",
|
|
20103
20934
|
schema: jsonSchema22,
|
|
20104
|
-
...
|
|
20935
|
+
...name223 != null && { name: name223 },
|
|
20105
20936
|
...description != null && { description }
|
|
20106
20937
|
})),
|
|
20107
20938
|
async parseCompleteOutput({ text: text22 }, context2) {
|
|
@@ -20155,7 +20986,7 @@ var object3 = ({
|
|
|
20155
20986
|
};
|
|
20156
20987
|
var array = ({
|
|
20157
20988
|
element: inputElementSchema,
|
|
20158
|
-
name:
|
|
20989
|
+
name: name223,
|
|
20159
20990
|
description
|
|
20160
20991
|
}) => {
|
|
20161
20992
|
const elementSchema = asSchema3(inputElementSchema);
|
|
@@ -20175,7 +21006,7 @@ var array = ({
|
|
|
20175
21006
|
required: ["elements"],
|
|
20176
21007
|
additionalProperties: false
|
|
20177
21008
|
},
|
|
20178
|
-
...
|
|
21009
|
+
...name223 != null && { name: name223 },
|
|
20179
21010
|
...description != null && { description }
|
|
20180
21011
|
};
|
|
20181
21012
|
}),
|
|
@@ -20205,6 +21036,7 @@ var array = ({
|
|
|
20205
21036
|
finishReason: context2.finishReason
|
|
20206
21037
|
});
|
|
20207
21038
|
}
|
|
21039
|
+
const validatedElements = [];
|
|
20208
21040
|
for (const element of outerValue.elements) {
|
|
20209
21041
|
const validationResult = await safeValidateTypes3({
|
|
20210
21042
|
value: element,
|
|
@@ -20220,8 +21052,9 @@ var array = ({
|
|
|
20220
21052
|
finishReason: context2.finishReason
|
|
20221
21053
|
});
|
|
20222
21054
|
}
|
|
21055
|
+
validatedElements.push(validationResult.value);
|
|
20223
21056
|
}
|
|
20224
|
-
return
|
|
21057
|
+
return validatedElements;
|
|
20225
21058
|
},
|
|
20226
21059
|
async parsePartialOutput({ text: text22 }) {
|
|
20227
21060
|
const result = await parsePartialJson3(text22);
|
|
@@ -20267,7 +21100,7 @@ var array = ({
|
|
|
20267
21100
|
};
|
|
20268
21101
|
var choice = ({
|
|
20269
21102
|
options: choiceOptions,
|
|
20270
|
-
name:
|
|
21103
|
+
name: name223,
|
|
20271
21104
|
description
|
|
20272
21105
|
}) => {
|
|
20273
21106
|
return {
|
|
@@ -20284,7 +21117,7 @@ var choice = ({
|
|
|
20284
21117
|
required: ["result"],
|
|
20285
21118
|
additionalProperties: false
|
|
20286
21119
|
},
|
|
20287
|
-
...
|
|
21120
|
+
...name223 != null && { name: name223 },
|
|
20288
21121
|
...description != null && { description }
|
|
20289
21122
|
}),
|
|
20290
21123
|
async parseCompleteOutput({ text: text22 }, context2) {
|
|
@@ -20345,14 +21178,14 @@ var choice = ({
|
|
|
20345
21178
|
};
|
|
20346
21179
|
};
|
|
20347
21180
|
var json = ({
|
|
20348
|
-
name:
|
|
21181
|
+
name: name223,
|
|
20349
21182
|
description
|
|
20350
21183
|
} = {}) => {
|
|
20351
21184
|
return {
|
|
20352
21185
|
name: "json",
|
|
20353
21186
|
responseFormat: Promise.resolve({
|
|
20354
21187
|
type: "json",
|
|
20355
|
-
...
|
|
21188
|
+
...name223 != null && { name: name223 },
|
|
20356
21189
|
...description != null && { description }
|
|
20357
21190
|
}),
|
|
20358
21191
|
async parseCompleteOutput({ text: text22 }, context2) {
|
|
@@ -20430,7 +21263,7 @@ async function embedMany3({
|
|
|
20430
21263
|
});
|
|
20431
21264
|
const headersWithUserAgent = withUserAgentSuffix2(
|
|
20432
21265
|
headers != null ? headers : {},
|
|
20433
|
-
`ai/${
|
|
21266
|
+
`ai/${VERSION23}`
|
|
20434
21267
|
);
|
|
20435
21268
|
const baseTelemetryAttributes = getBaseTelemetryAttributes3({
|
|
20436
21269
|
model,
|
|
@@ -20454,7 +21287,7 @@ async function embedMany3({
|
|
|
20454
21287
|
}),
|
|
20455
21288
|
tracer,
|
|
20456
21289
|
fn: async (span) => {
|
|
20457
|
-
var
|
|
21290
|
+
var _a223;
|
|
20458
21291
|
const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
|
|
20459
21292
|
model.maxEmbeddingsPerCall,
|
|
20460
21293
|
model.supportsParallelCalls
|
|
@@ -20479,7 +21312,7 @@ async function embedMany3({
|
|
|
20479
21312
|
}),
|
|
20480
21313
|
tracer,
|
|
20481
21314
|
fn: async (doEmbedSpan) => {
|
|
20482
|
-
var
|
|
21315
|
+
var _a232, _b19;
|
|
20483
21316
|
const modelResponse = await model.doEmbed({
|
|
20484
21317
|
values,
|
|
20485
21318
|
abortSignal,
|
|
@@ -20487,7 +21320,7 @@ async function embedMany3({
|
|
|
20487
21320
|
providerOptions
|
|
20488
21321
|
});
|
|
20489
21322
|
const embeddings3 = modelResponse.embeddings;
|
|
20490
|
-
const usage2 = (
|
|
21323
|
+
const usage2 = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
|
|
20491
21324
|
doEmbedSpan.setAttributes(
|
|
20492
21325
|
await selectTelemetryAttributes3({
|
|
20493
21326
|
telemetry,
|
|
@@ -20504,7 +21337,7 @@ async function embedMany3({
|
|
|
20504
21337
|
return {
|
|
20505
21338
|
embeddings: embeddings3,
|
|
20506
21339
|
usage: usage2,
|
|
20507
|
-
warnings: modelResponse.warnings,
|
|
21340
|
+
warnings: (_b19 = modelResponse.warnings) != null ? _b19 : [],
|
|
20508
21341
|
providerMetadata: modelResponse.providerMetadata,
|
|
20509
21342
|
response: modelResponse.response
|
|
20510
21343
|
};
|
|
@@ -20568,7 +21401,7 @@ async function embedMany3({
|
|
|
20568
21401
|
}),
|
|
20569
21402
|
tracer,
|
|
20570
21403
|
fn: async (doEmbedSpan) => {
|
|
20571
|
-
var
|
|
21404
|
+
var _a232, _b19;
|
|
20572
21405
|
const modelResponse = await model.doEmbed({
|
|
20573
21406
|
values: chunk,
|
|
20574
21407
|
abortSignal,
|
|
@@ -20576,7 +21409,7 @@ async function embedMany3({
|
|
|
20576
21409
|
providerOptions
|
|
20577
21410
|
});
|
|
20578
21411
|
const embeddings2 = modelResponse.embeddings;
|
|
20579
|
-
const usage = (
|
|
21412
|
+
const usage = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
|
|
20580
21413
|
doEmbedSpan.setAttributes(
|
|
20581
21414
|
await selectTelemetryAttributes3({
|
|
20582
21415
|
telemetry,
|
|
@@ -20593,7 +21426,7 @@ async function embedMany3({
|
|
|
20593
21426
|
return {
|
|
20594
21427
|
embeddings: embeddings2,
|
|
20595
21428
|
usage,
|
|
20596
|
-
warnings: modelResponse.warnings,
|
|
21429
|
+
warnings: (_b19 = modelResponse.warnings) != null ? _b19 : [],
|
|
20597
21430
|
providerMetadata: modelResponse.providerMetadata,
|
|
20598
21431
|
response: modelResponse.response
|
|
20599
21432
|
};
|
|
@@ -20615,7 +21448,7 @@ async function embedMany3({
|
|
|
20615
21448
|
result.providerMetadata
|
|
20616
21449
|
)) {
|
|
20617
21450
|
providerMetadata[providerName] = {
|
|
20618
|
-
...(
|
|
21451
|
+
...(_a223 = providerMetadata[providerName]) != null ? _a223 : {},
|
|
20619
21452
|
...metadata
|
|
20620
21453
|
};
|
|
20621
21454
|
}
|
|
@@ -22334,8 +23167,8 @@ async function listThreadsForResource({
|
|
|
22334
23167
|
const title = thread.title || "(untitled)";
|
|
22335
23168
|
const updated = formatTimestamp(thread.updatedAt);
|
|
22336
23169
|
const created = formatTimestamp(thread.createdAt);
|
|
22337
|
-
const
|
|
22338
|
-
lines.push(`- **${title}**${
|
|
23170
|
+
const marker28 = isCurrent ? " \u2190 current" : "";
|
|
23171
|
+
lines.push(`- **${title}**${marker28}`);
|
|
22339
23172
|
lines.push(` id: ${thread.id}`);
|
|
22340
23173
|
lines.push(` updated: ${updated} | created: ${created}`);
|
|
22341
23174
|
}
|
|
@@ -23494,8 +24327,8 @@ var __experimental_updateWorkingMemoryToolVNext = (config) => {
|
|
|
23494
24327
|
function createWorkingMemoryTool(config, options = {}) {
|
|
23495
24328
|
const useStateSignals = config.workingMemory?.useStateSignals === true;
|
|
23496
24329
|
const tool3 = options.vNext ? __experimental_updateWorkingMemoryToolVNext(config) : updateWorkingMemoryTool(config);
|
|
23497
|
-
const
|
|
23498
|
-
return { name:
|
|
24330
|
+
const name28 = useStateSignals ? SET_WORKING_MEMORY_TOOL_NAME : UPDATE_WORKING_MEMORY_TOOL_NAME;
|
|
24331
|
+
return { name: name28, tool: tool3 };
|
|
23499
24332
|
}
|
|
23500
24333
|
var WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
23501
24334
|
var WORKING_MEMORY_END_TAG = "</working_memory>";
|
|
@@ -23920,7 +24753,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
23920
24753
|
const separator = this.vector.indexSeparator ?? "_";
|
|
23921
24754
|
const prefix = `memory${separator}messages`;
|
|
23922
24755
|
const indexes = await this.vector.listIndexes();
|
|
23923
|
-
return indexes.filter((
|
|
24756
|
+
return indexes.filter((name28) => name28.startsWith(prefix));
|
|
23924
24757
|
}
|
|
23925
24758
|
/**
|
|
23926
24759
|
* Deletes all vector embeddings associated with a thread.
|
|
@@ -24584,7 +25417,7 @@ ${workingMemory}`;
|
|
|
24584
25417
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
24585
25418
|
);
|
|
24586
25419
|
}
|
|
24587
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
25420
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-2F4GJOP2.cjs');
|
|
24588
25421
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
24589
25422
|
await this.indexObservation(observation);
|
|
24590
25423
|
} : void 0;
|
|
@@ -25042,10 +25875,10 @@ Notes:
|
|
|
25042
25875
|
const tools = {};
|
|
25043
25876
|
const workingMemoryConfig = mergedConfig.workingMemory;
|
|
25044
25877
|
if (workingMemoryConfig?.enabled && workingMemoryConfig.agentManaged !== false && !mergedConfig.readOnly) {
|
|
25045
|
-
const { name:
|
|
25878
|
+
const { name: name28, tool: tool3 } = createWorkingMemoryTool(mergedConfig, {
|
|
25046
25879
|
vNext: this.isVNextWorkingMemoryConfig(mergedConfig)
|
|
25047
25880
|
});
|
|
25048
|
-
tools[
|
|
25881
|
+
tools[name28] = tool3;
|
|
25049
25882
|
}
|
|
25050
25883
|
const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
|
|
25051
25884
|
if (omConfig?.retrieval) {
|
|
@@ -25632,7 +26465,7 @@ Notes:
|
|
|
25632
26465
|
if (!effectiveConfig) return null;
|
|
25633
26466
|
const engine = await this.omEngine;
|
|
25634
26467
|
if (!engine) return null;
|
|
25635
|
-
const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-
|
|
26468
|
+
const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-2F4GJOP2.cjs');
|
|
25636
26469
|
return new ObservationalMemoryProcessor2(engine, this, {
|
|
25637
26470
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
25638
26471
|
});
|
|
@@ -28289,16 +29122,16 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
28289
29122
|
* (data-* parts are filtered out before sending to the LLM, so they don't affect model calls.)
|
|
28290
29123
|
* @internal Used by ReflectorRunner. Do not call directly.
|
|
28291
29124
|
*/
|
|
28292
|
-
async persistMarkerToMessage(
|
|
29125
|
+
async persistMarkerToMessage(marker28, messageList, threadId, resourceId) {
|
|
28293
29126
|
if (!messageList) return;
|
|
28294
29127
|
const allMsgs = messageList.get.all.db();
|
|
28295
29128
|
for (let i = allMsgs.length - 1; i >= 0; i--) {
|
|
28296
29129
|
const msg = allMsgs[i];
|
|
28297
29130
|
if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
|
|
28298
|
-
const markerData =
|
|
28299
|
-
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);
|
|
28300
29133
|
if (!alreadyPresent) {
|
|
28301
|
-
msg.content.parts.push(
|
|
29134
|
+
msg.content.parts.push(marker28);
|
|
28302
29135
|
}
|
|
28303
29136
|
try {
|
|
28304
29137
|
await this.messageHistory.persistMessages({
|
|
@@ -28319,7 +29152,7 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
28319
29152
|
* so it works even when no MessageList is available (e.g. async buffering ops).
|
|
28320
29153
|
* @internal Used by observation strategies. Do not call directly.
|
|
28321
29154
|
*/
|
|
28322
|
-
async persistMarkerToStorage(
|
|
29155
|
+
async persistMarkerToStorage(marker28, threadId, resourceId) {
|
|
28323
29156
|
try {
|
|
28324
29157
|
const result = await this.storage.listMessages({
|
|
28325
29158
|
threadId,
|
|
@@ -28329,10 +29162,10 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
28329
29162
|
const messages = result?.messages ?? [];
|
|
28330
29163
|
for (const msg of messages) {
|
|
28331
29164
|
if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
|
|
28332
|
-
const markerData =
|
|
28333
|
-
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);
|
|
28334
29167
|
if (!alreadyPresent) {
|
|
28335
|
-
msg.content.parts.push(
|
|
29168
|
+
msg.content.parts.push(marker28);
|
|
28336
29169
|
}
|
|
28337
29170
|
await this.messageHistory.persistMessages({
|
|
28338
29171
|
messages: [msg],
|
|
@@ -30295,6 +31128,9 @@ async function insertTemporalGapMarkers({
|
|
|
30295
31128
|
}
|
|
30296
31129
|
|
|
30297
31130
|
// src/processors/observational-memory/processor.ts
|
|
31131
|
+
function asLiveTurn(value) {
|
|
31132
|
+
return value && typeof value.end === "function" ? value : void 0;
|
|
31133
|
+
}
|
|
30298
31134
|
function getOmObservabilityContext(args) {
|
|
30299
31135
|
if (!args.tracing || !args.tracingContext || !args.loggerVNext || !args.metrics) {
|
|
30300
31136
|
return void 0;
|
|
@@ -30412,7 +31248,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
30412
31248
|
});
|
|
30413
31249
|
return messageList;
|
|
30414
31250
|
}
|
|
30415
|
-
const activeTurn = state.__omTurn ?? this.turn;
|
|
31251
|
+
const activeTurn = asLiveTurn(state.__omTurn) ?? this.turn;
|
|
30416
31252
|
if (activeTurn && activeTurn.messageList !== messageList) {
|
|
30417
31253
|
await activeTurn.end().catch(() => {
|
|
30418
31254
|
});
|
|
@@ -30529,7 +31365,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
30529
31365
|
return this.engine.getTokenCounter().runWithModelContext(state.__omActorModelContext, async () => {
|
|
30530
31366
|
const memoryContext = memory.parseMemoryRequestContext(requestContext);
|
|
30531
31367
|
if (memoryContext?.memoryConfig?.readOnly) return messageList;
|
|
30532
|
-
const turn = state.__omTurn ?? this.turn;
|
|
31368
|
+
const turn = asLiveTurn(state.__omTurn) ?? this.turn;
|
|
30533
31369
|
if (turn) {
|
|
30534
31370
|
await turn.end();
|
|
30535
31371
|
this.turn = void 0;
|
|
@@ -30625,5 +31461,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
30625
31461
|
exports.stripObservationGroups = stripObservationGroups;
|
|
30626
31462
|
exports.summarizeConversation = summarizeConversation;
|
|
30627
31463
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
30628
|
-
//# sourceMappingURL=chunk-
|
|
30629
|
-
//# sourceMappingURL=chunk-
|
|
31464
|
+
//# sourceMappingURL=chunk-42LZUXJ3.cjs.map
|
|
31465
|
+
//# sourceMappingURL=chunk-42LZUXJ3.cjs.map
|