managed-deepagents 0.9.6-dev.14 → 0.9.6-dev.15

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 (336) hide show
  1. package/README.md +953 -57
  2. package/dist/agent-auth.d.ts +1 -1
  3. package/dist/agent-auth.d.ts.map +1 -1
  4. package/dist/agent-auth.js +36 -12
  5. package/dist/agent-auth.js.map +1 -1
  6. package/dist/channels/actor.d.ts +43 -0
  7. package/dist/channels/actor.d.ts.map +1 -0
  8. package/dist/channels/actor.js +2 -0
  9. package/dist/channels/actor.js.map +1 -0
  10. package/dist/channels/assistant-text.d.ts +24 -0
  11. package/dist/channels/assistant-text.d.ts.map +1 -1
  12. package/dist/channels/assistant-text.js +65 -1
  13. package/dist/channels/assistant-text.js.map +1 -1
  14. package/dist/channels/binding.d.ts +20 -1
  15. package/dist/channels/binding.d.ts.map +1 -1
  16. package/dist/channels/binding.js +39 -10
  17. package/dist/channels/binding.js.map +1 -1
  18. package/dist/channels/delivery.d.ts +21 -0
  19. package/dist/channels/delivery.d.ts.map +1 -0
  20. package/dist/channels/delivery.js +196 -0
  21. package/dist/channels/delivery.js.map +1 -0
  22. package/dist/channels/github/connections.d.ts +11 -0
  23. package/dist/channels/github/connections.d.ts.map +1 -0
  24. package/dist/channels/github/connections.js +14 -0
  25. package/dist/channels/github/connections.js.map +1 -0
  26. package/dist/channels/github/index.d.ts +8 -0
  27. package/dist/channels/github/index.d.ts.map +1 -0
  28. package/dist/channels/github/index.js +274 -0
  29. package/dist/channels/github/index.js.map +1 -0
  30. package/dist/channels/github/mentions.d.ts +12 -0
  31. package/dist/channels/github/mentions.d.ts.map +1 -0
  32. package/dist/channels/github/mentions.js +185 -0
  33. package/dist/channels/github/mentions.js.map +1 -0
  34. package/dist/channels/github/schema.d.ts +4165 -0
  35. package/dist/channels/github/schema.d.ts.map +1 -0
  36. package/dist/channels/github/schema.js +221 -0
  37. package/dist/channels/github/schema.js.map +1 -0
  38. package/dist/channels/github/types.d.ts +163 -0
  39. package/dist/channels/github/types.d.ts.map +1 -0
  40. package/dist/channels/github/types.js +2 -0
  41. package/dist/channels/github/types.js.map +1 -0
  42. package/dist/channels/http/endpoint.d.ts +95 -0
  43. package/dist/channels/http/endpoint.d.ts.map +1 -0
  44. package/dist/channels/http/endpoint.js +276 -0
  45. package/dist/channels/http/endpoint.js.map +1 -0
  46. package/dist/channels/http/http.d.ts.map +1 -1
  47. package/dist/channels/http/http.js +386 -65
  48. package/dist/channels/http/http.js.map +1 -1
  49. package/dist/channels/http/index.d.ts +2 -1
  50. package/dist/channels/http/index.d.ts.map +1 -1
  51. package/dist/channels/http/index.js +14 -10
  52. package/dist/channels/http/index.js.map +1 -1
  53. package/dist/channels/http/ingress.d.ts +65 -5
  54. package/dist/channels/http/ingress.d.ts.map +1 -1
  55. package/dist/channels/http/ingress.js +149 -33
  56. package/dist/channels/http/ingress.js.map +1 -1
  57. package/dist/channels/http/provider.d.ts +119 -0
  58. package/dist/channels/http/provider.d.ts.map +1 -0
  59. package/dist/channels/http/provider.js +227 -0
  60. package/dist/channels/http/provider.js.map +1 -0
  61. package/dist/channels/http/studio.d.ts +24 -0
  62. package/dist/channels/http/studio.d.ts.map +1 -0
  63. package/dist/channels/http/studio.js +95 -0
  64. package/dist/channels/http/studio.js.map +1 -0
  65. package/dist/channels/http/threads.d.ts +7 -0
  66. package/dist/channels/http/threads.d.ts.map +1 -0
  67. package/dist/channels/http/threads.js +10 -0
  68. package/dist/channels/http/threads.js.map +1 -0
  69. package/dist/channels/http/types.d.ts +143 -2
  70. package/dist/channels/http/types.d.ts.map +1 -1
  71. package/dist/channels/linear/connections.d.ts +11 -0
  72. package/dist/channels/linear/connections.d.ts.map +1 -0
  73. package/dist/channels/linear/connections.js +14 -0
  74. package/dist/channels/linear/connections.js.map +1 -0
  75. package/dist/channels/linear/graphql.d.ts +57 -0
  76. package/dist/channels/linear/graphql.d.ts.map +1 -0
  77. package/dist/channels/linear/graphql.js +167 -0
  78. package/dist/channels/linear/graphql.js.map +1 -0
  79. package/dist/channels/linear/index.d.ts +9 -0
  80. package/dist/channels/linear/index.d.ts.map +1 -0
  81. package/dist/channels/linear/index.js +489 -0
  82. package/dist/channels/linear/index.js.map +1 -0
  83. package/dist/channels/linear/schema.d.ts +1050 -0
  84. package/dist/channels/linear/schema.d.ts.map +1 -0
  85. package/dist/channels/linear/schema.js +255 -0
  86. package/dist/channels/linear/schema.js.map +1 -0
  87. package/dist/channels/linear/types.d.ts +162 -0
  88. package/dist/channels/linear/types.d.ts.map +1 -0
  89. package/dist/channels/linear/types.js +2 -0
  90. package/dist/channels/linear/types.js.map +1 -0
  91. package/dist/channels/message-schema.d.ts +2 -0
  92. package/dist/channels/message-schema.d.ts.map +1 -1
  93. package/dist/channels/message-schema.js +4 -0
  94. package/dist/channels/message-schema.js.map +1 -1
  95. package/dist/channels/messaging-registry.d.ts +16 -0
  96. package/dist/channels/messaging-registry.d.ts.map +1 -1
  97. package/dist/channels/messaging-registry.js +29 -0
  98. package/dist/channels/messaging-registry.js.map +1 -1
  99. package/dist/channels/reserved-connections.d.ts +12 -0
  100. package/dist/channels/reserved-connections.d.ts.map +1 -0
  101. package/dist/channels/reserved-connections.js +55 -0
  102. package/dist/channels/reserved-connections.js.map +1 -0
  103. package/dist/channels/run-input.d.ts +71 -0
  104. package/dist/channels/run-input.d.ts.map +1 -0
  105. package/dist/channels/run-input.js +155 -0
  106. package/dist/channels/run-input.js.map +1 -0
  107. package/dist/channels/runtime.d.ts +1 -1
  108. package/dist/channels/runtime.d.ts.map +1 -1
  109. package/dist/channels/runtime.js +1 -1
  110. package/dist/channels/runtime.js.map +1 -1
  111. package/dist/channels/schedule-delivery.d.ts +1 -1
  112. package/dist/channels/schedule-delivery.d.ts.map +1 -1
  113. package/dist/channels/schedule-delivery.js +12 -23
  114. package/dist/channels/schedule-delivery.js.map +1 -1
  115. package/dist/channels/slack/api.d.ts +2 -0
  116. package/dist/channels/slack/api.d.ts.map +1 -1
  117. package/dist/channels/slack/api.js +6 -0
  118. package/dist/channels/slack/api.js.map +1 -1
  119. package/dist/channels/slack/connections.d.ts +6 -0
  120. package/dist/channels/slack/connections.d.ts.map +1 -0
  121. package/dist/channels/slack/connections.js +6 -0
  122. package/dist/channels/slack/connections.js.map +1 -0
  123. package/dist/channels/slack/events.d.ts +272 -0
  124. package/dist/channels/slack/events.d.ts.map +1 -0
  125. package/dist/channels/slack/events.js +235 -0
  126. package/dist/channels/slack/events.js.map +1 -0
  127. package/dist/channels/slack/files.d.ts.map +1 -1
  128. package/dist/channels/slack/files.js +2 -3
  129. package/dist/channels/slack/files.js.map +1 -1
  130. package/dist/channels/slack/index.d.ts +76 -2
  131. package/dist/channels/slack/index.d.ts.map +1 -1
  132. package/dist/channels/slack/index.js +177 -6
  133. package/dist/channels/slack/index.js.map +1 -1
  134. package/dist/channels/slack/message-content.d.ts.map +1 -1
  135. package/dist/channels/slack/message-content.js +23 -28
  136. package/dist/channels/slack/message-content.js.map +1 -1
  137. package/dist/channels/slack/status.d.ts +76 -0
  138. package/dist/channels/slack/status.d.ts.map +1 -0
  139. package/dist/channels/slack/status.js +427 -0
  140. package/dist/channels/slack/status.js.map +1 -0
  141. package/dist/channels/source-providers.js +1 -1
  142. package/dist/channels/source-providers.js.map +1 -1
  143. package/dist/channels/trigger/client.d.ts.map +1 -1
  144. package/dist/channels/trigger/client.js +6 -15
  145. package/dist/channels/trigger/client.js.map +1 -1
  146. package/dist/channels/trigger/http.d.ts +114 -3
  147. package/dist/channels/trigger/http.d.ts.map +1 -1
  148. package/dist/channels/trigger/http.js +314 -82
  149. package/dist/channels/trigger/http.js.map +1 -1
  150. package/dist/channels/trigger/identity-context.d.ts +1 -1
  151. package/dist/channels/trigger/identity-context.d.ts.map +1 -1
  152. package/dist/channels/trigger/identity-context.js +2 -3
  153. package/dist/channels/trigger/identity-context.js.map +1 -1
  154. package/dist/channels/trigger/ingress.d.ts +38 -1
  155. package/dist/channels/trigger/ingress.d.ts.map +1 -1
  156. package/dist/channels/trigger/ingress.js +49 -23
  157. package/dist/channels/trigger/ingress.js.map +1 -1
  158. package/dist/channels/trigger/types.d.ts +82 -3
  159. package/dist/channels/trigger/types.d.ts.map +1 -1
  160. package/dist/channels/trigger/types.js +36 -0
  161. package/dist/channels/trigger/types.js.map +1 -1
  162. package/dist/channels/types.d.ts +19 -3
  163. package/dist/channels/types.d.ts.map +1 -1
  164. package/dist/channels/types.js +2 -0
  165. package/dist/channels/types.js.map +1 -1
  166. package/dist/connections.d.ts +31 -0
  167. package/dist/connections.d.ts.map +1 -1
  168. package/dist/connections.js +108 -11
  169. package/dist/connections.js.map +1 -1
  170. package/dist/credential-gate.d.ts +2 -0
  171. package/dist/credential-gate.d.ts.map +1 -1
  172. package/dist/credential-gate.js +37 -3
  173. package/dist/credential-gate.js.map +1 -1
  174. package/dist/define-deep-agent.d.ts.map +1 -1
  175. package/dist/define-deep-agent.js +6 -0
  176. package/dist/define-deep-agent.js.map +1 -1
  177. package/dist/identity/loopback.d.ts +2 -14
  178. package/dist/identity/loopback.d.ts.map +1 -1
  179. package/dist/identity/loopback.js +4 -25
  180. package/dist/identity/loopback.js.map +1 -1
  181. package/dist/identity/slack/links.js +3 -3
  182. package/dist/identity/slack/links.js.map +1 -1
  183. package/dist/index.d.ts +15 -4
  184. package/dist/index.d.ts.map +1 -1
  185. package/dist/index.js +2 -1
  186. package/dist/index.js.map +1 -1
  187. package/dist/ingress/index.d.ts +0 -8
  188. package/dist/ingress/index.d.ts.map +1 -1
  189. package/dist/ingress/index.js +2 -32
  190. package/dist/ingress/index.js.map +1 -1
  191. package/dist/ingress/loopback.js +4 -4
  192. package/dist/ingress/loopback.js.map +1 -1
  193. package/dist/ingress/runs.d.ts +74 -1
  194. package/dist/ingress/runs.d.ts.map +1 -1
  195. package/dist/ingress/runs.js +176 -16
  196. package/dist/ingress/runs.js.map +1 -1
  197. package/dist/managed-composition.d.ts.map +1 -1
  198. package/dist/managed-composition.js +8 -13
  199. package/dist/managed-composition.js.map +1 -1
  200. package/dist/memory/instructions-middleware.d.ts.map +1 -1
  201. package/dist/memory/instructions-middleware.js +5 -6
  202. package/dist/memory/instructions-middleware.js.map +1 -1
  203. package/dist/namespaces.d.ts +21 -21
  204. package/dist/namespaces.d.ts.map +1 -1
  205. package/dist/namespaces.js +4 -29
  206. package/dist/namespaces.js.map +1 -1
  207. package/dist/runtime/auth.d.ts.map +1 -1
  208. package/dist/runtime/auth.js +151 -21
  209. package/dist/runtime/auth.js.map +1 -1
  210. package/dist/runtime/channel-icon.d.ts +22 -0
  211. package/dist/runtime/channel-icon.d.ts.map +1 -0
  212. package/dist/runtime/channel-icon.js +70 -0
  213. package/dist/runtime/channel-icon.js.map +1 -0
  214. package/dist/runtime/channel.d.ts +6 -0
  215. package/dist/runtime/channel.d.ts.map +1 -1
  216. package/dist/runtime/channel.js.map +1 -1
  217. package/dist/runtime/http.d.ts +0 -15
  218. package/dist/runtime/http.d.ts.map +1 -1
  219. package/dist/runtime/http.js +0 -37
  220. package/dist/runtime/http.js.map +1 -1
  221. package/dist/runtime/identity-http.d.ts +2 -0
  222. package/dist/runtime/identity-http.d.ts.map +1 -1
  223. package/dist/runtime/identity-http.js +40 -16
  224. package/dist/runtime/identity-http.js.map +1 -1
  225. package/dist/runtime/identity-runtime.d.ts +10 -0
  226. package/dist/runtime/identity-runtime.d.ts.map +1 -1
  227. package/dist/runtime/identity-runtime.js +22 -0
  228. package/dist/runtime/identity-runtime.js.map +1 -1
  229. package/dist/runtime/index.d.ts.map +1 -1
  230. package/dist/runtime/index.js +46 -47
  231. package/dist/runtime/index.js.map +1 -1
  232. package/dist/runtime/log.d.ts +14 -8
  233. package/dist/runtime/log.d.ts.map +1 -1
  234. package/dist/runtime/log.js +7 -16
  235. package/dist/runtime/log.js.map +1 -1
  236. package/dist/runtime/managed-middleware.d.ts.map +1 -1
  237. package/dist/runtime/managed-middleware.js +14 -1
  238. package/dist/runtime/managed-middleware.js.map +1 -1
  239. package/dist/runtime/managed-thread.d.ts +60 -0
  240. package/dist/runtime/managed-thread.d.ts.map +1 -0
  241. package/dist/runtime/managed-thread.js +76 -0
  242. package/dist/runtime/managed-thread.js.map +1 -0
  243. package/dist/runtime/managed-tools.d.ts +10 -10
  244. package/dist/runtime/managed-tools.d.ts.map +1 -1
  245. package/dist/runtime/managed-tools.js +24 -24
  246. package/dist/runtime/managed-tools.js.map +1 -1
  247. package/dist/runtime/memory/mounts.d.ts +11 -82
  248. package/dist/runtime/memory/mounts.d.ts.map +1 -1
  249. package/dist/runtime/memory/mounts.js +34 -173
  250. package/dist/runtime/memory/mounts.js.map +1 -1
  251. package/dist/runtime/memory/policy.d.ts.map +1 -1
  252. package/dist/runtime/memory/policy.js +1 -3
  253. package/dist/runtime/memory/policy.js.map +1 -1
  254. package/dist/runtime/run-input.d.ts +10 -0
  255. package/dist/runtime/run-input.d.ts.map +1 -1
  256. package/dist/runtime/run-input.js +47 -19
  257. package/dist/runtime/run-input.js.map +1 -1
  258. package/dist/runtime/sandbox-manager.d.ts +1 -1
  259. package/dist/runtime/sandbox-manager.d.ts.map +1 -1
  260. package/dist/runtime/sandbox-manager.js +9 -7
  261. package/dist/runtime/sandbox-manager.js.map +1 -1
  262. package/dist/runtime/schedule-auth.d.ts +17 -0
  263. package/dist/runtime/schedule-auth.d.ts.map +1 -1
  264. package/dist/runtime/schedule-auth.js +41 -3
  265. package/dist/runtime/schedule-auth.js.map +1 -1
  266. package/dist/runtime/selected-skills-backend.d.ts +3 -3
  267. package/dist/runtime/selected-skills-backend.d.ts.map +1 -1
  268. package/dist/runtime/selected-skills-backend.js +5 -5
  269. package/dist/runtime/selected-skills-backend.js.map +1 -1
  270. package/dist/runtime/thread-record.d.ts +81 -0
  271. package/dist/runtime/thread-record.d.ts.map +1 -0
  272. package/dist/runtime/thread-record.js +205 -0
  273. package/dist/runtime/thread-record.js.map +1 -0
  274. package/dist/runtime/types.d.ts +5 -1
  275. package/dist/runtime/types.d.ts.map +1 -1
  276. package/dist/runtime-schedules.d.ts +13 -0
  277. package/dist/runtime-schedules.d.ts.map +1 -1
  278. package/dist/runtime-schedules.js +86 -22
  279. package/dist/runtime-schedules.js.map +1 -1
  280. package/dist/sandbox.d.ts +0 -6
  281. package/dist/sandbox.d.ts.map +1 -1
  282. package/dist/sandbox.js +3 -7
  283. package/dist/sandbox.js.map +1 -1
  284. package/dist/schedule-channel.d.ts +5 -2
  285. package/dist/schedule-channel.d.ts.map +1 -1
  286. package/dist/schedule-channel.js +13 -12
  287. package/dist/schedule-channel.js.map +1 -1
  288. package/dist/telemetry/run-listener.d.ts +1 -1
  289. package/dist/telemetry/run-listener.d.ts.map +1 -1
  290. package/dist/telemetry/run-listener.js +2 -32
  291. package/dist/telemetry/run-listener.js.map +1 -1
  292. package/dist/telemetry/transport/posthog.d.ts +1 -13
  293. package/dist/telemetry/transport/posthog.d.ts.map +1 -1
  294. package/dist/telemetry/transport/posthog.js +30 -68
  295. package/dist/telemetry/transport/posthog.js.map +1 -1
  296. package/dist/values.d.ts +15 -0
  297. package/dist/values.d.ts.map +1 -0
  298. package/dist/values.js +31 -0
  299. package/dist/values.js.map +1 -0
  300. package/package.json +11 -11
  301. package/dist/concurrency/batch-processor.d.ts +0 -51
  302. package/dist/concurrency/batch-processor.d.ts.map +0 -1
  303. package/dist/concurrency/batch-processor.js +0 -99
  304. package/dist/concurrency/batch-processor.js.map +0 -1
  305. package/dist/resilience/retry.d.ts +0 -21
  306. package/dist/resilience/retry.d.ts.map +0 -1
  307. package/dist/resilience/retry.js +0 -40
  308. package/dist/resilience/retry.js.map +0 -1
  309. package/dist/runtime/graph-build-timing.d.ts +0 -30
  310. package/dist/runtime/graph-build-timing.d.ts.map +0 -1
  311. package/dist/runtime/graph-build-timing.js +0 -50
  312. package/dist/runtime/graph-build-timing.js.map +0 -1
  313. package/dist/telemetry/lifecycle.d.ts +0 -26
  314. package/dist/telemetry/lifecycle.d.ts.map +0 -1
  315. package/dist/telemetry/lifecycle.js +0 -49
  316. package/dist/telemetry/lifecycle.js.map +0 -1
  317. package/dist/telemetry/otel/context.d.ts +0 -57
  318. package/dist/telemetry/otel/context.d.ts.map +0 -1
  319. package/dist/telemetry/otel/context.js +0 -122
  320. package/dist/telemetry/otel/context.js.map +0 -1
  321. package/dist/telemetry/otel/exporter.d.ts +0 -53
  322. package/dist/telemetry/otel/exporter.d.ts.map +0 -1
  323. package/dist/telemetry/otel/exporter.js +0 -190
  324. package/dist/telemetry/otel/exporter.js.map +0 -1
  325. package/dist/telemetry/otel/index.d.ts +0 -6
  326. package/dist/telemetry/otel/index.d.ts.map +0 -1
  327. package/dist/telemetry/otel/index.js +0 -3
  328. package/dist/telemetry/otel/index.js.map +0 -1
  329. package/dist/telemetry/otel/otlp.d.ts +0 -44
  330. package/dist/telemetry/otel/otlp.d.ts.map +0 -1
  331. package/dist/telemetry/otel/otlp.js +0 -7
  332. package/dist/telemetry/otel/otlp.js.map +0 -1
  333. package/dist/telemetry/otel/truncate.d.ts +0 -10
  334. package/dist/telemetry/otel/truncate.d.ts.map +0 -1
  335. package/dist/telemetry/otel/truncate.js +0 -39
  336. package/dist/telemetry/otel/truncate.js.map +0 -1
