@mastra/server 1.75.0-alpha.3 → 1.75.0-alpha.5

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 (121) hide show
  1. package/dist/{agent-versions-RvvNdlZk.cjs → agent-versions-CivkX9fT.cjs} +2 -2
  2. package/dist/{agent-versions-RvvNdlZk.cjs.map → agent-versions-CivkX9fT.cjs.map} +1 -1
  3. package/dist/{agent-versions-CTAEDQuT.js → agent-versions-oCebJ7rc.js} +2 -2
  4. package/dist/{agent-versions-CTAEDQuT.js.map → agent-versions-oCebJ7rc.js.map} +1 -1
  5. package/dist/{api-schema-manifest-D9_jxxNw.cjs → api-schema-manifest-BKsEMyEs.cjs} +2 -2
  6. package/dist/{api-schema-manifest-D9_jxxNw.cjs.map → api-schema-manifest-BKsEMyEs.cjs.map} +1 -1
  7. package/dist/{api-schema-manifest-B0p6nxU1.js → api-schema-manifest-KsETdHDS.js} +2 -2
  8. package/dist/{api-schema-manifest-B0p6nxU1.js.map → api-schema-manifest-KsETdHDS.js.map} +1 -1
  9. package/dist/{channels-DJkXEpTr.cjs → channels-DUdpygCQ.cjs} +39 -1
  10. package/dist/channels-DUdpygCQ.cjs.map +1 -0
  11. package/dist/{channels-DzaCNtXe.js → channels-T1KaEfZX.js} +34 -2
  12. package/dist/channels-T1KaEfZX.js.map +1 -0
  13. package/dist/{dist-DgDFoIF5.cjs → dist-DRLe8Sd-.cjs} +24 -3
  14. package/dist/dist-DRLe8Sd-.cjs.map +1 -0
  15. package/dist/{dist-BFUX7iPi.js → dist-DWXEVDmb.js} +24 -3
  16. package/dist/dist-DWXEVDmb.js.map +1 -0
  17. package/dist/docs/SKILL.md +2 -2
  18. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  19. package/dist/docs/references/reference-observability-tracing-trace-query.md +65 -4
  20. package/dist/{observability-new-endpoints-lNC3o66-.js → observability-new-endpoints-DQuhr8aL.js} +114 -4
  21. package/dist/observability-new-endpoints-DQuhr8aL.js.map +1 -0
  22. package/dist/{observability-new-endpoints-7Zd6uEZf.cjs → observability-new-endpoints-Kphyk3do.cjs} +118 -2
  23. package/dist/observability-new-endpoints-Kphyk3do.cjs.map +1 -0
  24. package/dist/{routes-CJygX0-a.js → routes-B_ehFjzs.js} +5 -3
  25. package/dist/routes-B_ehFjzs.js.map +1 -0
  26. package/dist/{routes-BuiLQCOQ.cjs → routes-Op7uJGai.cjs} +5 -3
  27. package/dist/routes-Op7uJGai.cjs.map +1 -0
  28. package/dist/{scorer-versions-BfGNw7Wp.cjs → scorer-versions-B8q9-oF2.cjs} +2 -2
  29. package/dist/{scorer-versions-BfGNw7Wp.cjs.map → scorer-versions-B8q9-oF2.cjs.map} +1 -1
  30. package/dist/{scorer-versions-gXsdWw0V.js → scorer-versions-DGLHODqM.js} +2 -2
  31. package/dist/{scorer-versions-gXsdWw0V.js.map → scorer-versions-DGLHODqM.js.map} +1 -1
  32. package/dist/server/handlers/agent-builder.cjs +1 -1
  33. package/dist/server/handlers/agent-builder.js +1 -1
  34. package/dist/server/handlers/agent-versions.cjs +1 -1
  35. package/dist/server/handlers/agent-versions.d.ts +368 -0
  36. package/dist/server/handlers/agent-versions.d.ts.map +1 -1
  37. package/dist/server/handlers/agent-versions.js +1 -1
  38. package/dist/server/handlers/agents.cjs +1 -1
  39. package/dist/server/handlers/agents.d.ts +92 -0
  40. package/dist/server/handlers/agents.d.ts.map +1 -1
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/channels.cjs +2 -1
  43. package/dist/server/handlers/channels.d.ts +53 -0
  44. package/dist/server/handlers/channels.d.ts.map +1 -1
  45. package/dist/server/handlers/channels.js +2 -2
  46. package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
  47. package/dist/server/handlers/observability-new-endpoints.d.ts +260 -0
  48. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  49. package/dist/server/handlers/observability-new-endpoints.js +2 -2
  50. package/dist/server/handlers/observability-shared.cjs +19 -0
  51. package/dist/server/handlers/observability-shared.cjs.map +1 -1
  52. package/dist/server/handlers/observability-shared.d.ts +10 -0
  53. package/dist/server/handlers/observability-shared.d.ts.map +1 -1
  54. package/dist/server/handlers/observability-shared.js +18 -1
  55. package/dist/server/handlers/observability-shared.js.map +1 -1
  56. package/dist/server/handlers/observability.cjs +3 -1
  57. package/dist/server/handlers/observability.cjs.map +1 -1
  58. package/dist/server/handlers/observability.js +3 -2
  59. package/dist/server/handlers/observability.js.map +1 -1
  60. package/dist/server/handlers/scorer-versions.cjs +1 -1
  61. package/dist/server/handlers/scorer-versions.js +1 -1
  62. package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
  63. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  64. package/dist/server/handlers/stored-agents.cjs +1 -1
  65. package/dist/server/handlers/stored-agents.d.ts +460 -0
  66. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  67. package/dist/server/handlers/stored-agents.js +1 -1
  68. package/dist/server/handlers/stored-scorers.cjs +1 -1
  69. package/dist/server/handlers/stored-scorers.js +1 -1
  70. package/dist/server/handlers/system.cjs +2 -2
  71. package/dist/server/handlers/system.d.ts +2 -0
  72. package/dist/server/handlers/system.d.ts.map +1 -1
  73. package/dist/server/handlers/system.js +2 -2
  74. package/dist/server/handlers/tool-providers.cjs +2 -1
  75. package/dist/server/handlers/tool-providers.cjs.map +1 -1
  76. package/dist/server/handlers/tool-providers.d.ts.map +1 -1
  77. package/dist/server/handlers/tool-providers.js +2 -1
  78. package/dist/server/handlers/tool-providers.js.map +1 -1
  79. package/dist/server/schemas/agent-versions.d.ts +350 -0
  80. package/dist/server/schemas/agent-versions.d.ts.map +1 -1
  81. package/dist/server/schemas/channels.d.ts +11 -0
  82. package/dist/server/schemas/channels.d.ts.map +1 -1
  83. package/dist/server/schemas/index.cjs +5 -5
  84. package/dist/server/schemas/index.js +5 -5
  85. package/dist/server/schemas/stored-agents.d.ts +989 -149
  86. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  87. package/dist/server/schemas/system.d.ts +2 -0
  88. package/dist/server/schemas/system.d.ts.map +1 -1
  89. package/dist/server/server-adapter/index.cjs +1 -1
  90. package/dist/server/server-adapter/index.js +1 -1
  91. package/dist/server/server-adapter/routes/channels.d.ts +43 -0
  92. package/dist/server/server-adapter/routes/channels.d.ts.map +1 -1
  93. package/dist/server/server-adapter/routes/observability.d.ts +129 -0
  94. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  95. package/dist/server/server-adapter/routes/system.d.ts +2 -0
  96. package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
  97. package/dist/{stored-agents-ts0bWw8l.js → stored-agents-BzIvRgtz.js} +3 -2
  98. package/dist/stored-agents-BzIvRgtz.js.map +1 -0
  99. package/dist/{stored-agents-Dmsel7ey.cjs → stored-agents-DpY3ssfx.cjs} +3 -2
  100. package/dist/stored-agents-DpY3ssfx.cjs.map +1 -0
  101. package/dist/{stored-scorers-DySg7-qS.js → stored-scorers-CAt8hFj2.js} +2 -2
  102. package/dist/{stored-scorers-DySg7-qS.js.map → stored-scorers-CAt8hFj2.js.map} +1 -1
  103. package/dist/{stored-scorers-DoW6lYh8.cjs → stored-scorers-DyeqU2Rj.cjs} +2 -2
  104. package/dist/{stored-scorers-DoW6lYh8.cjs.map → stored-scorers-DyeqU2Rj.cjs.map} +1 -1
  105. package/dist/{system-CskEzH1o.cjs → system-Be5n6H_z.cjs} +2 -1
  106. package/dist/system-Be5n6H_z.cjs.map +1 -0
  107. package/dist/{system-6qFm79mm.js → system-BtGAJr9R.js} +2 -1
  108. package/dist/system-BtGAJr9R.js.map +1 -0
  109. package/package.json +6 -6
  110. package/dist/channels-DJkXEpTr.cjs.map +0 -1
  111. package/dist/channels-DzaCNtXe.js.map +0 -1
  112. package/dist/dist-BFUX7iPi.js.map +0 -1
  113. package/dist/dist-DgDFoIF5.cjs.map +0 -1
  114. package/dist/observability-new-endpoints-7Zd6uEZf.cjs.map +0 -1
  115. package/dist/observability-new-endpoints-lNC3o66-.js.map +0 -1
  116. package/dist/routes-BuiLQCOQ.cjs.map +0 -1
  117. package/dist/routes-CJygX0-a.js.map +0 -1
  118. package/dist/stored-agents-Dmsel7ey.cjs.map +0 -1
  119. package/dist/stored-agents-ts0bWw8l.js.map +0 -1
  120. package/dist/system-6qFm79mm.js.map +0 -1
  121. package/dist/system-CskEzH1o.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  const require_default_options = require("./default-options-C7tykjLq.cjs");
