@mastra/server 1.72.0-alpha.1 → 1.72.0-alpha.10

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 (140) hide show
  1. package/dist/{a2a-CwxSk6H0.cjs → a2a-CAQVpVxH.cjs} +23 -3
  2. package/dist/a2a-CAQVpVxH.cjs.map +1 -0
  3. package/dist/{a2a-DQOqoU_q.js → a2a-D2BffGsK.js} +23 -3
  4. package/dist/a2a-D2BffGsK.js.map +1 -0
  5. package/dist/{agent-builder-BGTZux5y.js → agent-builder-BlD120ac.js} +2 -2
  6. package/dist/{agent-builder-BGTZux5y.js.map → agent-builder-BlD120ac.js.map} +1 -1
  7. package/dist/{agent-builder-D-LAj4SD.cjs → agent-builder-CvwtAD7k.cjs} +2 -2
  8. package/dist/{agent-builder-D-LAj4SD.cjs.map → agent-builder-CvwtAD7k.cjs.map} +1 -1
  9. package/dist/{api-schema-manifest-Maxewnw7.cjs → api-schema-manifest-CaZU5zVt.cjs} +2 -2
  10. package/dist/{api-schema-manifest-Maxewnw7.cjs.map → api-schema-manifest-CaZU5zVt.cjs.map} +1 -1
  11. package/dist/{api-schema-manifest-DJiUahwo.js → api-schema-manifest-wF1O8MCU.js} +2 -2
  12. package/dist/{api-schema-manifest-DJiUahwo.js.map → api-schema-manifest-wF1O8MCU.js.map} +1 -1
  13. package/dist/{channels-DMw4LEA-.cjs → channels-DJkXEpTr.cjs} +18 -7
  14. package/dist/channels-DJkXEpTr.cjs.map +1 -0
  15. package/dist/{channels-xqChW6Vw.js → channels-DzaCNtXe.js} +18 -7
  16. package/dist/channels-DzaCNtXe.js.map +1 -0
  17. package/dist/{dist-Cfr6t0cK.cjs → dist-CRMvLG_8.cjs} +746 -366
  18. package/dist/dist-CRMvLG_8.cjs.map +1 -0
  19. package/dist/{dist-ABdCIqbD.js → dist-CYk5xS3y.js} +746 -366
  20. package/dist/dist-CYk5xS3y.js.map +1 -0
  21. package/dist/docs/SKILL.md +1 -1
  22. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  23. package/dist/docs/references/reference-observability-tracing-trace-query.md +37 -16
  24. package/dist/{editor-builder-BrkDnCEd.js → editor-builder-DJMAKDR5.js} +3 -2
  25. package/dist/editor-builder-DJMAKDR5.js.map +1 -0
  26. package/dist/{editor-builder-DIpISGSI.cjs → editor-builder-DrDs-t9i.cjs} +3 -2
  27. package/dist/editor-builder-DrDs-t9i.cjs.map +1 -0
  28. package/dist/{observability-new-endpoints-Ct0CSLE4.cjs → observability-new-endpoints-7Zd6uEZf.cjs} +111 -3
  29. package/dist/observability-new-endpoints-7Zd6uEZf.cjs.map +1 -0
  30. package/dist/{observability-new-endpoints-DqS6dcR5.js → observability-new-endpoints-lNC3o66-.js} +107 -5
  31. package/dist/observability-new-endpoints-lNC3o66-.js.map +1 -0
  32. package/dist/route-builder-2yrD15TL.cjs.map +1 -1
  33. package/dist/route-builder-lBil8Cvo.js.map +1 -1
  34. package/dist/{routes-D6sAEgtj.js → routes-B6soWZap.js} +6 -5
  35. package/dist/routes-B6soWZap.js.map +1 -0
  36. package/dist/{routes-C9CmwhbC.cjs → routes-x4As7pym.cjs} +6 -5
  37. package/dist/routes-x4As7pym.cjs.map +1 -0
  38. package/dist/server/handlers/a2a.cjs +1 -1
  39. package/dist/server/handlers/a2a.d.ts.map +1 -1
  40. package/dist/server/handlers/a2a.js +1 -1
  41. package/dist/server/handlers/agent-builder.cjs +3 -3
  42. package/dist/server/handlers/agent-builder.d.ts +4 -2
  43. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  44. package/dist/server/handlers/agent-builder.js +3 -3
  45. package/dist/server/handlers/agent-controller.cjs +2 -1
  46. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  47. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  48. package/dist/server/handlers/agent-controller.js +2 -1
  49. package/dist/server/handlers/agent-controller.js.map +1 -1
  50. package/dist/server/handlers/agents.cjs +49 -20
  51. package/dist/server/handlers/agents.cjs.map +1 -1
  52. package/dist/server/handlers/agents.d.ts.map +1 -1
  53. package/dist/server/handlers/agents.js +49 -20
  54. package/dist/server/handlers/agents.js.map +1 -1
  55. package/dist/server/handlers/channels.cjs +1 -1
  56. package/dist/server/handlers/channels.d.ts.map +1 -1
  57. package/dist/server/handlers/channels.js +1 -1
  58. package/dist/server/handlers/editor-builder.cjs +1 -1
  59. package/dist/server/handlers/editor-builder.d.ts.map +1 -1
  60. package/dist/server/handlers/editor-builder.js +1 -1
  61. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  62. package/dist/server/handlers/favorites-enrichment.js +1 -1
  63. package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
  64. package/dist/server/handlers/observability-new-endpoints.d.ts +100 -0
  65. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  66. package/dist/server/handlers/observability-new-endpoints.js +2 -2
  67. package/dist/server/handlers/observability-shared.cjs +46 -0
  68. package/dist/server/handlers/observability-shared.cjs.map +1 -1
  69. package/dist/server/handlers/observability-shared.d.ts +13 -0
  70. package/dist/server/handlers/observability-shared.d.ts.map +1 -1
  71. package/dist/server/handlers/observability-shared.js +42 -1
  72. package/dist/server/handlers/observability-shared.js.map +1 -1
  73. package/dist/server/handlers/observability.cjs +3 -1
  74. package/dist/server/handlers/observability.cjs.map +1 -1
  75. package/dist/server/handlers/observability.js +3 -2
  76. package/dist/server/handlers/observability.js.map +1 -1
  77. package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
  78. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  79. package/dist/server/handlers/stored-agents.cjs +6 -3
  80. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  81. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  82. package/dist/server/handlers/stored-agents.js +6 -3
  83. package/dist/server/handlers/stored-agents.js.map +1 -1
  84. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  85. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  86. package/dist/server/handlers/stored-skills.cjs +1 -1
  87. package/dist/server/handlers/stored-skills.js +1 -1
  88. package/dist/server/handlers/system.cjs +2 -2
  89. package/dist/server/handlers/system.d.ts +2 -0
  90. package/dist/server/handlers/system.d.ts.map +1 -1
  91. package/dist/server/handlers/system.js +2 -2
  92. package/dist/server/handlers/workflows.cjs +28 -4
  93. package/dist/server/handlers/workflows.cjs.map +1 -1
  94. package/dist/server/handlers/workflows.d.ts +5 -2
  95. package/dist/server/handlers/workflows.d.ts.map +1 -1
  96. package/dist/server/handlers/workflows.js +28 -4
  97. package/dist/server/handlers/workflows.js.map +1 -1
  98. package/dist/server/handlers.cjs +1 -1
  99. package/dist/server/handlers.js +1 -1
  100. package/dist/server/schemas/index.cjs +3 -3
  101. package/dist/server/schemas/index.js +3 -3
  102. package/dist/server/schemas/system.d.ts +2 -0
  103. package/dist/server/schemas/system.d.ts.map +1 -1
  104. package/dist/server/schemas/workflows.d.ts +2 -1
  105. package/dist/server/schemas/workflows.d.ts.map +1 -1
  106. package/dist/server/server-adapter/index.cjs +1 -1
  107. package/dist/server/server-adapter/index.js +1 -1
  108. package/dist/server/server-adapter/routes/agent-builder.d.ts +4 -2
  109. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
  110. package/dist/server/server-adapter/routes/observability.d.ts +97 -0
  111. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  112. package/dist/server/server-adapter/routes/system.d.ts +2 -0
  113. package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
  114. package/dist/server/server-adapter/routes/workflows.d.ts +4 -2
  115. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  116. package/dist/{system-BE5tDMHq.js → system-6qFm79mm.js} +2 -1
  117. package/dist/system-6qFm79mm.js.map +1 -0
  118. package/dist/{system-BlGYb2fu.cjs → system-CskEzH1o.cjs} +2 -1
  119. package/dist/system-CskEzH1o.cjs.map +1 -0
  120. package/dist/{workflows-CvJ4c4_p.js → workflows-BEdLrZQZ.js} +3 -2
  121. package/dist/workflows-BEdLrZQZ.js.map +1 -0
  122. package/dist/{workflows-Cv6MGw9d.cjs → workflows-BdoErlkd.cjs} +3 -2
  123. package/dist/workflows-BdoErlkd.cjs.map +1 -0
  124. package/package.json +6 -6
  125. package/dist/a2a-CwxSk6H0.cjs.map +0 -1
  126. package/dist/a2a-DQOqoU_q.js.map +0 -1
  127. package/dist/channels-DMw4LEA-.cjs.map +0 -1
  128. package/dist/channels-xqChW6Vw.js.map +0 -1
  129. package/dist/dist-ABdCIqbD.js.map +0 -1
  130. package/dist/dist-Cfr6t0cK.cjs.map +0 -1
  131. package/dist/editor-builder-BrkDnCEd.js.map +0 -1
  132. package/dist/editor-builder-DIpISGSI.cjs.map +0 -1
  133. package/dist/observability-new-endpoints-Ct0CSLE4.cjs.map +0 -1
  134. package/dist/observability-new-endpoints-DqS6dcR5.js.map +0 -1
  135. package/dist/routes-C9CmwhbC.cjs.map +0 -1
  136. package/dist/routes-D6sAEgtj.js.map +0 -1
  137. package/dist/system-BE5tDMHq.js.map +0 -1
  138. package/dist/system-BlGYb2fu.cjs.map +0 -1
  139. package/dist/workflows-Cv6MGw9d.cjs.map +0 -1
  140. package/dist/workflows-CvJ4c4_p.js.map +0 -1
