@trigger.dev/sdk 4.5.11 → 4.5.13
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 +154 -20
- package/dist/commonjs/v3/ai.js +1247 -406
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +3 -3
- package/dist/commonjs/v3/chat-client.d.ts +5 -4
- package/dist/commonjs/v3/chat-client.js +2 -6
- package/dist/commonjs/v3/chat-client.js.map +1 -1
- package/dist/commonjs/v3/chat.d.ts +7 -2
- package/dist/commonjs/v3/chat.js +22 -7
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/chat.test.js +13 -4
- package/dist/commonjs/v3/chat.test.js.map +1 -1
- package/dist/commonjs/v3/envvars.js.map +1 -1
- package/dist/commonjs/v3/retry.d.ts +1 -1
- package/dist/commonjs/v3/retry.js +1 -2
- package/dist/commonjs/v3/retry.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +2 -6
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/schedules/api.d.ts +8 -1
- package/dist/commonjs/v3/schedules/index.d.ts +11 -6
- package/dist/commonjs/v3/schedules/index.js +2 -0
- package/dist/commonjs/v3/schedules/index.js.map +1 -1
- package/dist/commonjs/v3/schedules/index.test.d.ts +1 -0
- package/dist/commonjs/v3/schedules/index.test.js +49 -0
- package/dist/commonjs/v3/schedules/index.test.js.map +1 -0
- package/dist/commonjs/v3/schedules/index.types.test.d.ts +1 -0
- package/dist/commonjs/v3/schedules/index.types.test.js +93 -0
- package/dist/commonjs/v3/schedules/index.types.test.js.map +1 -0
- package/dist/commonjs/v3/sessions.d.ts +4 -10
- package/dist/commonjs/v3/sessions.js +73 -47
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +2 -3
- package/dist/commonjs/v3/shared.js +14 -0
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.d.ts +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.js +1 -0
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/test/test-session-handle.d.ts +1 -31
- package/dist/commonjs/v3/test/test-session-handle.js +22 -25
- package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +154 -20
- package/dist/esm/v3/ai.js +1245 -406
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +3 -3
- package/dist/esm/v3/chat-client.d.ts +5 -4
- package/dist/esm/v3/chat-client.js +2 -6
- package/dist/esm/v3/chat-client.js.map +1 -1
- package/dist/esm/v3/chat.d.ts +7 -2
- package/dist/esm/v3/chat.js +22 -7
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/chat.test.js +13 -4
- package/dist/esm/v3/chat.test.js.map +1 -1
- package/dist/esm/v3/envvars.js.map +1 -1
- package/dist/esm/v3/retry.d.ts +1 -1
- package/dist/esm/v3/retry.js +1 -2
- package/dist/esm/v3/retry.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +2 -6
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/schedules/api.d.ts +8 -1
- package/dist/esm/v3/schedules/index.d.ts +11 -6
- package/dist/esm/v3/schedules/index.js +2 -0
- package/dist/esm/v3/schedules/index.js.map +1 -1
- package/dist/esm/v3/schedules/index.test.d.ts +1 -0
- package/dist/esm/v3/schedules/index.test.js +47 -0
- package/dist/esm/v3/schedules/index.test.js.map +1 -0
- package/dist/esm/v3/schedules/index.types.test.d.ts +1 -0
- package/dist/esm/v3/schedules/index.types.test.js +91 -0
- package/dist/esm/v3/schedules/index.types.test.js.map +1 -0
- package/dist/esm/v3/sessions.d.ts +4 -10
- package/dist/esm/v3/sessions.js +73 -47
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +2 -3
- package/dist/esm/v3/shared.js +15 -1
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.d.ts +1 -1
- package/dist/esm/v3/test/mock-chat-agent.js +2 -1
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/test/test-session-handle.d.ts +1 -31
- package/dist/esm/v3/test/test-session-handle.js +24 -25
- package/dist/esm/v3/test/test-session-handle.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/client-protocol.mdx +8 -3
- package/docs/ai-chat/custom-agents.mdx +181 -46
- package/docs/ai-chat/patterns/recovery-boot.mdx +9 -2
- package/docs/ai-chat/patterns/version-upgrades.mdx +26 -6
- package/docs/ai-chat/pending-messages.mdx +5 -3
- package/docs/ai-chat/reference.mdx +26 -10
- package/docs/ai-chat/types.mdx +5 -1
- package/docs/apikeys.mdx +159 -27
- package/docs/deployment/atomic-deployment.mdx +12 -0
- package/docs/deployment/overview.mdx +7 -1
- package/docs/deployment/version-skew-protection.mdx +430 -0
- package/docs/github-actions.mdx +33 -5
- package/docs/github-integration.mdx +12 -0
- package/docs/realtime/auth.mdx +3 -1
- package/docs/self-hosting/env/supervisor.mdx +1 -0
- package/docs/self-hosting/env/webapp.mdx +1 -0
- package/docs/tasks/scheduled.mdx +45 -0
- package/docs/vercel-integration.mdx +43 -9
- package/docs/versioning.mdx +2 -0
- package/package.json +3 -15
|
@@ -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
|
|
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.
|
|
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
|
|
|
@@ -42,8 +42,7 @@ You can connect Vercel from two entry points:
|
|
|
42
42
|
</Step>
|
|
43
43
|
|
|
44
44
|
<Step title="Configure build options">
|
|
45
|
-
Optionally adjust [build options](#build-options) for
|
|
46
|
-
env var discovery.
|
|
45
|
+
Optionally adjust [build options](#build-options) for env var pulling and new env var discovery.
|
|
47
46
|
</Step>
|
|
48
47
|
|
|
49
48
|
<Step title="Connect GitHub">
|
|
@@ -99,7 +98,7 @@ The integration syncs environment variables in both directions:
|
|
|
99
98
|
|
|
100
99
|
The following variables are excluded from the Vercel → Trigger.dev sync:
|
|
101
100
|
|
|
102
|
-
- `TRIGGER_SECRET_KEY`, `TRIGGER_VERSION`, `TRIGGER_PREVIEW_BRANCH` (managed by Trigger.dev)
|
|
101
|
+
- `TRIGGER_SECRET_KEY`, `TRIGGER_API_URL`, `TRIGGER_VERSION`, `TRIGGER_PREVIEW_BRANCH`, `TRIGGER_AUTOMATIC_SKEW_VERSION_PROTECTION` (managed by Trigger.dev)
|
|
103
102
|
- Sensitive/secret-type variables (Vercel API limitation)
|
|
104
103
|
|
|
105
104
|
You can control sync behavior per-variable from your project's Vercel settings. Deselecting a variable prevents its value from being updated during future syncs.
|
|
@@ -120,8 +119,41 @@ You can control sync behavior per-variable from your project's Vercel settings.
|
|
|
120
119
|
|
|
121
120
|
If you use [Supabase Branching](https://supabase.com/docs/guides/deployment/branching) or [Neon Database Branching](https://neon.tech/docs/guides/branching-intro) for preview environments, disable syncing for database env vars on the Environment Variables page and use the [syncSupabaseEnvVars](/config/extensions/syncEnvVars#syncsupabaseenvvars) or [syncNeonEnvVars](/config/extensions/syncEnvVars#syncneonenvvars) build extensions instead. These extensions automatically resolve the correct branch-specific credentials at build time.
|
|
122
121
|
|
|
122
|
+
## Version skew protection
|
|
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.
|
|
125
|
+
|
|
126
|
+
The integration sets this up for you:
|
|
127
|
+
|
|
128
|
+
- It sets `TRIGGER_AUTOMATIC_SKEW_VERSION_PROTECTION=1` on your Vercel project when you connect it, and re-asserts it on every build — so existing projects pick it up on their next deployment.
|
|
129
|
+
- It passes your commit SHA as the deployment's external id.
|
|
130
|
+
- `VERCEL_GIT_COMMIT_SHA` is available at runtime on Vercel, so the SDK finds the matching id with no work from you.
|
|
131
|
+
|
|
132
|
+
There is nothing to enable, and it works in production, staging and preview alike. Nothing is gated: your Vercel deployment is never held back.
|
|
133
|
+
|
|
134
|
+
<Note>
|
|
135
|
+
Version skew protection requires the `@trigger.dev/sdk` release that introduces external
|
|
136
|
+
deployment ids. Check the [release
|
|
137
|
+
notes](https://github.com/triggerdotdev/trigger.dev/releases) for the exact version, or just use
|
|
138
|
+
the latest. On an older SDK no id is sent and your runs execute on the current version, with no
|
|
139
|
+
warning.
|
|
140
|
+
</Note>
|
|
141
|
+
|
|
142
|
+
To opt out, set `TRIGGER_AUTOMATIC_SKEW_VERSION_PROTECTION` to `0` on your Vercel project. The integration only writes the variable when it is absent, so a value you set is never overwritten.
|
|
143
|
+
|
|
123
144
|
## Atomic deployments
|
|
124
145
|
|
|
146
|
+
<Warning>
|
|
147
|
+
**Automatic atomic deployments are deprecated.** Use [version skew
|
|
148
|
+
protection](/deployment/version-skew-protection) instead — it needs no second Vercel deployment,
|
|
149
|
+
never gates your app's deploy, doesn't touch `Auto-assign Custom Production Domains`, and covers
|
|
150
|
+
staging and preview as well as production.
|
|
151
|
+
|
|
152
|
+
Nothing is being switched off. The setting stays in your project's Vercel settings, keeps working,
|
|
153
|
+
and remains the way to hold your Vercel deployment back until your tasks have built. New
|
|
154
|
+
connections have it off by default.
|
|
155
|
+
</Warning>
|
|
156
|
+
|
|
125
157
|
Atomic deployments ensure your Vercel app and Trigger.dev tasks are deployed in sync. When enabled, Trigger.dev gates your Vercel deployment until the task build completes, then triggers a Vercel redeployment with the correct `TRIGGER_VERSION` set. This guarantees your app always uses the matching version of your tasks.
|
|
126
158
|
|
|
127
159
|
```mermaid
|
|
@@ -152,15 +184,16 @@ sequenceDiagram
|
|
|
152
184
|
TD->>TD: Promote build
|
|
153
185
|
```
|
|
154
186
|
|
|
155
|
-
Atomic deployments are
|
|
187
|
+
Atomic deployments are off by default for new connections. Projects that already had them enabled keep them enabled until you turn them off. Enabling them asks you to confirm first.
|
|
156
188
|
|
|
157
189
|
<Note>
|
|
158
190
|
When atomic deployments are enabled, the integration automatically disables `Auto-assign Custom
|
|
159
191
|
Production Domains` on your Vercel project. This is required so that Vercel doesn't promote a
|
|
160
|
-
deployment before the Trigger.dev build is ready.
|
|
192
|
+
deployment before the Trigger.dev build is ready. If you turn atomic deployments off, re-enable
|
|
193
|
+
that setting in Vercel or promote deployments yourself.
|
|
161
194
|
</Note>
|
|
162
195
|
|
|
163
|
-
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).
|
|
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).
|
|
164
197
|
|
|
165
198
|
## Environment mapping
|
|
166
199
|
|
|
@@ -184,7 +217,7 @@ If your Vercel project has a custom environment, you can select which one maps t
|
|
|
184
217
|
|
|
185
218
|
You can configure the following settings per-environment from your project's Vercel settings:
|
|
186
219
|
|
|
187
|
-
- **Atomic deployments
|
|
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.
|
|
188
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.
|
|
189
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.
|
|
190
223
|
|
|
@@ -201,7 +234,8 @@ Disconnecting stops automatic deployments, environment variable syncing, and dep
|
|
|
201
234
|
|
|
202
235
|
## Related
|
|
203
236
|
|
|
237
|
+
- [Version skew protection](/deployment/version-skew-protection)
|
|
204
238
|
- [GitHub integration](/github-integration)
|
|
205
|
-
- [Atomic deploys](/deployment/atomic-deployment)
|
|
239
|
+
- [Atomic deploys](/deployment/atomic-deployment) (deprecated for Vercel)
|
|
206
240
|
- [Environment variables](/deploy-environment-variables)
|
|
207
241
|
- [Preview branches](/deployment/preview-branches)
|
package/docs/versioning.mdx
CHANGED
|
@@ -47,6 +47,8 @@ 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.
|
|
51
|
+
|
|
50
52
|
## Retries and reattempts
|
|
51
53
|
|
|
52
54
|
When a task has an uncaught error it will [retry](/errors-retrying), assuming you have not set `maxAttempts` to 0. Retries are locked to the original version of the run.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/sdk",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.13",
|
|
4
4
|
"description": "trigger.dev Node.JS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -66,30 +66,18 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@opentelemetry/api": "1.9.1",
|
|
68
68
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
69
|
-
"@trigger.dev/core": "4.5.
|
|
70
|
-
"
|
|
71
|
-
"cronstrue": "^2.21.0",
|
|
72
|
-
"debug": "^4.3.4",
|
|
73
|
-
"evt": "^2.4.13",
|
|
74
|
-
"slug": "^6.0.0",
|
|
75
|
-
"ulid": "^2.3.0",
|
|
76
|
-
"uncrypto": "^0.1.3",
|
|
77
|
-
"ws": "^8.11.0"
|
|
69
|
+
"@trigger.dev/core": "4.5.13",
|
|
70
|
+
"uncrypto": "^0.1.3"
|
|
78
71
|
},
|
|
79
72
|
"devDependencies": {
|
|
80
73
|
"@ai-sdk/provider": "3.0.8",
|
|
81
74
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
82
|
-
"@types/debug": "^4.1.7",
|
|
83
75
|
"@types/react": "^19.2.14",
|
|
84
|
-
"@types/slug": "^5.0.3",
|
|
85
|
-
"@types/ws": "^8.5.3",
|
|
86
76
|
"ai": "^6.0.116",
|
|
87
77
|
"ai-v7": "npm:ai@7.0.0-canary.159",
|
|
88
|
-
"encoding": "^0.1.13",
|
|
89
78
|
"rimraf": "^6.0.1",
|
|
90
79
|
"tshy": "^4.1.3",
|
|
91
80
|
"tsx": "4.17.0",
|
|
92
|
-
"typed-emitter": "^2.1.0",
|
|
93
81
|
"typescript": "7.0.2",
|
|
94
82
|
"zod": "3.25.76"
|
|
95
83
|
},
|