@trigger.dev/sdk 4.6.4 → 4.7.0

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 (119) hide show
  1. package/dist/commonjs/v3/ai.d.ts +5 -2
  2. package/dist/commonjs/v3/ai.js +189 -266
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/chat-client.js +7 -0
  5. package/dist/commonjs/v3/chat-client.js.map +1 -1
  6. package/dist/commonjs/v3/chat-server.d.ts +1 -0
  7. package/dist/commonjs/v3/chat-server.js +8 -0
  8. package/dist/commonjs/v3/chat-server.js.map +1 -1
  9. package/dist/commonjs/v3/chat.d.ts +28 -4
  10. package/dist/commonjs/v3/chat.js +41 -9
  11. package/dist/commonjs/v3/chat.js.map +1 -1
  12. package/dist/commonjs/v3/chatRouteWait.d.ts +21 -0
  13. package/dist/commonjs/v3/chatRouteWait.js +43 -0
  14. package/dist/commonjs/v3/chatRouteWait.js.map +1 -0
  15. package/dist/commonjs/v3/compactionResponse.js +5 -0
  16. package/dist/commonjs/v3/compactionResponse.js.map +1 -1
  17. package/dist/commonjs/v3/concurrency-shared.d.ts +13 -0
  18. package/dist/commonjs/v3/concurrency-shared.js +35 -0
  19. package/dist/commonjs/v3/concurrency-shared.js.map +1 -0
  20. package/dist/commonjs/v3/concurrencyLimits.d.ts +73 -0
  21. package/dist/commonjs/v3/concurrencyLimits.js +166 -0
  22. package/dist/commonjs/v3/concurrencyLimits.js.map +1 -0
  23. package/dist/commonjs/v3/index.d.ts +2 -1
  24. package/dist/commonjs/v3/index.js +3 -1
  25. package/dist/commonjs/v3/index.js.map +1 -1
  26. package/dist/commonjs/v3/managedChatResponse.d.ts +44 -0
  27. package/dist/commonjs/v3/managedChatResponse.js +233 -0
  28. package/dist/commonjs/v3/managedChatResponse.js.map +1 -0
  29. package/dist/commonjs/v3/queues.d.ts +31 -0
  30. package/dist/commonjs/v3/queues.js +31 -0
  31. package/dist/commonjs/v3/queues.js.map +1 -1
  32. package/dist/commonjs/v3/shared.d.ts +18 -1
  33. package/dist/commonjs/v3/shared.js +137 -47
  34. package/dist/commonjs/v3/shared.js.map +1 -1
  35. package/dist/commonjs/v3/steeringContext.d.ts +41 -0
  36. package/dist/commonjs/v3/steeringContext.js +118 -0
  37. package/dist/commonjs/v3/steeringContext.js.map +1 -0
  38. package/dist/commonjs/v3/transcriptStorage.d.ts +4 -1
  39. package/dist/commonjs/v3/transcriptStorage.js +51 -4
  40. package/dist/commonjs/v3/transcriptStorage.js.map +1 -1
  41. package/dist/commonjs/version.js +1 -1
  42. package/dist/esm/v3/ai.d.ts +5 -2
  43. package/dist/esm/v3/ai.js +189 -266
  44. package/dist/esm/v3/ai.js.map +1 -1
  45. package/dist/esm/v3/chat-client.js +7 -0
  46. package/dist/esm/v3/chat-client.js.map +1 -1
  47. package/dist/esm/v3/chat-server.d.ts +1 -0
  48. package/dist/esm/v3/chat-server.js +8 -0
  49. package/dist/esm/v3/chat-server.js.map +1 -1
  50. package/dist/esm/v3/chat.d.ts +28 -4
  51. package/dist/esm/v3/chat.js +41 -9
  52. package/dist/esm/v3/chat.js.map +1 -1
  53. package/dist/esm/v3/chatRouteWait.d.ts +21 -0
  54. package/dist/esm/v3/chatRouteWait.js +40 -0
  55. package/dist/esm/v3/chatRouteWait.js.map +1 -0
  56. package/dist/esm/v3/compactionResponse.js +5 -0
  57. package/dist/esm/v3/compactionResponse.js.map +1 -1
  58. package/dist/esm/v3/concurrency-shared.d.ts +13 -0
  59. package/dist/esm/v3/concurrency-shared.js +31 -0
  60. package/dist/esm/v3/concurrency-shared.js.map +1 -0
  61. package/dist/esm/v3/concurrencyLimits.d.ts +73 -0
  62. package/dist/esm/v3/concurrencyLimits.js +158 -0
  63. package/dist/esm/v3/concurrencyLimits.js.map +1 -0
  64. package/dist/esm/v3/index.d.ts +2 -1
  65. package/dist/esm/v3/index.js +2 -1
  66. package/dist/esm/v3/index.js.map +1 -1
  67. package/dist/esm/v3/managedChatResponse.d.ts +44 -0
  68. package/dist/esm/v3/managedChatResponse.js +228 -0
  69. package/dist/esm/v3/managedChatResponse.js.map +1 -0
  70. package/dist/esm/v3/queues.d.ts +31 -0
  71. package/dist/esm/v3/queues.js +31 -0
  72. package/dist/esm/v3/queues.js.map +1 -1
  73. package/dist/esm/v3/shared.d.ts +18 -1
  74. package/dist/esm/v3/shared.js +136 -47
  75. package/dist/esm/v3/shared.js.map +1 -1
  76. package/dist/esm/v3/steeringContext.d.ts +41 -0
  77. package/dist/esm/v3/steeringContext.js +113 -0
  78. package/dist/esm/v3/steeringContext.js.map +1 -0
  79. package/dist/esm/v3/transcriptStorage.d.ts +4 -1
  80. package/dist/esm/v3/transcriptStorage.js +51 -4
  81. package/dist/esm/v3/transcriptStorage.js.map +1 -1
  82. package/dist/esm/version.js +1 -1
  83. package/docs/ai-chat/client-protocol.mdx +3 -1
  84. package/docs/ai-chat/error-handling.mdx +44 -76
  85. package/docs/ai-chat/fast-starts.mdx +1 -1
  86. package/docs/ai-chat/frontend.mdx +27 -21
  87. package/docs/ai-chat/patterns/branching-conversations.mdx +95 -230
  88. package/docs/ai-chat/patterns/human-in-the-loop.mdx +166 -164
  89. package/docs/ai-chat/patterns/tool-result-auditing.mdx +28 -27
  90. package/docs/ai-chat/patterns/version-upgrades.mdx +4 -4
  91. package/docs/ai-chat/pending-messages.mdx +19 -5
  92. package/docs/ai-chat/quick-start.mdx +26 -20
  93. package/docs/ai-chat/reference.mdx +21 -3
  94. package/docs/ai-chat/sessions.mdx +1 -1
  95. package/docs/ai-chat/testing.mdx +16 -4
  96. package/docs/concurrency.mdx +384 -0
  97. package/docs/database-connections.mdx +3 -3
  98. package/docs/deploy-environment-variables.mdx +6 -0
  99. package/docs/deployment/atomic-deployment.mdx +416 -132
  100. package/docs/deployment/overview.mdx +2 -2
  101. package/docs/github-actions.mdx +2 -2
  102. package/docs/github-integration.mdx +2 -2
  103. package/docs/idempotency.mdx +43 -5
  104. package/docs/introduction.mdx +1 -1
  105. package/docs/limits.mdx +16 -6
  106. package/docs/observability/query.mdx +25 -0
  107. package/docs/queues.mdx +271 -0
  108. package/docs/reports.mdx +1 -1
  109. package/docs/runs/priority.mdx +2 -25
  110. package/docs/self-hosting/env/webapp.mdx +7 -0
  111. package/docs/tasks/overview.mdx +3 -5
  112. package/docs/troubleshooting-alerts.mdx +124 -1
  113. package/docs/troubleshooting.mdx +12 -0
  114. package/docs/vercel-integration.mdx +6 -7
  115. package/docs/versioning.mdx +1 -1
  116. package/docs/writing-tasks-introduction.mdx +2 -1
  117. package/package.json +2 -2
  118. package/docs/deployment/version-skew-protection.mdx +0 -492
  119. package/docs/queue-concurrency.mdx +0 -358
