@trigger.dev/sdk 4.7.4 → 4.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/commonjs/v3/ai.d.ts +26 -0
  2. package/dist/commonjs/v3/ai.js +7 -5
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/query.d.ts +434 -1
  5. package/dist/commonjs/v3/query.js +115 -0
  6. package/dist/commonjs/v3/query.js.map +1 -1
  7. package/dist/commonjs/version.js +1 -1
  8. package/dist/esm/v3/ai.d.ts +26 -0
  9. package/dist/esm/v3/ai.js +7 -5
  10. package/dist/esm/v3/ai.js.map +1 -1
  11. package/dist/esm/v3/query.d.ts +434 -1
  12. package/dist/esm/v3/query.js +115 -0
  13. package/dist/esm/v3/query.js.map +1 -1
  14. package/dist/esm/version.js +1 -1
  15. package/docs/ai-chat/actions.mdx +6 -1
  16. package/docs/ai-chat/backend.mdx +47 -0
  17. package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
  18. package/docs/ai-chat/pending-messages.mdx +2 -0
  19. package/docs/ai-chat/reference.mdx +53 -2
  20. package/docs/ai-chat/transcript-storage.mdx +1 -1
  21. package/docs/apikeys.mdx +6 -4
  22. package/docs/cli-runs-commands.mdx +2 -2
  23. package/docs/cli-tasks-commands.mdx +95 -0
  24. package/docs/config/config-file.mdx +58 -0
  25. package/docs/config/extensions/prismaExtension.mdx +4 -4
  26. package/docs/deploy-environment-variables.mdx +4 -0
  27. package/docs/deployment/atomic-deployment.mdx +3 -3
  28. package/docs/deployment/overview.mdx +1 -1
  29. package/docs/deployment/preview-branches.mdx +1 -1
  30. package/docs/github-actions.mdx +3 -3
  31. package/docs/limits.mdx +6 -0
  32. package/docs/manual-setup.mdx +1 -1
  33. package/docs/mcp-tools.mdx +99 -3
  34. package/docs/observability/dashboards.mdx +62 -0
  35. package/docs/runs/max-duration.mdx +4 -0
  36. package/docs/self-hosting/env/supervisor.mdx +1 -0
  37. package/docs/webhooks/channels.mdx +158 -0
  38. package/docs/webhooks/connect.mdx +84 -0
  39. package/docs/webhooks/deliveries.mdx +103 -0
  40. package/docs/webhooks/filters.mdx +144 -0
  41. package/docs/webhooks/human-in-the-loop.mdx +162 -0
  42. package/docs/webhooks/linear.mdx +190 -0
  43. package/docs/webhooks/overview.mdx +119 -0
  44. package/docs/webhooks/session-routing.mdx +145 -0
  45. package/docs/webhooks/slack.mdx +397 -0
  46. package/docs/webhooks/sources.mdx +221 -0
  47. package/docs/webhooks/waiters.mdx +194 -0
  48. package/package.json +3 -2
@@ -1,5 +1,6 @@
1
- import type { ApiRequestOptions, Prettify } from "@trigger.dev/core/v3";
1
+ import type { AddDashboardWidgetRequestBody, ApiRequestOptions, CreateDashboardRequestBody, Prettify, ReplaceDashboardRequestBody, UpdateDashboardRequestBody, UpdateDashboardWidgetRequestBody } from "@trigger.dev/core/v3";
2
2
  export type { QueryTable, RunsTableRow, RunFriendlyStatus } from "@trigger.dev/core/v3";
3
+ export type { DashboardObject, DashboardSummary, DashboardWidget, DashboardWidgetDisplay, DashboardWidgetInput, DashboardWidgetPosition, } from "@trigger.dev/core/v3";
3
4
  export type QueryScope = "environment" | "project" | "organization";
4
5
  export type QueryFormat = "json" | "csv";