@@ -3,7 +3,7 @@ name: mastra-server
3
3
  description: Documentation for @mastra/server. Use when working with @mastra/server APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/server"
6
- version: "1.72.0-alpha.1"
6
+ version: "1.72.0-alpha.10"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.72.0-alpha.1",
2
+ "version": "1.72.0-alpha.10",
3
3
  "package": "@mastra/server",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -283,21 +283,21 @@ Hono and Fastify enforce the request-body limit before JSON parsing. Express and
283
283
 
284
284
  ## Fields and operators
285
285
 
286
- | Predicate context | Fields | Operators |
287
- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
288
- | Trace | `traceId`, `threadId`, `resourceId`, `entityName`, `entityType`, `environment`, `status` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
289
- | Trace metadata | `metadata.<key>` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
290
- | Trace | `startedAt`, `endedAt`, `durationMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
291
- | Trace | `tags` | `includes`, `notIncludes`, `exists`, `notExists` |
292
- | Span | `name`, `spanType`, `model`, `provider`, `status`, `entityType`, `entityId`, `entityName`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
293
- | Span | `startedAt`, `endedAt`, `durationMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
294
- | Span | `error` | `exists`, `notExists` |
295
- | Score | `scorerId`, `scorerVersion`, `scoreSource`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
296
- | Score | `score`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
297
- | Score | `spanId` | `exists`, `notExists` |
298
- | Feedback | `feedbackType`, `feedbackSource`, `feedbackUserId`, `sourceId`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
299
- | Feedback | `value`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
300
- | Feedback | `comment` | `exists`, `notExists` |
286
+ | Predicate context | Fields | Operators |
287
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
288
+ | Trace | `traceId`, `threadId`, `resourceId`, `runId`, `sessionId`, `userId`, `organizationId`, `entityName`, `entityType`, `environment`, `status` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
289
+ | Trace metadata | `metadata.<key>` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
290
+ | Trace | `startedAt`, `endedAt`, `durationMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
291
+ | Trace | `tags` | `includes`, `notIncludes`, `exists`, `notExists` |
292
+ | Span | `name`, `spanType`, `model`, `provider`, `status`, `entityType`, `entityId`, `entityName`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId`, `runId`, `sessionId`, `userId`, `organizationId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
293
+ | Span | `startedAt`, `endedAt`, `durationMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
294
+ | Span | `error` | `exists`, `notExists` |
295
+ | Score | `scorerId`, `scorerVersion`, `scoreSource`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
296
+ | Score | `score`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
297
+ | Score | `spanId` | `exists`, `notExists` |
298
+ | Feedback | `feedbackType`, `feedbackSource`, `feedbackUserId`, `sourceId`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
299
+ | Feedback | `value`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
300
+ | Feedback | `comment` | `exists`, `notExists` |
301
301
 
