@mastra/server 1.54.0 → 1.55.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/{a2a-BuHK-WlT.js → a2a-BPgUo8V4.js} +2 -2
  3. package/dist/a2a-BPgUo8V4.js.map +1 -0
  4. package/dist/{a2a-BpnLfSs-.cjs → a2a-CSvyekNE.cjs} +2 -2
  5. package/dist/a2a-CSvyekNE.cjs.map +1 -0
  6. package/dist/{agent-versions-DVHeWTEC.js → agent-versions-DC1Rp5EP.js} +2 -2
  7. package/dist/{agent-versions-DVHeWTEC.js.map → agent-versions-DC1Rp5EP.js.map} +1 -1
  8. package/dist/{agent-versions-CeW6txxf.cjs → agent-versions-DhkWMz0z.cjs} +2 -2
  9. package/dist/{agent-versions-CeW6txxf.cjs.map → agent-versions-DhkWMz0z.cjs.map} +1 -1
  10. package/dist/{agents-DtRakHQJ.cjs → agents-B9ofSVSn.cjs} +5 -5
  11. package/dist/agents-B9ofSVSn.cjs.map +1 -0
  12. package/dist/{agents-blOvvut1.js → agents-DD4PJgsF.js} +5 -5
  13. package/dist/agents-DD4PJgsF.js.map +1 -0
  14. package/dist/{api-schema-manifest-CgAqXSXH.cjs → api-schema-manifest-DdFxt0Xu.cjs} +2 -2
  15. package/dist/{api-schema-manifest-CgAqXSXH.cjs.map → api-schema-manifest-DdFxt0Xu.cjs.map} +1 -1
  16. package/dist/{api-schema-manifest-CQE7b1pm.js → api-schema-manifest-Tf3jW9LW.js} +2 -2
  17. package/dist/{api-schema-manifest-CQE7b1pm.js.map → api-schema-manifest-Tf3jW9LW.js.map} +1 -1
  18. package/dist/docs/SKILL.md +1 -1
  19. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  20. package/dist/docs/references/docs-agents-a2a.md +4 -2
  21. package/dist/docs/references/docs-server-custom-adapters.md +4 -4
  22. package/dist/docs/references/docs-server-middleware.md +1 -1
  23. package/dist/docs/references/reference-server-routes.md +7 -7
  24. package/dist/{editor-builder-CcPPiRKU.js → editor-builder-B_8M84Hb.js} +2 -2
  25. package/dist/{editor-builder-CcPPiRKU.js.map → editor-builder-B_8M84Hb.js.map} +1 -1
  26. package/dist/{editor-builder-BZlMvxNh.cjs → editor-builder-CGMd1H1a.cjs} +2 -2
  27. package/dist/{editor-builder-BZlMvxNh.cjs.map → editor-builder-CGMd1H1a.cjs.map} +1 -1
  28. package/dist/{editor-builder-Crs4928Q.cjs → editor-builder-DZRQf2UD.cjs} +2 -2
  29. package/dist/{editor-builder-Crs4928Q.cjs.map → editor-builder-DZRQf2UD.cjs.map} +1 -1
  30. package/dist/{editor-builder-B_YHUbi1.js → editor-builder-XFcH8gX0.js} +2 -2
  31. package/dist/{editor-builder-B_YHUbi1.js.map → editor-builder-XFcH8gX0.js.map} +1 -1
  32. package/dist/{routes-Bg2dyDbR.js → routes-DNk47bnI.js} +3 -3
  33. package/dist/{routes-Bg2dyDbR.js.map → routes-DNk47bnI.js.map} +1 -1
  34. package/dist/{routes-Dw1j4HlK.cjs → routes-I_yOSmz-.cjs} +3 -3
  35. package/dist/{routes-Dw1j4HlK.cjs.map → routes-I_yOSmz-.cjs.map} +1 -1
  36. package/dist/{scorer-versions-CcgXOO9h.js → scorer-versions-BoAERQxp.js} +2 -2
  37. package/dist/{scorer-versions-CcgXOO9h.js.map → scorer-versions-BoAERQxp.js.map} +1 -1
  38. package/dist/{scorer-versions-BaxgEGNa.cjs → scorer-versions-DX81YG5X.cjs} +2 -2
  39. package/dist/{scorer-versions-BaxgEGNa.cjs.map → scorer-versions-DX81YG5X.cjs.map} +1 -1
  40. package/dist/server/handlers/a2a.cjs +1 -1
  41. package/dist/server/handlers/a2a.js +1 -1
  42. package/dist/server/handlers/agent-builder.cjs +1 -1
  43. package/dist/server/handlers/agent-builder.js +1 -1
  44. package/dist/server/handlers/agent-versions.cjs +1 -1
  45. package/dist/server/handlers/agent-versions.js +1 -1
  46. package/dist/server/handlers/agents.cjs +7 -7
  47. package/dist/server/handlers/agents.cjs.map +1 -1
  48. package/dist/server/handlers/agents.d.ts +1 -1
  49. package/dist/server/handlers/agents.d.ts.map +1 -1
  50. package/dist/server/handlers/agents.js +7 -7
  51. package/dist/server/handlers/agents.js.map +1 -1
  52. package/dist/server/handlers/editor-builder.cjs +1 -1
  53. package/dist/server/handlers/editor-builder.js +1 -1
  54. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  55. package/dist/server/handlers/favorites-enrichment.js +1 -1
  56. package/dist/server/handlers/scorer-versions.cjs +1 -1
  57. package/dist/server/handlers/scorer-versions.js +1 -1
  58. package/dist/server/handlers/stored-agent-favorites.cjs +2 -2
  59. package/dist/server/handlers/stored-agent-favorites.js +2 -2
  60. package/dist/server/handlers/stored-agents.cjs +10 -11
  61. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  62. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  63. package/dist/server/handlers/stored-agents.js +10 -11
  64. package/dist/server/handlers/stored-agents.js.map +1 -1
  65. package/dist/server/handlers/stored-scorers.cjs +1 -1
  66. package/dist/server/handlers/stored-scorers.js +1 -1
  67. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  68. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  69. package/dist/server/handlers/stored-skills.cjs +1 -1
  70. package/dist/server/handlers/stored-skills.js +1 -1
  71. package/dist/server/handlers/system.cjs +1 -1
  72. package/dist/server/handlers/system.js +1 -1
  73. package/dist/server/handlers/tools.cjs +1 -1
  74. package/dist/server/handlers/tools.js +1 -1
  75. package/dist/server/handlers/workflows.cjs +1 -1
  76. package/dist/server/handlers/workflows.js +1 -1
  77. package/dist/server/handlers.cjs +1 -1
  78. package/dist/server/handlers.js +1 -1
  79. package/dist/server/schemas/agents.d.ts +2 -2
  80. package/dist/server/schemas/agents.d.ts.map +1 -1
  81. package/dist/server/schemas/index.cjs +6 -6
  82. package/dist/server/schemas/index.js +6 -6
  83. package/dist/server/schemas/stored-agents.d.ts +1 -0
  84. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  85. package/dist/server/server-adapter/index.cjs +1 -1
  86. package/dist/server/server-adapter/index.js +1 -1
  87. package/dist/{stored-agents-D3ZWjjQo.cjs → stored-agents-DR_L2wPJ.cjs} +3 -2
  88. package/dist/stored-agents-DR_L2wPJ.cjs.map +1 -0
  89. package/dist/{stored-agents-DGXL9L5P.js → stored-agents-GBSl2bkv.js} +3 -2
  90. package/dist/stored-agents-GBSl2bkv.js.map +1 -0
  91. package/dist/{stored-scorers-n2NdbB_a.js → stored-scorers-0eeoiKkg.js} +2 -2
  92. package/dist/{stored-scorers-n2NdbB_a.js.map → stored-scorers-0eeoiKkg.js.map} +1 -1
  93. package/dist/{stored-scorers-C4vBDgJi.cjs → stored-scorers-CMHNFquG.cjs} +2 -2
  94. package/dist/{stored-scorers-C4vBDgJi.cjs.map → stored-scorers-CMHNFquG.cjs.map} +1 -1
  95. package/package.json +6 -6
  96. package/dist/a2a-BpnLfSs-.cjs.map +0 -1
  97. package/dist/a2a-BuHK-WlT.js.map +0 -1
  98. package/dist/agents-DtRakHQJ.cjs.map +0 -1
  99. package/dist/agents-blOvvut1.js.map +0 -1
  100. package/dist/stored-agents-D3ZWjjQo.cjs.map +0 -1
  101. package/dist/stored-agents-DGXL9L5P.js.map +0 -1
@@ -3,11 +3,11 @@ import { u as statusQuerySchema } from "../../common-CPNOpqxA.js";
3
3
  import { n as createRoute } from "../../route-builder-D04LGdMT.js";
4
4
  import { c as toSlug, i as getStoredResourceScope, n as assertStoredResourceScope, s as scopeStoredResourceMetadata } from "../../utils-WZw3YUlC.js";
5
5
  import { handleError } from "./error.js";
6
- import { C as storedAgentIdPathParams, O as updateStoredAgentBodySchema, a as exportStoredAgentBodySchema, c as getStoredAgentResponseSchema, d as listStoredAgentsResponseSchema, g as previewInstructionsResponseSchema, h as previewInstructionsBodySchema, i as deleteStoredAgentResponseSchema, k as updateStoredAgentResponseSchema, m as openStoredAgentChangeRequestResponseSchema, n as createStoredAgentBodySchema, o as exportStoredAgentResponseSchema, p as openStoredAgentChangeRequestBodySchema, r as createStoredAgentResponseSchema, s as getStoredAgentDependentsResponseSchema, u as listStoredAgentsQuerySchema } from "../../stored-agents-DGXL9L5P.js";
6
+ import { C as storedAgentIdPathParams, O as updateStoredAgentBodySchema, a as exportStoredAgentBodySchema, c as getStoredAgentResponseSchema, d as listStoredAgentsResponseSchema, g as previewInstructionsResponseSchema, h as previewInstructionsBodySchema, i as deleteStoredAgentResponseSchema, k as updateStoredAgentResponseSchema, m as openStoredAgentChangeRequestResponseSchema, n as createStoredAgentBodySchema, o as exportStoredAgentResponseSchema, p as openStoredAgentChangeRequestBodySchema, r as createStoredAgentResponseSchema, s as getStoredAgentDependentsResponseSchema, u as listStoredAgentsQuerySchema } from "../../stored-agents-GBSl2bkv.js";
7
7
  import { handleAutoVersioning } from "./version-helpers.js";
8
8
  import { attachAuthor, prepareAuthorEnrichment } from "./author-enrichment.js";
9
9
  import { assertReadAccess, assertWriteAccess, getCallerAuthorId, matchesAuthorFilter, resolveAuthorFilter } from "./authorship.js";
10
- import { i as isBuilderFeatureEnabled } from "../../editor-builder-CcPPiRKU.js";
10
+ import { i as isBuilderFeatureEnabled } from "../../editor-builder-B_8M84Hb.js";
11
11
  import { enrichOrStripFavorites, prepareFavoritesEnrichment, stripFavoriteFields } from "./favorites-enrichment.js";
12
12
  import { validateMetadataAvatarUrl } from "./validate-avatar.js";
13
13
  //#region src/server/handlers/stored-agents.ts
