@mastra/server 1.29.0-alpha.6 → 1.29.1-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.
Files changed (92) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/{chunk-TRMAUC6D.cjs → chunk-3C3OXZPL.cjs} +4 -4
  3. package/dist/{chunk-TRMAUC6D.cjs.map → chunk-3C3OXZPL.cjs.map} +1 -1
  4. package/dist/{chunk-HBMTKCJL.cjs → chunk-53QVLUCB.cjs} +3 -3
  5. package/dist/{chunk-HBMTKCJL.cjs.map → chunk-53QVLUCB.cjs.map} +1 -1
  6. package/dist/{chunk-UMLVM74X.js → chunk-7NYP7OX2.js} +3 -3
  7. package/dist/{chunk-UMLVM74X.js.map → chunk-7NYP7OX2.js.map} +1 -1
  8. package/dist/{chunk-PBYMU4C4.js → chunk-EPCOAEFM.js} +5 -3
  9. package/dist/{chunk-PBYMU4C4.js.map → chunk-EPCOAEFM.js.map} +1 -1
  10. package/dist/{chunk-SJGVGNXJ.cjs → chunk-EPRYRKVV.cjs} +7 -7
  11. package/dist/{chunk-SJGVGNXJ.cjs.map → chunk-EPRYRKVV.cjs.map} +1 -1
  12. package/dist/{chunk-D4DWAPZU.js → chunk-GKLP6PD3.js} +3 -3
  13. package/dist/{chunk-D4DWAPZU.js.map → chunk-GKLP6PD3.js.map} +1 -1
  14. package/dist/{chunk-T32ZPNKL.cjs → chunk-GXCTBYTR.cjs} +4 -4
  15. package/dist/{chunk-T32ZPNKL.cjs.map → chunk-GXCTBYTR.cjs.map} +1 -1
  16. package/dist/{chunk-QZSLYLW4.js → chunk-HU57X24H.js} +3 -3
  17. package/dist/{chunk-QZSLYLW4.js.map → chunk-HU57X24H.js.map} +1 -1
  18. package/dist/{chunk-SRVUIHVN.js → chunk-JKNEQ3J4.js} +3 -3
  19. package/dist/{chunk-SRVUIHVN.js.map → chunk-JKNEQ3J4.js.map} +1 -1
  20. package/dist/{chunk-E4SZPFH3.js → chunk-JLLUTTIP.js} +3 -3
  21. package/dist/{chunk-E4SZPFH3.js.map → chunk-JLLUTTIP.js.map} +1 -1
  22. package/dist/{chunk-NIGJATIB.cjs → chunk-LIHUIA74.cjs} +5 -5
  23. package/dist/{chunk-NIGJATIB.cjs.map → chunk-LIHUIA74.cjs.map} +1 -1
  24. package/dist/{chunk-2XESZTZT.cjs → chunk-LOUG7JBX.cjs} +10 -10
  25. package/dist/{chunk-2XESZTZT.cjs.map → chunk-LOUG7JBX.cjs.map} +1 -1
  26. package/dist/{chunk-MIZHXCAC.js → chunk-NIZUR27T.js} +79 -34
  27. package/dist/chunk-NIZUR27T.js.map +1 -0
  28. package/dist/{chunk-OY6VG2JH.cjs → chunk-P6OB5MFM.cjs} +818 -35
  29. package/dist/chunk-P6OB5MFM.cjs.map +1 -0
  30. package/dist/{chunk-AZI2SAH6.cjs → chunk-PTTZTL3P.cjs} +6 -6
  31. package/dist/{chunk-AZI2SAH6.cjs.map → chunk-PTTZTL3P.cjs.map} +1 -1
  32. package/dist/{chunk-34CASLHS.js → chunk-SMDDF5Q2.js} +3 -3
  33. package/dist/{chunk-34CASLHS.js.map → chunk-SMDDF5Q2.js.map} +1 -1
  34. package/dist/{chunk-FJC2FLV6.js → chunk-TXQIQQRH.js} +3 -3
  35. package/dist/{chunk-FJC2FLV6.js.map → chunk-TXQIQQRH.js.map} +1 -1
  36. package/dist/{chunk-JOGDEYIU.cjs → chunk-UHIBPBN7.cjs} +79 -34
  37. package/dist/chunk-UHIBPBN7.cjs.map +1 -0
  38. package/dist/{chunk-J5JMA2EP.cjs → chunk-XCZ44WKI.cjs} +5 -3
  39. package/dist/chunk-XCZ44WKI.cjs.map +1 -0
  40. package/dist/{chunk-LCYZZIAU.js → chunk-Y3VOPMKQ.js} +800 -17
  41. package/dist/chunk-Y3VOPMKQ.js.map +1 -0
  42. package/dist/{chunk-ROPYYPBZ.js → chunk-YA4B6LPU.js} +4 -4
  43. package/dist/{chunk-ROPYYPBZ.js.map → chunk-YA4B6LPU.js.map} +1 -1
  44. package/dist/{chunk-HK6NFKTA.cjs → chunk-ZWIUMFSO.cjs} +4 -4
  45. package/dist/{chunk-HK6NFKTA.cjs.map → chunk-ZWIUMFSO.cjs.map} +1 -1
  46. package/dist/docs/SKILL.md +1 -1
  47. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  48. package/dist/{observational-memory-YYO73QMY-KGMPHQD4.cjs → observational-memory-YYO73QMY-CHIPDTZY.cjs} +26 -26
  49. package/dist/{observational-memory-YYO73QMY-KGMPHQD4.cjs.map → observational-memory-YYO73QMY-CHIPDTZY.cjs.map} +1 -1
  50. package/dist/{observational-memory-YYO73QMY-Q4SXDDYL.js → observational-memory-YYO73QMY-JNLMPY5B.js} +3 -3
  51. package/dist/{observational-memory-YYO73QMY-Q4SXDDYL.js.map → observational-memory-YYO73QMY-JNLMPY5B.js.map} +1 -1
  52. package/dist/{probe-image-size-7HF7Q24F.cjs → probe-image-size-H2PYJKCK.cjs} +113 -12
  53. package/dist/probe-image-size-H2PYJKCK.cjs.map +1 -0
  54. package/dist/{probe-image-size-M5NYSF5D.js → probe-image-size-QWKVSEOF.js} +113 -12
  55. package/dist/probe-image-size-QWKVSEOF.js.map +1 -0
  56. package/dist/server/handlers/a2a.cjs +10 -10
  57. package/dist/server/handlers/a2a.js +1 -1
  58. package/dist/server/handlers/agent-builder.cjs +16 -16
  59. package/dist/server/handlers/agent-builder.js +1 -1
  60. package/dist/server/handlers/agents.cjs +37 -37
  61. package/dist/server/handlers/agents.d.ts.map +1 -1
  62. package/dist/server/handlers/agents.js +1 -1
  63. package/dist/server/handlers/auth.cjs +11 -11
  64. package/dist/server/handlers/auth.d.ts +16 -0
  65. package/dist/server/handlers/auth.d.ts.map +1 -1
  66. package/dist/server/handlers/auth.js +1 -1
  67. package/dist/server/handlers/conversations.cjs +5 -5
  68. package/dist/server/handlers/conversations.js +1 -1
  69. package/dist/server/handlers/responses.cjs +4 -4
  70. package/dist/server/handlers/responses.js +1 -1
  71. package/dist/server/handlers/scores.cjs +7 -7
  72. package/dist/server/handlers/scores.js +1 -1
  73. package/dist/server/handlers/tools.cjs +6 -6
  74. package/dist/server/handlers/tools.js +1 -1
  75. package/dist/server/handlers/voice.cjs +8 -8
  76. package/dist/server/handlers/voice.js +1 -1
  77. package/dist/server/handlers.cjs +16 -16
  78. package/dist/server/handlers.js +8 -8
  79. package/dist/server/schemas/auth.d.ts +11 -0
  80. package/dist/server/schemas/auth.d.ts.map +1 -1
  81. package/dist/server/schemas/index.cjs +19 -19
  82. package/dist/server/schemas/index.js +1 -1
  83. package/dist/server/server-adapter/index.cjs +75 -75
  84. package/dist/server/server-adapter/index.js +9 -9
  85. package/package.json +9 -9
  86. package/dist/chunk-J5JMA2EP.cjs.map +0 -1
  87. package/dist/chunk-JOGDEYIU.cjs.map +0 -1
  88. package/dist/chunk-LCYZZIAU.js.map +0 -1
  89. package/dist/chunk-MIZHXCAC.js.map +0 -1
  90. package/dist/chunk-OY6VG2JH.cjs.map +0 -1
  91. package/dist/probe-image-size-7HF7Q24F.cjs.map +0 -1
  92. package/dist/probe-image-size-M5NYSF5D.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkHBMTKCJL_cjs = require('./chunk-HBMTKCJL.cjs');
