@mastra/server 1.5.0-alpha.0 → 1.5.0-alpha.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.5.0-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @mastra/core@1.5.0-alpha.1
9
+
3
10
  ## 1.5.0-alpha.0
4
11
 
5
12
  ### Minor Changes
@@ -1804,7 +1804,7 @@ var zodToJsonSchema = (schema, options) => {
1804
1804
  // ../../node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js
1805
1805
  var esm_default = zodToJsonSchema;
1806
1806
 
1807
- // ../schema-compat/dist/chunk-BXZCXMXO.js
1807
+ // ../schema-compat/dist/chunk-4EY4LZB2.js
1808
1808
  var PATCHED = /* @__PURE__ */ Symbol("__mastra_patched__");
1809
1809
  function patchRecordSchemas(schema) {
1810
1810
  if (!schema || typeof schema !== "object") return schema;
@@ -1813,7 +1813,7 @@ function patchRecordSchemas(schema) {
1813
1813
  const def = schema._zod?.def;
1814
1814
  if (def?.type === "record" && def.keyType && !def.valueType) {
1815
1815
  def.valueType = def.keyType;
1816
- def.keyType = z18.z.string();
1816
+ def.keyType = z42.z.string();
1817
1817
  }
1818
1818
  if (!def) return schema;
1819
1819
  if (def.type === "object" && def.shape) {
@@ -1902,10 +1902,9 @@ function fixAnyOfNullable(schema) {
1902
1902
  return result;
1903
1903
  }
1904
1904
  function zodToJsonSchema2(zodSchema5, target = "jsonSchema7", strategy = "relative") {
1905
- const fn = "toJSONSchema";
1906
- if (fn in z18.z) {
1905
+ if (zodSchema5?._zod) {
1907
1906
  patchRecordSchemas(zodSchema5);
1908
- const jsonSchema5 = z18.z[fn](zodSchema5, {
1907
+ const jsonSchema5 = z42.z.toJSONSchema(zodSchema5, {
1909
1908
  unrepresentable: "any",
1910
1909
  override: (ctx) => {
1911
1910
  const def = ctx.zodSchema?._def || ctx.zodSchema?._zod?.def;
@@ -19934,12 +19933,12 @@ async function getVercelRequestId() {
19934
19933
  var VERSION3 = "2.0.15";
19935
19934
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
19936
19935
  function createGatewayProvider(options = {}) {
19937
- var _a832, _b83;
19936
+ var _a832, _b84;
19938
19937
  let pendingMetadata = null;
19939
19938
  let metadataCache = null;
19940
19939
  const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
19941
19940
  let lastFetchTime = 0;
19942
- const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
19941
+ const baseURL = (_b84 = withoutTrailingSlash(options.baseURL)) != null ? _b84 : "https://ai-gateway.vercel.sh/v1/ai";
19943
19942
  const getHeaders = async () => {
19944
19943
  const auth = await getGatewayAuthToken(options);
19945
19944
  if (auth) {
@@ -19992,8 +19991,8 @@ function createGatewayProvider(options = {}) {
19992
19991
  });
19993
19992
  };
19994
19993
  const getAvailableModels = async () => {
19995
- var _a922, _b92, _c;
19996
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
19994
+ var _a923, _b92, _c;
19995
+ const now2 = (_c = (_b92 = (_a923 = options._internal) == null ? void 0 : _a923.currentDate) == null ? void 0 : _b92.call(_a923).getTime()) != null ? _c : Date.now();
19997
19996
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
19998
19997
  lastFetchTime = now2;
19999
19998
  pendingMetadata = new GatewayFetchMetadata({
@@ -20170,12 +20169,12 @@ function registerGlobal22(type, instance, diag, allowOverride) {
20170
20169
  return true;
20171
20170
  }
20172
20171
  function getGlobal22(type) {
20173
- var _a163, _b83;
20172
+ var _a163, _b84;
20174
20173
  var globalVersion = (_a163 = _global22[GLOBAL_OPENTELEMETRY_API_KEY22]) === null || _a163 === void 0 ? void 0 : _a163.version;
20175
20174
  if (!globalVersion || !isCompatible22(globalVersion)) {
20176
20175
  return;
20177
20176
  }
20178
- return (_b83 = _global22[GLOBAL_OPENTELEMETRY_API_KEY22]) === null || _b83 === void 0 ? void 0 : _b83[type];
20177
+ return (_b84 = _global22[GLOBAL_OPENTELEMETRY_API_KEY22]) === null || _b84 === void 0 ? void 0 : _b84[type];
20179
20178
  }
20180
20179
  function unregisterGlobal22(type, diag) {
20181
20180
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION222 + ".");
@@ -20340,7 +20339,7 @@ var DiagAPI22 = (
20340
20339
  }
20341
20340
  var self = this;
20342
20341
  var setLogger = function(logger, optionsOrLogLevel) {
20343
- var _a163, _b83, _c;
20342
+ var _a163, _b84, _c;
20344
20343
  if (optionsOrLogLevel === void 0) {
20345
20344
  optionsOrLogLevel = { logLevel: DiagLogLevel22.INFO };
20346
20345
  }
@@ -20355,7 +20354,7 @@ var DiagAPI22 = (
20355
20354
  };
20356
20355
  }
20357
20356
  var oldLogger = getGlobal22("diag");
20358
- var newLogger = createLogLevelDiagLogger22((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel22.INFO, logger);
20357
+ var newLogger = createLogLevelDiagLogger22((_b84 = optionsOrLogLevel.logLevel) !== null && _b84 !== void 0 ? _b84 : DiagLogLevel22.INFO, logger);
20359
20358
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
20360
20359
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
20361
20360
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -20894,8 +20893,8 @@ var dataContentSchema22 = z42.z.union([
20894
20893
  z42.z.custom(
20895
20894
  // Buffer might not be available in some environments such as CloudFlare:
20896
20895
  (value) => {
20897
- var _a163, _b83;
20898
- return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
20896
+ var _a163, _b84;
20897
+ return (_b84 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b84 : false;
20899
20898
  },
20900
20899
  { message: "Must be a Buffer" }
20901
20900
  )
@@ -22497,7 +22496,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
22497
22496
  );
22498
22497
  return Object.fromEntries(normalizedHeaders.entries());
22499
22498
  }
22500
- var VERSION4 = "4.0.13";
22499
+ var VERSION4 = "4.0.15";
22501
22500
  var getOriginalFetch3 = () => globalThis.fetch;
22502
22501
  var getFromApi2 = async ({
22503
22502
  url,
@@ -24505,7 +24504,7 @@ async function createGatewayErrorFromResponse2({
24505
24504
  cause,
24506
24505
  authMethod
24507
24506
  }) {
24508
- var _a832;
24507
+ var _a932;
24509
24508
  const parseResult = await safeValidateTypes3({
24510
24509
  value: response,
24511
24510
  schema: gatewayErrorResponseSchema2
@@ -24524,7 +24523,7 @@ async function createGatewayErrorFromResponse2({
24524
24523
  const validatedResponse = parseResult.value;
24525
24524
  const errorType = validatedResponse.error.type;
24526
24525
  const message = validatedResponse.error.message;
24527
- const generationId = (_a832 = validatedResponse.generationId) != null ? _a832 : void 0;
24526
+ const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
24528
24527
  switch (errorType) {
24529
24528
  case "authentication_error":
24530
24529
  return GatewayAuthenticationError2.createContextualError({
@@ -24590,21 +24589,88 @@ var gatewayErrorResponseSchema2 = lazySchema(
24590
24589
  })
24591
24590
  )
24592
24591
  );
24593
- function asGatewayError2(error, authMethod) {
24594
- var _a832;
24592
+ var name76 = "GatewayTimeoutError";
24593
+ var marker86 = `vercel.ai.gateway.error.${name76}`;
24594
+ var symbol86 = Symbol.for(marker86);
24595
+ var _a86;
24596
+ var _b83;
24597
+ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b83 = GatewayError2, _a86 = symbol86, _b83) {
24598
+ constructor({
24599
+ message = "Request timed out",
24600
+ statusCode = 408,
24601
+ cause,
24602
+ generationId
24603
+ } = {}) {
24604
+ super({ message, statusCode, cause, generationId });
24605
+ this[_a86] = true;
24606
+ this.name = name76;
24607
+ this.type = "timeout_error";
24608
+ }
24609
+ static isInstance(error) {
24610
+ return GatewayError2.hasMarker(error) && symbol86 in error;
24611
+ }
24612
+ /**
24613
+ * Creates a helpful timeout error message with troubleshooting guidance
24614
+ */
24615
+ static createTimeoutError({
24616
+ originalMessage,
24617
+ statusCode = 408,
24618
+ cause,
24619
+ generationId
24620
+ }) {
24621
+ const message = `Gateway request timed out: ${originalMessage}
24622
+
24623
+ 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`;
24624
+ return new _GatewayTimeoutError({
24625
+ message,
24626
+ statusCode,
24627
+ cause,
24628
+ generationId
24629
+ });
24630
+ }
24631
+ };
24632
+ function isTimeoutError(error) {
24633
+ if (!(error instanceof Error)) {
24634
+ return false;
24635
+ }
24636
+ const errorCode = error.code;
24637
+ if (typeof errorCode === "string") {
24638
+ const undiciTimeoutCodes = [
24639
+ "UND_ERR_HEADERS_TIMEOUT",
24640
+ "UND_ERR_BODY_TIMEOUT",
24641
+ "UND_ERR_CONNECT_TIMEOUT"
24642
+ ];
24643
+ return undiciTimeoutCodes.includes(errorCode);
24644
+ }
24645
+ return false;
24646
+ }
24647
+ async function asGatewayError2(error, authMethod) {
24648
+ var _a932;
24595
24649
  if (GatewayError2.isInstance(error)) {
24596
24650
  return error;
24597
24651
  }
24652
+ if (isTimeoutError(error)) {
24653
+ return GatewayTimeoutError.createTimeoutError({
24654
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
24655
+ cause: error
24656
+ });
24657
+ }
24598
24658
  if (APICallError3.isInstance(error)) {
24599
- return createGatewayErrorFromResponse2({
24659
+ if (error.cause && isTimeoutError(error.cause)) {
24660
+ return GatewayTimeoutError.createTimeoutError({
24661
+ originalMessage: error.message,
24662
+ cause: error
24663
+ });
24664
+ }
24665
+ return await createGatewayErrorFromResponse2({
24600
24666
  response: extractApiCallResponse2(error),
24601
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
24667
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
24602
24668
  defaultMessage: "Gateway request failed",
24603
24669
  cause: error,
24604
24670
  authMethod
24605
24671
  });
24606
24672
  }
24607
- return createGatewayErrorFromResponse2({
24673
+ return await createGatewayErrorFromResponse2({
24608
24674
  response: {},
24609
24675
  statusCode: 500,
24610
24676
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -24706,7 +24772,7 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
24706
24772
  provider: z42.z.string(),
24707
24773
  modelId: z42.z.string()
24708
24774
  }),
24709
- modelType: z42.z.enum(["language", "embedding", "image"]).nullish()
24775
+ modelType: z42.z.enum(["embedding", "image", "language", "video"]).nullish()
24710
24776
  })
24711
24777
  )
24712
24778
  })
@@ -24885,7 +24951,7 @@ var GatewayEmbeddingModel2 = class {
24885
24951
  abortSignal,
24886
24952
  providerOptions
24887
24953
  }) {
24888
- var _a832;
24954
+ var _a932;
24889
24955
  const resolvedHeaders = await resolve2(this.config.headers());
24890
24956
  try {
24891
24957
  const {
@@ -24916,7 +24982,7 @@ var GatewayEmbeddingModel2 = class {
24916
24982
  });
24917
24983
  return {
24918
24984
  embeddings: responseBody.embeddings,
24919
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
24985
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
24920
24986
  providerMetadata: responseBody.providerMetadata,
24921
24987
  response: { headers: responseHeaders, body: rawValue },
24922
24988
  warnings: []
@@ -24966,7 +25032,7 @@ var GatewayImageModel2 = class {
24966
25032
  headers,
24967
25033
  abortSignal
24968
25034
  }) {
24969
- var _a832;
25035
+ var _a932, _b92, _c, _d;
24970
25036
  const resolvedHeaders = await resolve2(this.config.headers());
24971
25037
  try {
24972
25038
  const {
@@ -25005,16 +25071,23 @@ var GatewayImageModel2 = class {
25005
25071
  return {
25006
25072
  images: responseBody.images,
25007
25073
  // Always base64 strings from server
25008
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
25074
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
25009
25075
  providerMetadata: responseBody.providerMetadata,
25010
25076
  response: {
25011
25077
  timestamp: /* @__PURE__ */ new Date(),
25012
25078
  modelId: this.modelId,
25013
25079
  headers: responseHeaders
25080
+ },
25081
+ ...responseBody.usage != null && {
25082
+ usage: {
25083
+ inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : void 0,
25084
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
25085
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
25086
+ }
25014
25087
  }
25015
25088
  };
25016
25089
  } catch (error) {
25017
- throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
25090
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
25018
25091
  }
25019
25092
  }
25020
25093
  getUrl() {
@@ -25039,16 +25112,160 @@ function maybeEncodeImageFile(file) {
25039
25112
  var providerMetadataEntrySchema2 = z42.z.object({
25040
25113
  images: z42.z.array(z42.z.unknown()).optional()
25041
25114
  }).catchall(z42.z.unknown());
25115
+ var gatewayImageWarningSchema = z42.z.discriminatedUnion("type", [
25116
+ z42.z.object({
25117
+ type: z42.z.literal("unsupported"),
25118
+ feature: z42.z.string(),
25119
+ details: z42.z.string().optional()
25120
+ }),
25121
+ z42.z.object({
25122
+ type: z42.z.literal("compatibility"),
25123
+ feature: z42.z.string(),
25124
+ details: z42.z.string().optional()
25125
+ }),
25126
+ z42.z.object({
25127
+ type: z42.z.literal("other"),
25128
+ message: z42.z.string()
25129
+ })
25130
+ ]);
25131
+ var gatewayImageUsageSchema = z42.z.object({
25132
+ inputTokens: z42.z.number().nullish(),
25133
+ outputTokens: z42.z.number().nullish(),
25134
+ totalTokens: z42.z.number().nullish()
25135
+ });
25042
25136
  var gatewayImageResponseSchema2 = z42.z.object({
25043
25137
  images: z42.z.array(z42.z.string()),
25044
25138
  // Always base64 strings over the wire
25045
- warnings: z42.z.array(
25046
- z42.z.object({
25047
- type: z42.z.literal("other"),
25048
- message: z42.z.string()
25049
- })
25050
- ).optional(),
25051
- providerMetadata: z42.z.record(z42.z.string(), providerMetadataEntrySchema2).optional()
25139
+ warnings: z42.z.array(gatewayImageWarningSchema).optional(),
25140
+ providerMetadata: z42.z.record(z42.z.string(), providerMetadataEntrySchema2).optional(),
25141
+ usage: gatewayImageUsageSchema.optional()
25142
+ });
25143
+ var GatewayVideoModel = class {
25144
+ constructor(modelId, config) {
25145
+ this.modelId = modelId;
25146
+ this.config = config;
25147
+ this.specificationVersion = "v3";
25148
+ this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
25149
+ }
25150
+ get provider() {
25151
+ return this.config.provider;
25152
+ }
25153
+ async doGenerate({
25154
+ prompt,
25155
+ n,
25156
+ aspectRatio,
25157
+ resolution,
25158
+ duration,
25159
+ fps,
25160
+ seed,
25161
+ image,
25162
+ providerOptions,
25163
+ headers,
25164
+ abortSignal
25165
+ }) {
25166
+ var _a932;
25167
+ const resolvedHeaders = await resolve2(this.config.headers());
25168
+ try {
25169
+ const {
25170
+ responseHeaders,
25171
+ value: responseBody
25172
+ } = await postJsonToApi2({
25173
+ url: this.getUrl(),
25174
+ headers: combineHeaders2(
25175
+ resolvedHeaders,
25176
+ headers != null ? headers : {},
25177
+ this.getModelConfigHeaders(),
25178
+ await resolve2(this.config.o11yHeaders)
25179
+ ),
25180
+ body: {
25181
+ prompt,
25182
+ n,
25183
+ ...aspectRatio && { aspectRatio },
25184
+ ...resolution && { resolution },
25185
+ ...duration && { duration },
25186
+ ...fps && { fps },
25187
+ ...seed && { seed },
25188
+ ...providerOptions && { providerOptions },
25189
+ ...image && { image: maybeEncodeVideoFile(image) }
25190
+ },
25191
+ successfulResponseHandler: createJsonResponseHandler2(
25192
+ gatewayVideoResponseSchema
25193
+ ),
25194
+ failedResponseHandler: createJsonErrorResponseHandler2({
25195
+ errorSchema: z42.z.any(),
25196
+ errorToMessage: (data) => data
25197
+ }),
25198
+ ...abortSignal && { abortSignal },
25199
+ fetch: this.config.fetch
25200
+ });
25201
+ return {
25202
+ videos: responseBody.videos,
25203
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
25204
+ providerMetadata: responseBody.providerMetadata,
25205
+ response: {
25206
+ timestamp: /* @__PURE__ */ new Date(),
25207
+ modelId: this.modelId,
25208
+ headers: responseHeaders
25209
+ }
25210
+ };
25211
+ } catch (error) {
25212
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
25213
+ }
25214
+ }
25215
+ getUrl() {
25216
+ return `${this.config.baseURL}/video-model`;
25217
+ }
25218
+ getModelConfigHeaders() {
25219
+ return {
25220
+ "ai-video-model-specification-version": "3",
25221
+ "ai-model-id": this.modelId
25222
+ };
25223
+ }
25224
+ };
25225
+ function maybeEncodeVideoFile(file) {
25226
+ if (file.type === "file" && file.data instanceof Uint8Array) {
25227
+ return {
25228
+ ...file,
25229
+ data: convertUint8ArrayToBase643(file.data)
25230
+ };
25231
+ }
25232
+ return file;
25233
+ }
25234
+ var providerMetadataEntrySchema22 = z42.z.object({
25235
+ videos: z42.z.array(z42.z.unknown()).optional()
25236
+ }).catchall(z42.z.unknown());
25237
+ var gatewayVideoDataSchema = z42.z.union([
25238
+ z42.z.object({
25239
+ type: z42.z.literal("url"),
25240
+ url: z42.z.string(),
25241
+ mediaType: z42.z.string()
25242
+ }),
25243
+ z42.z.object({
25244
+ type: z42.z.literal("base64"),
25245
+ data: z42.z.string(),
25246
+ mediaType: z42.z.string()
25247
+ })
25248
+ ]);
25249
+ var gatewayVideoWarningSchema = z42.z.discriminatedUnion("type", [
25250
+ z42.z.object({
25251
+ type: z42.z.literal("unsupported"),
25252
+ feature: z42.z.string(),
25253
+ details: z42.z.string().optional()
25254
+ }),
25255
+ z42.z.object({
25256
+ type: z42.z.literal("compatibility"),
25257
+ feature: z42.z.string(),
25258
+ details: z42.z.string().optional()
25259
+ }),
25260
+ z42.z.object({
25261
+ type: z42.z.literal("other"),
25262
+ message: z42.z.string()
25263
+ })
25264
+ ]);
25265
+ var gatewayVideoResponseSchema = z42.z.object({
25266
+ videos: z42.z.array(gatewayVideoDataSchema),
25267
+ warnings: z42.z.array(gatewayVideoWarningSchema).optional(),
25268
+ providerMetadata: z42.z.record(z42.z.string(), providerMetadataEntrySchema22).optional()
25052
25269
  });
25053
25270
  var parallelSearchInputSchema = lazySchema(
25054
25271
  () => zodSchema3(
@@ -25223,18 +25440,18 @@ var gatewayTools = {
25223
25440
  perplexitySearch
25224
25441
  };
25225
25442
  async function getVercelRequestId2() {
25226
- var _a832;
25227
- return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
25443
+ var _a932;
25444
+ return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
25228
25445
  }
25229
- var VERSION5 = "3.0.32";
25446
+ var VERSION5 = "3.0.50";
25230
25447
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
25231
25448
  function createGatewayProvider2(options = {}) {
25232
- var _a832, _b83;
25449
+ var _a932, _b92;
25233
25450
  let pendingMetadata = null;
25234
25451
  let metadataCache = null;
25235
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
25452
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
25236
25453
  let lastFetchTime = 0;
25237
- const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
25454
+ const baseURL = (_b92 = withoutTrailingSlash2(options.baseURL)) != null ? _b92 : "https://ai-gateway.vercel.sh/v3/ai";
25238
25455
  const getHeaders = async () => {
25239
25456
  try {
25240
25457
  const auth = await getGatewayAuthToken2(options);
@@ -25289,8 +25506,8 @@ function createGatewayProvider2(options = {}) {
25289
25506
  });
25290
25507
  };
25291
25508
  const getAvailableModels = async () => {
25292
- var _a922, _b92, _c;
25293
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
25509
+ var _a1022, _b102, _c;
25510
+ const now2 = (_c = (_b102 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b102.call(_a1022).getTime()) != null ? _c : Date.now();
25294
25511
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
25295
25512
  lastFetchTime = now2;
25296
25513
  pendingMetadata = new GatewayFetchMetadata2({
@@ -25353,6 +25570,19 @@ function createGatewayProvider2(options = {}) {
25353
25570
  };
25354
25571
  provider.embeddingModel = createEmbeddingModel;
25355
25572
  provider.textEmbeddingModel = createEmbeddingModel;
25573
+ provider.videoModel = (modelId) => {
25574
+ return new GatewayVideoModel(modelId, {
25575
+ provider: "gateway",
25576
+ baseURL,
25577
+ headers: getHeaders,
25578
+ fetch: options.fetch,
25579
+ o11yHeaders: createO11yHeaders()
25580
+ });
25581
+ };
25582
+ provider.chat = provider.languageModel;
25583
+ provider.embedding = provider.embeddingModel;
25584
+ provider.image = provider.imageModel;
25585
+ provider.video = provider.videoModel;
25356
25586
  provider.tools = gatewayTools;
25357
25587
  return provider;
25358
25588
  }
@@ -25467,12 +25697,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
25467
25697
  return true;
25468
25698
  }
25469
25699
  function getGlobal3(type) {
25470
- var _a21, _b83;
25700
+ var _a21, _b92;
25471
25701
  var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
25472
25702
  if (!globalVersion || !isCompatible3(globalVersion)) {
25473
25703
  return;
25474
25704
  }
25475
- return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
25705
+ return (_b92 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b92 === void 0 ? void 0 : _b92[type];
25476
25706
  }
25477
25707
  function unregisterGlobal3(type, diag) {
25478
25708
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
@@ -25637,7 +25867,7 @@ var DiagAPI3 = (
25637
25867
  }
25638
25868
  var self = this;
25639
25869
  var setLogger = function(logger, optionsOrLogLevel) {
25640
- var _a21, _b83, _c;
25870
+ var _a21, _b92, _c;
25641
25871
  if (optionsOrLogLevel === void 0) {
25642
25872
  optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
25643
25873
  }
@@ -25652,7 +25882,7 @@ var DiagAPI3 = (
25652
25882
  };
25653
25883
  }
25654
25884
  var oldLogger = getGlobal3("diag");
25655
- var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
25885
+ var newLogger = createLogLevelDiagLogger3((_b92 = optionsOrLogLevel.logLevel) !== null && _b92 !== void 0 ? _b92 : DiagLogLevel3.INFO, logger);
25656
25886
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
25657
25887
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
25658
25888
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -26085,10 +26315,10 @@ var __export32 = (target, all) => {
26085
26315
  for (var name21 in all)
26086
26316
  __defProp4(target, name21, { get: all[name21], enumerable: true });
26087
26317
  };
26088
- var name76 = "AI_InvalidArgumentError";
26089
- var marker86 = `vercel.ai.error.${name76}`;
26090
- var symbol86 = Symbol.for(marker86);
26091
- var _a86;
26318
+ var name86 = "AI_InvalidArgumentError";
26319
+ var marker96 = `vercel.ai.error.${name86}`;
26320
+ var symbol96 = Symbol.for(marker96);
26321
+ var _a96;
26092
26322
  var InvalidArgumentError23 = class extends AISDKError3 {
26093
26323
  constructor({
26094
26324
  parameter,
@@ -26096,20 +26326,20 @@ var InvalidArgumentError23 = class extends AISDKError3 {
26096
26326
  message
26097
26327
  }) {
26098
26328
  super({
26099
- name: name76,
26329
+ name: name86,
26100
26330
  message: `Invalid argument for parameter ${parameter}: ${message}`
26101
26331
  });
26102
- this[_a86] = true;
26332
+ this[_a96] = true;
26103
26333
  this.parameter = parameter;
26104
26334
  this.value = value;
26105
26335
  }
26106
26336
  static isInstance(error) {
26107
- return AISDKError3.hasMarker(error, marker86);
26337
+ return AISDKError3.hasMarker(error, marker96);
26108
26338
  }
26109
26339
  };
26110
- _a86 = symbol86;
26111
- var name86 = "AI_NoObjectGeneratedError";
26112
- var marker823 = `vercel.ai.error.${name86}`;
26340
+ _a96 = symbol96;
26341
+ var name822 = "AI_NoObjectGeneratedError";
26342
+ var marker823 = `vercel.ai.error.${name822}`;
26113
26343
  var symbol823 = Symbol.for(marker823);
26114
26344
  var _a823;
26115
26345
  var NoObjectGeneratedError3 = class extends AISDKError3 {
@@ -26121,7 +26351,7 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
26121
26351
  usage,
26122
26352
  finishReason
26123
26353
  }) {
26124
- super({ name: name86, message, cause });
26354
+ super({ name: name822, message, cause });
26125
26355
  this[_a823] = true;
26126
26356
  this.text = text222;
26127
26357
  this.response = response;
@@ -26281,7 +26511,7 @@ function getTotalTimeoutMs(timeout) {
26281
26511
  }
26282
26512
  return timeout.totalMs;
26283
26513
  }
26284
- var VERSION33 = "6.0.69";
26514
+ var VERSION33 = "6.0.91";
26285
26515
  var dataContentSchema3 = z42.z.union([
26286
26516
  z42.z.string(),
26287
26517
  z42.z.instanceof(Uint8Array),
@@ -26289,8 +26519,8 @@ var dataContentSchema3 = z42.z.union([
26289
26519
  z42.z.custom(
26290
26520
  // Buffer might not be available in some environments such as CloudFlare:
26291
26521
  (value) => {
26292
- var _a21, _b83;
26293
- return (_b83 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b83 : false;
26522
+ var _a21, _b92;
26523
+ return (_b92 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b92 : false;
26294
26524
  },
26295
26525
  { message: "Must be a Buffer" }
26296
26526
  )
@@ -39974,5 +40204,5 @@ exports.START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = START_ASYNC_AGENT_BUILDER_ACTIO
39974
40204
  exports.STREAM_AGENT_BUILDER_ACTION_ROUTE = STREAM_AGENT_BUILDER_ACTION_ROUTE;
39975
40205
  exports.STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE;
39976
40206
  exports.agent_builder_exports = agent_builder_exports;
39977
- //# sourceMappingURL=chunk-EBYX6A46.cjs.map
39978
- //# sourceMappingURL=chunk-EBYX6A46.cjs.map
40207
+ //# sourceMappingURL=chunk-O36HRJ75.cjs.map
40208
+ //# sourceMappingURL=chunk-O36HRJ75.cjs.map