@@ -7,6 +7,14 @@ We support receiving alerts for the following events:
7
7
  - Run fails
8
8
  - Deployment fails
9
9
  - Deployment succeeds
10
+ - A new error group appears, regresses, or is unignored
11
+
12
+ The first three are created from the **Alerts** page. The fourth — an **Error group** alert — is created from the **Errors** page instead, but appears in the same Alerts table once created. It behaves quite differently from a run failure alert; see [Error group alerts](#error-group-alerts) below.
13
+
14
+ <Note>
15
+ If you want to be told about **every** run that fails, choose a **run fails** alert. An Error group
16
+ alert will not do this — it deliberately stays quiet once it has alerted on a given error.
17
+ </Note>
10
18
 
11
19
  ## How to setup alerts
12
20
 
@@ -36,6 +44,37 @@ Click on the triple dot menu on the right side of the table row and select "Disa
36
44
  </Steps>
37
45
 
38
46
 
47
+ ## Error group alerts
48
+
49
+ Error group alerts are **issue-based**, not run-based. They are created from the **Errors** page in the dashboard (the "Configure alerts…" button), not from the New alert modal on the Alerts page. Once created they show up in the Alerts table alongside your other alerts, labelled "Error group".
50
+
51
+ An error group is one distinct error — the same error from many runs is a single group, with a status of **Unresolved**, **Resolved** or **Ignored** that you set from the Errors page.
52
+
53
+ ### When an error group alert fires
54
+
55
+ The alert only fires when a group's status *changes* in one of these three ways:
56
+
57
+ | Trigger | Meaning |
58
+ | :------ | :------ |
59
+ | New issue | The error has been seen for the first time. |
60
+ | Regression | The group was marked **Resolved**, and the error has occurred again since. |
61
+ | Unignored | The group was **Ignored**, and the ignore condition you set has been breached. |
62
+
63
+ ### Why it goes quiet
64
+
65
+ This is the part that surprises people, so it is worth stating plainly:
66
+
67
+ **An Unresolved error group does not alert.** After an error group alert fires, the group is set to Unresolved, and it stays silent no matter how many more times that error occurs. It will only alert again once you mark it **Resolved** (and it then recurs) or **Ignored** (and the ignore condition is breached).
68
+
69
+ This is intentional — one persistently broken task should not flood your Slack channel with a message per failed run. But it means an Error group alert is not a substitute for a run failure alert. If a task has been failing in production for days and you have had no notification, check whether the only alert you have configured is an Error group alert whose group is sitting at Unresolved.
70
+
71
+ ### Which alert type should I use?
72
+
73
+ - **"Tell me about every run that fails"** → a **run fails** alert, from the Alerts page. It fires for every run that fails once its retries are exhausted.
74
+ - **"Tell me when something new breaks"** → an **Error group** alert, from the Errors page.
75
+
76
+ The two are complementary, and many teams want both.
77
+
39
78
  ## Alert webhooks
40
79
 
41
80
  For the alert webhooks you can use the SDK to parse them. Here is an example of how to parse the webhook payload in Remix:
@@ -69,6 +108,10 @@ export async function action({ request }: ActionFunctionArgs) {
69
108
  console.log("[Webhook Internal Test] Deployment failed alert webhook received", { event });
70
109
  break;
71
110
  }
111
+ case "alert.error": {
112
+ console.log("[Webhook Internal Test] Error group alert webhook received", { event });
113
+ break;
114
+ }
72
115
  default: {
73
116
  console.log("[Webhook Internal Test] Unhandled webhook type", { event });
74
117
  }
@@ -112,7 +155,7 @@ When you create a webhook alert, you'll receive different payloads depending on
112
155
  </ParamField>
113
156
 
114
157
  <ParamField path="type" type="string">
115
- The type of alert webhook. One of: `alert.run.failed`, `alert.deployment.success`, or `alert.deployment.failed`
158
+ The type of alert webhook. One of: `alert.run.failed`, `alert.deployment.success`, `alert.deployment.failed`, or `alert.error`
116
159
  </ParamField>
117
160
 
118
161
  ### Run Failed Alert
@@ -383,3 +426,83 @@ This webhook is sent when a deployment fails. The payload is available on the `o
383
426
  Project name
384
427
  </ParamField>
385
428
 
429
+
430
+ ### Error Group Alert
431
+
432
+ This webhook is sent for an [error group alert](#error-group-alerts). The payload is available on the `object` property:
433
+
434
+ <ParamField path="object.classification" type="string">
435
+ Why the alert fired. One of: `new_issue`, `regression`, `unignored`
436
+ </ParamField>
437
+
438
+ <ParamField path="object.error.fingerprint" type="string">
439
+ Identifier for the error group
440
+ </ParamField>
441
+
442
+ <ParamField path="object.error.type" type="string">
443
+ Error type
444
+ </ParamField>
445
+
446
+ <ParamField path="object.error.message" type="string">
447
+ Error message
448
+ </ParamField>
449
+
450
+ <ParamField path="object.error.stackTrace" type="string">
451
+ Sample stack trace, if available
452
+ </ParamField>
453
+
454
+ <ParamField path="object.error.firstSeen" type="string">
455
+ When the error was first seen
456
+ </ParamField>
457
+
458
+ <ParamField path="object.error.lastSeen" type="string">
459
+ When the error was last seen
460
+ </ParamField>
461
+
462
+ <ParamField path="object.error.occurrenceCount" type="number">
463
+ Number of occurrences
464
+ </ParamField>
465
+
466
+ <ParamField path="object.error.taskIdentifier" type="string">
467
+ Task the error occurred in
468
+ </ParamField>
469
+
470
+ <ParamField path="object.environment.id" type="string">
471
+ Environment ID
472
+ </ParamField>
473
+
474
+ <ParamField path="object.environment.name" type="string">
475
+ Environment name
476
+ </ParamField>
477
+
478
+ <ParamField path="object.organization.id" type="string">
479
+ Organization ID
480
+ </ParamField>
481
+
482
+ <ParamField path="object.organization.slug" type="string">
483
+ Organization slug
484
+ </ParamField>
485
+
486
+ <ParamField path="object.organization.name" type="string">
487
+ Organization name
488
+ </ParamField>
489
+
490
+ <ParamField path="object.project.id" type="string">
491
+ Project ID
492
+ </ParamField>
493
+
494
+ <ParamField path="object.project.ref" type="string">
495
+ Project reference
496
+ </ParamField>
497
+
498
+ <ParamField path="object.project.slug" type="string">
499
+ Project slug
500
+ </ParamField>
501
+
502
+ <ParamField path="object.project.name" type="string">
503
+ Project name
504
+ </ParamField>
505
+
506
+ <ParamField path="object.dashboardUrl" type="string">
507
+ URL to view the error in the dashboard
508
+ </ParamField>
@@ -163,6 +163,18 @@ You need to be on at least these minor versions:
163
163
 
164
164
  ## Runtime issues
165
165
 
166
+ ### Runs stuck in "Pending version"
167
+
168
+ A run sits in **Pending version** when the version deployed to that environment doesn't contain the run's task, or doesn't contain the queue it was triggered on. The run isn't lost: unless it's pinned to a specific deployment (see the last cause below), it starts automatically once a version containing both is deployed.
169
+
170
+ Usually one of:
171
+
172
+ - **The task isn't in the deployed version.** It was renamed or removed, or the deploy adding it hasn't landed yet. Check the Tasks page for that environment.
173
+ - **The queue doesn't exist in the deployed version.** Overriding `queue` at trigger time only works if a deployed task declares that queue — see [Queues](/queues).
174
+ - **You triggered into the wrong organization, project or environment.** Check the secret key you triggered with belongs to the same place you deployed to.
175
+ - **A later deploy removed or renamed the task or queue while the run was waiting.** Most likely with `delay`. Pin the run to a version to avoid this: `trigger(payload, { delay: "1h", version: "20260227.2" })`. See [version locking](/deployment/overview#version-locking).
176
+ - **The run is pinned to an external deployment id that hasn't arrived.** This is [version skew protection](/deployment/atomic-deployment#waiting-and-expiry), and it behaves differently: only a deployment carrying the matching id releases the run, and it expires after 1 hour if none does.
177
+
166
178
  ### `Environment variable not found:`
167
179
 
168
180
  Your code is deployed separately from the rest of your app(s) so you need to make sure that you set any environment variables you use in your tasks in the Trigger.dev dashboard. [Read the guide](/deploy-environment-variables).
@@ -5,7 +5,7 @@ description: "Automatically deploy your tasks whenever you deploy to Vercel."
5
5
 
6
6
  ## How it works
7
7
 
8
- The Vercel integration connects your Vercel project to your Trigger.dev project so that every Vercel deployment automatically triggers a Trigger.dev deployment. It also syncs environment variables from Vercel into Trigger.dev, and sets up [version skew protection](/deployment/version-skew-protection) so your app and tasks stay in sync.
8
+ The Vercel integration connects your Vercel project to your Trigger.dev project so that every Vercel deployment automatically triggers a Trigger.dev deployment. It also syncs environment variables from Vercel into Trigger.dev, and sets up [version skew protection](/deployment/atomic-deployment) so your app and tasks stay in sync.
9
9
 
10
10
  This eliminates the need to manually run the `trigger.dev deploy` command or maintain custom CI/CD workflows for Vercel-based projects.
11
11
 
@@ -121,7 +121,7 @@ If you use [Supabase Branching](https://supabase.com/docs/guides/deployment/bran
121
121
 
122
122
  ## Version skew protection
123
123
 
124
- Your Vercel app and your tasks are deployed separately, so there is always a window where a new app can trigger tasks built from older code. [Version skew protection](/deployment/version-skew-protection) closes that window: each Trigger.dev deployment is tagged with your commit SHA, your app sends the same SHA when it triggers, and every run is pinned to the deployment built from the same commit. Runs triggered before the task build finishes wait for it rather than running on the previous version.
124
+ Your Vercel app and your tasks are deployed separately, so there is always a window where a new app can trigger tasks built from older code. [Version skew protection](/deployment/atomic-deployment) closes that window: each Trigger.dev deployment is tagged with your commit SHA, your app sends the same SHA when it triggers, and every run is pinned to the deployment built from the same commit. Runs triggered before the task build finishes wait for it rather than running on the previous version.
125
125
 
126
126
  The integration sets this up for you:
127
127
 
@@ -145,7 +145,7 @@ To opt out, set `TRIGGER_AUTOMATIC_SKEW_VERSION_PROTECTION` to `0` on your Verce
145
145
 
146
146
  <Warning>
147
147
  **Automatic atomic deployments are deprecated.** Use [version skew
148
- protection](/deployment/version-skew-protection) instead — it needs no second Vercel deployment,
148
+ protection](/deployment/atomic-deployment) instead — it needs no second Vercel deployment,
149
149
  never gates your app's deploy, doesn't touch `Auto-assign Custom Production Domains`, and covers
150
150
  staging and preview as well as production.
151
151
 
@@ -193,7 +193,7 @@ Atomic deployments are off by default for new connections. Projects that already
193
193
  that setting in Vercel or promote deployments yourself.
194
194
  </Note>
195
195
 
196
- Previously, setting up atomic deployments with Vercel required custom GitHub Actions workflows. The Vercel integration automates this entirely. For more details on how atomic deployments work, see [Atomic deploys](/deployment/atomic-deployment). For how to move off them, see [replacing automatic atomic deployments](/deployment/version-skew-protection#replacing-automatic-atomic-deployments).
196
+ Previously, setting up atomic deployments with Vercel required custom GitHub Actions workflows. The Vercel integration automates this entirely. For how to move off them, see [legacy atomic deployments](/deployment/atomic-deployment#legacy-atomic-deployments).
197
197
 
198
198
  ## Environment mapping
199
199
 
@@ -217,7 +217,7 @@ If your Vercel project has a custom environment, you can select which one maps t
217
217
 
218
218
  You can configure the following settings per-environment from your project's Vercel settings:
219
219
 
220
- - **Atomic deployments** (deprecated): Controls whether Trigger.dev gates and redeploys your Vercel deployment to keep it in sync. Off by default for new connections — use [version skew protection](/deployment/version-skew-protection) instead.
220
+ - **Atomic deployments** (deprecated): Controls whether Trigger.dev gates and redeploys your Vercel deployment to keep it in sync. Off by default for new connections — use [version skew protection](/deployment/atomic-deployment) instead.
221
221
  - **Pull env vars before build**: When enabled, Trigger.dev pulls the latest environment variables from Vercel before each build. Enabled for production, staging, and preview by default.
222
222
  - **Discover new env vars**: When enabled, new environment variables found in Vercel that don't yet exist in Trigger.dev are created automatically during builds. Only available for environments that also have env var pulling enabled. Enabled for production, staging, and preview by default.
223
223
 
@@ -234,8 +234,7 @@ Disconnecting stops automatic deployments, environment variable syncing, and dep
234
234
 
235
235
  ## Related
236
236
 
237
- - [Version skew protection](/deployment/version-skew-protection)
237
+ - [Atomic deployments (version skew protection)](/deployment/atomic-deployment)
238
238
  - [GitHub integration](/github-integration)
239
- - [Atomic deploys](/deployment/atomic-deployment) (deprecated for Vercel)
240
239
  - [Environment variables](/deploy-environment-variables)
241
240
  - [Preview branches](/deployment/preview-branches)
@@ -47,7 +47,7 @@ So a task run will continue running on the version it was locked to. We do this
47
47
 
48
48
  Every deployment creates a new version of all tasks for that environment.
49
49
 
50
- Because your application and your tasks deploy separately, a release of your app can briefly trigger tasks that belong to a different version. [Version skew protection](/deployment/version-skew-protection) pins each run to the deployment built from the same commit, once your app sends the id it was deployed with.
50
+ Because your application and your tasks deploy separately, a release of your app can briefly trigger tasks that belong to a different version. [Version skew protection](/deployment/atomic-deployment) pins each run to the deployment built from the same commit, once your app sends the id it was deployed with.
51
51
 
52
52
  ## Retries and reattempts
53
53
 
@@ -15,7 +15,8 @@ Before digging deeper into the details of writing tasks, you should read the [fu
15
15
  | [Logging](/logging) | View and send logs and traces from your tasks. |
16
16
  | [Errors & retrying](/errors-retrying) | How to deal with errors and write reliable tasks. |
17
17
  | [Wait](/wait) | Wait for periods of time or for external events to occur before continuing. |
18
- | [Concurrency & Queues](/queue-concurrency) | Configure what you want to happen when there is more than one run at a time. |
18
+ | [Queues](/queues) | Control the order your runs execute in. |
19
+ | [Concurrency](/concurrency) | Limit how many runs execute at once: per task, per tenant, or shared across tasks. |
19
20
  | [Realtime notifications](/realtime/overview) | Send realtime notifications from your task that you can subscribe to from your backend or frontend. |
20
21
  | [Versioning](/versioning) | How versioning works. |
21
22
  | [Machines](/machines) | Configure the CPU and RAM of the machine your task runs on |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trigger.dev/sdk",
3
- "version": "4.6.4",
3
+ "version": "4.7.0",
4
4
  "description": "trigger.dev Node.JS SDK",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -69,7 +69,7 @@
69
69
  "dependencies": {
70
70
  "@opentelemetry/api": "1.9.1",
71
71
  "@opentelemetry/semantic-conventions": "1.41.1",
72
- "@trigger.dev/core": "4.6.4",
72
+ "@trigger.dev/core": "4.7.0",
73
73
  "uncrypto": "^0.1.3"
74
74
  },
75
75
  "devDependencies": {