5
6
  /**
@@ -107,6 +108,438 @@ declare function execute<TRow extends Record<string, any> = Record<string, any>>
107
108
  format: "json";
108
109
  results: Array<Prettify<TRow>>;
109
110
  }>;
111
+ /**
112
+ * Lists the built-in dashboards and your organization's custom dashboards, with their widgets.
113
+ */
114
+ declare function listDashboards(requestOptions?: ApiRequestOptions): Promise<{
115
+ dashboards: {
116
+ key: string;
117
+ title: string;
118
+ type?: "builtIn" | "custom" | undefined;
119
+ description?: string | undefined;
120
+ widgets: {
121
+ id: string;
122
+ title: string;
123
+ query: string;
124
+ type: "bignumber" | "chart" | "table" | "title";
125
+ }[];
126
+ }[];
127
+ }>;
128
+ /**
129
+ * Retrieves a custom dashboard, including every widget, its query and its grid position.
130
+ */
131
+ declare function retrieveDashboard(dashboardId: string, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
132
+ id: string;
133
+ title: string;
134
+ description: string;
135
+ revision: string;
136
+ createdAt: Date;
137
+ updatedAt: Date;
138
+ widgets: {
139
+ id: string;
140
+ title: string;
141
+ query: string;
142
+ display: {
143
+ type: "table";
144
+ prettyFormatting: boolean;
145
+ sorting: {
146
+ desc: boolean;
147
+ id: string;
148
+ }[];
149
+ } | {
150
+ chartType: "bar" | "line";
151
+ xAxisColumn: string | null;
152
+ yAxisColumns: string[];
153
+ groupByColumn: string | null;
154
+ stacked: boolean;
155
+ sortByColumn: string | null;
156
+ sortDirection: "asc" | "desc";
157
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
158
+ seriesColors?: Record<string, string> | undefined;
159
+ type: "chart";
160
+ } | {
161
+ column: string;
162
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
163
+ sortDirection?: "asc" | "desc" | undefined;
164
+ abbreviate: boolean;
165
+ prefix?: string | undefined;
166
+ suffix?: string | undefined;
167
+ type: "bignumber";
168
+ } | {
169
+ type: "title";
170
+ };
171
+ fillGaps?: boolean | undefined;
172
+ position: {
173
+ x: number;
174
+ y: number;
175
+ w: number;
176
+ h: number;
177
+ };
178
+ }[];
179
+ }>;
180
+ /**
181
+ * Creates a custom dashboard, optionally with its widgets.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const dashboard = await query.dashboards.create({
186
+ * title: "Email tasks",
187
+ * widgets: [
188
+ * {
189
+ * title: "Runs per day",
190
+ * query: "SELECT timeBucket(), count() AS runs FROM runs GROUP BY timeBucket ORDER BY timeBucket",
191
+ * display: {
192
+ * type: "chart",
193
+ * chartType: "bar",
194
+ * xAxisColumn: "timebucket",
195
+ * yAxisColumns: ["runs"],
196
+ * groupByColumn: null,
197
+ * stacked: false,
198
+ * sortByColumn: null,
199
+ * sortDirection: "asc",
200
+ * aggregation: "sum",
201
+ * },
202
+ * },
203
+ * ],
204
+ * });
205
+ * ```
206
+ */
207
+ declare function createDashboard(body: CreateDashboardRequestBody, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
208
+ id: string;
209
+ title: string;
210
+ description: string;
211
+ revision: string;
212
+ createdAt: Date;
213
+ updatedAt: Date;
214
+ widgets: {
215
+ id: string;
216
+ title: string;
217
+ query: string;
218
+ display: {
219
+ type: "table";
220
+ prettyFormatting: boolean;
221
+ sorting: {
222
+ desc: boolean;
223
+ id: string;
224
+ }[];
225
+ } | {
226
+ chartType: "bar" | "line";
227
+ xAxisColumn: string | null;
228
+ yAxisColumns: string[];
229
+ groupByColumn: string | null;
230
+ stacked: boolean;
231
+ sortByColumn: string | null;
232
+ sortDirection: "asc" | "desc";
233
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
234
+ seriesColors?: Record<string, string> | undefined;
235
+ type: "chart";
236
+ } | {
237
+ column: string;
238
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
239
+ sortDirection?: "asc" | "desc" | undefined;
240
+ abbreviate: boolean;
241
+ prefix?: string | undefined;
242
+ suffix?: string | undefined;
243
+ type: "bignumber";
244
+ } | {
245
+ type: "title";
246
+ };
247
+ fillGaps?: boolean | undefined;
248
+ position: {
249
+ x: number;
250
+ y: number;
251
+ w: number;
252
+ h: number;
253
+ };
254
+ }[];
255
+ }>;
256
+ /**
257
+ * Renames a custom dashboard or changes its description.
258
+ */
259
+ declare function updateDashboard(dashboardId: string, body: UpdateDashboardRequestBody, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
260
+ id: string;
261
+ title: string;
262
+ description: string;
263
+ revision: string;
264
+ createdAt: Date;
265
+ updatedAt: Date;
266
+ widgets: {
267
+ id: string;
268
+ title: string;
269
+ query: string;
270
+ display: {
271
+ type: "table";
272
+ prettyFormatting: boolean;
273
+ sorting: {
274
+ desc: boolean;
275
+ id: string;
276
+ }[];
277
+ } | {
278
+ chartType: "bar" | "line";
279
+ xAxisColumn: string | null;
280
+ yAxisColumns: string[];
281
+ groupByColumn: string | null;
282
+ stacked: boolean;
283
+ sortByColumn: string | null;
284
+ sortDirection: "asc" | "desc";
285
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
286
+ seriesColors?: Record<string, string> | undefined;
287
+ type: "chart";
288
+ } | {
289
+ column: string;
290
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
291
+ sortDirection?: "asc" | "desc" | undefined;
292
+ abbreviate: boolean;
293
+ prefix?: string | undefined;
294
+ suffix?: string | undefined;
295
+ type: "bignumber";
296
+ } | {
297
+ type: "title";
298
+ };
299
+ fillGaps?: boolean | undefined;
300
+ position: {
301
+ x: number;
302
+ y: number;
303
+ w: number;
304
+ h: number;
305
+ };
306
+ }[];
307
+ }>;
308
+ /**
309
+ * Replaces every widget on a custom dashboard. A widget that already exists keeps its position
310
+ * unless you pass a new one; new widgets without a `position` are placed full width below the others,
311
+ * in order. Pass the `revision` you last read to reject the write if someone else changed the
312
+ * dashboard in the meantime.
313
+ */
314
+ declare function replaceDashboard(dashboardId: string, body: ReplaceDashboardRequestBody, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
315
+ id: string;
316
+ title: string;
317
+ description: string;
318
+ revision: string;
319
+ createdAt: Date;
320
+ updatedAt: Date;
321
+ widgets: {
322
+ id: string;
323
+ title: string;
324
+ query: string;
325
+ display: {
326
+ type: "table";
327
+ prettyFormatting: boolean;
328
+ sorting: {
329
+ desc: boolean;
330
+ id: string;
331
+ }[];
332
+ } | {
333
+ chartType: "bar" | "line";
334
+ xAxisColumn: string | null;
335
+ yAxisColumns: string[];
336
+ groupByColumn: string | null;
337
+ stacked: boolean;
338
+ sortByColumn: string | null;
339
+ sortDirection: "asc" | "desc";
340
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
341
+ seriesColors?: Record<string, string> | undefined;
342
+ type: "chart";
343
+ } | {
344
+ column: string;
345
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
346
+ sortDirection?: "asc" | "desc" | undefined;
347
+ abbreviate: boolean;
348
+ prefix?: string | undefined;
349
+ suffix?: string | undefined;
350
+ type: "bignumber";
351
+ } | {
352
+ type: "title";
353
+ };
354
+ fillGaps?: boolean | undefined;
355
+ position: {
356
+ x: number;
357
+ y: number;
358
+ w: number;
359
+ h: number;
360
+ };
361
+ }[];
362
+ }>;
363
+ /**
364
+ * Deletes a custom dashboard.
365
+ */
366
+ declare function deleteDashboard(dashboardId: string, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
367
+ id: string;
368
+ }>;
369
+ /**
370
+ * Adds a widget to a custom dashboard. Without a `position` it is placed full width at the bottom.
371
+ */
372
+ declare function addDashboardWidget(dashboardId: string, body: AddDashboardWidgetRequestBody, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
373
+ widgetId: string;
374
+ dashboard: {
375
+ id: string;
376
+ title: string;
377
+ description: string;
378
+ revision: string;
379
+ createdAt: Date;
380
+ updatedAt: Date;
381
+ widgets: {
382
+ id: string;
383
+ title: string;
384
+ query: string;
385
+ display: {
386
+ type: "table";
387
+ prettyFormatting: boolean;
388
+ sorting: {
389
+ desc: boolean;
390
+ id: string;
391
+ }[];
392
+ } | {
393
+ chartType: "bar" | "line";
394
+ xAxisColumn: string | null;
395
+ yAxisColumns: string[];
396
+ groupByColumn: string | null;
397
+ stacked: boolean;
398
+ sortByColumn: string | null;
399
+ sortDirection: "asc" | "desc";
400
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
401
+ seriesColors?: Record<string, string> | undefined;
402
+ type: "chart";
403
+ } | {
404
+ column: string;
405
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
406
+ sortDirection?: "asc" | "desc" | undefined;
407
+ abbreviate: boolean;
408
+ prefix?: string | undefined;
409
+ suffix?: string | undefined;
410
+ type: "bignumber";
411
+ } | {
412
+ type: "title";
413
+ };
414
+ fillGaps?: boolean | undefined;
415
+ position: {
416
+ x: number;
417
+ y: number;
418
+ w: number;
419
+ h: number;
420
+ };
421
+ }[];
422
+ };
423
+ }>;
424
+ /**
425
+ * Changes a widget's title, query, display, or position.
426
+ */
427
+ declare function updateDashboardWidget(dashboardId: string, widgetId: string, body: UpdateDashboardWidgetRequestBody, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
428
+ id: string;
429
+ title: string;
430
+ description: string;
431
+ revision: string;
432
+ createdAt: Date;
433
+ updatedAt: Date;
434
+ widgets: {
435
+ id: string;
436
+ title: string;
437
+ query: string;
438
+ display: {
439
+ type: "table";
440
+ prettyFormatting: boolean;
441
+ sorting: {
442
+ desc: boolean;
443
+ id: string;
444
+ }[];
445
+ } | {
446
+ chartType: "bar" | "line";
447
+ xAxisColumn: string | null;
448
+ yAxisColumns: string[];
449
+ groupByColumn: string | null;
450
+ stacked: boolean;
451
+ sortByColumn: string | null;
452
+ sortDirection: "asc" | "desc";
453
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
454
+ seriesColors?: Record<string, string> | undefined;
455
+ type: "chart";
456
+ } | {
457
+ column: string;
458
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
459
+ sortDirection?: "asc" | "desc" | undefined;
460
+ abbreviate: boolean;
461
+ prefix?: string | undefined;
462
+ suffix?: string | undefined;
463
+ type: "bignumber";
464
+ } | {
465
+ type: "title";
466
+ };
467
+ fillGaps?: boolean | undefined;
468
+ position: {
469
+ x: number;
470
+ y: number;
471
+ w: number;
472
+ h: number;
473
+ };
474
+ }[];
475
+ }>;
476
+ /**
477
+ * Removes a widget from a custom dashboard.
478
+ */
479
+ declare function deleteDashboardWidget(dashboardId: string, widgetId: string, options?: {
480
+ revision?: string;
481
+ }, requestOptions?: ApiRequestOptions): import("@trigger.dev/core/v3").ApiPromise<{
482
+ id: string;
483
+ title: string;
484
+ description: string;
485
+ revision: string;
486
+ createdAt: Date;
487
+ updatedAt: Date;
488
+ widgets: {
489
+ id: string;
490
+ title: string;
491
+ query: string;
492
+ display: {
493
+ type: "table";
494
+ prettyFormatting: boolean;
495
+ sorting: {
496
+ desc: boolean;
497
+ id: string;
498
+ }[];
499
+ } | {
500
+ chartType: "bar" | "line";
501
+ xAxisColumn: string | null;
502
+ yAxisColumns: string[];
503
+ groupByColumn: string | null;
504
+ stacked: boolean;
505
+ sortByColumn: string | null;
506
+ sortDirection: "asc" | "desc";
507
+ aggregation: "avg" | "count" | "max" | "min" | "sum";
508
+ seriesColors?: Record<string, string> | undefined;
509
+ type: "chart";
510
+ } | {
511
+ column: string;
512
+ aggregation: "avg" | "count" | "first" | "last" | "max" | "min" | "sum";
513
+ sortDirection?: "asc" | "desc" | undefined;
514
+ abbreviate: boolean;
515
+ prefix?: string | undefined;
516
+ suffix?: string | undefined;
517
+ type: "bignumber";
518
+ } | {
519
+ type: "title";
520
+ };
521
+ fillGaps?: boolean | undefined;
522
+ position: {
523
+ x: number;
524
+ y: number;
525
+ w: number;
526
+ h: number;
527
+ };
528
+ }[];
529
+ }>;
110
530
  export declare const query: {
111
531
  execute: typeof execute;
532
+ dashboards: {
533
+ list: typeof listDashboards;
534
+ retrieve: typeof retrieveDashboard;
535
+ create: typeof createDashboard;
536
+ update: typeof updateDashboard;
537
+ replace: typeof replaceDashboard;
538
+ del: typeof deleteDashboard;
539
+ widgets: {
540
+ add: typeof addDashboardWidget;
541
+ update: typeof updateDashboardWidget;
542
+ del: typeof deleteDashboardWidget;
543
+ };
544
+ };
112
545
  };
