managed-deepagents 0.10.0-dev.17 → 0.10.0-dev.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +508 -80
- package/dist/channels/actor.d.ts +43 -0
- package/dist/channels/actor.d.ts.map +1 -0
- package/dist/channels/actor.js +2 -0
- package/dist/channels/actor.js.map +1 -0
- package/dist/channels/assistant-text.d.ts +29 -0
- package/dist/channels/assistant-text.d.ts.map +1 -1
- package/dist/channels/assistant-text.js +72 -1
- package/dist/channels/assistant-text.js.map +1 -1
- package/dist/channels/binding.d.ts +20 -1
- package/dist/channels/binding.d.ts.map +1 -1
- package/dist/channels/binding.js +39 -10
- package/dist/channels/binding.js.map +1 -1
- package/dist/channels/delivery.d.ts +21 -0
- package/dist/channels/delivery.d.ts.map +1 -0
- package/dist/channels/delivery.js +196 -0
- package/dist/channels/delivery.js.map +1 -0
- package/dist/channels/github/index.d.ts.map +1 -1
- package/dist/channels/github/index.js +13 -11
- package/dist/channels/github/index.js.map +1 -1
- package/dist/channels/github/schema.d.ts +50 -1
- package/dist/channels/github/schema.d.ts.map +1 -1
- package/dist/channels/github/schema.js +12 -0
- package/dist/channels/github/schema.js.map +1 -1
- package/dist/channels/http/endpoint.d.ts +6 -4
- package/dist/channels/http/endpoint.d.ts.map +1 -1
- package/dist/channels/http/endpoint.js.map +1 -1
- package/dist/channels/http/http.d.ts.map +1 -1
- package/dist/channels/http/http.js +4 -10
- package/dist/channels/http/http.js.map +1 -1
- package/dist/channels/http/index.d.ts.map +1 -1
- package/dist/channels/http/index.js +10 -16
- package/dist/channels/http/index.js.map +1 -1
- package/dist/channels/http/ingress.d.ts +2 -2
- package/dist/channels/http/ingress.d.ts.map +1 -1
- package/dist/channels/http/ingress.js +9 -21
- package/dist/channels/http/ingress.js.map +1 -1
- package/dist/channels/http/provider.d.ts +10 -5
- package/dist/channels/http/provider.d.ts.map +1 -1
- package/dist/channels/http/provider.js +17 -10
- package/dist/channels/http/provider.js.map +1 -1
- package/dist/channels/http/studio.d.ts +5 -5
- package/dist/channels/http/studio.d.ts.map +1 -1
- package/dist/channels/http/studio.js +4 -6
- package/dist/channels/http/studio.js.map +1 -1
- package/dist/channels/http/types.d.ts +7 -1
- package/dist/channels/http/types.d.ts.map +1 -1
- package/dist/channels/linear/index.d.ts.map +1 -1
- package/dist/channels/linear/index.js +16 -11
- package/dist/channels/linear/index.js.map +1 -1
- package/dist/channels/linear/schema.d.ts +11 -25
- package/dist/channels/linear/schema.d.ts.map +1 -1
- package/dist/channels/linear/schema.js +6 -0
- package/dist/channels/linear/schema.js.map +1 -1
- package/dist/channels/linear/types.d.ts +9 -2
- package/dist/channels/linear/types.d.ts.map +1 -1
- package/dist/channels/messaging-registry.d.ts +16 -0
- package/dist/channels/messaging-registry.d.ts.map +1 -1
- package/dist/channels/messaging-registry.js +29 -0
- package/dist/channels/messaging-registry.js.map +1 -1
- package/dist/channels/reserved-connections.d.ts.map +1 -1
- package/dist/channels/reserved-connections.js +10 -0
- package/dist/channels/reserved-connections.js.map +1 -1
- package/dist/channels/run-input.d.ts +11 -0
- package/dist/channels/run-input.d.ts.map +1 -1
- package/dist/channels/run-input.js +18 -8
- package/dist/channels/run-input.js.map +1 -1
- package/dist/channels/runtime.d.ts +1 -1
- package/dist/channels/runtime.d.ts.map +1 -1
- package/dist/channels/runtime.js +1 -1
- package/dist/channels/runtime.js.map +1 -1
- package/dist/channels/schedule-delivery.d.ts +1 -1
- package/dist/channels/schedule-delivery.d.ts.map +1 -1
- package/dist/channels/schedule-delivery.js +9 -20
- package/dist/channels/schedule-delivery.js.map +1 -1
- package/dist/channels/slack/api.d.ts +2 -0
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +6 -0
- package/dist/channels/slack/api.js.map +1 -1
- package/dist/channels/slack/connections.d.ts +6 -0
- package/dist/channels/slack/connections.d.ts.map +1 -0
- package/dist/channels/slack/connections.js +6 -0
- package/dist/channels/slack/connections.js.map +1 -0
- package/dist/channels/slack/events.d.ts +272 -0
- package/dist/channels/slack/events.d.ts.map +1 -0
- package/dist/channels/slack/events.js +235 -0
- package/dist/channels/slack/events.js.map +1 -0
- package/dist/channels/slack/files.d.ts.map +1 -1
- package/dist/channels/slack/files.js +2 -3
- package/dist/channels/slack/files.js.map +1 -1
- package/dist/channels/slack/index.d.ts +44 -2
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +124 -3
- package/dist/channels/slack/index.js.map +1 -1
- package/dist/channels/slack/message-content.d.ts.map +1 -1
- package/dist/channels/slack/message-content.js +23 -28
- package/dist/channels/slack/message-content.js.map +1 -1
- package/dist/channels/slack/status.d.ts +76 -0
- package/dist/channels/slack/status.d.ts.map +1 -0
- package/dist/channels/slack/status.js +427 -0
- package/dist/channels/slack/status.js.map +1 -0
- package/dist/channels/trigger/client.d.ts.map +1 -1
- package/dist/channels/trigger/client.js +4 -9
- package/dist/channels/trigger/client.js.map +1 -1
- package/dist/channels/trigger/http.d.ts +114 -3
- package/dist/channels/trigger/http.d.ts.map +1 -1
- package/dist/channels/trigger/http.js +310 -71
- package/dist/channels/trigger/http.js.map +1 -1
- package/dist/channels/trigger/ingress.d.ts +38 -1
- package/dist/channels/trigger/ingress.d.ts.map +1 -1
- package/dist/channels/trigger/ingress.js +47 -1
- package/dist/channels/trigger/ingress.js.map +1 -1
- package/dist/channels/trigger/types.d.ts +82 -3
- package/dist/channels/trigger/types.d.ts.map +1 -1
- package/dist/channels/trigger/types.js +36 -0
- package/dist/channels/trigger/types.js.map +1 -1
- package/dist/channels/types.d.ts +19 -3
- package/dist/channels/types.d.ts.map +1 -1
- package/dist/channels/types.js +2 -0
- package/dist/channels/types.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ingress/runs.d.ts +22 -0
- package/dist/ingress/runs.d.ts.map +1 -1
- package/dist/ingress/runs.js +45 -1
- package/dist/ingress/runs.js.map +1 -1
- package/dist/managed-composition.d.ts.map +1 -1
- package/dist/managed-composition.js +8 -13
- package/dist/managed-composition.js.map +1 -1
- package/dist/namespaces.d.ts +0 -21
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +0 -29
- package/dist/namespaces.js.map +1 -1
- package/dist/runtime/auth.d.ts +1 -2
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +90 -63
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/identity-runtime.d.ts +4 -9
- package/dist/runtime/identity-runtime.d.ts.map +1 -1
- package/dist/runtime/identity-runtime.js +12 -25
- package/dist/runtime/identity-runtime.js.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +32 -23
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/managed-thread.d.ts +60 -0
- package/dist/runtime/managed-thread.d.ts.map +1 -0
- package/dist/runtime/managed-thread.js +76 -0
- package/dist/runtime/managed-thread.js.map +1 -0
- package/dist/runtime/managed-tools.d.ts +10 -2
- package/dist/runtime/managed-tools.d.ts.map +1 -1
- package/dist/runtime/managed-tools.js +10 -8
- package/dist/runtime/managed-tools.js.map +1 -1
- package/dist/runtime/memory/policy.d.ts.map +1 -1
- package/dist/runtime/memory/policy.js +1 -3
- package/dist/runtime/memory/policy.js.map +1 -1
- package/dist/runtime/run-input.d.ts +10 -0
- package/dist/runtime/run-input.d.ts.map +1 -1
- package/dist/runtime/run-input.js +48 -2
- package/dist/runtime/run-input.js.map +1 -1
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +1 -1
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/schedule-auth.d.ts +17 -0
- package/dist/runtime/schedule-auth.d.ts.map +1 -1
- package/dist/runtime/schedule-auth.js +39 -1
- package/dist/runtime/schedule-auth.js.map +1 -1
- package/dist/runtime/thread-record.d.ts +81 -0
- package/dist/runtime/thread-record.d.ts.map +1 -0
- package/dist/runtime/thread-record.js +205 -0
- package/dist/runtime/thread-record.js.map +1 -0
- package/dist/runtime/types.d.ts +5 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime-schedules.d.ts +13 -0
- package/dist/runtime-schedules.d.ts.map +1 -1
- package/dist/runtime-schedules.js +83 -20
- package/dist/runtime-schedules.js.map +1 -1
- package/dist/sandbox.d.ts +0 -6
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +3 -7
- package/dist/sandbox.js.map +1 -1
- package/dist/schedule-channel.d.ts +5 -2
- package/dist/schedule-channel.d.ts.map +1 -1
- package/dist/schedule-channel.js +13 -12
- package/dist/schedule-channel.js.map +1 -1
- package/dist/values.d.ts +15 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +31 -0
- package/dist/values.js.map +1 -0
- package/package.json +7 -7
- package/dist/channels/http/reply.d.ts +0 -20
- package/dist/channels/http/reply.d.ts.map +0 -1
- package/dist/channels/http/reply.js +0 -116
- package/dist/channels/http/reply.js.map +0 -1
package/README.md
CHANGED
|
@@ -151,7 +151,7 @@ strings and arrays remain explicit selections. Select memory with `defineMemory(
|
|
|
151
151
|
selected memory cannot use `allow`. Root `memory.ts` remains the fallback.
|
|
152
152
|
|
|
153
153
|
On direct runs, `executionRuntime.context` is application context or `undefined`.
|
|
154
|
-
On channel runs, it is `undefined`; read
|
|
154
|
+
On channel runs, it is `undefined`; read the conversation from `runtime.thread`.
|
|
155
155
|
`ManagedServerRuntime<AppContext>` preserves the application's context type.
|
|
156
156
|
`accessContext` identifies the Agent Server operation that called the factory.
|
|
157
157
|
During inspection, `executionRuntime` is `null`. Keep the factory repeatable and
|
|
@@ -243,12 +243,18 @@ current channel delivery:
|
|
|
243
243
|
runtime
|
|
244
244
|
.context // Application data on direct runs
|
|
245
245
|
.serverInfo // Trusted caller and server information
|
|
246
|
-
.
|
|
247
|
-
.
|
|
248
|
-
.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
|
252
258
|
.backend // Present when a sandbox is configured
|
|
253
259
|
.schedules // Create and manage schedules for this run's caller
|
|
254
260
|
```
|
|
@@ -265,8 +271,8 @@ await client.runs.create(threadId, assistantId, {
|
|
|
265
271
|
Direct API runs use your authored `contextSchema` and native LangGraph context
|
|
266
272
|
validation. On channel runs, tools and authored factories receive `undefined`
|
|
267
273
|
as context. Native middleware receives an empty context. Use
|
|
268
|
-
`runtime.channel.event` for the typed event and
|
|
269
|
-
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
|
|
270
276
|
required fields do not apply to channel runs. Supplying a `channel` field in a
|
|
271
277
|
direct API call does not establish a trusted channel source.
|
|
272
278
|
|
|
@@ -277,26 +283,48 @@ in the graph factory for each run or resume. Direct callers of the managed
|
|
|
277
283
|
compiler must build a fresh graph with the execution's context; a compiled graph
|
|
278
284
|
is scoped to that execution.
|
|
279
285
|
|
|
280
|
-
`runtime.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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.
|
|
284
295
|
|
|
285
296
|
```ts
|
|
286
|
-
|
|
287
|
-
|
|
297
|
+
const channel = runtime.thread?.origin?.channel;
|
|
298
|
+
if (channel?.post) {
|
|
299
|
+
await channel.post({
|
|
288
300
|
type: "content",
|
|
289
301
|
content: "I am checking that now.",
|
|
290
302
|
});
|
|
291
303
|
}
|
|
292
304
|
```
|
|
293
305
|
|
|
294
|
-
|
|
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.
|
|
295
323
|
It rejects native payloads and content it cannot send. For channels that support
|
|
296
324
|
native messages, set `type` to `"native"` and supply the JSON in `native`.
|
|
297
325
|
For content messages, set `type` to `"content"` and supply `content`.
|
|
298
326
|
Supply only the matching payload. Native JSON has no extra provider or payload
|
|
299
|
-
wrapper. The
|
|
327
|
+
wrapper. The channel helper has no `address`, `update`, or destination override.
|
|
300
328
|
A post sends an additional message; the normal final agent reply remains automatic.
|
|
301
329
|
|
|
302
330
|
Managed Slack channels save incoming files under `/workspace/attachments/` and
|
|
@@ -318,7 +346,8 @@ MDA does not reuse the previous delivery's event.
|
|
|
318
346
|
For a prompt that answers an interrupt, put a shared ID on the prompt and on the
|
|
319
347
|
interrupt value under `INTERRUPT_CORRELATION_KEY`. MDA uses `correlation_id` to
|
|
320
348
|
select that interrupt. Without a correlation ID, an answer can resume the only
|
|
321
|
-
pending interrupt
|
|
349
|
+
pending interrupt that isn't a tool-call review; multiple pending interrupts
|
|
350
|
+
require a match. Existing resume
|
|
322
351
|
values are unchanged.
|
|
323
352
|
|
|
324
353
|
The managed runtime fields are available to authored tools and middleware,
|
|
@@ -339,6 +368,312 @@ alias for the tool type. MDA adds `serverInfo`, `channel`, `backend`, and
|
|
|
339
368
|
but the type marks it optional so annotated hooks still match LangChain's native
|
|
340
369
|
runtime types.
|
|
341
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
|
+
|
|
342
677
|
## GitHub channels
|
|
343
678
|
|
|
344
679
|
The GitHub channel is a thin HTTP adapter. Add a channel file with event handlers:
|
|
@@ -375,26 +710,8 @@ Supabase or another provider. So MCP servers and tools that act on a user's
|
|
|
375
710
|
behalf or need a user connection are left out of those runs, with a warning,
|
|
376
711
|
and the run goes on without them. An issue or pull request is a shared
|
|
377
712
|
conversation, so the sender gets user memory only where the user memory
|
|
378
|
-
layer's `allow` opts in.
|
|
379
|
-
|
|
380
|
-
terminal, for example when a coding agent deploys, set `MDA_GITHUB_APP_OWNER` in
|
|
381
|
-
the shell or `.env` to that organization, or to `@me` for the personal account
|
|
382
|
-
of whoever creates the App. Deploy checks this before creating the deployment
|
|
383
|
-
and fails without it. During setup it prints the link for a person to open and
|
|
384
|
-
waits up to an hour for them to finish.
|
|
385
|
-
To use an existing App instead, choose it on the first deploy and enter its App
|
|
386
|
-
ID, private key file, installation ID and webhook secret. Agent Auth keeps them
|
|
387
|
-
like a created App's, and deploy looks up the bot ID, so nothing goes into
|
|
388
|
-
`.env`. `GH_WEBHOOK_SECRET` and `GH_APP_BOT_ID` (the App bot account's numeric
|
|
389
|
-
user ID) still override the stored values. An App has one webhook URL: if the
|
|
390
|
-
existing App's webhook points somewhere else, deploy asks before moving it to
|
|
391
|
-
the deployment, and fails without a terminal. Answer "No" to keep it there, for
|
|
392
|
-
example when another service receives the App's events and forwards the ones
|
|
393
|
-
for this agent to `<deployment-url>/channels/github/events` with the body and
|
|
394
|
-
GitHub's headers unchanged. Deploy remembers that URL and doesn't ask again, with
|
|
395
|
-
or without a terminal, until the App's webhook moves. Without a terminal, set
|
|
396
|
-
`MDA_GITHUB_WEBHOOK_ELSEWHERE` to the URL instead. If the App's installation
|
|
397
|
-
lacks a permission the channel needs, deploy names it.
|
|
713
|
+
layer's `allow` opts in. See [Setting up the GitHub App](#setting-up-the-github-app)
|
|
714
|
+
for what the first deploy asks.
|
|
398
715
|
|
|
399
716
|
Pass `app` to narrow what the agent can reach. Deploy applies changes to it on
|
|
400
717
|
every run:
|
|
@@ -425,8 +742,6 @@ manifest only when the App is created, so the App's owner grants added
|
|
|
425
742
|
permissions, and removes dropped or lowered ones, in the App's settings. Deploy
|
|
426
743
|
names both and links there. `mda delete` removes the App's connections
|
|
427
744
|
from Agent Auth and links the App on GitHub, where its owner can delete it.
|
|
428
|
-
A new App is named after the agent, and the first deploy asks which account to
|
|
429
|
-
create it in.
|
|
430
745
|
The `GH_*` overrides are read at request time; the webhook secret and bot ID read
|
|
431
746
|
from Agent Auth are cached for up to 5 minutes. A matched event fails closed if
|
|
432
747
|
the bot ID is missing or invalid. Calling `channels.github()` without handlers preserves
|
|
@@ -571,17 +886,68 @@ Callbacks receive a normalized event and its `thread` (`thread.id`,
|
|
|
571
886
|
`thread.channel.name`, and `thread.interrupted` while it waits on an interrupt). The event includes
|
|
572
887
|
the original payload, delivery and installation IDs, repository and sender.
|
|
573
888
|
Types describe handwritten subsets, not the complete GitHub schema. Run code can
|
|
574
|
-
inspect the normalized event through `runtime.channel.rawEvent`. Logs correlate the GitHub
|
|
889
|
+
inspect the normalized event through `runtime.thread.origin.channel.rawEvent`. Logs correlate the GitHub
|
|
575
890
|
delivery ID to the fresh thread and run IDs without printing the payload.
|
|
576
891
|
`GitHub handler returned run input` records the callback decision;
|
|
577
892
|
`channel run started` confirms run creation.
|
|
578
893
|
|
|
579
894
|
Each issue or pull request's thread belongs to that GitHub conversation, whoever
|
|
580
|
-
starts its runs. User connections
|
|
581
|
-
|
|
895
|
+
starts its runs. User connections and automatic GitHub replies are not
|
|
896
|
+
supported. To act on
|
|
582
897
|
GitHub from a run (comment, label, open pull requests), give the agent a GitHub
|
|
583
898
|
MCP server in `tools/mcp.ts`.
|
|
584
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
|
+
|
|
585
951
|
## Linear channels
|
|
586
952
|
|
|
587
953
|
The Linear channel receives a Linear app's webhooks. Each issue is one
|
|
@@ -644,37 +1010,73 @@ Slack channel's, such as `assets/icon.png` (at least 256×256 pixels, at most
|
|
|
644
1010
|
the app's icon there. They apply only when deploy creates the app: Linear has
|
|
645
1011
|
no API to change an app, so later changes to them do nothing. Change an
|
|
646
1012
|
existing app on its settings page in Linear; deploy reminds you of this when
|
|
647
|
-
it
|
|
648
|
-
|
|
649
|
-
`mda deploy` sets up the Linear app, which takes a Linear workspace admin
|
|
650
|
-
|
|
651
|
-
filled in with the app's name, redirect URI, webhook URL
|
|
652
|
-
(`<deployment-url>/channels/linear/events`) and events. The admin creates the
|
|
653
|
-
app and pastes its client ID, client secret and webhook signing secret into
|
|
654
|
-
deploy's prompts. Deploy asks for the workspace's URL key (as in
|
|
655
|
-
`https://linear.app/<key>/`) first, so the page opens in that workspace. Deploy
|
|
656
|
-
then opens the install page, where the admin approves the app for the
|
|
657
|
-
workspace. Agent Auth keeps the credentials, and the agent's token, so nothing
|
|
658
|
-
goes into `.env`. Without a terminal, for example when a coding agent deploys,
|
|
659
|
-
set `MDA_LINEAR_CLIENT_ID`, `MDA_LINEAR_CLIENT_SECRET` and
|
|
660
|
-
`MDA_LINEAR_WEBHOOK_SECRET` instead, and `MDA_LINEAR_WORKSPACE` to the
|
|
661
|
-
workspace's URL key so the links deploy prints open in that workspace; deploy
|
|
662
|
-
prints the install link. These four are read by the CLI only and never
|
|
663
|
-
uploaded to the deployment. If Linear later stops renewing the app's access,
|
|
664
|
-
the next deploy keeps the app and only asks an admin to approve it again.
|
|
665
|
-
Linear has no API to change an app's webhook URL either, so if the deployment
|
|
666
|
-
moves, update it on the app's page. `mda delete` removes the credentials;
|
|
667
|
-
delete the app itself in Linear.
|
|
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).
|
|
668
1017
|
|
|
669
1018
|
The channel reads the webhook signing secret from Agent Auth, or from
|
|
670
1019
|
`LINEAR_WEBHOOK_SECRET` when set. It acts as the app through the agent OAuth
|
|
671
1020
|
connection `mda/linear-app/<deployment-id>`, installed with `actor=app`; read
|
|
672
1021
|
its token with `await connections.get("mda/linear-token", { type: "agent" })` to call Linear's API from tools.
|
|
673
1022
|
|
|
1023
|
+
`reply: "none"` leaves the run's answer to the agent: the channel doesn't post
|
|
1024
|
+
it as a comment or in the session. Session acknowledgements, Stop and error
|
|
1025
|
+
notices still post.
|
|
1026
|
+
|
|
674
1027
|
[`examples/linear`](../../examples/linear) triages issues in agent sessions,
|
|
675
1028
|
shows its steps and plan there, and waits for approval in LangSmith Studio
|
|
676
1029
|
before moving an issue to another state.
|
|
677
1030
|
|
|
1031
|
+
### Setting up the Linear app
|
|
1032
|
+
|
|
1033
|
+
The first `mda deploy` of a Linear channel asks which Linear app it uses, as
|
|
1034
|
+
the Slack and GitHub channels do. Setting it up takes a Linear workspace admin:
|
|
1035
|
+
|
|
1036
|
+
- **Create a new Linear app**: Linear has no public API to create apps, so
|
|
1037
|
+
deploy asks for the workspace's URL key (as in `https://linear.app/<key>/`)
|
|
1038
|
+
and opens Linear's new-app page in that workspace, filled in with the app's
|
|
1039
|
+
name, redirect URI, webhook URL (`<deployment-url>/channels/linear/events`)
|
|
1040
|
+
and events. The admin creates the app and pastes its client ID, client
|
|
1041
|
+
secret and webhook signing secret into deploy's prompts.
|
|
1042
|
+
- **Use an existing Linear app**: deploy lists the redirect URI, webhook URL
|
|
1043
|
+
and events to set on the app's settings page, then asks for the same three
|
|
1044
|
+
values. Linear sends an app's webhooks to one URL, so whatever received them
|
|
1045
|
+
before stops receiving them.
|
|
1046
|
+
|
|
1047
|
+
Deploy then opens the install page, where the admin approves the app for the
|
|
1048
|
+
workspace. Agent Auth keeps the credentials and the agent's token, so nothing
|
|
1049
|
+
goes into `.env`, and later deploys keep the app without asking. If Linear
|
|
1050
|
+
stops renewing the app's access, the next deploy keeps the app and only asks
|
|
1051
|
+
an admin to approve it again. Linear has no API to change an app, so when the
|
|
1052
|
+
channel's `app` settings change or the deployment moves to another URL, update
|
|
1053
|
+
the app on its settings page.
|
|
1054
|
+
|
|
1055
|
+
To skip the questions, with or without a terminal, set
|
|
1056
|
+
`MDA_LINEAR_CLIENT_ID`, `MDA_LINEAR_CLIENT_SECRET` and
|
|
1057
|
+
`MDA_LINEAR_WEBHOOK_SECRET` in the shell or `.env`, and `MDA_LINEAR_WORKSPACE`
|
|
1058
|
+
to the workspace's URL key so the links deploy prints open in that workspace.
|
|
1059
|
+
`MDA_LINEAR_WEBHOOK_SECRET` alone supplies the signing secret of an installed
|
|
1060
|
+
app whose secret Agent Auth doesn't have yet. Deploy checks them before
|
|
1061
|
+
uploading, and asks Linear whether the client ID and secret belong together.
|
|
1062
|
+
Only the CLI reads them: they are never uploaded to the deployment, and you can
|
|
1063
|
+
remove them once the channel is set up. Without a terminal and without them,
|
|
1064
|
+
deploy stops before uploading with the link to create the app.
|
|
1065
|
+
|
|
1066
|
+
An app from these variables wasn't made from deploy's filled-in page, and
|
|
1067
|
+
Linear has no API that says what it has set. So before the install link,
|
|
1068
|
+
deploy lists the redirect URI, webhook URL and events the app needs, the same
|
|
1069
|
+
as for an existing app. In a terminal it waits until you say they're set;
|
|
1070
|
+
without one it prints them before the install link for an admin to open.
|
|
1071
|
+
Without the redirect URI, Linear answers the install with "Invalid
|
|
1072
|
+
redirect_uri".
|
|
1073
|
+
|
|
1074
|
+
If a setup step fails once the deployment is live, deploy offers to try again
|
|
1075
|
+
or to continue without the Linear channel. Without a terminal the failure ends
|
|
1076
|
+
the deploy, once the other channels are set up. An agent with a Linear channel
|
|
1077
|
+
can't be deployed with `--no-wait`, because setup needs the live deployment.
|
|
1078
|
+
`mda delete` removes the credentials; delete the app itself in Linear.
|
|
1079
|
+
|
|
678
1080
|
## HTTP channels
|
|
679
1081
|
|
|
680
1082
|
Use `channels.http({ provider, verify, parse, post })` for a provider webhook.
|
|
@@ -687,21 +1089,22 @@ A message returned by `parse` contains `userId`, `threadId`, `content`, and `tar
|
|
|
687
1089
|
`threadId` is the stable LangGraph thread UUID. `target` is separate JSON that the
|
|
688
1090
|
adapter needs to reply, such as a Photon conversation ID or a Slack channel and
|
|
689
1091
|
thread timestamp. MDA keeps this target private and binds it to
|
|
690
|
-
`runtime.channel.post`. The adapter's `post` callback receives the target for
|
|
1092
|
+
`runtime.thread.origin.channel.post`. The adapter's `post` callback receives the target for
|
|
691
1093
|
reply routing.
|
|
692
1094
|
|
|
693
1095
|
`verify` runs first with the original bytes and headers. `verify` and `parse`
|
|
694
1096
|
each get a separately readable request body. `parse` owns body decoding and can
|
|
695
1097
|
read JSON, form data, text, or bytes. It returns the existing `message` or `ignore`
|
|
696
|
-
result. MDA creates `runtime.channel.event` from the parsed message.
|
|
1098
|
+
result. MDA creates `runtime.thread.origin.channel.event` from the parsed message.
|
|
697
1099
|
|
|
698
1100
|
To expose provider data, return
|
|
699
1101
|
`{ type: "message", message, rawEvent: event }` from `parse`. MDA validates this
|
|
700
|
-
value as finite, acyclic JSON and copies it into
|
|
1102
|
+
value as finite, acyclic JSON and copies it into
|
|
1103
|
+
`runtime.thread.origin.channel.rawEvent`, in the run that message starts.
|
|
701
1104
|
If you omit `rawEvent`, it stays absent. MDA does not decode the body again.
|
|
702
1105
|
An explicit `null` is a valid event value.
|
|
703
1106
|
|
|
704
|
-
HTTP and Slack Trigger runs expose delivery through `runtime.channel`.
|
|
1107
|
+
HTTP and Slack Trigger runs expose delivery through `runtime.thread.origin.channel`.
|
|
705
1108
|
|
|
706
1109
|
The optional method has this signature:
|
|
707
1110
|
|
|
@@ -726,9 +1129,11 @@ credentials when it calls the provider API. Native routing or authentication
|
|
|
726
1129
|
fields must not replace them.
|
|
727
1130
|
|
|
728
1131
|
Automatic agent replies use the `content` form. An explicit
|
|
729
|
-
`runtime.channel.post({ type: "native", native: ... })` reaches your adapter
|
|
1132
|
+
`runtime.thread.origin.channel.post({ type: "native", native: ... })` reaches your adapter
|
|
730
1133
|
without conversion. Automatic replies run after the request is accepted. A failed
|
|
731
|
-
`post` is recorded as a delivery error.
|
|
1134
|
+
`post` is recorded as a delivery error. `reply: "none"` turns automatic
|
|
1135
|
+
replies off, so the agent replies itself; `post` still serves
|
|
1136
|
+
`runtime.channel.post` and error notices.
|
|
732
1137
|
If `post` is omitted, the channel can receive events and exposes facts, but
|
|
733
1138
|
has no runtime `post` method. The webhook path is `/channels/<name>/events`, where
|
|
734
1139
|
`<name>` is the channel file name. An existing Photon webhook needs no URL change
|
|
@@ -805,7 +1210,9 @@ a handler's result. `null` or HTTP 204 starts nothing. A GitHub event also
|
|
|
805
1210
|
carries what a handler gets beside the payload: its `action`, `repository`,
|
|
806
1211
|
`sender` and `mentions`, so a service checks them as a handler does. These are
|
|
807
1212
|
optional in `GitHubEndpointRequest`, so a receiver takes requests from older
|
|
808
|
-
deployments.
|
|
1213
|
+
deployments. A Slack message carries its `text`, `userId`, `channelId`,
|
|
1214
|
+
`messageTs`, `threadTs` and `files` the same way, with Slack's own event as
|
|
1215
|
+
`payload`.
|
|
809
1216
|
|
|
810
1217
|
```ts
|
|
811
1218
|
const backend = new Request(`${process.env.BACKEND_URL}/linear/runs`, {
|
|
@@ -822,8 +1229,8 @@ export const channel = channels.linear({
|
|
|
822
1229
|
});
|
|
823
1230
|
```
|
|
824
1231
|
|
|
825
|
-
GitHub or
|
|
826
|
-
background, so a slow service doesn't time out the delivery. A network error
|
|
1232
|
+
GitHub, Linear or Trigger Server gets its answer first, and MDA asks the
|
|
1233
|
+
service in the background, so a slow service doesn't time out the delivery. A network error
|
|
827
1234
|
before the answer, HTTP 429 or a 5xx is tried again, up to three attempts with
|
|
828
1235
|
the same `webhook-id`. Another error status, a redirect, an answer cut off or
|
|
829
1236
|
that isn't one of these, more than 10 MB, or no answer within 60 seconds fails the handler, as a
|
|
@@ -855,8 +1262,9 @@ const event = new Webhook(process.env.ENDPOINT_SECRET!).verify(
|
|
|
855
1262
|
);
|
|
856
1263
|
```
|
|
857
1264
|
|
|
858
|
-
On the service's side, `LinearEndpointRequest<K
|
|
859
|
-
`GitHubEndpointRequest<K>` type what the channel
|
|
1265
|
+
On the service's side, `LinearEndpointRequest<K>`,
|
|
1266
|
+
`GitHubEndpointRequest<K>` and `SlackEndpointRequest<K>` type what the channel
|
|
1267
|
+
sends, `{ event: { key,
|
|
860
1268
|
deliveryId, payload }, thread }`, with the payload typed by the event key, and
|
|
861
1269
|
`EndpointAnswer` types an answer, all JSON; answer `null` to start nothing. The
|
|
862
1270
|
request types are types only: validate the body as your service validates
|
|
@@ -987,8 +1395,31 @@ await runtime.schedules!.create({
|
|
|
987
1395
|
```
|
|
988
1396
|
|
|
989
1397
|
Set `newThread` to choose whether a run starts a new thread or continues the
|
|
990
|
-
current thread. When a schedule is created
|
|
991
|
-
each run posts its final answer to that channel.
|
|
1398
|
+
current thread. When a schedule is created on a channel's thread, such as a
|
|
1399
|
+
Slack thread, each run posts its final answer to that channel. A same-thread
|
|
1400
|
+
schedule posts wherever the thread's origin points when it runs, so its record
|
|
1401
|
+
has `channel: null` and `target: null`. A new-thread schedule keeps the
|
|
1402
|
+
conversation it was created in. Runtime schedules stay when you deploy again.
|
|
1403
|
+
|
|
1404
|
+
A user schedule can run as another person on the thread. Pass one of
|
|
1405
|
+
`runtime.thread.participants` as `runAs`; the caller still owns the schedule
|
|
1406
|
+
and is the one who can list, update, and delete it. Runs act as that person,
|
|
1407
|
+
with their connections.
|
|
1408
|
+
|
|
1409
|
+
```ts
|
|
1410
|
+
const me = runtime.serverInfo?.principal?.id;
|
|
1411
|
+
const bob = runtime.thread!.participants.find(({ id }) => id !== me);
|
|
1412
|
+
await runtime.schedules!.create({
|
|
1413
|
+
owner: { type: "user" },
|
|
1414
|
+
cron: "0 9 * * 1",
|
|
1415
|
+
prompt: "Remind Bob about the weekly report.",
|
|
1416
|
+
newThread: false,
|
|
1417
|
+
runAs: bob,
|
|
1418
|
+
});
|
|
1419
|
+
```
|
|
1420
|
+
|
|
1421
|
+
`runAs` needs `owner: { type: "user" }` and a participant with the same id and
|
|
1422
|
+
role; anything else is an error. The schedule's record shows it as `runAs`.
|
|
992
1423
|
|
|
993
1424
|
Each owner can have at most 20 runtime schedules per agent, paused ones
|
|
994
1425
|
included. Set `MDA_MAX_AGENT_SCHEDULES` or `MDA_MAX_USER_SCHEDULES` in the
|
|
@@ -1068,9 +1499,6 @@ server. In `mda dev`, an agent-owned connection reads from
|
|
|
1068
1499
|
slashes to double underscores (`mda/github-token` → `MDA_DEV_MDA__GITHUB_TOKEN`).
|
|
1069
1500
|
Hosted deployments resolve workspace connections from Agent Auth:
|
|
1070
1501
|
|
|
1071
|
-
The old `connectors/mcp.ts` file API remains available with a warning during
|
|
1072
|
-
`0.7.x`. It will be removed in `0.8.0`.
|
|
1073
|
-
|
|
1074
1502
|
```ts
|
|
1075
1503
|
import { defineMcp, connections } from "managed-deepagents";
|
|
1076
1504
|
|