@mastra/server 1.64.1-alpha.0 → 1.65.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +14 -1
- package/dist/{a2a-C7OgMND3.cjs → a2a-CW4FVjHx.cjs} +72 -21
- package/dist/a2a-CW4FVjHx.cjs.map +1 -0
- package/dist/{a2a-DdCHhKh5.js → a2a-Di7S6YaM.js} +72 -21
- package/dist/a2a-Di7S6YaM.js.map +1 -0
- package/dist/{agent-builder-D8JyDQ5J.cjs → agent-builder-B2GCn_tS.cjs} +2 -2
- package/dist/{agent-builder-D8JyDQ5J.cjs.map → agent-builder-B2GCn_tS.cjs.map} +1 -1
- package/dist/{agent-builder-DNTFty1u.js → agent-builder-DUM8fGTt.js} +2 -2
- package/dist/{agent-builder-DNTFty1u.js.map → agent-builder-DUM8fGTt.js.map} +1 -1
- package/dist/{agents-BetrUB_N.js → agents-AMeMJBI1.js} +2 -7
- package/dist/agents-AMeMJBI1.js.map +1 -0
- package/dist/{agents-CLv_RFQx.cjs → agents-C3k-sZBO.cjs} +2 -7
- package/dist/agents-C3k-sZBO.cjs.map +1 -0
- package/dist/{api-schema-manifest-BiPbewoh.js → api-schema-manifest-BHT0tcvI.js} +2 -2
- package/dist/{api-schema-manifest-BiPbewoh.js.map → api-schema-manifest-BHT0tcvI.js.map} +1 -1
- package/dist/{api-schema-manifest-BqgRfP-2.cjs → api-schema-manifest-Dk_mN3ub.cjs} +2 -2
- package/dist/{api-schema-manifest-BqgRfP-2.cjs.map → api-schema-manifest-Dk_mN3ub.cjs.map} +1 -1
- package/dist/{datasets-DYhcB-od.cjs → datasets-C63D44YJ.cjs} +13 -1
- package/dist/datasets-C63D44YJ.cjs.map +1 -0
- package/dist/{datasets-CInAtVdf.js → datasets-DFPCu6ID.js} +8 -2
- package/dist/datasets-DFPCu6ID.js.map +1 -0
- package/dist/{dist-mj70vroq.cjs → dist-BLP1i9vT.cjs} +66 -20
- package/dist/dist-BLP1i9vT.cjs.map +1 -0
- package/dist/{dist-BwPO-2NT.js → dist-BLvSboHt.js} +66 -20
- package/dist/dist-BLvSboHt.js.map +1 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-observability-tracing-trace-query.md +179 -0
- package/dist/docs/references/reference-server-routes.md +1 -0
- package/dist/{dynamic-workflows-CzkrhMwZ.js → dynamic-workflows-Cn9MXevC.js} +16 -1
- package/dist/dynamic-workflows-Cn9MXevC.js.map +1 -0
- package/dist/{dynamic-workflows-BT_ryQUl.cjs → dynamic-workflows-DSg9_yec.cjs} +16 -1
- package/dist/dynamic-workflows-DSg9_yec.cjs.map +1 -0
- package/dist/{editor-builder-BDEm-gZe.js → editor-builder-BmEpZsqX.js} +2 -2
- package/dist/{editor-builder-BDEm-gZe.js.map → editor-builder-BmEpZsqX.js.map} +1 -1
- package/dist/{editor-builder-B-KatZ10.cjs → editor-builder-DeFo8Kl5.cjs} +2 -2
- package/dist/{editor-builder-B-KatZ10.cjs.map → editor-builder-DeFo8Kl5.cjs.map} +1 -1
- package/dist/{editor-builder-c7QiLUV9.js → editor-builder-DzpPA6dp.js} +2 -2
- package/dist/{editor-builder-c7QiLUV9.js.map → editor-builder-DzpPA6dp.js.map} +1 -1
- package/dist/{editor-builder-DNRVszU-.cjs → editor-builder-WLxTW05v.cjs} +2 -2
- package/dist/{editor-builder-DNRVszU-.cjs.map → editor-builder-WLxTW05v.cjs.map} +1 -1
- package/dist/{observability-new-endpoints-BxXDVoQ0.cjs → observability-new-endpoints-DF85EOQS.cjs} +178 -15
- package/dist/observability-new-endpoints-DF85EOQS.cjs.map +1 -0
- package/dist/{observability-new-endpoints-C_om-Dj7.js → observability-new-endpoints-Zm5VNGIa.js} +174 -19
- package/dist/observability-new-endpoints-Zm5VNGIa.js.map +1 -0
- package/dist/{routes-DYQWvd_y.cjs → routes-BqrG1FfY.cjs} +8 -5
- package/dist/routes-BqrG1FfY.cjs.map +1 -0
- package/dist/{routes-CCD8Q7x1.js → routes-CxuspiM8.js} +10 -7
- package/dist/routes-CxuspiM8.js.map +1 -0
- package/dist/server/a2a/tasks.d.ts +13 -1
- package/dist/server/a2a/tasks.d.ts.map +1 -1
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +4 -4
- package/dist/server/handlers/agent-builder.d.ts +30 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +4 -4
- package/dist/server/handlers/agents.cjs +102 -41
- package/dist/server/handlers/agents.cjs.map +1 -1
- package/dist/server/handlers/agents.d.ts +55 -55
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +102 -41
- package/dist/server/handlers/agents.js.map +1 -1
- package/dist/server/handlers/author-enrichment.cjs +5 -3
- package/dist/server/handlers/author-enrichment.cjs.map +1 -1
- package/dist/server/handlers/author-enrichment.d.ts +1 -1
- package/dist/server/handlers/author-enrichment.d.ts.map +1 -1
- package/dist/server/handlers/author-enrichment.js +5 -3
- package/dist/server/handlers/author-enrichment.js.map +1 -1
- package/dist/server/handlers/datasets.cjs +29 -2
- package/dist/server/handlers/datasets.cjs.map +1 -1
- package/dist/server/handlers/datasets.d.ts +117 -0
- package/dist/server/handlers/datasets.d.ts.map +1 -1
- package/dist/server/handlers/datasets.js +29 -3
- package/dist/server/handlers/datasets.js.map +1 -1
- package/dist/server/handlers/dynamic-workflows.cjs +1 -1
- package/dist/server/handlers/dynamic-workflows.d.ts +96 -0
- package/dist/server/handlers/dynamic-workflows.d.ts.map +1 -1
- package/dist/server/handlers/dynamic-workflows.js +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 +302 -56
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +2 -2
- package/dist/server/handlers/observability-shared.cjs +13 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +8 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +13 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability-storage-schemas.cjs +5 -0
- package/dist/server/handlers/observability-storage-schemas.cjs.map +1 -1
- package/dist/server/handlers/observability-storage-schemas.d.ts +2 -0
- package/dist/server/handlers/observability-storage-schemas.d.ts.map +1 -1
- package/dist/server/handlers/observability-storage-schemas.js +4 -1
- package/dist/server/handlers/observability-storage-schemas.js.map +1 -1
- package/dist/server/handlers/observability.cjs +26 -1
- package/dist/server/handlers/observability.cjs.map +1 -1
- package/dist/server/handlers/observability.d.ts +2 -0
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +26 -3
- package/dist/server/handlers/observability.js.map +1 -1
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/responses.d.ts +11 -11
- 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 +2 -2
- package/dist/server/handlers/stored-agents.js +2 -2
- 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 +7 -4
- package/dist/server/handlers/system.cjs.map +1 -1
- 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 +7 -4
- package/dist/server/handlers/system.js.map +1 -1
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/workflows.cjs +3 -3
- package/dist/server/handlers/workflows.cjs.map +1 -1
- package/dist/server/handlers/workflows.d.ts +42 -0
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +3 -3
- package/dist/server/handlers/workflows.js.map +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +2 -2
- package/dist/server/schemas/agents.d.ts +8 -16
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/datasets.d.ts +7 -0
- package/dist/server/schemas/datasets.d.ts.map +1 -1
- package/dist/server/schemas/dynamic-workflows.d.ts +72 -0
- package/dist/server/schemas/dynamic-workflows.d.ts.map +1 -1
- package/dist/server/schemas/feedback.d.ts +64 -0
- package/dist/server/schemas/feedback.d.ts.map +1 -0
- package/dist/server/schemas/index.cjs +7 -6
- package/dist/server/schemas/index.js +7 -7
- package/dist/server/schemas/system.d.ts +1 -0
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/schemas/workflows.d.ts +12 -0
- package/dist/server/schemas/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +9 -2
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +3 -0
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +8 -3
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/routes/agent-builder.d.ts +30 -0
- package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/conversations.d.ts +3 -3
- package/dist/server/server-adapter/routes/datasets.d.ts +116 -0
- package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/legacy.d.ts +6 -6
- package/dist/server/server-adapter/routes/observability.d.ts +122 -1
- 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/workflows.d.ts +42 -0
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workspace.d.ts +23 -23
- package/dist/{system-wl_uZdyz.cjs → system-Cfo5a63a.cjs} +3 -1
- package/dist/system-Cfo5a63a.cjs.map +1 -0
- package/dist/{system-0TbTYKJY.js → system-DT2JfUun.js} +3 -1
- package/dist/system-DT2JfUun.js.map +1 -0
- package/dist/{workflows--79xhOOb.cjs → workflows-BNnfyZhn.cjs} +20 -15
- package/dist/workflows-BNnfyZhn.cjs.map +1 -0
- package/dist/{workflows-B2ooCiwN.js → workflows-CUgR3bTL.js} +20 -15
- package/dist/workflows-CUgR3bTL.js.map +1 -0
- package/package.json +5 -5
- package/dist/a2a-C7OgMND3.cjs.map +0 -1
- package/dist/a2a-DdCHhKh5.js.map +0 -1
- package/dist/agents-BetrUB_N.js.map +0 -1
- package/dist/agents-CLv_RFQx.cjs.map +0 -1
- package/dist/datasets-CInAtVdf.js.map +0 -1
- package/dist/datasets-DYhcB-od.cjs.map +0 -1
- package/dist/dist-BwPO-2NT.js.map +0 -1
- package/dist/dist-mj70vroq.cjs.map +0 -1
- package/dist/dynamic-workflows-BT_ryQUl.cjs.map +0 -1
- package/dist/dynamic-workflows-CzkrhMwZ.js.map +0 -1
- package/dist/observability-new-endpoints-BxXDVoQ0.cjs.map +0 -1
- package/dist/observability-new-endpoints-C_om-Dj7.js.map +0 -1
- package/dist/routes-CCD8Q7x1.js.map +0 -1
- package/dist/routes-DYQWvd_y.cjs.map +0 -1
- package/dist/system-0TbTYKJY.js.map +0 -1
- package/dist/system-wl_uZdyz.cjs.map +0 -1
- package/dist/workflows--79xhOOb.cjs.map +0 -1
- package/dist/workflows-B2ooCiwN.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-B-KatZ10.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';\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 const channelProviders = 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,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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-DeFo8Kl5.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';\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 const channelProviders = 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;;;;;;;ACpBA,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,cAAc,CAAC,EAAE;CAC1C,IAAI,CAAC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AChF,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"}
|
|
@@ -2,7 +2,7 @@ import { t as HTTPException } from "./http-exception-CyfxZB6W.js";
|
|
|
2
2
|
import { n as createRoute } from "./route-builder-BveLN9LU.js";
|
|
3
3
|
import { handleError } from "./server/handlers/error.js";
|
|
4
4
|
import { buildProvidersList } from "./server/handlers/agents.js";
|
|
5
|
-
import { i as builderAvailableModelsResponseSchema, l as infrastructureStatusResponseSchema, n as agentFeaturesSchema, s as builderSettingsResponseSchema } from "./editor-builder-
|
|
5
|
+
import { i as builderAvailableModelsResponseSchema, l as infrastructureStatusResponseSchema, n as agentFeaturesSchema, s as builderSettingsResponseSchema } from "./editor-builder-BmEpZsqX.js";
|
|
6
6
|
//#region src/server/utils/resolve-builder-model-policy.ts
|
|
7
7
|
/**
|
|
8
8
|
* Server-side wrapper around `builderToModelPolicy`.
|
|
@@ -334,4 +334,4 @@ const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({
|
|
|
334
334
|
//#endregion
|
|
335
335
|
export { requireBuilderFeature as a, isBuilderFeatureEnabled as i, GET_EDITOR_BUILDER_SETTINGS_ROUTE as n, GET_INFRASTRUCTURE_STATUS_ROUTE as r, GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE as t };
|
|
336
336
|
|
|
337
|
-
//# sourceMappingURL=editor-builder-
|
|
337
|
+
//# sourceMappingURL=editor-builder-DzpPA6dp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-c7QiLUV9.js","names":[],"sources":["../src/server/utils/resolve-builder-model-policy.ts","../src/server/handlers/editor-builder.ts"],"sourcesContent":["import type { BuilderModelPolicy } from '@mastra/core/agent-builder/ee';\nimport type { IMastraEditor } from '@mastra/core/editor';\n\n/**\n * Server-side wrapper around `builderToModelPolicy`.\n *\n * Handles the optional `IMastraEditor` builder API surface (older / OSS editors\n * may not implement `hasEnabledBuilderConfig` / `resolveBuilder`) and returns\n * a uniform `BuilderModelPolicy` to every call site.\n *\n * Returns `{ active: false }` whenever:\n * - no editor is configured,\n * - the editor doesn't expose builder methods,\n * - the builder config is disabled, or\n * - resolving the builder fails / yields nothing.\n *\n * The `@mastra/core/agent-builder/ee` subpath is loaded lazily so this module\n * remains importable on `@mastra/core` versions that pre-date the subpath\n * (the subpath was added in core 1.34.0). The dynamic import is only reached\n * once an editor is actually configured, by which point a compatible core is\n * guaranteed.\n */\nexport async function resolveBuilderModelPolicy(editor: IMastraEditor | undefined): Promise<BuilderModelPolicy> {\n if (!editor) return { active: false };\n if (typeof editor.resolveBuilder !== 'function') return { active: false };\n if (typeof editor.hasEnabledBuilderConfig === 'function' && !editor.hasEnabledBuilderConfig()) {\n return { active: false };\n }\n\n // Degrade to inactive on builder-resolution failure rather than letting the\n // rejection escape: agent execution routes seed this on every request, so a\n // transient failure must not 500 the entire route.\n try {\n const builder = await editor.resolveBuilder();\n const { builderToModelPolicy } = await import('@mastra/core/agent-builder/ee');\n return builderToModelPolicy(builder);\n } catch {\n return { active: false };\n }\n}\n","import type { Mastra } from '@mastra/core';\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 const channelProviders = 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;;;;;;;ACpBA,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,cAAc,CAAC,EAAE;CAC1C,IAAI,CAAC,UAAU,OAAO;CAEtB,MAAM,SAAS,oBAAoB,UAAU,QAAQ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ACP,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,OAAO,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"editor-builder-DzpPA6dp.js","names":[],"sources":["../src/server/utils/resolve-builder-model-policy.ts","../src/server/handlers/editor-builder.ts"],"sourcesContent":["import type { BuilderModelPolicy } from '@mastra/core/agent-builder/ee';\nimport type { IMastraEditor } from '@mastra/core/editor';\n\n/**\n * Server-side wrapper around `builderToModelPolicy`.\n *\n * Handles the optional `IMastraEditor` builder API surface (older / OSS editors\n * may not implement `hasEnabledBuilderConfig` / `resolveBuilder`) and returns\n * a uniform `BuilderModelPolicy` to every call site.\n *\n * Returns `{ active: false }` whenever:\n * - no editor is configured,\n * - the editor doesn't expose builder methods,\n * - the builder config is disabled, or\n * - resolving the builder fails / yields nothing.\n *\n * The `@mastra/core/agent-builder/ee` subpath is loaded lazily so this module\n * remains importable on `@mastra/core` versions that pre-date the subpath\n * (the subpath was added in core 1.34.0). The dynamic import is only reached\n * once an editor is actually configured, by which point a compatible core is\n * guaranteed.\n */\nexport async function resolveBuilderModelPolicy(editor: IMastraEditor | undefined): Promise<BuilderModelPolicy> {\n if (!editor) return { active: false };\n if (typeof editor.resolveBuilder !== 'function') return { active: false };\n if (typeof editor.hasEnabledBuilderConfig === 'function' && !editor.hasEnabledBuilderConfig()) {\n return { active: false };\n }\n\n // Degrade to inactive on builder-resolution failure rather than letting the\n // rejection escape: agent execution routes seed this on every request, so a\n // transient failure must not 500 the entire route.\n try {\n const builder = await editor.resolveBuilder();\n const { builderToModelPolicy } = await import('@mastra/core/agent-builder/ee');\n return builderToModelPolicy(builder);\n } catch {\n return { active: false };\n }\n}\n","import type { Mastra } from '@mastra/core';\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 const channelProviders = 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;;;;;;;ACpBA,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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,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,OAAO,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_agents = require("./agents-
|
|
1
|
+
const require_agents = require("./agents-C3k-sZBO.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-WLxTW05v.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-DNRVszU-.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,QAAQ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AAE,OAAO,CAAC,CAAC,SAAS;EAC1B,QAAQA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;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
|
+
{"version":3,"file":"editor-builder-WLxTW05v.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,OA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,WAAWA,OAAAA,EAAE,MAAMC,eAAAA,cAAc,EACnC,CAAC"}
|
package/dist/{observability-new-endpoints-BxXDVoQ0.cjs → observability-new-endpoints-DF85EOQS.cjs}
RENAMED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Bd6kNlEP.cjs");
|
|
1
2
|
const require_http_exception = require("./http-exception-CKDHupKw.cjs");
|
|
2
3
|
const require_route_builder = require("./route-builder-C8n4ugUf.cjs");
|
|
4
|
+
const require_constants = require("./constants-4IJp_uzj.cjs");
|
|
3
5
|
const require_server_handlers_error = require("./server/handlers/error.cjs");
|
|
4
6
|
const require_server_handlers_observability_list_query_schemas = require("./server/handlers/observability-list-query-schemas.cjs");
|
|
5
7
|
const require_server_handlers_observability_shared = require("./server/handlers/observability-shared.cjs");
|
|
8
|
+
const require_server_handlers_author_enrichment = require("./server/handlers/author-enrichment.cjs");
|
|
6
9
|
let zod_v4 = require("zod/v4");
|
|
10
|
+
let _mastra_core_storage = require("@mastra/core/storage");
|
|
11
|
+
_mastra_core_storage = require_rolldown_runtime.__toESM(_mastra_core_storage, 1);
|
|
7
12
|
let _mastra_core_features = require("@mastra/core/features");
|
|
8
13
|
let _mastra_core_observability = require("@mastra/core/observability");
|
|
9
14
|
//#region ../_internal-core/dist/storage/index.js
|
|
@@ -588,7 +593,7 @@ zod_v4.z.object({
|
|
|
588
593
|
direction: "DESC"
|
|
589
594
|
} })).describe("Arguments for listing feedback");
|
|
590
595
|
/** Schema for listFeedback operation response */
|
|
591
|
-
const listFeedbackResponseSchema = zod_v4.z.object({
|
|
596
|
+
const listFeedbackResponseSchema$1 = zod_v4.z.object({
|
|
592
597
|
pagination: paginationInfoSchema.optional(),
|
|
593
598
|
delta: deltaInfoSchema.optional(),
|
|
594
599
|
deltaCursor: deltaCursorSchema.optional(),
|
|
@@ -838,9 +843,17 @@ const getEnvironmentsResponseSchema = zod_v4.z.object({ environments: zod_v4.z.a
|
|
|
838
843
|
const getTagsArgsSchema = zod_v4.z.object({ entityType: entityTypeField.optional().describe("Optional entity type filter") }).describe("Arguments for getting tags");
|
|
839
844
|
const getTagsResponseSchema = zod_v4.z.object({ tags: zod_v4.z.array(zod_v4.z.string()).describe("Distinct tags") });
|
|
840
845
|
//#endregion
|
|
846
|
+
//#region src/server/schemas/feedback.ts
|
|
847
|
+
const listFeedbackResponseSchema = listFeedbackResponseSchema$1.extend({ feedback: zod_v4.z.array(feedbackRecordSchema.extend({ author: zod_v4.z.object({
|
|
848
|
+
id: zod_v4.z.string(),
|
|
849
|
+
name: zod_v4.z.string().optional(),
|
|
850
|
+
email: zod_v4.z.string().optional(),
|
|
851
|
+
avatarUrl: zod_v4.z.string().optional()
|
|
852
|
+
}).optional() })) });
|
|
853
|
+
//#endregion
|
|
841
854
|
//#region src/server/handlers/observability-new-endpoints.ts
|
|
842
855
|
function createNewRoute(def, config) {
|
|
843
|
-
const { handler, ...schemas } = config;
|
|
856
|
+
const { handler, preserveHttpExceptions, ...schemas } = config;
|
|
844
857
|
return require_route_builder.createRoute({
|
|
845
858
|
...def,
|
|
846
859
|
...schemas,
|
|
@@ -852,11 +865,143 @@ function createNewRoute(def, config) {
|
|
|
852
865
|
if (!_mastra_core_features.coreFeatures.has("observability:v1.13.2")) throw new require_http_exception.HTTPException(501, { message: "New observability endpoints require @mastra/core >= 1.13.2, please upgrade." });
|
|
853
866
|
return await handler(params);
|
|
854
867
|
} catch (error) {
|
|
868
|
+
if (preserveHttpExceptions && error instanceof require_http_exception.HTTPException) throw error;
|
|
855
869
|
return require_server_handlers_error.handleError(error, `Error calling: '${def.summary.toLocaleLowerCase()}'`);
|
|
856
870
|
}
|
|
857
871
|
})
|
|
858
872
|
});
|
|
859
873
|
}
|
|
874
|
+
const traceQueryMalformedBodyErrorSchema = zod_v4.z.object({
|
|
875
|
+
error: zod_v4.z.literal("Invalid request body"),
|
|
876
|
+
issues: zod_v4.z.array(zod_v4.z.object({
|
|
877
|
+
field: zod_v4.z.literal("body"),
|
|
878
|
+
message: zod_v4.z.string()
|
|
879
|
+
}).strict())
|
|
880
|
+
}).strict();
|
|
881
|
+
const traceQueryBodyTooLargeErrorSchema = zod_v4.z.object({ error: zod_v4.z.literal("Request body too large") }).strict();
|
|
882
|
+
const traceQueryMalformedCursorErrorSchema = zod_v4.z.object({
|
|
883
|
+
code: zod_v4.z.literal("TRACE_QUERY_CURSOR_MALFORMED"),
|
|
884
|
+
message: zod_v4.z.string()
|
|
885
|
+
}).strict();
|
|
886
|
+
const traceQueryCursorConflictErrorSchema = zod_v4.z.object({
|
|
887
|
+
code: zod_v4.z.literal("TRACE_QUERY_CURSOR_CONFLICT"),
|
|
888
|
+
message: zod_v4.z.string()
|
|
889
|
+
}).strict();
|
|
890
|
+
const traceQueryValidationIssueSchema = zod_v4.z.object({
|
|
891
|
+
code: zod_v4.z.string(),
|
|
892
|
+
path: zod_v4.z.array(zod_v4.z.union([zod_v4.z.string(), zod_v4.z.number()])),
|
|
893
|
+
message: zod_v4.z.string()
|
|
894
|
+
}).strict();
|
|
895
|
+
const traceQueryValidationResponseSchema = zod_v4.z.object({
|
|
896
|
+
code: zod_v4.z.literal("TRACE_QUERY_INVALID"),
|
|
897
|
+
message: zod_v4.z.string(),
|
|
898
|
+
issues: zod_v4.z.array(traceQueryValidationIssueSchema)
|
|
899
|
+
}).strict();
|
|
900
|
+
const traceQueryUnsupportedErrorSchema = zod_v4.z.object({
|
|
901
|
+
code: zod_v4.z.literal("TRACE_QUERY_UNSUPPORTED"),
|
|
902
|
+
message: zod_v4.z.string()
|
|
903
|
+
}).strict();
|
|
904
|
+
const traceQueryTimeoutErrorSchema = zod_v4.z.object({
|
|
905
|
+
code: zod_v4.z.literal("TRACE_QUERY_EXECUTION_TIMEOUT"),
|
|
906
|
+
message: zod_v4.z.string()
|
|
907
|
+
}).strict();
|
|
908
|
+
const traceQueryValidationError = (error) => ({
|
|
909
|
+
status: 422,
|
|
910
|
+
body: {
|
|
911
|
+
code: "TRACE_QUERY_INVALID",
|
|
912
|
+
message: "The trace query is invalid",
|
|
913
|
+
issues: error.issues.map((issue) => ({
|
|
914
|
+
code: "invalid_request",
|
|
915
|
+
path: issue.path.map((part) => typeof part === "symbol" ? String(part) : part),
|
|
916
|
+
message: issue.message
|
|
917
|
+
}))
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
function throwTraceQueryError(status, body) {
|
|
921
|
+
throw new require_http_exception.HTTPException(status, {
|
|
922
|
+
message: typeof body.message === "string" ? body.message : "Trace query failed",
|
|
923
|
+
res: new Response(JSON.stringify(body), {
|
|
924
|
+
status,
|
|
925
|
+
headers: { "content-type": "application/json" }
|
|
926
|
+
})
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
const QUERY_TRACES = createNewRoute(require_server_handlers_observability_shared.NEW_ROUTE_DEFS.QUERY_TRACES, {
|
|
930
|
+
bodySchema: _mastra_core_storage.traceQueryRequestSchema,
|
|
931
|
+
responseSchema: _mastra_core_storage.traceQueryResponseSchema,
|
|
932
|
+
onValidationError: traceQueryValidationError,
|
|
933
|
+
maxBodySize: 256 * 1024,
|
|
934
|
+
preserveHttpExceptions: true,
|
|
935
|
+
handler: async ({ mastra, timeRange, where, group, orderBy, page }) => {
|
|
936
|
+
let plan;
|
|
937
|
+
try {
|
|
938
|
+
plan = _mastra_core_storage.planTraceQuery({
|
|
939
|
+
timeRange,
|
|
940
|
+
where,
|
|
941
|
+
group,
|
|
942
|
+
orderBy,
|
|
943
|
+
page
|
|
944
|
+
});
|
|
945
|
+
} catch (error) {
|
|
946
|
+
if (error instanceof _mastra_core_storage.TraceQueryValidationError) throwTraceQueryError(422, {
|
|
947
|
+
code: error.code,
|
|
948
|
+
message: error.message,
|
|
949
|
+
issues: error.issues
|
|
950
|
+
});
|
|
951
|
+
if (error instanceof _mastra_core_storage.TraceQueryCursorError) throwTraceQueryError(error.code === "TRACE_QUERY_CURSOR_CONFLICT" ? 409 : 400, {
|
|
952
|
+
code: error.code,
|
|
953
|
+
message: error.message
|
|
954
|
+
});
|
|
955
|
+
throw error;
|
|
956
|
+
}
|
|
957
|
+
let observabilityStore;
|
|
958
|
+
try {
|
|
959
|
+
observabilityStore = await require_server_handlers_observability_shared.getObservabilityStore(mastra);
|
|
960
|
+
require_server_handlers_observability_shared.assertObservabilityTraceQuerySupported(observabilityStore);
|
|
961
|
+
} catch (error) {
|
|
962
|
+
if (error instanceof require_http_exception.HTTPException && error.status === 501) throwTraceQueryError(501, {
|
|
963
|
+
code: "TRACE_QUERY_UNSUPPORTED",
|
|
964
|
+
message: error.message
|
|
965
|
+
});
|
|
966
|
+
throw error;
|
|
967
|
+
}
|
|
968
|
+
try {
|
|
969
|
+
return await observabilityStore.queryTraces(plan);
|
|
970
|
+
} catch (error) {
|
|
971
|
+
if (error instanceof _mastra_core_storage.TraceQueryExecutionError) throwTraceQueryError(504, {
|
|
972
|
+
code: error.code,
|
|
973
|
+
message: error.message
|
|
974
|
+
});
|
|
975
|
+
throw error;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
});
|
|
979
|
+
if (QUERY_TRACES.openapi) {
|
|
980
|
+
QUERY_TRACES.openapi.responses[400] = {
|
|
981
|
+
description: "Malformed JSON or malformed cursor",
|
|
982
|
+
content: { "application/json": { schema: zod_v4.z.union([traceQueryMalformedBodyErrorSchema, traceQueryMalformedCursorErrorSchema]) } }
|
|
983
|
+
};
|
|
984
|
+
QUERY_TRACES.openapi.responses[409] = {
|
|
985
|
+
description: "Cursor does not match the normalized query",
|
|
986
|
+
content: { "application/json": { schema: traceQueryCursorConflictErrorSchema } }
|
|
987
|
+
};
|
|
988
|
+
QUERY_TRACES.openapi.responses[413] = {
|
|
989
|
+
description: "Request body exceeds 256 KiB",
|
|
990
|
+
content: { "application/json": { schema: traceQueryBodyTooLargeErrorSchema } }
|
|
991
|
+
};
|
|
992
|
+
QUERY_TRACES.openapi.responses[422] = {
|
|
993
|
+
description: "Structurally or semantically invalid trace query",
|
|
994
|
+
content: { "application/json": { schema: traceQueryValidationResponseSchema } }
|
|
995
|
+
};
|
|
996
|
+
QUERY_TRACES.openapi.responses[501] = {
|
|
997
|
+
description: "The configured observability store does not support trace queries",
|
|
998
|
+
content: { "application/json": { schema: traceQueryUnsupportedErrorSchema } }
|
|
999
|
+
};
|
|
1000
|
+
QUERY_TRACES.openapi.responses[504] = {
|
|
1001
|
+
description: "Trace query exceeded the configured database execution timeout",
|
|
1002
|
+
content: { "application/json": { schema: traceQueryTimeoutErrorSchema } }
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
860
1005
|
const LIST_LOGS = createNewRoute(require_server_handlers_observability_shared.NEW_ROUTE_DEFS.LIST_LOGS, {
|
|
861
1006
|
queryParamSchema: require_server_handlers_observability_shared.createObservabilityListQuerySchema(logsFilterSchema, logsOrderBySchema),
|
|
862
1007
|
responseSchema: listLogsResponseSchema,
|
|
@@ -969,21 +1114,18 @@ const GET_SCORE_PERCENTILES = createNewRoute(require_server_handlers_observabili
|
|
|
969
1114
|
const LIST_FEEDBACK = createNewRoute(require_server_handlers_observability_shared.NEW_ROUTE_DEFS.LIST_FEEDBACK, {
|
|
970
1115
|
queryParamSchema: require_server_handlers_observability_shared.createObservabilityListQuerySchema(feedbackFilterSchema, feedbackOrderBySchema),
|
|
971
1116
|
responseSchema: listFeedbackResponseSchema,
|
|
972
|
-
handler: async ({ mastra, mode, after, limit, ...params }) => {
|
|
1117
|
+
handler: async ({ mastra, requestContext, request, mode, after, limit, ...params }) => {
|
|
973
1118
|
const filters = require_route_builder.pickParams(feedbackFilterSchema, params);
|
|
974
1119
|
const observabilityStore = await require_server_handlers_observability_shared.getObservabilityStore(mastra);
|
|
975
|
-
if (mode === "delta")
|
|
976
|
-
require_server_handlers_observability_shared.assertObservabilityDeltaSupported(observabilityStore, require_server_handlers_observability_shared.OBSERVABILITY_LIST_ENDPOINTS.feedback);
|
|
977
|
-
return await observabilityStore.listFeedback({
|
|
978
|
-
mode,
|
|
979
|
-
filters,
|
|
980
|
-
after: typeof after === "string" ? after : void 0,
|
|
981
|
-
limit
|
|
982
|
-
});
|
|
983
|
-
}
|
|
1120
|
+
if (mode === "delta") require_server_handlers_observability_shared.assertObservabilityDeltaSupported(observabilityStore, require_server_handlers_observability_shared.OBSERVABILITY_LIST_ENDPOINTS.feedback);
|
|
984
1121
|
const pagination = require_route_builder.pickParams(require_server_handlers_observability_list_query_schemas.paginationArgsSchema, params);
|
|
985
1122
|
const orderBy = require_route_builder.pickParams(feedbackOrderBySchema, params);
|
|
986
|
-
|
|
1123
|
+
const result = await observabilityStore.listFeedback(mode === "delta" ? {
|
|
1124
|
+
mode,
|
|
1125
|
+
filters,
|
|
1126
|
+
after: typeof after === "string" ? after : void 0,
|
|
1127
|
+
limit
|
|
1128
|
+
} : mode === "page" ? {
|
|
987
1129
|
mode,
|
|
988
1130
|
filters,
|
|
989
1131
|
pagination,
|
|
@@ -993,14 +1135,28 @@ const LIST_FEEDBACK = createNewRoute(require_server_handlers_observability_share
|
|
|
993
1135
|
pagination,
|
|
994
1136
|
orderBy
|
|
995
1137
|
});
|
|
1138
|
+
const authors = await require_server_handlers_author_enrichment.prepareAuthorEnrichment(mastra, requestContext, result.feedback.map((record) => record.feedbackUserId), require_constants.isStudioClientTypeHeader(request?.headers.get("x-mastra-client-type") ?? void 0));
|
|
1139
|
+
return {
|
|
1140
|
+
...result,
|
|
1141
|
+
feedback: result.feedback.map((record) => {
|
|
1142
|
+
const author = record.feedbackUserId ? authors?.get(record.feedbackUserId) : void 0;
|
|
1143
|
+
return author ? {
|
|
1144
|
+
...record,
|
|
1145
|
+
author
|
|
1146
|
+
} : record;
|
|
1147
|
+
})
|
|
1148
|
+
};
|
|
996
1149
|
}
|
|
997
1150
|
});
|
|
998
1151
|
const CREATE_FEEDBACK = createNewRoute(require_server_handlers_observability_shared.NEW_ROUTE_DEFS.CREATE_FEEDBACK, {
|
|
999
1152
|
bodySchema: createFeedbackBodySchema,
|
|
1000
1153
|
responseSchema: createFeedbackResponseSchema,
|
|
1001
|
-
handler: async ({ mastra, feedback }) => {
|
|
1154
|
+
handler: async ({ mastra, requestContext, feedback }) => {
|
|
1155
|
+
const user = requestContext.get(require_constants.MASTRA_USER_KEY);
|
|
1156
|
+
const authenticatedId = user && typeof user === "object" && "id" in user ? user.id : void 0;
|
|
1002
1157
|
await (await require_server_handlers_observability_shared.getObservabilityStore(mastra)).createFeedback({ feedback: {
|
|
1003
1158
|
...feedback,
|
|
1159
|
+
...typeof authenticatedId === "string" && authenticatedId.trim().length > 0 ? { feedbackUserId: authenticatedId } : {},
|
|
1004
1160
|
feedbackId: feedback.feedbackId ?? (0, _mastra_core_observability.generateSignalId)(),
|
|
1005
1161
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1006
1162
|
reviewStatus: feedback.reviewStatus ?? "needs-review"
|
|
@@ -1177,6 +1333,7 @@ const GET_TAGS = createNewRoute(require_server_handlers_observability_shared.NEW
|
|
|
1177
1333
|
}
|
|
1178
1334
|
});
|
|
1179
1335
|
const NEW_ROUTES = {
|
|
1336
|
+
QUERY_TRACES,
|
|
1180
1337
|
LIST_LOGS,
|
|
1181
1338
|
LIST_SCORES,
|
|
1182
1339
|
CREATE_SCORE,
|
|
@@ -1375,6 +1532,12 @@ Object.defineProperty(exports, "NEW_ROUTES", {
|
|
|
1375
1532
|
return NEW_ROUTES;
|
|
1376
1533
|
}
|
|
1377
1534
|
});
|
|
1535
|
+
Object.defineProperty(exports, "QUERY_TRACES", {
|
|
1536
|
+
enumerable: true,
|
|
1537
|
+
get: function() {
|
|
1538
|
+
return QUERY_TRACES;
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1378
1541
|
Object.defineProperty(exports, "UPDATE_FEEDBACK_REVIEW_STATUS", {
|
|
1379
1542
|
enumerable: true,
|
|
1380
1543
|
get: function() {
|
|
@@ -1382,4 +1545,4 @@ Object.defineProperty(exports, "UPDATE_FEEDBACK_REVIEW_STATUS", {
|
|
|
1382
1545
|
}
|
|
1383
1546
|
});
|
|
1384
1547
|
|
|
1385
|
-
//# sourceMappingURL=observability-new-endpoints-
|
|
1548
|
+
//# sourceMappingURL=observability-new-endpoints-DF85EOQS.cjs.map
|