@mastra/server 1.69.0-alpha.4 → 1.70.0-alpha.0
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/{agents-BwKYvSyC.cjs → agents-CB7mDJp7.cjs} +2 -2
- package/dist/agents-CB7mDJp7.cjs.map +1 -0
- package/dist/{agents-bHwDNgU0.js → agents-DDX_EFXk.js} +2 -2
- package/dist/agents-DDX_EFXk.js.map +1 -0
- package/dist/{api-schema-manifest-Bh-4z7Op.cjs → api-schema-manifest-C8tCP7S9.cjs} +2 -2
- package/dist/{api-schema-manifest-Bh-4z7Op.cjs.map → api-schema-manifest-C8tCP7S9.cjs.map} +1 -1
- package/dist/{api-schema-manifest-CdFg0wYn.js → api-schema-manifest-FXO5uOve.js} +2 -2
- package/dist/{api-schema-manifest-CdFg0wYn.js.map → api-schema-manifest-FXO5uOve.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-observability-tracing-trace-query.md +14 -0
- package/dist/{editor-builder-BuURl04N.cjs → editor-builder-BQNg_3rZ.cjs} +2 -2
- package/dist/{editor-builder-BuURl04N.cjs.map → editor-builder-BQNg_3rZ.cjs.map} +1 -1
- package/dist/{editor-builder-BSczkr5E.js → editor-builder-D3-rOsbv.js} +2 -2
- package/dist/{editor-builder-BSczkr5E.js.map → editor-builder-D3-rOsbv.js.map} +1 -1
- package/dist/{editor-builder-PMRr8X4Q.js → editor-builder-DXxaAU_u.js} +2 -2
- package/dist/{editor-builder-PMRr8X4Q.js.map → editor-builder-DXxaAU_u.js.map} +1 -1
- package/dist/{editor-builder-BO3VMXPu.cjs → editor-builder-naBKxT2j.cjs} +2 -2
- package/dist/{editor-builder-BO3VMXPu.cjs.map → editor-builder-naBKxT2j.cjs.map} +1 -1
- package/dist/{observability-new-endpoints-19InA3-9.js → observability-new-endpoints-0hQR-aWF.js} +30 -9
- package/dist/observability-new-endpoints-0hQR-aWF.js.map +1 -0
- package/dist/{observability-new-endpoints-D-KKQfp0.cjs → observability-new-endpoints-BIoS0_PJ.cjs} +29 -8
- package/dist/observability-new-endpoints-BIoS0_PJ.cjs.map +1 -0
- package/dist/{routes-DbFemOQj.js → routes-Cp2GW67X.js} +4 -4
- package/dist/{routes-DbFemOQj.js.map → routes-Cp2GW67X.js.map} +1 -1
- package/dist/{routes-CsUaiwda.cjs → routes-D-JazyEo.cjs} +4 -4
- package/dist/{routes-CsUaiwda.cjs.map → routes-D-JazyEo.cjs.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +1 -1
- package/dist/server/handlers/agents.cjs.map +1 -1
- package/dist/server/handlers/agents.d.ts +5 -0
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/agents.js.map +1 -1
- package/dist/server/handlers/editor-builder.cjs +1 -1
- package/dist/server/handlers/editor-builder.js +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +1 -1
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +1 -1
- package/dist/server/handlers/mcp-client-versions.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +16 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +9 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +14 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +1 -1
- package/dist/server/handlers/prompt-block-versions.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +1 -1
- package/dist/server/handlers/scorer-versions.js +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
- package/dist/server/handlers/stored-agent-favorites.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +1 -1
- package/dist/server/handlers/stored-agents.js +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
- package/dist/server/handlers/stored-mcp-clients.js +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
- package/dist/server/handlers/stored-prompt-blocks.js +1 -1
- package/dist/server/handlers/stored-scorers.cjs +1 -1
- package/dist/server/handlers/stored-scorers.js +1 -1
- package/dist/server/handlers/stored-skill-favorites.cjs +2 -2
- package/dist/server/handlers/stored-skill-favorites.js +2 -2
- package/dist/server/handlers/stored-skills.cjs +2 -2
- package/dist/server/handlers/stored-skills.js +2 -2
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.d.ts +6 -0
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/schemas/agents.d.ts +5 -1
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +3 -3
- package/dist/server/schemas/index.js +3 -3
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/tools.d.ts +4 -0
- package/dist/server/server-adapter/routes/tools.d.ts.map +1 -1
- package/dist/{workflow-builder-DahN9vBL.cjs → workflow-builder-TC7EgW8A.cjs} +3 -3
- package/dist/{workflow-builder-DahN9vBL.cjs.map → workflow-builder-TC7EgW8A.cjs.map} +1 -1
- package/dist/{workflow-builder-49uw3EYL.js → workflow-builder-pbZ9S2Ue.js} +3 -3
- package/dist/{workflow-builder-49uw3EYL.js.map → workflow-builder-pbZ9S2Ue.js.map} +1 -1
- package/package.json +8 -8
- package/dist/agents-BwKYvSyC.cjs.map +0 -1
- package/dist/agents-bHwDNgU0.js.map +0 -1
- package/dist/observability-new-endpoints-19InA3-9.js.map +0 -1
- package/dist/observability-new-endpoints-D-KKQfp0.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as providerSchema } from "./agents-
|
|
1
|
+
import { k as providerSchema } from "./agents-DDX_EFXk.js";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
//#region src/server/schemas/editor-builder.ts
|
|
4
4
|
/**
|
|
@@ -191,4 +191,4 @@ const builderAvailableModelsResponseSchema = z.object({ providers: z.array(provi
|
|
|
191
191
|
//#endregion
|
|
192
192
|
export { builderModelPolicySchema as a, defaultModelEntrySchema as c, providerModelEntrySchema as d, builderAvailableModelsResponseSchema as i, infrastructureStatusResponseSchema as l, agentFeaturesSchema as n, builderPickerSchema as o, agentModelsSchema as r, builderSettingsResponseSchema as s, agentConfigurationSchema as t, pickerAllowlistSchema as u };
|
|
193
193
|
|
|
194
|
-
//# sourceMappingURL=editor-builder-
|
|
194
|
+
//# sourceMappingURL=editor-builder-DXxaAU_u.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-PMRr8X4Q.js","names":[],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,cAAc,EAAE,QAAQ,CAAC,CAAC,SAAS;CACnC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;CAM9B,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;AAC9B,CAAC;;;;;;;;;;AAaD,MAAM,2BAA2B,EAC9B,OAAO;CACN,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC1B,SAAS,EAAE,OAAO,CAAC,C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,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,WAAW,EAAE,OAAO;EAClB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;EAC5B,YAAY,EAAE,QAAQ;EACtB,eAAe,EAAE,QAAQ;EACzB,YAAY,EAAE,QAAQ;EACtB,oBAAoB,EAAE,OAAO,CAAC,CAAC,SAAS;EACxC,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;EACrC,QAAQ,EAAE,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,YAAY,EAAE,OAAO,EACnB,UAAU,EAAE,OAAO,EACjB,SAAS,EAAE,QAAQ,EACrB,CAAC,EACH,CAAC;AACH,CAAC;;;;;;;;;AAUD,MAAa,uCAAuC,EAAE,OAAO,EAC3D,WAAW,EAAE,MAAM,cAAc,EACnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"editor-builder-DXxaAU_u.js","names":[],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,cAAc,EAAE,QAAQ,CAAC,CAAC,SAAS;CACnC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;;;CAM9B,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;AAC9B,CAAC;;;;;;;;;;AAaD,MAAM,2BAA2B,EAC9B,OAAO;CACN,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC1B,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;AACtC,CAAC,CAAC,CACD,OAAO;AAEV,MAAM,4BAA4B,EAC/B,OAAO;CACN,MAAM,EAAE,QAAQ,QAAQ;CACxB,UAAU,EAA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CAAC,CAAC,SAAS;EAC1B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;EACjC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;EAC5B,YAAY,EAAE,QAAQ;EACtB,eAAe,EAAE,QAAQ;EACzB,YAAY,EAAE,QAAQ;EACtB,oBAAoB,EAAE,OAAO,CAAC,CAAC,SAAS;EACxC,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;EACrC,QAAQ,EAAE,MAAM,EAAE,OAAO;GAAE,KAAK,EAAE,OAAO;GAAG,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,YAAY,EAAE,OAAO,EACnB,UAAU,EAAE,OAAO,EACjB,SAAS,EAAE,QAAQ,EACrB,CAAC,EACH,CAAC;AACH,CAAC;;;;;;;;;AAUD,MAAa,uCAAuC,EAAE,OAAO,EAC3D,WAAW,EAAE,MAAM,cAAc,EACnC,CAAC"}
|
|
@@ -2,7 +2,7 @@ const require_http_exception = require("./http-exception-CKDHupKw.cjs");
|
|
|
2
2
|
const require_route_builder = require("./route-builder-2yrD15TL.cjs");
|
|
3
3
|
const require_server_handlers_error = require("./server/handlers/error.cjs");
|
|
4
4
|
const require_server_handlers_agents = require("./server/handlers/agents.cjs");
|
|
5
|
-
const require_editor_builder = require("./editor-builder-
|
|
5
|
+
const require_editor_builder = require("./editor-builder-BQNg_3rZ.cjs");
|
|
6
6
|
//#region src/server/utils/resolve-builder-model-policy.ts
|
|
7
7
|
/**
|
|
8
8
|
* Server-side wrapper around `builderToModelPolicy`.
|
|
@@ -363,4 +363,4 @@ Object.defineProperty(exports, "requireBuilderFeature", {
|
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
365
|
|
|
366
|
-
//# sourceMappingURL=editor-builder-
|
|
366
|
+
//# sourceMappingURL=editor-builder-naBKxT2j.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-builder-BO3VMXPu.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":";;;;;;;;;;;;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AAU;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-naBKxT2j.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,UAAU,OAAO;CAEtB,MAAM,SAASA,uBAAAA,oBAAoB,UAAU,QAAQ;CACrD,OAAO,OAAO,UAA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e,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"}
|
package/dist/{observability-new-endpoints-19InA3-9.js → observability-new-endpoints-0hQR-aWF.js}
RENAMED
|
@@ -3,7 +3,7 @@ import { a as wrapSchemaForQueryParams, i as pickParams, n as createRoute } from
|
|
|
3
3
|
import { d as MASTRA_USER_ROLES_KEY, l as MASTRA_USER_KEY, m as isStudioClientTypeHeader } from "./constants-0jFCWoex.js";
|
|
4
4
|
import { handleError } from "./server/handlers/error.js";
|
|
5
5
|
import { paginationArgsSchema as paginationArgsSchema$1 } from "./server/handlers/observability-list-query-schemas.js";
|
|
6
|
-
import { NEW_ROUTE_DEFS, OBSERVABILITY_LIST_ENDPOINTS, assertObservabilityDeltaSupported, assertObservabilityThreadQuerySupported, assertObservabilityTraceQueryDiscoverySupported, assertObservabilityTraceQuerySupported, createObservabilityListQuerySchema, getObservabilityStore, supportsTraceQueryDiscoveryCore } from "./server/handlers/observability-shared.js";
|
|
6
|
+
import { NEW_ROUTE_DEFS, OBSERVABILITY_LIST_ENDPOINTS, OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE, assertObservabilityDeltaSupported, assertObservabilityThreadQuerySupported, assertObservabilityTraceQueryDiscoverySupported, assertObservabilityTraceQuerySupported, assertObservabilityTraceQueryTenantScopeSupported, createObservabilityListQuerySchema, getObservabilityStore, supportsTraceQueryDiscoveryCore } from "./server/handlers/observability-shared.js";
|
|
7
7
|
import { prepareAuthorEnrichment } from "./server/handlers/author-enrichment.js";
|
|
8
8
|
import { getCallerPermissions } from "./server/handlers/authorship.js";
|
|
9
9
|
import { z } from "zod/v4";
|
|
@@ -960,6 +960,20 @@ const throwTraceQueryDiscoveryCoreUnsupported = () => throwTraceQueryError(501,
|
|
|
960
960
|
code: "TRACE_QUERY_DISCOVERY_UNSUPPORTED",
|
|
961
961
|
message: "Trace query discovery requires a newer @mastra/core. Please upgrade."
|
|
962
962
|
});
|
|
963
|
+
/**
|
|
964
|
+
* Trusted tenant scope for trace queries. `organizationId` is a reserved request-context
|
|
965
|
+
* key that only server-side auth may establish (see `isReservedRequestContextKey`), so a
|
|
966
|
+
* caller can't widen it through the request body. Absent key means self-hosted: no scope.
|
|
967
|
+
*/
|
|
968
|
+
function resolveTraceQueryScope(requestContext, unsupportedCode = "TRACE_QUERY_UNSUPPORTED") {
|
|
969
|
+
const organizationId = requestContext.get("organizationId");
|
|
970
|
+
if (typeof organizationId !== "string" || organizationId.length === 0) return void 0;
|
|
971
|
+
if (!coreFeatures.has("observability-trace-query-tenant-scope")) throwTraceQueryError(501, {
|
|
972
|
+
code: unsupportedCode,
|
|
973
|
+
message: OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE
|
|
974
|
+
});
|
|
975
|
+
return { organizationId };
|
|
976
|
+
}
|
|
963
977
|
const QUERY_TRACES = createNewRoute(NEW_ROUTE_DEFS.QUERY_TRACES, {
|
|
964
978
|
bodySchema: coreStorage.traceQueryRequestSchema,
|
|
965
979
|
responseSchema: coreStorage.traceQueryResponseSchema,
|
|
@@ -990,7 +1004,10 @@ const QUERY_TRACES = createNewRoute(NEW_ROUTE_DEFS.QUERY_TRACES, {
|
|
|
990
1004
|
mode,
|
|
991
1005
|
after,
|
|
992
1006
|
limit
|
|
993
|
-
}, {
|
|
1007
|
+
}, {
|
|
1008
|
+
authorizationBinding,
|
|
1009
|
+
scope: resolveTraceQueryScope(requestContext)
|
|
1010
|
+
});
|
|
994
1011
|
} catch (error) {
|
|
995
1012
|
if (error instanceof coreStorage.TraceQueryValidationError) throwTraceQueryError(422, {
|
|
996
1013
|
code: error.code,
|
|
@@ -1007,6 +1024,7 @@ const QUERY_TRACES = createNewRoute(NEW_ROUTE_DEFS.QUERY_TRACES, {
|
|
|
1007
1024
|
try {
|
|
1008
1025
|
observabilityStore = await getObservabilityStore(mastra);
|
|
1009
1026
|
assertObservabilityTraceQuerySupported(observabilityStore);
|
|
1027
|
+
assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
|
|
1010
1028
|
if (plan.paginationMode === "delta" && !observabilityStore.getFeatures()?.includes("delta-polling")) throw new HTTPException(501, { message: "This storage provider does not support observability delta polling" });
|
|
1011
1029
|
} catch (error) {
|
|
1012
1030
|
if (error instanceof HTTPException && error.status === 501) throwTraceQueryError(501, {
|
|
@@ -1064,18 +1082,19 @@ const GET_TRACE_QUERY_FIELDS = createNewRoute(NEW_ROUTE_DEFS.GET_TRACE_QUERY_FIE
|
|
|
1064
1082
|
preserveHttpExceptions: true,
|
|
1065
1083
|
isCoreSupported: supportsTraceQueryDiscoveryCore,
|
|
1066
1084
|
onUnsupportedCore: throwTraceQueryDiscoveryCoreUnsupported,
|
|
1067
|
-
handler: async ({ mastra, timeRange, predicateScope, search, limit }) => {
|
|
1085
|
+
handler: async ({ mastra, requestContext, timeRange, predicateScope, search, limit }) => {
|
|
1068
1086
|
const args = {
|
|
1069
1087
|
timeRange,
|
|
1070
1088
|
predicateScope,
|
|
1071
1089
|
search,
|
|
1072
1090
|
limit
|
|
1073
1091
|
};
|
|
1074
|
-
const plan = coreStorage.planTraceQueryObservedFields(args);
|
|
1092
|
+
const plan = coreStorage.planTraceQueryObservedFields(args, { scope: resolveTraceQueryScope(requestContext, "TRACE_QUERY_DISCOVERY_UNSUPPORTED") });
|
|
1075
1093
|
let observabilityStore;
|
|
1076
1094
|
try {
|
|
1077
1095
|
observabilityStore = await getObservabilityStore(mastra);
|
|
1078
1096
|
assertObservabilityTraceQueryDiscoverySupported(observabilityStore);
|
|
1097
|
+
assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
|
|
1079
1098
|
} catch (error) {
|
|
1080
1099
|
if (error instanceof HTTPException && error.status === 501) throwTraceQueryError(501, {
|
|
1081
1100
|
code: "TRACE_QUERY_DISCOVERY_UNSUPPORTED",
|
|
@@ -1110,18 +1129,19 @@ const GET_TRACE_QUERY_VALUES = createNewRoute(NEW_ROUTE_DEFS.GET_TRACE_QUERY_VAL
|
|
|
1110
1129
|
preserveHttpExceptions: true,
|
|
1111
1130
|
isCoreSupported: supportsTraceQueryDiscoveryCore,
|
|
1112
1131
|
onUnsupportedCore: throwTraceQueryDiscoveryCoreUnsupported,
|
|
1113
|
-
handler: async ({ mastra, timeRange, predicateScope, path, search, limit }) => {
|
|
1132
|
+
handler: async ({ mastra, requestContext, timeRange, predicateScope, path, search, limit }) => {
|
|
1114
1133
|
const plan = coreStorage.planTraceQueryValues({
|
|
1115
1134
|
timeRange,
|
|
1116
1135
|
predicateScope,
|
|
1117
1136
|
path,
|
|
1118
1137
|
search,
|
|
1119
1138
|
limit
|
|
1120
|
-
});
|
|
1139
|
+
}, { scope: resolveTraceQueryScope(requestContext, "TRACE_QUERY_DISCOVERY_UNSUPPORTED") });
|
|
1121
1140
|
let observabilityStore;
|
|
1122
1141
|
try {
|
|
1123
1142
|
observabilityStore = await getObservabilityStore(mastra);
|
|
1124
1143
|
assertObservabilityTraceQueryDiscoverySupported(observabilityStore);
|
|
1144
|
+
assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
|
|
1125
1145
|
} catch (error) {
|
|
1126
1146
|
if (error instanceof HTTPException && error.status === 501) throwTraceQueryError(501, {
|
|
1127
1147
|
code: "TRACE_QUERY_DISCOVERY_UNSUPPORTED",
|
|
@@ -1177,14 +1197,14 @@ const QUERY_THREADS = createNewRoute(NEW_ROUTE_DEFS.QUERY_THREADS, {
|
|
|
1177
1197
|
code: "TRACE_QUERY_UNSUPPORTED",
|
|
1178
1198
|
message: "Thread queries require a newer @mastra/core with observability thread-query support. Please upgrade."
|
|
1179
1199
|
}),
|
|
1180
|
-
handler: async ({ mastra, traces, where, page }) => {
|
|
1200
|
+
handler: async ({ mastra, requestContext, traces, where, page }) => {
|
|
1181
1201
|
let plan;
|
|
1182
1202
|
try {
|
|
1183
1203
|
plan = coreStorage.planThreadQuery({
|
|
1184
1204
|
traces,
|
|
1185
1205
|
where,
|
|
1186
1206
|
page
|
|
1187
|
-
});
|
|
1207
|
+
}, { scope: resolveTraceQueryScope(requestContext) });
|
|
1188
1208
|
} catch (error) {
|
|
1189
1209
|
if (error instanceof coreStorage.TraceQueryValidationError) throwTraceQueryError(422, {
|
|
1190
1210
|
code: error.code,
|
|
@@ -1201,6 +1221,7 @@ const QUERY_THREADS = createNewRoute(NEW_ROUTE_DEFS.QUERY_THREADS, {
|
|
|
1201
1221
|
try {
|
|
1202
1222
|
observabilityStore = await getObservabilityStore(mastra);
|
|
1203
1223
|
assertObservabilityThreadQuerySupported(observabilityStore);
|
|
1224
|
+
assertObservabilityTraceQueryTenantScopeSupported(observabilityStore, plan.scope);
|
|
1204
1225
|
} catch (error) {
|
|
1205
1226
|
if (error instanceof HTTPException && error.status === 501) throwTraceQueryError(501, {
|
|
1206
1227
|
code: "TRACE_QUERY_UNSUPPORTED",
|
|
@@ -1632,4 +1653,4 @@ const NEW_ROUTES = {
|
|
|
1632
1653
|
//#endregion
|
|
1633
1654
|
export { LIST_METRICS as A, GET_SCORE_TIME_SERIES as C, GET_TRACE_QUERY_VALUES as D, GET_TRACE_QUERY_FIELDS as E, UPDATE_FEEDBACK_REVIEW_STATUS as F, NEW_ROUTES as M, QUERY_THREADS as N, LIST_FEEDBACK as O, QUERY_TRACES as P, GET_SCORE_PERCENTILES as S, GET_TAGS as T, GET_METRIC_PERCENTILES as _, GET_ENTITY_NAMES as a, GET_SCORE_AGGREGATE as b, GET_FEEDBACK_AGGREGATE as c, GET_FEEDBACK_TIME_SERIES as d, GET_METRIC_AGGREGATE as f, GET_METRIC_NAMES as g, GET_METRIC_LABEL_VALUES as h, DELETE_SCORES as i, LIST_SCORES as j, LIST_LOGS as k, GET_FEEDBACK_BREAKDOWN as l, GET_METRIC_LABEL_KEYS as m, CREATE_SCORE as n, GET_ENTITY_TYPES as o, GET_METRIC_BREAKDOWN as p, DELETE_FEEDBACK as r, GET_ENVIRONMENTS as s, CREATE_FEEDBACK as t, GET_FEEDBACK_PERCENTILES as u, GET_METRIC_TIME_SERIES as v, GET_SERVICE_NAMES as w, GET_SCORE_BREAKDOWN as x, GET_SCORE as y };
|
|
1634
1655
|
|
|
1635
|
-
//# sourceMappingURL=observability-new-endpoints-
|
|
1656
|
+
//# sourceMappingURL=observability-new-endpoints-0hQR-aWF.js.map
|