@trigger.dev/sdk 4.7.3 → 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.
- package/dist/commonjs/v3/ai.d.ts +26 -0
- package/dist/commonjs/v3/ai.js +7 -5
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/concurrencyLimits.d.ts +37 -7
- package/dist/commonjs/v3/concurrencyLimits.js +38 -70
- package/dist/commonjs/v3/concurrencyLimits.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +1 -1
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/query.d.ts +434 -1
- package/dist/commonjs/v3/query.js +115 -0
- package/dist/commonjs/v3/query.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +22 -1
- package/dist/commonjs/v3/runs.js +6 -3
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +26 -0
- package/dist/esm/v3/ai.js +7 -5
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/concurrencyLimits.d.ts +37 -7
- package/dist/esm/v3/concurrencyLimits.js +38 -70
- package/dist/esm/v3/concurrencyLimits.js.map +1 -1
- package/dist/esm/v3/index.d.ts +1 -1
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/query.d.ts +434 -1
- package/dist/esm/v3/query.js +115 -0
- package/dist/esm/v3/query.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +22 -1
- package/dist/esm/v3/runs.js +6 -3
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/actions.mdx +6 -1
- package/docs/ai-chat/backend.mdx +47 -0
- package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
- package/docs/ai-chat/patterns/sub-agents.mdx +33 -0
- package/docs/ai-chat/pending-messages.mdx +2 -0
- package/docs/ai-chat/reference.mdx +53 -2
- package/docs/ai-chat/transcript-storage.mdx +1 -1
- package/docs/apikeys.mdx +9 -7
- package/docs/billing-limits.mdx +1 -1
- package/docs/cli-env-commands.mdx +5 -4
- package/docs/cli-init-commands.mdx +27 -1
- package/docs/cli-login-commands.mdx +20 -0
- package/docs/cli-projects-commands.mdx +13 -1
- package/docs/cli-runs-commands.mdx +3 -2
- package/docs/cli-tasks-commands.mdx +95 -0
- package/docs/cli-update-commands.mdx +9 -3
- package/docs/cli-whoami-commands.mdx +12 -0
- package/docs/concurrency.mdx +32 -0
- package/docs/config/config-file.mdx +58 -0
- package/docs/config/extensions/audioWaveform.mdx +4 -1
- package/docs/config/extensions/overview.mdx +2 -0
- package/docs/config/extensions/prismaExtension.mdx +6 -7
- package/docs/config/extensions/puppeteer.mdx +3 -5
- package/docs/config/extensions/pythonExtension.mdx +9 -1
- package/docs/config/extensions/syncEnvVars.mdx +6 -0
- package/docs/deploy-environment-variables.mdx +5 -1
- package/docs/deployment/atomic-deployment.mdx +5 -3
- package/docs/deployment/dev-branches.mdx +5 -5
- package/docs/deployment/overview.mdx +9 -8
- package/docs/deployment/preview-branches.mdx +7 -4
- package/docs/errors-retrying.mdx +4 -4
- package/docs/github-actions.mdx +3 -3
- package/docs/how-it-works.mdx +5 -5
- package/docs/introduction.mdx +6 -0
- package/docs/limits.mdx +32 -8
- package/docs/logging.mdx +1 -1
- package/docs/machines.mdx +1 -1
- package/docs/manual-setup.mdx +1 -1
- package/docs/mcp-introduction.mdx +8 -7
- package/docs/mcp-tools.mdx +113 -3
- package/docs/migrating-from-v3.mdx +1 -1
- package/docs/observability/dashboards.mdx +64 -0
- package/docs/observability/query.mdx +6 -2
- package/docs/private-networking/aws-console-setup.mdx +1 -1
- package/docs/private-networking/overview.mdx +1 -1
- package/docs/quick-start.mdx +3 -40
- package/docs/realtime/auth.mdx +1 -1
- package/docs/realtime/backend/input-streams.mdx +159 -0
- package/docs/realtime/backend/streams.mdx +25 -10
- package/docs/realtime/how-it-works.mdx +1 -1
- package/docs/realtime/react-hooks/overview.mdx +1 -1
- package/docs/realtime/react-hooks/streams.mdx +2 -2
- package/docs/realtime/react-hooks/subscribe.mdx +19 -3
- package/docs/realtime/react-hooks/triggering.mdx +2 -2
- package/docs/realtime/react-hooks/use-wait-token.mdx +1 -1
- package/docs/realtime/run-object.mdx +47 -24
- package/docs/replaying.mdx +26 -1
- package/docs/reports.mdx +4 -2
- package/docs/run-tests.mdx +2 -2
- package/docs/run-usage.mdx +3 -3
- package/docs/runs/heartbeats.mdx +2 -2
- package/docs/runs/list-best-practices.mdx +234 -0
- package/docs/runs/max-duration.mdx +4 -0
- package/docs/runs/metadata.mdx +7 -10
- package/docs/runs.mdx +18 -8
- package/docs/self-hosting/env/supervisor.mdx +3 -0
- package/docs/self-hosting/env/webapp.mdx +5 -0
- package/docs/self-hosting/overview.mdx +26 -0
- package/docs/tags.mdx +6 -0
- package/docs/tasks/scheduled.mdx +11 -5
- package/docs/triggering.mdx +8 -0
- package/docs/troubleshooting-alerts.mdx +102 -3
- package/docs/troubleshooting.mdx +1 -1
- package/docs/upgrading-packages.mdx +3 -3
- package/docs/vercel-integration.mdx +13 -3
- package/docs/versioning.mdx +1 -1
- package/docs/wait-for-token.mdx +3 -3
- package/docs/webhooks/channels.mdx +158 -0
- package/docs/webhooks/connect.mdx +84 -0
- package/docs/webhooks/deliveries.mdx +103 -0
- package/docs/webhooks/filters.mdx +144 -0
- package/docs/webhooks/human-in-the-loop.mdx +162 -0
- package/docs/webhooks/linear.mdx +190 -0
- package/docs/webhooks/overview.mdx +119 -0
- package/docs/webhooks/session-routing.mdx +145 -0
- package/docs/webhooks/slack.mdx +397 -0
- package/docs/webhooks/sources.mdx +221 -0
- package/docs/webhooks/waiters.mdx +194 -0
- package/package.json +3 -2
|
@@ -7,7 +7,6 @@ description: "Use these commands to list, inspect, replay and cancel runs from y
|
|
|
7
7
|
import CommonOptions from "/snippets/cli-options-common.mdx";
|
|
8
8
|
import ConfigFileOptions from "/snippets/cli-options-config-file.mdx";
|
|
9
9
|
import ProjectRefOptions from "/snippets/cli-options-project-ref.mdx";
|
|
10
|
-
import BranchOptions from "/snippets/cli-options-branch.mdx";
|
|
11
10
|
|
|
12
11
|
## runs list
|
|
13
12
|
|
|
@@ -85,7 +84,9 @@ npx trigger.dev@latest runs cancel run_abc123
|
|
|
85
84
|
|
|
86
85
|
<ConfigFileOptions />
|
|
87
86
|
<ProjectRefOptions />
|
|
88
|
-
<
|
|
87
|
+
<ParamField body="Branch" type="--branch | -b">
|
|
88
|
+
Required when using `--env preview`. Specify the branch, e.g. `--branch my-branch` or `-b my-branch`. With `--env dev`, it defaults to the same [dev branch](/deployment/dev-branches) as the dev command.
|
|
89
|
+
</ParamField>
|
|
89
90
|
|
|
90
91
|
### Common options
|
|
91
92
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "CLI tasks commands"
|
|
3
|
+
sidebarTitle: "tasks"
|
|
4
|
+
description: "Use these commands to trigger tasks from your terminal."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import CommonOptions from "/snippets/cli-options-common.mdx";
|
|
8
|
+
import ConfigFileOptions from "/snippets/cli-options-config-file.mdx";
|
|
9
|
+
import ProjectRefOptions from "/snippets/cli-options-project-ref.mdx";
|
|
10
|
+
|
|
11
|
+
## tasks trigger
|
|
12
|
+
|
|
13
|
+
Triggers a task and prints the run ID and its dashboard URL. It runs in the `dev` environment unless you pass `--env`, so start the [dev command](/cli-dev-commands) first.
|
|
14
|
+
|
|
15
|
+
<CodeGroup>
|
|
16
|
+
|
|
17
|
+
```bash npm
|
|
18
|
+
npx trigger.dev@latest tasks trigger hello-world --payload '{"name":"Ada"}'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash pnpm
|
|
22
|
+
pnpm dlx trigger.dev@latest tasks trigger hello-world --payload '{"name":"Ada"}'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```bash yarn
|
|
26
|
+
yarn dlx trigger.dev@latest tasks trigger hello-world --payload '{"name":"Ada"}'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
</CodeGroup>
|
|
30
|
+
|
|
31
|
+
Add `--wait` to wait for the run to finish. It prints the run's output, or its error and exits with code 1 if the run failed, which makes it useful in scripts and for coding agents testing a task:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx trigger.dev@latest tasks trigger hello-world --payload '{"name":"Ada"}' --wait
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The command fails without creating a run if the current version has no task with that ID. In `dev`, it warns you when the dev command isn't running, because the run waits in the queue until it starts.
|
|
38
|
+
|
|
39
|
+
<ParamField body="Payload" type="--payload">
|
|
40
|
+
The payload as JSON, e.g. `--payload '{"name":"Ada"}'`. Without it, the task gets no payload.
|
|
41
|
+
</ParamField>
|
|
42
|
+
|
|
43
|
+
<ParamField body="Payload file" type="--payload-file">
|
|
44
|
+
Read the payload from a JSON file instead.
|
|
45
|
+
</ParamField>
|
|
46
|
+
|
|
47
|
+
<ParamField body="Wait" type="--wait">
|
|
48
|
+
Wait for the run to finish, then print its output or error.
|
|
49
|
+
</ParamField>
|
|
50
|
+
|
|
51
|
+
<ParamField body="Timeout" type="--timeout">
|
|
52
|
+
With `--wait`, stop waiting after this many seconds and exit with code 1.
|
|
53
|
+
</ParamField>
|
|
54
|
+
|
|
55
|
+
<ParamField body="Tag" type="--tag">
|
|
56
|
+
A tag to add to the run. Repeat it to add more than one, e.g. `--tag cli --tag test`.
|
|
57
|
+
</ParamField>
|
|
58
|
+
|
|
59
|
+
<ParamField body="Idempotency key" type="--idempotency-key">
|
|
60
|
+
If a run with this key already exists, return it instead of creating a new one. See [idempotency](/idempotency).
|
|
61
|
+
</ParamField>
|
|
62
|
+
|
|
63
|
+
<ParamField body="Delay" type="--delay">
|
|
64
|
+
Wait before running, e.g. `30s`, `5m` or an ISO 8601 date.
|
|
65
|
+
</ParamField>
|
|
66
|
+
|
|
67
|
+
<ParamField body="TTL" type="--ttl">
|
|
68
|
+
Expire the run if it hasn't started within this time, e.g. `10m`.
|
|
69
|
+
</ParamField>
|
|
70
|
+
|
|
71
|
+
<ParamField body="Queue" type="--queue">
|
|
72
|
+
The queue to run in, instead of the queue set on the task.
|
|
73
|
+
</ParamField>
|
|
74
|
+
|
|
75
|
+
<ParamField body="Machine" type="--machine">
|
|
76
|
+
The machine to run on, e.g. `small-2x`. See [machines](/machines). Has no effect in `dev`.
|
|
77
|
+
</ParamField>
|
|
78
|
+
|
|
79
|
+
## Options
|
|
80
|
+
|
|
81
|
+
<ParamField body="Environment" type="--env | -e">
|
|
82
|
+
The environment to use: `dev`, `prod`, `staging` or `preview`. Defaults to `dev`.
|
|
83
|
+
</ParamField>
|
|
84
|
+
|
|
85
|
+
<ConfigFileOptions />
|
|
86
|
+
<ProjectRefOptions />
|
|
87
|
+
<ParamField body="Branch" type="--branch | -b">
|
|
88
|
+
The branch to use. Required with `--env preview`. In `dev`, it defaults to the same [dev branch](/deployment/dev-branches) as the dev command.
|
|
89
|
+
</ParamField>
|
|
90
|
+
|
|
91
|
+
### Common options
|
|
92
|
+
|
|
93
|
+
These options are available on most commands.
|
|
94
|
+
|
|
95
|
+
<CommonOptions />
|
|
@@ -14,19 +14,25 @@ Run the command like this:
|
|
|
14
14
|
<CodeGroup>
|
|
15
15
|
|
|
16
16
|
```bash npm
|
|
17
|
-
npx trigger.dev@latest update
|
|
17
|
+
npx trigger.dev@latest update [path]
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```bash pnpm
|
|
21
|
-
pnpm dlx trigger.dev@latest update
|
|
21
|
+
pnpm dlx trigger.dev@latest update [path]
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
```bash yarn
|
|
25
|
-
yarn dlx trigger.dev@latest update
|
|
25
|
+
yarn dlx trigger.dev@latest update [path]
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
</CodeGroup>
|
|
29
29
|
|
|
30
|
+
## Arguments
|
|
31
|
+
|
|
32
|
+
<ParamField body="Project path" type="[path]">
|
|
33
|
+
The directory that contains the `package.json` file. Defaults to `.`.
|
|
34
|
+
</ParamField>
|
|
35
|
+
|
|
30
36
|
## Options
|
|
31
37
|
|
|
32
38
|
### Common options
|
|
@@ -26,6 +26,18 @@ yarn dlx trigger.dev@latest whoami
|
|
|
26
26
|
|
|
27
27
|
## Options
|
|
28
28
|
|
|
29
|
+
<ParamField body="Config file" type="-c, --config <config file>">
|
|
30
|
+
The name of the config file.
|
|
31
|
+
</ParamField>
|
|
32
|
+
|
|
33
|
+
<ParamField body="Project ref" type="-p, --project-ref <project ref>">
|
|
34
|
+
The project ref. Overrides the project in the config file.
|
|
35
|
+
</ParamField>
|
|
36
|
+
|
|
37
|
+
<ParamField body="Env file" type="--env-file <env file>">
|
|
38
|
+
Path to a `.env` file to read `TRIGGER_PROJECT_REF` from. Defaults to `.env`, `.env.development`, `.env.local`, `.env.development.local` and `dev.vars` in the current directory.
|
|
39
|
+
</ParamField>
|
|
40
|
+
|
|
29
41
|
### Common options
|
|
30
42
|
|
|
31
43
|
These options are available on most commands.
|
package/docs/concurrency.mdx
CHANGED
|
@@ -367,6 +367,38 @@ await concurrencyLimits.reset("openai");
|
|
|
367
367
|
|
|
368
368
|
Overrides survive deploys: redeploying your code keeps an active override until you reset it.
|
|
369
369
|
|
|
370
|
+
### Overriding a limit for one key
|
|
371
|
+
|
|
372
|
+
Pass `concurrencyKey` to override a limit's `perKey` for a single key, for example to let one session run more (or fewer) runs at once than the limit allows every other key:
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import { concurrencyLimits } from "@trigger.dev/sdk";
|
|
376
|
+
|
|
377
|
+
// this session may run 3 at once under "subagents", for the next 7 days
|
|
378
|
+
await concurrencyLimits.override("subagents", {
|
|
379
|
+
concurrencyKey: sessionId,
|
|
380
|
+
perKey: 3,
|
|
381
|
+
ttl: "7d",
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// read it back: the key's bound, the override, and when it expires
|
|
385
|
+
const view = await concurrencyLimits.retrieve("subagents", { concurrencyKey: sessionId });
|
|
386
|
+
console.log(view.perKey.override, view.perKey.expiresAt, view.running);
|
|
387
|
+
|
|
388
|
+
// clear it early
|
|
389
|
+
await concurrencyLimits.reset("subagents", { concurrencyKey: sessionId });
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
A per-key override behaves differently from a limit override:
|
|
393
|
+
|
|
394
|
+
- **It is temporary.** It expires after `ttl` (a duration such as `"7d"` or a number of seconds). The default is 7 days and the maximum is 30 days. Call `override` again to extend it. Nothing warns you when it lapses, so check `expiresAt` if a key must keep its cap for longer than a week.
|
|
395
|
+
- **It changes one limit only.** The limit's own bounds and every other limit the run holds are untouched. A tenant-wide limit keeps applying on top of a per-session override.
|
|
396
|
+
- **It applies to every task holding the limit**, because the key's pool under a shared named limit is one pool.
|
|
397
|
+
- **It needs a `perKey` to override.** A limit declared with only a `total` has no per-key bound, so the call is rejected, and if a later deploy removes a limit's `perKey` its per-key overrides stop applying. A task's inline limit is addressed as `task/<task-id>`. `total` is not per key, so `concurrencyKey` goes with `perKey` (and optionally `ttl`) and never with `total`; the SDK's types enforce this.
|
|
398
|
+
- **`perKey: 0` blocks the key.** A paused limit stays paused whatever the override says.
|
|
399
|
+
- **It does not stop runs.** Lowering a key's cap takes effect at the next run to start; runs already executing continue.
|
|
400
|
+
- **`reset(name)` without a key leaves per-key overrides alone**; clear them with `reset(name, { concurrencyKey })` or let them expire.
|
|
401
|
+
|
|
370
402
|
### Pausing a limit
|
|
371
403
|
|
|
372
404
|
Pause a limit to stop every run holding it from being dequeued; runs that are already executing continue to completion. The configured bounds are kept, and resuming restores them:
|
|
@@ -267,6 +267,64 @@ export default defineConfig({
|
|
|
267
267
|
});
|
|
268
268
|
```
|
|
269
269
|
|
|
270
|
+
### Span processors
|
|
271
|
+
|
|
272
|
+
Span processors run on every span before it is exported, to Trigger.dev and to any `exporters` you configure. Use them to redact or drop span content before it reaches the run trace.
|
|
273
|
+
|
|
274
|
+
```ts trigger.config.ts
|
|
275
|
+
import { defineConfig } from "@trigger.dev/sdk";
|
|
276
|
+
import type { AttributeValue, Attributes } from "@opentelemetry/api";
|
|
277
|
+
import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
278
|
+
|
|
279
|
+
const EMAIL = /[\w.+-]+@[\w-]+\.[\w.]+/g;
|
|
280
|
+
|
|
281
|
+
function redact(value: AttributeValue | undefined): AttributeValue | undefined {
|
|
282
|
+
if (typeof value === "string") return value.replace(EMAIL, "[email]");
|
|
283
|
+
// Some attributes are string arrays, like the messages sent mid-turn
|
|
284
|
+
if (Array.isArray(value)) {
|
|
285
|
+
return value.map((item) =>
|
|
286
|
+
typeof item === "string" ? item.replace(EMAIL, "[email]") : item
|
|
287
|
+
) as AttributeValue;
|
|
288
|
+
}
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function scrub(attributes: Attributes) {
|
|
293
|
+
for (const key of Object.keys(attributes)) attributes[key] = redact(attributes[key]);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const redactEmails: SpanProcessor = {
|
|
297
|
+
onStart: () => {},
|
|
298
|
+
// The span is complete here and still writable
|
|
299
|
+
onEnding: (span) => {
|
|
300
|
+
scrub(span.attributes);
|
|
301
|
+
for (const event of span.events) scrub(event.attributes ?? {});
|
|
302
|
+
},
|
|
303
|
+
onEnd: () => {},
|
|
304
|
+
forceFlush: async () => {},
|
|
305
|
+
shutdown: async () => {},
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export default defineConfig({
|
|
309
|
+
project: "<project ref>",
|
|
310
|
+
telemetry: {
|
|
311
|
+
spanProcessors: [redactEmails],
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Your processors run ahead of ours, so they also see the in-progress copy of each span that the dashboard shows while a span is open. Redact in `onEnding`:
|
|
317
|
+
|
|
318
|
+
- `onStart` runs before we add the run context, so it sees only the attributes the span was started with.
|
|
319
|
+
- In `onEnd` the span is read-only and `setAttribute` does nothing. Writing to `span.attributes` directly still works.
|
|
320
|
+
- Content can also sit in span events (exceptions, for example). Events are on `span.events`.
|
|
321
|
+
|
|
322
|
+
After each call we restore the few attributes we use to link a span to its run, such as the run, task and attempt ids. Everything else can be redacted, including run tags and idempotency keys. If a processor throws, the error is reported and the span is still exported.
|
|
323
|
+
|
|
324
|
+
<Note>
|
|
325
|
+
Span processors only change span content. Run payloads and outputs, and the messages on a chat agent's session streams, are stored as sent. For chat agents, see [Redact chat content from traces](/ai-chat/patterns/redacting-telemetry).
|
|
326
|
+
</Note>
|
|
327
|
+
|
|
270
328
|
## Runtime
|
|
271
329
|
|
|
272
330
|
If you don't set a `runtime`, your tasks run on the current Node.js LTS. Setting `runtime: "node"` does the same thing — see the Node.js versions section below to pin a specific version instead.
|
|
@@ -14,7 +14,10 @@ export default defineConfig({
|
|
|
14
14
|
project: "<project ref>",
|
|
15
15
|
// Your other config settings...
|
|
16
16
|
build: {
|
|
17
|
-
extensions: [audioWaveform()], // uses
|
|
17
|
+
extensions: [audioWaveform()], // uses version 1.10.1 of audiowaveform by default
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
```
|
|
21
|
+
|
|
22
|
+
To use a different version, pass the `version` and `checksum` options to `audioWaveform()`.
|
|
23
|
+
|
|
@@ -51,6 +51,8 @@ Trigger.dev provides a set of built-in extensions that you can use to customize
|
|
|
51
51
|
| [prismaExtension](/config/extensions/prismaExtension) | Using prisma in your Trigger.dev tasks |
|
|
52
52
|
| [pythonExtension](/config/extensions/pythonExtension) | Execute Python scripts in your project |
|
|
53
53
|
| [puppeteer](/config/extensions/puppeteer) | Use Puppeteer in your Trigger.dev tasks |
|
|
54
|
+
| [playwright](/config/extensions/playwright) | Use Playwright in your Trigger.dev tasks |
|
|
55
|
+
| [lightpanda](/config/extensions/lightpanda) | Use Lightpanda in your Trigger.dev tasks |
|
|
54
56
|
| [ffmpeg](/config/extensions/ffmpeg) | Use FFmpeg in your Trigger.dev tasks |
|
|
55
57
|
| [aptGet](/config/extensions/aptGet) | Install system packages in your build image |
|
|
56
58
|
| [additionalFiles](/config/extensions/additionalFiles) | Copy additional files to your build image |
|
|
@@ -189,7 +189,7 @@ prismaExtension({
|
|
|
189
189
|
"scripts": {
|
|
190
190
|
"prebuild": "prisma generate",
|
|
191
191
|
"dev": "trigger dev",
|
|
192
|
-
"deploy": "trigger deploy"
|
|
192
|
+
"deploy": "trigger deploy --env prod"
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
```
|
|
@@ -331,7 +331,7 @@ steps:
|
|
|
331
331
|
- name: Generate Prisma client
|
|
332
332
|
run: npx prisma@6.19.0 generate
|
|
333
333
|
- name: Deploy Trigger.dev
|
|
334
|
-
run: npx trigger.dev@4.1.1 deploy
|
|
334
|
+
run: npx trigger.dev@4.1.1 deploy --env prod
|
|
335
335
|
env:
|
|
336
336
|
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
|
|
337
337
|
```
|
|
@@ -641,7 +641,7 @@ prismaExtension({
|
|
|
641
641
|
```prisma
|
|
642
642
|
generator client {
|
|
643
643
|
provider = "prisma-client-js"
|
|
644
|
-
binaryTargets = ["native", "
|
|
644
|
+
binaryTargets = ["native", "debian-openssl-3.0.x"]
|
|
645
645
|
}
|
|
646
646
|
```
|
|
647
647
|
|
|
@@ -885,7 +885,7 @@ export const db = new PrismaClient({
|
|
|
885
885
|
generator client {
|
|
886
886
|
provider = "prisma-client-js"
|
|
887
887
|
output = "../src/generated/prisma"
|
|
888
|
-
binaryTargets = ["native", "
|
|
888
|
+
binaryTargets = ["native", "debian-openssl-3.0.x"]
|
|
889
889
|
}
|
|
890
890
|
|
|
891
891
|
datasource db {
|
|
@@ -902,7 +902,7 @@ datasource db {
|
|
|
902
902
|
"scripts": {
|
|
903
903
|
"generate": "prisma generate",
|
|
904
904
|
"dev": "pnpm generate && trigger dev",
|
|
905
|
-
"deploy": "trigger deploy"
|
|
905
|
+
"deploy": "trigger deploy --env prod"
|
|
906
906
|
}
|
|
907
907
|
}
|
|
908
908
|
```
|
|
@@ -913,7 +913,6 @@ datasource db {
|
|
|
913
913
|
prismaExtension({
|
|
914
914
|
mode: "engine-only",
|
|
915
915
|
version: "6.19.0",
|
|
916
|
-
binaryTarget: "linux-arm64-openssl-3.0.x",
|
|
917
916
|
});
|
|
918
917
|
```
|
|
919
918
|
|
|
@@ -976,7 +975,7 @@ export default defineConfig({
|
|
|
976
975
|
"scripts": {
|
|
977
976
|
"generate": "prisma generate",
|
|
978
977
|
"dev": "pnpm generate && trigger dev",
|
|
979
|
-
"deploy": "trigger deploy"
|
|
978
|
+
"deploy": "trigger deploy --env prod"
|
|
980
979
|
}
|
|
981
980
|
}
|
|
982
981
|
```
|
|
@@ -4,6 +4,8 @@ sidebarTitle: "puppeteer"
|
|
|
4
4
|
description: "Use the puppeteer build extension to enable support for Puppeteer in your project"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
import ScrapingWarning from "/snippets/web-scraping-warning.mdx";
|
|
8
|
+
|
|
7
9
|
<ScrapingWarning />
|
|
8
10
|
|
|
9
11
|
To use Puppeteer in your project, add these build settings to your `trigger.config.ts` file:
|
|
@@ -21,10 +23,6 @@ export default defineConfig({
|
|
|
21
23
|
});
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
PUPPETEER_EXECUTABLE_PATH: "/usr/bin/google-chrome-stable",
|
|
28
|
-
```
|
|
26
|
+
The extension installs Chrome and sets `PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable` for deployed builds automatically, so you do not need to set it. Don't set it in your Dev environment: the extension does nothing in Dev, and locally Puppeteer uses the browser it downloads on install.
|
|
29
27
|
|
|
30
28
|
Follow [this example](/guides/examples/puppeteer) to get setup with Trigger.dev and Puppeteer in your project.
|
|
@@ -103,6 +103,14 @@ export default defineConfig({
|
|
|
103
103
|
|
|
104
104
|
This will install the packages specified in the `requirements.txt` file during the build process. You can then use these packages in your Python scripts.
|
|
105
105
|
|
|
106
|
+
You can also list requirements inline with the `requirements` option instead. You can't use it together with `requirementsFile`:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
pythonExtension({
|
|
110
|
+
requirements: ["pandas"],
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
106
114
|
<Note>
|
|
107
115
|
The `requirementsFile` option is only available in production mode. In development mode, you can
|
|
108
116
|
install the required packages manually using the `pip` command.
|
|
@@ -145,7 +153,7 @@ export const myStreamingScript = task({
|
|
|
145
153
|
const result = python.stream.runScript("./python/my_script.py", ["hello", "world"]);
|
|
146
154
|
|
|
147
155
|
// result is an async iterable/readable stream
|
|
148
|
-
for await (const chunk of
|
|
156
|
+
for await (const chunk of result) {
|
|
149
157
|
console.log(chunk);
|
|
150
158
|
}
|
|
151
159
|
},
|
|
@@ -31,6 +31,9 @@ The callback is passed a context object with the following properties:
|
|
|
31
31
|
- `environment`: The environment name that the task is being deployed to (e.g. `production`, `staging`, etc.)
|
|
32
32
|
- `projectRef`: The project ref of the Trigger.dev project
|
|
33
33
|
- `env`: The environment variables that are currently set in the Trigger.dev project
|
|
34
|
+
- `branch`: The preview branch name, if deploying to a preview branch (optional)
|
|
35
|
+
|
|
36
|
+
`syncEnvVars` also accepts a second argument with an `override` option (defaults to `true`). When `true`, synced variables overwrite variables with the same name that are already set in the environment you're deploying to. Set it to `false` to only sync variables that aren't set there yet.
|
|
34
37
|
|
|
35
38
|
### Marking variables as secrets
|
|
36
39
|
|
|
@@ -168,12 +171,15 @@ export default defineConfig({
|
|
|
168
171
|
projectId: "your-vercel-project-id",
|
|
169
172
|
vercelAccessToken: "your-vercel-access-token", // optional, we recommend to keep it as env variable
|
|
170
173
|
vercelTeamId: "your-vercel-team-id", // optional
|
|
174
|
+
branch: "your-preview-branch", // optional
|
|
171
175
|
}),
|
|
172
176
|
],
|
|
173
177
|
},
|
|
174
178
|
});
|
|
175
179
|
```
|
|
176
180
|
|
|
181
|
+
The `branch` option filters branch-specific Vercel variables for preview branches. It defaults to the `VERCEL_PREVIEW_BRANCH` environment variable, then the Trigger.dev preview branch. The access token is read from `VERCEL_ACCESS_TOKEN`, falling back to `VERCEL_TOKEN`.
|
|
182
|
+
|
|
177
183
|
### syncNeonEnvVars
|
|
178
184
|
|
|
179
185
|
The `syncNeonEnvVars` build extension syncs environment variables from your Neon database project to Trigger.dev. It automatically detects branches and builds the appropriate database connection strings for your environment.
|
|
@@ -3,6 +3,8 @@ title: "Environment Variables"
|
|
|
3
3
|
description: "Any environment variables used in your tasks need to be added so the deployed code will run successfully."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { RollingOut } from "/snippets/feature-status.jsx";
|
|
7
|
+
|
|
6
8
|
An environment variable in Node.js is accessed in your code using `process.env.MY_ENV_VAR`.
|
|
7
9
|
|
|
8
10
|
We deploy your tasks and scale them up and down when they are triggered. So any environment variables you use in your tasks need to accessible to us so your code will run successfully.
|
|
@@ -14,7 +16,7 @@ We deploy your tasks and scale them up and down when they are triggered. So any
|
|
|
14
16
|
<Steps>
|
|
15
17
|
|
|
16
18
|
<Step title="Go to the Environment Variables page">
|
|
17
|
-
In the sidebar select the "Environment Variables" page, then press the "
|
|
19
|
+
In the sidebar select the "Environment Variables" page, then press the "Add new"
|
|
18
20
|
button. 
|
|
19
21
|
</Step>
|
|
20
22
|
|
|
@@ -43,6 +45,8 @@ When creating an environment variable, you can mark it as a **Secret**. Secret v
|
|
|
43
45
|
|
|
44
46
|
You can edit an environment variable's values. You cannot edit the key name, you must delete and create a new one.
|
|
45
47
|
|
|
48
|
+
<RollingOut flag="allowEmptyEnvironmentVariableValues" />
|
|
49
|
+
|
|
46
50
|
<Note>
|
|
47
51
|
An empty string is a valid value. Saving a variable with an empty value stores it as an empty
|
|
48
52
|
string (your task sees the variable set to `""`), which is different from deleting the variable
|
|
@@ -60,7 +60,7 @@ The id is free-form and opaque to Trigger.dev — a commit SHA, a release tag, a
|
|
|
60
60
|
<Step title="Deploy your tasks with an external id">
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
npx trigger.dev@latest deploy --external-id "$(git rev-parse HEAD)"
|
|
63
|
+
npx trigger.dev@latest deploy --env prod --external-id "$(git rev-parse HEAD)"
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
</Step>
|
|
@@ -240,7 +240,7 @@ Read the commit in the place where it *is* available, and write it into both hal
|
|
|
240
240
|
|
|
241
241
|
```bash
|
|
242
242
|
# 1. Deploy side — name the deployment after the commit.
|
|
243
|
-
npx trigger.dev@latest deploy --external-id "$(git rev-parse HEAD)"
|
|
243
|
+
npx trigger.dev@latest deploy --env prod --external-id "$(git rev-parse HEAD)"
|
|
244
244
|
|
|
245
245
|
# 2. Application side — give the running app the same value.
|
|
246
246
|
TRIGGER_EXTERNAL_DEPLOYMENT_ID=<the-same-commit-sha>
|
|
@@ -385,7 +385,7 @@ If you filter deploys by path, derive the id from the same filter on both sides
|
|
|
385
385
|
|
|
386
386
|
```bash
|
|
387
387
|
TASK_ID=$(git log -1 --format=%H -- trigger/)
|
|
388
|
-
npx trigger.dev@latest deploy --external-id "$TASK_ID"
|
|
388
|
+
npx trigger.dev@latest deploy --env prod --external-id "$TASK_ID"
|
|
389
389
|
```
|
|
390
390
|
|
|
391
391
|
Compute the same value where you set your app's variable. In GitHub Actions this needs `fetch-depth: 0` on `actions/checkout` — the default shallow clone can't see far enough back.
|
|
@@ -443,6 +443,8 @@ If you use the [Vercel integration](/vercel-integration), version skew protectio
|
|
|
443
443
|
|
|
444
444
|
This covers production, staging and preview alike.
|
|
445
445
|
|
|
446
|
+
In production, the integration also gates the release on the task build. Each production deployment from your production branch carries a blocking **Trigger.dev Build** check, so a commit whose tasks fail to build never goes live and its runs never wait on a deployment that won't arrive. Re-run the **Trigger.dev deployment** check in GitHub to build that commit again. See [Production waits for your tasks](/vercel-integration#production-waits-for-your-tasks).
|
|
447
|
+
|
|
446
448
|
### Opting out
|
|
447
449
|
|
|
448
450
|
Set `TRIGGER_AUTOMATIC_SKEW_VERSION_PROTECTION` to `0` on your Vercel project. A `0` you set today stays `0` through every subsequent build.
|
|
@@ -59,7 +59,7 @@ You can also set the branch with the `TRIGGER_DEV_BRANCH` environment variable i
|
|
|
59
59
|
|
|
60
60
|
## Archive a branch
|
|
61
61
|
|
|
62
|
-
Archive a branch from the CLI when you no longer need it.
|
|
62
|
+
Archive a branch from the CLI when you no longer need it. Pass the branch with `--branch` (or set `TRIGGER_DEV_BRANCH`); it's required, and the `default` branch can't be archived:
|
|
63
63
|
|
|
64
64
|
<CodeGroup>
|
|
65
65
|
|
|
@@ -81,12 +81,12 @@ You can also create and archive branches from the **Dev branches** page in the d
|
|
|
81
81
|
|
|
82
82
|
## Limits on active branches
|
|
83
83
|
|
|
84
|
-
Each branch has its own concurrency, so we limit how many can
|
|
84
|
+
Each branch has its own concurrency, so we limit how many dev branches each developer can have active per project. The `default` development environment counts toward this limit. If you are at the limit when you run `dev --branch`, the CLI automatically archives up to 3 of your branches that have no connected dev session and have been idle for over an hour, to make room. You can also archive a branch any time to free a slot.
|
|
85
85
|
|
|
86
86
|
| Plan | Active dev branches |
|
|
87
87
|
| ----- | ------------------- |
|
|
88
|
-
| Free |
|
|
89
|
-
| Hobby |
|
|
90
|
-
| Pro |
|
|
88
|
+
| Free | 50 |
|
|
89
|
+
| Hobby | 50 |
|
|
90
|
+
| Pro | 50 |
|
|
91
91
|
|
|
92
92
|
Need more? [Get in touch](https://trigger.dev/contact) and we'll raise the limit.
|
|
@@ -6,7 +6,7 @@ description: "Learn how to deploy your tasks to Trigger.dev."
|
|
|
6
6
|
|
|
7
7
|
import CorepackError from "/snippets/corepack-error.mdx";
|
|
8
8
|
|
|
9
|
-
Before you can run production workloads on Trigger.dev, you need to deploy your tasks. The
|
|
9
|
+
Before you can run production workloads on Trigger.dev, you need to deploy your tasks. The manual way to do this is the [deploy CLI command](/cli-deploy-commands). You can also deploy automatically with the [GitHub integration](/github-integration) or the [Vercel integration](/vercel-integration):
|
|
10
10
|
|
|
11
11
|
<CodeGroup>
|
|
12
12
|
|
|
@@ -100,8 +100,9 @@ When you deploy, the version number is automatically incremented, and the new ve
|
|
|
100
100
|
The current version defines which version of the code new task runs will execute against. When a task run starts, it is locked to the current version. This ensures that the task run is not affected by changes to the code. Retries of the task run will also be locked to the original version.
|
|
101
101
|
|
|
102
102
|
<Note>
|
|
103
|
-
When you Replay a run in the dashboard we
|
|
104
|
-
|
|
103
|
+
When you Replay a run in the dashboard we create a new run that uses the current version by default
|
|
104
|
+
(in deployed environments you can pick a specific version in the replay dialog), not necessarily
|
|
105
|
+
the version of the original run.
|
|
105
106
|
</Note>
|
|
106
107
|
|
|
107
108
|
### Version locking
|
|
@@ -161,7 +162,7 @@ To keep your app and tasks in sync without coordinating promotion at all, see [a
|
|
|
161
162
|
|
|
162
163
|
## Staging deploys
|
|
163
164
|
|
|
164
|
-
|
|
165
|
+
Use the `--env` flag to choose the environment you deploy to. If you don't pass it, the `deploy` command deploys to the `prod` environment, unless `TRIGGER_ACCESS_TOKEN` holds an API key for another environment. To deploy to staging:
|
|
165
166
|
|
|
166
167
|
```bash
|
|
167
168
|
npx trigger.dev deploy --env staging
|
|
@@ -186,10 +187,10 @@ For additional environments beyond `prod` and `staging`, you can use [preview br
|
|
|
186
187
|
|
|
187
188
|
## Local builds
|
|
188
189
|
|
|
189
|
-
By default we use a remote build provider to speed up builds. However, you can also force the build to happen locally on your machine using the `--
|
|
190
|
+
By default we use a remote build provider to speed up builds. However, you can also force the build to happen locally on your machine using the `--local-build` flag:
|
|
190
191
|
|
|
191
192
|
```bash
|
|
192
|
-
npx trigger.dev deploy --
|
|
193
|
+
npx trigger.dev deploy --local-build
|
|
193
194
|
```
|
|
194
195
|
|
|
195
196
|
<Tip>
|
|
@@ -205,7 +206,7 @@ To use local builds, you need the following tools installed on your machine:
|
|
|
205
206
|
|
|
206
207
|
## Environment variables
|
|
207
208
|
|
|
208
|
-
To add custom environment variables to your deployed tasks, you need to add them to your project in the Trigger.dev dashboard, or automatically sync them using our [syncEnvVars](/config/
|
|
209
|
+
To add custom environment variables to your deployed tasks, you need to add them to your project in the Trigger.dev dashboard, or automatically sync them using our [syncEnvVars](/config/extensions/syncEnvVars) or [syncVercelEnvVars](/config/extensions/syncEnvVars#syncvercelenvvars) build extensions.
|
|
209
210
|
|
|
210
211
|
For more information on environment variables, see our [environment variables](/deploy-environment-variables) guide.
|
|
211
212
|
|
|
@@ -235,7 +236,7 @@ You can run the deploy command with `--log-level debug` at the end. This will pr
|
|
|
235
236
|
|
|
236
237
|
There should be a link below the error message to the full build logs on your machine. Take a look at these to see what went wrong. Join [our Discord](https://trigger.dev/discord) and you share it privately with us if you can't figure out what's going wrong. Do NOT share these publicly as the verbose logs might reveal private information about your project.
|
|
237
238
|
|
|
238
|
-
Sometimes these errors are caused by upstream availability issues with our remote build provider. In this case, you can try deploying with a local build using the `--
|
|
239
|
+
Sometimes these errors are caused by upstream availability issues with our remote build provider. In this case, you can try deploying with a local build using the `--local-build` flag. Refer to the [Local builds](#local-builds) section for more information.
|
|
239
240
|
|
|
240
241
|
#### `Deployment encountered an error`
|
|
241
242
|
|
|
@@ -18,10 +18,13 @@ The process to use preview branches looks like this:
|
|
|
18
18
|
3. Create a named **Trigger only** API key in the Preview environment, then trigger runs using the key (`TRIGGER_SECRET_KEY`) and branch name (`TRIGGER_PREVIEW_BRANCH`).
|
|
19
19
|
4. Archive the preview branch when the branch is done.
|
|
20
20
|
|
|
21
|
-
There are
|
|
21
|
+
There are three main ways to do this:
|
|
22
22
|
|
|
23
|
-
1. Automatically: using GitHub
|
|
24
|
-
2.
|
|
23
|
+
1. Automatically: using the [GitHub integration](/github-integration), which deploys pull requests to preview branches and archives them when the PR is merged or closed, without a GitHub Action.
|
|
24
|
+
2. Automatically: using GitHub Actions, if you deploy from your own CI workflows.
|
|
25
|
+
3. Manually: in the dashboard and/or using the CLI.
|
|
26
|
+
|
|
27
|
+
Pick one of the automatic options, not both.
|
|
25
28
|
|
|
26
29
|
### Limits on active preview branches
|
|
27
30
|
|
|
@@ -144,7 +147,7 @@ Creating and deploying a preview branch manually is easy:
|
|
|
144
147
|
npx trigger.dev@latest deploy --env preview
|
|
145
148
|
```
|
|
146
149
|
|
|
147
|
-
This will create and deploy a preview branch, automatically detecting the git branch. If for some reason the auto-detection doesn't work it will let you know and tell you do this:
|
|
150
|
+
This will create and deploy a preview branch, automatically detecting the git branch. When your CI checks out a detached HEAD, the branch is read from the CI provider's branch variable instead (GitLab, Bitbucket, CircleCI, Buildkite, Travis CI, Jenkins and Azure Pipelines are supported). If for some reason the auto-detection doesn't work it will let you know and tell you do this:
|
|
148
151
|
|
|
149
152
|
```bash
|
|
150
153
|
npx trigger.dev@latest deploy --env preview --branch your-branch-name
|
package/docs/errors-retrying.mdx
CHANGED
|
@@ -15,8 +15,8 @@ You can configure retrying in two ways:
|
|
|
15
15
|
<Note>Task-level retry settings override the defaults in your `trigger.config` file.</Note>
|
|
16
16
|
|
|
17
17
|
<Note>
|
|
18
|
-
By default when you create your project using the CLI init command
|
|
19
|
-
environment. You can
|
|
18
|
+
By default when you create your project using the CLI init command, retrying is enabled in the DEV
|
|
19
|
+
environment. You can disable it by setting `enabledInDev: false` in your [trigger.config file](/config/config-file).
|
|
20
20
|
</Note>
|
|
21
21
|
|
|
22
22
|
## A simple example with OpenAI
|
|
@@ -112,7 +112,7 @@ import { task, logger, retry } from "@trigger.dev/sdk";
|
|
|
112
112
|
|
|
113
113
|
export const taskWithFetchRetries = task({
|
|
114
114
|
id: "task-with-fetch-retries",
|
|
115
|
-
run: async (
|
|
115
|
+
run: async (payload: any, { ctx }) => {
|
|
116
116
|
//if the Response is a 429 (too many requests), it will retry using the data from the response. A lot of good APIs send these headers.
|
|
117
117
|
const headersResponse = await retry.fetch("http://my.host/test-headers", {
|
|
118
118
|
retry: {
|
|
@@ -182,7 +182,7 @@ export const taskWithFetchRetries = task({
|
|
|
182
182
|
|
|
183
183
|
## Advanced error handling and retrying
|
|
184
184
|
|
|
185
|
-
We provide a `catchError` callback on the task and
|
|
185
|
+
We provide a `catchError` callback on the task, and you can register one globally with `tasks.catchError()`. This gets called when an uncaught error is thrown in your task.
|
|
186
186
|
|
|
187
187
|
You can
|
|
188
188
|
|