2
- const require_stored_agents = require("./stored-agents-Dmsel7ey.cjs");
2
+ const require_stored_agents = require("./stored-agents-DpY3ssfx.cjs");
3
3
  const require_version_common = require("./version-common-Bu42Y2QN.cjs");
4
4
  let zod_v4 = require("zod/v4");
5
5
  //#region src/server/schemas/agent-versions.ts
@@ -118,4 +118,4 @@ Object.defineProperty(exports, "versionIdPathParams", {
118
118
  }
119
119
  });
120
120
 
121
- //# sourceMappingURL=agent-versions-RvvNdlZk.cjs.map
121
+ //# sourceMappingURL=agent-versions-CivkX9fT.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-versions-RvvNdlZk.cjs","names":["z","toolConfigSchema","instructionsSchema","conditionalFieldSchema","modelConfigSchema","toolsConfigSchema","defaultOptionsSchema","storedProcessorGraphSchema","storedMemoryRefSchema","scorerConfigSchema","createListVersionsResponseSchema","createCompareVersionsResponseSchema"],"sources":["../src/server/schemas/agent-versions.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { defaultOptionsSchema } from './default-options';\nimport { storedMemoryRefSchema } from './memory-config';\nimport {\n scorerConfigSchema,\n instructionsSchema,\n conditionalFieldSchema,\n modelConfigSchema,\n toolConfigSchema,\n toolsConfigSchema,\n storedProcessorGraphSchema,\n} from './stored-agents';\nimport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n createListVersionsResponseSchema,\n createCompareVersionsResponseSchema,\n} from './version-common';\n\nconst mcpClientToolsConfigSchema = z.object({\n tools: z.record(z.string(), toolConfigSchema).optional(),\n});\n\n// Re-export shared schemas for backwards compat\nexport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n};\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\n/**\n * Path parameters for agent version routes\n */\nexport const agentVersionPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n});\n\n/**\n * Path parameters for specific version routes\n */\nexport const versionIdPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n versionId: z.string().describe('Unique identifier for the version (UUID)'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\n/**\n * Agent version object schema (full response)\n * Config fields are top-level on the version (no nested snapshot object).\n * Extends StorageAgentSnapshotType fields.\n */\nexport const agentVersionSchema = z.object({\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n // Top-level config fields (from StorageAgentSnapshotType)\n name: z.string().describe('Name of the agent'),\n description: z.string().optional().describe('Description of the agent'),\n instructions: instructionsSchema,\n model: conditionalFieldSchema(modelConfigSchema).describe(\n 'Model configuration — static value or array of conditional variants',\n ),\n tools: conditionalFieldSchema(toolsConfigSchema)\n .optional()\n .describe('Tool keys mapped to per-tool config — static or conditional'),\n defaultOptions: conditionalFieldSchema(defaultOptionsSchema)\n .optional()\n .describe('Default options for generate/stream calls — static or conditional'),\n workflows: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Workflow keys with optional per-workflow config — static or conditional'),\n agents: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Agent keys with optional per-agent config — static or conditional'),\n integrationTools: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of tool provider IDs to their tool configurations — static or conditional'),\n mcpClients: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of stored MCP client IDs to their tool configurations — static or conditional'),\n inputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Input processor graph — static or conditional'),\n outputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Output processor graph — static or conditional'),\n memory: conditionalFieldSchema(storedMemoryRefSchema)\n .optional()\n .describe('Memory: registered memory reference or inline config — static or conditional'),\n scorers: conditionalFieldSchema(z.record(z.string(), scorerConfigSchema))\n .optional()\n .describe('Scorer keys with optional sampling config — static or conditional'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining valid request context variables'),\n // Version metadata fields\n changedFields: z.array(z.string()).optional().describe('Array of field names that changed from the previous version'),\n changeMessage: z.string().optional().describe('Optional message describing the changes'),\n createdAt: z.coerce.date().describe('When this version was created'),\n});\n\n/**\n * Response for GET /stored/agents/:agentId/versions\n */\nexport const listVersionsResponseSchema = createListVersionsResponseSchema(agentVersionSchema);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/:versionId\n */\nexport const getVersionResponseSchema = agentVersionSchema;\n\n/**\n * Response for POST /stored/agents/:agentId/versions\n */\nexport const createVersionResponseSchema = agentVersionSchema.partial().merge(\n z.object({\n // These fields are always present in a version response\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n createdAt: z.coerce.date().describe('When this version was created'),\n }),\n);\n\n/**\n * Response for POST /stored/agents/:agentId/versions/:versionId/restore\n */\nexport const restoreVersionResponseSchema = agentVersionSchema.describe(\n 'The newly created version from the restored configuration',\n);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/compare\n */\nexport const compareVersionsResponseSchema: ReturnType<\n typeof createCompareVersionsResponseSchema<type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WA,OAAAA,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC;;;;AAKD,MAAa,6BAA6BU,uBAAAA,iCAAiC,kBAAkB;;;;AAK7F,MAAa,2BAA2B;;;;AAKxC,MAAa,8BAA8B,mBAAmB,QAAQ,CAAC,CAAC,MACtEV,OAAAA,EAAE,OAAO;CAEP,IAAIA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAClE,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,yCAAyC;CACtE,eAAeA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAC7E,WAAWA,OAAAA,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC,CACH;;;;AAKA,MAAa,+BAA+B,mBAAmB,SAC7D,2DACF;;;;AAKA,MAAa,gCAETW,uBAAAA,oCAAoC,kBAAkB"}
1
+ {"version":3,"file":"agent-versions-CivkX9fT.cjs","names":["z","toolConfigSchema","instructionsSchema","conditionalFieldSchema","modelConfigSchema","toolsConfigSchema","defaultOptionsSchema","storedProcessorGraphSchema","storedMemoryRefSchema","scorerConfigSchema","createListVersionsResponseSchema","createCompareVersionsResponseSchema"],"sources":["../src/server/schemas/agent-versions.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { defaultOptionsSchema } from './default-options';\nimport { storedMemoryRefSchema } from './memory-config';\nimport {\n scorerConfigSchema,\n instructionsSchema,\n conditionalFieldSchema,\n modelConfigSchema,\n toolConfigSchema,\n toolsConfigSchema,\n storedProcessorGraphSchema,\n} from './stored-agents';\nimport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n createListVersionsResponseSchema,\n createCompareVersionsResponseSchema,\n} from './version-common';\n\nconst mcpClientToolsConfigSchema = z.object({\n tools: z.record(z.string(), toolConfigSchema).optional(),\n});\n\n// Re-export shared schemas for backwards compat\nexport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n};\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\n/**\n * Path parameters for agent version routes\n */\nexport const agentVersionPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n});\n\n/**\n * Path parameters for specific version routes\n */\nexport const versionIdPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n versionId: z.string().describe('Unique identifier for the version (UUID)'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\n/**\n * Agent version object schema (full response)\n * Config fields are top-level on the version (no nested snapshot object).\n * Extends StorageAgentSnapshotType fields.\n */\nexport const agentVersionSchema = z.object({\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n // Top-level config fields (from StorageAgentSnapshotType)\n name: z.string().describe('Name of the agent'),\n description: z.string().optional().describe('Description of the agent'),\n instructions: instructionsSchema,\n model: conditionalFieldSchema(modelConfigSchema).describe(\n 'Model configuration — static value or array of conditional variants',\n ),\n tools: conditionalFieldSchema(toolsConfigSchema)\n .optional()\n .describe('Tool keys mapped to per-tool config — static or conditional'),\n defaultOptions: conditionalFieldSchema(defaultOptionsSchema)\n .optional()\n .describe('Default options for generate/stream calls — static or conditional'),\n workflows: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Workflow keys with optional per-workflow config — static or conditional'),\n agents: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Agent keys with optional per-agent config — static or conditional'),\n integrationTools: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of tool provider IDs to their tool configurations — static or conditional'),\n mcpClients: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of stored MCP client IDs to their tool configurations — static or conditional'),\n inputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Input processor graph — static or conditional'),\n outputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Output processor graph — static or conditional'),\n memory: conditionalFieldSchema(storedMemoryRefSchema)\n .optional()\n .describe('Memory: registered memory reference or inline config — static or conditional'),\n scorers: conditionalFieldSchema(z.record(z.string(), scorerConfigSchema))\n .optional()\n .describe('Scorer keys with optional sampling config — static or conditional'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining valid request context variables'),\n // Version metadata fields\n changedFields: z.array(z.string()).optional().describe('Array of field names that changed from the previous version'),\n changeMessage: z.string().optional().describe('Optional message describing the changes'),\n createdAt: z.coerce.date().describe('When this version was created'),\n});\n\n/**\n * Response for GET /stored/agents/:agentId/versions\n */\nexport const listVersionsResponseSchema = createListVersionsResponseSchema(agentVersionSchema);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/:versionId\n */\nexport const getVersionResponseSchema = agentVersionSchema;\n\n/**\n * Response for POST /stored/agents/:agentId/versions\n */\nexport const createVersionResponseSchema = agentVersionSchema.partial().merge(\n z.object({\n // These fields are always present in a version response\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n createdAt: z.coerce.date().describe('When this version was created'),\n }),\n);\n\n/**\n * Response for POST /stored/agents/:agentId/versions/:versionId/restore\n */\nexport const restoreVersionResponseSchema = agentVersionSchema.describe(\n 'The newly created version from the restored configuration',\n);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/compare\n */\nexport const compareVersionsResponseSchema: ReturnType<\n typeof createCompareVersionsResponseSchema<typeof agentVersionSchema>\n> = createCompareVersionsResponseSchema(agentVersionSchema);\n"],"mappings":";;;;;AAuBA,MAAM,6BAA6BA,O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A6BU,uBAAAA,iCAAiC,kBAAkB;;;;AAK7F,MAAa,2BAA2B;;;;AAKxC,MAAa,8BAA8B,mBAAmB,QAAQ,CAAC,CAAC,MACtEV,OAAAA,EAAE,OAAO;CAEP,IAAIA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAClE,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,yCAAyC;CACtE,eAAeA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAC7E,WAAWA,OAAAA,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC,CACH;;;;AAKA,MAAa,+BAA+B,mBAAmB,SAC7D,2DACF;;;;AAKA,MAAa,gCAETW,uBAAAA,oCAAoC,kBAAkB"}
@@ -1,5 +1,5 @@
1
1
  import { t as defaultOptionsSchema } from "./default-options-oSlrqpuP.js";