3
+ var chunk53QVLUCB_cjs = require('./chunk-53QVLUCB.cjs');
4
4
  var chunkR2ODPDKE_cjs = require('./chunk-R2ODPDKE.cjs');
5
5
  var chunkEQR2JWYK_cjs = require('./chunk-EQR2JWYK.cjs');
6
6
  var chunkRPOKTN4O_cjs = require('./chunk-RPOKTN4O.cjs');
@@ -5274,7 +5274,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
5274
5274
  );
5275
5275
  return Object.fromEntries(normalizedHeaders.entries());
5276
5276
  }
5277
- var VERSION2 = "3.0.22";
5277
+ var VERSION2 = "3.0.23";
5278
5278
  var getOriginalFetch = () => globalThis.fetch;
5279
5279
  var getFromApi = async ({
5280
5280
  url,
@@ -7321,6 +7321,7 @@ async function parseAuthMethod(headers) {
7321
7321
  var gatewayAuthMethodSchema = lazyValidator(
7322
7322
  () => zodSchema2(z4.z.union([z4.z.literal("api-key"), z4.z.literal("oidc")]))
7323
7323
  );
7324
+ var KNOWN_MODEL_TYPES = ["embedding", "image", "language"];
7324
7325
  var GatewayFetchMetadata = class {
7325
7326
  constructor(config) {
7326
7327
  this.config = config;
@@ -7391,8 +7392,12 @@ var gatewayAvailableModelsResponseSchema = lazyValidator(
7391
7392
  provider: z4.z.string(),
7392
7393
  modelId: z4.z.string()
7393
7394
  }),
7394
- modelType: z4.z.enum(["language", "embedding", "image"]).nullish()
7395
+ modelType: z4.z.string().nullish()
7395
7396
  })
7397
+ ).transform(
7398
+ (models) => models.filter(
7399
+ (m) => m.modelType == null || KNOWN_MODEL_TYPES.includes(m.modelType)
7400
+ )
7396
7401
  )
7397
7402
  })
7398
7403
  )
@@ -7408,6 +7413,187 @@ var gatewayCreditsResponseSchema = lazyValidator(
7408
7413
  }))
7409
7414
  )
7410
7415
  );
7416
+ var GatewaySpendReport = class {
7417
+ constructor(config) {
7418
+ this.config = config;
7419
+ }
7420
+ async getSpendReport(params) {
7421
+ try {
7422
+ const baseUrl = new URL(this.config.baseURL);
7423
+ const searchParams = new URLSearchParams();
7424
+ searchParams.set("start_date", params.startDate);
7425
+ searchParams.set("end_date", params.endDate);
7426
+ if (params.groupBy) {
7427
+ searchParams.set("group_by", params.groupBy);
7428
+ }
7429
+ if (params.datePart) {
7430
+ searchParams.set("date_part", params.datePart);
7431
+ }
7432
+ if (params.userId) {
7433
+ searchParams.set("user_id", params.userId);
7434
+ }
7435
+ if (params.model) {
7436
+ searchParams.set("model", params.model);
7437
+ }
7438
+ if (params.provider) {
7439
+ searchParams.set("provider", params.provider);
7440
+ }
7441
+ if (params.credentialType) {
7442
+ searchParams.set("credential_type", params.credentialType);
7443
+ }
7444
+ if (params.tags && params.tags.length > 0) {
7445
+ searchParams.set("tags", params.tags.join(","));
7446
+ }
7447
+ const { value } = await getFromApi({
7448
+ url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
7449
+ headers: await resolve(this.config.headers()),
7450
+ successfulResponseHandler: createJsonResponseHandler(
7451
+ gatewaySpendReportResponseSchema
7452
+ ),
7453
+ failedResponseHandler: createJsonErrorResponseHandler({
7454
+ errorSchema: z4.z.any(),
7455
+ errorToMessage: (data) => data
7456
+ }),
7457
+ fetch: this.config.fetch
7458
+ });
7459
+ return value;
7460
+ } catch (error) {
7461
+ throw await asGatewayError(error);
7462
+ }
7463
+ }
7464
+ };
7465
+ var gatewaySpendReportResponseSchema = lazySchema(
7466
+ () => zodSchema2(
7467
+ z4.z.object({
7468
+ results: z4.z.array(
7469
+ z4.z.object({
7470
+ day: z4.z.string().optional(),
7471
+ hour: z4.z.string().optional(),
7472
+ user: z4.z.string().optional(),
7473
+ model: z4.z.string().optional(),
7474
+ tag: z4.z.string().optional(),
7475
+ provider: z4.z.string().optional(),
7476
+ credential_type: z4.z.enum(["byok", "system"]).optional(),
7477
+ total_cost: z4.z.number(),
7478
+ market_cost: z4.z.number().optional(),
7479
+ input_tokens: z4.z.number().optional(),
7480
+ output_tokens: z4.z.number().optional(),
7481
+ cached_input_tokens: z4.z.number().optional(),
7482
+ cache_creation_input_tokens: z4.z.number().optional(),
7483
+ reasoning_tokens: z4.z.number().optional(),
7484
+ request_count: z4.z.number().optional()
7485
+ }).transform(
7486
+ ({
7487
+ credential_type,
7488
+ total_cost,
7489
+ market_cost,
7490
+ input_tokens,
7491
+ output_tokens,
7492
+ cached_input_tokens,
7493
+ cache_creation_input_tokens,
7494
+ reasoning_tokens,
7495
+ request_count,
7496
+ ...rest
7497
+ }) => ({
7498
+ ...rest,
7499
+ ...credential_type !== void 0 ? { credentialType: credential_type } : {},
7500
+ totalCost: total_cost,
7501
+ ...market_cost !== void 0 ? { marketCost: market_cost } : {},
7502
+ ...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
7503
+ ...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
7504
+ ...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
7505
+ ...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
7506
+ ...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
7507
+ ...request_count !== void 0 ? { requestCount: request_count } : {}
7508
+ })
7509
+ )
7510
+ )
7511
+ })
7512
+ )
7513
+ );
7514
+ var GatewayGenerationInfoFetcher = class {
7515
+ constructor(config) {
7516
+ this.config = config;
7517
+ }
7518
+ async getGenerationInfo(params) {
7519
+ try {
7520
+ const baseUrl = new URL(this.config.baseURL);
7521
+ const { value } = await getFromApi({
7522
+ url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
7523
+ headers: await resolve(this.config.headers()),
7524
+ successfulResponseHandler: createJsonResponseHandler(
7525
+ gatewayGenerationInfoResponseSchema
7526
+ ),
7527
+ failedResponseHandler: createJsonErrorResponseHandler({
7528
+ errorSchema: z4.z.any(),
7529
+ errorToMessage: (data) => data
7530
+ }),
7531
+ fetch: this.config.fetch
7532
+ });
7533
+ return value;
7534
+ } catch (error) {
7535
+ throw await asGatewayError(error);
7536
+ }
7537
+ }
7538
+ };
7539
+ var gatewayGenerationInfoResponseSchema = lazySchema(
7540
+ () => zodSchema2(
7541
+ z4.z.object({
7542
+ data: z4.z.object({
7543
+ id: z4.z.string(),
7544
+ total_cost: z4.z.number(),
7545
+ upstream_inference_cost: z4.z.number(),
7546
+ usage: z4.z.number(),
7547
+ created_at: z4.z.string(),
7548
+ model: z4.z.string(),
7549
+ is_byok: z4.z.boolean(),
7550
+ provider_name: z4.z.string(),
7551
+ streamed: z4.z.boolean(),
7552
+ finish_reason: z4.z.string(),
7553
+ latency: z4.z.number(),
7554
+ generation_time: z4.z.number(),
7555
+ native_tokens_prompt: z4.z.number(),
7556
+ native_tokens_completion: z4.z.number(),
7557
+ native_tokens_reasoning: z4.z.number(),
7558
+ native_tokens_cached: z4.z.number(),
7559
+ native_tokens_cache_creation: z4.z.number(),
7560
+ billable_web_search_calls: z4.z.number()
7561
+ }).transform(
7562
+ ({
7563
+ total_cost,
7564
+ upstream_inference_cost,
7565
+ created_at,
7566
+ is_byok,
7567
+ provider_name,
7568
+ finish_reason,
7569
+ generation_time,
7570
+ native_tokens_prompt,
7571
+ native_tokens_completion,
7572
+ native_tokens_reasoning,
7573
+ native_tokens_cached,
7574
+ native_tokens_cache_creation,
7575
+ billable_web_search_calls,
7576
+ ...rest
7577
+ }) => ({
7578
+ ...rest,
7579
+ totalCost: total_cost,
7580
+ upstreamInferenceCost: upstream_inference_cost,
7581
+ createdAt: created_at,
7582
+ isByok: is_byok,
7583
+ providerName: provider_name,
7584
+ finishReason: finish_reason,
7585
+ generationTime: generation_time,
7586
+ promptTokens: native_tokens_prompt,
7587
+ completionTokens: native_tokens_completion,
7588
+ reasoningTokens: native_tokens_reasoning,
7589
+ cachedTokens: native_tokens_cached,
7590
+ cacheCreationTokens: native_tokens_cache_creation,
7591
+ billableWebSearchCalls: billable_web_search_calls
7592
+ })
7593
+ )
7594
+ }).transform(({ data }) => data)
7595
+ )
7596
+ );
7411
7597
  var GatewayLanguageModel = class {
7412
7598
  constructor(modelId, config) {
7413
7599
  this.modelId = modelId;
@@ -7910,7 +8096,7 @@ async function getVercelRequestId() {
7910
8096
  var _a932;
7911
8097
  return (_a932 = getContext().headers) == null ? void 0 : _a932["x-vercel-id"];
7912
8098
  }
7913
- var VERSION3 = "2.0.59";
8099
+ var VERSION3 = "2.0.82";
7914
8100
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
7915
8101
  function createGatewayProvider(options = {}) {
7916
8102
  var _a932, _b93;
@@ -8008,6 +8194,30 @@ function createGatewayProvider(options = {}) {
8008
8194
  );
8009
8195
  });
8010
8196
  };
