@mastra/server 1.72.0-alpha.0 → 1.72.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{a2a-CwxSk6H0.cjs → a2a-CAQVpVxH.cjs} +23 -3
- package/dist/a2a-CAQVpVxH.cjs.map +1 -0
- package/dist/{a2a-DQOqoU_q.js → a2a-D2BffGsK.js} +23 -3
- package/dist/a2a-D2BffGsK.js.map +1 -0
- package/dist/{agent-builder-BGTZux5y.js → agent-builder-BlD120ac.js} +2 -2
- package/dist/{agent-builder-BGTZux5y.js.map → agent-builder-BlD120ac.js.map} +1 -1
- package/dist/{agent-builder-D-LAj4SD.cjs → agent-builder-CvwtAD7k.cjs} +2 -2
- package/dist/{agent-builder-D-LAj4SD.cjs.map → agent-builder-CvwtAD7k.cjs.map} +1 -1
- package/dist/{api-schema-manifest-Maxewnw7.cjs → api-schema-manifest-CaZU5zVt.cjs} +2 -2
- package/dist/{api-schema-manifest-Maxewnw7.cjs.map → api-schema-manifest-CaZU5zVt.cjs.map} +1 -1
- package/dist/{api-schema-manifest-DJiUahwo.js → api-schema-manifest-wF1O8MCU.js} +2 -2
- package/dist/{api-schema-manifest-DJiUahwo.js.map → api-schema-manifest-wF1O8MCU.js.map} +1 -1
- package/dist/{channels-DMw4LEA-.cjs → channels-DJkXEpTr.cjs} +18 -7
- package/dist/channels-DJkXEpTr.cjs.map +1 -0
- package/dist/{channels-xqChW6Vw.js → channels-DzaCNtXe.js} +18 -7
- package/dist/channels-DzaCNtXe.js.map +1 -0
- package/dist/{dist-Cfr6t0cK.cjs → dist-CRMvLG_8.cjs} +746 -366
- package/dist/dist-CRMvLG_8.cjs.map +1 -0
- package/dist/{dist-ABdCIqbD.js → dist-CYk5xS3y.js} +746 -366
- package/dist/dist-CYk5xS3y.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-observability-tracing-trace-query.md +37 -16
- package/dist/{editor-builder-BrkDnCEd.js → editor-builder-DJMAKDR5.js} +3 -2
- package/dist/editor-builder-DJMAKDR5.js.map +1 -0
- package/dist/{editor-builder-DIpISGSI.cjs → editor-builder-DrDs-t9i.cjs} +3 -2
- package/dist/editor-builder-DrDs-t9i.cjs.map +1 -0
- package/dist/{observability-new-endpoints-Ct0CSLE4.cjs → observability-new-endpoints-7Zd6uEZf.cjs} +111 -3
- package/dist/observability-new-endpoints-7Zd6uEZf.cjs.map +1 -0
- package/dist/{observability-new-endpoints-DqS6dcR5.js → observability-new-endpoints-lNC3o66-.js} +107 -5
- package/dist/observability-new-endpoints-lNC3o66-.js.map +1 -0
- package/dist/route-builder-2yrD15TL.cjs.map +1 -1
- package/dist/route-builder-lBil8Cvo.js.map +1 -1
- package/dist/{routes-D6sAEgtj.js → routes-B6soWZap.js} +6 -5
- package/dist/routes-B6soWZap.js.map +1 -0
- package/dist/{routes-C9CmwhbC.cjs → routes-x4As7pym.cjs} +6 -5
- package/dist/routes-x4As7pym.cjs.map +1 -0
- package/dist/schema-e0VHpMt0-BS9KHnuT.cjs.map +1 -1
- package/dist/schema-e0VHpMt0-CvPvLS06.js.map +1 -1
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +3 -3
- package/dist/server/handlers/agent-builder.d.ts +4 -2
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +3 -3
- package/dist/server/handlers/agent-controller.cjs +2 -1
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +2 -1
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agents.cjs +49 -20
- package/dist/server/handlers/agents.cjs.map +1 -1
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +49 -20
- package/dist/server/handlers/agents.js.map +1 -1
- package/dist/server/handlers/channels.cjs +1 -1
- package/dist/server/handlers/channels.d.ts.map +1 -1
- package/dist/server/handlers/channels.js +1 -1
- package/dist/server/handlers/editor-builder.cjs +1 -1
- package/dist/server/handlers/editor-builder.d.ts.map +1 -1
- package/dist/server/handlers/editor-builder.js +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +1 -1
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +100 -0
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +2 -2
- package/dist/server/handlers/observability-shared.cjs +46 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +13 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +42 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +3 -1
- package/dist/server/handlers/observability.cjs.map +1 -1
- package/dist/server/handlers/observability.js +3 -2
- package/dist/server/handlers/observability.js.map +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
- package/dist/server/handlers/stored-agent-favorites.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +6 -3
- package/dist/server/handlers/stored-agents.cjs.map +1 -1
- package/dist/server/handlers/stored-agents.d.ts.map +1 -1
- package/dist/server/handlers/stored-agents.js +6 -3
- package/dist/server/handlers/stored-agents.js.map +1 -1
- package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
- package/dist/server/handlers/stored-skill-favorites.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +1 -1
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts +2 -0
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/handlers/workflows.cjs +28 -4
- package/dist/server/handlers/workflows.cjs.map +1 -1
- package/dist/server/handlers/workflows.d.ts +5 -2
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +28 -4
- package/dist/server/handlers/workflows.js.map +1 -1
- package/dist/server/handlers.cjs +1 -1
- package/dist/server/handlers.js +1 -1
- package/dist/server/schemas/index.cjs +3 -3
- package/dist/server/schemas/index.js +3 -3
- package/dist/server/schemas/system.d.ts +2 -0
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/schemas/workflows.d.ts +2 -1
- package/dist/server/schemas/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/agent-builder.d.ts +4 -2
- package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +97 -0
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/system.d.ts +2 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workflows.d.ts +4 -2
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
- package/dist/{system-BE5tDMHq.js → system-6qFm79mm.js} +2 -1
- package/dist/system-6qFm79mm.js.map +1 -0
- package/dist/{system-BlGYb2fu.cjs → system-CskEzH1o.cjs} +2 -1
- package/dist/system-CskEzH1o.cjs.map +1 -0
- package/dist/{workflows-CvJ4c4_p.js → workflows-BEdLrZQZ.js} +3 -2
- package/dist/workflows-BEdLrZQZ.js.map +1 -0
- package/dist/{workflows-Cv6MGw9d.cjs → workflows-BdoErlkd.cjs} +3 -2
- package/dist/workflows-BdoErlkd.cjs.map +1 -0
- package/package.json +7 -7
- package/dist/a2a-CwxSk6H0.cjs.map +0 -1
- package/dist/a2a-DQOqoU_q.js.map +0 -1
- package/dist/channels-DMw4LEA-.cjs.map +0 -1
- package/dist/channels-xqChW6Vw.js.map +0 -1
- package/dist/dist-ABdCIqbD.js.map +0 -1
- package/dist/dist-Cfr6t0cK.cjs.map +0 -1
- package/dist/editor-builder-BrkDnCEd.js.map +0 -1
- package/dist/editor-builder-DIpISGSI.cjs.map +0 -1
- package/dist/observability-new-endpoints-Ct0CSLE4.cjs.map +0 -1
- package/dist/observability-new-endpoints-DqS6dcR5.js.map +0 -1
- package/dist/routes-C9CmwhbC.cjs.map +0 -1
- package/dist/routes-D6sAEgtj.js.map +0 -1
- package/dist/system-BE5tDMHq.js.map +0 -1
- package/dist/system-BlGYb2fu.cjs.map +0 -1
- package/dist/workflows-Cv6MGw9d.cjs.map +0 -1
- package/dist/workflows-CvJ4c4_p.js.map +0 -1
|
@@ -57,8 +57,19 @@ const disconnectChannelResponseSchema = z.object({ success: z.boolean() });
|
|
|
57
57
|
function assertChannelsAvailable() {
|
|
58
58
|
if (!coreFeatures.has("channels")) throw new HTTPException(501, { message: "Channels require a newer version of @mastra/core" });
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the current channel providers. Prefers `resolveChannels()` so a
|
|
62
|
+
* live resolver (e.g. `channels()` from @mastra/connect) is consulted —
|
|
63
|
+
* connections added after boot are picked up without a restart. Falls back to
|
|
64
|
+
* the static snapshot on older @mastra/core versions without the method.
|
|
65
|
+
*/
|
|
66
|
+
async function resolveChannelProviders(mastra) {
|
|
67
|
+
const resolveChannels = mastra.resolveChannels;
|
|
68
|
+
const record = typeof resolveChannels === "function" ? await resolveChannels.call(mastra) : mastra.channels ?? {};
|
|
69
|
+
return Object.values(record);
|
|
70
|
+
}
|
|
71
|
+
async function getChannelOrThrow(mastra, platform) {
|
|
72
|
+
const channels = await resolveChannelProviders(mastra);
|
|
62
73
|
const channel = channels.find((c) => c.id === platform);
|
|
63
74
|
if (!channel) throw new HTTPException(404, { message: `Channel "${platform}" is not registered. Available: ${channels.map((c) => c.id).join(", ") || "none"}` });
|
|
64
75
|
return channel;
|
|
@@ -112,7 +123,7 @@ const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({
|
|
|
112
123
|
handler: async ({ mastra }) => {
|
|
113
124
|
assertChannelsAvailable();
|
|
114
125
|
try {
|
|
115
|
-
return
|
|
126
|
+
return (await resolveChannelProviders(mastra)).map((channel) => {
|
|
116
127
|
if (channel.getInfo) return channel.getInfo();
|
|
117
128
|
return {
|
|
118
129
|
id: channel.id,
|
|
@@ -141,7 +152,7 @@ const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({
|
|
|
141
152
|
handler: async ({ mastra, platform }) => {
|
|
142
153
|
assertChannelsAvailable();
|
|
143
154
|
try {
|
|
144
|
-
const channel = getChannelOrThrow(mastra, platform);
|
|
155
|
+
const channel = await getChannelOrThrow(mastra, platform);
|
|
145
156
|
if (!channel.listInstallations) return [];
|
|
146
157
|
return await channel.listInstallations();
|
|
147
158
|
} catch (error) {
|
|
@@ -166,7 +177,7 @@ const CONNECT_CHANNEL_ROUTE = createRoute({
|
|
|
166
177
|
handler: async ({ mastra, requestContext, platform, agentId, options }) => {
|
|
167
178
|
assertChannelsAvailable();
|
|
168
179
|
try {
|
|
169
|
-
const channel = getChannelOrThrow(mastra, platform);
|
|
180
|
+
const channel = await getChannelOrThrow(mastra, platform);
|
|
170
181
|
if (!channel.connect) throw new HTTPException(400, { message: `Channel "${platform}" does not support programmatic connection` });
|
|
171
182
|
await assertChannelAgentWriteAccess(mastra, requestContext, agentId, "connect");
|
|
172
183
|
return await channel.connect(agentId, options);
|
|
@@ -191,7 +202,7 @@ const DISCONNECT_CHANNEL_ROUTE = createRoute({
|
|
|
191
202
|
handler: async ({ mastra, requestContext, platform, agentId }) => {
|
|
192
203
|
assertChannelsAvailable();
|
|
193
204
|
try {
|
|
194
|
-
const channel = getChannelOrThrow(mastra, platform);
|
|
205
|
+
const channel = await getChannelOrThrow(mastra, platform);
|
|
195
206
|
if (!channel.disconnect) throw new HTTPException(400, { message: `Channel "${platform}" does not support programmatic disconnection` });
|
|
196
207
|
await assertChannelAgentWriteAccess(mastra, requestContext, agentId, "disconnect");
|
|
197
208
|
await channel.disconnect(agentId);
|
|
@@ -204,4 +215,4 @@ const DISCONNECT_CHANNEL_ROUTE = createRoute({
|
|
|
204
215
|
//#endregion
|
|
205
216
|
export { LIST_CHANNEL_PLATFORMS_ROUTE as i, DISCONNECT_CHANNEL_ROUTE as n, LIST_CHANNEL_INSTALLATIONS_ROUTE as r, CONNECT_CHANNEL_ROUTE as t };
|
|
206
217
|
|
|
207
|
-
//# sourceMappingURL=channels-
|
|
218
|
+
//# sourceMappingURL=channels-DzaCNtXe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels-DzaCNtXe.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","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} 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/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,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