@@ -39,7 +39,122 @@ function dateToISOString(date) {
39
39
  }
40
40
  return new Date(date).toISOString();
41
41
  }
42
+ function dashboardRequestOptions(name, attributes, requestOptions) {
43
+ return mergeRequestOptions({ tracer, name, icon: "query", attributes }, requestOptions);
44
+ }
45
+ /**
46
+ * Lists the built-in dashboards and your organization's custom dashboards, with their widgets.
47
+ */
48
+ function listDashboards(requestOptions) {
49
+ return apiClientManager
50
+ .clientOrThrow()
51
+ .listDashboards(dashboardRequestOptions("query.dashboards.list()", {}, requestOptions));
52
+ }
53
+ /**
54
+ * Retrieves a custom dashboard, including every widget, its query and its grid position.
55
+ */
56
+ function retrieveDashboard(dashboardId, requestOptions) {
57
+ return apiClientManager
58
+ .clientOrThrow()
59
+ .retrieveDashboard(dashboardId, dashboardRequestOptions("query.dashboards.retrieve()", { dashboardId }, requestOptions));
60
+ }
61
+ /**
62
+ * Creates a custom dashboard, optionally with its widgets.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const dashboard = await query.dashboards.create({
67
+ * title: "Email tasks",
68
+ * widgets: [
69
+ * {
70
+ * title: "Runs per day",
71
+ * query: "SELECT timeBucket(), count() AS runs FROM runs GROUP BY timeBucket ORDER BY timeBucket",
72
+ * display: {
73
+ * type: "chart",
74
+ * chartType: "bar",
75
+ * xAxisColumn: "timebucket",
76
+ * yAxisColumns: ["runs"],
77
+ * groupByColumn: null,
78
+ * stacked: false,
79
+ * sortByColumn: null,
80
+ * sortDirection: "asc",
81
+ * aggregation: "sum",
82
+ * },
83
+ * },
84
+ * ],
85
+ * });
86
+ * ```
87
+ */
88
+ function createDashboard(body, requestOptions) {
89
+ return apiClientManager
90
+ .clientOrThrow()
91
+ .createDashboard(body, dashboardRequestOptions("query.dashboards.create()", { title: body.title }, requestOptions));
92
+ }
93
+ /**
94
+ * Renames a custom dashboard or changes its description.
95
+ */
96
+ function updateDashboard(dashboardId, body, requestOptions) {
97
+ return apiClientManager
98
+ .clientOrThrow()
99
+ .updateDashboard(dashboardId, body, dashboardRequestOptions("query.dashboards.update()", { dashboardId }, requestOptions));
100
+ }
101
+ /**
102
+ * Replaces every widget on a custom dashboard. A widget that already exists keeps its position
103
+ * unless you pass a new one; new widgets without a `position` are placed full width below the others,
104
+ * in order. Pass the `revision` you last read to reject the write if someone else changed the
105
+ * dashboard in the meantime.
106
+ */
107
+ function replaceDashboard(dashboardId, body, requestOptions) {
108
+ return apiClientManager
109
+ .clientOrThrow()
110
+ .replaceDashboard(dashboardId, body, dashboardRequestOptions("query.dashboards.replace()", { dashboardId }, requestOptions));
111
+ }
112
+ /**
113
+ * Deletes a custom dashboard.
114
+ */
115
+ function deleteDashboard(dashboardId, requestOptions) {
116
+ return apiClientManager
117
+ .clientOrThrow()
118
+ .deleteDashboard(dashboardId, dashboardRequestOptions("query.dashboards.del()", { dashboardId }, requestOptions));
119
+ }
120
+ /**
121
+ * Adds a widget to a custom dashboard. Without a `position` it is placed full width at the bottom.
122
+ */
123
+ function addDashboardWidget(dashboardId, body, requestOptions) {
124
+ return apiClientManager
125
+ .clientOrThrow()
126
+ .addDashboardWidget(dashboardId, body, dashboardRequestOptions("query.dashboards.widgets.add()", { dashboardId }, requestOptions));
127
+ }
128
+ /**
129
+ * Changes a widget's title, query, display, or position.
130
+ */
131
+ function updateDashboardWidget(dashboardId, widgetId, body, requestOptions) {
132
+ return apiClientManager
133
+ .clientOrThrow()
134
+ .updateDashboardWidget(dashboardId, widgetId, body, dashboardRequestOptions("query.dashboards.widgets.update()", { dashboardId, widgetId }, requestOptions));
135
+ }
136
+ /**
137
+ * Removes a widget from a custom dashboard.
138
+ */
139
+ function deleteDashboardWidget(dashboardId, widgetId, options, requestOptions) {
140
+ return apiClientManager
141
+ .clientOrThrow()
142
+ .deleteDashboardWidget(dashboardId, widgetId, options, dashboardRequestOptions("query.dashboards.widgets.del()", { dashboardId, widgetId }, requestOptions));
143
+ }
42
144
  export const query = {
43
145
  execute,
146
+ dashboards: {
147
+ list: listDashboards,
148
+ retrieve: retrieveDashboard,
149
+ create: createDashboard,
150
+ update: updateDashboard,
151
+ replace: replaceDashboard,
152
+ del: deleteDashboard,
153
+ widgets: {
154
+ add: addDashboardWidget,
155
+ update: updateDashboardWidget,
156
+ del: deleteDashboardWidget,
157
+ },
158
+ },
44
159
  };