8197
+ const getSpendReport = async (params) => {
8198
+ return new GatewaySpendReport({
8199
+ baseURL,
8200
+ headers: getHeaders,
8201
+ fetch: options.fetch
8202
+ }).getSpendReport(params).catch(async (error) => {
8203
+ throw await asGatewayError(
8204
+ error,
8205
+ await parseAuthMethod(await getHeaders())
8206
+ );
8207
+ });
8208
+ };
8209
+ const getGenerationInfo = async (params) => {
8210
+ return new GatewayGenerationInfoFetcher({
8211
+ baseURL,
8212
+ headers: getHeaders,
8213
+ fetch: options.fetch
8214
+ }).getGenerationInfo(params).catch(async (error) => {
8215
+ throw await asGatewayError(
8216
+ error,
8217
+ await parseAuthMethod(await getHeaders())
8218
+ );
8219
+ });
8220
+ };
8011
8221
  const provider = function(modelId) {
8012
8222
  if (new.target) {
8013
8223
  throw new Error(
@@ -8018,6 +8228,8 @@ function createGatewayProvider(options = {}) {
8018
8228
  };
8019
8229
  provider.getAvailableModels = getAvailableModels;
8020
8230
  provider.getCredits = getCredits;
8231
+ provider.getSpendReport = getSpendReport;
8232
+ provider.getGenerationInfo = getGenerationInfo;
8021
8233
  provider.imageModel = (modelId) => {
8022
8234
  return new GatewayImageModel(modelId, {
8023
8235
  provider: "gateway",
@@ -8871,7 +9083,7 @@ function getGlobalProvider() {
8871
9083
  var _a163;
8872
9084
  return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
8873
9085
  }
8874
- var VERSION32 = "5.0.155";
9086
+ var VERSION32 = "5.0.179";
8875
9087
  var dataContentSchema2 = z4.z.union([
8876
9088
  z4.z.string(),
8877
9089
  z4.z.instanceof(Uint8Array),
@@ -10482,7 +10694,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
10482
10694
  );
10483
10695
  return Object.fromEntries(normalizedHeaders.entries());
10484
10696
  }
10485
- var VERSION4 = "4.0.19";
10697
+ var VERSION4 = "4.0.23";
10486
10698
  var getOriginalFetch3 = () => globalThis.fetch;
10487
10699
  var getFromApi2 = async ({
10488
10700
  url,
@@ -12567,6 +12779,13 @@ async function parseAuthMethod2(headers) {
12567
12779
  var gatewayAuthMethodSchema2 = lazySchema2(
12568
12780
  () => zodSchema3(z4.z.union([z4.z.literal("api-key"), z4.z.literal("oidc")]))
12569
12781
  );
12782
+ var KNOWN_MODEL_TYPES2 = [
12783
+ "embedding",
12784
+ "image",
12785
+ "language",
12786
+ "reranking",
12787
+ "video"
12788
+ ];
12570
12789
  var GatewayFetchMetadata2 = class {
12571
12790
  constructor(config) {
12572
12791
  this.config = config;
@@ -12637,8 +12856,12 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema2(
12637
12856
  provider: z4.z.string(),
12638
12857
  modelId: z4.z.string()
12639
12858
  }),
12640
- modelType: z4.z.enum(["embedding", "image", "language", "video"]).nullish()
12859
+ modelType: z4.z.string().nullish()
12641
12860
  })
12861
+ ).transform(
12862
+ (models) => models.filter(
12863
+ (m) => m.modelType == null || KNOWN_MODEL_TYPES2.includes(m.modelType)
12864
+ )
12642
12865
  )
12643
12866
  })
12644
12867
  )
@@ -12654,6 +12877,187 @@ var gatewayCreditsResponseSchema2 = lazySchema2(
12654
12877
  }))
12655
12878
  )
12656
12879
  );
