managed-deepagents 0.4.0-dev.72 → 0.4.0-dev.73

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 (245) hide show
  1. package/dist/channels/binding.d.ts +3 -5
  2. package/dist/channels/binding.d.ts.map +1 -1
  3. package/dist/channels/binding.js +3 -9
  4. package/dist/channels/binding.js.map +1 -1
  5. package/dist/channels/collect.d.ts +23 -0
  6. package/dist/channels/collect.d.ts.map +1 -0
  7. package/dist/channels/collect.js +46 -0
  8. package/dist/channels/collect.js.map +1 -0
  9. package/dist/channels/github/adapter-core.d.ts +6 -0
  10. package/dist/channels/github/adapter-core.d.ts.map +1 -0
  11. package/dist/channels/github/adapter-core.js +27 -0
  12. package/dist/channels/github/adapter-core.js.map +1 -0
  13. package/dist/channels/github/adapter.d.ts +16 -0
  14. package/dist/channels/github/adapter.d.ts.map +1 -0
  15. package/dist/channels/github/adapter.js +52 -0
  16. package/dist/channels/github/adapter.js.map +1 -0
  17. package/dist/channels/github/define.d.ts +198 -0
  18. package/dist/channels/github/define.d.ts.map +1 -0
  19. package/dist/channels/github/define.js +166 -0
  20. package/dist/channels/github/define.js.map +1 -0
  21. package/dist/channels/github/http.d.ts +25 -0
  22. package/dist/channels/github/http.d.ts.map +1 -0
  23. package/dist/channels/github/http.js +147 -0
  24. package/dist/channels/github/http.js.map +1 -0
  25. package/dist/channels/github/index.d.ts +12 -0
  26. package/dist/channels/github/index.d.ts.map +1 -0
  27. package/dist/channels/github/index.js +10 -0
  28. package/dist/channels/github/index.js.map +1 -0
  29. package/dist/channels/github/normalize.d.ts +32 -0
  30. package/dist/channels/github/normalize.d.ts.map +1 -0
  31. package/dist/channels/github/normalize.js +152 -0
  32. package/dist/channels/github/normalize.js.map +1 -0
  33. package/dist/channels/github/source-thread.d.ts +24 -0
  34. package/dist/channels/github/source-thread.d.ts.map +1 -0
  35. package/dist/channels/github/source-thread.js +54 -0
  36. package/dist/channels/github/source-thread.js.map +1 -0
  37. package/dist/channels/github/transport.d.ts +19 -0
  38. package/dist/channels/github/transport.d.ts.map +1 -0
  39. package/dist/channels/github/transport.js +92 -0
  40. package/dist/channels/github/transport.js.map +1 -0
  41. package/dist/channels/index.d.ts +9 -1
  42. package/dist/channels/index.d.ts.map +1 -1
  43. package/dist/channels/index.js +4 -0
  44. package/dist/channels/index.js.map +1 -1
  45. package/dist/channels/manifest.d.ts +36 -0
  46. package/dist/channels/manifest.d.ts.map +1 -0
  47. package/dist/channels/manifest.js +20 -0
  48. package/dist/channels/manifest.js.map +1 -0
  49. package/dist/channels/plugin.d.ts +61 -0
  50. package/dist/channels/plugin.d.ts.map +1 -0
  51. package/dist/channels/plugin.js +80 -0
  52. package/dist/channels/plugin.js.map +1 -0
  53. package/dist/channels/registry-store.d.ts +12 -0
  54. package/dist/channels/registry-store.d.ts.map +1 -0
  55. package/dist/channels/registry-store.js +18 -0
  56. package/dist/channels/registry-store.js.map +1 -0
  57. package/dist/channels/registry-types.d.ts +32 -0
  58. package/dist/channels/registry-types.d.ts.map +1 -0
  59. package/dist/channels/registry-types.js +5 -0
  60. package/dist/channels/registry-types.js.map +1 -0
  61. package/dist/channels/registry.d.ts +17 -0
  62. package/dist/channels/registry.d.ts.map +1 -0
  63. package/dist/channels/registry.js +37 -0
  64. package/dist/channels/registry.js.map +1 -0
  65. package/dist/channels/runtime.d.ts +2 -2
  66. package/dist/channels/runtime.d.ts.map +1 -1
  67. package/dist/channels/runtime.js.map +1 -1
  68. package/dist/channels/schedule-delivery.d.ts +4 -0
  69. package/dist/channels/schedule-delivery.d.ts.map +1 -1
  70. package/dist/channels/schedule-delivery.js +6 -5
  71. package/dist/channels/schedule-delivery.js.map +1 -1
  72. package/dist/channels/slack/adapter-core.d.ts +6 -0
  73. package/dist/channels/slack/adapter-core.d.ts.map +1 -0
  74. package/dist/channels/slack/adapter-core.js +24 -0
  75. package/dist/channels/slack/adapter-core.js.map +1 -0
  76. package/dist/channels/slack/adapter.d.ts +10 -0
  77. package/dist/channels/slack/adapter.d.ts.map +1 -0
  78. package/dist/channels/slack/adapter.js +22 -0
  79. package/dist/channels/slack/adapter.js.map +1 -0
  80. package/dist/channels/slack/define.d.ts +8 -18
  81. package/dist/channels/slack/define.d.ts.map +1 -1
  82. package/dist/channels/slack/define.js +29 -10
  83. package/dist/channels/slack/define.js.map +1 -1
  84. package/dist/channels/slack/http.d.ts +12 -1
  85. package/dist/channels/slack/http.d.ts.map +1 -1
  86. package/dist/channels/slack/http.js +103 -47
  87. package/dist/channels/slack/http.js.map +1 -1
  88. package/dist/channels/store.d.ts +4 -4
  89. package/dist/channels/store.d.ts.map +1 -1
  90. package/dist/channels/store.js.map +1 -1
  91. package/dist/channels/types.d.ts +4 -4
  92. package/dist/channels/types.d.ts.map +1 -1
  93. package/dist/channels/types.js.map +1 -1
  94. package/dist/connectors/github/index.d.ts +80 -0
  95. package/dist/connectors/github/index.d.ts.map +1 -0
  96. package/dist/connectors/github/index.js +118 -0
  97. package/dist/connectors/github/index.js.map +1 -0
  98. package/dist/connectors/github/sandbox.d.ts +57 -0
  99. package/dist/connectors/github/sandbox.d.ts.map +1 -0
  100. package/dist/connectors/github/sandbox.js +534 -0
  101. package/dist/connectors/github/sandbox.js.map +1 -0
  102. package/dist/connectors/{langsmith.d.ts → langsmith/index.d.ts} +3 -3
  103. package/dist/connectors/langsmith/index.d.ts.map +1 -0
  104. package/dist/connectors/{langsmith.js → langsmith/index.js} +4 -4
  105. package/dist/connectors/langsmith/index.js.map +1 -0
  106. package/dist/{runtime/langsmith-connector.d.ts → connectors/langsmith/routes.d.ts} +4 -4
  107. package/dist/connectors/langsmith/routes.d.ts.map +1 -0
  108. package/dist/{runtime/langsmith-connector.js → connectors/langsmith/routes.js} +12 -6
  109. package/dist/connectors/langsmith/routes.js.map +1 -0
  110. package/dist/{connectors.d.ts → connectors/mcp/index.d.ts} +2 -2
  111. package/dist/connectors/mcp/index.d.ts.map +1 -0
  112. package/dist/{connectors.js → connectors/mcp/index.js} +3 -3
  113. package/dist/connectors/mcp/index.js.map +1 -0
  114. package/dist/{runtime/connectors-manager.d.ts → connectors/mcp/load.d.ts} +2 -2
  115. package/dist/connectors/mcp/load.d.ts.map +1 -0
  116. package/dist/{runtime/connectors-manager.js → connectors/mcp/load.js} +1 -1
  117. package/dist/connectors/mcp/load.js.map +1 -0
  118. package/dist/identity/connect-paths.d.ts +8 -0
  119. package/dist/identity/connect-paths.d.ts.map +1 -0
  120. package/dist/identity/connect-paths.js +11 -0
  121. package/dist/identity/connect-paths.js.map +1 -0
  122. package/dist/identity/connect-provider-store.d.ts +16 -0
  123. package/dist/identity/connect-provider-store.d.ts.map +1 -0
  124. package/dist/identity/connect-provider-store.js +27 -0
  125. package/dist/identity/connect-provider-store.js.map +1 -0
  126. package/dist/identity/connect-provider-types.d.ts +68 -0
  127. package/dist/identity/connect-provider-types.d.ts.map +1 -0
  128. package/dist/identity/connect-provider-types.js +8 -0
  129. package/dist/identity/connect-provider-types.js.map +1 -0
  130. package/dist/identity/connect-provider.d.ts +33 -0
  131. package/dist/identity/connect-provider.d.ts.map +1 -0
  132. package/dist/identity/connect-provider.js +125 -0
  133. package/dist/identity/connect-provider.js.map +1 -0
  134. package/dist/identity/github/connect-http.d.ts +33 -0
  135. package/dist/identity/github/connect-http.d.ts.map +1 -0
  136. package/dist/identity/github/connect-http.js +111 -0
  137. package/dist/identity/github/connect-http.js.map +1 -0
  138. package/dist/identity/github/credentials-store.d.ts +76 -0
  139. package/dist/identity/github/credentials-store.d.ts.map +1 -0
  140. package/dist/identity/github/credentials-store.js +257 -0
  141. package/dist/identity/github/credentials-store.js.map +1 -0
  142. package/dist/identity/github/credentials.d.ts +82 -0
  143. package/dist/identity/github/credentials.d.ts.map +1 -0
  144. package/dist/identity/github/credentials.js +171 -0
  145. package/dist/identity/github/credentials.js.map +1 -0
  146. package/dist/identity/github/index.d.ts +10 -0
  147. package/dist/identity/github/index.d.ts.map +1 -0
  148. package/dist/identity/github/index.js +9 -0
  149. package/dist/identity/github/index.js.map +1 -0
  150. package/dist/identity/github/oauth.d.ts +50 -0
  151. package/dist/identity/github/oauth.d.ts.map +1 -0
  152. package/dist/identity/github/oauth.js +146 -0
  153. package/dist/identity/github/oauth.js.map +1 -0
  154. package/dist/identity/index.d.ts +2 -1
  155. package/dist/identity/index.d.ts.map +1 -1
  156. package/dist/identity/index.js +30 -0
  157. package/dist/identity/index.js.map +1 -1
  158. package/dist/identity/loopback.d.ts +8 -0
  159. package/dist/identity/loopback.d.ts.map +1 -0
  160. package/dist/identity/loopback.js +18 -0
  161. package/dist/identity/loopback.js.map +1 -0
  162. package/dist/identity/slack/connect-http.d.ts +36 -0
  163. package/dist/identity/slack/connect-http.d.ts.map +1 -0
  164. package/dist/identity/slack/connect-http.js +111 -0
  165. package/dist/identity/slack/connect-http.js.map +1 -0
  166. package/dist/identity/slack/index.d.ts +9 -0
  167. package/dist/identity/slack/index.d.ts.map +1 -0
  168. package/dist/identity/slack/index.js +8 -0
  169. package/dist/identity/slack/index.js.map +1 -0
  170. package/dist/identity/slack/links.d.ts.map +1 -0
  171. package/dist/identity/{links.js → slack/links.js} +2 -12
  172. package/dist/identity/slack/links.js.map +1 -0
  173. package/dist/identity/{slack-oauth.d.ts → slack/oauth.d.ts} +1 -1
  174. package/dist/identity/slack/oauth.d.ts.map +1 -0
  175. package/dist/identity/{slack-oauth.js → slack/oauth.js} +1 -1
  176. package/dist/identity/slack/oauth.js.map +1 -0
  177. package/dist/identity/types.d.ts +12 -1
  178. package/dist/identity/types.d.ts.map +1 -1
  179. package/dist/index.d.ts +13 -6
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +7 -2
  182. package/dist/index.js.map +1 -1
  183. package/dist/runtime/auth.d.ts +6 -0
  184. package/dist/runtime/auth.d.ts.map +1 -1
  185. package/dist/runtime/auth.js +19 -8
  186. package/dist/runtime/auth.js.map +1 -1
  187. package/dist/runtime/backend.d.ts +52 -0
  188. package/dist/runtime/backend.d.ts.map +1 -0
  189. package/dist/runtime/backend.js +165 -0
  190. package/dist/runtime/backend.js.map +1 -0
  191. package/dist/runtime/connector.d.ts +43 -12
  192. package/dist/runtime/connector.d.ts.map +1 -1
  193. package/dist/runtime/connector.js +25 -10
  194. package/dist/runtime/connector.js.map +1 -1
  195. package/dist/runtime/cors.js +1 -1
  196. package/dist/runtime/identity-http.d.ts +9 -3
  197. package/dist/runtime/identity-http.d.ts.map +1 -1
  198. package/dist/runtime/identity-http.js +24 -34
  199. package/dist/runtime/identity-http.js.map +1 -1
  200. package/dist/runtime/identity-runtime.d.ts +9 -28
  201. package/dist/runtime/identity-runtime.d.ts.map +1 -1
  202. package/dist/runtime/identity-runtime.js +30 -65
  203. package/dist/runtime/identity-runtime.js.map +1 -1
  204. package/dist/runtime/index.d.ts +9 -3
  205. package/dist/runtime/index.d.ts.map +1 -1
  206. package/dist/runtime/index.js +26 -68
  207. package/dist/runtime/index.js.map +1 -1
  208. package/dist/runtime/memory/index.d.ts +2 -2
  209. package/dist/runtime/memory/index.d.ts.map +1 -1
  210. package/dist/runtime/memory/index.js +2 -2
  211. package/dist/runtime/memory/index.js.map +1 -1
  212. package/dist/runtime/memory/mounts.d.ts +15 -1
  213. package/dist/runtime/memory/mounts.d.ts.map +1 -1
  214. package/dist/runtime/memory/mounts.js +31 -7
  215. package/dist/runtime/memory/mounts.js.map +1 -1
  216. package/dist/runtime/memory/paths.d.ts +0 -5
  217. package/dist/runtime/memory/paths.d.ts.map +1 -1
  218. package/dist/runtime/memory/paths.js +0 -24
  219. package/dist/runtime/memory/paths.js.map +1 -1
  220. package/dist/runtime/memory/seed.d.ts +0 -16
  221. package/dist/runtime/memory/seed.d.ts.map +1 -1
  222. package/dist/runtime/memory/seed.js +0 -43
  223. package/dist/runtime/memory/seed.js.map +1 -1
  224. package/dist/runtime/sandbox-manager.d.ts +20 -2
  225. package/dist/runtime/sandbox-manager.d.ts.map +1 -1
  226. package/dist/runtime/sandbox-manager.js +102 -9
  227. package/dist/runtime/sandbox-manager.js.map +1 -1
  228. package/package.json +11 -7
  229. package/dist/connectors/langsmith.d.ts.map +0 -1
  230. package/dist/connectors/langsmith.js.map +0 -1
  231. package/dist/connectors.d.ts.map +0 -1
  232. package/dist/connectors.js.map +0 -1
  233. package/dist/identity/links.d.ts.map +0 -1
  234. package/dist/identity/links.js.map +0 -1
  235. package/dist/identity/slack-connect-http.d.ts +0 -21
  236. package/dist/identity/slack-connect-http.d.ts.map +0 -1
  237. package/dist/identity/slack-connect-http.js +0 -129
  238. package/dist/identity/slack-connect-http.js.map +0 -1
  239. package/dist/identity/slack-oauth.d.ts.map +0 -1
  240. package/dist/identity/slack-oauth.js.map +0 -1
  241. package/dist/runtime/connectors-manager.d.ts.map +0 -1
  242. package/dist/runtime/connectors-manager.js.map +0 -1
  243. package/dist/runtime/langsmith-connector.d.ts.map +0 -1
  244. package/dist/runtime/langsmith-connector.js.map +0 -1
  245. /package/dist/identity/{links.d.ts → slack/links.d.ts} +0 -0