45
160
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/v3/query.ts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rB,gCAAgC,EAChC,EAAE,WAAW,EAAE,QAAQ,EAAE,EACzB,cAAc,CACf,CACF,CAAC;AACN,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,OAAO;IACP,UAAU,EAAE;QACV,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,iBAAiB;QAC3B,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,gBAAgB;QACzB,GAAG,EAAE,eAAe;QACpB,OAAO,EAAE;YACP,GAAG,EAAE,kBAAkB;YACvB,MAAM,EAAE,qBAAqB;YAC7B,GAAG,EAAE,qBAAqB;SAC3B;KACF;CACF,CAAC"}
@@ -1,2 +1,2 @@
1
- export const VERSION = "4.7.4";
1
+ export const VERSION = "4.7.5";
2
2
  //# sourceMappingURL=version.js.map
@@ -73,11 +73,16 @@ onAction: async ({ action }) => {
73
73
  chat.history.slice(0, -1);
74
74
  chat.inject([{ role: "system", content: "Answer formally this time." }]);
75
75
  return chat.turn(); // with a one-shot instruction
76
+
77
+ case "ask":
78
+ return chat.turn(action.question); // answer a new user message
76
79
  }
77
80
  }
78
81
  ```
79
82
 
80
- `run()` receives the edited history with no incoming user message, the same shape as a `regenerate-message` turn, and its `trigger` is `"action-turn"`, so a `run()` that returns early on `"action"` (the pre-May behaviour, when actions invoked `run()` directly) still answers. Returning anything other than `chat.turn()` or nothing is an error; a response can no longer be returned from `onAction` directly.
83
+ `chat.turn(message)` appends `message` (a string, or a `UIMessage`) to the history as a user message after the edit, and the turn answers it. That is how a button click becomes a question, such as a follow-up suggestion in [Slack](/webhooks/slack#buttons-that-send-the-agent-an-action).
84
+
85
+ Without a message, `run()` receives the edited history with no incoming user message, the same shape as a `regenerate-message` turn, and its `trigger` is `"action-turn"`, so a `run()` that returns early on `"action"` (the pre-May behaviour, when actions invoked `run()` directly) still answers. Returning anything other than `chat.turn()` or nothing is an error; a response can no longer be returned from `onAction` directly.
81
86
 
82
87
  ### Actions and persistence
83
88
 
@@ -4,6 +4,8 @@ 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
+
7
9
  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.
8
10
 
9
11
  | Capability | `chat.agent()` | `chat.createSession()` | Raw primitives |
@@ -497,6 +499,51 @@ Custom actions let the frontend send structured commands (undo, rollback, edit,
497
499
 
498
500
  See [Actions](/ai-chat/actions).
499
501
 
502
+ ### Webhook events and channels
503
+
504
+ <WebhooksBetaNote />
505
+
506
+ 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
+
508
+ ```ts
509
+ import { webhooks } from "@trigger.dev/sdk";
510
+ import { chat } from "@trigger.dev/sdk/ai";
511
+ import { appMentions, slack, webhookSource } from "@trigger.dev/slack";
512
+
513
+ const slackEvents = webhooks.endpoint.define({ id: "slack", source: webhookSource() });
514
+ const stripe = webhooks.endpoint.define({ id: "stripe", source: webhooks.stripe() });
515
+
516
+ export const orderEvents = chat.event({
517
+ id: "order-events",
518
+ endpoint: stripe,
519
+ key: "{event.data.object.customer}",
520
+ // invoices always carry a customer; events without one would have no session to go to
521
+ filter: "event.type startsWith 'invoice.'",
522
+ type: "order.event",
523
+ });
524
+
525
+ export const myChat = chat.agent({
526
+ id: "my-chat",
527
+ events: [orderEvents],
528
+ channels: [
529
+ slack({
530
+ id: "support-slack",
531
+ endpoint: slackEvents,
532
+ token: process.env.SLACK_BOT_TOKEN!,
533
+ startOn: appMentions(),
534
+ }),
535
+ ],
536
+ onAction: async ({ action }) => {
537
+ // A verified order-events delivery arrives here as an action.
538
+ },
539
+ run: async (payload) => {
540
+ // Inbound Slack messages run here as normal turns.
541
+ },
542
+ });
543
+ ```
544
+
545
+ See [session routing](/webhooks/session-routing) and [channels](/webhooks/channels). For the interactive approvals layer, where a turn pauses on a human decision (buttons in the thread) and resumes on the click, see [human-in-the-loop](/webhooks/human-in-the-loop).
546
+
500
547
  ### Chat history
501
548
 
502
549
  Imperative API for reading and modifying the accumulated message history. Works from any hook (`onAction`, `onTurnStart`, `onBeforeTurnComplete`, `onTurnComplete`, `hydrateMessages`) or from `run()` and AI SDK tools.