12880
+ var GatewaySpendReport2 = class {
12881
+ constructor(config) {
12882
+ this.config = config;
12883
+ }
12884
+ async getSpendReport(params) {
12885
+ try {
12886
+ const baseUrl = new URL(this.config.baseURL);
12887
+ const searchParams = new URLSearchParams();
12888
+ searchParams.set("start_date", params.startDate);
12889
+ searchParams.set("end_date", params.endDate);
12890
+ if (params.groupBy) {
12891
+ searchParams.set("group_by", params.groupBy);
12892
+ }
12893
+ if (params.datePart) {
12894
+ searchParams.set("date_part", params.datePart);
12895
+ }
12896
+ if (params.userId) {
12897
+ searchParams.set("user_id", params.userId);
12898
+ }
12899
+ if (params.model) {
12900
+ searchParams.set("model", params.model);
12901
+ }
12902
+ if (params.provider) {
12903
+ searchParams.set("provider", params.provider);
12904
+ }
12905
+ if (params.credentialType) {
12906
+ searchParams.set("credential_type", params.credentialType);
12907
+ }
12908
+ if (params.tags && params.tags.length > 0) {
12909
+ searchParams.set("tags", params.tags.join(","));
12910
+ }
12911
+ const { value } = await getFromApi2({
12912
+ url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
12913
+ headers: await resolve2(this.config.headers()),
12914
+ successfulResponseHandler: createJsonResponseHandler2(
12915
+ gatewaySpendReportResponseSchema2
12916
+ ),
12917
+ failedResponseHandler: createJsonErrorResponseHandler2({
12918
+ errorSchema: z4.z.any(),
12919
+ errorToMessage: (data) => data
12920
+ }),
12921
+ fetch: this.config.fetch
12922
+ });
12923
+ return value;
12924
+ } catch (error) {
12925
+ throw await asGatewayError2(error);
12926
+ }
12927
+ }
12928
+ };
12929
+ var gatewaySpendReportResponseSchema2 = lazySchema2(
12930
+ () => zodSchema3(
12931
+ z4.z.object({
12932
+ results: z4.z.array(
12933
+ z4.z.object({
12934
+ day: z4.z.string().optional(),
12935
+ hour: z4.z.string().optional(),
12936
+ user: z4.z.string().optional(),
12937
+ model: z4.z.string().optional(),
12938
+ tag: z4.z.string().optional(),
12939
+ provider: z4.z.string().optional(),
12940
+ credential_type: z4.z.enum(["byok", "system"]).optional(),
12941
+ total_cost: z4.z.number(),
12942
+ market_cost: z4.z.number().optional(),
12943
+ input_tokens: z4.z.number().optional(),
12944
+ output_tokens: z4.z.number().optional(),
12945
+ cached_input_tokens: z4.z.number().optional(),
12946
+ cache_creation_input_tokens: z4.z.number().optional(),
12947
+ reasoning_tokens: z4.z.number().optional(),
12948
+ request_count: z4.z.number().optional()
12949
+ }).transform(
12950
+ ({
12951
+ credential_type,
12952
+ total_cost,
12953
+ market_cost,
12954
+ input_tokens,
12955
+ output_tokens,
12956
+ cached_input_tokens,
12957
+ cache_creation_input_tokens,
12958
+ reasoning_tokens,
12959
+ request_count,
12960
+ ...rest
12961
+ }) => ({
12962
+ ...rest,
12963
+ ...credential_type !== void 0 ? { credentialType: credential_type } : {},
12964
+ totalCost: total_cost,
12965
+ ...market_cost !== void 0 ? { marketCost: market_cost } : {},
12966
+ ...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
12967
+ ...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
12968
+ ...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
12969
+ ...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
12970
+ ...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
12971
+ ...request_count !== void 0 ? { requestCount: request_count } : {}
12972
+ })
12973
+ )
12974
+ )
12975
+ })
12976
+ )
12977
+ );
12978
+ var GatewayGenerationInfoFetcher2 = class {
12979
+ constructor(config) {
12980
+ this.config = config;
12981
+ }
12982
+ async getGenerationInfo(params) {
12983
+ try {
12984
+ const baseUrl = new URL(this.config.baseURL);
12985
+ const { value } = await getFromApi2({
12986
+ url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
12987
+ headers: await resolve2(this.config.headers()),
12988
+ successfulResponseHandler: createJsonResponseHandler2(
12989
+ gatewayGenerationInfoResponseSchema2
12990
+ ),
12991
+ failedResponseHandler: createJsonErrorResponseHandler2({
12992
+ errorSchema: z4.z.any(),
12993
+ errorToMessage: (data) => data
12994
+ }),
12995
+ fetch: this.config.fetch
12996
+ });
12997
+ return value;
12998
+ } catch (error) {
12999
+ throw await asGatewayError2(error);
13000
+ }
13001
+ }
13002
+ };
13003
+ var gatewayGenerationInfoResponseSchema2 = lazySchema2(
13004
+ () => zodSchema3(
13005
+ z4.z.object({
13006
+ data: z4.z.object({
13007
+ id: z4.z.string(),
13008
+ total_cost: z4.z.number(),
13009
+ upstream_inference_cost: z4.z.number(),
13010
+ usage: z4.z.number(),
13011
+ created_at: z4.z.string(),
13012
+ model: z4.z.string(),
13013
+ is_byok: z4.z.boolean(),
13014
+ provider_name: z4.z.string(),
13015
+ streamed: z4.z.boolean(),
13016
+ finish_reason: z4.z.string(),
13017
+ latency: z4.z.number(),
13018
+ generation_time: z4.z.number(),
13019
+ native_tokens_prompt: z4.z.number(),
13020
+ native_tokens_completion: z4.z.number(),
13021
+ native_tokens_reasoning: z4.z.number(),
13022
+ native_tokens_cached: z4.z.number(),
13023
+ native_tokens_cache_creation: z4.z.number(),
13024
+ billable_web_search_calls: z4.z.number()
13025
+ }).transform(
13026
+ ({
13027
+ total_cost,
13028
+ upstream_inference_cost,
13029
+ created_at,
13030
+ is_byok,
13031
+ provider_name,
13032
+ finish_reason,
13033
+ generation_time,
13034
+ native_tokens_prompt,
13035
+ native_tokens_completion,
13036
+ native_tokens_reasoning,
13037
+ native_tokens_cached,
13038
+ native_tokens_cache_creation,
13039
+ billable_web_search_calls,
13040
+ ...rest
13041
+ }) => ({
13042
+ ...rest,
13043
+ totalCost: total_cost,
13044
+ upstreamInferenceCost: upstream_inference_cost,
13045
+ createdAt: created_at,
13046
+ isByok: is_byok,
13047
+ providerName: provider_name,
13048
+ finishReason: finish_reason,
13049
+ generationTime: generation_time,
13050
+ promptTokens: native_tokens_prompt,
13051
+ completionTokens: native_tokens_completion,
13052
+ reasoningTokens: native_tokens_reasoning,
13053
+ cachedTokens: native_tokens_cached,
13054
+ cacheCreationTokens: native_tokens_cache_creation,
13055
+ billableWebSearchCalls: billable_web_search_calls
13056
+ })
13057
+ )
13058
+ }).transform(({ data }) => data)
13059
+ )
13060
+ );
12657
13061
  var GatewayLanguageModel2 = class {
12658
13062
  constructor(modelId, config) {
12659
13063
  this.modelId = modelId;
@@ -13201,6 +13605,86 @@ var gatewayVideoEventSchema = z4.z.discriminatedUnion("type", [
13201
13605
  param: z4.z.unknown().nullable()
13202
13606
  })
13203
13607
  ]);
