@mastra/server 1.79.0 → 1.80.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/@internal_core/dist/storage/index.d.ts +243 -243
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +13 -13
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/routes/index.d.ts +12 -12
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/types/index.d.ts +1 -2
- package/dist/{a2a-Uood_0DN.cjs → a2a-qQkFvE8f.cjs} +2 -2
- package/dist/{a2a-Uood_0DN.cjs.map → a2a-qQkFvE8f.cjs.map} +1 -1
- package/dist/{a2a-BqLB3McP.js → a2a-wv2WQ3IG.js} +2 -2
- package/dist/{a2a-BqLB3McP.js.map → a2a-wv2WQ3IG.js.map} +1 -1
- package/dist/{agent-builder-CuBD1tpv.cjs → agent-builder-C8F4tCwd.cjs} +4 -4
- package/dist/{agent-builder-CuBD1tpv.cjs.map → agent-builder-C8F4tCwd.cjs.map} +1 -1
- package/dist/{agent-builder-VhM8ADW-.js → agent-builder-DFZjeOkA.js} +4 -4
- package/dist/{agent-builder-VhM8ADW-.js.map → agent-builder-DFZjeOkA.js.map} +1 -1
- package/dist/{agents-BHLTMBff.js → agents-BjdJ-Tyf.js} +3 -2
- package/dist/agents-BjdJ-Tyf.js.map +1 -0
- package/dist/{agents-T-OIM9IK.cjs → agents-CPYFVJak.cjs} +8 -1
- package/dist/agents-CPYFVJak.cjs.map +1 -0
- package/dist/{agents-BOWEUKyV.cjs → agents-CcY0JTDF.cjs} +81 -9
- package/dist/agents-CcY0JTDF.cjs.map +1 -0
- package/dist/{agents-DRQ3ScbX.js → agents-DaLwtv9x.js} +76 -10
- package/dist/agents-DaLwtv9x.js.map +1 -0
- package/dist/{api-schema-manifest-CI90M4sX.js → api-schema-manifest-B1WyInlF.js} +2 -2
- package/dist/{api-schema-manifest-CI90M4sX.js.map → api-schema-manifest-B1WyInlF.js.map} +1 -1
- package/dist/{api-schema-manifest-DIlNfbyw.cjs → api-schema-manifest-CxrGchcx.cjs} +2 -2
- package/dist/{api-schema-manifest-DIlNfbyw.cjs.map → api-schema-manifest-CxrGchcx.cjs.map} +1 -1
- package/dist/{conversations-C5MkQBB8.cjs → conversations-B16oVu_1.cjs} +2 -2
- package/dist/{conversations-C5MkQBB8.cjs.map → conversations-B16oVu_1.cjs.map} +1 -1
- package/dist/{conversations-8BWryNlF.js → conversations-B5RJ2jcO.js} +2 -2
- package/dist/{conversations-8BWryNlF.js.map → conversations-B5RJ2jcO.js.map} +1 -1
- package/dist/{datasets-BUC5T-fd.cjs → datasets-Cgtczd13.cjs} +11 -1
- package/dist/datasets-Cgtczd13.cjs.map +1 -0
- package/dist/{datasets-CCWuznUu.js → datasets-FRp69Mwv.js} +11 -1
- package/dist/datasets-FRp69Mwv.js.map +1 -0
- package/dist/{dist-k77XQGUn.js → dist-6ZwWUUBQ.js} +40 -6
- package/dist/{dist-k77XQGUn.js.map → dist-6ZwWUUBQ.js.map} +1 -1
- package/dist/{dist-B-bEVWlJ.cjs → dist-U8ZBR8z5.cjs} +40 -6
- package/dist/{dist-B-bEVWlJ.cjs.map → dist-U8ZBR8z5.cjs.map} +1 -1
- package/dist/{dist-B3kC8Yd0.cjs → dist-bT2343kX.cjs} +1 -1
- package/dist/dist-qYC51DiT.js +1 -0
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-connections-a2a.md +1 -1
- package/dist/docs/references/docs-guides-mcp-authentication-authorization.md +2 -2
- package/dist/docs/references/docs-server-middleware.md +1 -1
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +92 -11
- package/dist/{editor-builder-BDtiWw0f.cjs → editor-builder-Bt26tVKI.cjs} +2 -2
- package/dist/{editor-builder-BDtiWw0f.cjs.map → editor-builder-Bt26tVKI.cjs.map} +1 -1
- package/dist/{editor-builder-DnLCfqnY.js → editor-builder-DWMgkYK-.js} +2 -2
- package/dist/{editor-builder-DnLCfqnY.js.map → editor-builder-DWMgkYK-.js.map} +1 -1
- package/dist/{editor-builder-DtpP1FtW.cjs → editor-builder-D_OUA9P6.cjs} +3 -3
- package/dist/{editor-builder-DtpP1FtW.cjs.map → editor-builder-D_OUA9P6.cjs.map} +1 -1
- package/dist/{editor-builder-ClFlGXoX.js → editor-builder-DzGLnYcJ.js} +3 -3
- package/dist/{editor-builder-ClFlGXoX.js.map → editor-builder-DzGLnYcJ.js.map} +1 -1
- package/dist/{helpers-CAcEhq38.cjs → helpers-DvzrUzqY.cjs} +2 -2
- package/dist/{helpers-CAcEhq38.cjs.map → helpers-DvzrUzqY.cjs.map} +1 -1
- package/dist/{helpers-vrqddDd5.js → helpers-gCkmhB9x.js} +2 -2
- package/dist/{helpers-vrqddDd5.js.map → helpers-gCkmhB9x.js.map} +1 -1
- package/dist/{observability-BBMCMeT-.cjs → observability-C2BZQ2jU.cjs} +3 -2
- package/dist/{observability-BBMCMeT-.cjs.map → observability-C2BZQ2jU.cjs.map} +1 -1
- package/dist/{observability-ZRgRcvoX.js → observability-Dz9jvMJ3.js} +3 -2
- package/dist/{observability-ZRgRcvoX.js.map → observability-Dz9jvMJ3.js.map} +1 -1
- package/dist/{observability-new-endpoints-fjoZzEtk.js → observability-new-endpoints-3DlTYf34.js} +117 -4
- package/dist/observability-new-endpoints-3DlTYf34.js.map +1 -0
- package/dist/{observability-new-endpoints-tG3-odLa.cjs → observability-new-endpoints-Drr7q2Dj.cjs} +121 -2
- package/dist/observability-new-endpoints-Drr7q2Dj.cjs.map +1 -0
- package/dist/{plans-CiPgWBhO.cjs → plans-DVzqRj-i.cjs} +3 -3
- package/dist/{plans-CiPgWBhO.cjs.map → plans-DVzqRj-i.cjs.map} +1 -1
- package/dist/{plans-DCepEY7n.js → plans-TpICqvFU.js} +3 -3
- package/dist/{plans-DCepEY7n.js.map → plans-TpICqvFU.js.map} +1 -1
- package/dist/{probe-image-size-BdfbUHxx.js → probe-image-size-BYv_-JV7.js} +2 -2
- package/dist/{probe-image-size-BdfbUHxx.js.map → probe-image-size-BYv_-JV7.js.map} +1 -1
- package/dist/{probe-image-size-Alv3gwKl.cjs → probe-image-size-mZ2ldE98.cjs} +2 -2
- package/dist/{probe-image-size-Alv3gwKl.cjs.map → probe-image-size-mZ2ldE98.cjs.map} +1 -1
- package/dist/{responses-CCRijwDF.cjs → responses-CP2UYT8z.cjs} +2 -2
- package/dist/{responses-CCRijwDF.cjs.map → responses-CP2UYT8z.cjs.map} +1 -1
- package/dist/{responses-4FwMNxoJ.js → responses-CnQoSpBc.js} +2 -2
- package/dist/{responses-4FwMNxoJ.js.map → responses-CnQoSpBc.js.map} +1 -1
- package/dist/{routes-BC20mdNN.js → routes-DZ2QfTnF.js} +17 -15
- package/dist/routes-DZ2QfTnF.js.map +1 -0
- package/dist/{routes-DGLJyqjD.cjs → routes-OsQV338J.cjs} +17 -15
- package/dist/routes-OsQV338J.cjs.map +1 -0
- package/dist/{scores-D9UgETt_.js → scores-DFFS3Zxo.js} +2 -2
- package/dist/{scores-D9UgETt_.js.map → scores-DFFS3Zxo.js.map} +1 -1
- package/dist/{scores-DRdtS7NT.cjs → scores-DwiL1Nk8.cjs} +2 -2
- package/dist/{scores-DRdtS7NT.cjs.map → scores-DwiL1Nk8.cjs.map} +1 -1
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +1 -1
- package/dist/server/auth/index.js +1 -1
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +2 -1
- package/dist/server/handlers/agents.d.ts +31 -0
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/auth.cjs +15 -1
- package/dist/server/handlers/auth.cjs.map +1 -1
- package/dist/server/handlers/auth.d.ts.map +1 -1
- package/dist/server/handlers/auth.js +15 -1
- package/dist/server/handlers/auth.js.map +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/datasets.cjs +3 -2
- package/dist/server/handlers/datasets.cjs.map +1 -1
- package/dist/server/handlers/datasets.d.ts +8 -0
- package/dist/server/handlers/datasets.d.ts.map +1 -1
- package/dist/server/handlers/datasets.js +3 -2
- package/dist/server/handlers/datasets.js.map +1 -1
- package/dist/server/handlers/editor-builder.cjs +1 -1
- package/dist/server/handlers/editor-builder.js +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +1 -1
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +132 -0
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +19 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +10 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +18 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +3 -2
- package/dist/server/handlers/observability.js +3 -3
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/schedules-workflows-shim.cjs.map +1 -1
- package/dist/server/handlers/schedules-workflows-shim.js.map +1 -1
- package/dist/server/handlers/scores.cjs +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
- package/dist/server/handlers/stored-agent-favorites.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +29 -11
- package/dist/server/handlers/stored-agents.cjs.map +1 -1
- package/dist/server/handlers/stored-agents.d.ts.map +1 -1
- package/dist/server/handlers/stored-agents.js +29 -11
- package/dist/server/handlers/stored-agents.js.map +1 -1
- package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
- package/dist/server/handlers/stored-skill-favorites.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +1 -1
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts +2 -0
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.cjs +1 -1
- package/dist/server/handlers/workspace.d.ts +23 -23
- package/dist/server/handlers/workspace.js +1 -1
- package/dist/server/handlers.cjs +11 -11
- package/dist/server/handlers.js +11 -11
- package/dist/server/schemas/agents.d.ts +4 -0
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/datasets.d.ts +4 -0
- package/dist/server/schemas/datasets.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +5 -4
- package/dist/server/schemas/index.js +5 -5
- package/dist/server/schemas/system.d.ts +2 -0
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +95 -3
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +28 -1
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +93 -4
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/mcp-disconnect.d.ts +16 -0
- package/dist/server/server-adapter/mcp-disconnect.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/agents.d.ts +2 -1
- package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/datasets.d.ts +8 -0
- package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +129 -0
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/system.d.ts +2 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workspace.d.ts +23 -23
- package/dist/{system-BvpFMIJB.cjs → system-B_Sod-Le.cjs} +2 -1
- package/dist/system-B_Sod-Le.cjs.map +1 -0
- package/dist/{system-CpzPxRRq.js → system-sSSmmt7I.js} +2 -1
- package/dist/system-sSSmmt7I.js.map +1 -0
- package/dist/{tools-SPJtxG9N.cjs → tools-B2fMQuwp.cjs} +3 -3
- package/dist/tools-B2fMQuwp.cjs.map +1 -0
- package/dist/{tools-CmFSfDMn.js → tools-BrO42c5i.js} +3 -3
- package/dist/tools-BrO42c5i.js.map +1 -0
- package/dist/{workflow-builder-CjlLoQvo.js → workflow-builder-D-YMkDHC.js} +3 -3
- package/dist/{workflow-builder-CjlLoQvo.js.map → workflow-builder-D-YMkDHC.js.map} +1 -1
- package/dist/{workflow-builder-C9-8ZOWF.cjs → workflow-builder-DtXcLQoG.cjs} +3 -3
- package/dist/{workflow-builder-C9-8ZOWF.cjs.map → workflow-builder-DtXcLQoG.cjs.map} +1 -1
- package/dist/{workflows-bb-otd2o.js → workflows-CF7e2ST9.js} +2 -2
- package/dist/{workflows-bb-otd2o.js.map → workflows-CF7e2ST9.js.map} +1 -1
- package/dist/{workflows-DjqeJcdJ.cjs → workflows-DN2axrmq.cjs} +2 -2
- package/dist/{workflows-DjqeJcdJ.cjs.map → workflows-DN2axrmq.cjs.map} +1 -1
- package/dist/{workspace-B6kzp-bo.js → workspace-BVHXoKmP.js} +2 -2
- package/dist/workspace-BVHXoKmP.js.map +1 -0
- package/dist/{workspace-COKR1SxH.cjs → workspace-d25MZ9dj.cjs} +2 -2
- package/dist/workspace-d25MZ9dj.cjs.map +1 -0
- package/package.json +10 -10
- package/dist/agents-BHLTMBff.js.map +0 -1
- package/dist/agents-BOWEUKyV.cjs.map +0 -1
- package/dist/agents-DRQ3ScbX.js.map +0 -1
- package/dist/agents-T-OIM9IK.cjs.map +0 -1
- package/dist/datasets-BUC5T-fd.cjs.map +0 -1
- package/dist/datasets-CCWuznUu.js.map +0 -1
- package/dist/dist-BM9J-PTK.js +0 -1
- package/dist/observability-new-endpoints-fjoZzEtk.js.map +0 -1
- package/dist/observability-new-endpoints-tG3-odLa.cjs.map +0 -1
- package/dist/routes-BC20mdNN.js.map +0 -1
- package/dist/routes-DGLJyqjD.cjs.map +0 -1
- package/dist/system-BvpFMIJB.cjs.map +0 -1
- package/dist/system-CpzPxRRq.js.map +0 -1
- package/dist/tools-CmFSfDMn.js.map +0 -1
- package/dist/tools-SPJtxG9N.cjs.map +0 -1
- package/dist/workspace-B6kzp-bo.js.map +0 -1
- package/dist/workspace-COKR1SxH.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as openai } from "./dist-6ZwWUUBQ.js";
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.
|
|
6
|
+
version: "1.80.0-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -24,7 +24,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
24
24
|
|
|
25
25
|
### Reference
|
|
26
26
|
|
|
27
|
-
- [Reference: Advanced trace queries](references/reference-observability-tracing-advanced-queries.md) - Find, count, and measure completed traces with structured predicates. List matching traces, aggregate
|
|
27
|
+
- [Reference: Advanced trace queries](references/reference-observability-tracing-advanced-queries.md) - Find, count, and measure completed traces and spans with structured predicates. List matching traces, aggregate traces or spans into grouped measures, paginate, poll, and discover query fields.
|
|
28
28
|
- [Reference: createRoute()](references/reference-server-create-route.md) - Use createRoute() to define type-safe Mastra server routes with Zod validation for requests and responses, plus handler context and OpenAPI metadata.
|
|
29
29
|
- [Reference: MastraServer](references/reference-server-mastra-server.md) - The MastraServer abstract class is the base for all server adapters. Extend this class to create adapters for frameworks other than Hono or Express.
|
|
30
30
|
- [Reference: Server routes](references/reference-server-routes.md) - Server adapters register these routes when you call server.init(). All routes are prefixed with the prefix option if configured.
|
|
@@ -100,7 +100,7 @@ export const supportAgent = new Agent({
|
|
|
100
100
|
id: 'support-agent',
|
|
101
101
|
name: 'Support Agent',
|
|
102
102
|
instructions: 'Answer user questions and delegate weather questions when needed.',
|
|
103
|
-
model: 'openai/gpt-
|
|
103
|
+
model: 'openai/gpt-6.1-sol',
|
|
104
104
|
agents: {
|
|
105
105
|
remoteWeatherAgent,
|
|
106
106
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
4
4
|
|
|
5
|
-
# MCP authentication
|
|
5
|
+
# MCP authentication and authorization
|
|
6
6
|
|
|
7
7
|
You either connect your Mastra application to someone else's protected MCP server, or you expose your own tools and data to a third-party client. Each direction needs different credentials and different checks.
|
|
8
8
|
|
|
@@ -125,7 +125,7 @@ An MCP access token is for the MCP server. The specification prohibits passing t
|
|
|
125
125
|
|
|
126
126
|
Keep access tokens, refresh tokens, and service credentials outside model-visible instructions, tool arguments, and tool results. Return only the data needed for the task. The [authentication and identity guide](https://mastra.ai/docs/guides/authentication-identity) explains this model boundary.
|
|
127
127
|
|
|
128
|
-
##
|
|
128
|
+
## Production checklist
|
|
129
129
|
|
|
130
130
|
- [ ] **Validate tokens:** Configure validation for your issuer, including audience and expiry checks, and confirm an unvalidated token is rejected.
|
|
131
131
|
- [ ] **Challenge missing tokens:** Confirm every protected server path returns `401` without a bearer token.
|
|
@@ -8,7 +8,7 @@ Mastra servers can execute custom middleware functions before or after an API ro
|
|
|
8
8
|
|
|
9
9
|
A middleware receives the [Hono](https://hono.dev) `Context` (`c`) and a `next` function. If it returns a `Response` the request is short-circuited. Calling `next()` continues processing the next middleware or route handler.
|
|
10
10
|
|
|
11
|
-
> **Note:** Middleware handlers use Hono's signature, so they run on Hono-based serving paths: `mastra dev` and `mastra build`, the [Hono adapter](https://mastra.ai/reference/server/hono-adapter), and adapters built on it such as `@mastra/next` and `@mastra/tanstack-start`. Adapters for other frameworks (Express, Fastify, Koa) can't run Hono handlers and log a warning at startup when middleware is configured. Register middleware through the framework's own API there instead.
|
|
11
|
+
> **Note:** Middleware handlers use Hono's signature, so they run on Hono-based serving paths: `mastra dev` and `mastra build`, the [Hono adapter](https://mastra.ai/reference/server/hono-adapter), and adapters built on it such as `@mastra/next` and `@mastra/tanstack-start`. Adapters for other frameworks (Elysia, Express, Fastify, Koa, NestJS) can't run Hono handlers and log a warning at startup when middleware is configured. Register middleware through the framework's own API there instead.
|
|
12
12
|
>
|
|
13
13
|
> User middleware never runs on routes declared public with `requiresAuth: false`, so it can't block endpoints the framework needs to keep reachable, such as the Studio sign-in routes.
|
|
14
14
|
|
|
@@ -10,8 +10,9 @@ Advanced trace queries select completed traces with a structured time range and
|
|
|
10
10
|
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------------------------------------------ |
|
|
11
11
|
| Query traces | List matching traces, paginate through them, and poll for new ones. | `queryTraces()` | `POST /api/observability/traces/query` |
|
|
12
12
|
| Aggregate traces | Count matching traces and compute measures, such as error rate, latency percentiles, tokens, and cost, optionally grouped by dimensions and time buckets. | `aggregateTraces()` | `POST /api/observability/traces/aggregate` |
|
|
13
|
+
| Aggregate spans | Compute the same measures over individual spans, such as every agent run including nested ones, grouped by span dimensions. | `aggregateSpans()` | `POST /api/observability/spans/aggregate` |
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
The trace APIs accept the same [trace selection](#select-traces). The filters, operators, and limits on this page apply to each. Use the aggregate API to find the group that needs attention, such as an agent with a high error rate, then send the same predicate plus the group's dimensions to the query API to list the traces behind it. Each query result represents a trace. Use its `traceId` to [retrieve the full trace](https://mastra.ai/reference/client-js/observability).
|
|
15
16
|
|
|
16
17
|
The endpoints use the same authentication as other observability routes and require the `observability:read` permission. Every request requires a time range.
|
|
17
18
|
|
|
@@ -25,6 +26,7 @@ The configured observability store must support each API. Call `getObservability
|
|
|
25
26
|
| -------------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
26
27
|
| `traceQuery` | `trace-query` | `queryTraces()` |
|
|
27
28
|
| `traceAggregate` | `trace-aggregate` | `aggregateTraces()` |
|
|
29
|
+
| `spanAggregate` | `span-aggregate` | `aggregateSpans()` |
|
|
28
30
|
| `traceQueryRootDuration` | `trace-query-root-duration` | Trace-scope `durationMs` predicates |
|
|
29
31
|
| `traceQueryTimeToFirstChunk` | `trace-query-time-to-first-chunk` | `timeToFirstChunkMs` predicates and results |
|
|
30
32
|
| `traceQueryTimeToFirstChunkSort` | `trace-query-time-to-first-chunk-sort` | `orderBy` on `timeToFirstChunkMs` |
|
|
@@ -34,7 +36,7 @@ The configured observability store must support each API. Call `getObservability
|
|
|
34
36
|
| `traceQueryDiscovery` | `trace-query-discovery` | [Field and value discovery](#discover-fields-and-values) |
|
|
35
37
|
| `traceQueryTenantScope` | `trace-query-tenant-scope` | [Trusted tenant scope](#trusted-tenant-scope) |
|
|
36
38
|
|
|
37
|
-
A missing `traceAggregate` value means the server doesn't support aggregation. Servers without the aggregate route return `404`, and stores without the feature return `501 TRACE_AGGREGATE_UNSUPPORTED`. Against a store without a sub-feature, a request that uses a gated field returns `501` before storage runs. Root span `name`, `spanType`, and `entityId` are the exception and return `422` with a `field_not_allowed` issue.
|
|
39
|
+
A missing `traceAggregate` value means the server doesn't support aggregation. Servers without the aggregate route return `404`, and stores without the feature return `501 TRACE_AGGREGATE_UNSUPPORTED`. A missing `spanAggregate` value means the same for span aggregation, and stores without the feature return `501 SPAN_AGGREGATE_UNSUPPORTED`. Against a store without a sub-feature, a request that uses a gated field returns `501` before storage runs. Root span `name`, `spanType`, and `entityId` are the exception and return `422` with a `field_not_allowed` issue.
|
|
38
40
|
|
|
39
41
|
## Select traces
|
|
40
42
|
|
|
@@ -212,7 +214,7 @@ const selectedModel = {
|
|
|
212
214
|
{
|
|
213
215
|
op: 'eq',
|
|
214
216
|
left: { path: 'model' },
|
|
215
|
-
right: { literal: 'claude-sonnet-
|
|
217
|
+
right: { literal: 'claude-sonnet-5-5' },
|
|
216
218
|
},
|
|
217
219
|
{ op: 'eq', left: { path: 'provider' }, right: { literal: 'anthropic' } },
|
|
218
220
|
],
|
|
@@ -700,14 +702,14 @@ Token and cost measures read the model usage metrics recorded for each trace, so
|
|
|
700
702
|
|
|
701
703
|
A trace that recorded at least one usage metric is usage-bearing. `tokens.<kind>.sum` adds the tokens of a group's usage-bearing traces, and `tokens.<kind>.avg` divides that sum by the number of usage-bearing traces, not by `count`. Both are `null` when the group has no usage-bearing traces.
|
|
702
704
|
|
|
703
|
-
Cost comes from estimated cost recorded on total input and total output token metrics. `cost.sum` adds the cost of traces with at least one priced metric, and `cost.avg` divides by the number of those traces. A
|
|
705
|
+
Cost comes from estimated cost recorded on total input and total output token metrics. `cost.sum` adds the cost of traces with at least one priced metric, and `cost.avg` divides by the number of those traces. A partly priced call, where Mastra could price some token types but not others, adds the cost of the priced token types. A metric with any other pricing failure adds no cost.
|
|
704
706
|
|
|
705
707
|
When you request any `cost.*` measure, every row also includes a `cost` object:
|
|
706
708
|
|
|
707
|
-
| Field | Description
|
|
708
|
-
| ---------- |
|
|
709
|
-
| `coverage` | Fraction of usage-bearing traces whose usage was fully priced, from 0 to 1. `null` when the group has no usage-bearing traces. |
|
|
710
|
-
| `unit` | Cost unit of the priced metrics, such as `USD`. `'mixed'` when they use more than one unit, and `null` when none are priced.
|
|
709
|
+
| Field | Description |
|
|
710
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
711
|
+
| `coverage` | Fraction of usage-bearing traces whose usage was fully priced, from 0 to 1. A trace with a partly priced call isn't fully priced, so it lowers coverage even though its known cost is in `cost.sum`. `null` when the group has no usage-bearing traces. |
|
|
712
|
+
| `unit` | Cost unit of the priced metrics, such as `USD`. `'mixed'` when they use more than one unit, and `null` when none are priced. |
|
|
711
713
|
|
|
712
714
|
`cost.sum` and `cost.avg` are `null` when the group has no priced traces or `unit` is `'mixed'`. A coverage below 1 means the cost understates the group's spend. The `cost` object isn't a measure, so `having` and `orderBy` can't reference it.
|
|
713
715
|
|
|
@@ -803,11 +805,90 @@ PostgreSQL and ClickHouse stop aggregations after the same `traceQueryTimeoutMs`
|
|
|
803
805
|
| `501` | The installed Core or configured observability store doesn't support aggregation or a requested field. Returns `TRACE_AGGREGATE_UNSUPPORTED`. |
|
|
804
806
|
| `504` | A PostgreSQL or ClickHouse aggregation exceeded its execution timeout. Returns `TRACE_QUERY_EXECUTION_TIMEOUT` without partial results. |
|
|
805
807
|
|
|
808
|
+
## Aggregate spans
|
|
809
|
+
|
|
810
|
+
Use `aggregateSpans()` or `POST /api/observability/spans/aggregate` to compute measures over individual spans instead of traces. Trace aggregation only sees each trace's root span, so an agent run nested inside a workflow isn't counted. Span aggregation counts every span that matches, at any depth.
|
|
811
|
+
|
|
812
|
+
The request has the same shape as [`aggregateTraces()`](#aggregate-request-fields), with the same measures, `having`, `orderBy`, `interval`, limits, and errors. The differences are in which records are selected and which dimensions are available.
|
|
813
|
+
|
|
814
|
+
### Aggregate spans with the client SDK
|
|
815
|
+
|
|
816
|
+
This request counts agent runs by status per day, including nested runs:
|
|
817
|
+
|
|
818
|
+
```typescript
|
|
819
|
+
const { capabilities } = await mastraClient.getObservabilityCapabilities()
|
|
820
|
+
|
|
821
|
+
if (capabilities.spanAggregate) {
|
|
822
|
+
const { rows } = await mastraClient.aggregateSpans({
|
|
823
|
+
timeRange: {
|
|
824
|
+
from: '2026-08-01T00:00:00.000Z',
|
|
825
|
+
to: '2026-08-08T00:00:00.000Z',
|
|
826
|
+
},
|
|
827
|
+
where: { op: 'eq', left: { path: 'spanType' }, right: { literal: 'agent_run' } },
|
|
828
|
+
groupBy: ['status'],
|
|
829
|
+
interval: '1d',
|
|
830
|
+
measures: ['count', 'duration.p95'],
|
|
831
|
+
})
|
|
832
|
+
}
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
Send the same body to `POST /api/observability/spans/aggregate` to use HTTP directly.
|
|
836
|
+
|
|
837
|
+
### Span selection
|
|
838
|
+
|
|
839
|
+
Aggregation selects the spans that [`querySpans()`](https://mastra.ai/reference/client-js/observability) would return for the same `timeRange` and `where`:
|
|
840
|
+
|
|
841
|
+
- `timeRange` bounds each span's `startedAt`, and can span up to 365 days.
|
|
842
|
+
- `where` accepts the `querySpans()` fields and operators, such as `spanType`, `name`, `status`, `durationMs`, entity and parent/root entity fields, and context identifiers.
|
|
843
|
+
- Only completed spans count. When a span was exported more than once, only its latest copy counts.
|
|
844
|
+
|
|
845
|
+
`count` equals the number of spans `querySpans()` pages through for the same request. Buckets use each span's `startedAt`. `duration.*` measures read the span's own duration, and `errorCount` and `errorRate` read whether the span itself recorded an error.
|
|
846
|
+
|
|
847
|
+
On ClickHouse, a request whose `where` limits `spanType` to agent, workflow, processor, or scorer runs, RAG ingestion, or tool calls reads the smaller branch table instead of every span. That path can differ from `querySpans()`:
|
|
848
|
+
|
|
849
|
+
- Spans written before an upgrade from `@mastra/clickhouse` 1.4, 1.5, or 1.6 aren't in the branch table, so older windows can count fewer spans.
|
|
850
|
+
- After ClickHouse merges the copies of a span exported more than once, the branch table keeps the copy written last, not the one that ended last. Counts don't change, but the `status` and duration of a retried span can.
|
|
851
|
+
|
|
852
|
+
### Span dimensions
|
|
853
|
+
|
|
854
|
+
| Dimension | Notes |
|
|
855
|
+
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
856
|
+
| `name`, `spanType`, `status` | The span's own name, type, and status. `status` is `error` when the span recorded an error and `success` otherwise. |
|
|
857
|
+
| `entityType`, `entityId`, `entityName` | The entity that produced the span. |
|
|
858
|
+
| `parentEntityType`, `parentEntityName`, `rootEntityType`, `rootEntityName` | The calling entity and the trace's root entity, such as the agent that made a model call. |
|
|
859
|
+
| `environment`, `serviceName`, `executionSource` | Deployment attributes recorded on the span. |
|
|
860
|
+
| `threadId`, `resourceId`, `userId`, `sessionId`, `organizationId`, `experimentId` | Context identifiers recorded on the span. |
|
|
861
|
+
|
|
862
|
+
`countDistinct.<field>` accepts these dimensions and `traceId`, so `countDistinct.traceId` counts the traces the selected spans belong to. Span aggregation can't group by `metadata.<key>`, identity fields such as `traceId`, `spanId`, or `runId`, or by model and provider.
|
|
863
|
+
|
|
864
|
+
### Span tokens and cost
|
|
865
|
+
|
|
866
|
+
Token and cost measures use the usage metrics recorded by each span, matched by `traceId` and `spanId`. The [trace token rules](#token-and-cost-measures) apply per span: metrics from `timeRange.from` on count, retried exports count once, and averages divide by usage-bearing spans.
|
|
867
|
+
|
|
868
|
+
Usage isn't added up to parent spans. Model calls record usage on `model_generation` spans, so an `agent_run` span has no tokens of its own unless a model call under it wasn't exported. When a `model_generation` span isn't exported, its usage is recorded on the nearest exported ancestor instead. For token totals per agent, select `model_generation` spans and group by the calling agent:
|
|
869
|
+
|
|
870
|
+
```typescript
|
|
871
|
+
const tokensByAgent = await mastraClient.aggregateSpans({
|
|
872
|
+
timeRange: {
|
|
873
|
+
from: '2026-08-01T00:00:00.000Z',
|
|
874
|
+
to: '2026-08-08T00:00:00.000Z',
|
|
875
|
+
},
|
|
876
|
+
where: { op: 'eq', left: { path: 'spanType' }, right: { literal: 'model_generation' } },
|
|
877
|
+
groupBy: ['parentEntityName'],
|
|
878
|
+
measures: ['tokens.total.sum', 'cost.sum'],
|
|
879
|
+
orderBy: { field: 'cost.sum', direction: 'desc' },
|
|
880
|
+
})
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### List the spans behind a group
|
|
884
|
+
|
|
885
|
+
Aggregation never returns span records. To inspect a group, send the same `timeRange` and `where` to `querySpans()`, and add the group's dimension values as `eq` conditions. For example, add `{ op: 'eq', left: { path: 'status' }, right: { literal: 'error' } }` to list the failed agent runs from the first example.
|
|
886
|
+
|
|
806
887
|
## Trusted tenant scope
|
|
807
888
|
|
|
808
|
-
Hosts that serve more than one tenant supply a trusted scope outside the query document. The server reads the reserved `organizationId` request-context key, which only server-side authentication can set, and passes `{ organizationId }` to the planner. The scope is carried on the trusted plan and ANDed into every scan: current roots, related spans, the usage metrics read by token and cost measures, and both discovery routes. A related record from another tenant that shares a `traceId` never qualifies a trace.
|
|
889
|
+
Hosts that serve more than one tenant supply a trusted scope outside the query document. The server reads the reserved `organizationId` request-context key, which only server-side authentication can set, and passes `{ organizationId }` to the planner. The scope is carried on the trusted plan and ANDed into every scan: current roots, related spans, the usage metrics read by token and cost measures, span aggregation, and both discovery routes. A related record from another tenant that shares a `traceId` never qualifies a trace.
|
|
809
890
|
|
|
810
|
-
Hosts that call storage directly can pass a fuller scope to `planTraceQuery()`, `planTraceAggregate()`, `planTraceQueryObservedFields()`, and `planTraceQueryValues()`:
|
|
891
|
+
Hosts that call storage directly can pass a fuller scope to `planTraceQuery()`, `planTraceAggregate()`, `planSpanAggregate()`, `planTraceQueryObservedFields()`, and `planTraceQueryValues()`:
|
|
811
892
|
|
|
812
893
|
```typescript
|
|
813
894
|
const plan = planTraceQuery(parseTraceQueryRequest(request), {
|
|
@@ -938,7 +1019,7 @@ Both routes require `observability:read` and use the configured observability st
|
|
|
938
1019
|
|
|
939
1020
|
## Limitations
|
|
940
1021
|
|
|
941
|
-
|
|
1022
|
+
The query and aggregate APIs consider completed traces and spans only, not running ones. Trace queries can't return custom projections, embedded evidence, or summaries, and numbered trace pages include a total count. Trace aggregation can't group by span fields other than the root span's `name`, `spanType`, and `entityId`, or by `traceId` or `attributes.*`. Aggregation can't compute numeric measures over metadata, paginate groups, or zero-fill empty buckets. Span aggregation can't group by `model` or `provider`, and it attributes tokens only to the span that recorded them. The CLI's `mastra api trace aggregate` covers trace aggregation, and `mastra api span query` and `mastra api span aggregate` cover span queries and span aggregation.
|
|
942
1023
|
|
|
943
1024
|
## Related
|
|
944
1025
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_agents = require("./agents-
|
|
1
|
+
const require_agents = require("./agents-CPYFVJak.cjs");
|
|
2
2
|
let zod_v4 = require("zod/v4");
|
|
3
3
|
//#region src/server/schemas/editor-builder.ts
|
|
4
4
|
/**
|
|
@@ -256,4 +256,4 @@ Object.defineProperty(exports, "providerModelEntrySchema", {
|
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
|
|
259
|
-
//# sourceMappingURL=editor-builder-
|
|
259
|
+
//# sourceMappingURL=editor-builder-Bt26tVKI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-BDtiWw0f.cjs","names":["z","providerSchema"],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsBA,OAAAA,EAAE,OAAO;CAC1C,OAAOA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAWA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAASA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAWA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,WAAWA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,cAAcA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CACnC,SAASA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;CAM9B,OAAOA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;AAC9B,CAAC;;;;;;;;;;AAaD,MAAM,2BAA2BA,OAAAA,EAC9B,OAAO;CACN,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC1B,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;AACtC,CAAC,CAAC,CACD,OAAO;AAEV,MAAM,4BAA4BA,OAAAA,EAC/B,OAAO;CACN,MAAMA,OAAAA,EAAE,QAAQ,QAAQ;CACxB,UAAUA,OAAAA,EA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+
{"version":3,"file":"editor-builder-Bt26tVKI.cjs","names":["z","providerSchema"],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsBA,OAAAA,EAAE,OAAO;CAC1C,OAAOA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAWA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAASA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQA,OAAAA,EAAE,QAAQ,CAA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;EAC5B,YAAYA,OAAAA,EAAE,QAAQ;EACtB,eAAeA,OAAAA,EAAE,QAAQ;EACzB,YAAYA,OAAAA,EAAE,QAAQ;EACtB,oBAAoBA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;EACxC,iBAAiBA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;EACrC,QAAQA,OAAAA,EAAE,MAAMA,OAAAA,EAAE,OAAO;GAAE,KAAKA,OAAAA,EAAE,OAAO;GAAG,OAAOA,OAAAA,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,YAAYA,OAAAA,EAAE,OAAO,EACnB,UAAUA,OAAAA,EAAE,OAAO,EACjB,SAASA,OAAAA,EAAE,QAAQ,EACrB,CAAC,EACH,CAAC;AACH,CAAC;;;;;;;;;AAUD,MAAa,uCAAuCA,OAAAA,EAAE,OAAO,EAC3D,WAAWA,OAAAA,EAAE,MAAMC,eAAAA,cAAc,EACnC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as providerSchema } from "./agents-BjdJ-Tyf.js";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
//#region src/server/schemas/editor-builder.ts
|
|
4
4
|
/**
|
|
@@ -191,4 +191,4 @@ const builderAvailableModelsResponseSchema = z.object({ providers: z.array(provi
|
|
|
191
191
|
//#endregion
|
|
192
192
|
export { builderModelPolicySchema as a, defaultModelEntrySchema as c, providerModelEntrySchema as d, builderAvailableModelsResponseSchema as i, infrastructureStatusResponseSchema as l, agentFeaturesSchema as n, builderPickerSchema as o, agentModelsSchema as r, builderSettingsResponseSchema as s, agentConfigurationSchema as t, pickerAllowlistSchema as u };
|
|
193
193
|
|
|
194
|
-
//# sourceMappingURL=editor-builder-
|
|
194
|
+
//# sourceMappingURL=editor-builder-DWMgkYK-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-DnLCfqnY.js","names":[],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,cAAc,EAAE,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,CACH,EACF,CAAC;CACD,SAAS,EAAE,OAAO;EAChB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;EAC9B,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS;EACzB,YAAY,EAAE,QAAQ;EACtB,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC;EACtC,QAAQ,EAAE,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,WAAW,EAAE,OAAO;EAClB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;EAC5B,YAAY,EAAE,QAAQ;EACtB,eAAe,EAAE,QAAQ;EACzB,YAAY,EAAE,QAAQ;EACtB,oBAAoB,EAAE,OAAO,CAAC,CAAC,SAAS;EACxC,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;EACrC,QAAQ,EAAE,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,YAAY,EAAE,OAAO,EACnB,UAAU,EAAE,OAAO,EACjB,SAAS,EAAE,QAAQ,EACrB,CAAC,EACH,CAAC;AACH,CAAC;;;;;;;;;AAUD,MAAa,uCAAuC,EAAE,OAAO,EAC3D,WAAW,EAAE,MAAM,cAAc,EACnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"editor-builder-DWMgkYK-.js","names":[],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,cAAc,EAAE,QAAQ,CAAC,CAAC,SAAS;CACnC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;CAM9B,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;AAC9B,CAAC;;;;;;;;;;A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OAAO,CAAC,CAAC,SAAS;EACzB,YAAY,EAAE,QAAQ;EACtB,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC;EACtC,QAAQ,EAAE,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,WAAW,EAAE,OAAO;EAClB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;EAC5B,YAAY,EAAE,QAAQ;EACtB,eAAe,EAAE,QAAQ;EACzB,YAAY,EAAE,QAAQ;EACtB,oBAAoB,EAAE,OAAO,CAAC,CAAC,SAAS;EACxC,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;EACrC,QAAQ,EAAE,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,YAAY,EAAE,OAAO,EACnB,UAAU,EAAE,OAAO,EACjB,SAAS,EAAE,QAAQ,EACrB,CAAC,EACH,CAAC;AACH,CAAC;;;;;;;;;AAUD,MAAa,uCAAuC,EAAE,OAAO,EAC3D,WAAW,EAAE,MAAM,cAAc,EACnC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_http_exception = require("./http-exception-CKDHupKw.cjs");
|
|
2
2
|
const require_route_builder = require("./route-builder-B2Qhhd7C.cjs");
|
|
3
3
|
const require_server_handlers_error = require("./server/handlers/error.cjs");
|
|
4
|
-
const require_agents = require("./agents-
|
|
5
|
-
const require_editor_builder = require("./editor-builder-
|
|
4
|
+
const require_agents = require("./agents-CcY0JTDF.cjs");
|
|
5
|
+
const require_editor_builder = require("./editor-builder-Bt26tVKI.cjs");
|
|
6
6
|
//#region src/server/utils/resolve-builder-model-policy.ts
|
|
7
7
|
/**
|
|
8
8
|
* Server-side wrapper around `builderToModelPolicy`.
|
|
@@ -364,4 +364,4 @@ Object.defineProperty(exports, "requireBuilderFeature", {
|
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
-
//# sourceMappingURL=editor-builder-
|
|
367
|
+
//# sourceMappingURL=editor-builder-D_OUA9P6.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-DtpP1FtW.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,MAAM;CACxE,IAAI,OAAO,OAAO,4BAA4B,cAAc,CAAC,OAAO,wBAAwB,GAC1F,OAAO,EAAE,QAAQ,MAAM;CAMzB,IAAI;EACF,MAAM,UAAU,MAAM,OAAO,eAAe;EAC5C,MAAM,EAAE,yBAAyB,MAAM,OAAO;EAC9C,OAAO,qBAAqB,OAAO;CACrC,QAAQ;EACN,OAAO,EAAE,QAAQ,MAAM;CACzB;AACF;;;;;;;ACnBA,eAAe,uBAAuB,QAA+C;CACnF,MAAM,SAAS,OAAO,UAAU;CAChC,IAAI,CAAC,UAAU,OAAO,OAAO,mBAAmB,YAAY,OAAO;CACnE,IAAI,CAAC,OAAO,0BAA0B,GAAG,OAAO;CAChD,MAAM,UAAU,MAAM,OAAO,eAAe;CAC5C,IAAI,CAAC,WAAW,CAAC,QAAQ,SAAS,OAAO;CACzC,MAAM,WAAW,QAAQ,cAA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Ae;IACnD,MAAM,sBAAsB,cAAc,cACtC,qBAAqB,aAAa,eAClC,KAAA;IACJ,MAAM,aAAa,qBAAqB,UAAU,cAAc,gBAAgB;IAChF,MAAM,UAAU,qBAAqB,UAAU,WAAW,gBAAgB;IAC1E,MAAM,mBACJ,OAAO,gBAAgB,eAAe,YACtC,gBAAgB,cAChB,YAAY,gBAAgB,aACvB,gBAAgB,WAAW,SAC5B,CAAC;IACP,MAAM,gBACJ,OAAO,gBAAgB,YAAY,YAAY,gBAAgB,WAAW,YAAY,gBAAgB,UACjG,gBAAgB,QAAQ,SACzB,CAAC;IACP,YAAY;KACV,MAAM,cAAc,QAAQ;KAC5B,aAAa,cAAc,eAAe;KAC1C,MAAM,gBAAgB,QAAQ,qBAAqB,UAAU,QAAQ;KACrE,QAAQ,qBAAqB,UAAU;KACvC,YAAY,CAAC,CAAC;KACd,eAAe,CAAC,CAAC;KACjB,YAAY,CAAC,CAAC;KACd,oBAAoB,gBAAgB,UAAU;KAC9C,iBAAiB,gBAAgB,OAAO;KACxC,QAAQ,CACN,GAAG,iBAAiB,gBAAgB,CAAC,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"}
|
|
1
|
+
{"version":3,"file":"editor-builder-D_OUA9P6.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"],"mapp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;KACvC,YAAY,CAAC,CAAC;KACd,eAAe,CAAC,CAAC;KACjB,YAAY,CAAC,CAAC;KACd,oBAAoB,gBAAgB,UAAU;KAC9C,iBAAiB,gBAAgB,OAAO;KACxC,QAAQ,CACN,GAAG,iBAAiB,gBAAgB,CAAC,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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as HTTPException } from "./http-exception-CyfxZB6W.js";
|
|
2
2
|
import { n as createRoute } from "./route-builder-CjkWxv4E.js";
|
|
3
3
|
import { handleError } from "./server/handlers/error.js";
|
|
4
|
-
import {
|
|
5
|
-
import { i as builderAvailableModelsResponseSchema, l as infrastructureStatusResponseSchema, n as agentFeaturesSchema, s as builderSettingsResponseSchema } from "./editor-builder-
|
|
4
|
+
import { U as buildProvidersList } from "./agents-DaLwtv9x.js";
|
|
5
|
+
import { i as builderAvailableModelsResponseSchema, l as infrastructureStatusResponseSchema, n as agentFeaturesSchema, s as builderSettingsResponseSchema } from "./editor-builder-DWMgkYK-.js";
|
|
6
6
|
//#region src/server/utils/resolve-builder-model-policy.ts
|
|
7
7
|
/**
|
|
8
8
|
* Server-side wrapper around `builderToModelPolicy`.
|
|
@@ -335,4 +335,4 @@ const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({
|
|
|
335
335
|
//#endregion
|
|
336
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 };
|
|
337
337
|
|
|
338
|
-
//# sourceMappingURL=editor-builder-
|
|
338
|
+
//# sourceMappingURL=editor-builder-DzGLnYcJ.js.map
|