package/README.md CHANGED
@@ -136,7 +136,10 @@ export function agent(runtime: ManagedServerRuntime) {
136
136
  const ctx = runtime.executionRuntime?.context ?? {};
137
137
  return defineDeepAgent({
138
138
  name: "support",
139
- model: "tier" in ctx && ctx.tier === "fast" ? "openai:gpt-5-mini" : "openai:gpt-5.5",
139
+ model:
140
+ "tier" in ctx && ctx.tier === "fast"
141
+ ? "openai:gpt-5-mini"
142
+ : "openai:gpt-5.5",
140
143
  });
141
144
  }
142
145
  ```
@@ -148,7 +151,7 @@ strings and arrays remain explicit selections. Select memory with `defineMemory(
148
151
  selected memory cannot use `allow`. Root `memory.ts` remains the fallback.
149
152
 
150
153
  On direct runs, `executionRuntime.context` is application context or `undefined`.
151
- On channel runs, it is `undefined`; read delivery data from `runtime.channel`.
154
+ On channel runs, it is `undefined`; read the conversation from `runtime.thread`.
152
155
  `ManagedServerRuntime<AppContext>` preserves the application's context type.
153
156
  `accessContext` identifies the Agent Server operation that called the factory.
154
157
  During inspection, `executionRuntime` is `null`. Keep the factory repeatable and
@@ -240,12 +243,18 @@ current channel delivery:
240
243
  runtime
241
244
  .context // Application data on direct runs
242
245
  .serverInfo // Trusted caller and server information
243
- .channel // Present for a managed channel delivery
244
- .name // Configured channel name
245
- .provider // Provider label, such as slack
246
- .event // Typed MDA delivery; no internal routing
247
- .rawEvent // Optional original provider payload
248
- .post(...) // Present when sending is supported
246
+ .thread // The run's thread
247
+ .id // LangGraph thread ID
248
+ .origin // The channel conversation, or null
249
+ .channel // Where answers go
250
+ .name // Configured channel name
251
+ .provider // Provider label, such as slack
252
+ .event // Typed MDA delivery, or null
253
+ .rawEvent // Optional original provider payload
254
+ .post(...) // Present when sending is supported
255
+ .sender // The participant who sent the latest event, or null
256
+ .participants // The people on the thread: { id, role }
257
+ .channel // Deprecated: runtime.thread.origin?.channel
249
258
  .backend // Present when a sandbox is configured
250
259
  .schedules // Create and manage schedules for this run's caller
251
260
  ```
@@ -262,8 +271,8 @@ await client.runs.create(threadId, assistantId, {
262
271
  Direct API runs use your authored `contextSchema` and native LangGraph context
263
272
  validation. On channel runs, tools and authored factories receive `undefined`
264
273
  as context. Native middleware receives an empty context. Use
265
- `runtime.channel.event` for the typed event and `runtime.channel.rawEvent` for
266
- optional provider data. The application schema stays on the graph, but its
274
+ `runtime.thread.origin.channel.event` for the typed event and
275
+ `runtime.thread.origin.channel.rawEvent` for optional provider data. The application schema stays on the graph, but its
267
276
  required fields do not apply to channel runs. Supplying a `channel` field in a
268
277
  direct API call does not establish a trusted channel source.
269
278
 
@@ -274,23 +283,48 @@ in the graph factory for each run or resume. Direct callers of the managed
274
283
  compiler must build a fresh graph with the execution's context; a compiled graph
275
284
  is scoped to that execution.
276
285
 
277
- `runtime.channel` describes the current verified delivery. It is absent on
278
- ordinary API and schedule runs. Its facts are available even when the channel
279
- cannot send. `post` uses a private, verified reply target. The channel helper
280
- does not expose the target or let callers replace it.
286
+ `runtime.thread` is set in every run. `origin` is the channel conversation the
287
+ thread came from; it is `null` on a thread no channel message reached. Managed
288
+ ingress records the origin on the thread on every channel message, so runs that
289
+ no message started still have it: a run LangSmith Studio resumes, and a
290
+ scheduled run on the thread. In those runs `origin.channel.event` is `null` (a
291
+ scheduled run gets a `schedule` event) and there is no `rawEvent`. The channel's
292
+ facts are available even when it cannot send. `post` uses a private, verified
293
+ reply target. The channel helper does not expose the target or let callers
294
+ replace it.
281
295
 
282
296
  ```ts
283
- if (runtime.channel?.post) {
284
- await runtime.channel.post({ type: "content", content: "I am checking that now." });
297
+ const channel = runtime.thread?.origin?.channel;
298
+ if (channel?.post) {
299
+ await channel.post({
300
+ type: "content",
301
+ content: "I am checking that now.",
302
+ });
285
303
  }
286
304
  ```
287
305
 
288
- The built-in Slack `runtime.channel.post` sends text content through Trigger.
306
+ `participants` lists the people on the thread, in the order they joined, by
307
+ `principal.id` (the same id as `runtime.serverInfo.principal.id`). The first
308
+ person is `owner`; everyone after is a `member`. Services, such as the Linear
309
+ channel, are never participants. `origin.sender` is the participant who sent the
310
+ latest channel event, or `null` when that was not a person. The record holds
311
+ ids and routing only, never message text or provider payloads, because thread
312
+ metadata reaches traces.
313
+
314
+ `runtime.channel` is deprecated and will be removed in 0.11. It is the same
315
+ value as `runtime.thread.origin?.channel`.
316
+
317
+ When a run ends, MDA posts its answer to the thread's origin: Slack through
318
+ Trigger, HTTP channels through their `post`. A run that stops on an interrupt
319
+ reports it to Trigger, so Slack can ask for the decision. Answer `[quiet]` to
320
+ post nothing.
321
+
322
+ The built-in Slack channel `post` sends text content through Trigger.
289
323
  It rejects native payloads and content it cannot send. For channels that support
290
324
  native messages, set `type` to `"native"` and supply the JSON in `native`.
291
325
  For content messages, set `type` to `"content"` and supply `content`.
292
326
  Supply only the matching payload. Native JSON has no extra provider or payload
293
- wrapper. The `runtime.channel` helper has no `address`, `update`, or destination override.
327
+ wrapper. The channel helper has no `address`, `update`, or destination override.
294
328
  A post sends an additional message; the normal final agent reply remains automatic.
295
329
 
296
330
  Managed Slack channels save incoming files under `/workspace/attachments/` and
@@ -312,7 +346,8 @@ MDA does not reuse the previous delivery's event.
312
346
  For a prompt that answers an interrupt, put a shared ID on the prompt and on the
313
347
  interrupt value under `INTERRUPT_CORRELATION_KEY`. MDA uses `correlation_id` to
314
348
  select that interrupt. Without a correlation ID, an answer can resume the only
315
- pending interrupt; multiple pending interrupts require a match. Existing resume
349
+ pending interrupt that isn't a tool-call review; multiple pending interrupts
350
+ require a match. Existing resume
316
351
  values are unchanged.
317
352
 
318
353
  The managed runtime fields are available to authored tools and middleware,
@@ -323,23 +358,6 @@ when available. Its `link.status` currently reports `not_required`; it does not
323
358
  perform an account-link lookup. Its source thread identifier retains the existing
324
359
  provider-thread/LangGraph-thread fallback behavior.
325
360
 
326
- ### Self-hosted channel runtime configuration
327
-
328
- Agent Server's `MOUNT_PREFIX` is honored by managed event routes and default
329
- loopback clients. Explicit `MDA_CHANNEL_API_URL` or `LANGGRAPH_API_URL` overrides
330
- must already include the deployment path.
331
-
332
- Trigger-backed channels require `LANGSMITH_MDA_TRIGGER_SERVER_URL` and a
333
- deployment key (`LANGSMITH_API_KEY`, or `LANGCHAIN_API_KEY` on self-hosted).
334
- The runtime prefers `LANGSMITH_API_KEY` when both are present.
335
-
336
- If the Agent Auth token issuer differs from the runtime's LangSmith API URL,
337
- set `OAUTH_AS_ISSUER` in the deployment environment to the configured issuer
338
- (for example, `https://langsmith.example.com/api`). The runtime verifies the
339
- exact issuer and fetches its public `/.well-known/jwks.json`; it does not trust
340
- an issuer supplied by an incoming token. LangSmith must have signing keys
341
- configured, and the agent must be able to reach that public-key endpoint.
342
-
343
361
  ## Tool and middleware runtime types
344
362
 
345
363
  Use `ManagedToolRuntime<State, Context>` for tools and tool-call hooks. Use
@@ -350,6 +368,718 @@ alias for the tool type. MDA adds `serverInfo`, `channel`, `backend`, and
350
368
  but the type marks it optional so annotated hooks still match LangChain's native
351
369
  runtime types.
352
370
 
371
+ ## Slack channels
372
+
373
+ `channels.slack(...)` receives Slack messages through Trigger Server. Each
374
+ Slack thread is one conversation, and the run's reply is posted in it. By
375
+ default every message that reaches the app starts a run with the message.
376
+ `onEvent` decides what each kind of message starts instead:
377
+
378
+ ```ts
379
+ // channels/slack.ts
380
+ import { channels } from "managed-deepagents";
381
+
382
+ export const channel = channels.slack({
383
+ name: "Support Bot",
384
+ triggerMode: "thread",
385
+ onEvent: {
386
+ mention: (event, thread) => [
387
+ event.text,
388
+ {
389
+ context: { ticket: thread.id },
390
+ metadata: { slack_channel: event.channelId },
391
+ },
392
+ ],
393
+ directMessage: (event) => event.text,
394
+ // Replies in a followed thread that don't mention the app start nothing.
395
+ message: () => null,
396
+ },
397
+ multitaskStrategy: "enqueue",
398
+ });
399
+ ```
400
+
401
+ The keys are `mention`, a channel message that @-mentions the app;
402
+ `directMessage`; and `message`, any other channel message, which only
403
+ `triggerMode` `"thread"` or `"all"` delivers. Under those modes Slack sends a
404
+ mention as a plain message, so the channel asks Slack once for the app's bot
405
+ user, with the app's bot token, to tell a mention from a message. An unknown
406
+ key throws. A message kind without a handler starts a run with the message,
407
+ as without `onEvent`. With `triggerMode: "mention"`, a `message` handler is
408
+ never called, and defining the channel warns.
409
+
410
+ With a `mention` handler under `triggerMode` `"thread"`, a reply only
411
+ continues a thread the agent already ran on: when the handler declines a
412
+ thread's mention, the thread's later replies start nothing until someone
413
+ mentions the agent there again.
414
+
415
+ A handler gets the message (`text`, `userId`, `channelId`, `messageTs`,
416
+ `threadTs`, `files`, Slack's own event as `payload`, and `actor`) and its
417
+ thread (`id`, `sourceThreadKey`, `channel.name`). It returns the run's input, as
418
+ `agent.invoke` takes it, optionally with `context`, `metadata` and `webhook`
419
+ as `[input, options]`, as the GitHub and Linear handlers do. `null` or
420
+ `undefined` starts no run, and the app neither reacts nor replies. A handler
421
+ that throws, or returns input the channel can't start, starts no run either;
422
+ the error is logged without its message. The message's blocks and attachments
423
+ are added to the handler's messages, and its files still reach
424
+ `/workspace/attachments/`. Interrupt resumes don't go through `onEvent`; a
425
+ click on a button the agent posted does, as `interaction`: see
426
+ [Buttons your agent posts](#buttons-your-agent-posts).
427
+
428
+ A handler may also be an endpoint of your service, a URL or a `Request`:
429
+ Trigger Server gets its answer first, then MDA asks the service what the
430
+ message starts. See [Asking your service what to start](#asking-your-service-what-to-start).
431
+
432
+ ```ts
433
+ const backend = new Request(`${process.env.BACKEND_URL}/slack/runs`, {
434
+ headers: { "x-api-key": process.env.BACKEND_KEY! },
435
+ });
436
+
437
+ export const channel = channels.slack({
438
+ onEvent: { mention: backend, directMessage: backend },
439
+ });
440
+ ```
441
+
442
+ `multitaskStrategy` is what a message that starts a run does while its thread
443
+ already runs: `enqueue` (the default) waits for the run and starts after it,
444
+ `interrupt` cancels the run, keeping its progress, and starts at once,
445
+ `rollback` cancels it and discards its progress, and `reject` starts nothing.
446
+
447
+ `event.actor` is the Slack user who sent the message, as Trigger Server read
448
+ it from Slack's signed request: `{ provider: "slack", id, teamId }`. `teamId`
449
+ is their own workspace: in a Slack Connect channel, someone from another
450
+ organization keeps theirs. It is absent rather than guessed when Trigger
451
+ Server names no one, such as an older Trigger Server or a bot's message.
452
+
453
+ > **Not yet an identity check.** Trigger Server sends `actor` as a plain
454
+ > field of the delivery, and MDA doesn't yet verify the key that delivery
455
+ > comes with, only that it has one. Use `actor` to address or describe the
456
+ > sender, not to decide what they may do or which of your accounts they are.
457
+
458
+ Every channel's events carry `actor` in this shape, a `ChannelActor`: `{
459
+ provider, id }` plus the provider's own fields. GitHub's is the webhook's
460
+ `sender` (`name` is its login, plus `type` and `email?`), and Linear's is who
461
+ acted (plus `type?`, `name?` and `email?`); Slack's has no name or email,
462
+ since Trigger Server's delivery names none. Endpoints get it as `event.actor` too. It is personal
463
+ data: MDA doesn't log it or add it to a run's metadata; add what you need
464
+ through `metadata` yourself.
465
+
466
+ `onFinish` is called once when a message or an `interaction` is done, with
467
+ the event, its thread, and how it finished, as Linear's `onFinish` is:
468
+
469
+ - `run`: the message started a run, which ended with `run.status`
470
+ (`success`, `error`, `timeout` or `interrupted`). `interrupts` lists the
471
+ decisions the thread waits on.
472
+ - `skipped`: no run started. The handler returned nothing or failed
473
+ (`ignored`), or the thread was busy under `multitaskStrategy: "reject"`
474
+ (`rejected`).
475
+ - `failed`: MDA couldn't start the run, or lost track of it.
476
+
477
+ Use it to record which run answered which message in your own service,
478
+ update memory after a run succeeds, or alert someone when one fails:
479
+
480
+ ```ts
481
+ channels.slack({
482
+ onFinish: async (event, thread, finished) => {
483
+ if (finished.type !== "run") return;
484
+ if (finished.run.status === "success") {
485
+ // e.g. record the answer in your service, or update memory
486
+ } else {
487
+ // e.g. alert someone that the run failed
488
+ }
489
+ },
490
+ });
491
+ ```
492
+
493
+ It runs in the background after the reply, and errors are logged. Interrupt
494
+ resumes don't call it, and neither does a message Trigger Server will send
495
+ again because its run couldn't start. Like `channels.http`'s, it runs in the deployment's
496
+ process, so a restart loses it: set the run's `webhook` for anything you
497
+ can't miss.
498
+
499
+ ### The status a run shows
500
+
501
+ While a run works, Slack shows Trigger Server's working phrases ("is thinking
502
+ it through...", "reviewing your question..."). `status` shows yours instead,
503
+ the way `reactions` picks the emoji: a value for every run, or a function that
504
+ picks one. A value is a line, or a list of steps, each a title or `{ title,
505
+ status }` with `status` `pending` (the default), `in_progress`, `complete` or
506
+ `error`:
507
+
508
+ ```ts
509
+ channels.slack({ status: "is consulting the crystal ball" });
510
+ channels.slack({ status: ["Read the question", "Search the docs", "Answer"] });
511
+ channels.slack({
512
+ // The agent's to-do list, as Slack's plan.
513
+ status: ({ state }) =>
514
+ state.todos?.map((todo) => ({
515
+ title: todo.content,
516
+ status: todo.status === "completed" ? "complete" : todo.status,
517
+ })) ?? null,
518
+ });
519
+ ```
520
+
521
+ The function gets the agent's state as it is now, so it can say which tool is
522
+ about to run (the last message's `tool_calls`) or what's left on the to-do
523
+ list. It is called as the run starts, before and after each model call, and
524
+ every 4 s while a model or tool call runs, one call at a time. `null`, or an
525
+ empty list (as a to-do list is before the agent writes one), leaves what's
526
+ shown. A function that throws, takes longer than 1 s, or returns
527
+ something else leaves it too, with one warning per run. The status is only
528
+ posted when it changed, at most once a second, in the background, so it never
529
+ slows the run; a failed post is logged. A sync function runs on the event
530
+ loop, so do slow work in an async one.
531
+
532
+ Apps with Slack's agent view show a custom status as a plan above the reply:
533
+ the line is the plan's title and each step one of its tasks. A step that's
534
+ no longer listed is marked complete, since Slack can't remove one, and the
535
+ plan reads "Done" when the run ends. Other apps show the line, or the first
536
+ step not yet done, as the thread's status. Without `status`, nothing changes.
537
+
538
+ ### Replying from the agent
539
+
540
+ The channel posts the agent's last reply in the thread once a run succeeds.
541
+ `reply: "none"` leaves replying to the agent instead, for an agent that posts
542
+ its own messages, with `runtime.channel.post` or its own Slack client, or
543
+ that answers somewhere else:
544
+
545
+ ```ts
546
+ channels.slack({ reply: "none" });
547
+ ```
548
+
549
+ Reactions, the status, Stop and `onFinish` work as before. `channels.linear`
550
+ and `channels.http` take the same option. Deploying `reply: "none"` needs an
551
+ `mda` CLI from this release; an older one refuses it.
552
+
553
+ ### Buttons your agent posts
554
+
555
+ `runtime.channel.post` only sends what every channel can. For anything
556
+ Slack-specific, such as buttons, feedback buttons or a message the agent
557
+ updates later, the agent posts with its own Slack client. The app's bot token
558
+ is the agent connection `mda/slack-bot-token` (reading it as a user connection
559
+ throws), and `runtime.channel.rawEvent`, the Slack event the run came from,
560
+ names the thread: a message's own event, or a click's interaction payload,
561
+ whose `container` says where the button was.
562
+
563
+ ```ts
564
+ import { WebClient } from "@slack/web-api";
565
+ import { tool } from "langchain";
566
+ import { z } from "zod";
567
+ import { connections, type ManagedToolRuntime } from "managed-deepagents";
568
+
569
+ export const offerChoices = tool(
570
+ async ({ question, choices }, runtime: ManagedToolRuntime) => {
571
+ if (runtime.channel?.provider !== "slack") return "Not in Slack.";
572
+ const raw = runtime.channel.rawEvent as Record<string, any> | undefined;
573
+ const where = raw?.container ?? raw;
574
+ const channel = where?.channel_id ?? where?.channel;
575
+ const threadTs = where?.thread_ts ?? where?.message_ts ?? where?.ts;
576
+ const token = await connections.get("mda/slack-bot-token", { type: "agent" });
577
+ await new WebClient(token).chat.postMessage({
578
+ channel,
579
+ thread_ts: threadTs,
580
+ text: question,
581
+ blocks: [
582
+ { type: "section", text: { type: "mrkdwn", text: question } },
583
+ {
584
+ type: "actions",
585
+ elements: choices.map((choice) => ({
586
+ type: "button",
587
+ action_id: "quick_reply",
588
+ text: { type: "plain_text", text: choice },
589
+ value: choice,
590
+ })),
591
+ },
592
+ ],
593
+ });
594
+ return "Posted the choices.";
595
+ },
596
+ {
597
+ name: "offer_choices",
598
+ description: "Ask the user to pick one of a few answers in Slack.",
599
+ schema: z.object({ question: z.string(), choices: z.array(z.string()) }),
600
+ }
601
+ );
602
+ ```
603
+
604
+ Trigger Server forwards a click on such a button to the channel. `onEvent`'s
605
+ `interaction` decides what it starts, as the other keys do for messages:
606
+
607
+ ```ts
608
+ channels.slack({
609
+ onEvent: {
610
+ interaction: (event) =>
611
+ event.actionId === "quick_reply" ? String(event.value) : null,
612
+ },
613
+ });
614
+ ```
615
+
616
+ The event has `actionId` (the button's `action_id`, or a modal's
617
+ `callback_id`), `value` (the button's `value`, or the modal's `state.values`),
618
+ `userId`, `channelId`, `messageTs` (the message holding the button; absent for
619
+ a modal), `threadTs`, `actor`, and Slack's interaction payload as `payload`,
620
+ with its `response_url` and without its verification `token`. The run it
621
+ starts runs on the button's thread. Return `null` for a click that starts
622
+ nothing, such as a `feedback_buttons` rating you record yourself. An endpoint works here too, as
623
+ does `multitaskStrategy`.
624
+
625
+ Without `interaction`, a click starts a run with no new message, which reads
626
+ the click from `runtime.channel.event` (`type: "user_prompt_response"`, with
627
+ `action` and `value`). A click that answers a decision the thread waits on
628
+ resumes that run instead, and never reaches `interaction`. A click without a
629
+ correlation ID never answers a tool-call review, which its own prompt answers:
630
+ while the thread waits on one, such a click starts nothing. Trigger Server
631
+ forwards clicks on buttons without a URL and on Slack's `feedback_buttons`;
632
+ selects and inputs aren't forwarded.
633
+
634
+ ### Setting up the Slack app
635
+
636
+ The first `mda deploy` of a Slack channel asks which Slack app it uses, as the
637
+ GitHub and Linear channels do:
638
+
639
+ - **Create a new Slack app in _your workspace_**: LangSmith creates and manages
640
+ it, in the workspace you authorized LangSmith in. Deploy names the workspace.
641
+ - **Let LangSmith create and manage a new Slack app**: the same, when you
642
+ haven't authorized LangSmith in Slack yet. Deploy prints the link to do that.
643
+ - **Create a new Slack app yourself**: Slack opens with the app filled in from
644
+ a manifest. Install it, then paste its Bot User OAuth Token and Signing
645
+ Secret into the prompts.
646
+ - **Use an existing Slack app**: deploy lists the request URLs, bot events and
647
+ scopes to set on the app, then asks for its token and signing secret. Slack
648
+ sends an app's events to one URL, so whatever received them before stops
649
+ receiving them.
650
+
651
+ Self-hosted LangSmith can't create Slack apps, so it offers only your own.
652
+ LangSmith keeps the app's credentials, and later deploys keep whichever app
653
+ the channel has without asking. The agent reads the app's bot token as the
654
+ agent connection `mda/slack-bot-token`, so nothing goes into `.env`.
655
+
656
+ To skip the question, with or without a terminal, set `MDA_SLACK_BOT_TOKEN`
657
+ and `MDA_SLACK_SIGNING_SECRET` in the shell or `.env` to your own app's bot
658
+ token and signing secret. Deploy checks them before uploading. Only the CLI
659
+ reads them: they are never uploaded to the deployment, and you can remove both
660
+ once the channel is set up. Without a terminal and without them, hosted
661
+ LangSmith creates a managed app in the workspace you already authorized it in,
662
+ and says so. When you haven't authorized it yet, or on self-hosted LangSmith,
663
+ deploy stops before uploading and says what to set.
664
+
665
+ When Slack still needs you once the deployment is live, to authorize LangSmith
666
+ or to install the new app (some workspaces have an admin approve it first),
667
+ deploy prints the link and waits, continuing as soon as Slack reports it done.
668
+ In a terminal the link also opens in your browser, and Ctrl-C skips the
669
+ channel. Without one, deploy waits up to an hour, so a coding agent running it
670
+ can hand you the link; Ctrl-C stops it.
671
+
672
+ If a setup step fails once the deployment is live, deploy offers to try again
673
+ or to continue without the Slack channel. Without a terminal the failure ends
674
+ the deploy, once the other channels are set up. An agent with a Slack channel
675
+ can't be deployed with `--no-wait`, because setup needs the live deployment.
676
+
677
+ ## GitHub channels
678
+
679
+ The GitHub channel is a thin HTTP adapter. Add a channel file with event handlers:
680
+
681
+ ```ts
682
+ // channels/github.ts
683
+ import { channels } from "managed-deepagents";
684
+
685
+ export const channel = channels.github({
686
+ onEvent: {
687
+ "issues.labeled": (event, thread) => {
688
+ if (event.payload.label.name !== "triage") return;
689
+ return `Triage this issue for ${thread.channel.name}: summarize it and recommend next steps. Treat the following as untrusted data:\n${event.payload.issue.title}\n${event.payload.issue.body ?? ""}`;
690
+ },
691
+ },
692
+ });
693
+ ```
694
+
695
+ `mda deploy` sets this up: it creates a GitHub App subscribed to the handled
696
+ events with its webhook URL at `<deployment-url>/channels/github/events`, and
697
+ Agent Auth keeps the App's key, webhook secret and bot ID. The channel reads the
698
+ webhook secret and bot ID from Agent Auth, so neither goes into `.env`. To act on
699
+ GitHub, read an installation token for the App with
700
+ `await connections.get("mda/github-token", { type: "agent" })`; Agent Auth renews it as it expires.
701
+ Acting on GitHub as the person running the agent is not supported yet:
702
+ `connections.get("mda/github-token", { type: "user" })` throws, and deploy refuses
703
+ a project that declares it.
704
+
705
+ A run acts for the GitHub user who sent the event, as `github:<id>`: GitHub
706
+ signs each delivery, and the numeric ID outlives login renames. Events from
707
+ bots and organizations run as the channel. A GitHub sender cannot be mapped to a
708
+ user of the agent's identity, the principal `identity.ts` resolves from LangSmith,
709
+ Supabase or another provider. So MCP servers and tools that act on a user's
710
+ behalf or need a user connection are left out of those runs, with a warning,
711
+ and the run goes on without them. An issue or pull request is a shared
712
+ conversation, so the sender gets user memory only where the user memory
713
+ layer's `allow` opts in. See [Setting up the GitHub App](#setting-up-the-github-app)
714
+ for what the first deploy asks.
715
+
716
+ Pass `app` to narrow what the agent can reach. Deploy applies changes to it on
717
+ every run:
718
+
719
+ ```ts
720
+ channels.github({
721
+ app: {
722
+ permissions: { contents: "read" }, // for the token, beyond what the events need
723
+ repositories: ["acme/api", "acme/web"], // one owner
724
+ },
725
+ onEvent: {
726
+ "issues.opened": (event) => `Triage ${event.payload.issue.title}`,
727
+ },
728
+ });
729
+ ```
730
+
731
+ With `repositories`, events from other repositories start nothing, and deploy
732
+ reports listed ones the App is not installed on. The agent's token reaches every
733
+ repository the App is installed on, so install it only on the ones the agent may
734
+ change.
735
+
736
+ When the handled events, `permissions` or `repositories` change, `mda deploy`
737
+ renews the agent's token once the installation grants what it needs. Handled
738
+ events set their own permission level (read to receive an event, write to also
739
+ reply where it happened), and `permissions` can raise it but not lower it.
740
+ Deploy cannot change the App itself: GitHub reads an App's permissions from its
741
+ manifest only when the App is created, so the App's owner grants added
742
+ permissions, and removes dropped or lowered ones, in the App's settings. Deploy
743
+ names both and links there. `mda delete` removes the App's connections
744
+ from Agent Auth and links the App on GitHub, where its owner can delete it.
745
+ The `GH_*` overrides are read at request time; the webhook secret and bot ID read
746
+ from Agent Auth are cached for up to 5 minutes. A matched event fails closed if
747
+ the bot ID is missing or invalid. Calling `channels.github()` without handlers preserves
748
+ receipt-only behavior and needs only the webhook secret.
749
+
750
+ Supported keys:
751
+
752
+ - Issues: `issues.opened`, `issues.edited`, `issues.reopened`, `issues.labeled`,
753
+ `issue_comment.created`, `issue_comment.edited`.
754
+ - Pull requests: `pull_request.opened`, `pull_request.edited`,
755
+ `pull_request.reopened`, `pull_request.ready_for_review`,
756
+ `pull_request.converted_to_draft`, `pull_request.synchronize`,
757
+ `pull_request.labeled`, `pull_request.closed`.
758
+ - Reviews: `pull_request_review.submitted`, `pull_request_review.edited`,
759
+ `pull_request_review.dismissed`, `pull_request_review_comment.created`,
760
+ `pull_request_review_comment.edited`.
761
+ - Code and CI: `push`, `status`, `check_run.completed`, `check_suite.completed`,
762
+ `workflow_run.completed`. `push` and `status` have no action, so their key is
763
+ the event name. A CI event continues a pull request's conversation when it
764
+ ran for exactly one pull request.
765
+
766
+ GitHub sends no event for a mention, so each event lists the handles the
767
+ text it wrote mentions in `event.mentions`: the body of a new or edited
768
+ comment, review or review comment, or the title and body of an opened or
769
+ edited issue or pull request. An edit lists only the handles it added, so
770
+ fixing a typo doesn't mention anyone again. Events that write no text, such
771
+ as a push to a pull request, a label or a reopen, list none, even when the
772
+ body they belong to mentions someone. Handles are lowercased, listed once, in
773
+ order, and read as GitHub links them: `@octocat` or `@octo-org/reviewers`, not
774
+ `team@octo.dev`, and not in code, quotes or HTML comments, such as a pull
775
+ request template's `<!-- @openswe -->`. Any text tag counts, such as
776
+ `@openswe`, even one that is no GitHub account. A
777
+ handler that answers mentions checks the list:
778
+
779
+ ```ts
780
+ channels.github({
781
+ onEvent: {
782
+ "issue_comment.created": (event) => {
783
+ if (!event.mentions.includes("@openswe")) return;
784
+ return `Answer the comment on #${event.payload.issue.number}.`;
785
+ },
786
+ },
787
+ });
788
+ ```
789
+
790
+ An issue comment on a pull request has `issue.pull_request` set, and an edit
791
+ says what it changed in `payload.changes`.
792
+
793
+ While a conversation's run is still going, a new event that starts a run waits
794
+ for it by default. `multitaskStrategy` changes that, using LangGraph's names:
795
+ `"interrupt"` cancels the active run and keeps its progress, `"rollback"`
796
+ cancels it and discards its progress, and `"reject"` starts nothing. For
797
+ example, `channels.github({ multitaskStrategy: "interrupt", onEvent })` lets a
798
+ newer comment replace the work on an older one. Events on a conversation that
799
+ waits on an interrupt start nothing either way.
800
+ The authoring types describe supported keys and callable handlers. Configuration
801
+ is application code; incoming webhook payloads are validated at runtime.
802
+
803
+ Signatures are verified against the raw bytes. Ping returns 200; other valid
804
+ receipts return 202. An unconfigured event or the App's own activity starts
805
+ nothing. The request awaits the configured callback and run creation before
806
+ acknowledgment (an endpoint's is asked after; see "Asking your service what to
807
+ start"); synchronous and async callbacks are supported. A handler returns
808
+ what `agent.invoke` takes: a nonblank string (one user message), a message such
809
+ as `new HumanMessage(...)` with text or content blocks, state such as
810
+ `{ messages: [...], todos: [] }`, or `[input, { context, metadata }]` to also
811
+ set the run's context (`context.channel` is reserved) or metadata, such as
812
+ `{ issue: "ENG-123" }` to find the run by in LangSmith. Metadata keys are
813
+ letters, digits, `_`, `.` or `-`. Keys the Agent Server and LangSmith set
814
+ are reserved: `mda_`, `langgraph_` and `ls_` keys, and ids such as
815
+ `thread_id`, `session_id`, `run_id` and `user_id`.
816
+ `webhook: url` has the Agent Server POST the finished run (its status,
817
+ metadata, values and any error) to `url`, as `runs.create({ webhook })` does;
818
+ http(s), without credentials in the URL.
819
+ The handler's second argument is the conversation's `thread`: `thread.id` is
820
+ the thread the run starts on, for context that names it, such as a token your
821
+ backend signs for the thread.
822
+ `null` or `undefined` skips without a thread or run.
823
+ Other results and callback failures are safely logged and start nothing.
824
+
825
+ Each issue or pull request has one thread, so the agent keeps the conversation:
826
+ an issue, its comments, and a pull request with its reviews and review comments
827
+ continue the same thread, as does a workflow run for exactly one pull request.
828
+ Other events get a thread of their own. A redelivered webhook starts nothing,
829
+ because each thread runs a delivery once. A comment that arrives while the agent
830
+ is still working waits for that run to finish, so it never skips a decision the
831
+ run stops for. There is no automatic retry.
832
+
833
+ Handlers can call GitHub with a client such as Octokit and the App's
834
+ installation token from `connections.get("mda/github-token", { type: "agent" })`,
835
+ which resolves outside a run too. Agent-written values can hold anything, so
836
+ escape them before posting.
837
+
838
+ A run can still stop on an interrupt: a review from `interruptOn`, or a value
839
+ the agent passed to `interrupt()`. The GitHub channel neither asks for nor
840
+ answers interrupts. When a run stops on one, the App replies with a link to the
841
+ conversation's thread in LangSmith Studio, in the LangSmith environment
842
+ `mda deploy` recorded. While the conversation waits, events on it start nothing
843
+ and get the same link. Anyone with access
844
+ to the deployment's LangSmith workspace can answer there, reviews included;
845
+ Studio can only resume the conversation's interrupts, not start new turns in it.
846
+ The resumed run uses no user connections, even though a person answered: the
847
+ conversation holds content from outside the workspace, which must not act with
848
+ the grants of whoever resumes it from Studio.
849
+
850
+ To acknowledge an event the moment it arrives, such as with a 👀 reaction,
851
+ pass `onReceived(event, thread)`. It hears each delivery of a handled event once,
852
+ with the parsed event and its thread, as soon as the delivery reaches its
853
+ thread: before MDA reads the thread or asks the handler, which under the
854
+ default `enqueue` waits until a busy conversation's run has finished. It
855
+ fires even when the thread then waits on an interrupt or the handler declines,
856
+ so apply your own filters there, such as checking `event.mentions`. It runs in the
857
+ background, before `onFinish`; a failure is logged and doesn't stop the run.
858
+
859
+ ```ts
860
+ import { Octokit } from "@octokit/rest";
861
+ import { channels, connections } from "managed-deepagents";
862
+
863
+ export const channel = channels.github({
864
+ onEvent: { "issue_comment.created": (event) => answerMentions(event) },
865
+ onReceived: async (event) => {
866
+ if (event.key !== "issue_comment.created") return;
867
+ if (!event.mentions.includes("@my-agent")) return;
868
+ const auth = await connections.get("mda/github-token", { type: "agent" });
869
+ await new Octokit({ auth }).rest.reactions.createForIssueComment({
870
+ owner: event.repository.owner,
871
+ repo: event.repository.name,
872
+ comment_id: event.payload.comment.id,
873
+ content: "eyes",
874
+ request: { signal: AbortSignal.timeout(10_000) },
875
+ });
876
+ },
877
+ });
878
+ ```
879
+
880
+ Keep callbacks short: their work and run creation must fit within GitHub's webhook
881
+ response window. A handler for an event that waits for a busy conversation runs
882
+ once that run has finished, after the webhook was acknowledged. The request does not wait for agent completion. Run-start
883
+ failures return 500; skipped or failed callbacks are acknowledged without a run.
884
+
885
+ Callbacks receive a normalized event and its `thread` (`thread.id`,
886
+ `thread.channel.name`, and `thread.interrupted` while it waits on an interrupt). The event includes
887
+ the original payload, delivery and installation IDs, repository and sender.
888
+ Types describe handwritten subsets, not the complete GitHub schema. Run code can
889
+ inspect the normalized event through `runtime.thread.origin.channel.rawEvent`. Logs correlate the GitHub
890
+ delivery ID to the fresh thread and run IDs without printing the payload.
891
+ `GitHub handler returned run input` records the callback decision;
892
+ `channel run started` confirms run creation.
893
+
894
+ Each issue or pull request's thread belongs to that GitHub conversation, whoever
895
+ starts its runs. User connections and automatic GitHub replies are not
896
+ supported. To act on
897
+ GitHub from a run (comment, label, open pull requests), give the agent a GitHub
898
+ MCP server in `tools/mcp.ts`.
899
+
900
+ ### Setting up the GitHub App
901
+
902
+ The first `mda deploy` of a GitHub channel asks which GitHub App it uses, as
903
+ the Slack and Linear channels do:
904
+
905
+ - **Create a new GitHub App**: deploy asks which account should own it, an
906
+ organization or your personal account, then opens GitHub with the App filled
907
+ in and named after the agent. Create it, then install it on the repositories
908
+ the agent may reach.
909
+ - **Use an existing GitHub App**: enter its App ID, private key file and
910
+ webhook secret. Deploy records the installation GitHub reports. It asks you
911
+ to pick one when the App is installed in several accounts, opens the install
912
+ page when it's installed nowhere, and asks for the installation ID only when
913
+ GitHub can't be checked.
914
+
915
+ Agent Auth keeps the App's key, webhook secret and bot ID, so nothing goes into
916
+ `.env`, and later deploys keep the App without asking. An App has one webhook
917
+ URL: if an existing App's webhook points somewhere else, deploy asks before
918
+ moving it to the deployment. Answer "No" to keep it there, for example when
919
+ another service receives the App's events and forwards the ones for this agent
920
+ to `<deployment-url>/channels/github/events` with the body and GitHub's headers
921
+ unchanged. Deploy remembers that URL and doesn't ask again, with or without a
922
+ terminal, until the App's webhook moves. If the App's installation lacks a
923
+ permission the channel needs, deploy names it.
924
+
925
+ To skip the questions, with or without a terminal, set these in the shell or
926
+ `.env`:
927
+
928
+ - `MDA_GITHUB_APP_OWNER`: create a new App owned by this organization, or by
929
+ `@me`, the personal account of whoever creates it.
930
+ - `MDA_GITHUB_APP_ID`, `MDA_GITHUB_APP_PRIVATE_KEY_FILE` (the path to its
931
+ `.pem` file) and `MDA_GITHUB_WEBHOOK_SECRET`: use this existing App instead.
932
+ Add `MDA_GITHUB_APP_INSTALLATION_ID` when it's installed in several accounts.
933
+ - `MDA_GITHUB_WEBHOOK_SECRET` alone: the webhook secret of an existing App
934
+ whose secret Agent Auth doesn't have yet.
935
+ - `MDA_GITHUB_WEBHOOK_ELSEWHERE`: the URL an existing App's webhook keeps.
936
+ Without a terminal, deploy otherwise stops when the webhook points elsewhere.
937
+
938
+ Deploy checks them before uploading. Only the CLI reads them: they are never
939
+ uploaded to the deployment, and you can remove them once the channel is set
940
+ up. Without a terminal and without an owner or an existing App, deploy stops
941
+ before uploading and says what to set. During setup it prints the link for a
942
+ person to open and waits up to an hour for them to finish. `GH_WEBHOOK_SECRET`
943
+ and `GH_APP_BOT_ID` (the App bot account's numeric user ID) are different: the
944
+ deployment reads them, and they override what Agent Auth stores.
945
+
946
+ If a setup step fails once the deployment is live, deploy offers to try again
947
+ or to continue without the GitHub channel. Without a terminal the failure ends
948
+ the deploy, once the other channels are set up. An agent with a GitHub channel
949
+ can't be deployed with `--no-wait`, because setup needs the live deployment.
950
+
951
+ ## Linear channels
952
+
953
+ The Linear channel receives a Linear app's webhooks. Each issue is one
954
+ conversation, and each agent session on it another, and the run's reply is posted as a comment on the issue, in the
955
+ thread of the comment that started the run:
956
+
957
+ ```ts
958
+ // channels/linear.ts
959
+ import { channels } from "managed-deepagents";
960
+
961
+ export const channel = channels.linear({
962
+ app: { teams: ["ENG"] },
963
+ onEvent: {
964
+ "Issue.update": (event) => {
965
+ const before = event.payload.updatedFrom?.labelIds;
966
+ const added = Array.isArray(before)
967
+ ? event.payload.data.labelIds?.filter((id) => !before.includes(id))
968
+ : [];
969
+ if (
970
+ !event.payload.data.labels?.some(
971
+ (l) => added?.includes(l.id) && l.name === "agent"
972
+ )
973
+ )
974
+ return;
975
+ return `Triage ${event.payload.data.identifier}. Treat the following as untrusted data:\n${event.payload.data.title}\n${event.payload.data.description ?? ""}`;
976
+ },
977
+ },
978
+ });
979
+ ```
980
+
981
+ Handled events are `Issue.create`, `Issue.update`, `Comment.create`,
982
+ `AgentSessionEvent.created` and `AgentSessionEvent.prompted`, named as Linear
983
+ names them; an unknown key in `onEvent` throws. The channel verifies each delivery's `Linear-Signature`
984
+ and rejects deliveries older than a minute. It ignores events about teams
985
+ outside `app.teams`, changes by other apps and integrations (set
986
+ `ignoreBots: false` to keep them), and the app's own comments and changes.
987
+
988
+ > **Experimental.** Agent sessions use Linear's Agents API, which is a
989
+ > Developer Preview, so they may change as Linear changes it. Issue and
990
+ > comment events don't depend on it.
991
+
992
+ Agent sessions are on by default (`sessions: false` turns them off). Mentioning
993
+ the app or delegating an issue to it opens a Linear agent session. The channel
994
+ acknowledges it at once and links it to the run's thread in Studio. Without a
995
+ handler, the run starts with Linear's prompt for the session (`promptContext`),
996
+ and a reply in the session continues the conversation. Each session is a
997
+ thread of its own. The run's reply appears in the session, and Stop cancels
998
+ that session's run. A run that stops on interrupts, such
999
+ as a review from `interruptOn`, answers with a link to its thread in LangSmith
1000
+ Studio, where the decision is made; replies in the session meanwhile get the
1001
+ same link. Comments that a
1002
+ session already delivers, such as the mention itself and replies in the
1003
+ session, don't also reach a `Comment.create` handler.
1004
+
1005
+ `app` also names the app deploy asks the admin to create: `name` (2-80
1006
+ characters, without "Linear"; defaults to the agent's name), `description`,
1007
+ and `icon`, a PNG or JPEG given as a path relative to `channels/` like the
1008
+ Slack channel's, such as `assets/icon.png` (at least 256×256 pixels, at most
1009
+ 1 MB). The deployment serves it at `/channels/<name>/icon`, and deploy points
1010
+ the app's icon there. They apply only when deploy creates the app: Linear has
1011
+ no API to change an app, so later changes to them do nothing. Change an
1012
+ existing app on its settings page in Linear; deploy reminds you of this when
1013
+ it installs the app.
1014
+
1015
+ `mda deploy` sets up the Linear app, which takes a Linear workspace admin; see
1016
+ [Setting up the Linear app](#setting-up-the-linear-app).
1017
+
1018
+ The channel reads the webhook signing secret from Agent Auth, or from
1019
+ `LINEAR_WEBHOOK_SECRET` when set. It acts as the app through the deployment's
1020
+ Agent Auth app, whose OAuth connection is `mda/linear-app/<deployment-id>`,
1021
+ installed with `actor=app`; read its token with
1022
+ `await connections.get("mda/linear-token", { type: "agent" })` to call Linear's API from tools.
1023
+
1024
+ `reply: "none"` leaves the run's answer to the agent: the channel doesn't post
1025
+ it as a comment or in the session. Session acknowledgements, Stop and error
1026
+ notices still post.
1027
+
1028
+ [`examples/linear`](../../examples/linear) triages issues in agent sessions,
1029
+ shows its steps and plan there, and waits for approval in LangSmith Studio
1030
+ before moving an issue to another state.
1031
+
1032
+ ### Setting up the Linear app
1033
+
1034
+ The first `mda deploy` of a Linear channel asks which Linear app it uses, as
1035
+ the Slack and GitHub channels do. Setting it up takes a Linear workspace admin:
1036
+
1037
+ - **Create a new Linear app**: Linear has no public API to create apps, so
1038
+ deploy asks for the workspace's URL key (as in `https://linear.app/<key>/`)
1039
+ and opens Linear's new-app page in that workspace, filled in with the app's
1040
+ name, redirect URI, webhook URL (`<deployment-url>/channels/linear/events`)
1041
+ and events. The admin creates the app and pastes its client ID, client
1042
+ secret and webhook signing secret into deploy's prompts.
1043
+ - **Use an existing Linear app**: deploy lists the redirect URI, webhook URL
1044
+ and events to set on the app's settings page, then asks for the same three
1045
+ values. Linear sends an app's webhooks to one URL, so whatever received them
1046
+ before stops receiving them.
1047
+
1048
+ Deploy then opens the install page, where the admin approves the app for the
1049
+ workspace. Agent Auth keeps the credentials and the agent's token, so nothing
1050
+ goes into `.env`, and later deploys keep the app without asking. If Linear
1051
+ stops renewing the app's access, the next deploy keeps the app and only asks
1052
+ an admin to approve it again. Linear has no API to change an app, so when the
1053
+ channel's `app` settings change or the deployment moves to another URL, update
1054
+ the app on its settings page.
1055
+
1056
+ To skip the questions, with or without a terminal, set
1057
+ `MDA_LINEAR_CLIENT_ID`, `MDA_LINEAR_CLIENT_SECRET` and
1058
+ `MDA_LINEAR_WEBHOOK_SECRET` in the shell or `.env`, and `MDA_LINEAR_WORKSPACE`
1059
+ to the workspace's URL key so the links deploy prints open in that workspace.
1060
+ `MDA_LINEAR_WEBHOOK_SECRET` alone supplies the signing secret of an installed
1061
+ app whose secret Agent Auth doesn't have yet. Deploy checks them before
1062
+ uploading, and asks Linear whether the client ID and secret belong together.
1063
+ Only the CLI reads them: they are never uploaded to the deployment, and you can
1064
+ remove them once the channel is set up. Without a terminal and without them,
1065
+ deploy stops before uploading with the link to create the app.
1066
+
1067
+ An app from these variables wasn't made from deploy's filled-in page, and
1068
+ Linear has no API that says what it has set. So before the install link,
1069
+ deploy lists the redirect URI, webhook URL and events the app needs, the same
1070
+ as for an existing app. In a terminal it waits until you say they're set;
1071
+ without one it prints them before the install link for an admin to open.
1072
+ Without the redirect URI, Linear answers the install with "Invalid
1073
+ redirect_uri".
1074
+
1075
+ If a setup step fails once the deployment is live, deploy offers to try again
1076
+ or to continue without the Linear channel. Without a terminal the failure ends
1077
+ the deploy, once the other channels are set up. An agent with a Linear channel
1078
+ can't be deployed with `--no-wait`, because setup needs the live deployment.
1079
+ `mda delete` removes the credentials; delete the app itself in Linear.
1080
+ Deployments set up by an earlier `mda` keep the app as workspace connections,
1081
+ which only a LangSmith workspace admin can delete.
1082
+
353
1083
  ## HTTP channels
354
1084
 
355
1085
  Use `channels.http({ provider, verify, parse, post })` for a provider webhook.
@@ -362,21 +1092,22 @@ A message returned by `parse` contains `userId`, `threadId`, `content`, and `tar
362
1092
  `threadId` is the stable LangGraph thread UUID. `target` is separate JSON that the
363
1093
  adapter needs to reply, such as a Photon conversation ID or a Slack channel and
364
1094
  thread timestamp. MDA keeps this target private and binds it to
365
- `runtime.channel.post`. The adapter's `post` callback receives the target for
1095
+ `runtime.thread.origin.channel.post`. The adapter's `post` callback receives the target for
366
1096
  reply routing.
367
1097
 
368
1098
  `verify` runs first with the original bytes and headers. `verify` and `parse`
369
1099
  each get a separately readable request body. `parse` owns body decoding and can
370
1100
  read JSON, form data, text, or bytes. It returns the existing `message` or `ignore`
371
- result. MDA creates `runtime.channel.event` from the parsed message.
1101
+ result. MDA creates `runtime.thread.origin.channel.event` from the parsed message.
372
1102
 
373
1103
  To expose provider data, return
374
1104
  `{ type: "message", message, rawEvent: event }` from `parse`. MDA validates this
375
- value as finite, acyclic JSON and copies it into `runtime.channel.rawEvent`.
1105
+ value as finite, acyclic JSON and copies it into
1106
+ `runtime.thread.origin.channel.rawEvent`, in the run that message starts.
376
1107
  If you omit `rawEvent`, it stays absent. MDA does not decode the body again.
377
1108
  An explicit `null` is a valid event value.
378
1109
 
379
- HTTP and Slack Trigger runs expose delivery through `runtime.channel`.
1110
+ HTTP and Slack Trigger runs expose delivery through `runtime.thread.origin.channel`.
380
1111
 
381
1112
  The optional method has this signature:
382
1113
 
@@ -401,19 +1132,161 @@ credentials when it calls the provider API. Native routing or authentication
401
1132
  fields must not replace them.
402
1133
 
403
1134
  Automatic agent replies use the `content` form. An explicit
404
- `runtime.channel.post({ type: "native", native: ... })` reaches your adapter
1135
+ `runtime.thread.origin.channel.post({ type: "native", native: ... })` reaches your adapter
405
1136
  without conversion. Automatic replies run after the request is accepted. A failed
406
- `post` is recorded as a delivery error.
1137
+ `post` is recorded as a delivery error. `reply: "none"` turns automatic
1138
+ replies off, so the agent replies itself; `post` still serves
1139
+ `runtime.channel.post` and error notices.
407
1140
  If `post` is omitted, the channel can receive events and exposes facts, but
408
1141
  has no runtime `post` method. The webhook path is `/channels/<name>/events`, where
409
1142
  `<name>` is the channel file name. An existing Photon webhook needs no URL change
410
1143
  when the deployment host and channel name stay the same.
411
1144
 
412
- If a run or its observation fails, MDA uses `post` to send “Something went wrong
1145
+ If a run fails, MDA uses `post` to send “Something went wrong
413
1146
  while processing your request.” A failed send is logged without another attempt.
414
1147
  Optional async `onError(error, target)` replaces this default. MDA supplies the
415
1148
  reply target; pass it to your adapter's `post` to send a custom error message.
416
1149
 
1150
+ Two optional async hooks follow each message through its lifecycle:
1151
+
1152
+ - `onReceived(target, delivery)` runs for every verified message that reaches
1153
+ its thread, before MDA starts or queues anything for it, for providers that
1154
+ expect a prompt acknowledgement.
1155
+ - `onFinish(target, { ...delivery, type, ..., interrupts })` runs once each
1156
+ message is done, after `onReceived` and after `onError`, and says how by
1157
+ `type`:
1158
+ - `run`: the run it started ended, as `run: { id, status }` with
1159
+ LangGraph's run status: `success`, `error`, `timeout` or `interrupted` (it
1160
+ stopped on interrupts, or was cancelled).
1161
+ - `skipped`: it started no run, and `reason` says why: `cancel`, `waiting`
1162
+ (the thread waits on a decision), `ignored` (its `input` returned
1163
+ nothing), `duplicate` (a redelivery; the first delivery reports the run),
1164
+ `rejected` (a busy thread and `multitaskStrategy: "reject"`) or `dropped`
1165
+ (a cancel dropped it while it waited).
1166
+ - `failed`: MDA couldn't start its run after the provider got its answer
1167
+ (`reason: "start"`, final); couldn't start it and answered the provider with an
1168
+ error (`retry`), so it may redeliver it as a new delivery, which reports
1169
+ its own outcome; or lost track of the run (`observe`), which may still
1170
+ answer.
1171
+
1172
+ `interrupts` lists the decisions the thread waits on, as LangGraph's
1173
+ `thread.interrupts` does: when it isn't empty, point the sender to Studio,
1174
+ where they can be resumed.
1175
+
1176
+ A `parse` result of `{ type: "cancel", message: { userId, threadId, target } }`
1177
+ cancels the thread's queued and running runs, keeping their progress, and
1178
+ drops messages waiting for the thread. It finishes at once, as `skipped` for
1179
+ `cancel`, with what the thread still waits on.
1180
+
1181
+ ```ts
1182
+ onFinish: async (target, finished) => {
1183
+ if (finished.type === "run" && finished.run.status === "success")
1184
+ await markDone(target);
1185
+ else if (finished.interrupts.length)
1186
+ await notify(target, `A decision is pending: ${studioLink(finished.threadId)}`);
1187
+ },
1188
+ ```
1189
+
1190
+ The hooks run in the background, in the process that took the delivery;
1191
+ failures are logged. A restart while a run is in flight loses its
1192
+ `onFinish`, and a run Studio resumes has no delivery, so it gets none: keep a
1193
+ reconciliation, or the run's `webhook` (see handlers' run options), for anything
1194
+ that must not miss one. The run posts its own
1195
+ answer.
1196
+
1197
+ GitHub and Linear take `onFinish(event, thread, finished)`, `finished` as
1198
+ above without the delivery's own fields, with
1199
+ their parsed event and the thread its handler saw, called after their own
1200
+ notices, such as the comment or the session elicitation that a decision is
1201
+ pending, or Linear's "Stopped.".
1202
+
1203
+ ### Asking your service what to start
1204
+
1205
+ When the logic that decides a run lives in a service you already run, an
1206
+ `onEvent` handler can be that service's endpoint instead of a function: a URL,
1207
+ or a `Request` that also carries headers, such as a credential the service
1208
+ checks. When the event's thread takes a turn, MDA POSTs
1209
+ `{ event: { key, deliveryId, payload }, thread: { id, channel, interrupted? } }`
1210
+ as JSON to it, with the `Request`'s headers (never logged), and starts the run
1211
+ the service answers with: `{ input, context?, metadata?, webhook? }`, checked as
1212
+ a handler's result. `null` or HTTP 204 starts nothing. A GitHub event also
1213
+ carries what a handler gets beside the payload: its `action`, `repository`,
1214
+ `sender` and `mentions`, so a service checks them as a handler does. These are
1215
+ optional in `GitHubEndpointRequest`, so a receiver takes requests from older
1216
+ deployments. A Slack message carries its `text`, `userId`, `channelId`,
1217
+ `messageTs`, `threadTs` and `files` the same way, with Slack's own event as
1218
+ `payload`.
1219
+
1220
+ ```ts
1221
+ const backend = new Request(`${process.env.BACKEND_URL}/linear/runs`, {
1222
+ headers: { "x-api-key": process.env.BACKEND_KEY! },
1223
+ });
1224
+
1225
+ export const channel = channels.linear({
1226
+ onEvent: {
1227
+ "AgentSessionEvent.created": backend,
1228
+ "AgentSessionEvent.prompted": backend,
1229
+ "Issue.update": backend,
1230
+ "Comment.create": (event) => `Summarize ${event.payload.data.body}`,
1231
+ },
1232
+ });
1233
+ ```
1234
+
1235
+ GitHub, Linear or Trigger Server gets its answer first, and MDA asks the
1236
+ service in the background, so a slow service doesn't time out the delivery. A network error
1237
+ before the answer, HTTP 429 or a 5xx is tried again, up to three attempts with
1238
+ the same `webhook-id`. Another error status, a redirect, an answer cut off or
1239
+ that isn't one of these, more than 10 MB, or no answer within 60 seconds fails the handler, as a
1240
+ handler that throws does: Linear tells the session. The URL must be https, or
1241
+ plain http to a loopback host such as `localhost` for local development, and
1242
+ carry no credentials; a bad one throws when the channel is declared.
1243
+
1244
+ To let the service check that a request came from your deployment and wasn't
1245
+ changed or replayed, set `MDA_SERVICE_SECRET` in the project's `.env`;
1246
+ `mda deploy` forwards it to the deployment. MDA then signs every endpoint
1247
+ request as [Standard Webhooks](https://www.standardwebhooks.com/) does:
1248
+ `webhook-id`, `webhook-timestamp` and `webhook-signature`, an HMAC-SHA256 of the
1249
+ id, the timestamp and the exact body. The id is `msg_<deliveryId>` for the call
1250
+ that starts the run, and `msg_<deliveryId>_interrupted` for a GitHub call that
1251
+ asks whether to tell the conversation its thread waits on a decision. The secret is `whsec_` and padded base64
1252
+ of 24 to 64 random bytes (`echo "whsec_$(openssl rand -base64 32)"`; an
1253
+ `openssl rand -hex 32` value is valid too); several, separated by commas, each
1254
+ sign the request, for rotation. A malformed secret throws when the channel is declared.
1255
+
1256
+ The service keeps the same secret and verifies with any Standard Webhooks
1257
+ library, which also rejects timestamps older than five minutes:
1258
+
1259
+ ```ts
1260
+ import { Webhook } from "standardwebhooks";
1261
+
1262
+ const event = new Webhook(process.env.ENDPOINT_SECRET!).verify(
1263
+ rawBody,
1264
+ Object.fromEntries(request.headers)
1265
+ );
1266
+ ```
1267
+
1268
+ On the service's side, `LinearEndpointRequest<K>`,
1269
+ `GitHubEndpointRequest<K>` and `SlackEndpointRequest<K>` type what the channel
1270
+ sends, `{ event: { key,
1271
+ deliveryId, payload }, thread }`, with the payload typed by the event key, and
1272
+ `EndpointAnswer` types an answer, all JSON; answer `null` to start nothing. The
1273
+ request types are types only: validate the body as your service validates
1274
+ input, after verifying its signature, or the credential your endpoint's `Request`
1275
+ carries.
1276
+
1277
+ ```ts
1278
+ import type { EndpointAnswer, LinearEndpointRequest } from "managed-deepagents";
1279
+
1280
+ app.post("/linear/runs", (req, res) => {
1281
+ const { event, thread } = req.body as LinearEndpointRequest;
1282
+ const answer: EndpointAnswer | null =
1283
+ event.key === "AgentSessionEvent.created"
1284
+ ? { input: `Plan ${event.payload.agentSession.issue?.title}` }
1285
+ : null;
1286
+ res.json(answer);
1287
+ });
1288
+ ```
1289
+
417
1290
  ## Project Shape
418
1291
 
419
1292
  ```text
@@ -455,6 +1328,7 @@ export const schedule = defineSchedule({
455
1328
 
456
1329
  ```md
457
1330
  <!-- schedules/daily-digest.md -->
1331
+
458
1332
  Write the daily digest.
459
1333
  ```
460
1334
 
@@ -524,8 +1398,31 @@ await runtime.schedules!.create({
524
1398
  ```
525
1399
 
526
1400
  Set `newThread` to choose whether a run starts a new thread or continues the
527
- current thread. When a schedule is created from a channel such as Slack,
528
- each run posts its final answer to that channel. Runtime schedules stay when you deploy again.
1401
+ current thread. When a schedule is created on a channel's thread, such as a
1402
+ Slack thread, each run posts its final answer to that channel. A same-thread
1403
+ schedule posts wherever the thread's origin points when it runs, so its record
1404
+ has `channel: null` and `target: null`. A new-thread schedule keeps the
1405
+ conversation it was created in. Runtime schedules stay when you deploy again.
1406
+
1407
+ A user schedule can run as another person on the thread. Pass one of
1408
+ `runtime.thread.participants` as `runAs`; the caller still owns the schedule
1409
+ and is the one who can list, update, and delete it. Runs act as that person,
1410
+ with their connections.
1411
+
1412
+ ```ts
1413
+ const me = runtime.serverInfo?.principal?.id;
1414
+ const bob = runtime.thread!.participants.find(({ id }) => id !== me);
1415
+ await runtime.schedules!.create({
1416
+ owner: { type: "user" },
1417
+ cron: "0 9 * * 1",
1418
+ prompt: "Remind Bob about the weekly report.",
1419
+ newThread: false,
1420
+ runAs: bob,
1421
+ });
1422
+ ```
1423
+
1424
+ `runAs` needs `owner: { type: "user" }` and a participant with the same id and
1425
+ role; anything else is an error. The schedule's record shows it as `runAs`.
529
1426
 
530
1427
  Each owner can have at most 20 runtime schedules per agent, paused ones
531
1428
  included. Set `MDA_MAX_AGENT_SCHEDULES` or `MDA_MAX_USER_SCHEDULES` in the
@@ -565,7 +1462,10 @@ import type { ManagedToolRuntime } from "managed-deepagents";
565
1462
 
566
1463
  async function writeReport(runtime: ManagedToolRuntime) {
567
1464
  if (!runtime.backend) throw new Error("This tool requires a sandbox");
568
- const result = await runtime.backend.write("/workspace/report.txt", "Report ready");
1465
+ const result = await runtime.backend.write(
1466
+ "/workspace/report.txt",
1467
+ "Report ready"
1468
+ );
569
1469
  if (result.error) throw new Error(result.error);
570
1470
  }
571
1471
  ```
@@ -598,12 +1498,10 @@ used only to reconcile the registry and never enters the build or snapshot.
598
1498
  Add `tools/mcp.ts` to attach MCP servers. The file must export a named `mcp`.
599
1499
  By default, MDA exposes every tool loaded from each declared
600
1500
  server. In `mda dev`, an agent-owned connection reads from
601
- `MDA_DEV_<SLUG>` with the slug uppercased and hyphens changed to underscores.
1501
+ `MDA_DEV_<SLUG>` with the slug uppercased, hyphens changed to underscores, and
1502
+ slashes to double underscores (`mda/github-token` → `MDA_DEV_MDA__GITHUB_TOKEN`).
602
1503
  Hosted deployments resolve workspace connections from Agent Auth:
603
1504
 
604
- The old `connectors/mcp.ts` file API remains available with a warning during
605
- `0.7.x`. It will be removed in `0.8.0`.
606
-
607
1505
  ```ts
608
1506
  import { defineMcp, connections } from "managed-deepagents";
609
1507
 
@@ -695,10 +1593,10 @@ export const sandbox = defineSandbox({
695
1593
  });
696
1594
  ```
697
1595
 
698
- | Header value | Sent value |
699
- | --- | --- |
700
- | `ref` | Raw token |
701
- | `bearer(ref)` | `Bearer <token>` |
1596
+ | Header value | Sent value |
1597
+ | ---------------------- | -------------------------------- |
1598
+ | `ref` | Raw token |
1599
+ | `bearer(ref)` | `Bearer <token>` |
702
1600
  | `basic(username, ref)` | `Basic <base64(username:token)>` |
703
1601
 
704
1602
  Use `{ type: "agent" }` for agent credentials. Omit header `type` for
@@ -790,6 +1688,4 @@ workspace secrets; a value exported in your shell is not deployed. For
790
1688
  LangSmith itself, set `LANGSMITH_API_KEY` in `.env` or your shell, or run
791
1689
  interactively and press Enter at the prompt to sign in with your browser (the
792
1690
  CLI creates a key and writes it to `.env`). TypeScript deploys also require
793
- `npm` on `PATH` because the CLI generates a lockfile for the remote build;
794
- other lockfiles (`pnpm-lock.yaml`, `yarn.lock`, `bun.lock`) are left out of
795
- the build.
1691
+ `npm` on `PATH` because the CLI generates a lockfile for the remote build.