13608
+ var GatewayRerankingModel = class {
13609
+ constructor(modelId, config) {
13610
+ this.modelId = modelId;
13611
+ this.config = config;
13612
+ this.specificationVersion = "v3";
13613
+ }
13614
+ get provider() {
13615
+ return this.config.provider;
13616
+ }
13617
+ async doRerank({
13618
+ documents,
13619
+ query,
13620
+ topN,
13621
+ headers,
13622
+ abortSignal,
13623
+ providerOptions
13624
+ }) {
13625
+ const resolvedHeaders = await resolve2(this.config.headers());
13626
+ try {
13627
+ const {
13628
+ responseHeaders,
13629
+ value: responseBody,
13630
+ rawValue
13631
+ } = await postJsonToApi2({
13632
+ url: this.getUrl(),
13633
+ headers: combineHeaders2(
13634
+ resolvedHeaders,
13635
+ headers != null ? headers : {},
13636
+ this.getModelConfigHeaders(),
13637
+ await resolve2(this.config.o11yHeaders)
13638
+ ),
13639
+ body: {
13640
+ documents,
13641
+ query,
13642
+ ...topN != null ? { topN } : {},
13643
+ ...providerOptions ? { providerOptions } : {}
13644
+ },
13645
+ successfulResponseHandler: createJsonResponseHandler2(
13646
+ gatewayRerankingResponseSchema
13647
+ ),
13648
+ failedResponseHandler: createJsonErrorResponseHandler2({
13649
+ errorSchema: z4.z.any(),
13650
+ errorToMessage: (data) => data
13651
+ }),
13652
+ ...abortSignal && { abortSignal },
13653
+ fetch: this.config.fetch
13654
+ });
13655
+ return {
13656
+ ranking: responseBody.ranking,
13657
+ providerMetadata: responseBody.providerMetadata,
13658
+ response: { headers: responseHeaders, body: rawValue },
13659
+ warnings: []
13660
+ };
13661
+ } catch (error) {
13662
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
13663
+ }
13664
+ }
13665
+ getUrl() {
13666
+ return `${this.config.baseURL}/reranking-model`;
13667
+ }
13668
+ getModelConfigHeaders() {
13669
+ return {
13670
+ "ai-reranking-model-specification-version": "3",
13671
+ "ai-model-id": this.modelId
13672
+ };
13673
+ }
13674
+ };
13675
+ var gatewayRerankingResponseSchema = lazySchema2(
13676
+ () => zodSchema3(
13677
+ z4.z.object({
13678
+ ranking: z4.z.array(
13679
+ z4.z.object({
13680
+ index: z4.z.number(),
13681
+ relevanceScore: z4.z.number()
13682
+ })
13683
+ ),
13684
+ providerMetadata: z4.z.record(z4.z.string(), z4.z.record(z4.z.string(), z4.z.unknown())).optional()
13685
+ })
13686
+ )
13687
+ );
13204
13688
  var parallelSearchInputSchema2 = lazySchema2(
13205
13689
  () => zodSchema3(
13206
13690
  zod.z.object({
@@ -13377,7 +13861,7 @@ async function getVercelRequestId2() {
13377
13861
  var _a932;
13378
13862
  return (_a932 = getContext2().headers) == null ? void 0 : _a932["x-vercel-id"];
13379
13863
  }
13380
- var VERSION5 = "3.0.66";
13864
+ var VERSION5 = "3.0.104";
13381
13865
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
13382
13866
  function createGatewayProvider2(options = {}) {
13383
13867
  var _a932, _b93;
@@ -13477,6 +13961,30 @@ function createGatewayProvider2(options = {}) {
13477
13961
  );
13478
13962
  });
13479
13963
  };
13964
+ const getSpendReport = async (params) => {
13965
+ return new GatewaySpendReport2({
13966
+ baseURL,
13967
+ headers: getHeaders,
13968
+ fetch: options.fetch
13969
+ }).getSpendReport(params).catch(async (error) => {
13970
+ throw await asGatewayError2(
13971
+ error,
13972
+ await parseAuthMethod2(await getHeaders())
13973
+ );
13974
+ });
13975
+ };
13976
+ const getGenerationInfo = async (params) => {
13977
+ return new GatewayGenerationInfoFetcher2({
13978
+ baseURL,
13979
+ headers: getHeaders,
13980
+ fetch: options.fetch
13981
+ }).getGenerationInfo(params).catch(async (error) => {
13982
+ throw await asGatewayError2(
13983
+ error,
13984
+ await parseAuthMethod2(await getHeaders())
13985
+ );
13986
+ });
13987
+ };
13480
13988
  const provider = function(modelId) {
13481
13989
  if (new.target) {
13482
13990
  throw new Error(
@@ -13488,6 +13996,8 @@ function createGatewayProvider2(options = {}) {
13488
13996
  provider.specificationVersion = "v3";
13489
13997
  provider.getAvailableModels = getAvailableModels;
13490
13998
  provider.getCredits = getCredits;
13999
+ provider.getSpendReport = getSpendReport;
14000
+ provider.getGenerationInfo = getGenerationInfo;
13491
14001
  provider.imageModel = (modelId) => {
13492
14002
  return new GatewayImageModel2(modelId, {
13493
14003
  provider: "gateway",
@@ -13518,6 +14028,17 @@ function createGatewayProvider2(options = {}) {
13518
14028
  o11yHeaders: createO11yHeaders()
13519
14029
  });
13520
14030
  };
14031
+ const createRerankingModel = (modelId) => {
14032
+ return new GatewayRerankingModel(modelId, {
14033
+ provider: "gateway",
14034
+ baseURL,
14035
+ headers: getHeaders,
14036
+ fetch: options.fetch,
14037
+ o11yHeaders: createO11yHeaders()
14038
+ });
14039
+ };
14040
+ provider.rerankingModel = createRerankingModel;
14041
+ provider.reranking = createRerankingModel;
13521
14042
  provider.chat = provider.languageModel;
13522
14043
  provider.embedding = provider.embeddingModel;
13523
14044
  provider.image = provider.imageModel;
@@ -14450,7 +14971,7 @@ function getTotalTimeoutMs(timeout) {
14450
14971
  }
14451
14972
  return timeout.totalMs;
14452
14973
  }
14453
- var VERSION33 = "6.0.116";
14974
+ var VERSION33 = "6.0.168";
14454
14975
  var dataContentSchema3 = z4.z.union([
14455
14976
  z4.z.string(),
14456
14977
  z4.z.instanceof(Uint8Array),
@@ -16154,8 +16675,8 @@ function formatTimestamp(date) {
16154
16675
  return date.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "Z");
16155
16676
  }
16156
16677
  function truncateByTokens(text42, maxTokens, hint) {
16157
- if (chunkHBMTKCJL_cjs.estimateTokenCount(text42) <= maxTokens) return { text: text42, wasTruncated: false };
16158
- const truncated = chunkHBMTKCJL_cjs.truncateStringByTokens(text42, maxTokens);
16678
+ if (chunk53QVLUCB_cjs.estimateTokenCount(text42) <= maxTokens) return { text: text42, wasTruncated: false };
16679
+ const truncated = chunk53QVLUCB_cjs.truncateStringByTokens(text42, maxTokens);
16159
16680
  const suffix = hint ? ` [${hint} for more]` : "";
16160
16681
  return { text: truncated + suffix, wasTruncated: true };
16161
16682
  }
@@ -16207,11 +16728,11 @@ ${JSON.stringify(inv.args, null, 2)}`;
16207
16728
  });
16208
16729
  }
16209
16730
  if (inv.state === "result") {
16210
- const { value: resultValue } = chunkHBMTKCJL_cjs.resolveToolResultValue(
16731
+ const { value: resultValue } = chunk53QVLUCB_cjs.resolveToolResultValue(
16211
16732
  part,
16212
16733
  inv.result
16213
16734
  );
16214
- const resultStr = chunkHBMTKCJL_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
16735
+ const resultStr = chunk53QVLUCB_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
16215
16736
  const fullText = `[Tool Result: ${inv.toolName}]
16216
16737
  ${resultStr}`;
16217
16738
  parts.push(makePart(msg, i, "tool-result", fullText, detail, inv.toolName));
@@ -16238,7 +16759,7 @@ ${typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs, null, 2)}`;
16238
16759
  const toolName = part.toolName;
16239
16760
  if (toolName) {
16240
16761
  const rawResult = part.output ?? part.result;
16241
- const resultStr = chunkHBMTKCJL_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
16762
+ const resultStr = chunk53QVLUCB_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
16242
16763
  const fullText = `[Tool Result: ${toolName}]
16243
16764
  ${resultStr}`;
16244
16765
  parts.push(makePart(msg, i, "tool-result", fullText, detail, toolName));
@@ -16316,9 +16837,9 @@ function expandPriority(part) {
16316
16837
  }
16317
16838
  function renderFormattedParts(parts, timestamps, options) {
16318
16839
  const text42 = buildRenderedText(parts, timestamps);
16319
- let totalTokens = chunkHBMTKCJL_cjs.estimateTokenCount(text42);
16840
+ let totalTokens = chunk53QVLUCB_cjs.estimateTokenCount(text42);
16320
16841
  if (totalTokens > options.maxTokens) {
16321
- const truncated = chunkHBMTKCJL_cjs.truncateStringByTokens(text42, options.maxTokens);
16842
+ const truncated = chunk53QVLUCB_cjs.truncateStringByTokens(text42, options.maxTokens);
16322
16843
  return { text: truncated, truncated: true, tokenOffset: totalTokens - options.maxTokens };
16323
16844
  }
16324
16845
  const truncatedIndices = parts.map((p, i) => ({ part: p, index: i })).filter(({ part }) => part.text !== part.fullText).sort((a, b) => expandPriority(a.part) - expandPriority(b.part));
@@ -16329,8 +16850,8 @@ function renderFormattedParts(parts, timestamps, options) {
16329
16850
  for (const { part, index } of truncatedIndices) {
16330
16851
  if (remaining <= 0) break;
16331
16852
  const maxTokens = expandLimit(part);
16332
- const fullTokens = chunkHBMTKCJL_cjs.estimateTokenCount(part.fullText);
16333
- const currentTokens = chunkHBMTKCJL_cjs.estimateTokenCount(part.text);
16853
+ const fullTokens = chunk53QVLUCB_cjs.estimateTokenCount(part.fullText);
16854
+ const currentTokens = chunk53QVLUCB_cjs.estimateTokenCount(part.text);
16334
16855
  const targetTokens = Math.min(fullTokens, maxTokens);
16335
16856
  const delta = targetTokens - currentTokens;
16336
16857
  if (delta <= 0) continue;
@@ -16341,17 +16862,17 @@ function renderFormattedParts(parts, timestamps, options) {
16341
16862
  const expandedLimit = Math.min(currentTokens + remaining, maxTokens);
16342
16863
  const hint = `recall cursor="${part.messageId}" partIndex=${part.partIndex} detail="high"`;
16343
16864
  const { text: expanded2 } = truncateByTokens(part.fullText, expandedLimit, hint);
16344
- const expandedDelta = chunkHBMTKCJL_cjs.estimateTokenCount(expanded2) - currentTokens;
16865
+ const expandedDelta = chunk53QVLUCB_cjs.estimateTokenCount(expanded2) - currentTokens;
16345
16866
  parts[index] = { ...part, text: expanded2 };
16346
16867
  remaining -= expandedDelta;
16347
16868
  }
16348
16869
  }
16349
16870
  const expanded = buildRenderedText(parts, timestamps);
16350
- const expandedTokens = chunkHBMTKCJL_cjs.estimateTokenCount(expanded);
16871
+ const expandedTokens = chunk53QVLUCB_cjs.estimateTokenCount(expanded);
16351
16872
  if (expandedTokens <= options.maxTokens) {
16352
16873
  return { text: expanded, truncated: false, tokenOffset: 0 };
16353
16874
  }
16354
- const hardTruncated = chunkHBMTKCJL_cjs.truncateStringByTokens(expanded, options.maxTokens);
16875
+ const hardTruncated = chunk53QVLUCB_cjs.truncateStringByTokens(expanded, options.maxTokens);
16355
16876
  return { text: hardTruncated, truncated: true, tokenOffset: expandedTokens - options.maxTokens };
16356
16877
  }
16357
16878
  async function recallPart({
@@ -16402,7 +16923,7 @@ async function recallPart({
16402
16923
 
16403
16924
  `;
16404
16925
  const fallbackText = `${fallbackNote}${firstNextPart.text}`;
16405
- const truncatedText2 = chunkHBMTKCJL_cjs.truncateStringByTokens(fallbackText, maxTokens);
16926
+ const truncatedText2 = chunk53QVLUCB_cjs.truncateStringByTokens(fallbackText, maxTokens);
16406
16927
  const wasTruncated2 = truncatedText2 !== fallbackText;
16407
16928
  return {
16408
16929
  text: truncatedText2,
@@ -16417,7 +16938,7 @@ async function recallPart({
16417
16938
  }
16418
16939
  throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
16419
16940
  }
16420
- const truncatedText = chunkHBMTKCJL_cjs.truncateStringByTokens(target.text, maxTokens);
16941
+ const truncatedText = chunk53QVLUCB_cjs.truncateStringByTokens(target.text, maxTokens);
16421
16942
  const wasTruncated = truncatedText !== target.text;
16422
16943
  return {
16423
16944
  text: truncatedText,
@@ -17153,6 +17674,56 @@ var __experimental_updateWorkingMemoryToolVNext = (config) => {
17153
17674
  }
17154
17675
  });
17155
17676
  };
17677
+ var WORKING_MEMORY_START_TAG = "<working_memory>";
17678
+ var WORKING_MEMORY_END_TAG = "</working_memory>";
17679
+ var LEGACY_SYSTEM_REMINDER_METADATA_KEY = "dynamicAgentsMdReminder";
17680
+ function isRecord(value) {
17681
+ return typeof value === "object" && value !== null;
17682
+ }
17683
+ function removeWorkingMemoryTags(text42) {
17684
+ let result = "";
17685
+ let pos = 0;
17686
+ while (pos < text42.length) {
17687
+ const start = text42.indexOf(WORKING_MEMORY_START_TAG, pos);
17688
+ if (start === -1) {
17689
+ result += text42.substring(pos);
17690
+ break;
17691
+ }
17692
+ result += text42.substring(pos, start);
17693
+ const end = text42.indexOf(WORKING_MEMORY_END_TAG, start + WORKING_MEMORY_START_TAG.length);
17694
+ if (end === -1) {
17695
+ result += text42.substring(start);
17696
+ break;
17697
+ }
17698
+ pos = end + WORKING_MEMORY_END_TAG.length;
17699
+ }
17700
+ return result;
17701
+ }
17702
+ function extractWorkingMemoryContent(text42) {
17703
+ const start = text42.indexOf(WORKING_MEMORY_START_TAG);
17704
+ if (start === -1) return null;
17705
+ const contentStart = start + WORKING_MEMORY_START_TAG.length;
17706
+ const end = text42.indexOf(WORKING_MEMORY_END_TAG, contentStart);
17707
+ if (end === -1) return null;
17708
+ return text42.substring(contentStart, end);
17709
+ }
17710
+ function isSystemReminderMessage(message) {
17711
+ if (message.role !== "user" || !isRecord(message.content)) {
17712
+ return false;
17713
+ }
17714
+ const metadata = message.content.metadata;
17715
+ if (isRecord(metadata) && (isRecord(metadata.systemReminder) || LEGACY_SYSTEM_REMINDER_METADATA_KEY in metadata)) {
17716
+ return true;
17717
+ }
17718
+ const firstTextPart = message.content.parts.find((part) => part.type === "text");
17719
+ return typeof firstTextPart?.text === "string" && firstTextPart.text.startsWith("<system-reminder");
17720
+ }
17721
+ function filterSystemReminderMessages(messages, includeSystemReminders) {
17722
+ if (includeSystemReminders) {
17723
+ return messages;
17724
+ }
17725
+ return messages.filter((message) => !isSystemReminderMessage(message));
17726
+ }
17156
17727
  function normalizeObservationalMemoryConfig(config) {
17157
17728
  if (config === true) return { model: "google/gemini-2.5-flash" };
17158
17729
  if (config === false || config === void 0) return void 0;
@@ -17352,7 +17923,7 @@ var Memory = class extends memory.MastraMemory {
17352
17923
  });
17353
17924
  const rawMessages = shouldGetNewestAndReverse ? paginatedResult.messages.reverse() : paginatedResult.messages;
17354
17925
  const list = new agent.MessageList({ threadId, resourceId }).add(rawMessages, "memory");
17355
- const messages = memory.filterSystemReminderMessages(list.get.all.db(), includeSystemReminders);
17926
+ const messages = filterSystemReminderMessages(list.get.all.db(), includeSystemReminders);
17356
17927
  const { total, page: resultPage, perPage: resultPerPage, hasMore } = paginatedResult;
17357
17928
  const recallResult = { messages, usage, total, page: resultPage, perPage: resultPerPage, hasMore };
17358
17929
  span?.end({
@@ -17656,7 +18227,7 @@ ${workingMemory}`;
17656
18227
  }
17657
18228
  return chunks;
17658
18229
  }
17659
- hasher = chunkHBMTKCJL_cjs.e();
18230
+ hasher = chunk53QVLUCB_cjs.e();
17660
18231
  // embedding is computationally expensive so cache content -> embeddings/chunks
17661
18232
  embeddingCache = /* @__PURE__ */ new Map();
17662
18233
  firstEmbed;
@@ -17794,7 +18365,7 @@ ${workingMemory}`;
17794
18365
  newMessage.content = { ...message.content };
17795
18366
  }
17796
18367
  if (typeof newMessage.content?.content === "string" && newMessage.content.content.length > 0) {
17797
- newMessage.content.content = memory.removeWorkingMemoryTags(newMessage.content.content).trim();
18368
+ newMessage.content.content = removeWorkingMemoryTags(newMessage.content.content).trim();
17798
18369
  }
17799
18370
  if (Array.isArray(newMessage.content?.parts)) {
17800
18371
  newMessage.content.parts = newMessage.content.parts.filter((part) => {
@@ -17807,7 +18378,7 @@ ${workingMemory}`;
17807
18378
  const text42 = typeof part.text === "string" ? part.text : "";
17808
18379
  return {
17809
18380
  ...part,
17810
- text: memory.removeWorkingMemoryTags(text42).trim()
18381
+ text: removeWorkingMemoryTags(text42).trim()
17811
18382
  };
17812
18383
  }
17813
18384
  return part;
@@ -17823,7 +18394,7 @@ ${workingMemory}`;
17823
18394
  }
17824
18395
  parseWorkingMemory(text42) {
17825
18396
  if (!this.threadConfig.workingMemory?.enabled) return null;
17826
- const content = memory.extractWorkingMemoryContent(text42);
18397
+ const content = extractWorkingMemoryContent(text42);
17827
18398
  return content?.trim() ?? null;
17828
18399
  }
17829
18400
  async getWorkingMemory({
@@ -18058,7 +18629,7 @@ ${workingMemory}`;
18058
18629
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
18059
18630
  );
18060
18631
  }
18061
- const { ObservationalMemory: OMClass } = await import('./observational-memory-YYO73QMY-KGMPHQD4.cjs');
18632
+ const { ObservationalMemory: OMClass } = await import('./observational-memory-YYO73QMY-CHIPDTZY.cjs');
18062
18633
  const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
18063
18634
  await this.indexObservation(observation);
18064
18635
  } : void 0;
@@ -18983,7 +19554,7 @@ Notes:
18983
19554
  if (!effectiveConfig) return null;
18984
19555
  const engine = await this.omEngine;
18985
19556
  if (!engine) return null;
18986
- const { ObservationalMemoryProcessor } = await import('./observational-memory-YYO73QMY-KGMPHQD4.cjs');
19557
+ const { ObservationalMemoryProcessor } = await import('./observational-memory-YYO73QMY-CHIPDTZY.cjs');
18987
19558
  return new ObservationalMemoryProcessor(engine, this, {
18988
19559
  temporalMarkers: effectiveConfig.temporalMarkers
18989
19560
  });
@@ -24136,7 +24707,7 @@ function withUserAgentSuffix3(headers, ...userAgentSuffixParts) {
24136
24707
  );
24137
24708
  return Object.fromEntries(normalizedHeaders.entries());
24138
24709
  }
24139
- var VERSION6 = "3.0.22";
24710
+ var VERSION6 = "3.0.23";
24140
24711
  var getOriginalFetch4 = () => globalThis.fetch;
24141
24712
  var getFromApi3 = async ({
24142
24713
  url,
@@ -26183,6 +26754,7 @@ async function parseAuthMethod3(headers) {
26183
26754
  var gatewayAuthMethodSchema3 = lazyValidator2(
26184
26755
  () => zodSchema4(z4.z.union([z4.z.literal("api-key"), z4.z.literal("oidc")]))
26185
26756
  );
26757
+ var KNOWN_MODEL_TYPES3 = ["embedding", "image", "language"];
26186
26758
  var GatewayFetchMetadata3 = class {
26187
26759
  constructor(config) {
26188
26760
  this.config = config;
@@ -26253,8 +26825,12 @@ var gatewayAvailableModelsResponseSchema3 = lazyValidator2(
26253
26825
  provider: z4.z.string(),
26254
26826
  modelId: z4.z.string()
26255
26827
  }),
26256
- modelType: z4.z.enum(["language", "embedding", "image"]).nullish()
26828
+ modelType: z4.z.string().nullish()
26257
26829
  })
26830
+ ).transform(
26831
+ (models) => models.filter(
26832
+ (m) => m.modelType == null || KNOWN_MODEL_TYPES3.includes(m.modelType)
26833
+ )
26258
26834
  )
26259
26835
  })
26260
26836
  )
@@ -26270,6 +26846,187 @@ var gatewayCreditsResponseSchema3 = lazyValidator2(
26270
26846
  }))
26271
26847
  )
26272
26848
  );
