@trigger.dev/sdk 4.8.0-webhooks.20261020092920 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/v3/ai.d.ts +2 -1
- package/dist/commonjs/v3/ai.js +18 -1
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/webhooks.d.ts +11 -3
- package/dist/commonjs/v3/webhooks.js +17 -1
- package/dist/commonjs/v3/webhooks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +2 -1
- package/dist/esm/v3/ai.js +18 -1
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/webhooks.d.ts +11 -3
- package/dist/esm/v3/webhooks.js +17 -1
- package/dist/esm/v3/webhooks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai/prompts.mdx +9 -6
- package/docs/ai-chat/backend.mdx +10 -7
- package/docs/ai-chat/chat-local.mdx +4 -4
- package/docs/ai-chat/client-protocol.mdx +6 -3
- package/docs/ai-chat/fast-starts.mdx +1 -1
- package/docs/ai-chat/overview.mdx +4 -3
- package/docs/ai-chat/patterns/database-persistence.mdx +3 -3
- package/docs/ai-chat/patterns/native-compaction.mdx +6 -6
- package/docs/ai-chat/patterns/redacting-telemetry.mdx +5 -5
- package/docs/ai-chat/patterns/sub-agents.mdx +1 -1
- package/docs/ai-chat/patterns/version-upgrades.mdx +3 -3
- package/docs/ai-chat/pending-messages.mdx +1 -1
- package/docs/ai-chat/reference.mdx +4 -4
- package/docs/ai-chat/side-channels.mdx +2 -2
- package/docs/ai-chat/types.mdx +5 -5
- package/docs/apikeys.mdx +1 -1
- package/docs/database-connections.mdx +2 -2
- package/docs/deploy-environment-variables.mdx +19 -0
- package/docs/introduction.mdx +104 -24
- package/docs/mcp-tools.mdx +5 -4
- package/docs/self-hosting/env/supervisor.mdx +1 -0
- package/docs/self-hosting/env/webapp.mdx +24 -0
- package/docs/self-hosting/overview.mdx +2 -0
- package/docs/webhooks/channels.mdx +29 -7
- package/docs/webhooks/connect.mdx +14 -7
- package/docs/webhooks/deliveries.mdx +8 -5
- package/docs/webhooks/filters.mdx +8 -4
- package/docs/webhooks/human-in-the-loop.mdx +9 -6
- package/docs/webhooks/linear.mdx +2 -5
- package/docs/webhooks/overview.mdx +16 -4
- package/docs/webhooks/session-routing.mdx +8 -5
- package/docs/webhooks/slack.mdx +44 -19
- package/docs/webhooks/sources.mdx +36 -7
- package/docs/webhooks/waiters.mdx +0 -4
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { Webhook } from "@trigger.dev/core/v3";
|
|
|
2
2
|
import type { WebhookSource, InferWebhookEvent, AnyWebhookSource, ValidateWebhookFilter, NarrowWebhookEvent, ChatEvent, ValidatedWebhookKey, WebhookResponseConfig, WebhookUrlSecretConfig, WebhookVerifierConfig, StripeWebhookEvent, GitHubWebhookEvent, TaskRunContext, AnyWebhookEndpoint, InferWebhookEndpointEvent, WebhookEndpoint, WebhookEndpointContext, TaskOptions } from "@trigger.dev/core/v3";
|
|
3
3
|
import { cancelWebhookWaiter, createWebhookWaiter, waitForWebhookWaiter } from "./webhookWaiters.js";
|
|
4
4
|
import { type Task } from "./shared.js";
|
|
5
|
-
import { type WebhookProviderId } from "@trigger.dev/core/webhooks";
|
|
5
|
+
import { type HookdeckSourceOptions, type WebhookProviderId } from "@trigger.dev/core/webhooks";
|
|
6
6
|
/**
|
|
7
7
|
* The type of error thrown when a webhook fails to parse or verify
|
|
8
8
|
*/
|
|
@@ -74,6 +74,13 @@ export declare const webhookSources: {
|
|
|
74
74
|
* the endpoint's Connect panel, which you paste into Meta's Verify Token field.
|
|
75
75
|
*/
|
|
76
76
|
readonly whatsapp: <T = unknown>() => WebhookSource<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Hookdeck relays deliveries from another provider, so `T` is the original provider's event. It
|
|
79
|
+
* verifies `x-hookdeck-signature` (and `x-hookdeck-signature-2` while a secret is being rolled)
|
|
80
|
+
* with the Hookdeck project's signing secret, and dedupes retries on `x-hookdeck-eventid`. Pass
|
|
81
|
+
* `headerPrefix` when the project's header prefix was changed from `x-hookdeck`.
|
|
82
|
+
*/
|
|
83
|
+
readonly hookdeck: <T = unknown>(options?: HookdeckSourceOptions) => WebhookSource<T>;
|
|
77
84
|
};
|
|
78
85
|
type CamelCase<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S;
|
|
79
86
|
/**
|
|
@@ -85,7 +92,7 @@ type CamelCase<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${
|
|
|
85
92
|
export type ProviderProducers = {
|
|
86
93
|
[K in Exclude<WebhookProviderId, "zoom"> as CamelCase<K>]: <TEvent = unknown>() => WebhookSource<TEvent>;
|
|
87
94
|
};
|
|
88
|
-
export declare const providerProducers: Omit<ProviderProducers, "slack">;
|
|
95
|
+
export declare const providerProducers: Omit<ProviderProducers, "slack" | "hookdeck">;
|
|
89
96
|
export type WebhookEndpointOptions<TIdentifier extends string, TSource extends AnyWebhookSource> = {
|
|
90
97
|
/** The endpoint id. Subscribers reference the endpoint, and it names the endpoint's URL. */
|
|
91
98
|
id: TIdentifier;
|
|
@@ -212,6 +219,7 @@ interface Webhooks {
|
|
|
212
219
|
composio: typeof webhookSources.composio;
|
|
213
220
|
gitlab: typeof webhookSources.gitlab;
|
|
214
221
|
whatsapp: typeof webhookSources.whatsapp;
|
|
222
|
+
hookdeck: typeof webhookSources.hookdeck;
|
|
215
223
|
/** Declare the URLs providers deliver to. */
|
|
216
224
|
endpoint: {
|
|
217
225
|
define: typeof defineWebhookEndpoint;
|
|
@@ -226,4 +234,4 @@ interface Webhooks {
|
|
|
226
234
|
/**
|
|
227
235
|
* Webhook utilities for handling incoming webhook requests
|
|
228
236
|
*/
|
|
229
|
-
export declare const webhooks: Webhooks & Omit<ProviderProducers, "slack">;
|
|
237
|
+
export declare const webhooks: Webhooks & Omit<ProviderProducers, "slack" | "hookdeck">;
|
package/dist/esm/v3/webhooks.js
CHANGED
|
@@ -205,13 +205,28 @@ export const webhookSources = {
|
|
|
205
205
|
secretProvisioning: "provider",
|
|
206
206
|
};
|
|
207
207
|
},
|
|
208
|
+
/**
|
|
209
|
+
* Hookdeck relays deliveries from another provider, so `T` is the original provider's event. It
|
|
210
|
+
* verifies `x-hookdeck-signature` (and `x-hookdeck-signature-2` while a secret is being rolled)
|
|
211
|
+
* with the Hookdeck project's signing secret, and dedupes retries on `x-hookdeck-eventid`. Pass
|
|
212
|
+
* `headerPrefix` when the project's header prefix was changed from `x-hookdeck`.
|
|
213
|
+
*/
|
|
214
|
+
hookdeck(options) {
|
|
215
|
+
const setupPrompt = webhookSetupPrompts.hookdeck;
|
|
216
|
+
return {
|
|
217
|
+
provider: "hookdeck",
|
|
218
|
+
verifier: { kind: "config", config: webhookProviderConfigs.hookdeck.config(options) },
|
|
219
|
+
secretProvisioning: webhookProviderConfigs.hookdeck.secretProvisioning,
|
|
220
|
+
...(setupPrompt ? { setupPrompt } : {}),
|
|
221
|
+
};
|
|
222
|
+
},
|
|
208
223
|
};
|
|
209
224
|
function producerName(provider) {
|
|
210
225
|
return provider.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
211
226
|
}
|
|
212
227
|
export const providerProducers = Object.fromEntries(Object.entries(webhookProviderConfigs)
|
|
213
228
|
// Zoom needs a computed URL-validation response that the hosted ingress does not support yet.
|
|
214
|
-
.filter(([provider]) => provider !== "slack" && provider !== "zoom")
|
|
229
|
+
.filter(([provider]) => provider !== "slack" && provider !== "zoom" && provider !== "hookdeck")
|
|
215
230
|
.map(([provider, entry]) => [
|
|
216
231
|
producerName(provider),
|
|
217
232
|
() => {
|
|
@@ -333,6 +348,7 @@ export const webhooks = {
|
|
|
333
348
|
composio: webhookSources.composio,
|
|
334
349
|
gitlab: webhookSources.gitlab,
|
|
335
350
|
whatsapp: webhookSources.whatsapp,
|
|
351
|
+
hookdeck: webhookSources.hookdeck,
|
|
336
352
|
endpoint: { define: defineWebhookEndpoint },
|
|
337
353
|
waiter: { create: createWebhookWaiter, wait: waitForWebhookWaiter, cancel: cancelWebhookWaiter },
|
|
338
354
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/v3/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAqBhE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,8CAA8C;AAC9C,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAqB/D,wDAAwD;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,MAAM,CACJ,MAAmC,EACnC,OAQC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY,IAAK,MAAiC,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;YAC9F,MAAM,IAAI,KAAK,CACb,mJAAmJ,CACpJ,CAAC;QACJ,CAAC;QACD,8EAA8E;QAC9E,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,MAAM;gBACN,GAAG,CAAC,OAAO,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CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "4.8.
|
|
1
|
+
export const VERSION = "4.8.1";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/docs/ai/prompts.mdx
CHANGED
|
@@ -219,8 +219,9 @@ Prompts integrate with `chat.agent()` via `chat.prompt` — a run-scoped store f
|
|
|
219
219
|
```ts
|
|
220
220
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
221
221
|
import { prompts } from "@trigger.dev/sdk";
|
|
222
|
-
import {
|
|
222
|
+
import { createProviderRegistry, stepCountIs } from "ai";
|
|
223
223
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
224
|
+
import { z } from "zod";
|
|
224
225
|
|
|
225
226
|
const registry = createProviderRegistry({ anthropic });
|
|
226
227
|
|
|
@@ -234,13 +235,14 @@ const systemPrompt = prompts.define({
|
|
|
234
235
|
|
|
235
236
|
export const myChat = chat.agent({
|
|
236
237
|
id: "my-chat",
|
|
238
|
+
registry,
|
|
239
|
+
clientDataSchema: z.object({ name: z.string() }),
|
|
237
240
|
onChatStart: async ({ clientData }) => {
|
|
238
241
|
const resolved = await systemPrompt.resolve({ name: clientData.name });
|
|
239
242
|
chat.prompt.set(resolved);
|
|
240
243
|
},
|
|
241
|
-
run: async ({ messages, signal }) => {
|
|
244
|
+
run: async ({ messages, signal, streamText }) => {
|
|
242
245
|
return streamText({
|
|
243
|
-
...chat.toStreamTextOptions({ registry }),
|
|
244
246
|
messages,
|
|
245
247
|
abortSignal: signal,
|
|
246
248
|
stopWhen: stepCountIs(15),
|
|
@@ -249,9 +251,11 @@ export const myChat = chat.agent({
|
|
|
249
251
|
});
|
|
250
252
|
```
|
|
251
253
|
|
|
254
|
+
The `streamText` passed to `run()` applies the stored prompt: its system text, its model (resolved through the agent's `registry`), its `config`, and telemetry that links each generation to the prompt version. Options you pass at the call site win, apart from `system`, which throws when a prompt already sets one.
|
|
255
|
+
|
|
252
256
|
### chat.toStreamTextOptions()
|
|
253
257
|
|
|
254
|
-
|
|
258
|
+
Inside a `chat.agent` you don't need this: the `streamText` passed to `run()` applies the same options. Use `chat.toStreamTextOptions()` when you call `streamText` yourself, as in a [custom agent](/ai-chat/custom-agents). It returns an options object ready to spread into `streamText()`. When a prompt is stored via `chat.prompt.set()`, it includes:
|
|
255
259
|
|
|
256
260
|
- `system` — the compiled prompt text
|
|
257
261
|
- `model` — resolved via the `registry` when provided
|
|
@@ -277,14 +281,13 @@ const options = chat.toStreamTextOptions();
|
|
|
277
281
|
Access the stored prompt from anywhere in the run:
|
|
278
282
|
|
|
279
283
|
```ts
|
|
280
|
-
run: async ({ messages, signal }) => {
|
|
284
|
+
run: async ({ messages, signal, streamText }) => {
|
|
281
285
|
const prompt = chat.prompt(); // Throws if not set
|
|
282
286
|
console.log(prompt.text); // The compiled prompt
|
|
283
287
|
console.log(prompt.model); // "anthropic:claude-sonnet-4-5"
|
|
284
288
|
console.log(prompt.version); // 3
|
|
285
289
|
|
|
286
290
|
return streamText({
|
|
287
|
-
...chat.toStreamTextOptions({ registry }),
|
|
288
291
|
messages,
|
|
289
292
|
abortSignal: signal,
|
|
290
293
|
stopWhen: stepCountIs(15),
|
package/docs/ai-chat/backend.mdx
CHANGED
|
@@ -4,8 +4,6 @@ sidebarTitle: "Backend"
|
|
|
4
4
|
description: "Three approaches to building your chat backend — chat.agent(), session iterator, or raw task primitives."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
import WebhooksBetaNote from "/snippets/webhooks-beta-note.mdx";
|
|
8
|
-
|
|
9
7
|
There are three abstraction levels for a chat backend. All three speak the same wire protocol, so the [frontend transport](/ai-chat/frontend) works unchanged whichever you pick.
|
|
10
8
|
|
|
11
9
|
| Capability | `chat.agent()` | `chat.createSession()` | Raw primitives |
|
|
@@ -274,7 +272,7 @@ export const myChat = chat.agent({
|
|
|
274
272
|
});
|
|
275
273
|
```
|
|
276
274
|
|
|
277
|
-
The managed `streamText` carries the stored prompt's `system`, `model` (resolved through the agent's `registry`), sampling config, and `experimental_telemetry`. Options you pass at the call site win, apart from `system`, which throws when the prompt already set one.
|
|
275
|
+
The managed `streamText` carries the stored prompt's `system`, `model` (resolved through the agent's `registry`), sampling config, and `experimental_telemetry`. AI SDK telemetry is on even without a stored prompt, so model steps and tool calls show in the run trace. Options you pass at the call site win, apart from `system`, which throws when the prompt already set one.
|
|
278
276
|
|
|
279
277
|
`chat.toStreamTextOptions()` remains available for the same job, and is the only option in a [custom agent](#custom-agents), which has no `run` argument to take a bound `streamText` from. A `chat.headStart` route does get one, and there it also owns `messages`, `stopWhen` and `abortSignal`, since the handover depends on them. Pass `{ registry }` when a prompt names a provider-prefixed model, and `{ tools }` when you want HITL tool approvals, so the SDK knows which calls pause on `needsApproval`.
|
|
280
278
|
|
|
@@ -501,14 +499,12 @@ See [Actions](/ai-chat/actions).
|
|
|
501
499
|
|
|
502
500
|
### Webhook events and channels
|
|
503
501
|
|
|
504
|
-
<WebhooksBetaNote />
|
|
505
|
-
|
|
506
502
|
Two `chat.agent()` options wire an agent to verified inbound webhooks. `events` claims [`chat.event(...)`](/webhooks/session-routing) descriptors: each verified delivery is routed to this agent's session and arrives at `onAction` as an action (not a turn), so [session routing](/webhooks/session-routing) decides which conversation it lands on. `channels` claims channel connectors that turn an external chat surface into a frontend for the agent: an inbound message runs as a turn through `run()` and the reply is posted back. `slack()` ships in `@trigger.dev/slack`, and `chat.channels.custom(...)` builds a connector for any endpoint without a preset.
|
|
507
503
|
|
|
508
504
|
```ts
|
|
509
505
|
import { webhooks } from "@trigger.dev/sdk";
|
|
510
506
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
511
|
-
import { slack, webhookSource } from "@trigger.dev/slack";
|
|
507
|
+
import { appMentions, slack, webhookSource } from "@trigger.dev/slack";
|
|
512
508
|
|
|
513
509
|
const slackEvents = webhooks.endpoint.define({ id: "slack", source: webhookSource() });
|
|
514
510
|
const stripe = webhooks.endpoint.define({ id: "stripe", source: webhooks.stripe() });
|
|
@@ -525,7 +521,14 @@ export const orderEvents = chat.event({
|
|
|
525
521
|
export const myChat = chat.agent({
|
|
526
522
|
id: "my-chat",
|
|
527
523
|
events: [orderEvents],
|
|
528
|
-
channels: [
|
|
524
|
+
channels: [
|
|
525
|
+
slack({
|
|
526
|
+
id: "support-slack",
|
|
527
|
+
endpoint: slackEvents,
|
|
528
|
+
token: process.env.SLACK_BOT_TOKEN!,
|
|
529
|
+
startOn: appMentions(),
|
|
530
|
+
}),
|
|
531
|
+
],
|
|
529
532
|
onAction: async ({ action }) => {
|
|
530
533
|
// A verified order-events delivery arrives here as an action.
|
|
531
534
|
},
|
|
@@ -16,7 +16,7 @@ Declare locals at module level with a unique `id`, then initialize them inside a
|
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
19
|
-
import {
|
|
19
|
+
import { tool, stepCountIs } from "ai";
|
|
20
20
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
21
21
|
import { z } from "zod";
|
|
22
22
|
import { db } from "@/lib/db";
|
|
@@ -44,7 +44,7 @@ export const myChat = chat.agent({
|
|
|
44
44
|
messageCount: user.messageCount,
|
|
45
45
|
});
|
|
46
46
|
},
|
|
47
|
-
run: async ({ messages, signal }) => {
|
|
47
|
+
run: async ({ messages, signal, streamText }) => {
|
|
48
48
|
userContext.messageCount++;
|
|
49
49
|
|
|
50
50
|
return streamText({
|
|
@@ -88,7 +88,7 @@ When you use `ai.toolExecute()` inside AI SDK `tool()` to expose a subtask, chat
|
|
|
88
88
|
```ts
|
|
89
89
|
import { chat, ai } from "@trigger.dev/sdk/ai";
|
|
90
90
|
import { schemaTask } from "@trigger.dev/sdk";
|
|
91
|
-
import {
|
|
91
|
+
import { tool, stepCountIs } from "ai";
|
|
92
92
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
93
93
|
import { z } from "zod";
|
|
94
94
|
|
|
@@ -115,7 +115,7 @@ export const myChat = chat.agent({
|
|
|
115
115
|
onBoot: async ({ clientData }) => {
|
|
116
116
|
userContext.init({ name: "Alice", plan: "pro" });
|
|
117
117
|
},
|
|
118
|
-
run: async ({ messages, signal }) => {
|
|
118
|
+
run: async ({ messages, signal, streamText }) => {
|
|
119
119
|
return streamText({
|
|
120
120
|
model: anthropic("claude-sonnet-4-5"),
|
|
121
121
|
messages,
|
|
@@ -318,12 +318,13 @@ If nothing arrives by the deadline, the server sends `data: [DONE]` and closes.
|
|
|
318
318
|
|
|
319
319
|
### Stream format (S2)
|
|
320
320
|
|
|
321
|
-
The output stream uses [S2](https://s2.dev) under the hood and follows the standard SSE wire format ([WHATWG spec](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream)).
|
|
321
|
+
The output stream uses [S2](https://s2.dev) under the hood and follows the standard SSE wire format ([WHATWG spec](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream)). Four event types arrive on the wire:
|
|
322
322
|
|
|
323
323
|
| Event | Meaning |
|
|
324
324
|
| --- | --- |
|
|
325
325
|
| `batch` | One or more records. The records you actually care about. |
|
|
326
326
|
| `ping` | Keepalive (~every 5s on idle). Body is `{"timestamp": <ms>}`, and on backends that report it a `tail` (same `{seq_num, timestamp}` shape as a batch tail). The tail is what lets you tell you have caught up to the live edge; if you don't need caught-up detection, ignore the ping. |
|
|
327
|
+
| `error` | The read failed after the stream started, for example while the stream backend restarts. Body is a plain-text reason. The connection then closes **without** `[DONE]`. Treat it like a dropped connection and [resume](#resuming-a-stream) from the last `seq_num` you processed. |
|
|
327
328
|
| _(no `event:`, just `data: [DONE]`)_ | Stream is closing — server sends this once before EOF. |
|
|
328
329
|
|
|
329
330
|
A `batch` event in raw SSE format looks like this — note the `data` is a single line of JSON, no embedded newlines (per the SSE spec):
|
|
@@ -446,7 +447,7 @@ while (true) {
|
|
|
446
447
|
|
|
447
448
|
### Self-contained parser (for custom transports)
|
|
448
449
|
|
|
449
|
-
If you're building a transport in another language or don't want the dependency, here's a complete reader. It handles the SSE framing, the comma-separated `id:` line, batch unwrapping, the inner `body` string, and `ping` / `[DONE]` events:
|
|
450
|
+
If you're building a transport in another language or don't want the dependency, here's a complete reader. It handles the SSE framing, the comma-separated `id:` line, batch unwrapping, the inner `body` string, and `ping` / `error` / `[DONE]` events:
|
|
450
451
|
|
|
451
452
|
```ts
|
|
452
453
|
async function* readSessionOut(
|
|
@@ -489,6 +490,8 @@ async function* readSessionOut(
|
|
|
489
490
|
if (!data) continue;
|
|
490
491
|
|
|
491
492
|
if (eventType === "ping") continue;
|
|
493
|
+
// The read failed mid-stream. Reconnect from your last seq_num.
|
|
494
|
+
if (eventType === "error") throw new Error(`Stream read failed: ${data}`);
|
|
492
495
|
if (data === "[DONE]") return;
|
|
493
496
|
|
|
494
497
|
if (eventType === "batch") {
|
|
@@ -625,7 +628,7 @@ The built-in clients handle this transparently.
|
|
|
625
628
|
|
|
626
629
|
### Resuming a stream
|
|
627
630
|
|
|
628
|
-
If the SSE connection drops, reconnect with the `Last-Event-ID` header set to the **last `record.seq_num` you successfully processed** (decoded from the batch body
|
|
631
|
+
If the SSE connection drops, or the server sends an `error` event, reconnect with the `Last-Event-ID` header set to the **last `record.seq_num` you successfully processed** (decoded from the batch body, not the SSE `id:` line, which is a comma-list internal to S2):
|
|
629
632
|
|
|
630
633
|
```
|
|
631
634
|
GET /realtime/v1/sessions/{sessionId}/out
|
|
@@ -80,7 +80,7 @@ export const myChat = chat.agent({
|
|
|
80
80
|
if (preloaded) return; // Already initialized in onPreload
|
|
81
81
|
// ... fallback initialization for non-preloaded runs
|
|
82
82
|
},
|
|
83
|
-
run: async ({ messages, signal }) => {
|
|
83
|
+
run: async ({ messages, signal, streamText }) => {
|
|
84
84
|
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
85
85
|
},
|
|
86
86
|
});
|
|
@@ -12,12 +12,12 @@ A `chat.agent` task takes `messages`, calls `streamText`, and returns the result
|
|
|
12
12
|
|
|
13
13
|
```ts trigger/chat.ts
|
|
14
14
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
15
|
-
import {
|
|
15
|
+
import { stepCountIs } from "ai";
|
|
16
16
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
17
17
|
|
|
18
18
|
export const myChat = chat.agent({
|
|
19
19
|
id: "my-chat",
|
|
20
|
-
run: async ({ messages, signal }) =>
|
|
20
|
+
run: async ({ messages, signal, streamText }) =>
|
|
21
21
|
streamText({
|
|
22
22
|
model: anthropic("claude-sonnet-4-5"),
|
|
23
23
|
messages,
|
|
@@ -56,11 +56,12 @@ See [Quick Start](/ai-chat/quick-start) for the matching server actions and a ru
|
|
|
56
56
|
|
|
57
57
|
## How it fits together
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Four primitives, related but distinct:
|
|
60
60
|
|
|
61
61
|
- **Chat agents** — the SDK surface you define with [`chat.agent()`](/ai-chat/backend#chat-agent). Owns the turn loop, lifecycle hooks, and the response stream.
|
|
62
62
|
- **Sessions** — the durable, bi-directional channel keyed on `chatId` that holds the conversation across run boundaries. A chat agent runs *on top of* a [Session](/ai-chat/sessions).
|
|
63
63
|
- **Sub-agents** — Delegate work from one agent to another via [`AgentChat`](/ai-chat/patterns/sub-agents). The sub-agent runs as its own durable agent on its own session; its response streams back through the parent as preliminary tool results, so the frontend sees the sub-agent working inside the parent's tool card.
|
|
64
|
+
- **Channels** connect an agent to a surface other than your frontend. [`slack()`](/webhooks/slack) and [`linear()`](/webhooks/linear) turn an agent into a Slack or Linear agent, and [`chat.channels.custom()`](/webhooks/channels) connects any chat surface that sends webhooks. Each conversation there is still a durable session, and the reply posts back to the surface.
|
|
64
65
|
|
|
65
66
|
## Next steps
|
|
66
67
|
|
|
@@ -226,7 +226,7 @@ export const myChat = chat.agent({
|
|
|
226
226
|
}),
|
|
227
227
|
]);
|
|
228
228
|
},
|
|
229
|
-
run: async ({ messages, signal }) => {
|
|
229
|
+
run: async ({ messages, signal, streamText }) => {
|
|
230
230
|
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
231
231
|
},
|
|
232
232
|
});
|
|
@@ -254,7 +254,7 @@ End-to-end implementation across the three files involved: agent task, server ac
|
|
|
254
254
|
<CodeGroup>
|
|
255
255
|
```ts trigger/chat.ts
|
|
256
256
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
257
|
-
import {
|
|
257
|
+
import { stepCountIs } from "ai";
|
|
258
258
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
259
259
|
import { z } from "zod";
|
|
260
260
|
import { db } from "@/lib/db";
|
|
@@ -296,7 +296,7 @@ export const myChat = chat.agent({
|
|
|
296
296
|
}),
|
|
297
297
|
]);
|
|
298
298
|
},
|
|
299
|
-
run: async ({ messages, signal }) => {
|
|
299
|
+
run: async ({ messages, signal, streamText }) => {
|
|
300
300
|
return streamText({
|
|
301
301
|
model: anthropic("claude-sonnet-4-5"),
|
|
302
302
|
messages,
|
|
@@ -31,7 +31,7 @@ The fix: read the `appliedEdits` counts as they stream in `onStepFinish`, then a
|
|
|
31
31
|
|
|
32
32
|
```ts /trigger/native-persist.ts
|
|
33
33
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
34
|
-
import {
|
|
34
|
+
import { stepCountIs, tool, type UIMessage } from "ai";
|
|
35
35
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
36
36
|
import { z } from "zod";
|
|
37
37
|
|
|
@@ -75,7 +75,7 @@ export const nativePersist = chat.agent({
|
|
|
75
75
|
id: "native-persist",
|
|
76
76
|
idleTimeoutInSeconds: 120,
|
|
77
77
|
tools: { fetchRecord },
|
|
78
|
-
run: async ({ messages, chatId, tools, signal }) => {
|
|
78
|
+
run: async ({ messages, chatId, tools, signal, streamText }) => {
|
|
79
79
|
return streamText({
|
|
80
80
|
model: anthropic("claude-sonnet-4-5"),
|
|
81
81
|
messages,
|
|
@@ -132,7 +132,7 @@ OpenAI's `store: true` keeps the thread server-side and returns a `responseId`.
|
|
|
132
132
|
|
|
133
133
|
```ts /trigger/openai-store.ts
|
|
134
134
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
135
|
-
import {
|
|
135
|
+
import { stepCountIs, type ModelMessage } from "ai";
|
|
136
136
|
import { openai } from "@ai-sdk/openai";
|
|
137
137
|
|
|
138
138
|
// Persist the stored-response handle between turns. Replace with your database.
|
|
@@ -151,7 +151,7 @@ function messagesSinceLastAssistant(messages: ModelMessage[]): ModelMessage[] {
|
|
|
151
151
|
export const openaiStore = chat.agent({
|
|
152
152
|
id: "openai-store",
|
|
153
153
|
idleTimeoutInSeconds: 120,
|
|
154
|
-
run: async ({ messages, chatId, signal }) => {
|
|
154
|
+
run: async ({ messages, chatId, signal, streamText }) => {
|
|
155
155
|
const native = nativeStore.get(chatId);
|
|
156
156
|
const outbound = native ? messagesSinceLastAssistant(messages) : messages;
|
|
157
157
|
|
|
@@ -186,7 +186,7 @@ A native handle is a per-provider cache. An OpenAI `previousResponseId` means no
|
|
|
186
186
|
|
|
187
187
|
```ts /trigger/resilient-chat.ts
|
|
188
188
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
189
|
-
import {
|
|
189
|
+
import { generateText, stepCountIs, generateId, type ModelMessage } from "ai";
|
|
190
190
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
191
191
|
import { openai } from "@ai-sdk/openai";
|
|
192
192
|
|
|
@@ -241,7 +241,7 @@ export const resilientChat = chat.agent({
|
|
|
241
241
|
if (chatId) nativeStore.delete(chatId);
|
|
242
242
|
},
|
|
243
243
|
|
|
244
|
-
run: async ({ messages, chatId, signal }) => {
|
|
244
|
+
run: async ({ messages, chatId, signal, streamText }) => {
|
|
245
245
|
let lastError: unknown;
|
|
246
246
|
for (const providerId of FALLBACK_ORDER) {
|
|
247
247
|
const native = nativeStore.get(chatId);
|
|
@@ -4,7 +4,7 @@ sidebarTitle: "Redact chat content"
|
|
|
4
4
|
description: "Stop a chat agent recording user messages and clientData on its spans, turn off AI SDK prompt and response recording, or redact span content with a span processor before it leaves the worker."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
A chat agent's run trace records conversation content by default: the user's message
|
|
7
|
+
A chat agent's run trace records conversation content by default: the user's message, the `clientData` your frontend sends, and, through AI SDK telemetry, the prompts and responses of each model call. This page covers the three controls that change that, and what they don't cover.
|
|
8
8
|
|
|
9
9
|
## What the run trace records
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ A chat agent's run trace records conversation content by default: the user's mes
|
|
|
13
13
|
| `chat turn N` | The last user message (`chat.user_message`) and its first 80 characters as the span preview | `telemetry.recordUserMessage` |
|
|
14
14
|
| `chat turn N` | The raw `clientData` (`chat.client_data`) | `telemetry.recordClientData` |
|
|
15
15
|
| `pending message injected` | Messages sent mid-turn (`pending.messages`) | `telemetry.recordUserMessage` |
|
|
16
|
-
| AI SDK model call spans
|
|
16
|
+
| AI SDK model call spans (on by default with the `streamText` from `run`) | Prompt messages, response text, tool calls | `telemetry.recordUserMessage` for the default config, or `experimental_telemetry` on the model call |
|
|
17
17
|
| Any span | Everything above, plus your own attributes and span events | A span processor |
|
|
18
18
|
|
|
19
19
|
## Stop recording chat content
|
|
@@ -32,11 +32,11 @@ export const supportAgent = chat.agent({
|
|
|
32
32
|
});
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The spans still appear in the trace with their timings and token usage. The turn spans have no preview text.
|
|
35
|
+
The spans still appear in the trace with their timings and token usage. The turn spans have no preview text. `recordUserMessage: false` also keeps prompts and responses out of the AI SDK spans that the `streamText` passed to `run()` turns on, with or without a prompt stored by `chat.prompt.set()`, and leaves a stored prompt's variables out of the span metadata, unless the call passes its own `experimental_telemetry`.
|
|
36
36
|
|
|
37
37
|
## Stop the AI SDK recording prompts and responses
|
|
38
38
|
|
|
39
|
-
AI SDK model call
|
|
39
|
+
The `streamText` passed to `run()` turns AI SDK telemetry on, so each model call and tool call is a span in the run trace (pass `experimental_telemetry: { isEnabled: false }` to turn the spans off). If you call `streamText` from `ai` yourself, pass `experimental_telemetry` to get them. Those spans include prompts and responses unless you turn that off with `recordInputs` and `recordOutputs`:
|
|
40
40
|
|
|
41
41
|
```ts /trigger/support-agent.ts
|
|
42
42
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
@@ -50,7 +50,7 @@ export const supportAgent = chat.agent({
|
|
|
50
50
|
model: anthropic("claude-sonnet-4-5"),
|
|
51
51
|
messages,
|
|
52
52
|
abortSignal: signal,
|
|
53
|
-
// Replaces
|
|
53
|
+
// Replaces the default telemetry config (and chat.prompt.set()'s), so keep isEnabled on
|
|
54
54
|
experimental_telemetry: { isEnabled: true, recordInputs: false, recordOutputs: false },
|
|
55
55
|
}),
|
|
56
56
|
});
|
|
@@ -275,7 +275,7 @@ const tools = { research: researchTool };
|
|
|
275
275
|
export const myAgent = chat.agent({
|
|
276
276
|
id: "orchestrator",
|
|
277
277
|
tools, // declare here so toModelOutput survives across turns
|
|
278
|
-
run: async ({ messages, tools, stopSignal }) => {
|
|
278
|
+
run: async ({ messages, tools, stopSignal, streamText }) => {
|
|
279
279
|
return streamText({
|
|
280
280
|
model: anthropic("claude-sonnet-4-6"),
|
|
281
281
|
messages,
|
|
@@ -100,7 +100,7 @@ On the agent side, declare which versions the current code supports:
|
|
|
100
100
|
|
|
101
101
|
```ts
|
|
102
102
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
105
105
|
|
|
106
106
|
// The set of frontend protocol versions this agent code supports.
|
|
@@ -121,7 +121,7 @@ export const myChat = chat
|
|
|
121
121
|
chat.requestUpgrade();
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
-
run: async ({ messages, signal }) => {
|
|
124
|
+
run: async ({ messages, signal, streamText }) => {
|
|
125
125
|
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
126
126
|
},
|
|
127
127
|
});
|
|
@@ -183,7 +183,7 @@ export const myChat = chat
|
|
|
183
183
|
chat.requestUpgrade();
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
|
-
run: async ({ messages, signal }) => {
|
|
186
|
+
run: async ({ messages, signal, streamText }) => {
|
|
187
187
|
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
188
188
|
},
|
|
189
189
|
});
|
|
@@ -12,7 +12,7 @@ By default (without `pendingMessages`), a message sent while the agent is respon
|
|
|
12
12
|
|
|
13
13
|
The `pendingMessages` option enables steering instead, injecting user messages between tool-call steps via the AI SDK's `prepareStep`. Messages that arrive during streaming are queued and injected at the next step boundary. A message that is not injected becomes the next turn instead, whether that is because `shouldInject` returned `false` or because there were no more step boundaries (single-step response or final text generation). The backend handles that, so no client-side re-send is involved.
|
|
14
14
|
|
|
15
|
-
Messages from a [channel](/webhooks/channels) such as [Slack](/webhooks/slack) are offered the same way, with `metadata.source` set to `"channel"` so `shouldInject` can tell them apart. A channel's stop control and approval clicks are never offered. The connector acknowledges a channel message as soon as it arrives (Slack reacts with 👀, Linear posts a thought), before `shouldInject` decides, so the acknowledgement is the same whether the message is folded in or answered next.
|
|
15
|
+
Messages from a [channel](/webhooks/channels) such as [Slack](/webhooks/slack) are offered the same way, with `metadata.source` set to `"channel"` so `shouldInject` can tell them apart. A channel's stop control and approval clicks are never offered. The connector acknowledges a channel message as soon as it arrives (Slack reacts with 👀, Linear posts a thought), before `shouldInject` decides, so the acknowledgement is the same whether the message is folded in or answered next.
|
|
16
16
|
|
|
17
17
|
Use the `streamText` passed to your agent's `run` callback. It wires up pending-message injection automatically. If you import `streamText` directly from `ai`, spread `chat.toStreamTextOptions()` into its options to connect injection.
|
|
18
18
|
|
|
@@ -48,8 +48,8 @@ Options for `chat.agent()`.
|
|
|
48
48
|
| `hydrateMessages` | `(event: HydrateMessagesEvent) => UIMessage[] \| Promise<UIMessage[]>` | — | **Deprecated.** Load message history from backend, replacing the linear accumulator. Use `loadContext` on a `storage` instead; cannot be combined with `storage`. See [hydrateMessages](/ai-chat/lifecycle-hooks#hydratemessages) |
|
|
49
49
|
| `actionSchema` | `TaskSchema` | — | Schema for validating custom actions sent via `transport.sendAction()`. See [Actions](/ai-chat/actions) |
|
|
50
50
|
| `onAction` | `(event: ActionEvent) => Promise<void \| ActionTurn> \| void \| ActionTurn` | — | Handle custom actions. Actions are state edits: only `hydrateMessages` (or a storage's `loadContext`) + `onAction` fire. Return `chat.turn()` to run a turn on the edited history (`chat.turn(message)` to answer a new user message), or nothing for an edit only. See [Actions](/ai-chat/actions) |
|
|
51
|
-
| `events` | `ChatEvent[]` | — | Webhook event descriptors (from `chat.event()`) whose verified deliveries are routed to this agent as actions and handled in `onAction`. See [session routing](/webhooks/session-routing).
|
|
52
|
-
| `channels` | `ChannelConnector[]` | — | Channel connectors (for example `slack()`) that turn an external chat surface into a frontend for the agent: inbound messages run as turns and the reply posts back. See [channels](/webhooks/channels).
|
|
51
|
+
| `events` | `ChatEvent[]` | — | Webhook event descriptors (from `chat.event()`) whose verified deliveries are routed to this agent as actions and handled in `onAction`. See [session routing](/webhooks/session-routing). |
|
|
52
|
+
| `channels` | `ChannelConnector[]` | — | Channel connectors (for example `slack()`) that turn an external chat surface into a frontend for the agent: inbound messages run as turns and the reply posts back. See [channels](/webhooks/channels). |
|
|
53
53
|
| `onTurnStart` | `(event: TurnStartEvent) => Promise<void> \| void` | — | Fires every turn before `run()` |
|
|
54
54
|
| `onBeforeTurnComplete` | `(event: BeforeTurnCompleteEvent) => Promise<void> \| void` | — | Fires after response but before stream closes. Includes `writer`. |
|
|
55
55
|
| `onTurnComplete` | `(event: TurnCompleteEvent) => Promise<void> \| void` | — | Fires after each turn completes (stream closed) |
|
|
@@ -542,8 +542,8 @@ All methods available on the `chat` object from `@trigger.dev/sdk/ai`.
|
|
|
542
542
|
| Method | Description |
|
|
543
543
|
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
544
544
|
| `chat.agent(options)` | Create a chat agent |
|
|
545
|
-
| `chat.event(options)` | Declare an inbound webhook event descriptor an agent claims via `chat.agent({ events })`. See [session routing](/webhooks/session-routing).
|
|
546
|
-
| `chat.channels.custom(options)` | Create a generic chat-frontend channel over any verified webhook source (you supply the egress). The `slack()` preset ships in `@trigger.dev/slack`. See [channels](/webhooks/channels).
|
|
545
|
+
| `chat.event(options)` | Declare an inbound webhook event descriptor an agent claims via `chat.agent({ events })`. See [session routing](/webhooks/session-routing). |
|
|
546
|
+
| `chat.channels.custom(options)` | Create a generic chat-frontend channel over any verified webhook source (you supply the egress). The `slack()` preset ships in `@trigger.dev/slack`. See [channels](/webhooks/channels). |
|
|
547
547
|
| `chat.createSession(payload, options)` | Create an async iterator for chat turns |
|
|
548
548
|
| `chat.pipe(source, options?)` | Pipe a stream to the frontend (from anywhere inside a task) |
|
|
549
549
|
| `chat.pipeAndCapture(source, options?)` | Pipe and capture the response; returns `{ message, status, error }` |
|
|
@@ -38,12 +38,12 @@ Inside a `chat.agent` run, `chat.channel(...)` opens a channel on the current ru
|
|
|
38
38
|
|
|
39
39
|
```ts /trigger/browser-agent.ts
|
|
40
40
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
import { screenshots } from "./channels";
|
|
43
43
|
|
|
44
44
|
export const browserAgent = chat.agent({
|
|
45
45
|
id: "browser-agent",
|
|
46
|
-
run: async ({ messages, signal }) => {
|
|
46
|
+
run: async ({ messages, signal, streamText }) => {
|
|
47
47
|
const frames = chat.channel(screenshots);
|
|
48
48
|
|
|
49
49
|
frames.in.on((control) => setPaused(control.paused)); // control: ViewportControl
|
package/docs/ai-chat/types.mdx
CHANGED
|
@@ -56,7 +56,7 @@ Call `withUIMessage` **once**, then chain `.agent({ ... })` instead of `chat.age
|
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
58
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
59
|
-
import {
|
|
59
|
+
import { tool } from "ai";
|
|
60
60
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
61
61
|
import { z } from "zod";
|
|
62
62
|
import type { MyChatUIMessage } from "./my-chat-types";
|
|
@@ -90,7 +90,7 @@ export const myChat = chat
|
|
|
90
90
|
data: { status: "preparing" },
|
|
91
91
|
});
|
|
92
92
|
},
|
|
93
|
-
run: async ({ messages, tools, signal }) => {
|
|
93
|
+
run: async ({ messages, tools, signal, streamText }) => {
|
|
94
94
|
// `tools` is myTools, typed, handed back on the payload
|
|
95
95
|
return streamText({
|
|
96
96
|
model: anthropic("claude-sonnet-4-5"),
|
|
@@ -156,7 +156,7 @@ export const myChat = chat
|
|
|
156
156
|
// clientData is typed as { userId: string; model?: string }
|
|
157
157
|
await initUser(clientData.userId);
|
|
158
158
|
},
|
|
159
|
-
run: async ({ messages, clientData, signal }) => {
|
|
159
|
+
run: async ({ messages, clientData, signal, streamText }) => {
|
|
160
160
|
return streamText({
|
|
161
161
|
model: getModel(clientData.model),
|
|
162
162
|
messages,
|
|
@@ -193,7 +193,7 @@ export const myChat = chat
|
|
|
193
193
|
})
|
|
194
194
|
.agent({
|
|
195
195
|
id: "my-chat",
|
|
196
|
-
run: async ({ messages, signal }) => {
|
|
196
|
+
run: async ({ messages, signal, streamText }) => {
|
|
197
197
|
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
198
198
|
},
|
|
199
199
|
});
|
|
@@ -218,7 +218,7 @@ chat
|
|
|
218
218
|
// Runs second — task-specific logic
|
|
219
219
|
await createChatRecord(event.chatId);
|
|
220
220
|
},
|
|
221
|
-
run: async ({ messages, signal }) => {
|
|
221
|
+
run: async ({ messages, signal, streamText }) => {
|
|
222
222
|
return streamText({ model: anthropic("claude-sonnet-4-5"), messages, abortSignal: signal });
|
|
223
223
|
},
|
|
224
224
|
});
|