@@ -391,7 +391,7 @@ const CREATE_STORED_AGENT_ROUTE = createRoute({
391
391
  description: "Creates a new agent in storage with the provided configuration",
392
392
  tags: ["Stored Agents"],
393
393
  requiresAuth: true,
394
- handler: async ({ mastra, requestContext, id: providedId, metadata, visibility: bodyVisibility, name, description, instructions, model, tools, defaultOptions, workflows, agents, integrationTools, toolProviders, mcpClients, inputProcessors, outputProcessors, memory, scorers, skills, workspace, browser, requestContextSchema }) => {
394
+ handler: async ({ mastra, requestContext, id: providedId, metadata, visibility: bodyVisibility, autoPublish, name, description, instructions, model, tools, defaultOptions, workflows, agents, integrationTools, toolProviders, mcpClients, inputProcessors, outputProcessors, memory, scorers, skills, workspace, browser, requestContextSchema }) => {
395
395
  try {
396
396
  const storage = mastra.getStorage();
397
397
  if (!storage) throw new HTTPException(500, { message: "Storage is not configured" });
@@ -452,19 +452,18 @@ const CREATE_STORED_AGENT_ROUTE = createRoute({
452
452
  const editor = mastra.getEditor?.();
453
453
  if (editor) await editor.agent.create(input);
454
454
  else await agentsStore.create({ agent: input });
455
+ const isCodeSourceEditor = editor?.getSource?.() === "code";
455
456
  const { versions } = await agentsStore.listVersions({
456
457
  agentId: id,
457
458
  perPage: 1
458
459
  });
459
460
  const initialVersion = versions[0];
460
- if (initialVersion) {
461
- await agentsStore.update({
462
- id,
463
- activeVersionId: initialVersion.id,
464
- status: "published"
465
- });
466
- editor?.agent.clearCache(id);
467
- }
461
+ if (initialVersion && (autoPublish !== false || isCodeSourceEditor)) await agentsStore.update({
462
+ id,
463
+ activeVersionId: initialVersion.id,
464
+ status: "published"
465
+ });
466
+ editor?.agent.clearCache(id);
468
467
  const resolved = await agentsStore.getByIdResolved(id, { status: "published" });
469
468
  if (!resolved) throw new HTTPException(500, { message: "Failed to resolve created agent" });
470
469
  return enrichOrStripFavorites(mastra, requestContext, "agent", resolved);
@@ -1 +1 @@
1
- {"version":3,"file":"stored-agents.js","names":[],"sources":["../../../src/server/handlers/stored-agents.ts"],"sourcesContent":["import type { StorageCreateAgentInput, StorageUpdateAgentInput } from '@mastra/core/storage';\nimport type { z } from 'zod/v4';\n\nimport { HTTPException } from '../http-exception';\nimport {\n storedAgentIdPathParams,\n statusQuerySchema,\n listStoredAgentsQuerySchema,\n createStoredAgentBodySchema,\n updateStoredAgentBodySchema,\n listStoredAgentsResponseSchema,\n getStoredAgentResponseSchema,\n createStoredAgentResponseSchema,\n updateStoredAgentResponseSchema,\n deleteStoredAgentResponseSchema,\n getStoredAgentDependentsResponseSchema,\n exportStoredAgentBodySchema,\n openStoredAgentChangeRequestBodySchema,\n exportStoredAgentResponseSchema,\n openStoredAgentChangeRequestResponseSchema,\n previewInstructionsBodySchema,\n previewInstructionsResponseSchema,\n} from '../schemas/stored-agents';\nimport type { ServerRoute, RouteSchemas, InferParams } from '../server-adapter/routes';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { assertStoredResourceScope, getStoredResourceScope, scopeStoredResourceMetadata, toSlug } from '../utils';\n\nimport { attachAuthor, prepareAuthorEnrichment } from './author-enrichment';\nimport {\n assertReadAccess,\n assertWriteAccess,\n getCallerAuthorId,\n matchesAuthorFilter,\n resolveAuthorFilter,\n} from './authorship';\nimport { isBuilderFeatureEnabled } from './editor-builder';\nimport { handleError } from './error';\nimport { enrichOrStripFavorites, prepareFavoritesEnrichment, stripFavoriteFields } from './favorites-enrichment';\nimport { validateMetadataAvatarUrl } from './validate-avatar';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\n/**\n * Resolve a `browser` field that may be a boolean shorthand from the UI.\n * - `true` → look up the admin's builder default browser config\n * - `false` → `null` (explicit clear)\n * - object/null/undefined → pass through unchanged\n */\nasync function resolveBrowserField(browser: unknown, mastra: { getEditor?: () => unknown }): Promise<unknown> {\n if (browser === true) {\n const editor = mastra.getEditor?.() as any;\n const builder = await editor?.resolveBuilder?.();\n const defaultBrowser = builder?.getConfiguration?.()?.agent?.browser;\n if (!defaultBrowser) {\n console.warn(\n '[mastra:server] Browser enabled (browser: true) but no default browser config found ' +\n 'in builder configuration. The agent will be created/updated without browser access. ' +\n 'Set `editor.builder.configuration.agent.browser` to fix this.',\n );\n }\n return defaultBrowser ?? undefined;\n }\n if (browser === false) {\n return null;\n }\n return browser;\n}\n\nconst AGENT_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'instructions',\n 'model',\n 'tools',\n 'defaultOptions',\n 'workflows',\n 'agents',\n 'integrationTools',\n 'toolProviders',\n 'inputProcessors',\n 'outputProcessors',\n 'memory',\n 'scorers',\n 'requestContextSchema',\n 'mcpClients',\n 'skills',\n 'workspace',\n 'browser',\n] as const;\n\nconst CODE_AGENT_OVERRIDE_FIELDS = [\n 'instructions',\n 'tools',\n 'integrationTools',\n 'mcpClients',\n 'requestContextSchema',\n] as const;\n\n/**\n * Derive ownership flags from a code agent's editor config.\n * Mirrors the semantics of `editor.agent.applyStoredOverrides` so that\n * client save payloads, persisted snapshots, and export output all agree\n * on which fields Studio is allowed to own.\n */\nfunction getCodeAgentOwnership(editorConfig: unknown): {\n ownsInstructions: boolean;\n ownsTools: boolean;\n ownsToolDescriptionsOnly: boolean;\n} {\n if (editorConfig === false) {\n return { ownsInstructions: false, ownsTools: false, ownsToolDescriptionsOnly: false };\n }\n if (editorConfig === undefined || editorConfig === null) {\n // Legacy default: code agents without explicit editor config behave as fully editable.\n return { ownsInstructions: true, ownsTools: true, ownsToolDescriptionsOnly: false };\n }\n if (typeof editorConfig !== 'object') {\n return { ownsInstructions: false, ownsTools: false, ownsToolDescriptionsOnly: false };\n }\n const cfg = editorConfig as { instructions?: unknown; tools?: unknown };\n const ownsInstructions = cfg.instructions === true;\n const toolsCfg = cfg.tools;\n const ownsTools = toolsCfg === true;\n const ownsToolDescriptionsOnly =\n typeof toolsCfg === 'object' && toolsCfg !== null && (toolsCfg as { description?: unknown }).description === true;\n return { ownsInstructions, ownsTools, ownsToolDescriptionsOnly };\n}\n\nfunction hasNonEmptyInstructions(value: unknown): boolean {\n if (typeof value === 'string') {\n return value.trim().length > 0;\n }\n\n if (!Array.isArray(value)) {\n return false;\n }\n\n return value.some(block => {\n if (!block || typeof block !== 'object') {\n return false;\n }\n\n const typedBlock = block as { type?: unknown; id?: unknown; content?: unknown };\n if (typedBlock.type === 'prompt_block_ref') {\n return typeof typedBlock.id === 'string' && typedBlock.id.length > 0;\n }\n\n return typeof typedBlock.content === 'string' && typedBlock.content.trim().length > 0;\n });\n}\n\nfunction assertOwnedInstructionsNotEmpty(instructions: unknown) {\n if (!hasNonEmptyInstructions(instructions)) {\n throw new HTTPException(400, { message: 'Instructions are required' });\n }\n}\n\nfunction sortForStableJson(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortForStableJson);\n }\n\n if (value && typeof value === 'object' && !(value instanceof Date)) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, entry]) => entry !== undefined)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => [key, sortForStableJson(entry)]),\n );\n }\n\n return value;\n}\n\nfunction buildExportConfig(\n input: Record<string, unknown>,\n agent?: { __getEditorConfig?: () => unknown; source?: string },\n) {\n const editorConfig = agent?.__getEditorConfig?.();\n const isCodeAgent = agent?.source === 'code';\n const allowedFields = isCodeAgent ? CODE_AGENT_OVERRIDE_FIELDS : AGENT_SNAPSHOT_CONFIG_FIELDS;\n const ownership = isCodeAgent ? getCodeAgentOwnership(editorConfig) : null;\n const config: Record<string, unknown> = {};\n\n for (const field of allowedFields) {\n if (input[field] === undefined) continue;\n if (ownership) {\n if (field === 'instructions' && !ownership.ownsInstructions) continue;\n if (\n (field === 'tools' || field === 'integrationTools' || field === 'mcpClients') &&\n !ownership.ownsTools &&\n !ownership.ownsToolDescriptionsOnly\n ) {\n continue;\n }\n }\n config[field] = input[field];\n }\n\n return sortForStableJson(config) as Record<string, unknown>;\n}\n\nfunction agentExportFilename(agentId: string) {\n return `agents/${encodeURIComponent(agentId)}.json`;\n}\n\nfunction sourceChangeRequestHeadRef(agentId: string) {\n const safeAgentId = agentId.replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'agent';\n return `mastra/${safeAgentId}`;\n}\n\nfunction sourceChangeRequestMessage(agentId: string, userName?: string, changeMessage?: string) {\n const normalizedUserName = userName?.replace(/\\s+/g, ' ').trim();\n const normalizedMessage = changeMessage?.replace(/\\s+/g, ' ').trim();\n const message = normalizedMessage || `Update ${agentId} agent override`;\n return normalizedUserName ? `${message} by ${normalizedUserName}` : message;\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/agents - List all stored agents\n */\nexport const LIST_STORED_AGENTS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents',\n responseType: 'json',\n queryParamSchema: listStoredAgentsQuerySchema,\n responseSchema: listStoredAgentsResponseSchema,\n summary: 'List stored agents',\n description: 'Returns a paginated list of all agents stored in the database',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n page,\n perPage,\n orderBy,\n status,\n authorId,\n visibility,\n metadata,\n favoritedOnly,\n pinFavoritedFor,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Resolve the visibility scope for this caller. Non-owner queries for\n // another author return only that author's public rows; default lists\n // return the caller's rows plus legacy unowned records.\n const filter = resolveAuthorFilter({\n requestContext,\n resource: 'stored-agents',\n queryAuthorId: authorId,\n queryVisibility: visibility === 'public' ? 'public' : undefined,\n });\n\n const scope = await getStoredResourceScope(mastra, requestContext);\n const scopedMetadata = scopeStoredResourceMetadata(metadata, scope);\n\n const callerId = getCallerAuthorId(requestContext);\n const favoritesEnabled = await isBuilderFeatureEnabled(mastra, 'favorites');\n const honoredStarredOnly = favoritesEnabled && favoritedOnly === true;\n const favoriteSubjectId = pinFavoritedFor ?? callerId;\n\n // `?favoritedOnly=true`: fetch caller's favorited IDs, then refilter + recompute total.\n if (honoredStarredOnly) {\n const effectivePerPage: number = perPage ?? 100;\n if (!favoriteSubjectId) {\n return { agents: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) {\n throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n }\n const starredIds = await favoritesStore.listFavoritedIds({ userId: favoriteSubjectId, entityType: 'agent' });\n if (starredIds.length === 0) {\n return { agents: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const allMatching = await agentsStore.listResolved({\n perPage: false,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n entityIds: starredIds,\n });\n const visible = allMatching.agents.filter(record => matchesAuthorFilter(record, filter));\n const total = visible.length;\n const startIdx = effectivePerPage === 0 ? 0 : page * effectivePerPage;\n const endIdx = effectivePerPage === 0 ? 0 : startIdx + effectivePerPage;\n const sliced = effectivePerPage === 0 ? [] : visible.slice(startIdx, endIdx);\n const annotated = sliced.map(record => ({ ...record, isFavorited: true }));\n const authors = await prepareAuthorEnrichment(\n mastra,\n requestContext,\n annotated.map(a => a.authorId),\n );\n const withAuthors = authors ? annotated.map(record => attachAuthor(record, authors)) : annotated;\n const hasMore = effectivePerPage > 0 && endIdx < total;\n return { agents: withAuthors, total, page, perPage: effectivePerPage, hasMore };\n }\n\n const result = await agentsStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n });\n\n // Post-filter to enforce ownership + visibility rules across all backends.\n // Storage adapters can only do an equality filter on authorId, so we apply\n // the ownedOrPublic / publicOnly logic here.\n // Note: `total` is left as the storage-reported count to keep pagination\n // math working. For `unrestricted` / `exact` filters nothing is removed.\n // For `ownedOrPublic` / `publicOnly`, downstream UIs should treat the\n // filter as a view over the caller's scope — an approximation is OK.\n const visibleAgents = result.agents.filter(record => matchesAuthorFilter(record, filter));\n\n const authors = await prepareAuthorEnrichment(\n mastra,\n requestContext,\n visibleAgents.map(a => a.authorId),\n );\n\n if (!favoritesEnabled) {\n const stripped = visibleAgents.map(stripFavoriteFields);\n const withAuthors = authors ? stripped.map(record => attachAuthor(record, authors)) : stripped;\n return { ...result, agents: withAuthors };\n }\n\n const enrichment = await prepareFavoritesEnrichment(\n mastra,\n requestContext,\n 'agent',\n visibleAgents.map(a => a.id),\n );\n const annotated = enrichment\n ? visibleAgents.map(record => ({ ...record, isFavorited: enrichment.starredIds.has(record.id) }))\n : visibleAgents.map(stripFavoriteFields);\n const withAuthors = authors ? annotated.map(record => attachAuthor(record, authors)) : annotated;\n\n return { ...result, agents: withAuthors };\n } catch (error) {\n return handleError(error, 'Error listing stored agents');\n }\n },\n});\n\nasync function buildStoredAgentExport({\n mastra,\n requestContext,\n storedAgentId,\n body,\n}: {\n mastra: any;\n requestContext: any;\n storedAgentId: string;\n body: Record<string, unknown>;\n}) {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : undefined;\n const storedAgent = await agentsStore?.getByIdResolved(storedAgentId, { status: 'draft' });\n if (storedAgent) {\n assertStoredResourceScope(storedAgent, await getStoredResourceScope(mastra, requestContext));\n assertReadAccess({ requestContext, resource: 'stored-agents', resourceId: storedAgentId, record: storedAgent });\n }\n\n let codeAgent: { __getEditorConfig?: () => unknown; source?: string } | undefined;\n try {\n codeAgent = mastra.getAgentById?.(storedAgentId) as typeof codeAgent;\n } catch {\n codeAgent = undefined;\n }\n\n if (!storedAgent && !codeAgent) {\n throw new HTTPException(404, { message: `Agent with id ${storedAgentId} not found` });\n }\n\n const config = buildExportConfig(body, codeAgent);\n const content = `${JSON.stringify(config, null, 2)}\\n`;\n\n return {\n agentId: storedAgentId,\n fileName: agentExportFilename(storedAgentId),\n content,\n config,\n };\n}\n\nexport const EXPORT_STORED_AGENT_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents/:storedAgentId/export',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: exportStoredAgentBodySchema,\n responseSchema: exportStoredAgentResponseSchema,\n summary: 'Export stored agent override JSON',\n description: 'Returns deterministic JSON for an agent configuration or code-agent override without mutating storage',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId, ...body }) => {\n try {\n return await buildStoredAgentExport({ mastra, requestContext, storedAgentId, body });\n } catch (error) {\n return handleError(error, 'Error exporting stored agent');\n }\n },\n});\n\nexport const OPEN_STORED_AGENT_CHANGE_REQUEST_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents/:storedAgentId/change-request',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: openStoredAgentChangeRequestBodySchema,\n responseSchema: openStoredAgentChangeRequestResponseSchema,\n summary: 'Open stored agent source change request',\n description: 'Opens a source-provider change request for deterministic agent override JSON without mutating storage',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId, ...body }) => {\n try {\n const provider = mastra.getEditor?.()?.getSourceControlProvider?.();\n if (!provider?.openChangeRequest) {\n throw new HTTPException(400, { message: 'Source control provider cannot open change requests' });\n }\n\n const openChangeRequest = provider.openChangeRequest.bind(provider);\n const { changeMessage, userName, inspectOnly, ...exportBody } = body;\n const headRef = sourceChangeRequestHeadRef(storedAgentId);\n const title = `Update ${storedAgentId} agent override`;\n const result = inspectOnly\n ? await openChangeRequest({\n title,\n headRef,\n files: [],\n })\n : await (async () => {\n const response = await buildStoredAgentExport({ mastra, requestContext, storedAgentId, body: exportBody });\n const message = sourceChangeRequestMessage(storedAgentId, userName, changeMessage);\n return openChangeRequest({\n title,\n body: `Updates ${response.fileName} from Mastra Studio.`,\n headRef,\n files: [\n {\n path: response.fileName,\n content: response.content,\n message,\n },\n ],\n });\n })();\n\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : undefined;\n await (\n agentsStore as { useProviderRef?: (agentId: string, ref: string) => Promise<void> } | undefined\n )?.useProviderRef?.(storedAgentId, result.ref ?? headRef);\n mastra.getEditor?.()?.agent?.clearCache?.(storedAgentId);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error opening stored agent change request');\n }\n },\n});\n\n/**\n * GET /stored/agents/:storedAgentId - Get a stored agent by ID\n */\nexport const GET_STORED_AGENT_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredAgentResponseSchema,\n summary: 'Get stored agent by ID',\n description:\n 'Returns a specific agent from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n const agent = await agentsStore.getByIdResolved(storedAgentId, { status });\n\n if (!agent) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n assertStoredResourceScope(agent, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, `stored-agents:read[:<id>]`\n // holder, and the record isn't public/legacy-unowned.\n assertReadAccess({ requestContext, resource: 'stored-agents', resourceId: storedAgentId, record: agent });\n\n const authors = await prepareAuthorEnrichment(mastra, requestContext, [agent.authorId]);\n const withFavorite = await enrichOrStripFavorites(mastra, requestContext, 'agent', agent);\n return attachAuthor(withFavorite, authors);\n } catch (error) {\n return handleError(error, 'Error getting stored agent');\n }\n },\n});\n\n/**\n * POST /stored/agents - Create a new stored agent\n */\nexport const CREATE_STORED_AGENT_ROUTE: ServerRoute<\n InferParams<undefined, undefined, typeof createStoredAgentBodySchema>,\n z.infer<typeof createStoredAgentResponseSchema>,\n 'json',\n RouteSchemas<undefined, undefined, typeof createStoredAgentBodySchema, typeof createStoredAgentResponseSchema>,\n 'POST',\n '/stored/agents'\n> = createRoute({\n method: 'POST',\n path: '/stored/agents',\n responseType: 'json',\n bodySchema: createStoredAgentBodySchema,\n responseSchema: createStoredAgentResponseSchema,\n summary: 'Create stored agent',\n description: 'Creates a new agent in storage with the provided configuration',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n id: providedId,\n metadata,\n visibility: bodyVisibility,\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive agent ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if agent with this ID already exists\n const existing = await agentsStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Agent with id ${id} already exists` });\n }\n\n // Force authorId from the authenticated caller; ignore any body-provided value.\n // No owner = always public (no auth / no user context).\n // With an owner, respect the client's choice, defaulting to 'private'.\n const authorId = getCallerAuthorId(requestContext) ?? undefined;\n const visibility = authorId ? (bodyVisibility ?? 'private') : 'public';\n\n // Reject oversized avatar images before writing to storage.\n validateMetadataAvatarUrl(metadata);\n\n // Model policy enforcement is intentionally not done on save: each UI\n // surface gates its own model picker via ModelPolicyProvider, and the\n // policy is surface-scoped (builder vs editor). Re-introducing a single\n // server-side check here would either over-enforce on the editor or\n // under-enforce on the builder until per-surface enforcement lands.\n\n const resolvedBrowser = await resolveBrowserField(browser, mastra);\n\n let createInstructions: typeof instructions | undefined = instructions;\n let createTools = tools;\n let createIntegrationTools = integrationTools;\n let createMcpClients = mcpClients;\n let codeAgentForCreate: { __getEditorConfig?: () => unknown; source?: string } | undefined;\n try {\n codeAgentForCreate = mastra.getAgentById?.(id) as typeof codeAgentForCreate;\n } catch {\n codeAgentForCreate = undefined;\n }\n if (codeAgentForCreate?.source === 'code') {\n const ownership = getCodeAgentOwnership(codeAgentForCreate.__getEditorConfig?.());\n if (ownership.ownsInstructions) {\n assertOwnedInstructionsNotEmpty(createInstructions);\n } else {\n createInstructions = undefined;\n }\n if (!ownership.ownsTools && !ownership.ownsToolDescriptionsOnly) {\n createTools = undefined;\n createIntegrationTools = undefined;\n createMcpClients = undefined;\n }\n }\n\n const input = {\n id,\n authorId,\n visibility,\n metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),\n name,\n description,\n instructions: createInstructions,\n model,\n tools: createTools,\n defaultOptions,\n workflows,\n agents,\n integrationTools: createIntegrationTools,\n toolProviders,\n mcpClients: createMcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser: resolvedBrowser,\n requestContextSchema,\n } as StorageCreateAgentInput;\n\n // Use editor.agent.create() when available to apply builder defaults\n const editor = mastra.getEditor?.();\n if (editor) {\n await editor.agent.create(input);\n } else {\n // Fallback to direct storage create\n await agentsStore.create({ agent: input });\n }\n\n // Publish the initial version so the agent is immediately usable.\n // Without this, the thin record stays as status='draft' with activeVersionId=null,\n // which makes the agent unreachable via status='published' resolution.\n const { versions } = await agentsStore.listVersions({ agentId: id, perPage: 1 });\n const initialVersion = versions[0];\n if (initialVersion) {\n await agentsStore.update({\n id,\n activeVersionId: initialVersion.id,\n status: 'published',\n });\n editor?.agent.clearCache(id);\n }\n\n // Return the resolved agent (thin record + version config) using the newly published version\n const resolved = await agentsStore.getByIdResolved(id, { status: 'published' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created agent' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'agent', resolved);\n } catch (error) {\n return handleError(error, 'Error creating stored agent');\n }\n },\n});\n\n/**\n * PATCH /stored/agents/:storedAgentId - Update a stored agent\n */\nexport const UPDATE_STORED_AGENT_ROUTE: ServerRoute<\n InferParams<typeof storedAgentIdPathParams, undefined, typeof updateStoredAgentBodySchema>,\n z.infer<typeof updateStoredAgentResponseSchema>,\n 'json',\n RouteSchemas<\n typeof storedAgentIdPathParams,\n undefined,\n typeof updateStoredAgentBodySchema,\n typeof updateStoredAgentResponseSchema\n >,\n 'PATCH',\n '/stored/agents/:storedAgentId'\n> = createRoute({\n method: 'PATCH',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: updateStoredAgentBodySchema,\n responseSchema: updateStoredAgentResponseSchema,\n summary: 'Update stored agent',\n description: 'Updates an existing agent in storage with the provided fields',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n storedAgentId,\n // Metadata-level fields\n authorId,\n metadata,\n visibility,\n // Config fields (snapshot-level)\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser,\n requestContextSchema,\n // Version options\n changeMessage,\n autoPublish = false,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent exists\n const existing = await agentsStore.getById(storedAgentId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n const scope = await getStoredResourceScope(mastra, requestContext);\n assertStoredResourceScope(existing, scope);\n\n // Throws 404 if the caller isn't the owner, admin, or `agents:edit[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-agents',\n resourceId: storedAgentId,\n action: 'edit',\n record: existing,\n });\n\n // Reject oversized avatar images before writing to storage.\n validateMetadataAvatarUrl(metadata);\n\n // No owner = always public, regardless of what the client sent.\n const callerAuthorId = getCallerAuthorId(requestContext) ?? undefined;\n const resolvedVisibility = callerAuthorId ? visibility : visibility != null ? 'public' : undefined;\n\n // Model policy enforcement is intentionally not done on save: each UI\n // surface gates its own model picker via ModelPolicyProvider, and the\n // policy is surface-scoped (builder vs editor). Re-introducing a single\n // server-side check here would either over-enforce on the editor or\n // under-enforce on the builder until per-surface enforcement lands.\n\n // Resolve boolean browser shorthand from the UI\n const resolvedBrowser = await resolveBrowserField(browser, mastra);\n\n // For code-defined agents, strip fields the editor config does not allow\n // Studio to own. This keeps stored snapshots (and the per-entity files\n // they get persisted to) free of fields the server never reads back.\n let codeAgentForUpdate: { __getEditorConfig?: () => unknown; source?: string } | undefined;\n try {\n codeAgentForUpdate = mastra.getAgentById?.(storedAgentId) as typeof codeAgentForUpdate;\n } catch {\n codeAgentForUpdate = undefined;\n }\n if (codeAgentForUpdate?.source === 'code') {\n const ownership = getCodeAgentOwnership(codeAgentForUpdate.__getEditorConfig?.());\n if (ownership.ownsInstructions) {\n if (instructions !== undefined) {\n assertOwnedInstructionsNotEmpty(instructions);\n }\n } else {\n instructions = undefined;\n }\n if (!ownership.ownsTools && !ownership.ownsToolDescriptionsOnly) {\n tools = undefined;\n integrationTools = undefined;\n mcpClients = undefined;\n }\n }\n\n const mergedMetadata: Record<string, unknown> = { ...(existing.metadata ?? {}), ...(metadata ?? {}) };\n const scopedMetadata = scopeStoredResourceMetadata(mergedMetadata, scope);\n\n // Update the agent with both metadata-level and config-level fields\n // The storage layer handles separating these into agent-record updates vs new-version creation\n // Cast needed because Zod's passthrough() output types don't exactly match the handwritten TS interfaces\n const updatedAgent = await agentsStore.update({\n id: storedAgentId,\n authorId,\n metadata: scopedMetadata,\n visibility: resolvedVisibility,\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser: resolvedBrowser,\n requestContextSchema,\n } as StorageUpdateAgentInput);\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = {\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser: resolvedBrowser,\n requestContextSchema,\n };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n const autoVersionResult = await handleAutoVersioning(\n agentsStore as unknown as VersionedStoreInterface,\n storedAgentId,\n 'agentId',\n AGENT_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedAgent,\n providedConfigFields,\n changeMessage ? { changeMessage } : undefined,\n );\n\n if (!autoVersionResult) {\n throw new Error('handleAutoVersioning returned undefined');\n }\n\n // In code mode, local saves should overwrite the most recent saved\n // snapshot rather than creating new draft versions on every keystroke\n // batch. Version history is intended to track commits, not raw saves.\n // We collapse the freshly created version onto the previous one by\n // deleting the prior latest version, leaving a single rolling snapshot.\n // When the user explicitly provides a changeMessage we treat that as a\n // commit and keep the new version as a discrete history entry.\n const isCodeSource = mastra.getEditor?.()?.getSource?.() === 'code';\n if (isCodeSource && autoVersionResult.versionCreated && !changeMessage) {\n const { versions } = await agentsStore.listVersions({ agentId: storedAgentId, perPage: 2 });\n const previousVersion = versions[1];\n const isPublishedVersion = previousVersion?.id === existing.activeVersionId;\n if (previousVersion && !isPublishedVersion) {\n await agentsStore.deleteVersion(previousVersion.id);\n }\n }\n\n // Publication remains opt-in so Classic Studio can save drafts without moving the active version,\n // while Agent Builder can preserve immediate runtime updates by sending autoPublish: true.\n // This flag is a bridge until version creation and publication move to dedicated APIs.\n if (autoVersionResult.versionCreated && autoPublish) {\n const { versions } = await agentsStore.listVersions({ agentId: storedAgentId, perPage: 1 });\n const latestVersion = versions[0];\n if (latestVersion) {\n await agentsStore.update({\n id: storedAgentId,\n activeVersionId: latestVersion.id,\n });\n }\n }\n\n // Clear the cached agent instance so the next request gets the updated config\n const editor = mastra.getEditor();\n if (editor) {\n editor.agent.clearCache(storedAgentId);\n }\n\n // Return the resolved agent with the latest version\n const resolved = await agentsStore.getByIdResolved(storedAgentId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated agent' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'agent', resolved);\n } catch (error) {\n return handleError(error, 'Error updating stored agent');\n }\n },\n});\n\n/**\n * DELETE /stored/agents/:storedAgentId - Delete a stored agent\n */\nexport const DELETE_STORED_AGENT_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n responseSchema: deleteStoredAgentResponseSchema,\n summary: 'Delete stored agent',\n description: 'Deletes an agent from storage by its unique identifier',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent exists\n const existing = await agentsStore.getById(storedAgentId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n assertStoredResourceScope(existing, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, or `agents:delete[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-agents',\n resourceId: storedAgentId,\n action: 'delete',\n record: existing,\n });\n\n await agentsStore.delete(storedAgentId);\n\n // Cascade: drop any favorite rows referencing this agent so they don't\n // resurrect if the same id is reused. Failure must not abort the delete.\n try {\n const favoritesStore = await storage.getStore('favorites');\n await favoritesStore?.deleteFavoritesForEntity({ entityType: 'agent', entityId: storedAgentId });\n } catch (cascadeError) {\n mastra\n .getLogger?.()\n ?.warn?.('Failed to cascade-delete favorites for agent', { storedAgentId, error: cascadeError });\n }\n\n // Clear the cached agent instance\n mastra.getEditor()?.agent.clearCache(storedAgentId);\n\n return { success: true, message: `Agent ${storedAgentId} deleted successfully` };\n } catch (error) {\n return handleError(error, 'Error deleting stored agent');\n }\n },\n});\n\n/**\n * GET /stored/agents/:storedAgentId/dependents - List agents that reference\n * the target agent as a sub-agent.\n *\n * Returns `dependents` for caller-visible references (named) and `hiddenCount`\n * for references from agents the caller can't read (count only, no leak).\n * `hiddenCount` is only populated when the target is public — private targets\n * can't legitimately be referenced from other workspaces.\n */\nexport const GET_STORED_AGENT_DEPENDENTS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents/:storedAgentId/dependents',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n responseSchema: getStoredAgentDependentsResponseSchema,\n summary: 'List dependents of a stored agent',\n description:\n 'Returns agents that reference the target as a sub-agent. Used to warn before deleting or unsharing. Caller-readable references appear in `dependents` (id + name); cross-workspace references the caller cannot read are aggregated in `hiddenCount` and only surfaced when the target is public.',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId }) => {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Mirrors GET: 404 if the caller can't read the target. Prevents the\n // dependents endpoint from being usable as a sub-agent reference oracle.\n const target = await agentsStore.getById(storedAgentId);\n if (!target) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n assertStoredResourceScope(target, await getStoredResourceScope(mastra, requestContext));\n assertReadAccess({ requestContext, resource: 'stored-agents', resourceId: storedAgentId, record: target });\n\n // Full scan (no authorId filter) so a public target can detect\n // cross-workspace private dependents. We split into caller-visible\n // `dependents` vs `hiddenCount` so private agents owned by other users\n // are counted but never named.\n const filter = resolveAuthorFilter({ requestContext, resource: 'stored-agents' });\n const all = await agentsStore.listResolved({\n perPage: false,\n status: 'published',\n });\n\n const targetIsPublic = (target as { visibility?: string }).visibility === 'public';\n\n // Caller-readable dependents are surfaced by name (the caller already\n // has access to them). Cross-workspace dependents the caller cannot\n // read are aggregated into hiddenCount, only when the target is public.\n const dependents: Array<{ id: string; name: string }> = [];\n let hiddenCount = 0;\n\n for (const record of all.agents) {\n if (record.id === storedAgentId) continue;\n if (!referencesTarget((record as { agents?: unknown }).agents, storedAgentId)) continue;\n\n if (matchesAuthorFilter(record, filter)) {\n dependents.push({\n id: record.id,\n name: (record as { name?: string }).name ?? record.id,\n });\n } else if (targetIsPublic) {\n hiddenCount += 1;\n }\n // Private target: drop hidden refs silently — they shouldn't exist\n // and surfacing the count would leak cross-workspace structure.\n }\n\n return { dependents, hiddenCount };\n } catch (error) {\n return handleError(error, 'Error listing stored agent dependents');\n }\n },\n});\n\n/**\n * Does the resolved `agents` snapshot field reference `targetId`?\n * The field can be either a static `Record<string, toolConfig>` or an array of\n * conditional variants (`{ value, rules? }`). Match if any variant's value\n * (or the static object) contains a matching key.\n */\nfunction referencesTarget(subAgents: unknown, targetId: string): boolean {\n if (!subAgents) return false;\n if (Array.isArray(subAgents)) {\n return subAgents.some(variant => {\n const value = (variant as { value?: unknown })?.value;\n return Boolean(value && typeof value === 'object' && Object.prototype.hasOwnProperty.call(value, targetId));\n });\n }\n if (typeof subAgents === 'object') {\n return Object.prototype.hasOwnProperty.call(subAgents, targetId);\n }\n return false;\n}\n\n/**\n * POST /stored/agents/preview-instructions - Preview resolved instructions\n */\nexport const PREVIEW_INSTRUCTIONS_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents/preview-instructions',\n responseType: 'json',\n bodySchema: previewInstructionsBodySchema,\n responseSchema: previewInstructionsResponseSchema,\n summary: 'Preview resolved instructions',\n description:\n 'Resolves an array of instruction blocks against a request context, evaluating rules, fetching prompt block references, and rendering template variables. Returns the final concatenated instruction string.',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, blocks, context }) => {\n try {\n const editor = mastra.getEditor();\n if (!editor) {\n throw new HTTPException(500, { message: 'Editor is not configured' });\n }\n\n const result = await editor.prompt.preview(blocks, context ?? {});\n\n return { result };\n } catch (error) {\n return handleError(error, 'Error previewing instructions');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgDA,eAAe,oBAAoB,SAAkB,QAAyD;CAC5G,IAAI,YAAY,MAAM;EAGpB,MAAM,kBAAiB,OAFR,OAAO,YAAY,EAAA,EACJ,iBAAiB,EAAA,EACf,mBAAmB,CAAC,EAAE,OAAO;EAC7D,IAAI,CAAC,gBACH,QAAQ,KACN,uOAGF;EAEF,OAAO,kBAAkB,KAAA;CAC3B;CACA,IAAI,YAAY,OACd,OAAO;CAET,OAAO;AACT;AAEA,MAAM,+BAA+B;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACA;AACF;;;;;;;AAQA,SAAS,sBAAsB,cAI7B;CACA,IAAI,iBAAiB,OACnB,OAAO;EAAE,kBAAkB;EAAO,WAAW;EAAO,0BAA0B;CAAM;CAEtF,IAAI,iBAAiB,KAAA,KAAa,iBAAiB,MAEjD,OAAO;EAAE,kBAAkB;EAAM,WAAW;EAAM,0BAA0B;CAAM;CAEpF,IAAI,OAAO,iBAAiB,UAC1B,OAAO;EAAE,kBAAkB;EAAO,WAAW;EAAO,0BAA0B;CAAM;CAEtF,MAAM,MAAM;CACZ,MAAM,mBAAmB,IAAI,iBAAiB;CAC9C,MAAM,WAAW,IAAI;CAIrB,OAAO;EAAE;EAAkB,WAHT,aAAa;EAGO,0BADpC,OAAO,aAAa,YAAY,aAAa,QAAS,SAAuC,gBAAgB;CAChD;AACjE;AAEA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AFY,OAAO,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC,EAEhD;EAClB,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,+BAA+B;EAC3D;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"stored-agents.js","names":[],"sources":["../../../src/server/handlers/stored-agents.ts"],"sourcesContent":["import type { StorageCreateAgentInput, StorageUpdateAgentInput } from '@mastra/core/storage';\nimport type { z } from 'zod/v4';\n\nimport { HTTPException } from '../http-exception';\nimport {\n storedAgentIdPathParams,\n statusQuerySchema,\n listStoredAgentsQuerySchema,\n createStoredAgentBodySchema,\n updateStoredAgentBodySchema,\n listStoredAgentsResponseSchema,\n getStoredAgentResponseSchema,\n createStoredAgentResponseSchema,\n updateStoredAgentResponseSchema,\n deleteStoredAgentResponseSchema,\n getStoredAgentDependentsResponseSchema,\n exportStoredAgentBodySchema,\n openStoredAgentChangeRequestBodySchema,\n exportStoredAgentResponseSchema,\n openStoredAgentChangeRequestResponseSchema,\n previewInstructionsBodySchema,\n previewInstructionsResponseSchema,\n} from '../schemas/stored-agents';\nimport type { ServerRoute, RouteSchemas, InferParams } from '../server-adapter/routes';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { assertStoredResourceScope, getStoredResourceScope, scopeStoredResourceMetadata, toSlug } from '../utils';\n\nimport { attachAuthor, prepareAuthorEnrichment } from './author-enrichment';\nimport {\n assertReadAccess,\n assertWriteAccess,\n getCallerAuthorId,\n matchesAuthorFilter,\n resolveAuthorFilter,\n} from './authorship';\nimport { isBuilderFeatureEnabled } from './editor-builder';\nimport { handleError } from './error';\nimport { enrichOrStripFavorites, prepareFavoritesEnrichment, stripFavoriteFields } from './favorites-enrichment';\nimport { validateMetadataAvatarUrl } from './validate-avatar';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\n/**\n * Resolve a `browser` field that may be a boolean shorthand from the UI.\n * - `true` → look up the admin's builder default browser config\n * - `false` → `null` (explicit clear)\n * - object/null/undefined → pass through unchanged\n */\nasync function resolveBrowserField(browser: unknown, mastra: { getEditor?: () => unknown }): Promise<unknown> {\n if (browser === true) {\n const editor = mastra.getEditor?.() as any;\n const builder = await editor?.resolveBuilder?.();\n const defaultBrowser = builder?.getConfiguration?.()?.agent?.browser;\n if (!defaultBrowser) {\n console.warn(\n '[mastra:server] Browser enabled (browser: true) but no default browser config found ' +\n 'in builder configuration. The agent will be created/updated without browser access. ' +\n 'Set `editor.builder.configuration.agent.browser` to fix this.',\n );\n }\n return defaultBrowser ?? undefined;\n }\n if (browser === false) {\n return null;\n }\n return browser;\n}\n\nconst AGENT_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'instructions',\n 'model',\n 'tools',\n 'defaultOptions',\n 'workflows',\n 'agents',\n 'integrationTools',\n 'toolProviders',\n 'inputProcessors',\n 'outputProcessors',\n 'memory',\n 'scorers',\n 'requestContextSchema',\n 'mcpClients',\n 'skills',\n 'workspace',\n 'browser',\n] as const;\n\nconst CODE_AGENT_OVERRIDE_FIELDS = [\n 'instructions',\n 'tools',\n 'integrationTools',\n 'mcpClients',\n 'requestContextSchema',\n] as const;\n\n/**\n * Derive ownership flags from a code agent's editor config.\n * Mirrors the semantics of `editor.agent.applyStoredOverrides` so that\n * client save payloads, persisted snapshots, and export output all agree\n * on which fields Studio is allowed to own.\n */\nfunction getCodeAgentOwnership(editorConfig: unknown): {\n ownsInstructions: boolean;\n ownsTools: boolean;\n ownsToolDescriptionsOnly: boolean;\n} {\n if (editorConfig === false) {\n return { ownsInstructions: false, ownsTools: false, ownsToolDescriptionsOnly: false };\n }\n if (editorConfig === undefined || editorConfig === null) {\n // Legacy default: code agents without explicit editor config behave as fully editable.\n return { ownsInstructions: true, ownsTools: true, ownsToolDescriptionsOnly: false };\n }\n if (typeof editorConfig !== 'object') {\n return { ownsInstructions: false, ownsTools: false, ownsToolDescriptionsOnly: false };\n }\n const cfg = editorConfig as { instructions?: unknown; tools?: unknown };\n const ownsInstructions = cfg.instructions === true;\n const toolsCfg = cfg.tools;\n const ownsTools = toolsCfg === true;\n const ownsToolDescriptionsOnly =\n typeof toolsCfg === 'object' && toolsCfg !== null && (toolsCfg as { description?: unknown }).description === true;\n return { ownsInstructions, ownsTools, ownsToolDescriptionsOnly };\n}\n\nfunction hasNonEmptyInstructions(value: unknown): boolean {\n if (typeof value === 'string') {\n return value.trim().length > 0;\n }\n\n if (!Array.isArray(value)) {\n return false;\n }\n\n return value.some(block => {\n if (!block || typeof block !== 'object') {\n return false;\n }\n\n const typedBlock = block as { type?: unknown; id?: unknown; content?: unknown };\n if (typedBlock.type === 'prompt_block_ref') {\n return typeof typedBlock.id === 'string' && typedBlock.id.length > 0;\n }\n\n return typeof typedBlock.content === 'string' && typedBlock.content.trim().length > 0;\n });\n}\n\nfunction assertOwnedInstructionsNotEmpty(instructions: unknown) {\n if (!hasNonEmptyInstructions(instructions)) {\n throw new HTTPException(400, { message: 'Instructions are required' });\n }\n}\n\nfunction sortForStableJson(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortForStableJson);\n }\n\n if (value && typeof value === 'object' && !(value instanceof Date)) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, entry]) => entry !== undefined)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => [key, sortForStableJson(entry)]),\n );\n }\n\n return value;\n}\n\nfunction buildExportConfig(\n input: Record<string, unknown>,\n agent?: { __getEditorConfig?: () => unknown; source?: string },\n) {\n const editorConfig = agent?.__getEditorConfig?.();\n const isCodeAgent = agent?.source === 'code';\n const allowedFields = isCodeAgent ? CODE_AGENT_OVERRIDE_FIELDS : AGENT_SNAPSHOT_CONFIG_FIELDS;\n const ownership = isCodeAgent ? getCodeAgentOwnership(editorConfig) : null;\n const config: Record<string, unknown> = {};\n\n for (const field of allowedFields) {\n if (input[field] === undefined) continue;\n if (ownership) {\n if (field === 'instructions' && !ownership.ownsInstructions) continue;\n if (\n (field === 'tools' || field === 'integrationTools' || field === 'mcpClients') &&\n !ownership.ownsTools &&\n !ownership.ownsToolDescriptionsOnly\n ) {\n continue;\n }\n }\n config[field] = input[field];\n }\n\n return sortForStableJson(config) as Record<string, unknown>;\n}\n\nfunction agentExportFilename(agentId: string) {\n return `agents/${encodeURIComponent(agentId)}.json`;\n}\n\nfunction sourceChangeRequestHeadRef(agentId: string) {\n const safeAgentId = agentId.replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'agent';\n return `mastra/${safeAgentId}`;\n}\n\nfunction sourceChangeRequestMessage(agentId: string, userName?: string, changeMessage?: string) {\n const normalizedUserName = userName?.replace(/\\s+/g, ' ').trim();\n const normalizedMessage = changeMessage?.replace(/\\s+/g, ' ').trim();\n const message = normalizedMessage || `Update ${agentId} agent override`;\n return normalizedUserName ? `${message} by ${normalizedUserName}` : message;\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/agents - List all stored agents\n */\nexport const LIST_STORED_AGENTS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents',\n responseType: 'json',\n queryParamSchema: listStoredAgentsQuerySchema,\n responseSchema: listStoredAgentsResponseSchema,\n summary: 'List stored agents',\n description: 'Returns a paginated list of all agents stored in the database',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n page,\n perPage,\n orderBy,\n status,\n authorId,\n visibility,\n metadata,\n favoritedOnly,\n pinFavoritedFor,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Resolve the visibility scope for this caller. Non-owner queries for\n // another author return only that author's public rows; default lists\n // return the caller's rows plus legacy unowned records.\n const filter = resolveAuthorFilter({\n requestContext,\n resource: 'stored-agents',\n queryAuthorId: authorId,\n queryVisibility: visibility === 'public' ? 'public' : undefined,\n });\n\n const scope = await getStoredResourceScope(mastra, requestContext);\n const scopedMetadata = scopeStoredResourceMetadata(metadata, scope);\n\n const callerId = getCallerAuthorId(requestContext);\n const favoritesEnabled = await isBuilderFeatureEnabled(mastra, 'favorites');\n const honoredStarredOnly = favoritesEnabled && favoritedOnly === true;\n const favoriteSubjectId = pinFavoritedFor ?? callerId;\n\n // `?favoritedOnly=true`: fetch caller's favorited IDs, then refilter + recompute total.\n if (honoredStarredOnly) {\n const effectivePerPage: number = perPage ?? 100;\n if (!favoriteSubjectId) {\n return { agents: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const favoritesStore = await storage.getStore('favorites');\n if (!favoritesStore) {\n throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n }\n const starredIds = await favoritesStore.listFavoritedIds({ userId: favoriteSubjectId, entityType: 'agent' });\n if (starredIds.length === 0) {\n return { agents: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n }\n const allMatching = await agentsStore.listResolved({\n perPage: false,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n entityIds: starredIds,\n });\n const visible = allMatching.agents.filter(record => matchesAuthorFilter(record, filter));\n const total = visible.length;\n const startIdx = effectivePerPage === 0 ? 0 : page * effectivePerPage;\n const endIdx = effectivePerPage === 0 ? 0 : startIdx + effectivePerPage;\n const sliced = effectivePerPage === 0 ? [] : visible.slice(startIdx, endIdx);\n const annotated = sliced.map(record => ({ ...record, isFavorited: true }));\n const authors = await prepareAuthorEnrichment(\n mastra,\n requestContext,\n annotated.map(a => a.authorId),\n );\n const withAuthors = authors ? annotated.map(record => attachAuthor(record, authors)) : annotated;\n const hasMore = effectivePerPage > 0 && endIdx < total;\n return { agents: withAuthors, total, page, perPage: effectivePerPage, hasMore };\n }\n\n const result = await agentsStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n metadata: scopedMetadata,\n });\n\n // Post-filter to enforce ownership + visibility rules across all backends.\n // Storage adapters can only do an equality filter on authorId, so we apply\n // the ownedOrPublic / publicOnly logic here.\n // Note: `total` is left as the storage-reported count to keep pagination\n // math working. For `unrestricted` / `exact` filters nothing is removed.\n // For `ownedOrPublic` / `publicOnly`, downstream UIs should treat the\n // filter as a view over the caller's scope — an approximation is OK.\n const visibleAgents = result.agents.filter(record => matchesAuthorFilter(record, filter));\n\n const authors = await prepareAuthorEnrichment(\n mastra,\n requestContext,\n visibleAgents.map(a => a.authorId),\n );\n\n if (!favoritesEnabled) {\n const stripped = visibleAgents.map(stripFavoriteFields);\n const withAuthors = authors ? stripped.map(record => attachAuthor(record, authors)) : stripped;\n return { ...result, agents: withAuthors };\n }\n\n const enrichment = await prepareFavoritesEnrichment(\n mastra,\n requestContext,\n 'agent',\n visibleAgents.map(a => a.id),\n );\n const annotated = enrichment\n ? visibleAgents.map(record => ({ ...record, isFavorited: enrichment.starredIds.has(record.id) }))\n : visibleAgents.map(stripFavoriteFields);\n const withAuthors = authors ? annotated.map(record => attachAuthor(record, authors)) : annotated;\n\n return { ...result, agents: withAuthors };\n } catch (error) {\n return handleError(error, 'Error listing stored agents');\n }\n },\n});\n\nasync function buildStoredAgentExport({\n mastra,\n requestContext,\n storedAgentId,\n body,\n}: {\n mastra: any;\n requestContext: any;\n storedAgentId: string;\n body: Record<string, unknown>;\n}) {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : undefined;\n const storedAgent = await agentsStore?.getByIdResolved(storedAgentId, { status: 'draft' });\n if (storedAgent) {\n assertStoredResourceScope(storedAgent, await getStoredResourceScope(mastra, requestContext));\n assertReadAccess({ requestContext, resource: 'stored-agents', resourceId: storedAgentId, record: storedAgent });\n }\n\n let codeAgent: { __getEditorConfig?: () => unknown; source?: string } | undefined;\n try {\n codeAgent = mastra.getAgentById?.(storedAgentId) as typeof codeAgent;\n } catch {\n codeAgent = undefined;\n }\n\n if (!storedAgent && !codeAgent) {\n throw new HTTPException(404, { message: `Agent with id ${storedAgentId} not found` });\n }\n\n const config = buildExportConfig(body, codeAgent);\n const content = `${JSON.stringify(config, null, 2)}\\n`;\n\n return {\n agentId: storedAgentId,\n fileName: agentExportFilename(storedAgentId),\n content,\n config,\n };\n}\n\nexport const EXPORT_STORED_AGENT_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents/:storedAgentId/export',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: exportStoredAgentBodySchema,\n responseSchema: exportStoredAgentResponseSchema,\n summary: 'Export stored agent override JSON',\n description: 'Returns deterministic JSON for an agent configuration or code-agent override without mutating storage',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId, ...body }) => {\n try {\n return await buildStoredAgentExport({ mastra, requestContext, storedAgentId, body });\n } catch (error) {\n return handleError(error, 'Error exporting stored agent');\n }\n },\n});\n\nexport const OPEN_STORED_AGENT_CHANGE_REQUEST_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents/:storedAgentId/change-request',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: openStoredAgentChangeRequestBodySchema,\n responseSchema: openStoredAgentChangeRequestResponseSchema,\n summary: 'Open stored agent source change request',\n description: 'Opens a source-provider change request for deterministic agent override JSON without mutating storage',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId, ...body }) => {\n try {\n const provider = mastra.getEditor?.()?.getSourceControlProvider?.();\n if (!provider?.openChangeRequest) {\n throw new HTTPException(400, { message: 'Source control provider cannot open change requests' });\n }\n\n const openChangeRequest = provider.openChangeRequest.bind(provider);\n const { changeMessage, userName, inspectOnly, ...exportBody } = body;\n const headRef = sourceChangeRequestHeadRef(storedAgentId);\n const title = `Update ${storedAgentId} agent override`;\n const result = inspectOnly\n ? await openChangeRequest({\n title,\n headRef,\n files: [],\n })\n : await (async () => {\n const response = await buildStoredAgentExport({ mastra, requestContext, storedAgentId, body: exportBody });\n const message = sourceChangeRequestMessage(storedAgentId, userName, changeMessage);\n return openChangeRequest({\n title,\n body: `Updates ${response.fileName} from Mastra Studio.`,\n headRef,\n files: [\n {\n path: response.fileName,\n content: response.content,\n message,\n },\n ],\n });\n })();\n\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : undefined;\n await (\n agentsStore as { useProviderRef?: (agentId: string, ref: string) => Promise<void> } | undefined\n )?.useProviderRef?.(storedAgentId, result.ref ?? headRef);\n mastra.getEditor?.()?.agent?.clearCache?.(storedAgentId);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error opening stored agent change request');\n }\n },\n});\n\n/**\n * GET /stored/agents/:storedAgentId - Get a stored agent by ID\n */\nexport const GET_STORED_AGENT_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredAgentResponseSchema,\n summary: 'Get stored agent by ID',\n description:\n 'Returns a specific agent from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n const agent = await agentsStore.getByIdResolved(storedAgentId, { status });\n\n if (!agent) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n assertStoredResourceScope(agent, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, `stored-agents:read[:<id>]`\n // holder, and the record isn't public/legacy-unowned.\n assertReadAccess({ requestContext, resource: 'stored-agents', resourceId: storedAgentId, record: agent });\n\n const authors = await prepareAuthorEnrichment(mastra, requestContext, [agent.authorId]);\n const withFavorite = await enrichOrStripFavorites(mastra, requestContext, 'agent', agent);\n return attachAuthor(withFavorite, authors);\n } catch (error) {\n return handleError(error, 'Error getting stored agent');\n }\n },\n});\n\n/**\n * POST /stored/agents - Create a new stored agent\n */\nexport const CREATE_STORED_AGENT_ROUTE: ServerRoute<\n InferParams<undefined, undefined, typeof createStoredAgentBodySchema>,\n z.infer<typeof createStoredAgentResponseSchema>,\n 'json',\n RouteSchemas<undefined, undefined, typeof createStoredAgentBodySchema, typeof createStoredAgentResponseSchema>,\n 'POST',\n '/stored/agents'\n> = createRoute({\n method: 'POST',\n path: '/stored/agents',\n responseType: 'json',\n bodySchema: createStoredAgentBodySchema,\n responseSchema: createStoredAgentResponseSchema,\n summary: 'Create stored agent',\n description: 'Creates a new agent in storage with the provided configuration',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n id: providedId,\n metadata,\n visibility: bodyVisibility,\n autoPublish,\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive agent ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if agent with this ID already exists\n const existing = await agentsStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Agent with id ${id} already exists` });\n }\n\n // Force authorId from the authenticated caller; ignore any body-provided value.\n // No owner = always public (no auth / no user context).\n // With an owner, respect the client's choice, defaulting to 'private'.\n const authorId = getCallerAuthorId(requestContext) ?? undefined;\n const visibility = authorId ? (bodyVisibility ?? 'private') : 'public';\n\n // Reject oversized avatar images before writing to storage.\n validateMetadataAvatarUrl(metadata);\n\n // Model policy enforcement is intentionally not done on save: each UI\n // surface gates its own model picker via ModelPolicyProvider, and the\n // policy is surface-scoped (builder vs editor). Re-introducing a single\n // server-side check here would either over-enforce on the editor or\n // under-enforce on the builder until per-surface enforcement lands.\n\n const resolvedBrowser = await resolveBrowserField(browser, mastra);\n\n let createInstructions: typeof instructions | undefined = instructions;\n let createTools = tools;\n let createIntegrationTools = integrationTools;\n let createMcpClients = mcpClients;\n let codeAgentForCreate: { __getEditorConfig?: () => unknown; source?: string } | undefined;\n try {\n codeAgentForCreate = mastra.getAgentById?.(id) as typeof codeAgentForCreate;\n } catch {\n codeAgentForCreate = undefined;\n }\n if (codeAgentForCreate?.source === 'code') {\n const ownership = getCodeAgentOwnership(codeAgentForCreate.__getEditorConfig?.());\n if (ownership.ownsInstructions) {\n assertOwnedInstructionsNotEmpty(createInstructions);\n } else {\n createInstructions = undefined;\n }\n if (!ownership.ownsTools && !ownership.ownsToolDescriptionsOnly) {\n createTools = undefined;\n createIntegrationTools = undefined;\n createMcpClients = undefined;\n }\n }\n\n const input = {\n id,\n authorId,\n visibility,\n metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),\n name,\n description,\n instructions: createInstructions,\n model,\n tools: createTools,\n defaultOptions,\n workflows,\n agents,\n integrationTools: createIntegrationTools,\n toolProviders,\n mcpClients: createMcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser: resolvedBrowser,\n requestContextSchema,\n } as StorageCreateAgentInput;\n\n // Use editor.agent.create() when available to apply builder defaults\n const editor = mastra.getEditor?.();\n if (editor) {\n await editor.agent.create(input);\n } else {\n // Fallback to direct storage create\n await agentsStore.create({ agent: input });\n }\n\n // Publish the initial version so the agent is immediately usable. Without this the\n // thin record stays at status='draft' with activeVersionId=null, which makes the\n // agent unreachable via status='published' resolution — a created agent that\n // resolves nowhere. That's why publishing is the default.\n //\n // Callers staging an agent for later review, and Studio when it saves an override\n // for a code-defined agent, pass autoPublish: false. In the override case the code\n // definition already serves traffic, so the first save must behave like every later\n // save and stay a draft until the user explicitly publishes.\n //\n // A code-source editor can't honour that: there is no draft/publish step there\n // (the save writes the override file, git is the version history) and filesystem\n // storage only persists published entities, so an unpublished record would never\n // reach disk. The editor's own source is server-side knowledge — a client can't\n // reliably determine it before saving — so the flag is overridden here.\n const isCodeSourceEditor = editor?.getSource?.() === 'code';\n const { versions } = await agentsStore.listVersions({ agentId: id, perPage: 1 });\n const initialVersion = versions[0];\n if (initialVersion && (autoPublish !== false || isCodeSourceEditor)) {\n await agentsStore.update({\n id,\n activeVersionId: initialVersion.id,\n status: 'published',\n });\n }\n editor?.agent.clearCache(id);\n\n // Return the resolved agent (thin record + version config). Published resolution falls\n // back to the latest version, so an unpublished code-agent override still returns the\n // config the caller just saved.\n const resolved = await agentsStore.getByIdResolved(id, { status: 'published' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created agent' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'agent', resolved);\n } catch (error) {\n return handleError(error, 'Error creating stored agent');\n }\n },\n});\n\n/**\n * PATCH /stored/agents/:storedAgentId - Update a stored agent\n */\nexport const UPDATE_STORED_AGENT_ROUTE: ServerRoute<\n InferParams<typeof storedAgentIdPathParams, undefined, typeof updateStoredAgentBodySchema>,\n z.infer<typeof updateStoredAgentResponseSchema>,\n 'json',\n RouteSchemas<\n typeof storedAgentIdPathParams,\n undefined,\n typeof updateStoredAgentBodySchema,\n typeof updateStoredAgentResponseSchema\n >,\n 'PATCH',\n '/stored/agents/:storedAgentId'\n> = createRoute({\n method: 'PATCH',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: updateStoredAgentBodySchema,\n responseSchema: updateStoredAgentResponseSchema,\n summary: 'Update stored agent',\n description: 'Updates an existing agent in storage with the provided fields',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n requestContext,\n storedAgentId,\n // Metadata-level fields\n authorId,\n metadata,\n visibility,\n // Config fields (snapshot-level)\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser,\n requestContextSchema,\n // Version options\n changeMessage,\n autoPublish = false,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent exists\n const existing = await agentsStore.getById(storedAgentId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n const scope = await getStoredResourceScope(mastra, requestContext);\n assertStoredResourceScope(existing, scope);\n\n // Throws 404 if the caller isn't the owner, admin, or `agents:edit[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-agents',\n resourceId: storedAgentId,\n action: 'edit',\n record: existing,\n });\n\n // Reject oversized avatar images before writing to storage.\n validateMetadataAvatarUrl(metadata);\n\n // No owner = always public, regardless of what the client sent.\n const callerAuthorId = getCallerAuthorId(requestContext) ?? undefined;\n const resolvedVisibility = callerAuthorId ? visibility : visibility != null ? 'public' : undefined;\n\n // Model policy enforcement is intentionally not done on save: each UI\n // surface gates its own model picker via ModelPolicyProvider, and the\n // policy is surface-scoped (builder vs editor). Re-introducing a single\n // server-side check here would either over-enforce on the editor or\n // under-enforce on the builder until per-surface enforcement lands.\n\n // Resolve boolean browser shorthand from the UI\n const resolvedBrowser = await resolveBrowserField(browser, mastra);\n\n // For code-defined agents, strip fields the editor config does not allow\n // Studio to own. This keeps stored snapshots (and the per-entity files\n // they get persisted to) free of fields the server never reads back.\n let codeAgentForUpdate: { __getEditorConfig?: () => unknown; source?: string } | undefined;\n try {\n codeAgentForUpdate = mastra.getAgentById?.(storedAgentId) as typeof codeAgentForUpdate;\n } catch {\n codeAgentForUpdate = undefined;\n }\n if (codeAgentForUpdate?.source === 'code') {\n const ownership = getCodeAgentOwnership(codeAgentForUpdate.__getEditorConfig?.());\n if (ownership.ownsInstructions) {\n if (instructions !== undefined) {\n assertOwnedInstructionsNotEmpty(instructions);\n }\n } else {\n instructions = undefined;\n }\n if (!ownership.ownsTools && !ownership.ownsToolDescriptionsOnly) {\n tools = undefined;\n integrationTools = undefined;\n mcpClients = undefined;\n }\n }\n\n const mergedMetadata: Record<string, unknown> = { ...(existing.metadata ?? {}), ...(metadata ?? {}) };\n const scopedMetadata = scopeStoredResourceMetadata(mergedMetadata, scope);\n\n // Update the agent with both metadata-level and config-level fields\n // The storage layer handles separating these into agent-record updates vs new-version creation\n // Cast needed because Zod's passthrough() output types don't exactly match the handwritten TS interfaces\n const updatedAgent = await agentsStore.update({\n id: storedAgentId,\n authorId,\n metadata: scopedMetadata,\n visibility: resolvedVisibility,\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser: resolvedBrowser,\n requestContextSchema,\n } as StorageUpdateAgentInput);\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = {\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n toolProviders,\n mcpClients,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n skills,\n workspace,\n browser: resolvedBrowser,\n requestContextSchema,\n };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n const autoVersionResult = await handleAutoVersioning(\n agentsStore as unknown as VersionedStoreInterface,\n storedAgentId,\n 'agentId',\n AGENT_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedAgent,\n providedConfigFields,\n changeMessage ? { changeMessage } : undefined,\n );\n\n if (!autoVersionResult) {\n throw new Error('handleAutoVersioning returned undefined');\n }\n\n // In code mode, local saves should overwrite the most recent saved\n // snapshot rather than creating new draft versions on every keystroke\n // batch. Version history is intended to track commits, not raw saves.\n // We collapse the freshly created version onto the previous one by\n // deleting the prior latest version, leaving a single rolling snapshot.\n // When the user explicitly provides a changeMessage we treat that as a\n // commit and keep the new version as a discrete history entry.\n const isCodeSource = mastra.getEditor?.()?.getSource?.() === 'code';\n if (isCodeSource && autoVersionResult.versionCreated && !changeMessage) {\n const { versions } = await agentsStore.listVersions({ agentId: storedAgentId, perPage: 2 });\n const previousVersion = versions[1];\n const isPublishedVersion = previousVersion?.id === existing.activeVersionId;\n if (previousVersion && !isPublishedVersion) {\n await agentsStore.deleteVersion(previousVersion.id);\n }\n }\n\n // Publication remains opt-in so Classic Studio can save drafts without moving the active version,\n // while Agent Builder can preserve immediate runtime updates by sending autoPublish: true.\n // This flag is a bridge until version creation and publication move to dedicated APIs.\n if (autoVersionResult.versionCreated && autoPublish) {\n const { versions } = await agentsStore.listVersions({ agentId: storedAgentId, perPage: 1 });\n const latestVersion = versions[0];\n if (latestVersion) {\n await agentsStore.update({\n id: storedAgentId,\n activeVersionId: latestVersion.id,\n });\n }\n }\n\n // Clear the cached agent instance so the next request gets the updated config\n const editor = mastra.getEditor();\n if (editor) {\n editor.agent.clearCache(storedAgentId);\n }\n\n // Return the resolved agent with the latest version\n const resolved = await agentsStore.getByIdResolved(storedAgentId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated agent' });\n }\n\n return enrichOrStripFavorites(mastra, requestContext, 'agent', resolved);\n } catch (error) {\n return handleError(error, 'Error updating stored agent');\n }\n },\n});\n\n/**\n * DELETE /stored/agents/:storedAgentId - Delete a stored agent\n */\nexport const DELETE_STORED_AGENT_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n responseSchema: deleteStoredAgentResponseSchema,\n summary: 'Delete stored agent',\n description: 'Deletes an agent from storage by its unique identifier',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent exists\n const existing = await agentsStore.getById(storedAgentId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n assertStoredResourceScope(existing, await getStoredResourceScope(mastra, requestContext));\n\n // Throws 404 if the caller isn't the owner, admin, or `agents:delete[:<id>]` holder.\n assertWriteAccess({\n requestContext,\n resource: 'stored-agents',\n resourceId: storedAgentId,\n action: 'delete',\n record: existing,\n });\n\n await agentsStore.delete(storedAgentId);\n\n // Cascade: drop any favorite rows referencing this agent so they don't\n // resurrect if the same id is reused. Failure must not abort the delete.\n try {\n const favoritesStore = await storage.getStore('favorites');\n await favoritesStore?.deleteFavoritesForEntity({ entityType: 'agent', entityId: storedAgentId });\n } catch (cascadeError) {\n mastra\n .getLogger?.()\n ?.warn?.('Failed to cascade-delete favorites for agent', { storedAgentId, error: cascadeError });\n }\n\n // Clear the cached agent instance\n mastra.getEditor()?.agent.clearCache(storedAgentId);\n\n return { success: true, message: `Agent ${storedAgentId} deleted successfully` };\n } catch (error) {\n return handleError(error, 'Error deleting stored agent');\n }\n },\n});\n\n/**\n * GET /stored/agents/:storedAgentId/dependents - List agents that reference\n * the target agent as a sub-agent.\n *\n * Returns `dependents` for caller-visible references (named) and `hiddenCount`\n * for references from agents the caller can't read (count only, no leak).\n * `hiddenCount` is only populated when the target is public — private targets\n * can't legitimately be referenced from other workspaces.\n */\nexport const GET_STORED_AGENT_DEPENDENTS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents/:storedAgentId/dependents',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n responseSchema: getStoredAgentDependentsResponseSchema,\n summary: 'List dependents of a stored agent',\n description:\n 'Returns agents that reference the target as a sub-agent. Used to warn before deleting or unsharing. Caller-readable references appear in `dependents` (id + name); cross-workspace references the caller cannot read are aggregated in `hiddenCount` and only surfaced when the target is public.',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, storedAgentId }) => {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Mirrors GET: 404 if the caller can't read the target. Prevents the\n // dependents endpoint from being usable as a sub-agent reference oracle.\n const target = await agentsStore.getById(storedAgentId);\n if (!target) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n assertStoredResourceScope(target, await getStoredResourceScope(mastra, requestContext));\n assertReadAccess({ requestContext, resource: 'stored-agents', resourceId: storedAgentId, record: target });\n\n // Full scan (no authorId filter) so a public target can detect\n // cross-workspace private dependents. We split into caller-visible\n // `dependents` vs `hiddenCount` so private agents owned by other users\n // are counted but never named.\n const filter = resolveAuthorFilter({ requestContext, resource: 'stored-agents' });\n const all = await agentsStore.listResolved({\n perPage: false,\n status: 'published',\n });\n\n const targetIsPublic = (target as { visibility?: string }).visibility === 'public';\n\n // Caller-readable dependents are surfaced by name (the caller already\n // has access to them). Cross-workspace dependents the caller cannot\n // read are aggregated into hiddenCount, only when the target is public.\n const dependents: Array<{ id: string; name: string }> = [];\n let hiddenCount = 0;\n\n for (const record of all.agents) {\n if (record.id === storedAgentId) continue;\n if (!referencesTarget((record as { agents?: unknown }).agents, storedAgentId)) continue;\n\n if (matchesAuthorFilter(record, filter)) {\n dependents.push({\n id: record.id,\n name: (record as { name?: string }).name ?? record.id,\n });\n } else if (targetIsPublic) {\n hiddenCount += 1;\n }\n // Private target: drop hidden refs silently — they shouldn't exist\n // and surfacing the count would leak cross-workspace structure.\n }\n\n return { dependents, hiddenCount };\n } catch (error) {\n return handleError(error, 'Error listing stored agent dependents');\n }\n },\n});\n\n/**\n * Does the resolved `agents` snapshot field reference `targetId`?\n * The field can be either a static `Record<string, toolConfig>` or an array of\n * conditional variants (`{ value, rules? }`). Match if any variant's value\n * (or the static object) contains a matching key.\n */\nfunction referencesTarget(subAgents: unknown, targetId: string): boolean {\n if (!subAgents) return false;\n if (Array.isArray(subAgents)) {\n return subAgents.some(variant => {\n const value = (variant as { value?: unknown })?.value;\n return Boolean(value && typeof value === 'object' && Object.prototype.hasOwnProperty.call(value, targetId));\n });\n }\n if (typeof subAgents === 'object') {\n return Object.prototype.hasOwnProperty.call(subAgents, targetId);\n }\n return false;\n}\n\n/**\n * POST /stored/agents/preview-instructions - Preview resolved instructions\n */\nexport const PREVIEW_INSTRUCTIONS_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents/preview-instructions',\n responseType: 'json',\n bodySchema: previewInstructionsBodySchema,\n responseSchema: previewInstructionsResponseSchema,\n summary: 'Preview resolved instructions',\n description:\n 'Resolves an array of instruction blocks against a request context, evaluating rules, fetching prompt block references, and rendering template variables. Returns the final concatenated instruction string.',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, blocks, context }) => {\n try {\n const editor = mastra.getEditor();\n if (!editor) {\n throw new HTTPException(500, { message: 'Editor is not configured' });\n }\n\n const result = await editor.prompt.preview(blocks, context ?? {});\n\n return { result };\n } catch (error) {\n return handleError(error, 'Error previewing instructions');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgDA,eAAe,oBAAoB,SAAkB,QAAyD;CAC5G,IAA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kB,OAAgC,QAAQ,aAAa,GAAG;IAE/E,IAAI,oBAAoB,QAAQ,MAAM,GACpC,WAAW,KAAK;KACd,IAAI,OAAO;KACX,MAAO,OAA6B,QAAQ,OAAO;IACrD,CAAC;SACI,IAAI,gBACT,eAAe;GAInB;GAEA,OAAO;IAAE;IAAY;GAAY;EACnC,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,uCAAuC;EACnE;CACF;AACF,CAAC;;;;;;;AAQD,SAAS,iBAAiB,WAAoB,UAA2B;CACvE,IAAI,CAAC,WAAW,OAAO;CACvB,IAAI,MAAM,QAAQ,SAAS,GACzB,OAAO,UAAU,MAAK,YAAW;EAC/B,MAAM,QAAS,SAAiC;EAChD,OAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,OAAO,UAAU,eAAe,KAAK,OAAO,QAAQ,CAAC;CAC5G,CAAC;CAEH,IAAI,OAAO,cAAc,UACvB,OAAO,OAAO,UAAU,eAAe,KAAK,WAAW,QAAQ;CAEjE,OAAO;AACT;;;;AAKA,MAAa,6BAA6B,YAAY;CACpD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,YAAY;CACZ,gBAAgB;CAChB,SAAS;CACT,aACE;CACF,MAAM,CAAC,eAAe;CACtB,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,QAAQ,cAAc;EAC9C,IAAI;GACF,MAAM,SAAS,OAAO,UAAU;GAChC,IAAI,CAAC,QACH,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;GAKtE,OAAO,EAAE,QAAA,MAFY,OAAO,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC,EAEhD;EAClB,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,+BAA+B;EAC3D;CACF;AACF,CAAC"}
@@ -5,7 +5,7 @@ const require_route_builder = require("../../route-builder-s_6tzrpE.cjs");
5
5
  const require_utils = require("../../utils-RHPgZGTu.cjs");
6
6
  const require_server_handlers_error = require("./error.cjs");
7
7
  const require_server_handlers_version_helpers = require("./version-helpers.cjs");
8
- const require_stored_scorers = require("../../stored-scorers-C4vBDgJi.cjs");
8
+ const require_stored_scorers = require("../../stored-scorers-CMHNFquG.cjs");
9
9
  //#region src/server/handlers/stored-scorers.ts
10
10
  const SCORER_SNAPSHOT_CONFIG_FIELDS = [
11
11
  "name",
@@ -4,7 +4,7 @@ import { n as createRoute } from "../../route-builder-D04LGdMT.js";
4
4
  import { c as toSlug, i as getStoredResourceScope, n as assertStoredResourceScope, s as scopeStoredResourceMetadata } from "../../utils-WZw3YUlC.js";
5
5
  import { handleError } from "./error.js";
6
6
  import { handleAutoVersioning } from "./version-helpers.js";
7
- import { a as listStoredScorersQuerySchema, i as getStoredScorerResponseSchema, l as updateStoredScorerBodySchema, n as createStoredScorerResponseSchema, o as listStoredScorersResponseSchema, r as deleteStoredScorerResponseSchema, s as storedScorerIdPathParams, t as createStoredScorerBodySchema, u as updateStoredScorerResponseSchema } from "../../stored-scorers-n2NdbB_a.js";
7
+ import { a as listStoredScorersQuerySchema, i as getStoredScorerResponseSchema, l as updateStoredScorerBodySchema, n as createStoredScorerResponseSchema, o as listStoredScorersResponseSchema, r as deleteStoredScorerResponseSchema, s as storedScorerIdPathParams, t as createStoredScorerBodySchema, u as updateStoredScorerResponseSchema } from "../../stored-scorers-0eeoiKkg.js";
8
8
  //#region src/server/handlers/stored-scorers.ts
9
9
  const SCORER_SNAPSHOT_CONFIG_FIELDS = [
10
10
  "name",
@@ -4,7 +4,7 @@ const require_route_builder = require("../../route-builder-s_6tzrpE.cjs");
4
4
  const require_utils = require("../../utils-RHPgZGTu.cjs");
5
5
  const require_server_handlers_error = require("./error.cjs");
6
6
  const require_server_handlers_authorship = require("./authorship.cjs");
7
- const require_editor_builder = require("../../editor-builder-BZlMvxNh.cjs");
7
+ const require_editor_builder = require("../../editor-builder-CGMd1H1a.cjs");
8
8
  const require_favorites = require("../../favorites-D1-AzGsK.cjs");
9
9
  const require_stored_skills = require("../../stored-skills-CgwoCNNV.cjs");
10
10
  //#region src/server/handlers/stored-skill-favorites.ts
@@ -3,7 +3,7 @@ import { n as createRoute } from "../../route-builder-D04LGdMT.js";
3
3
  import { i as getStoredResourceScope, n as assertStoredResourceScope } from "../../utils-WZw3YUlC.js";
4
4
  import { handleError } from "./error.js";
5
5
  import { assertReadAccess, getCallerAuthorId } from "./authorship.js";
6
- import { a as requireBuilderFeature } from "../../editor-builder-CcPPiRKU.js";
6
+ import { a as requireBuilderFeature } from "../../editor-builder-B_8M84Hb.js";
7
7
  import { t as favoriteToggleResponseSchema } from "../../favorites-DWDyKxts.js";
8
8
  import { p as storedSkillIdPathParams } from "../../stored-skills-B_aAMn5W.js";
9
9
  //#region src/server/handlers/stored-skill-favorites.ts
@@ -4,7 +4,7 @@ const require_route_builder = require("../../route-builder-s_6tzrpE.cjs");
4
4
  const require_utils = require("../../utils-RHPgZGTu.cjs");
5
5
  const require_server_handlers_error = require("./error.cjs");
6
6
  const require_server_handlers_authorship = require("./authorship.cjs");
7
- const require_editor_builder = require("../../editor-builder-BZlMvxNh.cjs");
7
+ const require_editor_builder = require("../../editor-builder-CGMd1H1a.cjs");
8
8
  const require_server_handlers_favorites_enrichment = require("./favorites-enrichment.cjs");
9
9
  const require_stored_skills = require("../../stored-skills-CgwoCNNV.cjs");
10
10
  let _mastra_core_workspace = require("@mastra/core/workspace");
@@ -3,7 +3,7 @@ import { n as createRoute } from "../../route-builder-D04LGdMT.js";
3
3
  import { c as toSlug, i as getStoredResourceScope, n as assertStoredResourceScope, s as scopeStoredResourceMetadata } from "../../utils-WZw3YUlC.js";
4
4
  import { handleError } from "./error.js";
5
5
  import { assertReadAccess, assertWriteAccess, getCallerAuthorId, matchesAuthorFilter, resolveAuthorFilter } from "./authorship.js";
6
- import { i as isBuilderFeatureEnabled } from "../../editor-builder-CcPPiRKU.js";
6
+ import { i as isBuilderFeatureEnabled } from "../../editor-builder-B_8M84Hb.js";
7
7
  import { enrichOrStripFavorites, prepareFavoritesEnrichment, stripFavoriteFields } from "./favorites-enrichment.js";
8
8
  import { a as deleteStoredSkillResponseSchema, c as listStoredSkillsResponseSchema, g as updateStoredSkillResponseSchema, h as updateStoredSkillBodySchema, i as createStoredSkillResponseSchema, l as publishStoredSkillBodySchema, o as getStoredSkillResponseSchema, p as storedSkillIdPathParams, r as createStoredSkillBodySchema, s as listStoredSkillsQuerySchema, u as publishStoredSkillResponseSchema } from "../../stored-skills-B_aAMn5W.js";
9
9
  import { LocalSkillSource } from "@mastra/core/workspace";
@@ -86,7 +86,7 @@ const GET_API_SCHEMA_ROUTE = require_route_builder.createRoute({
86
86
  tags: ["System"],
87
87
  requiresAuth: true,
88
88
  handler: async () => {
89
- const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-CgAqXSXH.cjs"));
89
+ const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-DdFxt0Xu.cjs"));
90
90
  return buildApiSchemaManifest();
91
91
  }
92
92
  });
@@ -85,7 +85,7 @@ const GET_API_SCHEMA_ROUTE = createRoute({
85
85
  tags: ["System"],
86
86
  requiresAuth: true,
87
87
  handler: async () => {
88
- const { buildApiSchemaManifest } = await import("../../api-schema-manifest-CQE7b1pm.js");
88
+ const { buildApiSchemaManifest } = await import("../../api-schema-manifest-Tf3jW9LW.js");
89
89
  return buildApiSchemaManifest();
90
90
  }
91
91
  });
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
3
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
4
4
  const require_common = require("../../common-spbwhiWS.cjs");
5
- const require_agents = require("../../agents-DtRakHQJ.cjs");
5
+ const require_agents = require("../../agents-B9ofSVSn.cjs");
6
6
  const require_schema_Ba6HLBWs = require("../../schema-Ba6HLBWs-DrPMJ7GF.cjs");
7
7
  const require_route_builder = require("../../route-builder-s_6tzrpE.cjs");
8
8
  require("../../schema-3g7n4JAz.cjs");
@@ -1,7 +1,7 @@
1
1
  import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
2
2
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
3
  import { o as optionalRunIdSchema } from "../../common-CPNOpqxA.js";
4
- import { H as serializedToolSchema, J as toolIdPathParams, S as listToolsResponseSchema, _ as executeToolResponseSchema, g as executeToolContextBodySchema, h as executeToolBodySchema, s as agentToolPathParams } from "../../agents-blOvvut1.js";
4
+ import { H as serializedToolSchema, J as toolIdPathParams, S as listToolsResponseSchema, _ as executeToolResponseSchema, g as executeToolContextBodySchema, h as executeToolBodySchema, s as agentToolPathParams } from "../../agents-DD4PJgsF.js";
5
5
  import { n as standardSchemaToJSONSchema, r as toStandardSchema } from "../../schema-Ba6HLBWs-DmI3p9Jn.js";
6
6
  import { n as createRoute } from "../../route-builder-D04LGdMT.js";
7
7
  import "../../schema-DrqevtFK.js";
@@ -3,7 +3,7 @@ const require_rolldown_runtime = require("../../rolldown-runtime-CVvi-lCc.cjs");
3
3
  const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
4
4
  const require_common = require("../../common-spbwhiWS.cjs");
5
5
  const require_workflows = require("../../workflows-Bxy77CRQ.cjs");
6
- const require_agents = require("../../agents-DtRakHQJ.cjs");
6
+ const require_agents = require("../../agents-B9ofSVSn.cjs");
7
7
  const require_route_builder = require("../../route-builder-s_6tzrpE.cjs");
8
8
  const require_utils = require("../../utils-RHPgZGTu.cjs");
9
9
  const require_server_handlers_error = require("./error.cjs");
@@ -2,7 +2,7 @@ import { n as __exportAll } from "../../rolldown-runtime-DuvcJU0W.js";
2
2
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
3
3
  import { l as runIdSchema, o as optionalRunIdSchema } from "../../common-CPNOpqxA.js";
4
4
  import { _ as workflowRunPathParams, a as observeWorkflowQuerySchema, b as workflowRunsResponseSchema, d as streamWorkflowBodySchema, f as timeTravelBodySchema, g as workflowInfoSchema, h as workflowIdPathParams, i as listWorkflowsResponseSchema, l as startAsyncWorkflowBodySchema, m as workflowExecutionResultSchema, n as createWorkflowRunResponseSchema, o as restartBodySchema, p as workflowControlResponseSchema, r as listWorkflowRunsQuerySchema, s as resumeBodySchema, t as createWorkflowRunBodySchema, v as workflowRunResultQuerySchema, y as workflowRunResultSchema } from "../../workflows-CiUa_yVU.js";
5
- import { W as streamResponseSchema } from "../../agents-blOvvut1.js";
5
+ import { W as streamResponseSchema } from "../../agents-DD4PJgsF.js";
6
6
  import { n as createRoute } from "../../route-builder-D04LGdMT.js";
7
7
  import { a as getWorkflowInfo, t as WorkflowRegistry } from "../../utils-WZw3YUlC.js";
8
8
  import { handleError } from "./error.js";
@@ -3,7 +3,7 @@ const require_server_handlers_error = require("./handlers/error.cjs");
3
3
  const require_server_handlers_workflows = require("./handlers/workflows.cjs");
4
4
  const require_server_handlers_agent_builder = require("./handlers/agent-builder.cjs");
5
5
  const require_server_handlers_agents = require("./handlers/agents.cjs");
6
- const require_a2a = require("../a2a-BpnLfSs-.cjs");
6
+ const require_a2a = require("../a2a-CSvyekNE.cjs");
7
7
  const require_server_handlers_conversations = require("./handlers/conversations.cjs");
8
8
  const require_server_handlers_logs = require("./handlers/logs.cjs");
9
9
  const require_server_handlers_mcp = require("./handlers/mcp.cjs");
@@ -2,7 +2,7 @@ import { formatZodError, isZodError } from "./handlers/error.js";
2
2
  import { t as workflows_exports } from "./handlers/workflows.js";
3
3
  import { t as agent_builder_exports } from "./handlers/agent-builder.js";
4
4
  import { t as agents_exports } from "./handlers/agents.js";
5
- import { r as a2a_exports } from "../a2a-BuHK-WlT.js";
5
+ import { r as a2a_exports } from "../a2a-BPgUo8V4.js";
6
6
  import { t as conversations_exports } from "./handlers/conversations.js";
7
7
  import { t as logs_exports } from "./handlers/logs.js";
8
8
  import { t as mcp_exports } from "./handlers/mcp.js";
@@ -45,8 +45,8 @@ export declare const agentIdPathParams: z.ZodObject<{
45
45
  }, z.core.$strip>;
46
46
  /**
47
47
  * Query params for GET /agents/:agentId — controls which stored config version is used for overrides.
48
- * Use either `status` or `versionId`, not both.
49
- * - `status` — 'draft' (latest version, default) or 'published' (active published version).
48
+ * When `status` and `versionId` are both provided, `versionId` takes precedence.
49
+ * - `status` — 'draft' (latest version) or 'published' (active published version, default).
50
50
  * - `versionId` — Resolve with a specific version ID.
51
51
  */
52
52
  export declare const agentVersionQuerySchema: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/server/schemas/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,6BAA6B,EAC7B,aAAa,EACb,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B;;;;GAIG;AACH;;;;GAIG;AACH,KAAK,gBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAE3E;;;;GAIG;AACH,KAAK,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,EAAE,CAAC;AAE/F,KAAK,aAAa,GAAG;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB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js");
5
5
  const require_default_options = require("../../default-options-BcPyp2Gx.cjs");
6
6
  const require_routes = require("../../routes-BKUF5ZHA.cjs");
7
- const require_agents = require("../../agents-DtRakHQJ.cjs");
8
- const require_stored_agents = require("../../stored-agents-D3ZWjjQo.cjs");
7
+ const require_agents = require("../../agents-B9ofSVSn.cjs");
8
+ const require_stored_agents = require("../../stored-agents-DR_L2wPJ.cjs");
9
9
  const require_rule_group = require("../../rule-group-Hyn4rN52.cjs");
10
10
  const require_stored_workspaces = require("../../stored-workspaces-CbJQaFuP.cjs");
11
11
  const require_tool_providers = require("../../tool-providers-DFQkhO4R.cjs");
@@ -20,17 +20,17 @@ const require_mcp = require("../../mcp-DusNUBdz.cjs");
20
20
  const require_scores = require("../../scores-Bm_sUKY1.cjs");
21
21
  const require_vectors = require("../../vectors-Cj-SPxOy.cjs");
22
22
  const require_version_common = require("../../version-common-CEBQY7M8.cjs");
23
- const require_agent_versions = require("../../agent-versions-CeW6txxf.cjs");
23
+ const require_agent_versions = require("../../agent-versions-DhkWMz0z.cjs");
24
24
  const require_datasets = require("../../datasets-BnzmEeJy.cjs");
25
- const require_editor_builder = require("../../editor-builder-Crs4928Q.cjs");
25
+ const require_editor_builder = require("../../editor-builder-DZRQf2UD.cjs");
26
26
  const require_mcp_client_versions = require("../../mcp-client-versions-Db71zP8j.cjs");
27
27
  const require_processor_providers = require("../../processor-providers-DGBNerTY.cjs");
28
28
  const require_processors = require("../../processors-BirBp7z3.cjs");
29
29
  const require_prompt_block_versions = require("../../prompt-block-versions-Bl3RmkTE.cjs");
30
- const require_scorer_versions = require("../../scorer-versions-BaxgEGNa.cjs");
30
+ const require_scorer_versions = require("../../scorer-versions-DX81YG5X.cjs");
31
31
  const require_stored_mcp_clients = require("../../stored-mcp-clients-CwA5_nZ9.cjs");
32
32
  const require_stored_prompt_blocks = require("../../stored-prompt-blocks-DR_Wts8r.cjs");
33
- const require_stored_scorers = require("../../stored-scorers-C4vBDgJi.cjs");
33
+ const require_stored_scorers = require("../../stored-scorers-CMHNFquG.cjs");
34
34
  const require_stored_skills = require("../../stored-skills-CgwoCNNV.cjs");
35
35
  const require_system = require("../../system-wl_uZdyz.cjs");
36
36
  exports.SKILL_ORIGIN_METADATA_KEY = require_stored_skills.SKILL_ORIGIN_METADATA_KEY;