26849
+ var GatewaySpendReport3 = class {
26850
+ constructor(config) {
26851
+ this.config = config;
26852
+ }
26853
+ async getSpendReport(params) {
26854
+ try {
26855
+ const baseUrl = new URL(this.config.baseURL);
26856
+ const searchParams = new URLSearchParams();
26857
+ searchParams.set("start_date", params.startDate);
26858
+ searchParams.set("end_date", params.endDate);
26859
+ if (params.groupBy) {
26860
+ searchParams.set("group_by", params.groupBy);
26861
+ }
26862
+ if (params.datePart) {
26863
+ searchParams.set("date_part", params.datePart);
26864
+ }
26865
+ if (params.userId) {
26866
+ searchParams.set("user_id", params.userId);
26867
+ }
26868
+ if (params.model) {
26869
+ searchParams.set("model", params.model);
26870
+ }
26871
+ if (params.provider) {
26872
+ searchParams.set("provider", params.provider);
26873
+ }
26874
+ if (params.credentialType) {
26875
+ searchParams.set("credential_type", params.credentialType);
26876
+ }
26877
+ if (params.tags && params.tags.length > 0) {
26878
+ searchParams.set("tags", params.tags.join(","));
26879
+ }
26880
+ const { value } = await getFromApi3({
26881
+ url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
26882
+ headers: await resolve4(this.config.headers()),
26883
+ successfulResponseHandler: createJsonResponseHandler3(
26884
+ gatewaySpendReportResponseSchema3
26885
+ ),
26886
+ failedResponseHandler: createJsonErrorResponseHandler3({
26887
+ errorSchema: z4.z.any(),
26888
+ errorToMessage: (data) => data
26889
+ }),
26890
+ fetch: this.config.fetch
26891
+ });
26892
+ return value;
26893
+ } catch (error) {
26894
+ throw await asGatewayError3(error);
26895
+ }
26896
+ }
26897
+ };
26898
+ var gatewaySpendReportResponseSchema3 = lazySchema3(
26899
+ () => zodSchema4(
26900
+ z4.z.object({
26901
+ results: z4.z.array(
26902
+ z4.z.object({
26903
+ day: z4.z.string().optional(),
26904
+ hour: z4.z.string().optional(),
26905
+ user: z4.z.string().optional(),
26906
+ model: z4.z.string().optional(),
26907
+ tag: z4.z.string().optional(),
26908
+ provider: z4.z.string().optional(),
26909
+ credential_type: z4.z.enum(["byok", "system"]).optional(),
26910
+ total_cost: z4.z.number(),
26911
+ market_cost: z4.z.number().optional(),
26912
+ input_tokens: z4.z.number().optional(),
26913
+ output_tokens: z4.z.number().optional(),
26914
+ cached_input_tokens: z4.z.number().optional(),
26915
+ cache_creation_input_tokens: z4.z.number().optional(),
26916
+ reasoning_tokens: z4.z.number().optional(),
26917
+ request_count: z4.z.number().optional()
26918
+ }).transform(
26919
+ ({
26920
+ credential_type,
26921
+ total_cost,
26922
+ market_cost,
26923
+ input_tokens,
26924
+ output_tokens,
26925
+ cached_input_tokens,
26926
+ cache_creation_input_tokens,
26927
+ reasoning_tokens,
26928
+ request_count,
26929
+ ...rest
26930
+ }) => ({
26931
+ ...rest,
26932
+ ...credential_type !== void 0 ? { credentialType: credential_type } : {},
26933
+ totalCost: total_cost,
26934
+ ...market_cost !== void 0 ? { marketCost: market_cost } : {},
26935
+ ...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
26936
+ ...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
26937
+ ...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
26938
+ ...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
26939
+ ...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
26940
+ ...request_count !== void 0 ? { requestCount: request_count } : {}
26941
+ })
26942
+ )
26943
+ )
26944
+ })
26945
+ )
26946
+ );
26947
+ var GatewayGenerationInfoFetcher3 = class {
26948
+ constructor(config) {
26949
+ this.config = config;
26950
+ }
26951
+ async getGenerationInfo(params) {
26952
+ try {
26953
+ const baseUrl = new URL(this.config.baseURL);
26954
+ const { value } = await getFromApi3({
26955
+ url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
26956
+ headers: await resolve4(this.config.headers()),
26957
+ successfulResponseHandler: createJsonResponseHandler3(
26958
+ gatewayGenerationInfoResponseSchema3
26959
+ ),
26960
+ failedResponseHandler: createJsonErrorResponseHandler3({
26961
+ errorSchema: z4.z.any(),
26962
+ errorToMessage: (data) => data
26963
+ }),
26964
+ fetch: this.config.fetch
26965
+ });
26966
+ return value;
26967
+ } catch (error) {
26968
+ throw await asGatewayError3(error);
26969
+ }
26970
+ }
26971
+ };
26972
+ var gatewayGenerationInfoResponseSchema3 = lazySchema3(
26973
+ () => zodSchema4(
26974
+ z4.z.object({
26975
+ data: z4.z.object({
26976
+ id: z4.z.string(),
26977
+ total_cost: z4.z.number(),
26978
+ upstream_inference_cost: z4.z.number(),
26979
+ usage: z4.z.number(),
26980
+ created_at: z4.z.string(),
26981
+ model: z4.z.string(),
26982
+ is_byok: z4.z.boolean(),
26983
+ provider_name: z4.z.string(),
26984
+ streamed: z4.z.boolean(),
26985
+ finish_reason: z4.z.string(),
26986
+ latency: z4.z.number(),
26987
+ generation_time: z4.z.number(),
26988
+ native_tokens_prompt: z4.z.number(),
26989
+ native_tokens_completion: z4.z.number(),
26990
+ native_tokens_reasoning: z4.z.number(),
26991
+ native_tokens_cached: z4.z.number(),
26992
+ native_tokens_cache_creation: z4.z.number(),
26993
+ billable_web_search_calls: z4.z.number()
26994
+ }).transform(
26995
+ ({
26996
+ total_cost,
26997
+ upstream_inference_cost,
26998
+ created_at,
26999
+ is_byok,
27000
+ provider_name,
27001
+ finish_reason,
27002
+ generation_time,
27003
+ native_tokens_prompt,
27004
+ native_tokens_completion,
27005
+ native_tokens_reasoning,
27006
+ native_tokens_cached,
27007
+ native_tokens_cache_creation,
27008
+ billable_web_search_calls,
27009
+ ...rest
27010
+ }) => ({
27011
+ ...rest,
27012
+ totalCost: total_cost,
27013
+ upstreamInferenceCost: upstream_inference_cost,
27014
+ createdAt: created_at,
27015
+ isByok: is_byok,
27016
+ providerName: provider_name,
27017
+ finishReason: finish_reason,
27018
+ generationTime: generation_time,
27019
+ promptTokens: native_tokens_prompt,
27020
+ completionTokens: native_tokens_completion,
27021
+ reasoningTokens: native_tokens_reasoning,
27022
+ cachedTokens: native_tokens_cached,
27023
+ cacheCreationTokens: native_tokens_cache_creation,
27024
+ billableWebSearchCalls: billable_web_search_calls
27025
+ })
27026
+ )
27027
+ }).transform(({ data }) => data)
27028
+ )
27029
+ );
26273
27030
  var GatewayLanguageModel3 = class {
26274
27031
  constructor(modelId, config) {
26275
27032
  this.modelId = modelId;
@@ -26772,7 +27529,7 @@ async function getVercelRequestId3() {
26772
27529
  var _a93;
26773
27530
  return (_a93 = getContext3().headers) == null ? void 0 : _a93["x-vercel-id"];
26774
27531
  }
26775
- var VERSION24 = "2.0.59";
27532
+ var VERSION24 = "2.0.82";
26776
27533
  var AI_GATEWAY_PROTOCOL_VERSION3 = "0.0.1";
26777
27534
  function createGatewayProvider3(options = {}) {
26778
27535
  var _a93, _b92;
@@ -26870,6 +27627,30 @@ function createGatewayProvider3(options = {}) {
26870
27627
  );
26871
27628
  });
26872
27629
  };