302
302
  Compose predicates with `{ op: 'and', args: [...] }`, `{ op: 'or', args: [...] }`, and `{ op: 'not', arg: ... }`. Comparison predicates place a field reference on the left and a literal on the right. Membership predicates use a field reference in `value` and a homogeneous literal array in `set`. Tag predicates name the stored tag collection in `path`. `includes` and `notIncludes` also take one tag in `value`, while `exists` and `notExists` take only `op` and `path`. See [Filter by tags](#filter-by-tags).
303
303
 
@@ -319,6 +319,27 @@ This top-level predicate doesn't inspect child spans. In contrast, `spans.some`
319
319
 
320
320
  Trace queries exclude incomplete roots before evaluating predicates. As a result, `{ op: 'notExists', path: 'durationMs' }` doesn't find running traces or malformed roots without a usable `endedAt`.
321
321
 
322
+ ### Filter by context identifiers
323
+
324
+ `runId`, `sessionId`, `userId`, and `organizationId` are available at trace scope and inside `spans.some` / `spans.none`. Trace-scope predicates read the current root span. Span-scope predicates bind to one related current span, so a run recorded only on a child span is found through `spans.some`:
325
+
326
+ ```typescript
327
+ const sessionTracesWithRun = {
328
+ op: 'and',
329
+ args: [
330
+ { op: 'eq', left: { path: 'organizationId' }, right: { literal: 'org-123' } },
331
+ { op: 'eq', left: { path: 'sessionId' }, right: { literal: 'session-123' } },
332
+ {
333
+ spans: {
334
+ some: { op: 'eq', left: { path: 'runId' }, right: { literal: 'run-42' } },
335
+ },
336
+ },
337
+ ],
338
+ }
339
+ ```
340
+
341
+ These identifiers support `eq`, `ne`, `in`, `notIn`, `exists`, and `notExists`. Field discovery lists them, but value discovery doesn't return their recorded values. Stores advertise support through the `trace-query-context-ids` feature. A predicate on one of these fields against an older store returns `501` before storage runs, and field discovery omits them for that store.
342
+
322
343
  ### Filter by span properties
323
344
 
324
345
  Every condition inside one `spans.some` or `spans.none` clause applies to the same current span. For example, this predicate finds a failed tool span whose name is `medication_lookup`; a matching name on one span and an error on another don't satisfy it:
@@ -679,7 +700,7 @@ const plan = planTraceQuery(parseTraceQueryRequest(request), {
679
700
  })
680
701
  ```
681
702
 
682
- `resourceId` is optional and narrows within the organization. Keyset and delta cursors are bound to the scope, so a cursor minted under one scope and reused under another returns `409` before storage runs. A scoped request against an observability store or `@mastra/core` that predates tenant scope returns `501` instead of running unscoped. Stores advertise support through the `trace-query-tenant-scope` feature. Callers can't name `organizationId` or `projectId` in predicates. Without a scope the routes behave as before, so self-hosted installations keep their own tenant model.
703
+ `resourceId` is optional and narrows within the organization. Keyset and delta cursors are bound to the scope. A cursor created under one scope and reused under another returns `409` before storage runs. A scoped request against an observability store or `@mastra/core` that predates tenant scope returns `501` instead of running unscoped. Stores advertise support through the `trace-query-tenant-scope` feature. Callers can't name `projectId` in predicates. An `organizationId` predicate compares recorded data and is ANDed with the scope, so it can only narrow the tenant's own traces and never widens it. Without a scope the routes behave as before, so self-hosted installations keep their own tenant model.
683
704
 
684
705
  Cursor pagination is deterministic, but it isn't a database snapshot. Traces or replacement signals written between page requests can change later pages.
685
706
 
@@ -244,7 +244,8 @@ const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({
244
244
  key,
245
245
  value: formatConfigValue(value)
246
246
  }));
247
- const channelProviders = mastra.getChannelProviders() ?? {};
247
+ const mastraWithResolver = mastra;
248
+ const channelProviders = typeof mastraWithResolver.resolveChannels === "function" ? await mastraWithResolver.resolveChannels() : mastra.getChannelProviders() ?? {};
248
249
  const channels = { providers: Object.entries(channelProviders).map(([id, provider]) => {
249
250
  const info = provider.getInfo?.();
250
251
  const routes = provider.getRoutes?.() ?? [];
@@ -334,4 +335,4 @@ const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({
334
335
  //#endregion
335
336
  export { requireBuilderFeature as a, isBuilderFeatureEnabled as i, GET_EDITOR_BUILDER_SETTINGS_ROUTE as n, GET_INFRASTRUCTURE_STATUS_ROUTE as r, GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE as t };
336
337
 
337
- //# sourceMappingURL=editor-builder-BrkDnCEd.js.map
338
+ //# sourceMappingURL=editor-builder-DJMAKDR5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-builder-DJMAKDR5.js","names":[],"sources":["../src/server/utils/resolve-builder-model-policy.ts","../src/server/handlers/editor-builder.ts"],"sourcesContent":["import type { BuilderModelPolicy } from '@mastra/core/agent-builder/ee';\nimport type { IMastraEditor } from '@mastra/core/editor';\n\n/**\n * Server-side wrapper around `builderToModelPolicy`.\n *\n * Handles the optional `IMastraEditor` builder API surface (older / OSS editors\n * may not implement `hasEnabledBuilderConfig` / `resolveBuilder`) and returns\n * a uniform `BuilderModelPolicy` to every call site.\n *\n * Returns `{ active: false }` whenever:\n * - no editor is configured,\n * - the editor doesn't expose builder methods,\n * - the builder config is disabled, or\n * - resolving the builder fails / yields nothing.\n *\n * The `@mastra/core/agent-builder/ee` subpath is loaded lazily so this module\n * remains importable on `@mastra/core` versions that pre-date the subpath\n * (the subpath was added in core 1.34.0). The dynamic import is only reached\n * once an editor is actually configured, by which point a compatible core is\n * guaranteed.\n */\nexport async function resolveBuilderModelPolicy(editor: IMastraEditor | undefined): Promise<BuilderModelPolicy> {\n if (!editor) return { active: false };\n if (typeof editor.resolveBuilder !== 'function') return { active: false };\n if (typeof editor.hasEnabledBuilderConfig === 'function' && !editor.hasEnabledBuilderConfig()) {\n return { active: false };\n }\n\n // Degrade to inactive on builder-resolution failure rather than letting the\n // rejection escape: agent execution routes seed this on every request, so a\n // transient failure must not 500 the entire route.\n try {\n const builder = await editor.resolveBuilder();\n const { builderToModelPolicy } = await import('@mastra/core/agent-builder/ee');\n return builderToModelPolicy(builder);\n } catch {\n return { active: false };\n }\n}\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\n\nimport { HTTPException } from '../http-exception';\nimport {\n agentFeaturesSchema,\n builderAvailableModelsResponseSchema,\n builderSettingsResponseSchema,\n infrastructureStatusResponseSchema,\n} from '../schemas/editor-builder';\nimport type { AgentFeatures, InfrastructureStatus } from '../schemas/editor-builder';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { resolveBuilderModelPolicy } from '../utils/resolve-builder-model-policy';\nimport { buildProvidersList } from './agents';\nimport { handleError } from './error';\n\n/**\n * Resolve the active builder feature flags. Returns `null` when the editor is\n * absent, the builder is disabled, or no features are configured.\n */\nasync function resolveBuilderFeatures(mastra: Mastra): Promise<AgentFeatures | null> {\n const editor = mastra.getEditor();\n if (!editor || typeof editor.resolveBuilder !== 'function') return null;\n if (!editor.hasEnabledBuilderConfig?.()) return null;\n const builder = await editor.resolveBuilder();\n if (!builder || !builder.enabled) return null;\n const features = builder.getFeatures?.()?.agent;\n if (!features) return null;\n // Validate the shape so unknown keys cannot smuggle through.\n const parsed = agentFeaturesSchema.safeParse(features);\n return parsed.success ? parsed.data : null;\n}\n\n/**\n * Returns whether a given agent-builder feature is enabled. Used by list /\n * get-by-id handlers to soft-gate response enrichment (omit fields, ignore\n * favoritedOnly / pinFavoritedFor params) when the feature is off.\n */\nexport async function isBuilderFeatureEnabled(mastra: Mastra, feature: keyof AgentFeatures): Promise<boolean> {\n const features = await resolveBuilderFeatures(mastra);\n return features?.[feature] === true;\n}\n\n/**\n * Hard-gate helper for mutation routes that must not exist when the feature\n * is off. Throws `HTTPException(404)` so we don't leak the existence of the\n * feature surface (matches behavior of unregistered routes).\n */\nexport async function requireBuilderFeature(mastra: Mastra, feature: keyof AgentFeatures): Promise<void> {\n if (!(await isBuilderFeatureEnabled(mastra, feature))) {\n throw new HTTPException(404, { message: 'Not Found' });\n }\n}\n\n/**\n * GET /editor/builder/settings\n *\n * Returns the agent builder settings configured by the admin.\n * Used by frontend to determine which features to display.\n */\nexport const GET_EDITOR_BUILDER_SETTINGS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/settings',\n responseType: 'json',\n responseSchema: builderSettingsResponseSchema,\n summary: 'Get agent builder settings',\n description: 'Returns the agent builder feature flags and configuration for UI gating',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-agents:read',\n handler: async ({ mastra }) => {\n try {\n const editor = mastra.getEditor();\n\n // No editor configured\n if (!editor) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Editor doesn't support builder (older version or OSS)\n if (typeof editor.resolveBuilder !== 'function') {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Check if builder is enabled in config\n if (!editor.hasEnabledBuilderConfig?.()) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Resolve the builder instance\n const builder = await editor.resolveBuilder();\n if (!builder || !builder.enabled) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n const baseWarnings = builder.getModelPolicyWarnings?.() ?? [];\n const configuration = builder.getConfiguration();\n\n // Picker allowlists are written against entity `.id` (what users see in\n // the UI, URLs, traces). The client filters list responses by their\n // response keys, which are not always `.id`:\n // - GET /agents keys by `agent.id`\n // - GET /tools keys by registration key (values include `id`)\n // - GET /workflows keys by registration key (values omit `id`)\n // To keep the client filter simple, we accept `.id` (fallback to\n // registration key) for matching, but emit visible IDs as response keys\n // so `Object.keys(data)` lines up.\n type AliasPair = { id: string; key: string };\n const collectAliases = (registry: Record<string, unknown>): AliasPair[] =>\n Object.entries(registry).map(([key, entity]) => ({\n id: (entity as { id?: string }).id || key,\n key,\n }));\n\n const toolAliases = collectAliases(mastra.listTools() ?? {});\n const agentAliases = collectAliases(mastra.listAgents() ?? {});\n const workflowAliases = collectAliases(mastra.listWorkflows() ?? {});\n\n // Tools/workflows responses are keyed by registration key. Agents\n // response is keyed by `.id`.\n const toResponseKey = (aliases: AliasPair[], byId: 'id' | 'key') => {\n const map = new Map<string, string>();\n for (const a of aliases) {\n map.set(a.id, byId === 'id' ? a.id : a.key);\n map.set(a.key, byId === 'id' ? a.id : a.key);\n }\n return map;\n };\n const toolKeyMap = toResponseKey(toolAliases, 'key');\n const agentKeyMap = toResponseKey(agentAliases, 'id');\n const workflowKeyMap = toResponseKey(workflowAliases, 'key');\n\n // Lazy-load the EE subpath so this module remains importable on\n // `@mastra/core` versions that pre-date it (added in core 1.34.0).\n // We only reach here after `builder.enabled` is true, which guarantees\n // a compatible core.\n const { builderToModelPolicy, resolvePickerVisibility } = await import('@mastra/core/agent-builder/ee');\n\n const picker = resolvePickerVisibility({\n config: configuration?.agent,\n registeredToolIds: toolAliases.flatMap(a => [a.id, a.key]),\n registeredAgentIds: agentAliases.flatMap(a => [a.id, a.key]),\n registeredWorkflowIds: workflowAliases.flatMap(a => [a.id, a.key]),\n });\n\n const normalize = (visible: string[] | null, map: Map<string, string>): string[] | null => {\n if (visible === null) return null;\n const out: string[] = [];\n const seen = new Set<string>();\n for (const id of visible) {\n const mapped = map.get(id);\n if (mapped && !seen.has(mapped)) {\n seen.add(mapped);\n out.push(mapped);\n }\n }\n return out;\n };\n\n const modelPolicyWarnings = [...baseWarnings, ...picker.warnings];\n\n return {\n enabled: true,\n features: builder.getFeatures(),\n configuration,\n modelPolicy: builderToModelPolicy(builder),\n picker: {\n visibleTools: normalize(picker.visibleTools, toolKeyMap),\n visibleAgents: normalize(picker.visibleAgents, agentKeyMap),\n visibleWorkflows: normalize(picker.visibleWorkflows, workflowKeyMap),\n },\n ...(modelPolicyWarnings.length > 0 ? { modelPolicyWarnings } : {}),\n };\n } catch (error) {\n return handleError(error, 'Error getting builder settings');\n }\n },\n});\n\n/**\n * GET /editor/builder/models/available\n *\n * Returns the configured AI providers/models the agent builder may use. The\n * server is the single authority: it scopes the list to providers with a\n * configured API key (`connected`) and applies the active builder model\n * policy via `isModelAllowed`, so the Studio surfaces can render the response\n * verbatim without importing any EE matcher into the browser.\n *\n * - Providers without a configured API key are always omitted — the builder\n * decides the agent's model from this list, so an unconnected provider would\n * produce an agent that can never run.\n * - Policy inactive (or no allowlist) ⇒ all connected providers are returned.\n * - Policy active with an allowlist ⇒ each connected provider's models are\n * filtered, and providers left with no allowed models are omitted entirely.\n */\nexport const GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/models/available',\n responseType: 'json',\n responseSchema: builderAvailableModelsResponseSchema,\n summary: 'List builder-available AI models',\n description: 'Returns AI providers/models filtered by the active agent-builder model policy.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-agents:read',\n handler: async ({ mastra }) => {\n try {\n // Only surface providers whose API key is configured (`connected`). The\n // agent builder decides the agent's model from this list, so including\n // providers without a key lets it pick a model that can never run. We\n // scope to connected providers so every choice is actually usable.\n const providers = (await buildProvidersList(mastra)).filter(provider => provider.connected);\n const policy = await resolveBuilderModelPolicy(mastra.getEditor());\n\n // Inactive policy (or no allowlist) ⇒ no allowlist filtering to apply.\n if (!policy.active || !policy.allowed || policy.allowed.length === 0) {\n return { providers };\n }\n\n // Lazy-load the EE matcher (server-only); mirrors the convention used by\n // resolve-builder-model-policy and the settings handler.\n const { isModelAllowed } = await import('@mastra/core/agent-builder/ee');\n\n const filtered = providers\n .map(provider => ({\n ...provider,\n models: provider.models.filter(modelId => isModelAllowed(policy.allowed, { provider: provider.id, modelId })),\n }))\n .filter(provider => provider.models.length > 0);\n\n return { providers: filtered };\n } catch (error) {\n return handleError(error, 'Error fetching available models');\n }\n },\n});\n\n/**\n * GET /editor/builder/infrastructure\n *\n * Returns the runtime status of Mastra-opinionated primitives (channels,\n * browser providers, workspaces). Admin-only; surfaced in Studio Settings so\n * admins can sanity-check what's wired up to the running server.\n */\nexport const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/infrastructure',\n responseType: 'json',\n responseSchema: infrastructureStatusResponseSchema,\n summary: 'Get infrastructure status',\n description: 'Agent Builder infrastructure configuration and lightweight runtime status.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'infrastructure:read',\n handler: async ({ mastra }) => {\n try {\n const formatConfigValue = (value: unknown): string => {\n if (value === null || value === undefined) return 'not set';\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value);\n if (Array.isArray(value)) return `${value.length} item${value.length === 1 ? '' : 's'}`;\n return value.constructor?.name && value.constructor.name !== 'Object' ? value.constructor.name : 'configured';\n };\n\n const getProviderName = (value: unknown): string | null => {\n if (!value) return null;\n if (typeof value === 'object' && 'provider' in value && typeof value.provider === 'string')\n return value.provider;\n if (typeof value === 'object' && 'constructor' in value) {\n const name = (value as { constructor?: { name?: string } }).constructor?.name;\n return name && name !== 'Object' ? name : 'configured';\n }\n return null;\n };\n\n const getConfigEntries = (config: Record<string, unknown>, omittedKeys: string[] = []) =>\n Object.entries(config)\n .filter(([key, value]) => !omittedKeys.includes(key) && value !== undefined && value !== null)\n .map(([key, value]) => ({ key, value: formatConfigValue(value) }));\n\n // Prefer resolveChannels() so a live channels resolver (e.g. @mastra/connect's\n // channels()) reports connections added after boot; older cores lack the method.\n const mastraWithResolver = mastra as typeof mastra & {\n resolveChannels?: () => Promise<Record<string, ChannelProvider>>;\n };\n const channelProviders =\n typeof mastraWithResolver.resolveChannels === 'function'\n ? await mastraWithResolver.resolveChannels()\n : (mastra.getChannelProviders() ?? {});\n const channels: InfrastructureStatus['channels'] = {\n providers: Object.entries(channelProviders)\n .map(([id, provider]) => {\n const info = provider.getInfo?.();\n const routes = provider.getRoutes?.() ?? [];\n return {\n id: info?.id ?? id,\n name: info?.name ?? id,\n isConfigured: info?.isConfigured ?? false,\n routeCount: routes.length,\n };\n })\n .filter(provider => provider.isConfigured),\n };\n\n const editor = mastra.getEditor();\n let browser: InfrastructureStatus['browser'] = {\n type: null,\n provider: null,\n env: null,\n registered: false,\n availableProviders: [],\n config: [],\n };\n let workspace: InfrastructureStatus['workspace'] = {\n type: null,\n workspaceId: null,\n name: null,\n source: null,\n registered: false,\n hasFilesystem: false,\n hasSandbox: false,\n filesystemProvider: null,\n sandboxProvider: null,\n config: [],\n };\n let registries: InfrastructureStatus['registries'] = {\n skillsSh: { enabled: false },\n };\n\n if (editor?.resolveBuilder) {\n const browsers = (editor as unknown as { __browsers?: Map<string, unknown> }).__browsers;\n const builder = await editor.resolveBuilder();\n const builderRegistries = builder?.getRegistries?.();\n registries = {\n skillsSh: { enabled: builderRegistries?.skillsSh?.enabled === true },\n };\n const configuration = builder?.getConfiguration?.()?.agent as\n | {\n browser?: { type?: string; config?: { provider?: string; env?: string } };\n workspace?: {\n type?: string;\n workspaceId?: string;\n config?: { name?: string; filesystem?: unknown; sandbox?: unknown };\n };\n }\n | undefined;\n\n const browserRef = configuration?.browser;\n const browserConfig = browserRef?.config ?? {};\n const providerId = browserConfig.provider ?? null;\n browser = {\n type: browserRef?.type ?? null,\n provider: providerId,\n env: browserConfig.env ?? null,\n registered: providerId ? !!browsers?.has(providerId) : false,\n availableProviders: browsers ? Array.from(browsers.keys()) : [],\n config: getConfigEntries(browserConfig, ['provider', 'env']),\n };\n\n const workspaceRef = configuration?.workspace;\n const workspaceConfig = workspaceRef?.config ?? {};\n const registeredWorkspaces = mastra.listWorkspaces();\n const registeredWorkspace = workspaceRef?.workspaceId\n ? registeredWorkspaces[workspaceRef.workspaceId]\n : undefined;\n const filesystem = registeredWorkspace?.workspace.filesystem ?? workspaceConfig.filesystem;\n const sandbox = registeredWorkspace?.workspace.sandbox ?? workspaceConfig.sandbox;\n const filesystemConfig =\n typeof workspaceConfig.filesystem === 'object' &&\n workspaceConfig.filesystem &&\n 'config' in workspaceConfig.filesystem\n ? (workspaceConfig.filesystem.config as Record<string, unknown>)\n : {};\n const sandboxConfig =\n typeof workspaceConfig.sandbox === 'object' && workspaceConfig.sandbox && 'config' in workspaceConfig.sandbox\n ? (workspaceConfig.sandbox.config as Record<string, unknown>)\n : {};\n workspace = {\n type: workspaceRef?.type ?? null,\n workspaceId: workspaceRef?.workspaceId ?? null,\n name: workspaceConfig.name ?? registeredWorkspace?.workspace.name ?? null,\n source: registeredWorkspace?.source ?? null,\n registered: !!registeredWorkspace,\n hasFilesystem: !!filesystem,\n hasSandbox: !!sandbox,\n filesystemProvider: getProviderName(filesystem),\n sandboxProvider: getProviderName(sandbox),\n config: [\n ...getConfigEntries(filesystemConfig).map(entry => ({ ...entry, key: `filesystem.${entry.key}` })),\n ...getConfigEntries(sandboxConfig).map(entry => ({ ...entry, key: `sandbox.${entry.key}` })),\n ],\n };\n }\n\n return { channels, browser, workspace, registries };\n } catch (error) {\n return handleError(error, 'Error getting infrastructure status');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,eAAsB,0BAA0B,QAAgE;CAC9G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AAC,CAAC,KAAI,WAAU;MAAE,GAAG;MAAO,KAAK,cAAc,MAAM;KAAM,EAAE,GACjG,GAAG,iBAAiB,aAAa,CAAC,CAAC,KAAI,WAAU;MAAE,GAAG;MAAO,KAAK,WAAW,MAAM;KAAM,EAAE,CAC7F;IACF;GACF;GAEA,OAAO;IAAE;IAAU;IAAS;IAAW;GAAW;EACpD,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
@@ -244,7 +244,8 @@ const GET_INFRASTRUCTURE_STATUS_ROUTE = require_route_builder.createRoute({
244
244
  key,
245
245
  value: formatConfigValue(value)
246
246
  }));
247
- const channelProviders = mastra.getChannelProviders() ?? {};
247
+ const mastraWithResolver = mastra;
248
+ const channelProviders = typeof mastraWithResolver.resolveChannels === "function" ? await mastraWithResolver.resolveChannels() : mastra.getChannelProviders() ?? {};
248
249
  const channels = { providers: Object.entries(channelProviders).map(([id, provider]) => {
249
250
  const info = provider.getInfo?.();
250
251
  const routes = provider.getRoutes?.() ?? [];
@@ -363,4 +364,4 @@ Object.defineProperty(exports, "requireBuilderFeature", {
363
364
  }
364
365
  });
365
366
 
366
- //# sourceMappingURL=editor-builder-DIpISGSI.cjs.map
367
+ //# sourceMappingURL=editor-builder-DrDs-t9i.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-builder-DrDs-t9i.cjs","names":["agentFeaturesSchema","HTTPException","createRoute","builderSettingsResponseSchema","handleError","builderAvailableModelsResponseSchema","buildProvidersList","infrastructureStatusResponseSchema"],"sources":["../src/server/utils/resolve-builder-model-policy.ts","../src/server/handlers/editor-builder.ts"],"sourcesContent":["import type { BuilderModelPolicy } from '@mastra/core/agent-builder/ee';\nimport type { IMastraEditor } from '@mastra/core/editor';\n\n/**\n * Server-side wrapper around `builderToModelPolicy`.\n *\n * Handles the optional `IMastraEditor` builder API surface (older / OSS editors\n * may not implement `hasEnabledBuilderConfig` / `resolveBuilder`) and returns\n * a uniform `BuilderModelPolicy` to every call site.\n *\n * Returns `{ active: false }` whenever:\n * - no editor is configured,\n * - the editor doesn't expose builder methods,\n * - the builder config is disabled, or\n * - resolving the builder fails / yields nothing.\n *\n * The `@mastra/core/agent-builder/ee` subpath is loaded lazily so this module\n * remains importable on `@mastra/core` versions that pre-date the subpath\n * (the subpath was added in core 1.34.0). The dynamic import is only reached\n * once an editor is actually configured, by which point a compatible core is\n * guaranteed.\n */\nexport async function resolveBuilderModelPolicy(editor: IMastraEditor | undefined): Promise<BuilderModelPolicy> {\n if (!editor) return { active: false };\n if (typeof editor.resolveBuilder !== 'function') return { active: false };\n if (typeof editor.hasEnabledBuilderConfig === 'function' && !editor.hasEnabledBuilderConfig()) {\n return { active: false };\n }\n\n // Degrade to inactive on builder-resolution failure rather than letting the\n // rejection escape: agent execution routes seed this on every request, so a\n // transient failure must not 500 the entire route.\n try {\n const builder = await editor.resolveBuilder();\n const { builderToModelPolicy } = await import('@mastra/core/agent-builder/ee');\n return builderToModelPolicy(builder);\n } catch {\n return { active: false };\n }\n}\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\n\nimport { HTTPException } from '../http-exception';\nimport {\n agentFeaturesSchema,\n builderAvailableModelsResponseSchema,\n builderSettingsResponseSchema,\n infrastructureStatusResponseSchema,\n} from '../schemas/editor-builder';\nimport type { AgentFeatures, InfrastructureStatus } from '../schemas/editor-builder';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { resolveBuilderModelPolicy } from '../utils/resolve-builder-model-policy';\nimport { buildProvidersList } from './agents';\nimport { handleError } from './error';\n\n/**\n * Resolve the active builder feature flags. Returns `null` when the editor is\n * absent, the builder is disabled, or no features are configured.\n */\nasync function resolveBuilderFeatures(mastra: Mastra): Promise<AgentFeatures | null> {\n const editor = mastra.getEditor();\n if (!editor || typeof editor.resolveBuilder !== 'function') return null;\n if (!editor.hasEnabledBuilderConfig?.()) return null;\n const builder = await editor.resolveBuilder();\n if (!builder || !builder.enabled) return null;\n const features = builder.getFeatures?.()?.agent;\n if (!features) return null;\n // Validate the shape so unknown keys cannot smuggle through.\n const parsed = agentFeaturesSchema.safeParse(features);\n return parsed.success ? parsed.data : null;\n}\n\n/**\n * Returns whether a given agent-builder feature is enabled. Used by list /\n * get-by-id handlers to soft-gate response enrichment (omit fields, ignore\n * favoritedOnly / pinFavoritedFor params) when the feature is off.\n */\nexport async function isBuilderFeatureEnabled(mastra: Mastra, feature: keyof AgentFeatures): Promise<boolean> {\n const features = await resolveBuilderFeatures(mastra);\n return features?.[feature] === true;\n}\n\n/**\n * Hard-gate helper for mutation routes that must not exist when the feature\n * is off. Throws `HTTPException(404)` so we don't leak the existence of the\n * feature surface (matches behavior of unregistered routes).\n */\nexport async function requireBuilderFeature(mastra: Mastra, feature: keyof AgentFeatures): Promise<void> {\n if (!(await isBuilderFeatureEnabled(mastra, feature))) {\n throw new HTTPException(404, { message: 'Not Found' });\n }\n}\n\n/**\n * GET /editor/builder/settings\n *\n * Returns the agent builder settings configured by the admin.\n * Used by frontend to determine which features to display.\n */\nexport const GET_EDITOR_BUILDER_SETTINGS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/settings',\n responseType: 'json',\n responseSchema: builderSettingsResponseSchema,\n summary: 'Get agent builder settings',\n description: 'Returns the agent builder feature flags and configuration for UI gating',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-agents:read',\n handler: async ({ mastra }) => {\n try {\n const editor = mastra.getEditor();\n\n // No editor configured\n if (!editor) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Editor doesn't support builder (older version or OSS)\n if (typeof editor.resolveBuilder !== 'function') {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Check if builder is enabled in config\n if (!editor.hasEnabledBuilderConfig?.()) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Resolve the builder instance\n const builder = await editor.resolveBuilder();\n if (!builder || !builder.enabled) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n const baseWarnings = builder.getModelPolicyWarnings?.() ?? [];\n const configuration = builder.getConfiguration();\n\n // Picker allowlists are written against entity `.id` (what users see in\n // the UI, URLs, traces). The client filters list responses by their\n // response keys, which are not always `.id`:\n // - GET /agents keys by `agent.id`\n // - GET /tools keys by registration key (values include `id`)\n // - GET /workflows keys by registration key (values omit `id`)\n // To keep the client filter simple, we accept `.id` (fallback to\n // registration key) for matching, but emit visible IDs as response keys\n // so `Object.keys(data)` lines up.\n type AliasPair = { id: string; key: string };\n const collectAliases = (registry: Record<string, unknown>): AliasPair[] =>\n Object.entries(registry).map(([key, entity]) => ({\n id: (entity as { id?: string }).id || key,\n key,\n }));\n\n const toolAliases = collectAliases(mastra.listTools() ?? {});\n const agentAliases = collectAliases(mastra.listAgents() ?? {});\n const workflowAliases = collectAliases(mastra.listWorkflows() ?? {});\n\n // Tools/workflows responses are keyed by registration key. Agents\n // response is keyed by `.id`.\n const toResponseKey = (aliases: AliasPair[], byId: 'id' | 'key') => {\n const map = new Map<string, string>();\n for (const a of aliases) {\n map.set(a.id, byId === 'id' ? a.id : a.key);\n map.set(a.key, byId === 'id' ? a.id : a.key);\n }\n return map;\n };\n const toolKeyMap = toResponseKey(toolAliases, 'key');\n const agentKeyMap = toResponseKey(agentAliases, 'id');\n const workflowKeyMap = toResponseKey(workflowAliases, 'key');\n\n // Lazy-load the EE subpath so this module remains importable on\n // `@mastra/core` versions that pre-date it (added in core 1.34.0).\n // We only reach here after `builder.enabled` is true, which guarantees\n // a compatible core.\n const { builderToModelPolicy, resolvePickerVisibility } = await import('@mastra/core/agent-builder/ee');\n\n const picker = resolvePickerVisibility({\n config: configuration?.agent,\n registeredToolIds: toolAliases.flatMap(a => [a.id, a.key]),\n registeredAgentIds: agentAliases.flatMap(a => [a.id, a.key]),\n registeredWorkflowIds: workflowAliases.flatMap(a => [a.id, a.key]),\n });\n\n const normalize = (visible: string[] | null, map: Map<string, string>): string[] | null => {\n if (visible === null) return null;\n const out: string[] = [];\n const seen = new Set<string>();\n for (const id of visible) {\n const mapped = map.get(id);\n if (mapped && !seen.has(mapped)) {\n seen.add(mapped);\n out.push(mapped);\n }\n }\n return out;\n };\n\n const modelPolicyWarnings = [...baseWarnings, ...picker.warnings];\n\n return {\n enabled: true,\n features: builder.getFeatures(),\n configuration,\n modelPolicy: builderToModelPolicy(builder),\n picker: {\n visibleTools: normalize(picker.visibleTools, toolKeyMap),\n visibleAgents: normalize(picker.visibleAgents, agentKeyMap),\n visibleWorkflows: normalize(picker.visibleWorkflows, workflowKeyMap),\n },\n ...(modelPolicyWarnings.length > 0 ? { modelPolicyWarnings } : {}),\n };\n } catch (error) {\n return handleError(error, 'Error getting builder settings');\n }\n },\n});\n\n/**\n * GET /editor/builder/models/available\n *\n * Returns the configured AI providers/models the agent builder may use. The\n * server is the single authority: it scopes the list to providers with a\n * configured API key (`connected`) and applies the active builder model\n * policy via `isModelAllowed`, so the Studio surfaces can render the response\n * verbatim without importing any EE matcher into the browser.\n *\n * - Providers without a configured API key are always omitted — the builder\n * decides the agent's model from this list, so an unconnected provider would\n * produce an agent that can never run.\n * - Policy inactive (or no allowlist) ⇒ all connected providers are returned.\n * - Policy active with an allowlist ⇒ each connected provider's models are\n * filtered, and providers left with no allowed models are omitted entirely.\n */\nexport const GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/models/available',\n responseType: 'json',\n responseSchema: builderAvailableModelsResponseSchema,\n summary: 'List builder-available AI models',\n description: 'Returns AI providers/models filtered by the active agent-builder model policy.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-agents:read',\n handler: async ({ mastra }) => {\n try {\n // Only surface providers whose API key is configured (`connected`). The\n // agent builder decides the agent's model from this list, so including\n // providers without a key lets it pick a model that can never run. We\n // scope to connected providers so every choice is actually usable.\n const providers = (await buildProvidersList(mastra)).filter(provider => provider.connected);\n const policy = await resolveBuilderModelPolicy(mastra.getEditor());\n\n // Inactive policy (or no allowlist) ⇒ no allowlist filtering to apply.\n if (!policy.active || !policy.allowed || policy.allowed.length === 0) {\n return { providers };\n }\n\n // Lazy-load the EE matcher (server-only); mirrors the convention used by\n // resolve-builder-model-policy and the settings handler.\n const { isModelAllowed } = await import('@mastra/core/agent-builder/ee');\n\n const filtered = providers\n .map(provider => ({\n ...provider,\n models: provider.models.filter(modelId => isModelAllowed(policy.allowed, { provider: provider.id, modelId })),\n }))\n .filter(provider => provider.models.length > 0);\n\n return { providers: filtered };\n } catch (error) {\n return handleError(error, 'Error fetching available models');\n }\n },\n});\n\n/**\n * GET /editor/builder/infrastructure\n *\n * Returns the runtime status of Mastra-opinionated primitives (channels,\n * browser providers, workspaces). Admin-only; surfaced in Studio Settings so\n * admins can sanity-check what's wired up to the running server.\n */\nexport const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/infrastructure',\n responseType: 'json',\n responseSchema: infrastructureStatusResponseSchema,\n summary: 'Get infrastructure status',\n description: 'Agent Builder infrastructure configuration and lightweight runtime status.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'infrastructure:read',\n handler: async ({ mastra }) => {\n try {\n const formatConfigValue = (value: unknown): string => {\n if (value === null || value === undefined) return 'not set';\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value);\n if (Array.isArray(value)) return `${value.length} item${value.length === 1 ? '' : 's'}`;\n return value.constructor?.name && value.constructor.name !== 'Object' ? value.constructor.name : 'configured';\n };\n\n const getProviderName = (value: unknown): string | null => {\n if (!value) return null;\n if (typeof value === 'object' && 'provider' in value && typeof value.provider === 'string')\n return value.provider;\n if (typeof value === 'object' && 'constructor' in value) {\n const name = (value as { constructor?: { name?: string } }).constructor?.name;\n return name && name !== 'Object' ? name : 'configured';\n }\n return null;\n };\n\n const getConfigEntries = (config: Record<string, unknown>, omittedKeys: string[] = []) =>\n Object.entries(config)\n .filter(([key, value]) => !omittedKeys.includes(key) && value !== undefined && value !== null)\n .map(([key, value]) => ({ key, value: formatConfigValue(value) }));\n\n // Prefer resolveChannels() so a live channels resolver (e.g. @mastra/connect's\n // channels()) reports connections added after boot; older cores lack the method.\n const mastraWithResolver = mastra as typeof mastra & {\n resolveChannels?: () => Promise<Record<string, ChannelProvider>>;\n };\n const channelProviders =\n typeof mastraWithResolver.resolveChannels === 'function'\n ? await mastraWithResolver.resolveChannels()\n : (mastra.getChannelProviders() ?? {});\n const channels: InfrastructureStatus['channels'] = {\n providers: Object.entries(channelProviders)\n .map(([id, provider]) => {\n const info = provider.getInfo?.();\n const routes = provider.getRoutes?.() ?? [];\n return {\n id: info?.id ?? id,\n name: info?.name ?? id,\n isConfigured: info?.isConfigured ?? false,\n routeCount: routes.length,\n };\n })\n .filter(provider => provider.isConfigured),\n };\n\n const editor = mastra.getEditor();\n let browser: InfrastructureStatus['browser'] = {\n type: null,\n provider: null,\n env: null,\n registered: false,\n availableProviders: [],\n config: [],\n };\n let workspace: InfrastructureStatus['workspace'] = {\n type: null,\n workspaceId: null,\n name: null,\n source: null,\n registered: false,\n hasFilesystem: false,\n hasSandbox: false,\n filesystemProvider: null,\n sandboxProvider: null,\n config: [],\n };\n let registries: InfrastructureStatus['registries'] = {\n skillsSh: { enabled: false },\n };\n\n if (editor?.resolveBuilder) {\n const browsers = (editor as unknown as { __browsers?: Map<string, unknown> }).__browsers;\n const builder = await editor.resolveBuilder();\n const builderRegistries = builder?.getRegistries?.();\n registries = {\n skillsSh: { enabled: builderRegistries?.skillsSh?.enabled === true },\n };\n const configuration = builder?.getConfiguration?.()?.agent as\n | {\n browser?: { type?: string; config?: { provider?: string; env?: string } };\n workspace?: {\n type?: string;\n workspaceId?: string;\n config?: { name?: string; filesystem?: unknown; sandbox?: unknown };\n };\n }\n | undefined;\n\n const browserRef = configuration?.browser;\n const browserConfig = browserRef?.config ?? {};\n const providerId = browserConfig.provider ?? null;\n browser = {\n type: browserRef?.type ?? null,\n provider: providerId,\n env: browserConfig.env ?? null,\n registered: providerId ? !!browsers?.has(providerId) : false,\n availableProviders: browsers ? Array.from(browsers.keys()) : [],\n config: getConfigEntries(browserConfig, ['provider', 'env']),\n };\n\n const workspaceRef = configuration?.workspace;\n const workspaceConfig = workspaceRef?.config ?? {};\n const registeredWorkspaces = mastra.listWorkspaces();\n const registeredWorkspace = workspaceRef?.workspaceId\n ? registeredWorkspaces[workspaceRef.workspaceId]\n : undefined;\n const filesystem = registeredWorkspace?.workspace.filesystem ?? workspaceConfig.filesystem;\n const sandbox = registeredWorkspace?.workspace.sandbox ?? workspaceConfig.sandbox;\n const filesystemConfig =\n typeof workspaceConfig.filesystem === 'object' &&\n workspaceConfig.filesystem &&\n 'config' in workspaceConfig.filesystem\n ? (workspaceConfig.filesystem.config as Record<string, unknown>)\n : {};\n const sandboxConfig =\n typeof workspaceConfig.sandbox === 'object' && workspaceConfig.sandbox && 'config' in workspaceConfig.sandbox\n ? (workspaceConfig.sandbox.config as Record<string, unknown>)\n : {};\n workspace = {\n type: workspaceRef?.type ?? null,\n workspaceId: workspaceRef?.workspaceId ?? null,\n name: workspaceConfig.name ?? registeredWorkspace?.workspace.name ?? null,\n source: registeredWorkspace?.source ?? null,\n registered: !!registeredWorkspace,\n hasFilesystem: !!filesystem,\n hasSandbox: !!sandbox,\n filesystemProvider: getProviderName(filesystem),\n sandboxProvider: getProviderName(sandbox),\n config: [\n ...getConfigEntries(filesystemConfig).map(entry => ({ ...entry, key: `filesystem.${entry.key}` })),\n ...getConfigEntries(sandboxConfig).map(entry => ({ ...entry, key: `sandbox.${entry.key}` })),\n ],\n };\n }\n\n return { channels, browser, workspace, registries };\n } catch (error) {\n return handleError(error, 'Error getting infrastructure status');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,eAAsB,0BAA0B,QAAgE;CAC9G,IAAI,CAAC,QAAQ,OAAO,EAAE,QAAQ,MAAM;CACpC,IAAI,OAAO,OAAO,mBAAmB,YAAY,OAAO,EAAE,QAAQ,MAA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C,CAAC,KAAI,WAAU;MAAE,GAAG;MAAO,KAAK,cAAc,MAAM;KAAM,EAAE,GACjG,GAAG,iBAAiB,aAAa,CAAC,CAAC,KAAI,WAAU;MAAE,GAAG;MAAO,KAAK,WAAW,MAAM;KAAM,EAAE,CAC7F;IACF;GACF;GAEA,OAAO;IAAE;IAAU;IAAS;IAAW;GAAW;EACpD,SAAS,OAAO;GACd,OAAOH,8BAAAA,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
@@ -5,7 +5,7 @@ const require_constants = require("./constants-4IJp_uzj.cjs");
5
5
  const require_server_handlers_error = require("./server/handlers/error.cjs");
6
6
  const require_server_handlers_observability_list_query_schemas = require("./server/handlers/observability-list-query-schemas.cjs");
7
7
  const require_server_handlers_observability_shared = require("./server/handlers/observability-shared.cjs");
8
- const require_system = require("./system-BlGYb2fu.cjs");
8
+ const require_system = require("./system-CskEzH1o.cjs");
9
9
  const require_server_handlers_author_enrichment = require("./server/handlers/author-enrichment.cjs");
10
10
  const require_server_handlers_authorship = require("./server/handlers/authorship.cjs");
11
11
  let zod_v4 = require("zod/v4");
@@ -1028,6 +1028,7 @@ const QUERY_TRACES = createNewRoute(require_server_handlers_observability_shared
1028
1028
  observabilityStore = await require_server_handlers_observability_shared.getObservabilityStore(mastra);
1029
1029
  require_server_handlers_observability_shared.assertObservabilityTraceQuerySupported(observabilityStore);
1030
1030
  require_server_handlers_observability_shared.assertObservabilityTraceQueryRootDurationSupported(observabilityStore, plan.where);
1031
+ require_server_handlers_observability_shared.assertObservabilityTraceQueryContextIdsSupported(observabilityStore, plan.where);
1031
1032
  require_server_handlers_observability_shared.assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
1032
1033
  if (plan.paginationMode === "delta" && !observabilityStore.getFeatures()?.includes("delta-polling")) throw new require_http_exception.HTTPException(501, { message: "This storage provider does not support observability delta polling" });
1033
1034
  } catch (error) {
@@ -1078,6 +1079,105 @@ if (QUERY_TRACES.openapi) {
1078
1079
  content: { "application/json": { schema: traceQueryTimeoutErrorSchema } }
1079
1080
  };
1080
1081
  }
1082
+ const traceAggregateUnsupportedErrorSchema = zod_v4.z.object({
1083
+ code: zod_v4.z.literal("TRACE_AGGREGATE_UNSUPPORTED"),
1084
+ message: zod_v4.z.string()
1085
+ }).strict();
1086
+ /** Never echoes caller input: only the predicate-complexity issue keeps its own fixed message. */
1087
+ const traceAggregateValidationError = (error) => ({
1088
+ status: 422,
1089
+ body: {
1090
+ code: "TRACE_QUERY_INVALID",
1091
+ message: "The trace aggregate query is invalid",
1092
+ issues: error.issues.map((issue) => {
1093
+ const predicateTooComplex = issue.code === "custom" && issue.message === _mastra_core_storage.TRACE_QUERY_PREDICATE_COMPLEXITY_MESSAGE;
1094
+ return {
1095
+ code: predicateTooComplex ? "predicate_too_complex" : "invalid_request",
1096
+ path: issue.path.map((part) => typeof part === "symbol" ? String(part) : part),
1097
+ message: predicateTooComplex ? _mastra_core_storage.TRACE_QUERY_PREDICATE_COMPLEXITY_MESSAGE : "The value does not match the trace-aggregate request contract"
1098
+ };
1099
+ })
1100
+ }
1101
+ });
1102
+ const AGGREGATE_TRACES = createNewRoute(require_server_handlers_observability_shared.NEW_ROUTE_DEFS.AGGREGATE_TRACES, {
1103
+ bodySchema: _mastra_core_storage.traceAggregateRequestSchema,
1104
+ responseSchema: _mastra_core_storage.traceAggregateResponseSchema,
1105
+ onValidationError: traceAggregateValidationError,
1106
+ maxBodySize: 256 * 1024,
1107
+ preserveHttpExceptions: true,
1108
+ isCoreSupported: require_server_handlers_observability_shared.supportsTraceAggregateCore,
1109
+ onUnsupportedCore: () => throwTraceQueryError(501, {
1110
+ code: "TRACE_AGGREGATE_UNSUPPORTED",
1111
+ message: "Trace aggregation requires a newer @mastra/core. Please upgrade."
1112
+ }),
1113
+ handler: async ({ mastra, requestContext, timeRange, where, groupBy, interval, measures, having, orderBy, limit }) => {
1114
+ let plan;
1115
+ try {
1116
+ plan = _mastra_core_storage.planTraceAggregate({
1117
+ timeRange,
1118
+ where,
1119
+ groupBy,
1120
+ interval,
1121
+ measures,
1122
+ having,
1123
+ orderBy,
1124
+ limit
1125
+ }, { scope: resolveTraceQueryScope(requestContext, "TRACE_AGGREGATE_UNSUPPORTED") });
1126
+ } catch (error) {
1127
+ if (error instanceof _mastra_core_storage.TraceQueryValidationError) throwTraceQueryError(422, {
1128
+ code: error.code,
1129
+ message: error.message,
1130
+ issues: error.issues
1131
+ });
1132
+ throw error;
1133
+ }
1134
+ let observabilityStore;
1135
+ try {
1136
+ observabilityStore = await require_server_handlers_observability_shared.getObservabilityStore(mastra);
1137
+ require_server_handlers_observability_shared.assertObservabilityTraceAggregateSupported(observabilityStore);
1138
+ require_server_handlers_observability_shared.assertObservabilityTraceQueryRootDurationSupported(observabilityStore, plan.where);
1139
+ require_server_handlers_observability_shared.assertObservabilityTraceQueryContextIdsSupported(observabilityStore, plan.where);
1140
+ require_server_handlers_observability_shared.assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
1141
+ } catch (error) {
1142
+ if (error instanceof require_http_exception.HTTPException && error.status === 501) throwTraceQueryError(501, {
1143
+ code: "TRACE_AGGREGATE_UNSUPPORTED",
1144
+ message: error.message
1145
+ });
1146
+ throw error;
1147
+ }
1148
+ try {
1149
+ return await observabilityStore.aggregateTraces(plan);
1150
+ } catch (error) {
1151
+ if (error instanceof _mastra_core_storage.TraceQueryExecutionError) throwTraceQueryError(504, {
1152
+ code: error.code,
1153
+ message: error.message
1154
+ });
1155
+ throw error;
1156
+ }
1157
+ }
1158
+ });
1159
+ if (AGGREGATE_TRACES.openapi) {
1160
+ AGGREGATE_TRACES.openapi.responses[400] = {
1161
+ description: "Malformed JSON",
1162
+ content: { "application/json": { schema: traceQueryMalformedBodyErrorSchema } }
1163
+ };
1164
+ AGGREGATE_TRACES.openapi.responses[413] = {
1165
+ description: "Request body exceeds 256 KiB",
1166
+ content: { "application/json": { schema: traceQueryBodyTooLargeErrorSchema } }
1167
+ };
1168
+ AGGREGATE_TRACES.openapi.responses[422] = {
1169
+ description: "Structurally or semantically invalid trace aggregate query",
1170
+ content: { "application/json": { schema: traceQueryValidationResponseSchema } }
1171
+ };
1172
+ AGGREGATE_TRACES.openapi.responses[501] = {
1173
+ description: "The configured observability store does not support trace aggregation",
1174
+ content: { "application/json": { schema: traceAggregateUnsupportedErrorSchema } }
1175
+ };
1176
+ AGGREGATE_TRACES.openapi.responses[504] = {
1177
+ description: "Trace aggregate query exceeded the configured database execution timeout",
1178
+ content: { "application/json": { schema: traceQueryTimeoutErrorSchema } }
1179
+ };
1180
+ }
1081
1181
  const GET_TRACE_QUERY_FIELDS = createNewRoute(require_server_handlers_observability_shared.NEW_ROUTE_DEFS.GET_TRACE_QUERY_FIELDS, {
1082
1182
  bodySchema: _mastra_core_storage.getTraceQueryFieldsArgsSchema,
1083
1183
  responseSchema: _mastra_core_storage.getTraceQueryFieldsResponseSchema,
@@ -1109,7 +1209,7 @@ const GET_TRACE_QUERY_FIELDS = createNewRoute(require_server_handlers_observabil
1109
1209
  try {
1110
1210
  const observed = await observabilityStore.getTraceQueryObservedFields(plan);
1111
1211
  return {
1112
- canonicalFields: _mastra_core_storage.getTraceQueryCanonicalFieldDescriptors(predicateScope, search).filter((field) => predicateScope !== "trace" || field.path !== "durationMs" || require_server_handlers_observability_shared.supportsObservabilityTraceQueryRootDuration(observabilityStore)),
1212
+ canonicalFields: _mastra_core_storage.getTraceQueryCanonicalFieldDescriptors(predicateScope, search).filter((field) => predicateScope !== "trace" || field.path !== "durationMs" || require_server_handlers_observability_shared.supportsObservabilityTraceQueryRootDuration(observabilityStore)).filter((field) => !require_server_handlers_observability_shared.isTraceQueryContextIdField(field.path) || require_server_handlers_observability_shared.supportsObservabilityTraceQueryContextIds(observabilityStore)),
1113
1213
  ...observed
1114
1214
  };
1115
1215
  } catch (error) {
@@ -1226,7 +1326,9 @@ const QUERY_THREADS = createNewRoute(require_server_handlers_observability_share
1226
1326
  observabilityStore = await require_server_handlers_observability_shared.getObservabilityStore(mastra);
1227
1327
  require_server_handlers_observability_shared.assertObservabilityThreadQuerySupported(observabilityStore);
1228
1328
  require_server_handlers_observability_shared.assertObservabilityTraceQueryRootDurationSupported(observabilityStore, plan.traces.where);
1329
+ require_server_handlers_observability_shared.assertObservabilityTraceQueryContextIdsSupported(observabilityStore, plan.traces.where);
1229
1330
  require_server_handlers_observability_shared.assertObservabilityTraceQueryRootDurationSupported(observabilityStore, plan.where);
1331
+ require_server_handlers_observability_shared.assertObservabilityTraceQueryContextIdsSupported(observabilityStore, plan.where);
1230
1332
  require_server_handlers_observability_shared.assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
1231
1333
  } catch (error) {
1232
1334
  if (error instanceof require_http_exception.HTTPException && error.status === 501) throwTraceQueryError(501, {
@@ -1686,6 +1788,12 @@ const NEW_ROUTES = {
1686
1788
  GET_CAPABILITIES
1687
1789
  };
1688
1790
  //#endregion
1791
+ Object.defineProperty(exports, "AGGREGATE_TRACES", {
1792
+ enumerable: true,
1793
+ get: function() {
1794
+ return AGGREGATE_TRACES;
1795
+ }
1796
+ });
1689
1797
  Object.defineProperty(exports, "CREATE_FEEDBACK", {
1690
1798
  enumerable: true,
1691
1799
  get: function() {
@@ -1903,4 +2011,4 @@ Object.defineProperty(exports, "UPDATE_FEEDBACK_REVIEW_STATUS", {
1903
2011
  }
1904
2012
  });
1905
2013
 
1906
- //# sourceMappingURL=observability-new-endpoints-Ct0CSLE4.cjs.map
2014
+ //# sourceMappingURL=observability-new-endpoints-7Zd6uEZf.cjs.map