@mastra/memory 1.8.2 → 1.8.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/chunk-3PUO6DLX.js +439 -0
- package/dist/chunk-3PUO6DLX.js.map +1 -0
- package/dist/{chunk-23EXJLET.cjs → chunk-CK4U3AYR.cjs} +4 -4
- package/dist/{chunk-23EXJLET.cjs.map → chunk-CK4U3AYR.cjs.map} +1 -1
- package/dist/chunk-DAJJSFVA.cjs +441 -0
- package/dist/chunk-DAJJSFVA.cjs.map +1 -0
- package/dist/{chunk-BSDWQEU3.js → chunk-SVPZMV27.js} +4 -4
- package/dist/{chunk-BSDWQEU3.js.map → chunk-SVPZMV27.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +876 -246
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +870 -240
- package/dist/index.js.map +1 -1
- package/dist/{token-6GSAFR2W-TW2P7HCS.cjs → token-APYSY3BW-POD4OUWN.cjs} +14 -14
- package/dist/token-APYSY3BW-POD4OUWN.cjs.map +1 -0
- package/dist/{token-6GSAFR2W-ABXTQD64.js → token-APYSY3BW-YTVQELJT.js} +11 -11
- package/dist/token-APYSY3BW-YTVQELJT.js.map +1 -0
- package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs +10 -0
- package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs.map +1 -0
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js +8 -0
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js.map +1 -0
- package/package.json +8 -8
- package/dist/chunk-HJYHDIOC.js +0 -250
- package/dist/chunk-HJYHDIOC.js.map +0 -1
- package/dist/chunk-LIBOSOHM.cjs +0 -252
- package/dist/chunk-LIBOSOHM.cjs.map +0 -1
- package/dist/token-6GSAFR2W-ABXTQD64.js.map +0 -1
- package/dist/token-6GSAFR2W-TW2P7HCS.cjs.map +0 -1
- package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs +0 -10
- package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs.map +0 -1
- package/dist/token-util-NEHG7TUY-XQP3QSPX.js +0 -8
- package/dist/token-util-NEHG7TUY-XQP3QSPX.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCK4U3AYR_cjs = require('./chunk-CK4U3AYR.cjs');
|
|
4
4
|
var chunkIDRQZVB4_cjs = require('./chunk-IDRQZVB4.cjs');
|
|
5
5
|
var v3 = require('zod/v3');
|
|
6
6
|
var zod = require('zod');
|
|
@@ -179,13 +179,13 @@ var _AISDKError = class _AISDKError2 extends Error {
|
|
|
179
179
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
180
180
|
*/
|
|
181
181
|
constructor({
|
|
182
|
-
name:
|
|
182
|
+
name: name146,
|
|
183
183
|
message,
|
|
184
184
|
cause
|
|
185
185
|
}) {
|
|
186
186
|
super(message);
|
|
187
187
|
this[_a] = true;
|
|
188
|
-
this.name =
|
|
188
|
+
this.name = name146;
|
|
189
189
|
this.cause = cause;
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -196,8 +196,8 @@ var _AISDKError = class _AISDKError2 extends Error {
|
|
|
196
196
|
static isInstance(error) {
|
|
197
197
|
return _AISDKError2.hasMarker(error, marker);
|
|
198
198
|
}
|
|
199
|
-
static hasMarker(error,
|
|
200
|
-
const markerSymbol = Symbol.for(
|
|
199
|
+
static hasMarker(error, marker156) {
|
|
200
|
+
const markerSymbol = Symbol.for(marker156);
|
|
201
201
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
202
202
|
}
|
|
203
203
|
};
|
|
@@ -2379,12 +2379,12 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
2379
2379
|
return true;
|
|
2380
2380
|
}
|
|
2381
2381
|
function getGlobal(type) {
|
|
2382
|
-
var _a173,
|
|
2382
|
+
var _a173, _b19;
|
|
2383
2383
|
var globalVersion = (_a173 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a173 === void 0 ? void 0 : _a173.version;
|
|
2384
2384
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
2385
2385
|
return;
|
|
2386
2386
|
}
|
|
2387
|
-
return (
|
|
2387
|
+
return (_b19 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b19 === void 0 ? void 0 : _b19[type];
|
|
2388
2388
|
}
|
|
2389
2389
|
function unregisterGlobal(type, diag) {
|
|
2390
2390
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
|
|
@@ -2549,7 +2549,7 @@ var DiagAPI = (
|
|
|
2549
2549
|
}
|
|
2550
2550
|
var self = this;
|
|
2551
2551
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
2552
|
-
var _a173,
|
|
2552
|
+
var _a173, _b19, _c;
|
|
2553
2553
|
if (optionsOrLogLevel === void 0) {
|
|
2554
2554
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
2555
2555
|
}
|
|
@@ -2564,7 +2564,7 @@ var DiagAPI = (
|
|
|
2564
2564
|
};
|
|
2565
2565
|
}
|
|
2566
2566
|
var oldLogger = getGlobal("diag");
|
|
2567
|
-
var newLogger = createLogLevelDiagLogger((
|
|
2567
|
+
var newLogger = createLogLevelDiagLogger((_b19 = optionsOrLogLevel.logLevel) !== null && _b19 !== void 0 ? _b19 : DiagLogLevel.INFO, logger);
|
|
2568
2568
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
2569
2569
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
2570
2570
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
@@ -3525,8 +3525,8 @@ var dataContentSchema = zod.z.union([
|
|
|
3525
3525
|
zod.z.custom(
|
|
3526
3526
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
3527
3527
|
(value) => {
|
|
3528
|
-
var _a173,
|
|
3529
|
-
return (
|
|
3528
|
+
var _a173, _b19;
|
|
3529
|
+
return (_b19 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b19 : false;
|
|
3530
3530
|
},
|
|
3531
3531
|
{ message: "Must be a Buffer" }
|
|
3532
3532
|
)
|
|
@@ -4138,7 +4138,8 @@ function trimStartOfStream() {
|
|
|
4138
4138
|
var marker17 = "vercel.ai.error";
|
|
4139
4139
|
var symbol17 = Symbol.for(marker17);
|
|
4140
4140
|
var _a17;
|
|
4141
|
-
var
|
|
4141
|
+
var _b;
|
|
4142
|
+
var AISDKError2 = class _AISDKError3 extends (_b = Error, _a17 = symbol17, _b) {
|
|
4142
4143
|
/**
|
|
4143
4144
|
* Creates an AI SDK Error.
|
|
4144
4145
|
*
|
|
@@ -4148,13 +4149,13 @@ var _AISDKError3 = class _AISDKError22 extends Error {
|
|
|
4148
4149
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
4149
4150
|
*/
|
|
4150
4151
|
constructor({
|
|
4151
|
-
name:
|
|
4152
|
+
name: name1422,
|
|
4152
4153
|
message,
|
|
4153
4154
|
cause
|
|
4154
4155
|
}) {
|
|
4155
4156
|
super(message);
|
|
4156
4157
|
this[_a17] = true;
|
|
4157
|
-
this.name =
|
|
4158
|
+
this.name = name1422;
|
|
4158
4159
|
this.cause = cause;
|
|
4159
4160
|
}
|
|
4160
4161
|
/**
|
|
@@ -4163,20 +4164,19 @@ var _AISDKError3 = class _AISDKError22 extends Error {
|
|
|
4163
4164
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
4164
4165
|
*/
|
|
4165
4166
|
static isInstance(error) {
|
|
4166
|
-
return
|
|
4167
|
+
return _AISDKError3.hasMarker(error, marker17);
|
|
4167
4168
|
}
|
|
4168
|
-
static hasMarker(error,
|
|
4169
|
-
const markerSymbol = Symbol.for(
|
|
4169
|
+
static hasMarker(error, marker1522) {
|
|
4170
|
+
const markerSymbol = Symbol.for(marker1522);
|
|
4170
4171
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
4171
4172
|
}
|
|
4172
4173
|
};
|
|
4173
|
-
_a17 = symbol17;
|
|
4174
|
-
var AISDKError2 = _AISDKError3;
|
|
4175
4174
|
var name17 = "AI_APICallError";
|
|
4176
4175
|
var marker23 = `vercel.ai.error.${name17}`;
|
|
4177
4176
|
var symbol23 = Symbol.for(marker23);
|
|
4178
4177
|
var _a23;
|
|
4179
|
-
var
|
|
4178
|
+
var _b2;
|
|
4179
|
+
var APICallError2 = class extends (_b2 = AISDKError2, _a23 = symbol23, _b2) {
|
|
4180
4180
|
constructor({
|
|
4181
4181
|
message,
|
|
4182
4182
|
url,
|
|
@@ -4206,12 +4206,12 @@ var APICallError2 = class extends AISDKError2 {
|
|
|
4206
4206
|
return AISDKError2.hasMarker(error, marker23);
|
|
4207
4207
|
}
|
|
4208
4208
|
};
|
|
4209
|
-
_a23 = symbol23;
|
|
4210
4209
|
var name23 = "AI_EmptyResponseBodyError";
|
|
4211
4210
|
var marker33 = `vercel.ai.error.${name23}`;
|
|
4212
4211
|
var symbol33 = Symbol.for(marker33);
|
|
4213
4212
|
var _a33;
|
|
4214
|
-
var
|
|
4213
|
+
var _b3;
|
|
4214
|
+
var EmptyResponseBodyError = class extends (_b3 = AISDKError2, _a33 = symbol33, _b3) {
|
|
4215
4215
|
// used in isInstance
|
|
4216
4216
|
constructor({ message = "Empty response body" } = {}) {
|
|
4217
4217
|
super({ name: name23, message });
|
|
@@ -4221,7 +4221,6 @@ var EmptyResponseBodyError = class extends AISDKError2 {
|
|
|
4221
4221
|
return AISDKError2.hasMarker(error, marker33);
|
|
4222
4222
|
}
|
|
4223
4223
|
};
|
|
4224
|
-
_a33 = symbol33;
|
|
4225
4224
|
function getErrorMessage3(error) {
|
|
4226
4225
|
if (error == null) {
|
|
4227
4226
|
return "unknown error";
|
|
@@ -4238,7 +4237,8 @@ var name33 = "AI_InvalidArgumentError";
|
|
|
4238
4237
|
var marker43 = `vercel.ai.error.${name33}`;
|
|
4239
4238
|
var symbol43 = Symbol.for(marker43);
|
|
4240
4239
|
var _a43;
|
|
4241
|
-
var
|
|
4240
|
+
var _b4;
|
|
4241
|
+
var InvalidArgumentError3 = class extends (_b4 = AISDKError2, _a43 = symbol43, _b4) {
|
|
4242
4242
|
constructor({
|
|
4243
4243
|
message,
|
|
4244
4244
|
cause,
|
|
@@ -4252,12 +4252,12 @@ var InvalidArgumentError3 = class extends AISDKError2 {
|
|
|
4252
4252
|
return AISDKError2.hasMarker(error, marker43);
|
|
4253
4253
|
}
|
|
4254
4254
|
};
|
|
4255
|
-
_a43 = symbol43;
|
|
4256
4255
|
var name63 = "AI_JSONParseError";
|
|
4257
4256
|
var marker73 = `vercel.ai.error.${name63}`;
|
|
4258
4257
|
var symbol73 = Symbol.for(marker73);
|
|
4259
4258
|
var _a73;
|
|
4260
|
-
var
|
|
4259
|
+
var _b7;
|
|
4260
|
+
var JSONParseError2 = class extends (_b7 = AISDKError2, _a73 = symbol73, _b7) {
|
|
4261
4261
|
constructor({ text: text4, cause }) {
|
|
4262
4262
|
super({
|
|
4263
4263
|
name: name63,
|
|
@@ -4272,12 +4272,12 @@ Error message: ${getErrorMessage3(cause)}`,
|
|
|
4272
4272
|
return AISDKError2.hasMarker(error, marker73);
|
|
4273
4273
|
}
|
|
4274
4274
|
};
|
|
4275
|
-
_a73 = symbol73;
|
|
4276
4275
|
var name123 = "AI_TypeValidationError";
|
|
4277
4276
|
var marker133 = `vercel.ai.error.${name123}`;
|
|
4278
4277
|
var symbol133 = Symbol.for(marker133);
|
|
4279
4278
|
var _a133;
|
|
4280
|
-
var
|
|
4279
|
+
var _b13;
|
|
4280
|
+
var TypeValidationError2 = class _TypeValidationError3 extends (_b13 = AISDKError2, _a133 = symbol133, _b13) {
|
|
4281
4281
|
constructor({ value, cause }) {
|
|
4282
4282
|
super({
|
|
4283
4283
|
name: name123,
|
|
@@ -4305,11 +4305,9 @@ Error message: ${getErrorMessage3(cause)}`,
|
|
|
4305
4305
|
value,
|
|
4306
4306
|
cause
|
|
4307
4307
|
}) {
|
|
4308
|
-
return
|
|
4308
|
+
return _TypeValidationError3.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError3({ value, cause });
|
|
4309
4309
|
}
|
|
4310
4310
|
};
|
|
4311
|
-
_a133 = symbol133;
|
|
4312
|
-
var TypeValidationError2 = _TypeValidationError3;
|
|
4313
4311
|
var ParseError = class extends Error {
|
|
4314
4312
|
constructor(message, options) {
|
|
4315
4313
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -4540,14 +4538,14 @@ function handleFetchError({
|
|
|
4540
4538
|
return error;
|
|
4541
4539
|
}
|
|
4542
4540
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
4543
|
-
var
|
|
4541
|
+
var _a224, _b222, _c;
|
|
4544
4542
|
if (globalThisAny.window) {
|
|
4545
4543
|
return `runtime/browser`;
|
|
4546
4544
|
}
|
|
4547
|
-
if ((
|
|
4545
|
+
if ((_a224 = globalThisAny.navigator) == null ? void 0 : _a224.userAgent) {
|
|
4548
4546
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
4549
4547
|
}
|
|
4550
|
-
if ((_c = (
|
|
4548
|
+
if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
|
|
4551
4549
|
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
4552
4550
|
}
|
|
4553
4551
|
if (globalThisAny.EdgeRuntime) {
|
|
@@ -4585,7 +4583,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
4585
4583
|
);
|
|
4586
4584
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
4587
4585
|
}
|
|
4588
|
-
var VERSION2 = "3.0.
|
|
4586
|
+
var VERSION2 = "3.0.22";
|
|
4589
4587
|
var getOriginalFetch = () => globalThis.fetch;
|
|
4590
4588
|
var getFromApi = async ({
|
|
4591
4589
|
url,
|
|
@@ -4670,8 +4668,8 @@ function loadOptionalSetting({
|
|
|
4670
4668
|
}
|
|
4671
4669
|
return settingValue;
|
|
4672
4670
|
}
|
|
4673
|
-
var suspectProtoRx = /"
|
|
4674
|
-
var suspectConstructorRx = /"
|
|
4671
|
+
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
4672
|
+
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
4675
4673
|
function _parse(text4) {
|
|
4676
4674
|
const obj = JSON.parse(text4);
|
|
4677
4675
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -4691,7 +4689,7 @@ function filter(obj) {
|
|
|
4691
4689
|
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
4692
4690
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
4693
4691
|
}
|
|
4694
|
-
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
4692
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
4695
4693
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
4696
4694
|
}
|
|
4697
4695
|
for (const key in node) {
|
|
@@ -4927,6 +4925,36 @@ var postToApi = async ({
|
|
|
4927
4925
|
throw handleFetchError({ error, url, requestBodyValues: body.values });
|
|
4928
4926
|
}
|
|
4929
4927
|
};
|
|
4928
|
+
function tool(tool22) {
|
|
4929
|
+
return tool22;
|
|
4930
|
+
}
|
|
4931
|
+
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
4932
|
+
id,
|
|
4933
|
+
name: name224,
|
|
4934
|
+
inputSchema,
|
|
4935
|
+
outputSchema: outputSchema3
|
|
4936
|
+
}) {
|
|
4937
|
+
return ({
|
|
4938
|
+
execute,
|
|
4939
|
+
toModelOutput,
|
|
4940
|
+
onInputStart,
|
|
4941
|
+
onInputDelta,
|
|
4942
|
+
onInputAvailable,
|
|
4943
|
+
...args
|
|
4944
|
+
}) => tool({
|
|
4945
|
+
type: "provider-defined",
|
|
4946
|
+
id,
|
|
4947
|
+
name: name224,
|
|
4948
|
+
args,
|
|
4949
|
+
inputSchema,
|
|
4950
|
+
outputSchema: outputSchema3,
|
|
4951
|
+
execute,
|
|
4952
|
+
toModelOutput,
|
|
4953
|
+
onInputStart,
|
|
4954
|
+
onInputDelta,
|
|
4955
|
+
onInputAvailable
|
|
4956
|
+
});
|
|
4957
|
+
}
|
|
4930
4958
|
async function resolve(value) {
|
|
4931
4959
|
if (typeof value === "function") {
|
|
4932
4960
|
value = value();
|
|
@@ -5024,6 +5052,31 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
|
5024
5052
|
rawValue: parsedResult.rawValue
|
|
5025
5053
|
};
|
|
5026
5054
|
};
|
|
5055
|
+
function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
|
|
5056
|
+
if (jsonSchema22.type === "object") {
|
|
5057
|
+
jsonSchema22.additionalProperties = false;
|
|
5058
|
+
const properties = jsonSchema22.properties;
|
|
5059
|
+
if (properties != null) {
|
|
5060
|
+
for (const property in properties) {
|
|
5061
|
+
properties[property] = addAdditionalPropertiesToJsonSchema(
|
|
5062
|
+
properties[property]
|
|
5063
|
+
);
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
if (jsonSchema22.type === "array" && jsonSchema22.items != null) {
|
|
5068
|
+
if (Array.isArray(jsonSchema22.items)) {
|
|
5069
|
+
jsonSchema22.items = jsonSchema22.items.map(
|
|
5070
|
+
(item) => addAdditionalPropertiesToJsonSchema(item)
|
|
5071
|
+
);
|
|
5072
|
+
} else {
|
|
5073
|
+
jsonSchema22.items = addAdditionalPropertiesToJsonSchema(
|
|
5074
|
+
jsonSchema22.items
|
|
5075
|
+
);
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
return jsonSchema22;
|
|
5079
|
+
}
|
|
5027
5080
|
var getRelativePath2 = (pathA, pathB) => {
|
|
5028
5081
|
let i = 0;
|
|
5029
5082
|
for (; i < pathA.length && i < pathB.length; i++) {
|
|
@@ -5066,11 +5119,11 @@ function parseAnyDef2() {
|
|
|
5066
5119
|
return {};
|
|
5067
5120
|
}
|
|
5068
5121
|
function parseArrayDef2(def, refs) {
|
|
5069
|
-
var
|
|
5122
|
+
var _a224, _b222, _c;
|
|
5070
5123
|
const res = {
|
|
5071
5124
|
type: "array"
|
|
5072
5125
|
};
|
|
5073
|
-
if (((
|
|
5126
|
+
if (((_a224 = def.type) == null ? void 0 : _a224._def) && ((_c = (_b222 = def.type) == null ? void 0 : _b222._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
5074
5127
|
res.items = parseDef2(def.type._def, {
|
|
5075
5128
|
...refs,
|
|
5076
5129
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -5429,8 +5482,8 @@ function escapeNonAlphaNumeric2(source) {
|
|
|
5429
5482
|
return result;
|
|
5430
5483
|
}
|
|
5431
5484
|
function addFormat2(schema, value, message, refs) {
|
|
5432
|
-
var
|
|
5433
|
-
if (schema.format || ((
|
|
5485
|
+
var _a224;
|
|
5486
|
+
if (schema.format || ((_a224 = schema.anyOf) == null ? void 0 : _a224.some((x) => x.format))) {
|
|
5434
5487
|
if (!schema.anyOf) {
|
|
5435
5488
|
schema.anyOf = [];
|
|
5436
5489
|
}
|
|
@@ -5449,8 +5502,8 @@ function addFormat2(schema, value, message, refs) {
|
|
|
5449
5502
|
}
|
|
5450
5503
|
}
|
|
5451
5504
|
function addPattern2(schema, regex, message, refs) {
|
|
5452
|
-
var
|
|
5453
|
-
if (schema.pattern || ((
|
|
5505
|
+
var _a224;
|
|
5506
|
+
if (schema.pattern || ((_a224 = schema.allOf) == null ? void 0 : _a224.some((x) => x.pattern))) {
|
|
5454
5507
|
if (!schema.allOf) {
|
|
5455
5508
|
schema.allOf = [];
|
|
5456
5509
|
}
|
|
@@ -5469,7 +5522,7 @@ function addPattern2(schema, regex, message, refs) {
|
|
|
5469
5522
|
}
|
|
5470
5523
|
}
|
|
5471
5524
|
function stringifyRegExpWithFlags2(regex, refs) {
|
|
5472
|
-
var
|
|
5525
|
+
var _a224;
|
|
5473
5526
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
5474
5527
|
return regex.source;
|
|
5475
5528
|
}
|
|
@@ -5499,7 +5552,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
5499
5552
|
pattern += source[i];
|
|
5500
5553
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
5501
5554
|
inCharRange = false;
|
|
5502
|
-
} else if (source[i + 1] === "-" && ((
|
|
5555
|
+
} else if (source[i + 1] === "-" && ((_a224 = source[i + 2]) == null ? void 0 : _a224.match(/[a-z]/))) {
|
|
5503
5556
|
pattern += source[i];
|
|
5504
5557
|
inCharRange = true;
|
|
5505
5558
|
} else {
|
|
@@ -5541,15 +5594,15 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
5541
5594
|
return pattern;
|
|
5542
5595
|
}
|
|
5543
5596
|
function parseRecordDef2(def, refs) {
|
|
5544
|
-
var
|
|
5597
|
+
var _a224, _b222, _c, _d, _e, _f;
|
|
5545
5598
|
const schema = {
|
|
5546
5599
|
type: "object",
|
|
5547
|
-
additionalProperties: (
|
|
5600
|
+
additionalProperties: (_a224 = parseDef2(def.valueType._def, {
|
|
5548
5601
|
...refs,
|
|
5549
5602
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
5550
|
-
})) != null ?
|
|
5603
|
+
})) != null ? _a224 : refs.allowedAdditionalProperties
|
|
5551
5604
|
};
|
|
5552
|
-
if (((
|
|
5605
|
+
if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
5553
5606
|
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
5554
5607
|
return {
|
|
5555
5608
|
...schema,
|
|
@@ -5804,8 +5857,8 @@ function safeIsOptional2(schema) {
|
|
|
5804
5857
|
}
|
|
5805
5858
|
}
|
|
5806
5859
|
var parseOptionalDef2 = (def, refs) => {
|
|
5807
|
-
var
|
|
5808
|
-
if (refs.currentPath.toString() === ((
|
|
5860
|
+
var _a224;
|
|
5861
|
+
if (refs.currentPath.toString() === ((_a224 = refs.propertyPath) == null ? void 0 : _a224.toString())) {
|
|
5809
5862
|
return parseDef2(def.innerType._def, refs);
|
|
5810
5863
|
}
|
|
5811
5864
|
const innerSchema = parseDef2(def.innerType._def, {
|
|
@@ -5975,10 +6028,10 @@ var selectParser2 = (def, typeName, refs) => {
|
|
|
5975
6028
|
}
|
|
5976
6029
|
};
|
|
5977
6030
|
function parseDef2(def, refs, forceResolution = false) {
|
|
5978
|
-
var
|
|
6031
|
+
var _a224;
|
|
5979
6032
|
const seenItem = refs.seen.get(def);
|
|
5980
6033
|
if (refs.override) {
|
|
5981
|
-
const overrideResult = (
|
|
6034
|
+
const overrideResult = (_a224 = refs.override) == null ? void 0 : _a224.call(
|
|
5982
6035
|
refs,
|
|
5983
6036
|
def,
|
|
5984
6037
|
refs,
|
|
@@ -6044,11 +6097,11 @@ var getRefs2 = (options) => {
|
|
|
6044
6097
|
currentPath,
|
|
6045
6098
|
propertyPath: void 0,
|
|
6046
6099
|
seen: new Map(
|
|
6047
|
-
Object.entries(_options.definitions).map(([
|
|
6100
|
+
Object.entries(_options.definitions).map(([name224, def]) => [
|
|
6048
6101
|
def._def,
|
|
6049
6102
|
{
|
|
6050
6103
|
def: def._def,
|
|
6051
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
6104
|
+
path: [..._options.basePath, _options.definitionPath, name224],
|
|
6052
6105
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
6053
6106
|
jsonSchema: void 0
|
|
6054
6107
|
}
|
|
@@ -6057,50 +6110,50 @@ var getRefs2 = (options) => {
|
|
|
6057
6110
|
};
|
|
6058
6111
|
};
|
|
6059
6112
|
var zodToJsonSchema2 = (schema, options) => {
|
|
6060
|
-
var
|
|
6113
|
+
var _a224;
|
|
6061
6114
|
const refs = getRefs2(options);
|
|
6062
6115
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
6063
|
-
(acc, [
|
|
6064
|
-
var
|
|
6116
|
+
(acc, [name324, schema2]) => {
|
|
6117
|
+
var _a324;
|
|
6065
6118
|
return {
|
|
6066
6119
|
...acc,
|
|
6067
|
-
[
|
|
6120
|
+
[name324]: (_a324 = parseDef2(
|
|
6068
6121
|
schema2._def,
|
|
6069
6122
|
{
|
|
6070
6123
|
...refs,
|
|
6071
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
6124
|
+
currentPath: [...refs.basePath, refs.definitionPath, name324]
|
|
6072
6125
|
},
|
|
6073
6126
|
true
|
|
6074
|
-
)) != null ?
|
|
6127
|
+
)) != null ? _a324 : parseAnyDef2()
|
|
6075
6128
|
};
|
|
6076
6129
|
},
|
|
6077
6130
|
{}
|
|
6078
6131
|
) : void 0;
|
|
6079
|
-
const
|
|
6080
|
-
const main = (
|
|
6132
|
+
const name224 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
6133
|
+
const main = (_a224 = parseDef2(
|
|
6081
6134
|
schema._def,
|
|
6082
|
-
|
|
6135
|
+
name224 === void 0 ? refs : {
|
|
6083
6136
|
...refs,
|
|
6084
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
6137
|
+
currentPath: [...refs.basePath, refs.definitionPath, name224]
|
|
6085
6138
|
},
|
|
6086
6139
|
false
|
|
6087
|
-
)) != null ?
|
|
6140
|
+
)) != null ? _a224 : parseAnyDef2();
|
|
6088
6141
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
6089
6142
|
if (title !== void 0) {
|
|
6090
6143
|
main.title = title;
|
|
6091
6144
|
}
|
|
6092
|
-
const combined =
|
|
6145
|
+
const combined = name224 === void 0 ? definitions ? {
|
|
6093
6146
|
...main,
|
|
6094
6147
|
[refs.definitionPath]: definitions
|
|
6095
6148
|
} : main : {
|
|
6096
6149
|
$ref: [
|
|
6097
6150
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
6098
6151
|
refs.definitionPath,
|
|
6099
|
-
|
|
6152
|
+
name224
|
|
6100
6153
|
].join("/"),
|
|
6101
6154
|
[refs.definitionPath]: {
|
|
6102
6155
|
...definitions,
|
|
6103
|
-
[
|
|
6156
|
+
[name224]: main
|
|
6104
6157
|
}
|
|
6105
6158
|
};
|
|
6106
6159
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -6108,8 +6161,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
6108
6161
|
};
|
|
6109
6162
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
6110
6163
|
function zod3Schema(zodSchema22, options) {
|
|
6111
|
-
var
|
|
6112
|
-
const useReferences = (
|
|
6164
|
+
var _a224;
|
|
6165
|
+
const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
|
|
6113
6166
|
return jsonSchema2(
|
|
6114
6167
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
6115
6168
|
() => zod_to_json_schema_default(zodSchema22, {
|
|
@@ -6124,15 +6177,17 @@ function zod3Schema(zodSchema22, options) {
|
|
|
6124
6177
|
);
|
|
6125
6178
|
}
|
|
6126
6179
|
function zod4Schema(zodSchema22, options) {
|
|
6127
|
-
var
|
|
6128
|
-
const useReferences = (
|
|
6180
|
+
var _a224;
|
|
6181
|
+
const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
|
|
6129
6182
|
return jsonSchema2(
|
|
6130
6183
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
6131
|
-
() =>
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6184
|
+
() => addAdditionalPropertiesToJsonSchema(
|
|
6185
|
+
z4__namespace.toJSONSchema(zodSchema22, {
|
|
6186
|
+
target: "draft-7",
|
|
6187
|
+
io: "input",
|
|
6188
|
+
reused: useReferences ? "ref" : "inline"
|
|
6189
|
+
})
|
|
6190
|
+
),
|
|
6136
6191
|
{
|
|
6137
6192
|
validate: async (value) => {
|
|
6138
6193
|
const result = await z4__namespace.safeParseAsync(zodSchema22, value);
|
|
@@ -6152,6 +6207,15 @@ function zodSchema2(zodSchema22, options) {
|
|
|
6152
6207
|
}
|
|
6153
6208
|
}
|
|
6154
6209
|
var schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
6210
|
+
function lazySchema(createSchema) {
|
|
6211
|
+
let schema;
|
|
6212
|
+
return () => {
|
|
6213
|
+
if (schema == null) {
|
|
6214
|
+
schema = createSchema();
|
|
6215
|
+
}
|
|
6216
|
+
return schema;
|
|
6217
|
+
};
|
|
6218
|
+
}
|
|
6155
6219
|
function jsonSchema2(jsonSchema22, {
|
|
6156
6220
|
validate
|
|
6157
6221
|
} = {}) {
|
|
@@ -6181,8 +6245,8 @@ function asSchema2(schema) {
|
|
|
6181
6245
|
function withoutTrailingSlash(url) {
|
|
6182
6246
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
6183
6247
|
}
|
|
6184
|
-
var require_get_context =
|
|
6185
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.0
|
|
6248
|
+
var require_get_context = chunkCK4U3AYR_cjs.__commonJS({
|
|
6249
|
+
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
|
|
6186
6250
|
var __defProp22 = Object.defineProperty;
|
|
6187
6251
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
6188
6252
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -6213,8 +6277,8 @@ var require_get_context = chunk23EXJLET_cjs.__commonJS({
|
|
|
6213
6277
|
}
|
|
6214
6278
|
}
|
|
6215
6279
|
});
|
|
6216
|
-
var require_get_vercel_oidc_token =
|
|
6217
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.0
|
|
6280
|
+
var require_get_vercel_oidc_token = chunkCK4U3AYR_cjs.__commonJS({
|
|
6281
|
+
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
|
|
6218
6282
|
var __defProp22 = Object.defineProperty;
|
|
6219
6283
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
6220
6284
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -6239,7 +6303,7 @@ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
|
|
|
6239
6303
|
});
|
|
6240
6304
|
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
6241
6305
|
var import_get_context = require_get_context();
|
|
6242
|
-
var import_token_error =
|
|
6306
|
+
var import_token_error = chunkCK4U3AYR_cjs.require_token_error();
|
|
6243
6307
|
async function getVercelOidcToken3() {
|
|
6244
6308
|
let token = "";
|
|
6245
6309
|
let err;
|
|
@@ -6250,19 +6314,23 @@ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
|
|
|
6250
6314
|
}
|
|
6251
6315
|
try {
|
|
6252
6316
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
6253
|
-
await import('./token-util-
|
|
6254
|
-
await import('./token-
|
|
6317
|
+
await import('./token-util-RMHT2CPJ-77HHGIQN.cjs'),
|
|
6318
|
+
await import('./token-APYSY3BW-POD4OUWN.cjs')
|
|
6255
6319
|
]);
|
|
6256
6320
|
if (!token || isExpired(getTokenPayload(token))) {
|
|
6257
6321
|
await refreshToken();
|
|
6258
6322
|
token = getVercelOidcTokenSync2();
|
|
6259
6323
|
}
|
|
6260
6324
|
} catch (error) {
|
|
6261
|
-
|
|
6262
|
-
|
|
6325
|
+
let message = err instanceof Error ? err.message : "";
|
|
6326
|
+
if (error instanceof Error) {
|
|
6327
|
+
message = `${message}
|
|
6263
6328
|
${error.message}`;
|
|
6264
6329
|
}
|
|
6265
|
-
|
|
6330
|
+
if (message) {
|
|
6331
|
+
throw new import_token_error.VercelOidcTokenError(message);
|
|
6332
|
+
}
|
|
6333
|
+
throw error;
|
|
6266
6334
|
}
|
|
6267
6335
|
return token;
|
|
6268
6336
|
}
|
|
@@ -6277,8 +6345,8 @@ ${error.message}`;
|
|
|
6277
6345
|
}
|
|
6278
6346
|
}
|
|
6279
6347
|
});
|
|
6280
|
-
var require_dist =
|
|
6281
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.0
|
|
6348
|
+
var require_dist = chunkCK4U3AYR_cjs.__commonJS({
|
|
6349
|
+
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
|
|
6282
6350
|
var __defProp22 = Object.defineProperty;
|
|
6283
6351
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
6284
6352
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -6307,13 +6375,13 @@ var require_dist = chunk23EXJLET_cjs.__commonJS({
|
|
|
6307
6375
|
var import_get_context = require_get_context();
|
|
6308
6376
|
}
|
|
6309
6377
|
});
|
|
6310
|
-
var import_oidc =
|
|
6311
|
-
var import_oidc2 =
|
|
6378
|
+
var import_oidc = chunkCK4U3AYR_cjs.__toESM(require_dist(), 1);
|
|
6379
|
+
var import_oidc2 = chunkCK4U3AYR_cjs.__toESM(require_dist(), 1);
|
|
6312
6380
|
var marker18 = "vercel.ai.gateway.error";
|
|
6313
6381
|
var symbol18 = Symbol.for(marker18);
|
|
6314
6382
|
var _a18;
|
|
6315
|
-
var
|
|
6316
|
-
var GatewayError = class _GatewayError extends (
|
|
6383
|
+
var _b16;
|
|
6384
|
+
var GatewayError = class _GatewayError extends (_b16 = Error, _a18 = symbol18, _b16) {
|
|
6317
6385
|
constructor({
|
|
6318
6386
|
message,
|
|
6319
6387
|
statusCode = 500,
|
|
@@ -6340,8 +6408,8 @@ var name18 = "GatewayAuthenticationError";
|
|
|
6340
6408
|
var marker24 = `vercel.ai.gateway.error.${name18}`;
|
|
6341
6409
|
var symbol24 = Symbol.for(marker24);
|
|
6342
6410
|
var _a24;
|
|
6343
|
-
var
|
|
6344
|
-
var GatewayAuthenticationError = class _GatewayAuthenticationError extends (
|
|
6411
|
+
var _b22;
|
|
6412
|
+
var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b22 = GatewayError, _a24 = symbol24, _b22) {
|
|
6345
6413
|
constructor({
|
|
6346
6414
|
message = "Authentication failed",
|
|
6347
6415
|
statusCode = 401,
|
|
@@ -6399,8 +6467,8 @@ var name24 = "GatewayInvalidRequestError";
|
|
|
6399
6467
|
var marker34 = `vercel.ai.gateway.error.${name24}`;
|
|
6400
6468
|
var symbol34 = Symbol.for(marker34);
|
|
6401
6469
|
var _a34;
|
|
6402
|
-
var
|
|
6403
|
-
var GatewayInvalidRequestError = class extends (
|
|
6470
|
+
var _b32;
|
|
6471
|
+
var GatewayInvalidRequestError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
|
|
6404
6472
|
constructor({
|
|
6405
6473
|
message = "Invalid request",
|
|
6406
6474
|
statusCode = 400,
|
|
@@ -6419,8 +6487,8 @@ var name34 = "GatewayRateLimitError";
|
|
|
6419
6487
|
var marker44 = `vercel.ai.gateway.error.${name34}`;
|
|
6420
6488
|
var symbol44 = Symbol.for(marker44);
|
|
6421
6489
|
var _a44;
|
|
6422
|
-
var
|
|
6423
|
-
var GatewayRateLimitError = class extends (
|
|
6490
|
+
var _b42;
|
|
6491
|
+
var GatewayRateLimitError = class extends (_b42 = GatewayError, _a44 = symbol44, _b42) {
|
|
6424
6492
|
constructor({
|
|
6425
6493
|
message = "Rate limit exceeded",
|
|
6426
6494
|
statusCode = 429,
|
|
@@ -6446,8 +6514,8 @@ var modelNotFoundParamSchema = lazyValidator(
|
|
|
6446
6514
|
)
|
|
6447
6515
|
);
|
|
6448
6516
|
var _a54;
|
|
6449
|
-
var
|
|
6450
|
-
var GatewayModelNotFoundError = class extends (
|
|
6517
|
+
var _b52;
|
|
6518
|
+
var GatewayModelNotFoundError = class extends (_b52 = GatewayError, _a54 = symbol54, _b52) {
|
|
6451
6519
|
constructor({
|
|
6452
6520
|
message = "Model not found",
|
|
6453
6521
|
statusCode = 404,
|
|
@@ -6468,8 +6536,8 @@ var name54 = "GatewayInternalServerError";
|
|
|
6468
6536
|
var marker64 = `vercel.ai.gateway.error.${name54}`;
|
|
6469
6537
|
var symbol64 = Symbol.for(marker64);
|
|
6470
6538
|
var _a64;
|
|
6471
|
-
var
|
|
6472
|
-
var GatewayInternalServerError = class extends (
|
|
6539
|
+
var _b62;
|
|
6540
|
+
var GatewayInternalServerError = class extends (_b62 = GatewayError, _a64 = symbol64, _b62) {
|
|
6473
6541
|
constructor({
|
|
6474
6542
|
message = "Internal server error",
|
|
6475
6543
|
statusCode = 500,
|
|
@@ -6488,8 +6556,8 @@ var name64 = "GatewayResponseError";
|
|
|
6488
6556
|
var marker74 = `vercel.ai.gateway.error.${name64}`;
|
|
6489
6557
|
var symbol74 = Symbol.for(marker74);
|
|
6490
6558
|
var _a74;
|
|
6491
|
-
var
|
|
6492
|
-
var GatewayResponseError = class extends (
|
|
6559
|
+
var _b72;
|
|
6560
|
+
var GatewayResponseError = class extends (_b72 = GatewayError, _a74 = symbol74, _b72) {
|
|
6493
6561
|
constructor({
|
|
6494
6562
|
message = "Invalid response from Gateway",
|
|
6495
6563
|
statusCode = 502,
|
|
@@ -6573,21 +6641,85 @@ var gatewayErrorResponseSchema = lazyValidator(
|
|
|
6573
6641
|
})
|
|
6574
6642
|
)
|
|
6575
6643
|
);
|
|
6576
|
-
|
|
6577
|
-
|
|
6644
|
+
var name74 = "GatewayTimeoutError";
|
|
6645
|
+
var marker84 = `vercel.ai.gateway.error.${name74}`;
|
|
6646
|
+
var symbol84 = Symbol.for(marker84);
|
|
6647
|
+
var _a84;
|
|
6648
|
+
var _b82;
|
|
6649
|
+
var GatewayTimeoutError = class _GatewayTimeoutError extends (_b82 = GatewayError, _a84 = symbol84, _b82) {
|
|
6650
|
+
constructor({
|
|
6651
|
+
message = "Request timed out",
|
|
6652
|
+
statusCode = 408,
|
|
6653
|
+
cause
|
|
6654
|
+
} = {}) {
|
|
6655
|
+
super({ message, statusCode, cause });
|
|
6656
|
+
this[_a84] = true;
|
|
6657
|
+
this.name = name74;
|
|
6658
|
+
this.type = "timeout_error";
|
|
6659
|
+
}
|
|
6660
|
+
static isInstance(error) {
|
|
6661
|
+
return GatewayError.hasMarker(error) && symbol84 in error;
|
|
6662
|
+
}
|
|
6663
|
+
/**
|
|
6664
|
+
* Creates a helpful timeout error message with troubleshooting guidance
|
|
6665
|
+
*/
|
|
6666
|
+
static createTimeoutError({
|
|
6667
|
+
originalMessage,
|
|
6668
|
+
statusCode = 408,
|
|
6669
|
+
cause
|
|
6670
|
+
}) {
|
|
6671
|
+
const message = `Gateway request timed out: ${originalMessage}
|
|
6672
|
+
|
|
6673
|
+
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
|
|
6674
|
+
return new _GatewayTimeoutError({
|
|
6675
|
+
message,
|
|
6676
|
+
statusCode,
|
|
6677
|
+
cause
|
|
6678
|
+
});
|
|
6679
|
+
}
|
|
6680
|
+
};
|
|
6681
|
+
function isTimeoutError(error) {
|
|
6682
|
+
if (!(error instanceof Error)) {
|
|
6683
|
+
return false;
|
|
6684
|
+
}
|
|
6685
|
+
const errorCode = error.code;
|
|
6686
|
+
if (typeof errorCode === "string") {
|
|
6687
|
+
const undiciTimeoutCodes = [
|
|
6688
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
6689
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
6690
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
6691
|
+
];
|
|
6692
|
+
return undiciTimeoutCodes.includes(errorCode);
|
|
6693
|
+
}
|
|
6694
|
+
return false;
|
|
6695
|
+
}
|
|
6696
|
+
async function asGatewayError(error, authMethod) {
|
|
6697
|
+
var _a932;
|
|
6578
6698
|
if (GatewayError.isInstance(error)) {
|
|
6579
6699
|
return error;
|
|
6580
6700
|
}
|
|
6701
|
+
if (isTimeoutError(error)) {
|
|
6702
|
+
return GatewayTimeoutError.createTimeoutError({
|
|
6703
|
+
originalMessage: error instanceof Error ? error.message : "Unknown error",
|
|
6704
|
+
cause: error
|
|
6705
|
+
});
|
|
6706
|
+
}
|
|
6581
6707
|
if (APICallError2.isInstance(error)) {
|
|
6582
|
-
|
|
6708
|
+
if (error.cause && isTimeoutError(error.cause)) {
|
|
6709
|
+
return GatewayTimeoutError.createTimeoutError({
|
|
6710
|
+
originalMessage: error.message,
|
|
6711
|
+
cause: error
|
|
6712
|
+
});
|
|
6713
|
+
}
|
|
6714
|
+
return await createGatewayErrorFromResponse({
|
|
6583
6715
|
response: extractApiCallResponse(error),
|
|
6584
|
-
statusCode: (
|
|
6716
|
+
statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
|
|
6585
6717
|
defaultMessage: "Gateway request failed",
|
|
6586
6718
|
cause: error,
|
|
6587
6719
|
authMethod
|
|
6588
6720
|
});
|
|
6589
6721
|
}
|
|
6590
|
-
return createGatewayErrorFromResponse({
|
|
6722
|
+
return await createGatewayErrorFromResponse({
|
|
6591
6723
|
response: {},
|
|
6592
6724
|
statusCode: 500,
|
|
6593
6725
|
defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
|
|
@@ -6868,7 +7000,7 @@ var GatewayEmbeddingModel = class {
|
|
|
6868
7000
|
abortSignal,
|
|
6869
7001
|
providerOptions
|
|
6870
7002
|
}) {
|
|
6871
|
-
var
|
|
7003
|
+
var _a932;
|
|
6872
7004
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
6873
7005
|
try {
|
|
6874
7006
|
const {
|
|
@@ -6899,7 +7031,7 @@ var GatewayEmbeddingModel = class {
|
|
|
6899
7031
|
});
|
|
6900
7032
|
return {
|
|
6901
7033
|
embeddings: responseBody.embeddings,
|
|
6902
|
-
usage: (
|
|
7034
|
+
usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
|
|
6903
7035
|
providerMetadata: responseBody.providerMetadata,
|
|
6904
7036
|
response: { headers: responseHeaders, body: rawValue }
|
|
6905
7037
|
};
|
|
@@ -6946,7 +7078,7 @@ var GatewayImageModel = class {
|
|
|
6946
7078
|
headers,
|
|
6947
7079
|
abortSignal
|
|
6948
7080
|
}) {
|
|
6949
|
-
var
|
|
7081
|
+
var _a932, _b93, _c, _d;
|
|
6950
7082
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
6951
7083
|
try {
|
|
6952
7084
|
const {
|
|
@@ -6981,16 +7113,23 @@ var GatewayImageModel = class {
|
|
|
6981
7113
|
return {
|
|
6982
7114
|
images: responseBody.images,
|
|
6983
7115
|
// Always base64 strings from server
|
|
6984
|
-
warnings: (
|
|
7116
|
+
warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
|
|
6985
7117
|
providerMetadata: responseBody.providerMetadata,
|
|
6986
7118
|
response: {
|
|
6987
7119
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6988
7120
|
modelId: this.modelId,
|
|
6989
7121
|
headers: responseHeaders
|
|
7122
|
+
},
|
|
7123
|
+
...responseBody.usage != null && {
|
|
7124
|
+
usage: {
|
|
7125
|
+
inputTokens: (_b93 = responseBody.usage.inputTokens) != null ? _b93 : void 0,
|
|
7126
|
+
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
|
|
7127
|
+
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
|
|
7128
|
+
}
|
|
6990
7129
|
}
|
|
6991
7130
|
};
|
|
6992
7131
|
} catch (error) {
|
|
6993
|
-
throw asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
7132
|
+
throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
6994
7133
|
}
|
|
6995
7134
|
}
|
|
6996
7135
|
getUrl() {
|
|
@@ -7006,6 +7145,11 @@ var GatewayImageModel = class {
|
|
|
7006
7145
|
var providerMetadataEntrySchema = z4.z.object({
|
|
7007
7146
|
images: z4.z.array(z4.z.unknown()).optional()
|
|
7008
7147
|
}).catchall(z4.z.unknown());
|
|
7148
|
+
var gatewayImageUsageSchema = z4.z.object({
|
|
7149
|
+
inputTokens: z4.z.number().nullish(),
|
|
7150
|
+
outputTokens: z4.z.number().nullish(),
|
|
7151
|
+
totalTokens: z4.z.number().nullish()
|
|
7152
|
+
});
|
|
7009
7153
|
var gatewayImageResponseSchema = z4.z.object({
|
|
7010
7154
|
images: z4.z.array(z4.z.string()),
|
|
7011
7155
|
// Always base64 strings over the wire
|
|
@@ -7015,21 +7159,196 @@ var gatewayImageResponseSchema = z4.z.object({
|
|
|
7015
7159
|
message: z4.z.string()
|
|
7016
7160
|
})
|
|
7017
7161
|
).optional(),
|
|
7018
|
-
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema).optional()
|
|
7162
|
+
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema).optional(),
|
|
7163
|
+
usage: gatewayImageUsageSchema.optional()
|
|
7164
|
+
});
|
|
7165
|
+
var parallelSearchInputSchema = lazySchema(
|
|
7166
|
+
() => zodSchema2(
|
|
7167
|
+
zod.z.object({
|
|
7168
|
+
objective: zod.z.string().describe(
|
|
7169
|
+
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
7170
|
+
),
|
|
7171
|
+
search_queries: zod.z.array(zod.z.string()).optional().describe(
|
|
7172
|
+
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
7173
|
+
),
|
|
7174
|
+
mode: zod.z.enum(["one-shot", "agentic"]).optional().describe(
|
|
7175
|
+
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
7176
|
+
),
|
|
7177
|
+
max_results: zod.z.number().optional().describe(
|
|
7178
|
+
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
7179
|
+
),
|
|
7180
|
+
source_policy: zod.z.object({
|
|
7181
|
+
include_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to include in search results."),
|
|
7182
|
+
exclude_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to exclude from search results."),
|
|
7183
|
+
after_date: zod.z.string().optional().describe(
|
|
7184
|
+
"Only include results published after this date (ISO 8601 format)."
|
|
7185
|
+
)
|
|
7186
|
+
}).optional().describe(
|
|
7187
|
+
"Source policy for controlling which domains to include/exclude and freshness."
|
|
7188
|
+
),
|
|
7189
|
+
excerpts: zod.z.object({
|
|
7190
|
+
max_chars_per_result: zod.z.number().optional().describe("Maximum characters per result."),
|
|
7191
|
+
max_chars_total: zod.z.number().optional().describe("Maximum total characters across all results.")
|
|
7192
|
+
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
7193
|
+
fetch_policy: zod.z.object({
|
|
7194
|
+
max_age_seconds: zod.z.number().optional().describe(
|
|
7195
|
+
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
7196
|
+
)
|
|
7197
|
+
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
7198
|
+
})
|
|
7199
|
+
)
|
|
7200
|
+
);
|
|
7201
|
+
var parallelSearchOutputSchema = lazySchema(
|
|
7202
|
+
() => zodSchema2(
|
|
7203
|
+
zod.z.union([
|
|
7204
|
+
// Success response
|
|
7205
|
+
zod.z.object({
|
|
7206
|
+
searchId: zod.z.string(),
|
|
7207
|
+
results: zod.z.array(
|
|
7208
|
+
zod.z.object({
|
|
7209
|
+
url: zod.z.string(),
|
|
7210
|
+
title: zod.z.string(),
|
|
7211
|
+
excerpt: zod.z.string(),
|
|
7212
|
+
publishDate: zod.z.string().nullable().optional(),
|
|
7213
|
+
relevanceScore: zod.z.number().optional()
|
|
7214
|
+
})
|
|
7215
|
+
)
|
|
7216
|
+
}),
|
|
7217
|
+
// Error response
|
|
7218
|
+
zod.z.object({
|
|
7219
|
+
error: zod.z.enum([
|
|
7220
|
+
"api_error",
|
|
7221
|
+
"rate_limit",
|
|
7222
|
+
"timeout",
|
|
7223
|
+
"invalid_input",
|
|
7224
|
+
"configuration_error",
|
|
7225
|
+
"unknown"
|
|
7226
|
+
]),
|
|
7227
|
+
statusCode: zod.z.number().optional(),
|
|
7228
|
+
message: zod.z.string()
|
|
7229
|
+
})
|
|
7230
|
+
])
|
|
7231
|
+
)
|
|
7232
|
+
);
|
|
7233
|
+
var parallelSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
7234
|
+
id: "gateway.parallel_search",
|
|
7235
|
+
name: "parallel_search",
|
|
7236
|
+
inputSchema: parallelSearchInputSchema,
|
|
7237
|
+
outputSchema: parallelSearchOutputSchema
|
|
7238
|
+
});
|
|
7239
|
+
var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
7240
|
+
var perplexitySearchInputSchema = lazySchema(
|
|
7241
|
+
() => zodSchema2(
|
|
7242
|
+
zod.z.object({
|
|
7243
|
+
query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
|
|
7244
|
+
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
7245
|
+
),
|
|
7246
|
+
max_results: zod.z.number().optional().describe(
|
|
7247
|
+
"Maximum number of search results to return (1-20, default: 10)"
|
|
7248
|
+
),
|
|
7249
|
+
max_tokens_per_page: zod.z.number().optional().describe(
|
|
7250
|
+
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
7251
|
+
),
|
|
7252
|
+
max_tokens: zod.z.number().optional().describe(
|
|
7253
|
+
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
7254
|
+
),
|
|
7255
|
+
country: zod.z.string().optional().describe(
|
|
7256
|
+
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
7257
|
+
),
|
|
7258
|
+
search_domain_filter: zod.z.array(zod.z.string()).optional().describe(
|
|
7259
|
+
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
7260
|
+
),
|
|
7261
|
+
search_language_filter: zod.z.array(zod.z.string()).optional().describe(
|
|
7262
|
+
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
7263
|
+
),
|
|
7264
|
+
search_after_date: zod.z.string().optional().describe(
|
|
7265
|
+
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
7266
|
+
),
|
|
7267
|
+
search_before_date: zod.z.string().optional().describe(
|
|
7268
|
+
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
7269
|
+
),
|
|
7270
|
+
last_updated_after_filter: zod.z.string().optional().describe(
|
|
7271
|
+
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
7272
|
+
),
|
|
7273
|
+
last_updated_before_filter: zod.z.string().optional().describe(
|
|
7274
|
+
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
7275
|
+
),
|
|
7276
|
+
search_recency_filter: zod.z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
7277
|
+
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
7278
|
+
)
|
|
7279
|
+
})
|
|
7280
|
+
)
|
|
7281
|
+
);
|
|
7282
|
+
var perplexitySearchOutputSchema = lazySchema(
|
|
7283
|
+
() => zodSchema2(
|
|
7284
|
+
zod.z.union([
|
|
7285
|
+
// Success response
|
|
7286
|
+
zod.z.object({
|
|
7287
|
+
results: zod.z.array(
|
|
7288
|
+
zod.z.object({
|
|
7289
|
+
title: zod.z.string(),
|
|
7290
|
+
url: zod.z.string(),
|
|
7291
|
+
snippet: zod.z.string(),
|
|
7292
|
+
date: zod.z.string().optional(),
|
|
7293
|
+
lastUpdated: zod.z.string().optional()
|
|
7294
|
+
})
|
|
7295
|
+
),
|
|
7296
|
+
id: zod.z.string()
|
|
7297
|
+
}),
|
|
7298
|
+
// Error response
|
|
7299
|
+
zod.z.object({
|
|
7300
|
+
error: zod.z.enum([
|
|
7301
|
+
"api_error",
|
|
7302
|
+
"rate_limit",
|
|
7303
|
+
"timeout",
|
|
7304
|
+
"invalid_input",
|
|
7305
|
+
"unknown"
|
|
7306
|
+
]),
|
|
7307
|
+
statusCode: zod.z.number().optional(),
|
|
7308
|
+
message: zod.z.string()
|
|
7309
|
+
})
|
|
7310
|
+
])
|
|
7311
|
+
)
|
|
7312
|
+
);
|
|
7313
|
+
var perplexitySearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
7314
|
+
id: "gateway.perplexity_search",
|
|
7315
|
+
name: "perplexity_search",
|
|
7316
|
+
inputSchema: perplexitySearchInputSchema,
|
|
7317
|
+
outputSchema: perplexitySearchOutputSchema
|
|
7019
7318
|
});
|
|
7319
|
+
var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
7320
|
+
var gatewayTools = {
|
|
7321
|
+
/**
|
|
7322
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
7323
|
+
*
|
|
7324
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
7325
|
+
* replacing multiple keyword searches with a single call for broad
|
|
7326
|
+
* or complex queries. Supports different search types for depth vs
|
|
7327
|
+
* breadth tradeoffs.
|
|
7328
|
+
*/
|
|
7329
|
+
parallelSearch,
|
|
7330
|
+
/**
|
|
7331
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
7332
|
+
* news, research papers, and articles.
|
|
7333
|
+
*
|
|
7334
|
+
* Provides ranked search results with advanced filtering options including
|
|
7335
|
+
* domain, language, date range, and recency filters.
|
|
7336
|
+
*/
|
|
7337
|
+
perplexitySearch
|
|
7338
|
+
};
|
|
7020
7339
|
async function getVercelRequestId() {
|
|
7021
|
-
var
|
|
7022
|
-
return (
|
|
7340
|
+
var _a932;
|
|
7341
|
+
return (_a932 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
|
|
7023
7342
|
}
|
|
7024
|
-
var VERSION3 = "2.0.
|
|
7343
|
+
var VERSION3 = "2.0.58";
|
|
7025
7344
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
7026
7345
|
function createGatewayProvider(options = {}) {
|
|
7027
|
-
var
|
|
7346
|
+
var _a932, _b93;
|
|
7028
7347
|
let pendingMetadata = null;
|
|
7029
7348
|
let metadataCache = null;
|
|
7030
|
-
const cacheRefreshMillis = (
|
|
7349
|
+
const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
|
|
7031
7350
|
let lastFetchTime = 0;
|
|
7032
|
-
const baseURL = (
|
|
7351
|
+
const baseURL = (_b93 = withoutTrailingSlash(options.baseURL)) != null ? _b93 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
7033
7352
|
const getHeaders = async () => {
|
|
7034
7353
|
const auth = await getGatewayAuthToken(options);
|
|
7035
7354
|
if (auth) {
|
|
@@ -7062,13 +7381,18 @@ function createGatewayProvider(options = {}) {
|
|
|
7062
7381
|
settingValue: void 0,
|
|
7063
7382
|
environmentVariableName: "VERCEL_REGION"
|
|
7064
7383
|
});
|
|
7384
|
+
const projectId = loadOptionalSetting({
|
|
7385
|
+
settingValue: void 0,
|
|
7386
|
+
environmentVariableName: "VERCEL_PROJECT_ID"
|
|
7387
|
+
});
|
|
7065
7388
|
return async () => {
|
|
7066
7389
|
const requestId = await getVercelRequestId();
|
|
7067
7390
|
return {
|
|
7068
7391
|
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
7069
7392
|
...environment && { "ai-o11y-environment": environment },
|
|
7070
7393
|
...region && { "ai-o11y-region": region },
|
|
7071
|
-
...requestId && { "ai-o11y-request-id": requestId }
|
|
7394
|
+
...requestId && { "ai-o11y-request-id": requestId },
|
|
7395
|
+
...projectId && { "ai-o11y-project-id": projectId }
|
|
7072
7396
|
};
|
|
7073
7397
|
};
|
|
7074
7398
|
};
|
|
@@ -7082,8 +7406,8 @@ function createGatewayProvider(options = {}) {
|
|
|
7082
7406
|
});
|
|
7083
7407
|
};
|
|
7084
7408
|
const getAvailableModels = async () => {
|
|
7085
|
-
var
|
|
7086
|
-
const now2 = (_c = (
|
|
7409
|
+
var _a1022, _b103, _c;
|
|
7410
|
+
const now2 = (_c = (_b103 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b103.call(_a1022).getTime()) != null ? _c : Date.now();
|
|
7087
7411
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
7088
7412
|
lastFetchTime = now2;
|
|
7089
7413
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -7143,6 +7467,7 @@ function createGatewayProvider(options = {}) {
|
|
|
7143
7467
|
o11yHeaders: createO11yHeaders()
|
|
7144
7468
|
});
|
|
7145
7469
|
};
|
|
7470
|
+
provider.tools = gatewayTools;
|
|
7146
7471
|
return provider;
|
|
7147
7472
|
}
|
|
7148
7473
|
var gateway = createGatewayProvider();
|
|
@@ -7260,12 +7585,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
|
|
|
7260
7585
|
return true;
|
|
7261
7586
|
}
|
|
7262
7587
|
function getGlobal2(type) {
|
|
7263
|
-
var _a163,
|
|
7588
|
+
var _a163, _b93;
|
|
7264
7589
|
var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
|
|
7265
7590
|
if (!globalVersion || !isCompatible2(globalVersion)) {
|
|
7266
7591
|
return;
|
|
7267
7592
|
}
|
|
7268
|
-
return (
|
|
7593
|
+
return (_b93 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b93 === void 0 ? void 0 : _b93[type];
|
|
7269
7594
|
}
|
|
7270
7595
|
function unregisterGlobal2(type, diag) {
|
|
7271
7596
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
|
|
@@ -7430,7 +7755,7 @@ var DiagAPI2 = (
|
|
|
7430
7755
|
}
|
|
7431
7756
|
var self = this;
|
|
7432
7757
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
7433
|
-
var _a163,
|
|
7758
|
+
var _a163, _b93, _c;
|
|
7434
7759
|
if (optionsOrLogLevel === void 0) {
|
|
7435
7760
|
optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
|
|
7436
7761
|
}
|
|
@@ -7445,7 +7770,7 @@ var DiagAPI2 = (
|
|
|
7445
7770
|
};
|
|
7446
7771
|
}
|
|
7447
7772
|
var oldLogger = getGlobal2("diag");
|
|
7448
|
-
var newLogger = createLogLevelDiagLogger2((
|
|
7773
|
+
var newLogger = createLogLevelDiagLogger2((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel2.INFO, logger);
|
|
7449
7774
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
7450
7775
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
7451
7776
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
@@ -7936,8 +8261,8 @@ var UnsupportedModelVersionError2 = class extends AISDKError2 {
|
|
|
7936
8261
|
this.modelId = options.modelId;
|
|
7937
8262
|
}
|
|
7938
8263
|
};
|
|
7939
|
-
var
|
|
7940
|
-
var marker144 = `vercel.ai.error.${
|
|
8264
|
+
var name143 = "AI_RetryError";
|
|
8265
|
+
var marker144 = `vercel.ai.error.${name143}`;
|
|
7941
8266
|
var symbol144 = Symbol.for(marker144);
|
|
7942
8267
|
var _a144;
|
|
7943
8268
|
var RetryError2 = class extends AISDKError2 {
|
|
@@ -7946,7 +8271,7 @@ var RetryError2 = class extends AISDKError2 {
|
|
|
7946
8271
|
reason,
|
|
7947
8272
|
errors
|
|
7948
8273
|
}) {
|
|
7949
|
-
super({ name:
|
|
8274
|
+
super({ name: name143, message });
|
|
7950
8275
|
this[_a144] = true;
|
|
7951
8276
|
this.reason = reason;
|
|
7952
8277
|
this.errors = errors;
|
|
@@ -7976,7 +8301,7 @@ function getGlobalProvider() {
|
|
|
7976
8301
|
var _a163;
|
|
7977
8302
|
return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
|
|
7978
8303
|
}
|
|
7979
|
-
var VERSION32 = "5.0.
|
|
8304
|
+
var VERSION32 = "5.0.154";
|
|
7980
8305
|
var dataContentSchema2 = z4.z.union([
|
|
7981
8306
|
z4.z.string(),
|
|
7982
8307
|
z4.z.instanceof(Uint8Array),
|
|
@@ -7984,8 +8309,8 @@ var dataContentSchema2 = z4.z.union([
|
|
|
7984
8309
|
z4.z.custom(
|
|
7985
8310
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
7986
8311
|
(value) => {
|
|
7987
|
-
var _a163,
|
|
7988
|
-
return (
|
|
8312
|
+
var _a163, _b93;
|
|
8313
|
+
return (_b93 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b93 : false;
|
|
7989
8314
|
},
|
|
7990
8315
|
{ message: "Must be a Buffer" }
|
|
7991
8316
|
)
|
|
@@ -9079,8 +9404,8 @@ var object2 = ({
|
|
|
9079
9404
|
var marker19 = "vercel.ai.error";
|
|
9080
9405
|
var symbol19 = Symbol.for(marker19);
|
|
9081
9406
|
var _a19;
|
|
9082
|
-
var
|
|
9083
|
-
var AISDKError3 = class _AISDKError4 extends (
|
|
9407
|
+
var _b17;
|
|
9408
|
+
var AISDKError3 = class _AISDKError4 extends (_b17 = Error, _a19 = symbol19, _b17) {
|
|
9084
9409
|
/**
|
|
9085
9410
|
* Creates an AI SDK Error.
|
|
9086
9411
|
*
|
|
@@ -9116,8 +9441,8 @@ var name19 = "AI_APICallError";
|
|
|
9116
9441
|
var marker25 = `vercel.ai.error.${name19}`;
|
|
9117
9442
|
var symbol25 = Symbol.for(marker25);
|
|
9118
9443
|
var _a25;
|
|
9119
|
-
var
|
|
9120
|
-
var APICallError3 = class extends (
|
|
9444
|
+
var _b23;
|
|
9445
|
+
var APICallError3 = class extends (_b23 = AISDKError3, _a25 = symbol25, _b23) {
|
|
9121
9446
|
constructor({
|
|
9122
9447
|
message,
|
|
9123
9448
|
url,
|
|
@@ -9151,8 +9476,8 @@ var name25 = "AI_EmptyResponseBodyError";
|
|
|
9151
9476
|
var marker35 = `vercel.ai.error.${name25}`;
|
|
9152
9477
|
var symbol35 = Symbol.for(marker35);
|
|
9153
9478
|
var _a35;
|
|
9154
|
-
var
|
|
9155
|
-
var EmptyResponseBodyError2 = class extends (
|
|
9479
|
+
var _b33;
|
|
9480
|
+
var EmptyResponseBodyError2 = class extends (_b33 = AISDKError3, _a35 = symbol35, _b33) {
|
|
9156
9481
|
// used in isInstance
|
|
9157
9482
|
constructor({ message = "Empty response body" } = {}) {
|
|
9158
9483
|
super({ name: name25, message });
|
|
@@ -9178,8 +9503,8 @@ var name35 = "AI_InvalidArgumentError";
|
|
|
9178
9503
|
var marker45 = `vercel.ai.error.${name35}`;
|
|
9179
9504
|
var symbol45 = Symbol.for(marker45);
|
|
9180
9505
|
var _a45;
|
|
9181
|
-
var
|
|
9182
|
-
var InvalidArgumentError4 = class extends (
|
|
9506
|
+
var _b43;
|
|
9507
|
+
var InvalidArgumentError4 = class extends (_b43 = AISDKError3, _a45 = symbol45, _b43) {
|
|
9183
9508
|
constructor({
|
|
9184
9509
|
message,
|
|
9185
9510
|
cause,
|
|
@@ -9197,8 +9522,8 @@ var name65 = "AI_JSONParseError";
|
|
|
9197
9522
|
var marker75 = `vercel.ai.error.${name65}`;
|
|
9198
9523
|
var symbol75 = Symbol.for(marker75);
|
|
9199
9524
|
var _a75;
|
|
9200
|
-
var
|
|
9201
|
-
var JSONParseError3 = class extends (
|
|
9525
|
+
var _b73;
|
|
9526
|
+
var JSONParseError3 = class extends (_b73 = AISDKError3, _a75 = symbol75, _b73) {
|
|
9202
9527
|
constructor({ text: text4, cause }) {
|
|
9203
9528
|
super({
|
|
9204
9529
|
name: name65,
|
|
@@ -9217,8 +9542,8 @@ var name125 = "AI_TypeValidationError";
|
|
|
9217
9542
|
var marker135 = `vercel.ai.error.${name125}`;
|
|
9218
9543
|
var symbol135 = Symbol.for(marker135);
|
|
9219
9544
|
var _a135;
|
|
9220
|
-
var
|
|
9221
|
-
var TypeValidationError3 = class _TypeValidationError4 extends (
|
|
9545
|
+
var _b132;
|
|
9546
|
+
var TypeValidationError3 = class _TypeValidationError4 extends (_b132 = AISDKError3, _a135 = symbol135, _b132) {
|
|
9222
9547
|
constructor({
|
|
9223
9548
|
value,
|
|
9224
9549
|
cause,
|
|
@@ -9269,8 +9594,8 @@ Error message: ${getErrorMessage4(cause)}`,
|
|
|
9269
9594
|
cause,
|
|
9270
9595
|
context: context2
|
|
9271
9596
|
}) {
|
|
9272
|
-
var _a1522,
|
|
9273
|
-
if (_TypeValidationError4.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? void 0 : _a1522.field) === (context2 == null ? void 0 : context2.field) && ((
|
|
9597
|
+
var _a1522, _b1522, _c;
|
|
9598
|
+
if (_TypeValidationError4.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? void 0 : _a1522.field) === (context2 == null ? void 0 : context2.field) && ((_b1522 = cause.context) == null ? void 0 : _b1522.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context2 == null ? void 0 : context2.entityId)) {
|
|
9274
9599
|
return cause;
|
|
9275
9600
|
}
|
|
9276
9601
|
return new _TypeValidationError4({ value, cause, context: context2 });
|
|
@@ -9587,7 +9912,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
9587
9912
|
);
|
|
9588
9913
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9589
9914
|
}
|
|
9590
|
-
var VERSION4 = "4.0.
|
|
9915
|
+
var VERSION4 = "4.0.19";
|
|
9591
9916
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
9592
9917
|
var getFromApi2 = async ({
|
|
9593
9918
|
url,
|
|
@@ -9672,8 +9997,8 @@ function loadOptionalSetting2({
|
|
|
9672
9997
|
}
|
|
9673
9998
|
return settingValue;
|
|
9674
9999
|
}
|
|
9675
|
-
var suspectProtoRx2 = /"
|
|
9676
|
-
var suspectConstructorRx2 = /"
|
|
10000
|
+
var suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
10001
|
+
var suspectConstructorRx2 = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
9677
10002
|
function _parse2(text4) {
|
|
9678
10003
|
const obj = JSON.parse(text4);
|
|
9679
10004
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -9693,7 +10018,7 @@ function filter2(obj) {
|
|
|
9693
10018
|
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
9694
10019
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9695
10020
|
}
|
|
9696
|
-
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
10021
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
9697
10022
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9698
10023
|
}
|
|
9699
10024
|
for (const key in node) {
|
|
@@ -9719,7 +10044,7 @@ function secureJsonParse2(text4) {
|
|
|
9719
10044
|
Error.stackTraceLimit = stackTraceLimit;
|
|
9720
10045
|
}
|
|
9721
10046
|
}
|
|
9722
|
-
function
|
|
10047
|
+
function addAdditionalPropertiesToJsonSchema2(jsonSchema22) {
|
|
9723
10048
|
if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
|
|
9724
10049
|
jsonSchema22.additionalProperties = false;
|
|
9725
10050
|
const { properties } = jsonSchema22;
|
|
@@ -9751,7 +10076,7 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
|
|
|
9751
10076
|
}
|
|
9752
10077
|
function visit(def) {
|
|
9753
10078
|
if (typeof def === "boolean") return def;
|
|
9754
|
-
return
|
|
10079
|
+
return addAdditionalPropertiesToJsonSchema2(def);
|
|
9755
10080
|
}
|
|
9756
10081
|
var ignoreOverride3 = /* @__PURE__ */ Symbol(
|
|
9757
10082
|
"Let zodToJsonSchema decide on which parser to use"
|
|
@@ -10836,7 +11161,7 @@ var zod3ToJsonSchema = (schema, options) => {
|
|
|
10836
11161
|
return combined;
|
|
10837
11162
|
};
|
|
10838
11163
|
var schemaSymbol3 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
10839
|
-
function
|
|
11164
|
+
function lazySchema2(createSchema) {
|
|
10840
11165
|
let schema;
|
|
10841
11166
|
return () => {
|
|
10842
11167
|
if (schema == null) {
|
|
@@ -10869,7 +11194,7 @@ function asSchema3(schema) {
|
|
|
10869
11194
|
}
|
|
10870
11195
|
function standardSchema(standardSchema2) {
|
|
10871
11196
|
return jsonSchema3(
|
|
10872
|
-
() =>
|
|
11197
|
+
() => addAdditionalPropertiesToJsonSchema2(
|
|
10873
11198
|
standardSchema2["~standard"].jsonSchema.input({
|
|
10874
11199
|
target: "draft-07"
|
|
10875
11200
|
})
|
|
@@ -10909,7 +11234,7 @@ function zod4Schema2(zodSchema22, options) {
|
|
|
10909
11234
|
const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
|
|
10910
11235
|
return jsonSchema3(
|
|
10911
11236
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
10912
|
-
() =>
|
|
11237
|
+
() => addAdditionalPropertiesToJsonSchema2(
|
|
10913
11238
|
z4__namespace.toJSONSchema(zodSchema22, {
|
|
10914
11239
|
target: "draft-7",
|
|
10915
11240
|
io: "input",
|
|
@@ -11115,8 +11440,8 @@ var postToApi2 = async ({
|
|
|
11115
11440
|
throw handleFetchError2({ error, url, requestBodyValues: body.values });
|
|
11116
11441
|
}
|
|
11117
11442
|
};
|
|
11118
|
-
function
|
|
11119
|
-
return
|
|
11443
|
+
function tool2(tool22) {
|
|
11444
|
+
return tool22;
|
|
11120
11445
|
}
|
|
11121
11446
|
function createProviderToolFactoryWithOutputSchema({
|
|
11122
11447
|
id,
|
|
@@ -11132,7 +11457,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
11132
11457
|
onInputDelta,
|
|
11133
11458
|
onInputAvailable,
|
|
11134
11459
|
...args
|
|
11135
|
-
}) =>
|
|
11460
|
+
}) => tool2({
|
|
11136
11461
|
type: "provider",
|
|
11137
11462
|
id,
|
|
11138
11463
|
args,
|
|
@@ -11382,8 +11707,8 @@ var import_oidc22 = chunkIDRQZVB4_cjs.__toESM(require_dist2(), 1);
|
|
|
11382
11707
|
var marker20 = "vercel.ai.gateway.error";
|
|
11383
11708
|
var symbol20 = Symbol.for(marker20);
|
|
11384
11709
|
var _a20;
|
|
11385
|
-
var
|
|
11386
|
-
var GatewayError2 = class _GatewayError2 extends (
|
|
11710
|
+
var _b18;
|
|
11711
|
+
var GatewayError2 = class _GatewayError2 extends (_b18 = Error, _a20 = symbol20, _b18) {
|
|
11387
11712
|
constructor({
|
|
11388
11713
|
message,
|
|
11389
11714
|
statusCode = 500,
|
|
@@ -11412,8 +11737,8 @@ var name20 = "GatewayAuthenticationError";
|
|
|
11412
11737
|
var marker26 = `vercel.ai.gateway.error.${name20}`;
|
|
11413
11738
|
var symbol26 = Symbol.for(marker26);
|
|
11414
11739
|
var _a26;
|
|
11415
|
-
var
|
|
11416
|
-
var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (
|
|
11740
|
+
var _b24;
|
|
11741
|
+
var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b24 = GatewayError2, _a26 = symbol26, _b24) {
|
|
11417
11742
|
constructor({
|
|
11418
11743
|
message = "Authentication failed",
|
|
11419
11744
|
statusCode = 401,
|
|
@@ -11474,8 +11799,8 @@ var name26 = "GatewayInvalidRequestError";
|
|
|
11474
11799
|
var marker36 = `vercel.ai.gateway.error.${name26}`;
|
|
11475
11800
|
var symbol36 = Symbol.for(marker36);
|
|
11476
11801
|
var _a36;
|
|
11477
|
-
var
|
|
11478
|
-
var GatewayInvalidRequestError2 = class extends (
|
|
11802
|
+
var _b34;
|
|
11803
|
+
var GatewayInvalidRequestError2 = class extends (_b34 = GatewayError2, _a36 = symbol36, _b34) {
|
|
11479
11804
|
constructor({
|
|
11480
11805
|
message = "Invalid request",
|
|
11481
11806
|
statusCode = 400,
|
|
@@ -11495,8 +11820,8 @@ var name36 = "GatewayRateLimitError";
|
|
|
11495
11820
|
var marker46 = `vercel.ai.gateway.error.${name36}`;
|
|
11496
11821
|
var symbol46 = Symbol.for(marker46);
|
|
11497
11822
|
var _a46;
|
|
11498
|
-
var
|
|
11499
|
-
var GatewayRateLimitError2 = class extends (
|
|
11823
|
+
var _b44;
|
|
11824
|
+
var GatewayRateLimitError2 = class extends (_b44 = GatewayError2, _a46 = symbol46, _b44) {
|
|
11500
11825
|
constructor({
|
|
11501
11826
|
message = "Rate limit exceeded",
|
|
11502
11827
|
statusCode = 429,
|
|
@@ -11515,7 +11840,7 @@ var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol4
|
|
|
11515
11840
|
var name46 = "GatewayModelNotFoundError";
|
|
11516
11841
|
var marker56 = `vercel.ai.gateway.error.${name46}`;
|
|
11517
11842
|
var symbol56 = Symbol.for(marker56);
|
|
11518
|
-
var modelNotFoundParamSchema2 =
|
|
11843
|
+
var modelNotFoundParamSchema2 = lazySchema2(
|
|
11519
11844
|
() => zodSchema3(
|
|
11520
11845
|
z4.z.object({
|
|
11521
11846
|
modelId: z4.z.string()
|
|
@@ -11523,8 +11848,8 @@ var modelNotFoundParamSchema2 = lazySchema(
|
|
|
11523
11848
|
)
|
|
11524
11849
|
);
|
|
11525
11850
|
var _a56;
|
|
11526
|
-
var
|
|
11527
|
-
var GatewayModelNotFoundError2 = class extends (
|
|
11851
|
+
var _b54;
|
|
11852
|
+
var GatewayModelNotFoundError2 = class extends (_b54 = GatewayError2, _a56 = symbol56, _b54) {
|
|
11528
11853
|
constructor({
|
|
11529
11854
|
message = "Model not found",
|
|
11530
11855
|
statusCode = 404,
|
|
@@ -11546,8 +11871,8 @@ var name56 = "GatewayInternalServerError";
|
|
|
11546
11871
|
var marker66 = `vercel.ai.gateway.error.${name56}`;
|
|
11547
11872
|
var symbol66 = Symbol.for(marker66);
|
|
11548
11873
|
var _a66;
|
|
11549
|
-
var
|
|
11550
|
-
var GatewayInternalServerError2 = class extends (
|
|
11874
|
+
var _b64;
|
|
11875
|
+
var GatewayInternalServerError2 = class extends (_b64 = GatewayError2, _a66 = symbol66, _b64) {
|
|
11551
11876
|
constructor({
|
|
11552
11877
|
message = "Internal server error",
|
|
11553
11878
|
statusCode = 500,
|
|
@@ -11567,8 +11892,8 @@ var name66 = "GatewayResponseError";
|
|
|
11567
11892
|
var marker76 = `vercel.ai.gateway.error.${name66}`;
|
|
11568
11893
|
var symbol76 = Symbol.for(marker76);
|
|
11569
11894
|
var _a76;
|
|
11570
|
-
var
|
|
11571
|
-
var GatewayResponseError2 = class extends (
|
|
11895
|
+
var _b74;
|
|
11896
|
+
var GatewayResponseError2 = class extends (_b74 = GatewayError2, _a76 = symbol76, _b74) {
|
|
11572
11897
|
constructor({
|
|
11573
11898
|
message = "Invalid response from Gateway",
|
|
11574
11899
|
statusCode = 502,
|
|
@@ -11595,7 +11920,7 @@ async function createGatewayErrorFromResponse2({
|
|
|
11595
11920
|
cause,
|
|
11596
11921
|
authMethod
|
|
11597
11922
|
}) {
|
|
11598
|
-
var
|
|
11923
|
+
var _a932;
|
|
11599
11924
|
const parseResult = await safeValidateTypes3({
|
|
11600
11925
|
value: response,
|
|
11601
11926
|
schema: gatewayErrorResponseSchema2
|
|
@@ -11614,7 +11939,7 @@ async function createGatewayErrorFromResponse2({
|
|
|
11614
11939
|
const validatedResponse = parseResult.value;
|
|
11615
11940
|
const errorType = validatedResponse.error.type;
|
|
11616
11941
|
const message = validatedResponse.error.message;
|
|
11617
|
-
const generationId = (
|
|
11942
|
+
const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
|
|
11618
11943
|
switch (errorType) {
|
|
11619
11944
|
case "authentication_error":
|
|
11620
11945
|
return GatewayAuthenticationError2.createContextualError({
|
|
@@ -11667,7 +11992,7 @@ async function createGatewayErrorFromResponse2({
|
|
|
11667
11992
|
});
|
|
11668
11993
|
}
|
|
11669
11994
|
}
|
|
11670
|
-
var gatewayErrorResponseSchema2 =
|
|
11995
|
+
var gatewayErrorResponseSchema2 = lazySchema2(
|
|
11671
11996
|
() => zodSchema3(
|
|
11672
11997
|
z4.z.object({
|
|
11673
11998
|
error: z4.z.object({
|
|
@@ -11680,21 +12005,88 @@ var gatewayErrorResponseSchema2 = lazySchema(
|
|
|
11680
12005
|
})
|
|
11681
12006
|
)
|
|
11682
12007
|
);
|
|
11683
|
-
|
|
11684
|
-
|
|
12008
|
+
var name76 = "GatewayTimeoutError";
|
|
12009
|
+
var marker86 = `vercel.ai.gateway.error.${name76}`;
|
|
12010
|
+
var symbol86 = Symbol.for(marker86);
|
|
12011
|
+
var _a86;
|
|
12012
|
+
var _b84;
|
|
12013
|
+
var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (_b84 = GatewayError2, _a86 = symbol86, _b84) {
|
|
12014
|
+
constructor({
|
|
12015
|
+
message = "Request timed out",
|
|
12016
|
+
statusCode = 408,
|
|
12017
|
+
cause,
|
|
12018
|
+
generationId
|
|
12019
|
+
} = {}) {
|
|
12020
|
+
super({ message, statusCode, cause, generationId });
|
|
12021
|
+
this[_a86] = true;
|
|
12022
|
+
this.name = name76;
|
|
12023
|
+
this.type = "timeout_error";
|
|
12024
|
+
}
|
|
12025
|
+
static isInstance(error) {
|
|
12026
|
+
return GatewayError2.hasMarker(error) && symbol86 in error;
|
|
12027
|
+
}
|
|
12028
|
+
/**
|
|
12029
|
+
* Creates a helpful timeout error message with troubleshooting guidance
|
|
12030
|
+
*/
|
|
12031
|
+
static createTimeoutError({
|
|
12032
|
+
originalMessage,
|
|
12033
|
+
statusCode = 408,
|
|
12034
|
+
cause,
|
|
12035
|
+
generationId
|
|
12036
|
+
}) {
|
|
12037
|
+
const message = `Gateway request timed out: ${originalMessage}
|
|
12038
|
+
|
|
12039
|
+
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
|
|
12040
|
+
return new _GatewayTimeoutError2({
|
|
12041
|
+
message,
|
|
12042
|
+
statusCode,
|
|
12043
|
+
cause,
|
|
12044
|
+
generationId
|
|
12045
|
+
});
|
|
12046
|
+
}
|
|
12047
|
+
};
|
|
12048
|
+
function isTimeoutError2(error) {
|
|
12049
|
+
if (!(error instanceof Error)) {
|
|
12050
|
+
return false;
|
|
12051
|
+
}
|
|
12052
|
+
const errorCode = error.code;
|
|
12053
|
+
if (typeof errorCode === "string") {
|
|
12054
|
+
const undiciTimeoutCodes = [
|
|
12055
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
12056
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
12057
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
12058
|
+
];
|
|
12059
|
+
return undiciTimeoutCodes.includes(errorCode);
|
|
12060
|
+
}
|
|
12061
|
+
return false;
|
|
12062
|
+
}
|
|
12063
|
+
async function asGatewayError2(error, authMethod) {
|
|
12064
|
+
var _a932;
|
|
11685
12065
|
if (GatewayError2.isInstance(error)) {
|
|
11686
12066
|
return error;
|
|
11687
12067
|
}
|
|
12068
|
+
if (isTimeoutError2(error)) {
|
|
12069
|
+
return GatewayTimeoutError2.createTimeoutError({
|
|
12070
|
+
originalMessage: error instanceof Error ? error.message : "Unknown error",
|
|
12071
|
+
cause: error
|
|
12072
|
+
});
|
|
12073
|
+
}
|
|
11688
12074
|
if (APICallError3.isInstance(error)) {
|
|
11689
|
-
|
|
12075
|
+
if (error.cause && isTimeoutError2(error.cause)) {
|
|
12076
|
+
return GatewayTimeoutError2.createTimeoutError({
|
|
12077
|
+
originalMessage: error.message,
|
|
12078
|
+
cause: error
|
|
12079
|
+
});
|
|
12080
|
+
}
|
|
12081
|
+
return await createGatewayErrorFromResponse2({
|
|
11690
12082
|
response: extractApiCallResponse2(error),
|
|
11691
|
-
statusCode: (
|
|
12083
|
+
statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
|
|
11692
12084
|
defaultMessage: "Gateway request failed",
|
|
11693
12085
|
cause: error,
|
|
11694
12086
|
authMethod
|
|
11695
12087
|
});
|
|
11696
12088
|
}
|
|
11697
|
-
return createGatewayErrorFromResponse2({
|
|
12089
|
+
return await createGatewayErrorFromResponse2({
|
|
11698
12090
|
response: {},
|
|
11699
12091
|
statusCode: 500,
|
|
11700
12092
|
defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
|
|
@@ -11723,7 +12115,7 @@ async function parseAuthMethod2(headers) {
|
|
|
11723
12115
|
});
|
|
11724
12116
|
return result.success ? result.value : void 0;
|
|
11725
12117
|
}
|
|
11726
|
-
var gatewayAuthMethodSchema2 =
|
|
12118
|
+
var gatewayAuthMethodSchema2 = lazySchema2(
|
|
11727
12119
|
() => zodSchema3(z4.z.union([z4.z.literal("api-key"), z4.z.literal("oidc")]))
|
|
11728
12120
|
);
|
|
11729
12121
|
var GatewayFetchMetadata2 = class {
|
|
@@ -11770,7 +12162,7 @@ var GatewayFetchMetadata2 = class {
|
|
|
11770
12162
|
}
|
|
11771
12163
|
}
|
|
11772
12164
|
};
|
|
11773
|
-
var gatewayAvailableModelsResponseSchema2 =
|
|
12165
|
+
var gatewayAvailableModelsResponseSchema2 = lazySchema2(
|
|
11774
12166
|
() => zodSchema3(
|
|
11775
12167
|
z4.z.object({
|
|
11776
12168
|
models: z4.z.array(
|
|
@@ -11796,13 +12188,13 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
|
|
|
11796
12188
|
provider: z4.z.string(),
|
|
11797
12189
|
modelId: z4.z.string()
|
|
11798
12190
|
}),
|
|
11799
|
-
modelType: z4.z.enum(["
|
|
12191
|
+
modelType: z4.z.enum(["embedding", "image", "language", "video"]).nullish()
|
|
11800
12192
|
})
|
|
11801
12193
|
)
|
|
11802
12194
|
})
|
|
11803
12195
|
)
|
|
11804
12196
|
);
|
|
11805
|
-
var gatewayCreditsResponseSchema2 =
|
|
12197
|
+
var gatewayCreditsResponseSchema2 = lazySchema2(
|
|
11806
12198
|
() => zodSchema3(
|
|
11807
12199
|
z4.z.object({
|
|
11808
12200
|
balance: z4.z.string(),
|
|
@@ -11975,7 +12367,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
11975
12367
|
abortSignal,
|
|
11976
12368
|
providerOptions
|
|
11977
12369
|
}) {
|
|
11978
|
-
var
|
|
12370
|
+
var _a932;
|
|
11979
12371
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
11980
12372
|
try {
|
|
11981
12373
|
const {
|
|
@@ -12006,7 +12398,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
12006
12398
|
});
|
|
12007
12399
|
return {
|
|
12008
12400
|
embeddings: responseBody.embeddings,
|
|
12009
|
-
usage: (
|
|
12401
|
+
usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
|
|
12010
12402
|
providerMetadata: responseBody.providerMetadata,
|
|
12011
12403
|
response: { headers: responseHeaders, body: rawValue },
|
|
12012
12404
|
warnings: []
|
|
@@ -12025,7 +12417,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
12025
12417
|
};
|
|
12026
12418
|
}
|
|
12027
12419
|
};
|
|
12028
|
-
var gatewayEmbeddingResponseSchema2 =
|
|
12420
|
+
var gatewayEmbeddingResponseSchema2 = lazySchema2(
|
|
12029
12421
|
() => zodSchema3(
|
|
12030
12422
|
z4.z.object({
|
|
12031
12423
|
embeddings: z4.z.array(z4.z.array(z4.z.number())),
|
|
@@ -12056,7 +12448,7 @@ var GatewayImageModel2 = class {
|
|
|
12056
12448
|
headers,
|
|
12057
12449
|
abortSignal
|
|
12058
12450
|
}) {
|
|
12059
|
-
var
|
|
12451
|
+
var _a932, _b93, _c, _d;
|
|
12060
12452
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
12061
12453
|
try {
|
|
12062
12454
|
const {
|
|
@@ -12095,16 +12487,23 @@ var GatewayImageModel2 = class {
|
|
|
12095
12487
|
return {
|
|
12096
12488
|
images: responseBody.images,
|
|
12097
12489
|
// Always base64 strings from server
|
|
12098
|
-
warnings: (
|
|
12490
|
+
warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
|
|
12099
12491
|
providerMetadata: responseBody.providerMetadata,
|
|
12100
12492
|
response: {
|
|
12101
12493
|
timestamp: /* @__PURE__ */ new Date(),
|
|
12102
12494
|
modelId: this.modelId,
|
|
12103
12495
|
headers: responseHeaders
|
|
12496
|
+
},
|
|
12497
|
+
...responseBody.usage != null && {
|
|
12498
|
+
usage: {
|
|
12499
|
+
inputTokens: (_b93 = responseBody.usage.inputTokens) != null ? _b93 : void 0,
|
|
12500
|
+
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
|
|
12501
|
+
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
|
|
12502
|
+
}
|
|
12104
12503
|
}
|
|
12105
12504
|
};
|
|
12106
12505
|
} catch (error) {
|
|
12107
|
-
throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
12506
|
+
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
12108
12507
|
}
|
|
12109
12508
|
}
|
|
12110
12509
|
getUrl() {
|
|
@@ -12129,18 +12528,231 @@ function maybeEncodeImageFile(file) {
|
|
|
12129
12528
|
var providerMetadataEntrySchema2 = z4.z.object({
|
|
12130
12529
|
images: z4.z.array(z4.z.unknown()).optional()
|
|
12131
12530
|
}).catchall(z4.z.unknown());
|
|
12531
|
+
var gatewayImageWarningSchema = z4.z.discriminatedUnion("type", [
|
|
12532
|
+
z4.z.object({
|
|
12533
|
+
type: z4.z.literal("unsupported"),
|
|
12534
|
+
feature: z4.z.string(),
|
|
12535
|
+
details: z4.z.string().optional()
|
|
12536
|
+
}),
|
|
12537
|
+
z4.z.object({
|
|
12538
|
+
type: z4.z.literal("compatibility"),
|
|
12539
|
+
feature: z4.z.string(),
|
|
12540
|
+
details: z4.z.string().optional()
|
|
12541
|
+
}),
|
|
12542
|
+
z4.z.object({
|
|
12543
|
+
type: z4.z.literal("other"),
|
|
12544
|
+
message: z4.z.string()
|
|
12545
|
+
})
|
|
12546
|
+
]);
|
|
12547
|
+
var gatewayImageUsageSchema2 = z4.z.object({
|
|
12548
|
+
inputTokens: z4.z.number().nullish(),
|
|
12549
|
+
outputTokens: z4.z.number().nullish(),
|
|
12550
|
+
totalTokens: z4.z.number().nullish()
|
|
12551
|
+
});
|
|
12132
12552
|
var gatewayImageResponseSchema2 = z4.z.object({
|
|
12133
12553
|
images: z4.z.array(z4.z.string()),
|
|
12134
12554
|
// Always base64 strings over the wire
|
|
12135
|
-
warnings: z4.z.array(
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
message: z4.z.string()
|
|
12139
|
-
})
|
|
12140
|
-
).optional(),
|
|
12141
|
-
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional()
|
|
12555
|
+
warnings: z4.z.array(gatewayImageWarningSchema).optional(),
|
|
12556
|
+
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional(),
|
|
12557
|
+
usage: gatewayImageUsageSchema2.optional()
|
|
12142
12558
|
});
|
|
12143
|
-
var
|
|
12559
|
+
var GatewayVideoModel = class {
|
|
12560
|
+
constructor(modelId, config) {
|
|
12561
|
+
this.modelId = modelId;
|
|
12562
|
+
this.config = config;
|
|
12563
|
+
this.specificationVersion = "v3";
|
|
12564
|
+
this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
|
|
12565
|
+
}
|
|
12566
|
+
get provider() {
|
|
12567
|
+
return this.config.provider;
|
|
12568
|
+
}
|
|
12569
|
+
async doGenerate({
|
|
12570
|
+
prompt,
|
|
12571
|
+
n,
|
|
12572
|
+
aspectRatio,
|
|
12573
|
+
resolution,
|
|
12574
|
+
duration,
|
|
12575
|
+
fps,
|
|
12576
|
+
seed,
|
|
12577
|
+
image,
|
|
12578
|
+
providerOptions,
|
|
12579
|
+
headers,
|
|
12580
|
+
abortSignal
|
|
12581
|
+
}) {
|
|
12582
|
+
var _a932;
|
|
12583
|
+
const resolvedHeaders = await resolve2(this.config.headers());
|
|
12584
|
+
try {
|
|
12585
|
+
const { responseHeaders, value: responseBody } = await postJsonToApi2({
|
|
12586
|
+
url: this.getUrl(),
|
|
12587
|
+
headers: combineHeaders2(
|
|
12588
|
+
resolvedHeaders,
|
|
12589
|
+
headers != null ? headers : {},
|
|
12590
|
+
this.getModelConfigHeaders(),
|
|
12591
|
+
await resolve2(this.config.o11yHeaders),
|
|
12592
|
+
{ accept: "text/event-stream" }
|
|
12593
|
+
),
|
|
12594
|
+
body: {
|
|
12595
|
+
prompt,
|
|
12596
|
+
n,
|
|
12597
|
+
...aspectRatio && { aspectRatio },
|
|
12598
|
+
...resolution && { resolution },
|
|
12599
|
+
...duration && { duration },
|
|
12600
|
+
...fps && { fps },
|
|
12601
|
+
...seed && { seed },
|
|
12602
|
+
...providerOptions && { providerOptions },
|
|
12603
|
+
...image && { image: maybeEncodeVideoFile(image) }
|
|
12604
|
+
},
|
|
12605
|
+
successfulResponseHandler: async ({
|
|
12606
|
+
response,
|
|
12607
|
+
url,
|
|
12608
|
+
requestBodyValues
|
|
12609
|
+
}) => {
|
|
12610
|
+
if (response.body == null) {
|
|
12611
|
+
throw new APICallError3({
|
|
12612
|
+
message: "SSE response body is empty",
|
|
12613
|
+
url,
|
|
12614
|
+
requestBodyValues,
|
|
12615
|
+
statusCode: response.status
|
|
12616
|
+
});
|
|
12617
|
+
}
|
|
12618
|
+
const eventStream = parseJsonEventStream2({
|
|
12619
|
+
stream: response.body,
|
|
12620
|
+
schema: gatewayVideoEventSchema
|
|
12621
|
+
});
|
|
12622
|
+
const reader = eventStream.getReader();
|
|
12623
|
+
const { done, value: parseResult } = await reader.read();
|
|
12624
|
+
reader.releaseLock();
|
|
12625
|
+
if (done || !parseResult) {
|
|
12626
|
+
throw new APICallError3({
|
|
12627
|
+
message: "SSE stream ended without a data event",
|
|
12628
|
+
url,
|
|
12629
|
+
requestBodyValues,
|
|
12630
|
+
statusCode: response.status
|
|
12631
|
+
});
|
|
12632
|
+
}
|
|
12633
|
+
if (!parseResult.success) {
|
|
12634
|
+
throw new APICallError3({
|
|
12635
|
+
message: "Failed to parse video SSE event",
|
|
12636
|
+
cause: parseResult.error,
|
|
12637
|
+
url,
|
|
12638
|
+
requestBodyValues,
|
|
12639
|
+
statusCode: response.status
|
|
12640
|
+
});
|
|
12641
|
+
}
|
|
12642
|
+
const event = parseResult.value;
|
|
12643
|
+
if (event.type === "error") {
|
|
12644
|
+
throw new APICallError3({
|
|
12645
|
+
message: event.message,
|
|
12646
|
+
statusCode: event.statusCode,
|
|
12647
|
+
url,
|
|
12648
|
+
requestBodyValues,
|
|
12649
|
+
responseHeaders: Object.fromEntries([...response.headers]),
|
|
12650
|
+
responseBody: JSON.stringify(event),
|
|
12651
|
+
data: {
|
|
12652
|
+
error: {
|
|
12653
|
+
message: event.message,
|
|
12654
|
+
type: event.errorType,
|
|
12655
|
+
param: event.param
|
|
12656
|
+
}
|
|
12657
|
+
}
|
|
12658
|
+
});
|
|
12659
|
+
}
|
|
12660
|
+
return {
|
|
12661
|
+
value: {
|
|
12662
|
+
videos: event.videos,
|
|
12663
|
+
warnings: event.warnings,
|
|
12664
|
+
providerMetadata: event.providerMetadata
|
|
12665
|
+
},
|
|
12666
|
+
responseHeaders: Object.fromEntries([...response.headers])
|
|
12667
|
+
};
|
|
12668
|
+
},
|
|
12669
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
12670
|
+
errorSchema: z4.z.any(),
|
|
12671
|
+
errorToMessage: (data) => data
|
|
12672
|
+
}),
|
|
12673
|
+
...abortSignal && { abortSignal },
|
|
12674
|
+
fetch: this.config.fetch
|
|
12675
|
+
});
|
|
12676
|
+
return {
|
|
12677
|
+
videos: responseBody.videos,
|
|
12678
|
+
warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
|
|
12679
|
+
providerMetadata: responseBody.providerMetadata,
|
|
12680
|
+
response: {
|
|
12681
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
12682
|
+
modelId: this.modelId,
|
|
12683
|
+
headers: responseHeaders
|
|
12684
|
+
}
|
|
12685
|
+
};
|
|
12686
|
+
} catch (error) {
|
|
12687
|
+
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
12688
|
+
}
|
|
12689
|
+
}
|
|
12690
|
+
getUrl() {
|
|
12691
|
+
return `${this.config.baseURL}/video-model`;
|
|
12692
|
+
}
|
|
12693
|
+
getModelConfigHeaders() {
|
|
12694
|
+
return {
|
|
12695
|
+
"ai-video-model-specification-version": "3",
|
|
12696
|
+
"ai-model-id": this.modelId
|
|
12697
|
+
};
|
|
12698
|
+
}
|
|
12699
|
+
};
|
|
12700
|
+
function maybeEncodeVideoFile(file) {
|
|
12701
|
+
if (file.type === "file" && file.data instanceof Uint8Array) {
|
|
12702
|
+
return {
|
|
12703
|
+
...file,
|
|
12704
|
+
data: convertUint8ArrayToBase643(file.data)
|
|
12705
|
+
};
|
|
12706
|
+
}
|
|
12707
|
+
return file;
|
|
12708
|
+
}
|
|
12709
|
+
var providerMetadataEntrySchema22 = z4.z.object({
|
|
12710
|
+
videos: z4.z.array(z4.z.unknown()).optional()
|
|
12711
|
+
}).catchall(z4.z.unknown());
|
|
12712
|
+
var gatewayVideoDataSchema = z4.z.union([
|
|
12713
|
+
z4.z.object({
|
|
12714
|
+
type: z4.z.literal("url"),
|
|
12715
|
+
url: z4.z.string(),
|
|
12716
|
+
mediaType: z4.z.string()
|
|
12717
|
+
}),
|
|
12718
|
+
z4.z.object({
|
|
12719
|
+
type: z4.z.literal("base64"),
|
|
12720
|
+
data: z4.z.string(),
|
|
12721
|
+
mediaType: z4.z.string()
|
|
12722
|
+
})
|
|
12723
|
+
]);
|
|
12724
|
+
var gatewayVideoWarningSchema = z4.z.discriminatedUnion("type", [
|
|
12725
|
+
z4.z.object({
|
|
12726
|
+
type: z4.z.literal("unsupported"),
|
|
12727
|
+
feature: z4.z.string(),
|
|
12728
|
+
details: z4.z.string().optional()
|
|
12729
|
+
}),
|
|
12730
|
+
z4.z.object({
|
|
12731
|
+
type: z4.z.literal("compatibility"),
|
|
12732
|
+
feature: z4.z.string(),
|
|
12733
|
+
details: z4.z.string().optional()
|
|
12734
|
+
}),
|
|
12735
|
+
z4.z.object({
|
|
12736
|
+
type: z4.z.literal("other"),
|
|
12737
|
+
message: z4.z.string()
|
|
12738
|
+
})
|
|
12739
|
+
]);
|
|
12740
|
+
var gatewayVideoEventSchema = z4.z.discriminatedUnion("type", [
|
|
12741
|
+
z4.z.object({
|
|
12742
|
+
type: z4.z.literal("result"),
|
|
12743
|
+
videos: z4.z.array(gatewayVideoDataSchema),
|
|
12744
|
+
warnings: z4.z.array(gatewayVideoWarningSchema).optional(),
|
|
12745
|
+
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema22).optional()
|
|
12746
|
+
}),
|
|
12747
|
+
z4.z.object({
|
|
12748
|
+
type: z4.z.literal("error"),
|
|
12749
|
+
message: z4.z.string(),
|
|
12750
|
+
errorType: z4.z.string(),
|
|
12751
|
+
statusCode: z4.z.number(),
|
|
12752
|
+
param: z4.z.unknown().nullable()
|
|
12753
|
+
})
|
|
12754
|
+
]);
|
|
12755
|
+
var parallelSearchInputSchema2 = lazySchema2(
|
|
12144
12756
|
() => zodSchema3(
|
|
12145
12757
|
zod.z.object({
|
|
12146
12758
|
objective: zod.z.string().describe(
|
|
@@ -12176,7 +12788,7 @@ var parallelSearchInputSchema = lazySchema(
|
|
|
12176
12788
|
})
|
|
12177
12789
|
)
|
|
12178
12790
|
);
|
|
12179
|
-
var
|
|
12791
|
+
var parallelSearchOutputSchema2 = lazySchema2(
|
|
12180
12792
|
() => zodSchema3(
|
|
12181
12793
|
zod.z.union([
|
|
12182
12794
|
// Success response
|
|
@@ -12208,13 +12820,13 @@ var parallelSearchOutputSchema = lazySchema(
|
|
|
12208
12820
|
])
|
|
12209
12821
|
)
|
|
12210
12822
|
);
|
|
12211
|
-
var
|
|
12823
|
+
var parallelSearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
|
|
12212
12824
|
id: "gateway.parallel_search",
|
|
12213
|
-
inputSchema:
|
|
12214
|
-
outputSchema:
|
|
12825
|
+
inputSchema: parallelSearchInputSchema2,
|
|
12826
|
+
outputSchema: parallelSearchOutputSchema2
|
|
12215
12827
|
});
|
|
12216
|
-
var
|
|
12217
|
-
var
|
|
12828
|
+
var parallelSearch2 = (config = {}) => parallelSearchToolFactory2(config);
|
|
12829
|
+
var perplexitySearchInputSchema2 = lazySchema2(
|
|
12218
12830
|
() => zodSchema3(
|
|
12219
12831
|
zod.z.object({
|
|
12220
12832
|
query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
|
|
@@ -12256,7 +12868,7 @@ var perplexitySearchInputSchema = lazySchema(
|
|
|
12256
12868
|
})
|
|
12257
12869
|
)
|
|
12258
12870
|
);
|
|
12259
|
-
var
|
|
12871
|
+
var perplexitySearchOutputSchema2 = lazySchema2(
|
|
12260
12872
|
() => zodSchema3(
|
|
12261
12873
|
zod.z.union([
|
|
12262
12874
|
// Success response
|
|
@@ -12287,13 +12899,13 @@ var perplexitySearchOutputSchema = lazySchema(
|
|
|
12287
12899
|
])
|
|
12288
12900
|
)
|
|
12289
12901
|
);
|
|
12290
|
-
var
|
|
12902
|
+
var perplexitySearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
|
|
12291
12903
|
id: "gateway.perplexity_search",
|
|
12292
|
-
inputSchema:
|
|
12293
|
-
outputSchema:
|
|
12904
|
+
inputSchema: perplexitySearchInputSchema2,
|
|
12905
|
+
outputSchema: perplexitySearchOutputSchema2
|
|
12294
12906
|
});
|
|
12295
|
-
var
|
|
12296
|
-
var
|
|
12907
|
+
var perplexitySearch2 = (config = {}) => perplexitySearchToolFactory2(config);
|
|
12908
|
+
var gatewayTools2 = {
|
|
12297
12909
|
/**
|
|
12298
12910
|
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
12299
12911
|
*
|
|
@@ -12302,7 +12914,7 @@ var gatewayTools = {
|
|
|
12302
12914
|
* or complex queries. Supports different search types for depth vs
|
|
12303
12915
|
* breadth tradeoffs.
|
|
12304
12916
|
*/
|
|
12305
|
-
parallelSearch,
|
|
12917
|
+
parallelSearch: parallelSearch2,
|
|
12306
12918
|
/**
|
|
12307
12919
|
* Search the web using Perplexity's Search API for real-time information,
|
|
12308
12920
|
* news, research papers, and articles.
|
|
@@ -12310,21 +12922,21 @@ var gatewayTools = {
|
|
|
12310
12922
|
* Provides ranked search results with advanced filtering options including
|
|
12311
12923
|
* domain, language, date range, and recency filters.
|
|
12312
12924
|
*/
|
|
12313
|
-
perplexitySearch
|
|
12925
|
+
perplexitySearch: perplexitySearch2
|
|
12314
12926
|
};
|
|
12315
12927
|
async function getVercelRequestId2() {
|
|
12316
|
-
var
|
|
12317
|
-
return (
|
|
12928
|
+
var _a932;
|
|
12929
|
+
return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
|
|
12318
12930
|
}
|
|
12319
|
-
var VERSION5 = "3.0.
|
|
12931
|
+
var VERSION5 = "3.0.66";
|
|
12320
12932
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
12321
12933
|
function createGatewayProvider2(options = {}) {
|
|
12322
|
-
var
|
|
12934
|
+
var _a932, _b93;
|
|
12323
12935
|
let pendingMetadata = null;
|
|
12324
12936
|
let metadataCache = null;
|
|
12325
|
-
const cacheRefreshMillis = (
|
|
12937
|
+
const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
|
|
12326
12938
|
let lastFetchTime = 0;
|
|
12327
|
-
const baseURL = (
|
|
12939
|
+
const baseURL = (_b93 = withoutTrailingSlash2(options.baseURL)) != null ? _b93 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
12328
12940
|
const getHeaders = async () => {
|
|
12329
12941
|
try {
|
|
12330
12942
|
const auth = await getGatewayAuthToken2(options);
|
|
@@ -12359,13 +12971,18 @@ function createGatewayProvider2(options = {}) {
|
|
|
12359
12971
|
settingValue: void 0,
|
|
12360
12972
|
environmentVariableName: "VERCEL_REGION"
|
|
12361
12973
|
});
|
|
12974
|
+
const projectId = loadOptionalSetting2({
|
|
12975
|
+
settingValue: void 0,
|
|
12976
|
+
environmentVariableName: "VERCEL_PROJECT_ID"
|
|
12977
|
+
});
|
|
12362
12978
|
return async () => {
|
|
12363
12979
|
const requestId = await getVercelRequestId2();
|
|
12364
12980
|
return {
|
|
12365
12981
|
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
12366
12982
|
...environment && { "ai-o11y-environment": environment },
|
|
12367
12983
|
...region && { "ai-o11y-region": region },
|
|
12368
|
-
...requestId && { "ai-o11y-request-id": requestId }
|
|
12984
|
+
...requestId && { "ai-o11y-request-id": requestId },
|
|
12985
|
+
...projectId && { "ai-o11y-project-id": projectId }
|
|
12369
12986
|
};
|
|
12370
12987
|
};
|
|
12371
12988
|
};
|
|
@@ -12379,8 +12996,8 @@ function createGatewayProvider2(options = {}) {
|
|
|
12379
12996
|
});
|
|
12380
12997
|
};
|
|
12381
12998
|
const getAvailableModels = async () => {
|
|
12382
|
-
var
|
|
12383
|
-
const now2 = (_c = (
|
|
12999
|
+
var _a1022, _b103, _c;
|
|
13000
|
+
const now2 = (_c = (_b103 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b103.call(_a1022).getTime()) != null ? _c : Date.now();
|
|
12384
13001
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
12385
13002
|
lastFetchTime = now2;
|
|
12386
13003
|
pendingMetadata = new GatewayFetchMetadata2({
|
|
@@ -12443,7 +13060,20 @@ function createGatewayProvider2(options = {}) {
|
|
|
12443
13060
|
};
|
|
12444
13061
|
provider.embeddingModel = createEmbeddingModel;
|
|
12445
13062
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
12446
|
-
provider.
|
|
13063
|
+
provider.videoModel = (modelId) => {
|
|
13064
|
+
return new GatewayVideoModel(modelId, {
|
|
13065
|
+
provider: "gateway",
|
|
13066
|
+
baseURL,
|
|
13067
|
+
headers: getHeaders,
|
|
13068
|
+
fetch: options.fetch,
|
|
13069
|
+
o11yHeaders: createO11yHeaders()
|
|
13070
|
+
});
|
|
13071
|
+
};
|
|
13072
|
+
provider.chat = provider.languageModel;
|
|
13073
|
+
provider.embedding = provider.embeddingModel;
|
|
13074
|
+
provider.image = provider.imageModel;
|
|
13075
|
+
provider.video = provider.videoModel;
|
|
13076
|
+
provider.tools = gatewayTools2;
|
|
12447
13077
|
return provider;
|
|
12448
13078
|
}
|
|
12449
13079
|
var gateway2 = createGatewayProvider2();
|
|
@@ -12557,12 +13187,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
|
|
|
12557
13187
|
return true;
|
|
12558
13188
|
}
|
|
12559
13189
|
function getGlobal3(type) {
|
|
12560
|
-
var _a21,
|
|
13190
|
+
var _a21, _b93;
|
|
12561
13191
|
var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
|
|
12562
13192
|
if (!globalVersion || !isCompatible3(globalVersion)) {
|
|
12563
13193
|
return;
|
|
12564
13194
|
}
|
|
12565
|
-
return (
|
|
13195
|
+
return (_b93 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b93 === void 0 ? void 0 : _b93[type];
|
|
12566
13196
|
}
|
|
12567
13197
|
function unregisterGlobal3(type, diag) {
|
|
12568
13198
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
|
|
@@ -12727,7 +13357,7 @@ var DiagAPI3 = (
|
|
|
12727
13357
|
}
|
|
12728
13358
|
var self = this;
|
|
12729
13359
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
12730
|
-
var _a21,
|
|
13360
|
+
var _a21, _b93, _c;
|
|
12731
13361
|
if (optionsOrLogLevel === void 0) {
|
|
12732
13362
|
optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
|
|
12733
13363
|
}
|
|
@@ -12742,7 +13372,7 @@ var DiagAPI3 = (
|
|
|
12742
13372
|
};
|
|
12743
13373
|
}
|
|
12744
13374
|
var oldLogger = getGlobal3("diag");
|
|
12745
|
-
var newLogger = createLogLevelDiagLogger3((
|
|
13375
|
+
var newLogger = createLogLevelDiagLogger3((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel3.INFO, logger);
|
|
12746
13376
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
12747
13377
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
12748
13378
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
@@ -13175,10 +13805,10 @@ var __export3 = (target, all) => {
|
|
|
13175
13805
|
for (var name21 in all)
|
|
13176
13806
|
__defProp4(target, name21, { get: all[name21], enumerable: true });
|
|
13177
13807
|
};
|
|
13178
|
-
var
|
|
13179
|
-
var
|
|
13180
|
-
var
|
|
13181
|
-
var
|
|
13808
|
+
var name86 = "AI_InvalidArgumentError";
|
|
13809
|
+
var marker96 = `vercel.ai.error.${name86}`;
|
|
13810
|
+
var symbol96 = Symbol.for(marker96);
|
|
13811
|
+
var _a96;
|
|
13182
13812
|
var InvalidArgumentError23 = class extends AISDKError3 {
|
|
13183
13813
|
constructor({
|
|
13184
13814
|
parameter,
|
|
@@ -13186,20 +13816,20 @@ var InvalidArgumentError23 = class extends AISDKError3 {
|
|
|
13186
13816
|
message
|
|
13187
13817
|
}) {
|
|
13188
13818
|
super({
|
|
13189
|
-
name:
|
|
13819
|
+
name: name86,
|
|
13190
13820
|
message: `Invalid argument for parameter ${parameter}: ${message}`
|
|
13191
13821
|
});
|
|
13192
|
-
this[
|
|
13822
|
+
this[_a96] = true;
|
|
13193
13823
|
this.parameter = parameter;
|
|
13194
13824
|
this.value = value;
|
|
13195
13825
|
}
|
|
13196
13826
|
static isInstance(error) {
|
|
13197
|
-
return AISDKError3.hasMarker(error,
|
|
13827
|
+
return AISDKError3.hasMarker(error, marker96);
|
|
13198
13828
|
}
|
|
13199
13829
|
};
|
|
13200
|
-
|
|
13201
|
-
var
|
|
13202
|
-
var marker823 = `vercel.ai.error.${
|
|
13830
|
+
_a96 = symbol96;
|
|
13831
|
+
var name823 = "AI_NoObjectGeneratedError";
|
|
13832
|
+
var marker823 = `vercel.ai.error.${name823}`;
|
|
13203
13833
|
var symbol823 = Symbol.for(marker823);
|
|
13204
13834
|
var _a823;
|
|
13205
13835
|
var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
@@ -13211,7 +13841,7 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
|
13211
13841
|
usage,
|
|
13212
13842
|
finishReason
|
|
13213
13843
|
}) {
|
|
13214
|
-
super({ name:
|
|
13844
|
+
super({ name: name823, message, cause });
|
|
13215
13845
|
this[_a823] = true;
|
|
13216
13846
|
this.text = text22;
|
|
13217
13847
|
this.response = response;
|
|
@@ -13371,7 +14001,7 @@ function getTotalTimeoutMs(timeout) {
|
|
|
13371
14001
|
}
|
|
13372
14002
|
return timeout.totalMs;
|
|
13373
14003
|
}
|
|
13374
|
-
var VERSION33 = "6.0.
|
|
14004
|
+
var VERSION33 = "6.0.116";
|
|
13375
14005
|
var dataContentSchema3 = z4.z.union([
|
|
13376
14006
|
z4.z.string(),
|
|
13377
14007
|
z4.z.instanceof(Uint8Array),
|
|
@@ -13379,8 +14009,8 @@ var dataContentSchema3 = z4.z.union([
|
|
|
13379
14009
|
z4.z.custom(
|
|
13380
14010
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
13381
14011
|
(value) => {
|
|
13382
|
-
var _a21,
|
|
13383
|
-
return (
|
|
14012
|
+
var _a21, _b93;
|
|
14013
|
+
return (_b93 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b93 : false;
|
|
13384
14014
|
},
|
|
13385
14015
|
{ message: "Must be a Buffer" }
|
|
13386
14016
|
)
|