27630
+ const getSpendReport = async (params) => {
27631
+ return new GatewaySpendReport3({
27632
+ baseURL,
27633
+ headers: getHeaders,
27634
+ fetch: options.fetch
27635
+ }).getSpendReport(params).catch(async (error) => {
27636
+ throw await asGatewayError3(
27637
+ error,
27638
+ await parseAuthMethod3(await getHeaders())
27639
+ );
27640
+ });
27641
+ };
27642
+ const getGenerationInfo = async (params) => {
27643
+ return new GatewayGenerationInfoFetcher3({
27644
+ baseURL,
27645
+ headers: getHeaders,
27646
+ fetch: options.fetch
27647
+ }).getGenerationInfo(params).catch(async (error) => {
27648
+ throw await asGatewayError3(
27649
+ error,
27650
+ await parseAuthMethod3(await getHeaders())
27651
+ );
27652
+ });
27653
+ };
26873
27654
  const provider = function(modelId) {
26874
27655
  if (new.target) {
26875
27656
  throw new Error(
@@ -26880,6 +27661,8 @@ function createGatewayProvider3(options = {}) {
26880
27661
  };
26881
27662
  provider.getAvailableModels = getAvailableModels;
26882
27663
  provider.getCredits = getCredits;
27664
+ provider.getSpendReport = getSpendReport;
27665
+ provider.getGenerationInfo = getGenerationInfo;
26883
27666
  provider.imageModel = (modelId) => {
26884
27667
  return new GatewayImageModel3(modelId, {
26885
27668
  provider: "gateway",
@@ -30084,5 +30867,5 @@ exports.START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = START_ASYNC_AGENT_BUILDER_ACTIO
30084
30867
  exports.STREAM_AGENT_BUILDER_ACTION_ROUTE = STREAM_AGENT_BUILDER_ACTION_ROUTE;
30085
30868
  exports.STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE;
30086
30869
  exports.agent_builder_exports = agent_builder_exports;
30087
- //# sourceMappingURL=chunk-OY6VG2JH.cjs.map
30088
- //# sourceMappingURL=chunk-OY6VG2JH.cjs.map
30870
+ //# sourceMappingURL=chunk-P6OB5MFM.cjs.map
30871
+ //# sourceMappingURL=chunk-P6OB5MFM.cjs.map