2
- import { D as toolsConfigSchema, E as toolConfigSchema, I as storedMemoryRefSchema, T as storedProcessorGraphSchema, f as modelConfigSchema, l as instructionsSchema, t as conditionalFieldSchema, x as scorerConfigSchema } from "./stored-agents-ts0bWw8l.js";
2
+ import { D as toolsConfigSchema, E as toolConfigSchema, I as storedMemoryRefSchema, T as storedProcessorGraphSchema, f as modelConfigSchema, l as instructionsSchema, t as conditionalFieldSchema, x as scorerConfigSchema } from "./stored-agents-BzIvRgtz.js";
3
3
  import { i as createListVersionsResponseSchema, r as createCompareVersionsResponseSchema } from "./version-common-Co-USxDX.js";
4
4
  import { z } from "zod/v4";
5
5
  //#region src/server/schemas/agent-versions.ts
@@ -71,4 +71,4 @@ const compareVersionsResponseSchema = createCompareVersionsResponseSchema(agentV
71
71
  //#endregion
72
72
  export { getVersionResponseSchema as a, versionIdPathParams as c, createVersionResponseSchema as i, agentVersionSchema as n, listVersionsResponseSchema as o, compareVersionsResponseSchema as r, restoreVersionResponseSchema as s, agentVersionPathParams as t };
73
73
 
74
- //# sourceMappingURL=agent-versions-CTAEDQuT.js.map
74
+ //# sourceMappingURL=agent-versions-oCebJ7rc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-versions-CTAEDQuT.js","names":[],"sources":["../src/server/schemas/agent-versions.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { defaultOptionsSchema } from './default-options';\nimport { storedMemoryRefSchema } from './memory-config';\nimport {\n scorerConfigSchema,\n instructionsSchema,\n conditionalFieldSchema,\n modelConfigSchema,\n toolConfigSchema,\n toolsConfigSchema,\n storedProcessorGraphSchema,\n} from './stored-agents';\nimport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n createListVersionsResponseSchema,\n createCompareVersionsResponseSchema,\n} from './version-common';\n\nconst mcpClientToolsConfigSchema = z.object({\n tools: z.record(z.string(), toolConfigSchema).optional(),\n});\n\n// Re-export shared schemas for backwards compat\nexport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n};\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\n/**\n * Path parameters for agent version routes\n */\nexport const agentVersionPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n});\n\n/**\n * Path parameters for specific version routes\n */\nexport const versionIdPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n versionId: z.string().describe('Unique identifier for the version (UUID)'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\n/**\n * Agent version object schema (full response)\n * Config fields are top-level on the version (no nested snapshot object).\n * Extends StorageAgentSnapshotType fields.\n */\nexport const agentVersionSchema = z.object({\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n // Top-level config fields (from StorageAgentSnapshotType)\n name: z.string().describe('Name of the agent'),\n description: z.string().optional().describe('Description of the agent'),\n instructions: instructionsSchema,\n model: conditionalFieldSchema(modelConfigSchema).describe(\n 'Model configuration — static value or array of conditional variants',\n ),\n tools: conditionalFieldSchema(toolsConfigSchema)\n .optional()\n .describe('Tool keys mapped to per-tool config — static or conditional'),\n defaultOptions: conditionalFieldSchema(defaultOptionsSchema)\n .optional()\n .describe('Default options for generate/stream calls — static or conditional'),\n workflows: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Workflow keys with optional per-workflow config — static or conditional'),\n agents: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Agent keys with optional per-agent config — static or conditional'),\n integrationTools: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of tool provider IDs to their tool configurations — static or conditional'),\n mcpClients: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of stored MCP client IDs to their tool configurations — static or conditional'),\n inputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Input processor graph — static or conditional'),\n outputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Output processor graph — static or conditional'),\n memory: conditionalFieldSchema(storedMemoryRefSchema)\n .optional()\n .describe('Memory: registered memory reference or inline config — static or conditional'),\n scorers: conditionalFieldSchema(z.record(z.string(), scorerConfigSchema))\n .optional()\n .describe('Scorer keys with optional sampling config — static or conditional'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining valid request context variables'),\n // Version metadata fields\n changedFields: z.array(z.string()).optional().describe('Array of field names that changed from the previous version'),\n changeMessage: z.string().optional().describe('Optional message describing the changes'),\n createdAt: z.coerce.date().describe('When this version was created'),\n});\n\n/**\n * Response for GET /stored/agents/:agentId/versions\n */\nexport const listVersionsResponseSchema = createListVersionsResponseSchema(agentVersionSchema);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/:versionId\n */\nexport const getVersionResponseSchema = agentVersionSchema;\n\n/**\n * Response for POST /stored/agents/:agentId/versions\n */\nexport const createVersionResponseSchema = agentVersionSchema.partial().merge(\n z.object({\n // These fields are always present in a version response\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n createdAt: z.coerce.date().describe('When this version was created'),\n }),\n);\n\n/**\n * Response for POST /stored/agents/:agentId/versions/:versionId/restore\n */\nexport const restoreVersionResponseSchema = agentVersionSchema.describe(\n 'The newly created version from the restored configuration',\n);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/compare\n */\nexport const compareVersionsResponseSchema: ReturnType<\n typeof createCompareVersionsResponseSchema<typeof agentVersionSchema>\n> = createCompareVersionsResponseSchema(agentVersionSchema);\n"],"mappings":";;;;;AAuBA,MAAM,6BAA6B,EAAE,OAAO,EAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,SAAS,EACzD,CAAC;;;;AAmBD,MAAa,yBAAyB,EAAE,OAAO,EAC7C,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,wCAAwC,EACvE,CAAC;;;;AAKD,MAAa,sBAAsB,EAAE,OAAO;CAC1C,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,wCAAwC;CACrE,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;AAC3E,CAAC;;;;;;AAWD,MAAa,qBAAqB,EAAE,OAAO;CACzC,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAClE,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,yCAAyC;CACtE,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAE7E,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,mBAAmB;CAC7C,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,0BAA0B;CACtE,cAAc;CACd,O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C;CACvF,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC;;;;AAKD,MAAa,6BAA6B,iCAAiC,kBAAkB;;;;AAK7F,MAAa,2BAA2B;;;;AAKxC,MAAa,8BAA8B,mBAAmB,QAAQ,CAAC,CAAC,MACtE,EAAE,OAAO;CAEP,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAClE,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,yCAAyC;CACtE,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAC7E,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC,CACH;;;;AAKA,MAAa,+BAA+B,mBAAmB,SAC7D,2DACF;;;;AAKA,MAAa,gCAET,oCAAoC,kBAAkB"}
1
+ {"version":3,"file":"agent-versions-oCebJ7rc.js","names":[],"sources":["../src/server/schemas/agent-versions.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { defaultOptionsSchema } from './default-options';\nimport { storedMemoryRefSchema } from './memory-config';\nimport {\n scorerConfigSchema,\n instructionsSchema,\n conditionalFieldSchema,\n modelConfigSchema,\n toolConfigSchema,\n toolsConfigSchema,\n storedProcessorGraphSchema,\n} from './stored-agents';\nimport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n createListVersionsResponseSchema,\n createCompareVersionsResponseSchema,\n} from './version-common';\n\nconst mcpClientToolsConfigSchema = z.object({\n tools: z.record(z.string(), toolConfigSchema).optional(),\n});\n\n// Re-export shared schemas for backwards compat\nexport {\n listVersionsQuerySchema,\n compareVersionsQuerySchema,\n createVersionBodySchema,\n activateVersionResponseSchema,\n deleteVersionResponseSchema,\n versionDiffEntrySchema,\n};\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\n/**\n * Path parameters for agent version routes\n */\nexport const agentVersionPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n});\n\n/**\n * Path parameters for specific version routes\n */\nexport const versionIdPathParams = z.object({\n agentId: z.string().describe('Unique identifier for the stored agent'),\n versionId: z.string().describe('Unique identifier for the version (UUID)'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\n/**\n * Agent version object schema (full response)\n * Config fields are top-level on the version (no nested snapshot object).\n * Extends StorageAgentSnapshotType fields.\n */\nexport const agentVersionSchema = z.object({\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n // Top-level config fields (from StorageAgentSnapshotType)\n name: z.string().describe('Name of the agent'),\n description: z.string().optional().describe('Description of the agent'),\n instructions: instructionsSchema,\n model: conditionalFieldSchema(modelConfigSchema).describe(\n 'Model configuration — static value or array of conditional variants',\n ),\n tools: conditionalFieldSchema(toolsConfigSchema)\n .optional()\n .describe('Tool keys mapped to per-tool config — static or conditional'),\n defaultOptions: conditionalFieldSchema(defaultOptionsSchema)\n .optional()\n .describe('Default options for generate/stream calls — static or conditional'),\n workflows: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Workflow keys with optional per-workflow config — static or conditional'),\n agents: conditionalFieldSchema(z.record(z.string(), toolConfigSchema))\n .optional()\n .describe('Agent keys with optional per-agent config — static or conditional'),\n integrationTools: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of tool provider IDs to their tool configurations — static or conditional'),\n mcpClients: conditionalFieldSchema(z.record(z.string(), mcpClientToolsConfigSchema))\n .optional()\n .describe('Map of stored MCP client IDs to their tool configurations — static or conditional'),\n inputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Input processor graph — static or conditional'),\n outputProcessors: conditionalFieldSchema(storedProcessorGraphSchema)\n .optional()\n .describe('Output processor graph — static or conditional'),\n memory: conditionalFieldSchema(storedMemoryRefSchema)\n .optional()\n .describe('Memory: registered memory reference or inline config — static or conditional'),\n scorers: conditionalFieldSchema(z.record(z.string(), scorerConfigSchema))\n .optional()\n .describe('Scorer keys with optional sampling config — static or conditional'),\n requestContextSchema: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('JSON Schema defining valid request context variables'),\n // Version metadata fields\n changedFields: z.array(z.string()).optional().describe('Array of field names that changed from the previous version'),\n changeMessage: z.string().optional().describe('Optional message describing the changes'),\n createdAt: z.coerce.date().describe('When this version was created'),\n});\n\n/**\n * Response for GET /stored/agents/:agentId/versions\n */\nexport const listVersionsResponseSchema = createListVersionsResponseSchema(agentVersionSchema);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/:versionId\n */\nexport const getVersionResponseSchema = agentVersionSchema;\n\n/**\n * Response for POST /stored/agents/:agentId/versions\n */\nexport const createVersionResponseSchema = agentVersionSchema.partial().merge(\n z.object({\n // These fields are always present in a version response\n id: z.string().describe('Unique identifier for the version (UUID)'),\n agentId: z.string().describe('ID of the agent this version belongs to'),\n versionNumber: z.number().describe('Sequential version number (1, 2, 3, ...)'),\n createdAt: z.coerce.date().describe('When this version was created'),\n }),\n);\n\n/**\n * Response for POST /stored/agents/:agentId/versions/:versionId/restore\n */\nexport const restoreVersionResponseSchema = agentVersionSchema.describe(\n 'The newly created version from the restored configuration',\n);\n\n/**\n * Response for GET /stored/agents/:agentId/versions/compare\n */\nexport const compareVersionsResponseSchema: ReturnType<\n typeof createCompareVersionsResponseSchema<typeof agentVersionSchema>\n> = createCompareVersionsResponseSchema(agentVersionSchema);\n"],"mappings":";;;;;AAuBA,MAAM,6BAA6B,EAAE,OAAO,EAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,SAAS,EACzD,CAAC;;;;AAmBD,MAAa,yBAAyB,EAAE,OAAO,EAC7C,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,wCAAwC,EACvE,CAAC;;;;AAKD,MAA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C,CACV,SAAS,gDAAgD;CAC5D,QAAQ,uBAAuB,qBAAqB,CAAC,CAClD,SAAS,CAAC,CACV,SAAS,8EAA8E;CAC1F,SAAS,uBAAuB,EAAE,OAAO,EAAE,OAAO,GAAG,kBAAkB,CAAC,CAAC,CACtE,SAAS,CAAC,CACV,SAAS,mEAAmE;CAC/E,sBAAsB,EACnB,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC/B,SAAS,CAAC,CACV,SAAS,sDAAsD;CAElE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,6DAA6D;CACpH,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,yCAAyC;CACvF,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC;;;;AAKD,MAAa,6BAA6B,iCAAiC,kBAAkB;;;;AAK7F,MAAa,2BAA2B;;;;AAKxC,MAAa,8BAA8B,mBAAmB,QAAQ,CAAC,CAAC,MACtE,EAAE,OAAO;CAEP,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAClE,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,yCAAyC;CACtE,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS,0CAA0C;CAC7E,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS,+BAA+B;AACrE,CAAC,CACH;;;;AAKA,MAAa,+BAA+B,mBAAmB,SAC7D,2DACF;;;;AAKA,MAAa,gCAET,oCAAoC,kBAAkB"}
@@ -1,6 +1,6 @@
1
1
  require("./rolldown-runtime-Bd6kNlEP.cjs");
2
2
  const require_route_builder = require("./route-builder-2yrD15TL.cjs");
3
- const require_routes = require("./routes-BuiLQCOQ.cjs");
3
+ const require_routes = require("./routes-Op7uJGai.cjs");
4
4
  //#region src/server/server-adapter/api-schema-manifest.ts
5
5
  function convertSchema(schema) {
6
6
  return schema ? require_route_builder.schemaToJsonSchema(schema) : void 0;
@@ -53,4 +53,4 @@ function buildApiSchemaManifest(routes = require_routes.SERVER_ROUTES) {
53
53
  //#endregion
54
54
  exports.buildApiSchemaManifest = buildApiSchemaManifest;
55
55
 
56
- //# sourceMappingURL=api-schema-manifest-D9_jxxNw.cjs.map
56
+ //# sourceMappingURL=api-schema-manifest-BKsEMyEs.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-schema-manifest-D9_jxxNw.cjs","names":["schemaToJsonSchema","SERVER_ROUTES"],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAASA,sBAAAA,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA,SAAS,WAAW,QAAkE;CACpF,MAAM,OAAO,QAAQ;CACrB,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI;AACpD;AAEA,SAAS,mBAAmB,gBAAiE;CAC3F,IAAI,CAAC,gBAAgB,OAAO,EAAE,MAAM,UAAU;CAE9C,MAAM,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiCC,eAAAA,eAAkC;CACxG,OAAO;EACL,SAAS;EACT,QAAQ,OAAO,OAAO,eAAe,CAAC,CAAC,KAAI,UAAS;GAClD,MAAM,iBAAiB,cAAc,MAAM,cAAc;GACzD,OAAO;IACL,QAAQ,MAAM;IACd,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,eAAe;IACpD,kBAAkB,cAAc,MAAM,gBAAgB;IACtD,YAAY,cAAc,MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"api-schema-manifest-BKsEMyEs.cjs","names":["schemaToJsonSchema","SERVER_ROUTES"],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAASA,sBAAAA,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA,SAAS,WAAW,QAAkE;CACpF,MAAM,OAAO,QAAQ;CACrB,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI;AACpD;AAEA,SAAS,mBAAmB,gBAAiE;CAC3F,IAAI,CAAC,gBAAgB,OAAO,EAAE,MAAM,UAAU;CAE9C,MAAM,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiCC,eAAAA,eAAkC;CACxG,OAAO;EACL,SAAS;EACT,QAAQ,OAAO,OAAO,eAAe,CAAC,CAAC,KAAI,UAAS;GAClD,MAAM,iBAAiB,cAAc,MAAM,cAAc;GACzD,OAAO;IACL,QAAQ,MAAM;IACd,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,eAAe;IACpD,kBAAkB,cAAc,MAAM,gBAAgB;IACtD,YAAY,cAAc,MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { c as schemaToJsonSchema } from "./route-builder-lBil8Cvo.js";
2
- import { t as SERVER_ROUTES } from "./routes-CJygX0-a.js";
2
+ import { t as SERVER_ROUTES } from "./routes-B_ehFjzs.js";
3
3
  //#region src/server/server-adapter/api-schema-manifest.ts
4
4
  function convertSchema(schema) {
5
5
  return schema ? schemaToJsonSchema(schema) : void 0;
@@ -52,4 +52,4 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
52
52
  //#endregion
53
53
  export { buildApiSchemaManifest };
54
54
 
55
- //# sourceMappingURL=api-schema-manifest-B0p6nxU1.js.map
55
+ //# sourceMappingURL=api-schema-manifest-KsETdHDS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-schema-manifest-B0p6nxU1.js","names":[],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAAS,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA,SAAS,WAAW,QAAkE;CACpF,MAAM,OAAO,QAAQ;CACrB,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI;AACpD;AAEA,SAAS,mBAAmB,gBAAiE;CAC3F,IAAI,CAAC,gBAAgB,OAAO,EAAE,MAAM,UAAU;CAE9C,MAAM,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiC,eAAkC;CACxG,OAAO;EACL,SAAS;EACT,QAAQ,OAAO,OAAO,eAAe,CAAC,CAAC,KAAI,UAAS;GAClD,MAAM,iBAAiB,cAAc,MAAM,cAAc;GACzD,OAAO;IACL,QAAQ,MAAM;IACd,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,eAAe;IACpD,kBAAkB,cAAc,MAAM,gBAAgB;IACtD,YAAY,cAAc,MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"api-schema-manifest-KsETdHDS.js","names":[],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAAS,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA,SAAS,WAAW,QAAkE;CACpF,MAAM,OAAO,QAAQ;CACrB,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI;AACpD;A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
52
52
  const listChannelInstallationsResponseSchema = zod_v4.z.array(channelInstallationInfoSchema);
53
53
  const connectChannelResponseSchema = channelConnectResultSchema;
54
54
  const disconnectChannelResponseSchema = zod_v4.z.object({ success: zod_v4.z.boolean() });
55
+ const reconcileChannelResponseSchema = channelInstallationInfoSchema.nullable().describe("The reconciled installation, or null when the agent has none (or the platform does not reconcile)");
55
56
  //#endregion
56
57
  //#region src/server/handlers/channels.ts
57
58
  function assertChannelsAvailable() {
@@ -187,6 +188,37 @@ const CONNECT_CHANNEL_ROUTE = require_route_builder.createRoute({
187
188
  }
188
189
  });
189
190
  /**
191
+ * POST /channels/:platform/:agentId/reconcile - Reconcile an agent's installation
192
+ *
193
+ * The explicit write path for connect flows that complete out-of-band (e.g.
194
+ * Discord's bot invite has no redirect back to the server). Listing stays a
195
+ * pure read; Studio calls this on window focus while a connect is in flight.
196
+ * Gated on the same write access as connect — reconciliation can activate the
197
+ * agent's installation.
198
+ */
199
+ const RECONCILE_CHANNEL_ROUTE = require_route_builder.createRoute({
200
+ method: "POST",
201
+ path: "/channels/:platform/:agentId/reconcile",
202
+ responseType: "json",
203
+ pathParamSchema: channelAgentPathParams,
204
+ responseSchema: reconcileChannelResponseSchema,
205
+ summary: "Reconcile channel installation",
206
+ description: "Checks a pending installation against platform state and activates it if its connect flow has completed. Returns the installation, or null when the agent has none or the platform does not support reconciliation.",
207
+ tags: ["Channels"],
208
+ requiresAuth: true,
209
+ handler: async ({ mastra, requestContext, platform, agentId }) => {
210
+ assertChannelsAvailable();
211
+ try {
212
+ const channel = await getChannelOrThrow(mastra, platform);
213
+ await assertChannelAgentWriteAccess(mastra, requestContext, agentId, "connect");
214
+ if (!channel.reconcileInstallation) return null;
215
+ return await channel.reconcileInstallation(agentId);
216
+ } catch (error) {
217
+ return require_server_handlers_error.handleError(error, "Error reconciling channel installation");
218
+ }
219
+ }
220
+ });
221
+ /**
190
222
  * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform
191
223
  */
192
224
  const DISCONNECT_CHANNEL_ROUTE = require_route_builder.createRoute({
@@ -237,5 +269,11 @@ Object.defineProperty(exports, "LIST_CHANNEL_PLATFORMS_ROUTE", {
237
269
  return LIST_CHANNEL_PLATFORMS_ROUTE;
238
270
  }
239
271
  });
272
+ Object.defineProperty(exports, "RECONCILE_CHANNEL_ROUTE", {
273
+ enumerable: true,
274
+ get: function() {
275
+ return RECONCILE_CHANNEL_ROUTE;
276
+ }
277
+ });
240
278
 
241
- //# sourceMappingURL=channels-DJkXEpTr.cjs.map
279
+ //# sourceMappingURL=channels-DUdpygCQ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels-DUdpygCQ.cjs","names":["z","coreFeatures","HTTPException","getCallerAuthorId","hasAdminBypass","hasScopedPermission","createRoute","handleError"],"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const channelPlatformPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n});\n\nexport const channelAgentPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n agentId: z.string().describe('Agent identifier'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nexport const connectChannelBodySchema = z.object({\n agentId: z.string().describe('Agent identifier to connect'),\n options: z.record(z.string(), z.unknown()).optional().describe('Platform-specific connection options'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nconst channelPlatformInfoSchema = z.object({\n id: z.string().describe('Platform identifier'),\n name: z.string().describe('Human-readable platform name'),\n isConfigured: z.boolean().describe('Whether the platform is ready to connect agents'),\n connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe('JSON Schema for connect options'),\n});\n\nconst channelInstallationInfoSchema = z.object({\n id: z.string().describe('Installation identifier'),\n platform: z.string().describe('Platform identifier'),\n agentId: z.string().describe('Connected agent identifier'),\n status: z.enum(['active', 'pending']).describe('Installation status'),\n displayName: z.string().optional().describe('Platform-specific display name'),\n installedAt: z.coerce.date().optional().describe('Installation timestamp'),\n});\n\nconst channelConnectOAuthSchema = z.object({\n type: z.literal('oauth').describe('OAuth-based connection requiring browser redirect'),\n authorizationUrl: z.string().describe('OAuth authorization URL for user redirect'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectDeepLinkSchema = z.object({\n type: z.literal('deep_link').describe('Deep-link connection requiring native app interaction'),\n url: z.string().describe('Deep link URL to open in platform app'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectImmediateSchema = z.object({\n type: z.literal('immediate').describe('Immediate connection with no user interaction needed'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectResultSchema = z.discriminatedUnion('type', [\n channelConnectOAuthSchema,\n channelConnectDeepLinkSchema,\n channelConnectImmediateSchema,\n]);\n\nexport const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);\n\nexport const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);\n\nexport const connectChannelResponseSchema = channelConnectResultSchema;\n\nexport const disconnectChannelResponseSchema = z.object({\n success: z.boolean(),\n});\n\nexport const reconcileChannelResponseSchema = channelInstallationInfoSchema\n .nullable()\n .describe('The reconciled installation, or null when the agent has none (or the platform does not reconcile)');\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\nimport type { RequestContext } from '@mastra/core/di';\nimport { coreFeatures } from '@mastra/core/features';\n\nimport { MASTRA_USER_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\nimport {\n channelPlatformPathParams,\n channelAgentPathParams,\n connectChannelBodySchema,\n listChannelPlatformsResponseSchema,\n listChannelInstallationsResponseSchema,\n connectChannelResponseSchema,\n disconnectChannelResponseSchema,\n reconcileChannelResponseSchema,\n} from '../schemas/channels';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { assertWriteAccess, getCallerAuthorId, hasAdminBypass, hasScopedPermission } from './authorship';\nimport { handleError } from './error';\n\n// ============================================================================\n// Feature gate + helpers\n// ============================================================================\n\nfunction assertChannelsAvailable(): void {\n if (!coreFeatures.has('channels')) {\n throw new HTTPException(501, { message: 'Channels require a newer version of @mastra/core' });\n }\n}\n\n/**\n * Resolves the current channel providers. Prefers `resolveChannels()` so a\n * live resolver (e.g. `channels()` from @mastra/connect) is consulted —\n * connections added after boot are picked up without a restart. Falls back to\n * the static snapshot on older @mastra/core versions without the method.\n */\nasync function resolveChannelProviders(mastra: Mastra): Promise<ChannelProvider[]> {\n const resolveChannels = (mastra as Mastra & { resolveChannels?: () => Promise<Record<string, ChannelProvider>> })\n .resolveChannels;\n const record = typeof resolveChannels === 'function' ? await resolveChannels.call(mastra) : (mastra.channels ?? {});\n return Object.values(record);\n}\n\nasync function getChannelOrThrow(mastra: Mastra, platform: string): Promise<ChannelProvider> {\n const channels = await resolveChannelProviders(mastra);\n const channel = channels.find(c => c.id === platform);\n if (!channel) {\n const available = channels.map(c => c.id).join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\n/**\n * Unified connect/disconnect authorization.\n *\n * - Stored agent exists → same write access as editing the agent record.\n * - Code-defined agent (no stored record) → route's `requiresAuth` is the gate.\n * - Agent doesn't exist anywhere:\n * - connect → 404 (can't connect a channel to a non-existent agent)\n * - disconnect → orphan cleanup, gated on `channels:write`\n */\nasync function assertChannelAgentWriteAccess(\n mastra: Mastra,\n requestContext: RequestContext,\n agentId: string,\n action: 'connect' | 'disconnect',\n): Promise<void> {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : null;\n const stored = agentsStore ? await agentsStore.getById(agentId) : null;\n\n if (stored) {\n assertWriteAccess({\n requestContext,\n resource: 'agents',\n resourceId: agentId,\n action: 'edit',\n record: stored,\n });\n return;\n }\n\n // Not in stored-agents (or storage doesn't support it). Check the runtime\n // registry for a code-defined agent.\n const codeDefined = mastra.getAgentById(agentId);\n if (codeDefined) {\n // Code-defined agents have no owner/ACL — route's requiresAuth /\n // requiresPermission is the gate. Pass-through.\n return;\n }\n\n if (action === 'connect') {\n throw new HTTPException(404, { message: `Agent \"${agentId}\" not found` });\n }\n\n // Disconnect against an unknown agentId = orphan cleanup (stored agent was\n // deleted but the channel installation row is still around). Allow it, but\n // gate on channels:write so this isn't an \"any authenticated user\" backdoor.\n // Follow the same no-auth-configured pass-through as assertWriteAccess.\n const callerAuthorId = getCallerAuthorId(requestContext);\n if (!callerAuthorId && !requestContext.get(MASTRA_USER_KEY)) return;\n if (hasAdminBypass(requestContext, 'channels')) return;\n if (hasScopedPermission({ requestContext, resource: 'channels', action: 'write' })) return;\n\n throw new HTTPException(404, { message: 'Not found' });\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /channels/platforms - List available channel platforms\n */\nexport const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/platforms',\n responseType: 'json',\n responseSchema: listChannelPlatformsResponseSchema,\n summary: 'List channel platforms',\n description: 'Returns available channel platforms and their configuration status',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n assertChannelsAvailable();\n try {\n const channels = await resolveChannelProviders(mastra);\n return channels.map(channel => {\n if (channel.getInfo) {\n return channel.getInfo();\n }\n return {\n id: channel.id,\n name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),\n isConfigured: true,\n };\n });\n } catch (error) {\n return handleError(error, 'Error listing channel platforms');\n }\n },\n});\n\n/**\n * GET /channels/:platform/installations - List installations for a platform\n */\nexport const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/:platform/installations',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n responseSchema: listChannelInstallationsResponseSchema,\n summary: 'List channel installations',\n description: 'Returns all active and pending installations for a channel platform',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, platform }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n if (!channel.listInstallations) {\n return [];\n }\n\n return await channel.listInstallations();\n } catch (error) {\n return handleError(error, 'Error listing channel installations');\n }\n },\n});\n\n/**\n * POST /channels/:platform/connect - Connect an agent to a platform\n */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/connect',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n bodySchema: connectChannelBodySchema,\n responseSchema: connectChannelResponseSchema,\n summary: 'Connect agent to channel',\n description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n if (!channel.connect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic connection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n return await channel.connect(agentId, options);\n } catch (error) {\n return handleError(error, 'Error connecting agent to channel');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/reconcile - Reconcile an agent's installation\n *\n * The explicit write path for connect flows that complete out-of-band (e.g.\n * Discord's bot invite has no redirect back to the server). Listing stays a\n * pure read; Studio calls this on window focus while a connect is in flight.\n * Gated on the same write access as connect — reconciliation can activate the\n * agent's installation.\n */\nexport const RECONCILE_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/reconcile',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: reconcileChannelResponseSchema,\n summary: 'Reconcile channel installation',\n description:\n 'Checks a pending installation against platform state and activates it if its connect flow has completed. Returns the installation, or null when the agent has none or the platform does not support reconciliation.',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n // Resolve the agent (404 on unknown) and authorize the write before the\n // capability check so unknown agents never read as a successful no-op.\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n if (!channel.reconcileInstallation) {\n return null;\n }\n\n return await channel.reconcileInstallation(agentId);\n } catch (error) {\n return handleError(error, 'Error reconciling channel installation');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/disconnect',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: disconnectChannelResponseSchema,\n summary: 'Disconnect agent from channel',\n description: 'Deletes the platform app and cleans up the installation',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n if (!channel.disconnect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic disconnection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n await channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"],"mappings":";;;;;;;;AAMA,MAAa,4BAA4BA,OAAAA,EAAE,OAAO,EAChD,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C,EAC7E,CAAC;AAED,MAAa,yBAAyBA,OAAAA,EAAE,OAAO;CAC7C,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C;CAC3E,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB;AACjD,CAAC;AAMD,MAAa,2BAA2BA,OAAAA,EAAE,OAAO;CAC/C,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,6BAA6B;CAC1D,SAASA,OAAAA,EAAE,OAAOA,OAAAA,EAAE,OAAO,G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,iBAAiB;CACjB,gBAAgB;CAChB,SAAS;CACT,aACE;CACF,MAAM,CAAC,UAAU;CACjB,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,gBAAgB,UAAU,cAAc;EAChE,wBAAwB;EACxB,IAAI;GACF,MAAM,UAAU,MAAM,kBAAkB,QAAQ,QAAQ;GAIxD,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,SAAS;GAE9E,IAAI,CAAC,QAAQ,uBACX,OAAO;GAGT,OAAO,MAAM,QAAQ,sBAAsB,OAAO;EACpD,SAAS,OAAO;GACd,OAAOC,8BAAAA,YAAY,OAAO,wCAAwC;EACpE;CACF;AACF,CAAC;;;;AAKD,MAAa,2BAA2BD,sBAAAA,YAAY;CAClD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,UAAU;CACjB,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,gBAAgB,UAAU,cAAc;EAChE,wBAAwB;EACxB,IAAI;GACF,MAAM,UAAU,MAAM,kBAAkB,QAAQ,QAAQ;GAExD,IAAI,CAAC,QAAQ,YACX,MAAM,IAAIJ,uBAAAA,cAAc,KAAK,EAC3B,SAAS,YAAY,SAAS,+CAChC,CAAC;GAGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,YAAY;GAEjF,MAAM,QAAQ,WAAW,OAAO;GAChC,OAAO,EAAE,SAAS,KAAK;EACzB,SAAS,OAAO;GACd,OAAOK,8BAAAA,YAAY,OAAO,wCAAwC;EACpE;CACF;AACF,CAAC"}
@@ -52,6 +52,7 @@ const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);
52
52
  const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);
53
53
  const connectChannelResponseSchema = channelConnectResultSchema;
54
54
  const disconnectChannelResponseSchema = z.object({ success: z.boolean() });
55
+ const reconcileChannelResponseSchema = channelInstallationInfoSchema.nullable().describe("The reconciled installation, or null when the agent has none (or the platform does not reconcile)");
55
56
  //#endregion
56
57
  //#region src/server/handlers/channels.ts
57
58
  function assertChannelsAvailable() {
@@ -187,6 +188,37 @@ const CONNECT_CHANNEL_ROUTE = createRoute({
187
188
  }
188
189
  });
189
190
  /**
191
+ * POST /channels/:platform/:agentId/reconcile - Reconcile an agent's installation
192
+ *
193
+ * The explicit write path for connect flows that complete out-of-band (e.g.
194
+ * Discord's bot invite has no redirect back to the server). Listing stays a
195
+ * pure read; Studio calls this on window focus while a connect is in flight.
196
+ * Gated on the same write access as connect — reconciliation can activate the
197
+ * agent's installation.
198
+ */
199
+ const RECONCILE_CHANNEL_ROUTE = createRoute({
200
+ method: "POST",
201
+ path: "/channels/:platform/:agentId/reconcile",
202
+ responseType: "json",
203
+ pathParamSchema: channelAgentPathParams,
204
+ responseSchema: reconcileChannelResponseSchema,
205
+ summary: "Reconcile channel installation",
206
+ description: "Checks a pending installation against platform state and activates it if its connect flow has completed. Returns the installation, or null when the agent has none or the platform does not support reconciliation.",
207
+ tags: ["Channels"],
208
+ requiresAuth: true,
209
+ handler: async ({ mastra, requestContext, platform, agentId }) => {
210
+ assertChannelsAvailable();
211
+ try {
212
+ const channel = await getChannelOrThrow(mastra, platform);
213
+ await assertChannelAgentWriteAccess(mastra, requestContext, agentId, "connect");
214
+ if (!channel.reconcileInstallation) return null;
215
+ return await channel.reconcileInstallation(agentId);
216
+ } catch (error) {
217
+ return handleError(error, "Error reconciling channel installation");
218
+ }
219
+ }
220
+ });
221
+ /**
190
222
  * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform
191
223
  */
192
224
  const DISCONNECT_CHANNEL_ROUTE = createRoute({
@@ -213,6 +245,6 @@ const DISCONNECT_CHANNEL_ROUTE = createRoute({
213
245
  }
214
246
  });
215
247
  //#endregion
216
- export { LIST_CHANNEL_PLATFORMS_ROUTE as i, DISCONNECT_CHANNEL_ROUTE as n, LIST_CHANNEL_INSTALLATIONS_ROUTE as r, CONNECT_CHANNEL_ROUTE as t };
248
+ export { RECONCILE_CHANNEL_ROUTE as a, LIST_CHANNEL_PLATFORMS_ROUTE as i, DISCONNECT_CHANNEL_ROUTE as n, LIST_CHANNEL_INSTALLATIONS_ROUTE as r, CONNECT_CHANNEL_ROUTE as t };
217
249
 
218
- //# sourceMappingURL=channels-DzaCNtXe.js.map
250
+ //# sourceMappingURL=channels-T1KaEfZX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels-T1KaEfZX.js","names":[],"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const channelPlatformPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n});\n\nexport const channelAgentPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n agentId: z.string().describe('Agent identifier'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nexport const connectChannelBodySchema = z.object({\n agentId: z.string().describe('Agent identifier to connect'),\n options: z.record(z.string(), z.unknown()).optional().describe('Platform-specific connection options'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nconst channelPlatformInfoSchema = z.object({\n id: z.string().describe('Platform identifier'),\n name: z.string().describe('Human-readable platform name'),\n isConfigured: z.boolean().describe('Whether the platform is ready to connect agents'),\n connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe('JSON Schema for connect options'),\n});\n\nconst channelInstallationInfoSchema = z.object({\n id: z.string().describe('Installation identifier'),\n platform: z.string().describe('Platform identifier'),\n agentId: z.string().describe('Connected agent identifier'),\n status: z.enum(['active', 'pending']).describe('Installation status'),\n displayName: z.string().optional().describe('Platform-specific display name'),\n installedAt: z.coerce.date().optional().describe('Installation timestamp'),\n});\n\nconst channelConnectOAuthSchema = z.object({\n type: z.literal('oauth').describe('OAuth-based connection requiring browser redirect'),\n authorizationUrl: z.string().describe('OAuth authorization URL for user redirect'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectDeepLinkSchema = z.object({\n type: z.literal('deep_link').describe('Deep-link connection requiring native app interaction'),\n url: z.string().describe('Deep link URL to open in platform app'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectImmediateSchema = z.object({\n type: z.literal('immediate').describe('Immediate connection with no user interaction needed'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectResultSchema = z.discriminatedUnion('type', [\n channelConnectOAuthSchema,\n channelConnectDeepLinkSchema,\n channelConnectImmediateSchema,\n]);\n\nexport const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);\n\nexport const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);\n\nexport const connectChannelResponseSchema = channelConnectResultSchema;\n\nexport const disconnectChannelResponseSchema = z.object({\n success: z.boolean(),\n});\n\nexport const reconcileChannelResponseSchema = channelInstallationInfoSchema\n .nullable()\n .describe('The reconciled installation, or null when the agent has none (or the platform does not reconcile)');\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\nimport type { RequestContext } from '@mastra/core/di';\nimport { coreFeatures } from '@mastra/core/features';\n\nimport { MASTRA_USER_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\nimport {\n channelPlatformPathParams,\n channelAgentPathParams,\n connectChannelBodySchema,\n listChannelPlatformsResponseSchema,\n listChannelInstallationsResponseSchema,\n connectChannelResponseSchema,\n disconnectChannelResponseSchema,\n reconcileChannelResponseSchema,\n} from '../schemas/channels';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { assertWriteAccess, getCallerAuthorId, hasAdminBypass, hasScopedPermission } from './authorship';\nimport { handleError } from './error';\n\n// ============================================================================\n// Feature gate + helpers\n// ============================================================================\n\nfunction assertChannelsAvailable(): void {\n if (!coreFeatures.has('channels')) {\n throw new HTTPException(501, { message: 'Channels require a newer version of @mastra/core' });\n }\n}\n\n/**\n * Resolves the current channel providers. Prefers `resolveChannels()` so a\n * live resolver (e.g. `channels()` from @mastra/connect) is consulted —\n * connections added after boot are picked up without a restart. Falls back to\n * the static snapshot on older @mastra/core versions without the method.\n */\nasync function resolveChannelProviders(mastra: Mastra): Promise<ChannelProvider[]> {\n const resolveChannels = (mastra as Mastra & { resolveChannels?: () => Promise<Record<string, ChannelProvider>> })\n .resolveChannels;\n const record = typeof resolveChannels === 'function' ? await resolveChannels.call(mastra) : (mastra.channels ?? {});\n return Object.values(record);\n}\n\nasync function getChannelOrThrow(mastra: Mastra, platform: string): Promise<ChannelProvider> {\n const channels = await resolveChannelProviders(mastra);\n const channel = channels.find(c => c.id === platform);\n if (!channel) {\n const available = channels.map(c => c.id).join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\n/**\n * Unified connect/disconnect authorization.\n *\n * - Stored agent exists → same write access as editing the agent record.\n * - Code-defined agent (no stored record) → route's `requiresAuth` is the gate.\n * - Agent doesn't exist anywhere:\n * - connect → 404 (can't connect a channel to a non-existent agent)\n * - disconnect → orphan cleanup, gated on `channels:write`\n */\nasync function assertChannelAgentWriteAccess(\n mastra: Mastra,\n requestContext: RequestContext,\n agentId: string,\n action: 'connect' | 'disconnect',\n): Promise<void> {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : null;\n const stored = agentsStore ? await agentsStore.getById(agentId) : null;\n\n if (stored) {\n assertWriteAccess({\n requestContext,\n resource: 'agents',\n resourceId: agentId,\n action: 'edit',\n record: stored,\n });\n return;\n }\n\n // Not in stored-agents (or storage doesn't support it). Check the runtime\n // registry for a code-defined agent.\n const codeDefined = mastra.getAgentById(agentId);\n if (codeDefined) {\n // Code-defined agents have no owner/ACL — route's requiresAuth /\n // requiresPermission is the gate. Pass-through.\n return;\n }\n\n if (action === 'connect') {\n throw new HTTPException(404, { message: `Agent \"${agentId}\" not found` });\n }\n\n // Disconnect against an unknown agentId = orphan cleanup (stored agent was\n // deleted but the channel installation row is still around). Allow it, but\n // gate on channels:write so this isn't an \"any authenticated user\" backdoor.\n // Follow the same no-auth-configured pass-through as assertWriteAccess.\n const callerAuthorId = getCallerAuthorId(requestContext);\n if (!callerAuthorId && !requestContext.get(MASTRA_USER_KEY)) return;\n if (hasAdminBypass(requestContext, 'channels')) return;\n if (hasScopedPermission({ requestContext, resource: 'channels', action: 'write' })) return;\n\n throw new HTTPException(404, { message: 'Not found' });\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /channels/platforms - List available channel platforms\n */\nexport const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/platforms',\n responseType: 'json',\n responseSchema: listChannelPlatformsResponseSchema,\n summary: 'List channel platforms',\n description: 'Returns available channel platforms and their configuration status',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n assertChannelsAvailable();\n try {\n const channels = await resolveChannelProviders(mastra);\n return channels.map(channel => {\n if (channel.getInfo) {\n return channel.getInfo();\n }\n return {\n id: channel.id,\n name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),\n isConfigured: true,\n };\n });\n } catch (error) {\n return handleError(error, 'Error listing channel platforms');\n }\n },\n});\n\n/**\n * GET /channels/:platform/installations - List installations for a platform\n */\nexport const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/:platform/installations',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n responseSchema: listChannelInstallationsResponseSchema,\n summary: 'List channel installations',\n description: 'Returns all active and pending installations for a channel platform',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, platform }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n if (!channel.listInstallations) {\n return [];\n }\n\n return await channel.listInstallations();\n } catch (error) {\n return handleError(error, 'Error listing channel installations');\n }\n },\n});\n\n/**\n * POST /channels/:platform/connect - Connect an agent to a platform\n */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/connect',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n bodySchema: connectChannelBodySchema,\n responseSchema: connectChannelResponseSchema,\n summary: 'Connect agent to channel',\n description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n if (!channel.connect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic connection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n return await channel.connect(agentId, options);\n } catch (error) {\n return handleError(error, 'Error connecting agent to channel');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/reconcile - Reconcile an agent's installation\n *\n * The explicit write path for connect flows that complete out-of-band (e.g.\n * Discord's bot invite has no redirect back to the server). Listing stays a\n * pure read; Studio calls this on window focus while a connect is in flight.\n * Gated on the same write access as connect — reconciliation can activate the\n * agent's installation.\n */\nexport const RECONCILE_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/reconcile',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: reconcileChannelResponseSchema,\n summary: 'Reconcile channel installation',\n description:\n 'Checks a pending installation against platform state and activates it if its connect flow has completed. Returns the installation, or null when the agent has none or the platform does not support reconciliation.',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n // Resolve the agent (404 on unknown) and authorize the write before the\n // capability check so unknown agents never read as a successful no-op.\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n if (!channel.reconcileInstallation) {\n return null;\n }\n\n return await channel.reconcileInstallation(agentId);\n } catch (error) {\n return handleError(error, 'Error reconciling channel installation');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/disconnect',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: disconnectChannelResponseSchema,\n summary: 'Disconnect agent from channel',\n description: 'Deletes the platform app and cleans up the installation',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = await getChannelOrThrow(mastra, platform);\n\n if (!channel.disconnect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic disconnection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n await channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"],"mappings":";;;;;;;;AAMA,MAAa,4BAA4B,EAAE,OAAO,EAChD,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C,EAC7E,CAAC;AAED,MAAa,yBAAyB,EAAE,OAAO;CAC7C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C;CAC3E,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB;AACjD,CAAC;AAMD,MAAa,2BAA2B,EAAE,OAAO;CAC/C,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,6BAA6B;CAC1D,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sCAAsC;AACvG,CAAC;AAMD,MAAM,4BAA4B,EAAE,OAAO;CACzC,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,qBAAqB;CAC7C,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,8BAA8B;CACxD,cAAc,EAAE,QAAQ,CAAC,CAAC,SAAS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AExD,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,cAAc,KAAK,EAC3B,SAAS,YAAY,SAAS,+CAChC,CAAC;GAGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,YAAY;GAEjF,MAAM,QAAQ,WAAW,OAAO;GAChC,OAAO,EAAE,SAAS,KAAK;EACzB,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,wCAAwC;EACpE;CACF;AACF,CAAC"}
@@ -4637,7 +4637,7 @@ function splitLines(text) {
4637
4637
  return result;
4638
4638
  }
4639
4639
  //#endregion
4640
- //#region ../memory/dist/src-BxI-PDpC.js
4640
+ //#region ../memory/dist/src-BQOm4kZc.js
4641
4641
  var __defProp$3 = Object.defineProperty;
4642
4642
  var __exportAll = (all, no_symbols) => {
4643
4643
  let target = {};
@@ -25310,6 +25310,25 @@ function getObserverMessageLabel(msg) {
25310
25310
  if (isSystemReminderMessage(msg)) return "system-reminder";
25311
25311
  return msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
25312
25312
  }
25313
+ /**
25314
+ * Attachment URLs the agent already found undownloadable. Core records them on the user
25315
+ * message (`metadata.mastra.unavailableAttachments`) so they are not fetched again.
25316
+ */
25317
+ function getUnavailableAttachmentUrls(msg) {
25318
+ const mastra = msg.content?.metadata?.mastra;
25319
+ const urls = isRecord$2(mastra) ? mastra.unavailableAttachments : void 0;
25320
+ return new Set(Array.isArray(urls) ? urls.filter((url) => typeof url === "string") : []);
25321
+ }
25322
+ function getObserverAttachmentUrl(part) {
25323
+ const asset = part.type === "image" ? part.image : part.data ?? part.url;
25324
+ if (asset instanceof URL) return asset.toString();
25325
+ if (typeof asset !== "string") return void 0;
25326
+ try {
25327
+ return new URL(asset).toString();
25328
+ } catch {
25329
+ return;
25330
+ }
25331
+ }
25313
25332
  function formatObserverMessage(msg, counter, toolFormatting, options) {
25314
25333
  const maxLen = options?.maxPartLength;
25315
25334
  const maxToolResultTokens = options?.maxToolResultTokens ?? 5e3;
@@ -25318,6 +25337,7 @@ function formatObserverMessage(msg, counter, toolFormatting, options) {
25318
25337
  const role = getObserverMessageLabel(msg);
25319
25338
  const attachments = [];
25320
25339
  const messageCreatedAt = normalizeObserverCreatedAt(msg.createdAt);
25340
+ const unavailableUrls = getUnavailableAttachmentUrls(msg);
25321
25341
  let lines = [];
25322
25342
  const temporalGapText = isTemporalGapMarker(msg) ? getTemporalGapMarkerText(msg) : void 0;
25323
25343
  const pushLine = (title, body, createdAt) => {
@@ -25376,7 +25396,8 @@ function formatObserverMessage(msg, counter, toolFormatting, options) {
25376
25396
  }
25377
25397
  if (partType === "image" || partType === "file") {
25378
25398
  const attachment = part;
25379
- if (shouldIncludeObserverAttachment(attachment, attachmentFilter)) {
25399
+ const attachmentUrl = unavailableUrls.size > 0 ? getObserverAttachmentUrl(attachment) : void 0;
25400
+ if (!(attachmentUrl !== void 0 && unavailableUrls.has(attachmentUrl)) && shouldIncludeObserverAttachment(attachment, attachmentFilter)) {
25380
25401
  const inputAttachment = toObserverInputAttachmentPart(attachment);
25381
25402
  if (inputAttachment) attachments.push(inputAttachment);
25382
25403
  }
@@ -50466,4 +50487,4 @@ const agentBuilderWorkflows = {
50466
50487
  //#endregion
50467
50488
  exports.agentBuilderWorkflows = agentBuilderWorkflows;
50468
50489
 
50469
- //# sourceMappingURL=dist-DgDFoIF5.cjs.map
50490
+ //# sourceMappingURL=dist-DRLe8Sd-.cjs.map