@@ -5,16 +5,15 @@
5
5
  * The runtime seam rebuilds `runtime.channel` only when the trusted auth user
6
6
  * source provider matches — clients cannot invent a channel surface.
7
7
  */
8
- import { wasFinalPosted } from "./runtime.js";
9
8
  import type { ChannelTransport } from "./runtime.js";
10
- import type { ChannelAddress, ChannelEvent, ChannelProvider, RuntimeChannel } from "./types.js";
9
+ import type { ChannelAddress, ChannelEvent, RuntimeChannel } from "./types.js";
11
10
  /** Env var holding the Slack bot token for Phase 1 single-workspace installs. */
12
11
  export declare const SLACK_BOT_TOKEN_ENV = "SLACK_BOT_TOKEN";
13
12
  /** Configurable key stamped by the managed channel runner (never client-trusted alone). */
14
13
  export declare const CHANNEL_BINDING_KEY = "mda_channel_binding";
15
14
  export interface ChannelBinding {
16
15
  name: string;
17
- provider: ChannelProvider;
16
+ provider: string;
18
17
  event: ChannelEvent;
19
18
  address: ChannelAddress;
20
19
  autoReply: boolean;
@@ -29,6 +28,5 @@ export declare function wasDeliveryFinalPosted(deliveryId: string): boolean;
29
28
  * Returns `undefined` unless the auth user source provider matches the binding
30
29
  * and a transport can be constructed.
31
30
  */
32
- export declare function resolveRuntimeChannel(configurable: Record<string, unknown> | undefined, transportFactory?: (provider: ChannelProvider) => ChannelTransport | undefined): RuntimeChannel | undefined;
33
- export { wasFinalPosted };
31
+ export declare function resolveRuntimeChannel(configurable: Record<string, unknown> | undefined, transportFactory?: (provider: string) => ChannelTransport | undefined): RuntimeChannel | undefined;
34
32
  //# sourceMappingURL=binding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/channels/binding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAwB,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAKzD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEzD;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjD,gBAAgB,GAAE,CAChB,QAAQ,EAAE,eAAe,KACtB,gBAAgB,GAAG,SAA4B,GACnD,cAAc,GAAG,SAAS,CA+B5B;AAWD,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/channels/binding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/E,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAKzD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEzD;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjD,gBAAgB,GAAE,CAChB,QAAQ,EAAE,MAAM,KACb,gBAAgB,GAAG,SAA4B,GACnD,cAAc,GAAG,SAAS,CA+B5B"}
@@ -5,8 +5,8 @@
5
5
  * The runtime seam rebuilds `runtime.channel` only when the trusted auth user
6
6
  * source provider matches — clients cannot invent a channel surface.
7
7
  */
8
- import { createRuntimeChannel, wasFinalPosted } from "./runtime.js";
9
- import { createSlackWebApiTransport } from "./slack/transport.js";
8
+ import { createRuntimeChannel } from "./runtime.js";
9
+ import { getChannelAdapter } from "./registry.js";
10
10
  /** Env var holding the Slack bot token for Phase 1 single-workspace installs. */
11
11
  export const SLACK_BOT_TOKEN_ENV = "SLACK_BOT_TOKEN";
12
12
  /** Configurable key stamped by the managed channel runner (never client-trusted alone). */
@@ -56,12 +56,6 @@ export function resolveRuntimeChannel(configurable, transportFactory = defaultTr
56
56
  });
