@mastra/server 1.31.0-alpha.1 → 1.31.0-alpha.3

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 (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/chunk-CUIH4FYN.js +190 -0
  3. package/dist/chunk-CUIH4FYN.js.map +1 -0
  4. package/dist/chunk-CXBX2UAP.cjs +195 -0
  5. package/dist/chunk-CXBX2UAP.cjs.map +1 -0
  6. package/dist/{chunk-HR4M27JP.cjs → chunk-LOZTHAYC.cjs} +3 -3
  7. package/dist/{chunk-HR4M27JP.cjs.map → chunk-LOZTHAYC.cjs.map} +1 -1
  8. package/dist/{chunk-2PF5ZR2Q.js → chunk-NB6HG472.js} +3 -3
  9. package/dist/{chunk-2PF5ZR2Q.js.map → chunk-NB6HG472.js.map} +1 -1
  10. package/dist/docs/SKILL.md +1 -1
  11. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  12. package/dist/server/handlers/agent-builder.cjs +16 -16
  13. package/dist/server/handlers/agent-builder.js +1 -1
  14. package/dist/server/handlers/channels.cjs +24 -0
  15. package/dist/server/handlers/channels.cjs.map +1 -0
  16. package/dist/server/handlers/channels.d.ts +90 -0
  17. package/dist/server/handlers/channels.d.ts.map +1 -0
  18. package/dist/server/handlers/channels.js +3 -0
  19. package/dist/server/handlers/channels.js.map +1 -0
  20. package/dist/server/handlers.cjs +12 -12
  21. package/dist/server/handlers.js +3 -3
  22. package/dist/server/schemas/channels.d.ts +45 -0
  23. package/dist/server/schemas/channels.d.ts.map +1 -0
  24. package/dist/server/schemas/index.cjs +83 -83
  25. package/dist/server/schemas/index.js +3 -3
  26. package/dist/server/server-adapter/index.cjs +31 -21
  27. package/dist/server/server-adapter/index.cjs.map +1 -1
  28. package/dist/server/server-adapter/index.js +16 -6
  29. package/dist/server/server-adapter/index.js.map +1 -1
  30. package/dist/server/server-adapter/routes/channels.d.ts +75 -0
  31. package/dist/server/server-adapter/routes/channels.d.ts.map +1 -0
  32. package/dist/server/server-adapter/routes/index.d.ts +3 -1
  33. package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
  34. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.31.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Added platform channels framework with ChannelProvider interface, ChannelsStorage domain, and ChannelConnectResult discriminated union supporting OAuth, deep link, and immediate connection flows. Channels can be registered on the Mastra instance and expose connect/disconnect/list APIs for platform integrations. ([#15876](https://github.com/mastra-ai/mastra/pull/15876))
8
+
9
+ - Updated dependencies [[`b2deb29`](https://github.com/mastra-ai/mastra/commit/b2deb29412b300c868655b5840463614fbb7962d), [`66644be`](https://github.com/mastra-ai/mastra/commit/66644beac1aa560f0e417956ff007c89341dc382), [`310b953`](https://github.com/mastra-ai/mastra/commit/310b95345f302dcd5ba3ed862bdc96f059d44122), [`43f0e1d`](https://github.com/mastra-ai/mastra/commit/43f0e1d5d5a74ba6fc746f2ad89ebe0c64777a7d), [`da0b9e2`](https://github.com/mastra-ai/mastra/commit/da0b9e2ba7ecc560213b426d6c097fe63946086e)]:
10
+ - @mastra/core@1.31.0-alpha.3
11
+
12
+ ## 1.31.0-alpha.2
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`2b0f355`](https://github.com/mastra-ai/mastra/commit/2b0f3553be3e9e5524da539a66e5cf82668440a4)]:
17
+ - @mastra/core@1.31.0-alpha.2
18
+
3
19
  ## 1.31.0-alpha.1
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,190 @@
1
+ import { createRoute } from './chunk-PA2BYLKF.js';
2
+ import { handleError } from './chunk-P23KBWKB.js';
3
+ import { HTTPException } from './chunk-6QWQZI4Q.js';
4
+ import { coreFeatures } from '@mastra/core/features';
5
+ import { z } from 'zod/v4';
6
+
7
+ var channelPlatformPathParams = z.object({
8
+ platform: z.string().describe('Channel platform identifier (e.g., "slack")')
9
+ });
10
+ var channelAgentPathParams = z.object({
11
+ platform: z.string().describe('Channel platform identifier (e.g., "slack")'),
12
+ agentId: z.string().describe("Agent identifier")
13
+ });
14
+ var connectChannelBodySchema = z.object({
15
+ agentId: z.string().describe("Agent identifier to connect"),
16
+ options: z.record(z.string(), z.unknown()).optional().describe("Platform-specific connection options")
17
+ });
18
+ var channelPlatformInfoSchema = z.object({
19
+ id: z.string().describe("Platform identifier"),
20
+ name: z.string().describe("Human-readable platform name"),
21
+ isConfigured: z.boolean().describe("Whether the platform is ready to connect agents"),
22
+ connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe("JSON Schema for connect options")
23
+ });
24
+ var channelInstallationInfoSchema = z.object({
25
+ id: z.string().describe("Installation identifier"),
26
+ platform: z.string().describe("Platform identifier"),
27
+ agentId: z.string().describe("Connected agent identifier"),
28
+ status: z.enum(["active", "pending"]).describe("Installation status"),
29
+ displayName: z.string().optional().describe("Platform-specific display name"),
30
+ installedAt: z.coerce.date().optional().describe("Installation timestamp")
31
+ });
32
+ var channelConnectOAuthSchema = z.object({
33
+ type: z.literal("oauth").describe("OAuth-based connection requiring browser redirect"),
34
+ authorizationUrl: z.string().describe("OAuth authorization URL for user redirect"),
35
+ installationId: z.string().describe("Installation identifier")
36
+ });
37
+ var channelConnectDeepLinkSchema = z.object({
38
+ type: z.literal("deep_link").describe("Deep-link connection requiring native app interaction"),
39
+ url: z.string().describe("Deep link URL to open in platform app"),
40
+ installationId: z.string().describe("Installation identifier")
41
+ });
42
+ var channelConnectImmediateSchema = z.object({
43
+ type: z.literal("immediate").describe("Immediate connection with no user interaction needed"),
44
+ installationId: z.string().describe("Installation identifier")
45
+ });
46
+ var channelConnectResultSchema = z.discriminatedUnion("type", [
47
+ channelConnectOAuthSchema,
48
+ channelConnectDeepLinkSchema,
49
+ channelConnectImmediateSchema
50
+ ]);
51
+ var listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);
52
+ var listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);
53
+ var connectChannelResponseSchema = channelConnectResultSchema;
54
+ var disconnectChannelResponseSchema = z.object({
55
+ success: z.boolean()
56
+ });
57
+
58
+ // src/server/handlers/channels.ts
59
+ function assertChannelsAvailable() {
60
+ if (!coreFeatures.has("channels")) {
61
+ throw new HTTPException(501, { message: "Channels require a newer version of @mastra/core" });
62
+ }
63
+ }
64
+ function getChannelOrThrow(mastra, platform) {
65
+ const channels = mastra.channels ?? {};
66
+ const channel = Object.values(channels).find((c) => c.id === platform);
67
+ if (!channel) {
68
+ const available = Object.values(channels).map((c) => c.id).join(", ");
69
+ throw new HTTPException(404, {
70
+ message: `Channel "${platform}" is not registered. Available: ${available || "none"}`
71
+ });
72
+ }
73
+ return channel;
74
+ }
75
+ function assertAgentExists(mastra, agentId) {
76
+ const agent = mastra.getAgentById?.(agentId);
77
+ if (!agent) {
78
+ throw new HTTPException(404, {
79
+ message: `Agent "${agentId}" not found`
80
+ });
81
+ }
82
+ }
83
+ var LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({
84
+ method: "GET",
85
+ path: "/channels/platforms",
86
+ responseType: "json",
87
+ responseSchema: listChannelPlatformsResponseSchema,
88
+ summary: "List channel platforms",
89
+ description: "Returns available channel platforms and their configuration status",
90
+ tags: ["Channels"],
91
+ requiresAuth: true,
92
+ handler: async ({ mastra }) => {
93
+ assertChannelsAvailable();
94
+ try {
95
+ const channels = mastra.channels ?? {};
96
+ return Object.values(channels).map((channel) => {
97
+ if (channel.getInfo) {
98
+ return channel.getInfo();
99
+ }
100
+ return {
101
+ id: channel.id,
102
+ name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),
103
+ isConfigured: true
104
+ };
105
+ });
106
+ } catch (error) {
107
+ return handleError(error, "Error listing channel platforms");
108
+ }
109
+ }
110
+ });
111
+ var LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({
112
+ method: "GET",
113
+ path: "/channels/:platform/installations",
114
+ responseType: "json",
115
+ pathParamSchema: channelPlatformPathParams,
116
+ responseSchema: listChannelInstallationsResponseSchema,
117
+ summary: "List channel installations",
118
+ description: "Returns all active and pending installations for a channel platform",
119
+ tags: ["Channels"],
120
+ requiresAuth: true,
121
+ handler: async ({ mastra, platform }) => {
122
+ assertChannelsAvailable();
123
+ try {
124
+ const channel = getChannelOrThrow(mastra, platform);
125
+ if (!channel.listInstallations) {
126
+ return [];
127
+ }
128
+ return await channel.listInstallations();
129
+ } catch (error) {
130
+ return handleError(error, "Error listing channel installations");
131
+ }
132
+ }
133
+ });
134
+ var CONNECT_CHANNEL_ROUTE = createRoute({
135
+ method: "POST",
136
+ path: "/channels/:platform/connect",
137
+ responseType: "json",
138
+ pathParamSchema: channelPlatformPathParams,
139
+ bodySchema: connectChannelBodySchema,
140
+ responseSchema: connectChannelResponseSchema,
141
+ summary: "Connect agent to channel",
142
+ description: "Creates a platform app for the agent and returns an OAuth authorization URL",
143
+ tags: ["Channels"],
144
+ requiresAuth: true,
145
+ handler: async ({ mastra, platform, agentId, options }) => {
146
+ assertChannelsAvailable();
147
+ try {
148
+ const channel = getChannelOrThrow(mastra, platform);
149
+ if (!channel.connect) {
150
+ throw new HTTPException(400, {
151
+ message: `Channel "${platform}" does not support programmatic connection`
152
+ });
153
+ }
154
+ return await channel.connect(agentId, options);
155
+ } catch (error) {
156
+ return handleError(error, "Error connecting agent to channel");
157
+ }
158
+ }
159
+ });
160
+ var DISCONNECT_CHANNEL_ROUTE = createRoute({
161
+ method: "POST",
162
+ path: "/channels/:platform/:agentId/disconnect",
163
+ responseType: "json",
164
+ pathParamSchema: channelAgentPathParams,
165
+ responseSchema: disconnectChannelResponseSchema,
166
+ summary: "Disconnect agent from channel",
167
+ description: "Deletes the platform app and cleans up the installation",
168
+ tags: ["Channels"],
169
+ requiresAuth: true,
170
+ handler: async ({ mastra, platform, agentId }) => {
171
+ assertChannelsAvailable();
172
+ try {
173
+ assertAgentExists(mastra, agentId);
174
+ const channel = getChannelOrThrow(mastra, platform);
175
+ if (!channel.disconnect) {
176
+ throw new HTTPException(400, {
177
+ message: `Channel "${platform}" does not support programmatic disconnection`
178
+ });
179
+ }
180
+ await channel.disconnect(agentId);
181
+ return { success: true };
182
+ } catch (error) {
183
+ return handleError(error, "Error disconnecting agent from channel");
184
+ }
185
+ }
186
+ });
187
+
188
+ export { CONNECT_CHANNEL_ROUTE, DISCONNECT_CHANNEL_ROUTE, LIST_CHANNEL_INSTALLATIONS_ROUTE, LIST_CHANNEL_PLATFORMS_ROUTE };
189
+ //# sourceMappingURL=chunk-CUIH4FYN.js.map
190
+ //# sourceMappingURL=chunk-CUIH4FYN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"names":[],"mappings":";;;;;;AAMO,IAAM,yBAAA,GAA4B,EAAE,MAAA,CAAO;AAAA,EAChD,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,6CAA6C;AAC7E,CAAC,CAAA;AAEM,IAAM,sBAAA,GAAyB,EAAE,MAAA,CAAO;AAAA,EAC7C,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,6CAA6C,CAAA;AAAA,EAC3E,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kBAAkB;AACjD,CAAC,CAAA;AAMM,IAAM,wBAAA,GAA2B,EAAE,MAAA,CAAO;AAAA,EAC/C,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,6BAA6B,CAAA;AAAA,EAC1D,OAAA,EAAS,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA,EAAS,CAAE,SAAS,sCAAsC;AACvG,CAAC,CAAA;AAMD,IAAM,yBAAA,GAA4B,EAAE,MAAA,CAAO;AAAA,EACzC,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,qBAAqB,CAAA;AAAA,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AAQ,KAAM;AAChD,IAAA,uBAAA,EAAwB;AACxB,IAAA,IAAI;AACF,MAAA,iBAAA,CAAkB,QAAQ,OAAO,CAAA;AACjC,MAAA,MAAM,OAAA,GAAU,iBAAA,CAAkB,MAAA,EAAQ,QAAQ,CAAA;AAElD,MAAA,IAAI,CAAC,QAAQ,UAAA,EAAY;AACvB,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK;AAAA,UAC3B,OAAA,EAAS,YAAY,QAAQ,CAAA,6CAAA;AAAA,SAC9B,CAAA;AAAA,MACH;AAEA,MAAA,MAAM,OAAA,CAAQ,WAAW,OAAO,CAAA;AAChC,MAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAAA,IACzB,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,wCAAwC,CAAA;AAAA,IACpE;AAAA,EACF;AACF,CAAC","file":"chunk-CUIH4FYN.js","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 { coreFeatures } from '@mastra/core/features';\n\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 { 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\nfunction getChannelOrThrow(mastra: any, platform: string) {\n const channels = mastra.channels ?? {};\n const channel = Object.values(channels).find((c: any) => c.id === platform) as any;\n if (!channel) {\n const available = Object.values(channels)\n .map((c: any) => c.id)\n .join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\nfunction assertAgentExists(mastra: any, agentId: string) {\n const agent = mastra.getAgentById?.(agentId);\n if (!agent) {\n throw new HTTPException(404, {\n message: `Agent \"${agentId}\" not found`,\n });\n }\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 = (mastra as any).channels ?? {};\n return Object.values(channels).map((channel: any) => {\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 = 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, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = 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 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, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n assertAgentExists(mastra, agentId);\n const channel = 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 channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"]}
@@ -0,0 +1,195 @@
1
+ 'use strict';
2
+
3
+ var chunk5UKYK7YK_cjs = require('./chunk-5UKYK7YK.cjs');
4
+ var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
5
+ var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
6
+ var features = require('@mastra/core/features');
7
+ var v4 = require('zod/v4');
8
+
9
+ var channelPlatformPathParams = v4.z.object({
10
+ platform: v4.z.string().describe('Channel platform identifier (e.g., "slack")')
11
+ });
12
+ var channelAgentPathParams = v4.z.object({
13
+ platform: v4.z.string().describe('Channel platform identifier (e.g., "slack")'),
14
+ agentId: v4.z.string().describe("Agent identifier")
15
+ });
16
+ var connectChannelBodySchema = v4.z.object({
17
+ agentId: v4.z.string().describe("Agent identifier to connect"),
18
+ options: v4.z.record(v4.z.string(), v4.z.unknown()).optional().describe("Platform-specific connection options")
19
+ });
20
+ var channelPlatformInfoSchema = v4.z.object({
21
+ id: v4.z.string().describe("Platform identifier"),
22
+ name: v4.z.string().describe("Human-readable platform name"),
23
+ isConfigured: v4.z.boolean().describe("Whether the platform is ready to connect agents"),
24
+ connectOptionsSchema: v4.z.record(v4.z.string(), v4.z.unknown()).optional().describe("JSON Schema for connect options")
25
+ });
26
+ var channelInstallationInfoSchema = v4.z.object({
27
+ id: v4.z.string().describe("Installation identifier"),
28
+ platform: v4.z.string().describe("Platform identifier"),
29
+ agentId: v4.z.string().describe("Connected agent identifier"),
30
+ status: v4.z.enum(["active", "pending"]).describe("Installation status"),
31
+ displayName: v4.z.string().optional().describe("Platform-specific display name"),
32
+ installedAt: v4.z.coerce.date().optional().describe("Installation timestamp")
33
+ });
34
+ var channelConnectOAuthSchema = v4.z.object({
35
+ type: v4.z.literal("oauth").describe("OAuth-based connection requiring browser redirect"),
36
+ authorizationUrl: v4.z.string().describe("OAuth authorization URL for user redirect"),
37
+ installationId: v4.z.string().describe("Installation identifier")
38
+ });
39
+ var channelConnectDeepLinkSchema = v4.z.object({
40
+ type: v4.z.literal("deep_link").describe("Deep-link connection requiring native app interaction"),
41
+ url: v4.z.string().describe("Deep link URL to open in platform app"),
42
+ installationId: v4.z.string().describe("Installation identifier")
43
+ });
44
+ var channelConnectImmediateSchema = v4.z.object({
45
+ type: v4.z.literal("immediate").describe("Immediate connection with no user interaction needed"),
46
+ installationId: v4.z.string().describe("Installation identifier")
47
+ });
48
+ var channelConnectResultSchema = v4.z.discriminatedUnion("type", [
49
+ channelConnectOAuthSchema,
50
+ channelConnectDeepLinkSchema,
51
+ channelConnectImmediateSchema
52
+ ]);
53
+ var listChannelPlatformsResponseSchema = v4.z.array(channelPlatformInfoSchema);
54
+ var listChannelInstallationsResponseSchema = v4.z.array(channelInstallationInfoSchema);
55
+ var connectChannelResponseSchema = channelConnectResultSchema;
56
+ var disconnectChannelResponseSchema = v4.z.object({
57
+ success: v4.z.boolean()
58
+ });
59
+
60
+ // src/server/handlers/channels.ts
61
+ function assertChannelsAvailable() {
62
+ if (!features.coreFeatures.has("channels")) {
63
+ throw new chunk64ITUOXI_cjs.HTTPException(501, { message: "Channels require a newer version of @mastra/core" });
64
+ }
65
+ }
66
+ function getChannelOrThrow(mastra, platform) {
67
+ const channels = mastra.channels ?? {};
68
+ const channel = Object.values(channels).find((c) => c.id === platform);
69
+ if (!channel) {
70
+ const available = Object.values(channels).map((c) => c.id).join(", ");
71
+ throw new chunk64ITUOXI_cjs.HTTPException(404, {
72
+ message: `Channel "${platform}" is not registered. Available: ${available || "none"}`
73
+ });
74
+ }
75
+ return channel;
76
+ }
77
+ function assertAgentExists(mastra, agentId) {
78
+ const agent = mastra.getAgentById?.(agentId);
79
+ if (!agent) {
80
+ throw new chunk64ITUOXI_cjs.HTTPException(404, {
81
+ message: `Agent "${agentId}" not found`
82
+ });
83
+ }
84
+ }
85
+ var LIST_CHANNEL_PLATFORMS_ROUTE = chunk5UKYK7YK_cjs.createRoute({
86
+ method: "GET",
87
+ path: "/channels/platforms",
88
+ responseType: "json",
89
+ responseSchema: listChannelPlatformsResponseSchema,
90
+ summary: "List channel platforms",
91
+ description: "Returns available channel platforms and their configuration status",
92
+ tags: ["Channels"],
93
+ requiresAuth: true,
94
+ handler: async ({ mastra }) => {
95
+ assertChannelsAvailable();
96
+ try {
97
+ const channels = mastra.channels ?? {};
98
+ return Object.values(channels).map((channel) => {
99
+ if (channel.getInfo) {
100
+ return channel.getInfo();
101
+ }
102
+ return {
103
+ id: channel.id,
104
+ name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),
105
+ isConfigured: true
106
+ };
107
+ });
108
+ } catch (error) {
109
+ return chunkB34S64RC_cjs.handleError(error, "Error listing channel platforms");
110
+ }
111
+ }
112
+ });
113
+ var LIST_CHANNEL_INSTALLATIONS_ROUTE = chunk5UKYK7YK_cjs.createRoute({
114
+ method: "GET",
115
+ path: "/channels/:platform/installations",
116
+ responseType: "json",
117
+ pathParamSchema: channelPlatformPathParams,
118
+ responseSchema: listChannelInstallationsResponseSchema,
119
+ summary: "List channel installations",
120
+ description: "Returns all active and pending installations for a channel platform",
121
+ tags: ["Channels"],
122
+ requiresAuth: true,
123
+ handler: async ({ mastra, platform }) => {
124
+ assertChannelsAvailable();
125
+ try {
126
+ const channel = getChannelOrThrow(mastra, platform);
127
+ if (!channel.listInstallations) {
128
+ return [];
129
+ }
130
+ return await channel.listInstallations();
131
+ } catch (error) {
132
+ return chunkB34S64RC_cjs.handleError(error, "Error listing channel installations");
133
+ }
134
+ }
135
+ });
136
+ var CONNECT_CHANNEL_ROUTE = chunk5UKYK7YK_cjs.createRoute({
137
+ method: "POST",
138
+ path: "/channels/:platform/connect",
139
+ responseType: "json",
140
+ pathParamSchema: channelPlatformPathParams,
141
+ bodySchema: connectChannelBodySchema,
142
+ responseSchema: connectChannelResponseSchema,
143
+ summary: "Connect agent to channel",
144
+ description: "Creates a platform app for the agent and returns an OAuth authorization URL",
145
+ tags: ["Channels"],
146
+ requiresAuth: true,
147
+ handler: async ({ mastra, platform, agentId, options }) => {
148
+ assertChannelsAvailable();
149
+ try {
150
+ const channel = getChannelOrThrow(mastra, platform);
151
+ if (!channel.connect) {
152
+ throw new chunk64ITUOXI_cjs.HTTPException(400, {
153
+ message: `Channel "${platform}" does not support programmatic connection`
154
+ });
155
+ }
156
+ return await channel.connect(agentId, options);
157
+ } catch (error) {
158
+ return chunkB34S64RC_cjs.handleError(error, "Error connecting agent to channel");
159
+ }
160
+ }
161
+ });
162
+ var DISCONNECT_CHANNEL_ROUTE = chunk5UKYK7YK_cjs.createRoute({
163
+ method: "POST",
164
+ path: "/channels/:platform/:agentId/disconnect",
165
+ responseType: "json",
166
+ pathParamSchema: channelAgentPathParams,
167
+ responseSchema: disconnectChannelResponseSchema,
168
+ summary: "Disconnect agent from channel",
169
+ description: "Deletes the platform app and cleans up the installation",
170
+ tags: ["Channels"],
171
+ requiresAuth: true,
172
+ handler: async ({ mastra, platform, agentId }) => {
173
+ assertChannelsAvailable();
174
+ try {
175
+ assertAgentExists(mastra, agentId);
176
+ const channel = getChannelOrThrow(mastra, platform);
177
+ if (!channel.disconnect) {
178
+ throw new chunk64ITUOXI_cjs.HTTPException(400, {
179
+ message: `Channel "${platform}" does not support programmatic disconnection`
180
+ });
181
+ }
182
+ await channel.disconnect(agentId);
183
+ return { success: true };
184
+ } catch (error) {
185
+ return chunkB34S64RC_cjs.handleError(error, "Error disconnecting agent from channel");
186
+ }
187
+ }
188
+ });
189
+
190
+ exports.CONNECT_CHANNEL_ROUTE = CONNECT_CHANNEL_ROUTE;
191
+ exports.DISCONNECT_CHANNEL_ROUTE = DISCONNECT_CHANNEL_ROUTE;
192
+ exports.LIST_CHANNEL_INSTALLATIONS_ROUTE = LIST_CHANNEL_INSTALLATIONS_ROUTE;
193
+ exports.LIST_CHANNEL_PLATFORMS_ROUTE = LIST_CHANNEL_PLATFORMS_ROUTE;
194
+ //# sourceMappingURL=chunk-CXBX2UAP.cjs.map
195
+ //# sourceMappingURL=chunk-CXBX2UAP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"names":["z","coreFeatures","HTTPException","createRoute","handleError"],"mappings":";;;;;;;;AAMO,IAAM,yBAAA,GAA4BA,KAAE,MAAA,CAAO;AAAA,EAChD,QAAA,EAAUA,IAAA,CAAE,MAAA,EAAO,CAAE,SAAS,6CAA6C;AAC7E,CAAC,CAAA;AAEM,IAAM,sBAAA,GAAyBA,KAAE,MAA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} 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 { coreFeatures } from '@mastra/core/features';\n\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 { 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\nfunction getChannelOrThrow(mastra: any, platform: string) {\n const channels = mastra.channels ?? {};\n const channel = Object.values(channels).find((c: any) => c.id === platform) as any;\n if (!channel) {\n const available = Object.values(channels)\n .map((c: any) => c.id)\n .join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\nfunction assertAgentExists(mastra: any, agentId: string) {\n const agent = mastra.getAgentById?.(agentId);\n if (!agent) {\n throw new HTTPException(404, {\n message: `Agent \"${agentId}\" not found`,\n });\n }\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 = (mastra as any).channels ?? {};\n return Object.values(channels).map((channel: any) => {\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 = 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, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = 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 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, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n assertAgentExists(mastra, agentId);\n const channel = 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 channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"]}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var chunkSEAOI56Z_cjs = require('./chunk-SEAOI56Z.cjs');
3
4
  var chunkRPMBPQNO_cjs = require('./chunk-RPMBPQNO.cjs');
4
5
  var chunkR2ODPDKE_cjs = require('./chunk-R2ODPDKE.cjs');
5
6
  var chunkY2SA2JZT_cjs = require('./chunk-Y2SA2JZT.cjs');
6
- var chunkSEAOI56Z_cjs = require('./chunk-SEAOI56Z.cjs');
7
7
  var chunkTF7NSMHW_cjs = require('./chunk-TF7NSMHW.cjs');
8
8
  var chunkGUWIV3ZN_cjs = require('./chunk-GUWIV3ZN.cjs');
9
9
  var chunkYJQYJ5WD_cjs = require('./chunk-YJQYJ5WD.cjs');
@@ -30867,5 +30867,5 @@ exports.START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = START_ASYNC_AGENT_BUILDER_ACTIO
30867
30867
  exports.STREAM_AGENT_BUILDER_ACTION_ROUTE = STREAM_AGENT_BUILDER_ACTION_ROUTE;
30868
30868
  exports.STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE;
30869
30869
  exports.agent_builder_exports = agent_builder_exports;
30870
- //# sourceMappingURL=chunk-HR4M27JP.cjs.map
30871
- //# sourceMappingURL=chunk-HR4M27JP.cjs.map
30870
+ //# sourceMappingURL=chunk-LOZTHAYC.cjs.map
30871
+ //# sourceMappingURL=chunk-LOZTHAYC.cjs.map