57
57
  }
58
58
  function defaultTransport(provider) {
59
- if (provider !== "slack")
60
- return undefined;
61
- const token = process.env[SLACK_BOT_TOKEN_ENV];
62
- if (!token)
63
- return undefined;
64
- return createSlackWebApiTransport({ botToken: token });
59
+ return getChannelAdapter(provider)?.createTransport(process.env);
65
60
  }
66
- export { wasFinalPosted };
67
61
  //# sourceMappingURL=binding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/channels/binding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD,sFAAsF;AACtF,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAmB,CAAC;AAWzD,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,qBAAqB,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACvD,OAAO,qBAAqB,CAAC,GA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OAAO,CAAC,IAAI,KAAK,QAAQ;QAChC,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;QACpC,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;QACtC,cAAc,KAAK,OAAO,CAAC,QAAQ,EACnC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IAEjC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACtC,OAAO,oBAAoB,CAAC;QAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS;QACT,aAAa,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC;KACjD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,iBAAiB,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Collect validated channel declarations from discovered `channels/` modules.
3
+ *
4
+ * Mirrors {@link collectConnectors}: each module must export a named branded
5
+ * {@link ChannelDefinition}. Adapters are registered during collect.
6
+ */
7
+ import { type ChannelDefinition } from "./plugin.js";
8
+ export interface ChannelModuleEntry {
9
+ /** Project-relative source path for error messages (`channels/github.ts`). */
10
+ source: string;
11
+ /** Imported module namespace / exports object. */
12
+ module: {
13
+ channel?: unknown;
14
+ [key: string]: unknown;
15
+ };
16
+ }
17
+ /**
18
+ * Map file-stem channel names to their live declarations.
19
+ *
20
+ * @param entries - Discovered channel modules with project-relative sources.
21
+ */
22
+ export declare function collectChannels(entries: readonly ChannelModuleEntry[]): Record<string, ChannelDefinition>;
23
+ //# sourceMappingURL=collect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/channels/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA4BnC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Collect validated channel declarations from discovered `channels/` modules.
3
+ *
4
+ * Mirrors {@link collectConnectors}: each module must export a named branded
5
+ * {@link ChannelDefinition}. Adapters are registered during collect.
6
+ */
7
+ import { isChannelDefinition } from "./plugin.js";
8
+ import { registerChannelAdapter } from "./registry-store.js";
9
+ /**
10
+ * Map file-stem channel names to their live declarations.
11
+ *
12
+ * @param entries - Discovered channel modules with project-relative sources.
13
+ */
14
+ export function collectChannels(entries) {
15
+ const out = {};
16
+ for (const entry of entries) {
17
+ const channel = entry.module.channel;
18
+ if (channel === undefined || channel === null) {
19
+ throw new Error(`${entry.source} defines no \`channel\` export. A file under channels/ ` +
20
+ "must export exactly one branded channel as `channel` " +
21
+ "(e.g. `export const channel = defineGitHubChannel(...)` or a " +
22
+ "third-party `defineXChannel` that returns defineChannel(...)).");
23
+ }
24
+ if (!isChannelDefinition(channel)) {
25
+ throw new Error(`${entry.source} export \`channel\` is not a branded ChannelDefinition. ` +
26
+ "The define* helper must return an object with CHANNEL_BRAND, " +
27
+ "provider, adapter, toManifest, and config " +
28
+ "(use defineChannel(...) from managed-deepagents/channels).");
29
+ }
30
+ const name = channelStemName(entry.source);
31
+ if (out[name] !== undefined) {
32
+ throw new Error(`duplicate channel name '${name}' from channels/`);
33
+ }
34
+ registerChannelAdapter(channel.adapter);
35
+ out[name] = channel;
36
+ }
37
+ return out;
38
+ }
39
+ function channelStemName(source) {
40
+ const base = source.replace(/^.*\//, "").replace(/\.(ts|js|py)$/, "");
41
+ if (!base || base === "channel") {
42
+ throw new Error(`invalid channel path "${source}": use channels/<name>.ts (not channel.ts)`);
43
+ }
44
+ return base;
45
+ }
46
+ //# sourceMappingURL=collect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect.js","sourceRoot":"","sources":["../../src/channels/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAA0B,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAS7D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAsC;IAEtC,MAAM,GAAG,GAAsC,EAAE,CAAC;IAClD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QACrC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,CAAC,MAAM,yDAAyD;gBACtE,uDAAuD;gBACvD,+DAA+D;gBAC/D,gEAAgE,CACnE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,CAAC,MAAM,0DAA0D;gBACvE,+DAA+D;gBAC/D,4CAA4C;gBAC5C,4DAA4D,CAC/D,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAC;QACrE,CAAC;QACD,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACtE,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,yBAAyB,MAAM,4CAA4C,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * GitHub adapter object without imports from `define.ts` (avoids load cycles).
3
+ */
4
+ import type { ChannelProviderAdapter } from "../registry-types.js";
5
+ export declare const githubChannelAdapter: ChannelProviderAdapter;
6
+ //# sourceMappingURL=adapter-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-core.d.ts","sourceRoot":"","sources":["../../../src/channels/github/adapter-core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AASnE,eAAO,MAAM,oBAAoB,EAAE,sBAyBlC,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * GitHub adapter object without imports from `define.ts` (avoids load cycles).
3
+ */
4
+ import { handleGitHubEventsRequest } from "./http.js";
5
+ import { createGitHubAppTransport, GITHUB_APP_ID_ENV, GITHUB_APP_PRIVATE_KEY_ENV, GITHUB_INSTALLATION_ID_ENV, } from "./transport.js";
6
+ export const githubChannelAdapter = {
7
+ provider: "github",
8
+ async handleEventsRequest(request, ctx) {
9
+ const definition = ctx.definition;
10
+ const { githubConfigFromManifest } = await import("./adapter.js");
11
+ return handleGitHubEventsRequest(request, {
12
+ name: ctx.name,
13
+ config: definition?.config ?? githubConfigFromManifest(ctx.manifest),
14
+ definition: ctx.definition,
15
+ rawBody: ctx.rawBody,
16
+ });
17
+ },
18
+ createTransport(env) {
19
+ const appId = env[GITHUB_APP_ID_ENV] ?? "";
20
+ const privateKey = env[GITHUB_APP_PRIVATE_KEY_ENV] ?? "";
21
+ const installationId = env[GITHUB_INSTALLATION_ID_ENV] ?? "";
22
+ if (!appId || !privateKey || !installationId)
23
+ return undefined;
24
+ return createGitHubAppTransport({ appId, privateKey, installationId });
25
+ },
26
+ };
27
+ //# sourceMappingURL=adapter-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-core.js","sourceRoot":"","sources":["../../../src/channels/github/adapter-core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,QAAQ,EAAE,QAAQ;IAElB,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,GAAG;QACpC,MAAM,UAAU,GAAG,GAAG,CAAC,UAEV,CAAC;QACd,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;QAClE,OAAO,yBAAyB,CAAC,OAAO,EAAE;YACxC,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,UAAU,EAAE,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC;YACpE,UAAU,EAAE,GAAG,CAAC,UAEE;YAClB,OAAO,EAAE,GAAG,CAAC,OAAO;SACrB,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,GAAG;QACjB,MAAM,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC;QACzD,MAAM,cAAc,GAAG,GAAG,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,KAAK,IAAI,CAAC,UAAU,IAAI,CAAC,cAAc;YAAE,OAAO,SAAS,CAAC;QAC/D,OAAO,wBAAwB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;IACzE,CAAC;CACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * GitHub channel provider adapter — registry entry for webhooks + transport.
3
+ */
4
+ import type { ChannelManifest } from "../manifest.js";
5
+ import type { RequiredGitHubChannelConfig } from "./define.js";
6
+ import { GITHUB_CHANNEL_REQUIRED_ENV } from "./define.js";
7
+ export { GITHUB_CHANNEL_REQUIRED_ENV };
8
+ export { githubChannelAdapter } from "./adapter-core.js";
9
+ /**
10
+ * Rebuild a config shell from the JSON manifest when the live module is absent.
11
+ *
12
+ * Manifest handlers have no `prompt` — callers that only have the manifest
13
+ * cannot produce agent task text. Prefer passing the live definition.
14
+ */
15
+ export declare function githubConfigFromManifest(manifest: ChannelManifest): RequiredGitHubChannelConfig;
16
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/channels/github/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAEV,2BAA2B,EAE5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,eAAe,GACxB,2BAA2B,CA6C7B"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * GitHub channel provider adapter — registry entry for webhooks + transport.
3
+ */
4
+ import { GITHUB_CHANNEL_REQUIRED_ENV } from "./define.js";
5
+ export { GITHUB_CHANNEL_REQUIRED_ENV };
6
+ export { githubChannelAdapter } from "./adapter-core.js";
7
+ /**
8
+ * Rebuild a config shell from the JSON manifest when the live module is absent.
9
+ *
10
+ * Manifest handlers have no `prompt` — callers that only have the manifest
11
+ * cannot produce agent task text. Prefer passing the live definition.
12
+ */
13
+ export function githubConfigFromManifest(manifest) {
14
+ const cfg = manifest.providerConfig;
15
+ const rawHandlers = cfg.handlers;
16
+ if (Array.isArray(rawHandlers) && rawHandlers.length > 0) {
17
+ const handlers = rawHandlers.map((entry, index) => {
18
+ const h = entry;
19
+ const on = h.on;
20
+ const autoReply = typeof h.autoReply === "boolean"
21
+ ? h.autoReply
22
+ : typeof h.auto_reply === "boolean"
23
+ ? h.auto_reply
24
+ : true;
25
+ const repositories = Array.isArray(h.repositories)
26
+ ? h.repositories
27
+ : undefined;
28
+ return {
29
+ on,
30
+ repositories,
31
+ autoReply,
32
+ prompt: () => {
33
+ throw new Error(`GitHub channel "${manifest.name}" handlers[${index}] has no live ` +
34
+ "`prompt` callback; ensure the channel module is loaded via _mda_channels.");
35
+ },
36
+ };
37
+ });
38
+ return { handlers };
39
+ }
40
+ // Legacy manifests with flat triggers only — stub so mount does not crash.
41
+ const triggers = cfg.triggers ?? [];
42
+ return {
43
+ handlers: triggers.map((on) => ({
44
+ on,
45
+ autoReply: manifest.autoReply,
46
+ prompt: () => {
47
+ throw new Error(`GitHub channel "${manifest.name}" requires a live handlers[].prompt callback`);
48
+ },
49
+ })),
50
+ };
51
+ }
52
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/channels/github/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAyB;IAEzB,MAAM,GAAG,GAAG,QAAQ,CAAC,cAA4B,CAAC;IAClD,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,MAAM,QAAQ,GAAmC,WAAW,CAAC,GAAG,CAC9D,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,CAAC,GAAG,KAAgC,CAAC;YAC3C,MAAM,EAAE,GAAG,CAAC,CAAC,EAA0B,CAAC;YACxC,MAAM,SAAS,GACb,OAAO,CAAC,CAAC,SAAS,KAAK,SAAS;gBAC9B,CAAC,CAAC,CAAC,CAAC,SAAS;gBACb,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,SAAS;oBACjC,CAAC,CAAC,CAAC,CAAC,UAAU;oBACd,CAAC,CAAC,IAAI,CAAC;YACb,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC;gBAChD,CAAC,CAAE,CAAC,CAAC,YAAyB;gBAC9B,CAAC,CAAC,SAAS,CAAC;YACd,OAAO;gBACL,EAAE;gBACF,YAAY;gBACZ,SAAS;gBACT,MAAM,EAAE,GAAG,EAAE;oBACX,MAAM,IAAI,KAAK,CACb,mBAAmB,QAAQ,CAAC,IAAI,cAAc,KAAK,gBAAgB;wBACjE,2EAA2E,CAC9E,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC,CACF,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,CAAC;IACtB,CAAC;IACD,2EAA2E;IAC3E,MAAM,QAAQ,GAAI,GAAG,CAAC,QAA4C,IAAI,EAAE,CAAC;IACzE,OAAO;QACL,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC9B,EAAE;YACF,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,MAAM,EAAE,GAAG,EAAE;gBACX,MAAM,IAAI,KAAK,CACb,mBAAmB,QAAQ,CAAC,IAAI,8CAA8C,CAC/E,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * `defineGitHubChannel` — declarative GitHub App webhook channel authoring.
3
+ *
4
+ * Authors declare **handlers** (event filter + optional repo scope + `prompt`).
5
+ * `instructions.md` remains the agent system prompt; each handler's `prompt`
6
+ * builds the human message for that webhook turn.
7
+ *
8
+ * MDA does **not** ship copies of GitHub webhook payload types. Prefer
9
+ * [`@octokit/webhooks-types`](https://www.npmjs.com/package/@octokit/webhooks-types)
10
+ * in the agent project and narrow {@link GitHubWebhookPromptEvent.payload}:
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import type { PullRequestOpenedEvent } from "@octokit/webhooks-types";
15
+ *
16
+ * prompt(event) {
17
+ * const pr = event.payload as PullRequestOpenedEvent;
18
+ * return `Review ${pr.pull_request.title}`;
19
+ * }
20
+ * ```
21
+ */
22
+ import { type ChannelDefinition, type ChannelManifestBody } from "../plugin.js";
23
+ /**
24
+ * GitHub webhook filter for a handler's {@link GitHubChannelHandler.on}.
25
+ *
26
+ * - `"pull_request"` — any action for that `X-GitHub-Event`
27
+ * - `"pull_request.opened"` — event + `payload.action`
28
+ * - `"*"` — every webhook delivery
29
+ *
30
+ * Any non-empty string is accepted; MDA does not maintain an event allowlist.
31
+ */
32
+ export type GitHubChannelTrigger = string;
33
+ /**
34
+ * Envelope passed to {@link GitHubChannelHandler.prompt}.
35
+ *
36
+ * Common routing fields are lifted for filters / auto-reply. The raw webhook
37
+ * JSON stays on {@link GitHubWebhookPromptEvent.payload} as `unknown` so callers
38
+ * can narrow with Octokit (or other) types without MDA duplicating schemas.
39
+ */
40
+ export interface GitHubWebhookPromptEvent {
41
+ /**
42
+ * `X-GitHub-Event` header value (e.g. `"pull_request"`, `"issues"`, `"push"`).
43
+ */
44
+ eventName: string;
45
+ /**
46
+ * `payload.action` when present (e.g. `"opened"`). Omitted for events without
47
+ * an action field.
48
+ */
49
+ action?: string;
50
+ /**
51
+ * Convenience id: `eventName` or `eventName.action` when `action` is set.
52
+ *
53
+ * @example `"pull_request.opened"`
54
+ */
55
+ trigger: string;
56
+ /** `X-GitHub-Delivery` header. */
57
+ deliveryId: string;
58
+ /** Repository full name (`owner/repo`) when the payload includes `repository`. */
59
+ repository?: string;
60
+ /** GitHub App installation id when present on the payload or env fallback. */
61
+ installationId?: string;
62
+ /**
63
+ * Issue or pull request number when the payload includes one (used for
64
+ * source-thread keys and auto-reply comments).
65
+ */
66
+ issueOrPullNumber?: number;
67
+ /**
68
+ * Verified webhook JSON body. Treat as `unknown` and narrow with
69
+ * `@octokit/webhooks-types` (or equivalent) in the agent project.
70
+ */
71
+ payload: unknown;
72
+ }
73
+ /**
74
+ * One subscription inside {@link defineGitHubChannel}.
75
+ *
76
+ * Handlers are matched in order: first handler whose `on` matches the webhook
77
+ * and whose `repositories` allowlist (if set) includes the repo wins.
78
+ */
79
+ export interface GitHubChannelHandler {
80
+ /**
81
+ * Which deliveries this handler accepts.
82
+ *
83
+ * @see GitHubChannelTrigger
84
+ */
85
+ on: GitHubChannelTrigger;
86
+ /**
87
+ * Restrict this handler to these repositories (`owner/repo`).
88
+ * Omit or leave empty to accept any repository (including payloads with no
89
+ * `repository` field when the allowlist is omitted).
90
+ */
91
+ repositories?: readonly string[];
92
+ /**
93
+ * When `true` and the payload identifies an issue/PR (`owner/repo#N`), post
94
+ * the agent’s final reply as an issue comment on that conversation. When
95
+ * `false`, or when no issue/PR number can be resolved, the agent still runs
96
+ * but no comment is posted.
97
+ *
98
+ * @default true
99
+ */
100
+ autoReply?: boolean;
101
+ /**
102
+ * Build the human message for the agent turn from the webhook envelope.
103
+ *
104
+ * Narrow `event.payload` with `@octokit/webhooks-types` in your project —
105
+ * MDA does not vendor those schemas.
106
+ */
107
+ prompt: (event: GitHubWebhookPromptEvent) => string;
108
+ }
109
+ /**
110
+ * Serializable handler metadata embedded in the compile/deploy manifest.
111
+ * Live `prompt` callbacks are not included — they come from the imported module.
112
+ */
113
+ export interface GitHubChannelHandlerManifest {
114
+ /** Event filter (`event`, `event.action`, or `"*"`). */
115
+ on: GitHubChannelTrigger;
116
+ /** Optional repo allowlist (`owner/repo`). */
117
+ repositories?: readonly string[];
118
+ /** Whether this handler attempts a PR/issue comment after the agent run. */
119
+ autoReply: boolean;
120
+ }
121
+ /**
122
+ * Authoring input for {@link defineGitHubChannel}.
123
+ *
124
+ * Routing and per-event task text only — agent persona/tools stay on
125
+ * `instructions.md` and the agent definition.
126
+ */
127
+ export interface GitHubChannelConfig {
128
+ /**
129
+ * Ordered handler list. First match wins for each webhook delivery.
130
+ */
131
+ handlers: readonly GitHubChannelHandler[];
132
+ }
133
+ /**
134
+ * Normalized GitHub channel config after {@link defineGitHubChannel} validation.
135
+ *
136
+ * Retains live `prompt` callbacks for runtime. Used when the channel module is
137
+ * imported by the managed HTTP app.
138
+ */
139
+ export interface RequiredGitHubChannelConfig {
140
+ /** Normalized handlers with defaults applied (`autoReply` → `true`). */
141
+ handlers: readonly RequiredGitHubChannelHandler[];
142
+ }
143
+ /**
144
+ * Normalized handler with defaults applied.
145
+ */
146
+ export interface RequiredGitHubChannelHandler {
147
+ on: GitHubChannelTrigger;
148
+ repositories?: readonly string[];
149
+ autoReply: boolean;
150
+ prompt: (event: GitHubWebhookPromptEvent) => string;
151
+ }
152
+ /**
153
+ * Validated channel declaration returned by {@link defineGitHubChannel}.
154
+ *
155
+ * Files under `channels/*.ts` export a named `channel` of this shape for CLI
156
+ * discovery. The live object (including `prompt` callbacks) is imported at
157
+ * runtime via `_mda_channels`; the JSON manifest carries only serializable
158
+ * metadata for deploy secrets and mount.
159
+ */
160
+ export type GitHubChannelDefinition = ChannelDefinition<RequiredGitHubChannelConfig>;
161
+ /** Env vars for Phase 1 single-install GitHub App webhooks. */
162
+ export declare const GITHUB_CHANNEL_REQUIRED_ENV: readonly ["GITHUB_WEBHOOK_SECRET", "GITHUB_APP_ID", "GITHUB_APP_PRIVATE_KEY", "GITHUB_INSTALLATION_ID"];
163
+ /**
164
+ * Declare a managed GitHub channel. Files under `channels/*.ts` export a named
165
+ * `channel` created with this helper.
166
+ *
167
+ * @param config - Handlers that map webhook events to agent turns.
168
+ */
169
+ export declare function defineGitHubChannel(config: GitHubChannelConfig): GitHubChannelDefinition;
170
+ /**
171
+ * GitHub App permissions implied by handlers.
172
+ *
173
+ * Auto-reply comments need `issues:write`. Contents/metadata reads are declared
174
+ * broadly so arbitrary webhook handlers can inspect payloads; tighten App
175
+ * permissions in GitHub settings to match what you actually use.
176
+ */
177
+ export declare function requiredGitHubPermissions(config: RequiredGitHubChannelConfig): string[];
178
+ /**
179
+ * Build author-supplied deploy fields for a GitHub channel.
180
+ *
181
+ * `name` and `provider` are stamped by {@link defineChannel} / `toManifest(name)`.
182
+ */
183
+ export declare function toGitHubChannelManifest(definition: GitHubChannelDefinition | RequiredGitHubChannelConfig): ChannelManifestBody;
184
+ /**
185
+ * Whether a handler `on` filter matches a delivery.
186
+ *
187
+ * @param on - `"*"`, `"pull_request"`, or `"pull_request.opened"`
188
+ * @param eventName - `X-GitHub-Event`
189
+ * @param action - `payload.action` when present
190
+ */
191
+ export declare function githubTriggerMatches(on: string, eventName: string, action?: string): boolean;
192
+ /**
193
+ * Find the first handler that matches event/action + repository.
194
+ *
195
+ * @returns The handler, or `undefined` when no handler matches (event ignored).
196
+ */
197
+ export declare function matchGitHubHandler(config: RequiredGitHubChannelConfig, eventName: string, repository: string | undefined, action?: string): RequiredGitHubChannelHandler | undefined;
198
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/channels/github/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAItB;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,EAAE,EAAE,oBAAoB,CAAC;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,MAAM,CAAC;CACrD;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,wDAAwD;IACxD,EAAE,EAAE,oBAAoB,C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E,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,CAAC,EAAE,MAAM,GACd,4BAA4B,GAAG,SAAS,CAU1C"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * `defineGitHubChannel` — declarative GitHub App webhook channel authoring.
3
+ *
4
+ * Authors declare **handlers** (event filter + optional repo scope + `prompt`).
5
+ * `instructions.md` remains the agent system prompt; each handler's `prompt`
6
+ * builds the human message for that webhook turn.
7
+ *
8
+ * MDA does **not** ship copies of GitHub webhook payload types. Prefer
9
+ * [`@octokit/webhooks-types`](https://www.npmjs.com/package/@octokit/webhooks-types)
10
+ * in the agent project and narrow {@link GitHubWebhookPromptEvent.payload}:
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import type { PullRequestOpenedEvent } from "@octokit/webhooks-types";
15
+ *
16
+ * prompt(event) {
17
+ * const pr = event.payload as PullRequestOpenedEvent;
18
+ * return `Review ${pr.pull_request.title}`;
19
+ * }
20
+ * ```
21
+ */
22
+ import { defineChannel, } from "../plugin.js";
23
+ import { githubChannelAdapter } from "./adapter-core.js";
24
+ /** Env vars for Phase 1 single-install GitHub App webhooks. */
25
+ export const GITHUB_CHANNEL_REQUIRED_ENV = [
26
+ "GITHUB_WEBHOOK_SECRET",
27
+ "GITHUB_APP_ID",
28
+ "GITHUB_APP_PRIVATE_KEY",
29
+ "GITHUB_INSTALLATION_ID",
30
+ ];
31
+ /**
32
+ * Declare a managed GitHub channel. Files under `channels/*.ts` export a named
33
+ * `channel` created with this helper.
34
+ *
35
+ * @param config - Handlers that map webhook events to agent turns.
36
+ */
37
+ export function defineGitHubChannel(config) {
38
+ const normalized = validateAndNormalize(config);
39
+ return defineChannel({
40
+ provider: "github",
41
+ adapter: githubChannelAdapter,
42
+ config: normalized,
43
+ toManifest: () => toGitHubChannelManifest(normalized),
44
+ });
45
+ }
46
+ /**
47
+ * GitHub App permissions implied by handlers.
48
+ *
49
+ * Auto-reply comments need `issues:write`. Contents/metadata reads are declared
50
+ * broadly so arbitrary webhook handlers can inspect payloads; tighten App
51
+ * permissions in GitHub settings to match what you actually use.
52
+ */
53
+ export function requiredGitHubPermissions(config) {
54
+ const perms = new Set(["metadata:read"]);
55
+ for (const handler of config.handlers) {
56
+ if (handler.autoReply) {
57
+ perms.add("issues:write");
58
+ perms.add("pull_requests:read");
59
+ }
60
+ }
61
+ return [...perms].sort();
62
+ }
63
+ /**
64
+ * Build author-supplied deploy fields for a GitHub channel.
65
+ *
66
+ * `name` and `provider` are stamped by {@link defineChannel} / `toManifest(name)`.
67
+ */
68
+ export function toGitHubChannelManifest(definition) {
69
+ const config = "config" in definition && definition.config
70
+ ? definition.config
71
+ : definition;
72
+ const handlers = config.handlers.map((handler) => ({
73
+ on: handler.on,
74
+ repositories: handler.repositories,
75
+ autoReply: handler.autoReply,
76
+ }));
77
+ const triggers = [...new Set(handlers.map((h) => h.on))];
78
+ const anyAutoReply = handlers.some((h) => h.autoReply);
79
+ return {
80
+ autoReply: anyAutoReply,
81
+ requiredPermissions: requiredGitHubPermissions(config),
82
+ requiredEnv: [...GITHUB_CHANNEL_REQUIRED_ENV],
83
+ providerConfig: {
84
+ triggers,
85
+ handlers: handlers,
86
+ },
87
+ };
88
+ }
89
+ /**
90
+ * Whether a handler `on` filter matches a delivery.
91
+ *
92
+ * @param on - `"*"`, `"pull_request"`, or `"pull_request.opened"`
93
+ * @param eventName - `X-GitHub-Event`
94
+ * @param action - `payload.action` when present
95
+ */
96
+ export function githubTriggerMatches(on, eventName, action) {
97
+ if (!on || !eventName)
98
+ return false;
99
+ if (on === "*")
100
+ return true;
101
+ if (on === eventName)
102
+ return true;
103
+ if (action !== undefined && on === `${eventName}.${action}`)
104
+ return true;
105
+ return false;
106
+ }
107
+ /**
108
+ * Find the first handler that matches event/action + repository.
109
+ *
110
+ * @returns The handler, or `undefined` when no handler matches (event ignored).
111
+ */
112
+ export function matchGitHubHandler(config, eventName, repository, action) {
113
+ for (const handler of config.handlers) {
114
+ if (!githubTriggerMatches(handler.on, eventName, action))
115
+ continue;
116
+ const repos = handler.repositories;
117
+ if (repos && repos.length > 0) {
118
+ if (!repository || !repos.includes(repository))
119
+ continue;
120
+ }
121
+ return handler;
122
+ }
123
+ return undefined;
124
+ }
125
+ function validateAndNormalize(config) {
126
+ if (config === null || typeof config !== "object") {
127
+ throw new Error("defineGitHubChannel(...) requires a configuration object.");
128
+ }
129
+ if (!Array.isArray(config.handlers) || config.handlers.length === 0) {
130
+ throw new Error("defineGitHubChannel(...) requires a non-empty `handlers` array.");
131
+ }
132
+ const handlers = [];
133
+ for (let i = 0; i < config.handlers.length; i++) {
134
+ const raw = config.handlers[i];
135
+ if (raw === null || typeof raw !== "object") {
136
+ throw new Error(`defineGitHubChannel(...) handlers[${i}] must be an object.`);
137
+ }
138
+ if (typeof raw.on !== "string" || raw.on.trim().length === 0) {
139
+ throw new Error(`defineGitHubChannel(...) handlers[${i}].on must be a non-empty string ` +
140
+ '(e.g. "pull_request", "pull_request.opened", or "*").');
141
+ }
142
+ if (typeof raw.prompt !== "function") {
143
+ throw new Error(`defineGitHubChannel(...) handlers[${i}] requires a \`prompt\` function.`);
144
+ }
145
+ const autoReply = raw.autoReply ?? true;
146
+ if (typeof autoReply !== "boolean") {
147
+ throw new Error(`defineGitHubChannel(...) handlers[${i}].autoReply must be a boolean.`);
148
+ }
149
+ let repositories;
150
+ if (raw.repositories !== undefined) {
151
+ if (!Array.isArray(raw.repositories) ||
152
+ raw.repositories.some((v) => typeof v !== "string")) {
153
+ throw new Error(`defineGitHubChannel(...) handlers[${i}].repositories must be an array of strings.`);
154
+ }
155
+ repositories = [...raw.repositories];
156
+ }
157
+ handlers.push({
158
+ on: raw.on.trim(),
159
+ repositories,
160
+ autoReply,
161
+ prompt: raw.prompt,
162
+ });
163
+ }
164
+ return { handlers };
165
+ }
166
+ //# sourceMappingURL=define.js.map