@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.
Files changed (119) 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/concurrencyLimits.d.ts +37 -7
  5. package/dist/commonjs/v3/concurrencyLimits.js +38 -70
  6. package/dist/commonjs/v3/concurrencyLimits.js.map +1 -1
  7. package/dist/commonjs/v3/index.d.ts +1 -1
  8. package/dist/commonjs/v3/index.js.map +1 -1
  9. package/dist/commonjs/v3/query.d.ts +434 -1
  10. package/dist/commonjs/v3/query.js +115 -0
  11. package/dist/commonjs/v3/query.js.map +1 -1
  12. package/dist/commonjs/v3/runs.d.ts +22 -1
  13. package/dist/commonjs/v3/runs.js +6 -3
  14. package/dist/commonjs/v3/runs.js.map +1 -1
  15. package/dist/commonjs/version.js +1 -1
  16. package/dist/esm/v3/ai.d.ts +26 -0
  17. package/dist/esm/v3/ai.js +7 -5
  18. package/dist/esm/v3/ai.js.map +1 -1
  19. package/dist/esm/v3/concurrencyLimits.d.ts +37 -7
  20. package/dist/esm/v3/concurrencyLimits.js +38 -70
  21. package/dist/esm/v3/concurrencyLimits.js.map +1 -1
  22. package/dist/esm/v3/index.d.ts +1 -1
  23. package/dist/esm/v3/index.js.map +1 -1
  24. package/dist/esm/v3/query.d.ts +434 -1
  25. package/dist/esm/v3/query.js +115 -0
  26. package/dist/esm/v3/query.js.map +1 -1
  27. package/dist/esm/v3/runs.d.ts +22 -1
  28. package/dist/esm/v3/runs.js +6 -3
  29. package/dist/esm/v3/runs.js.map +1 -1
  30. package/dist/esm/version.js +1 -1
  31. package/docs/ai-chat/actions.mdx +6 -1
  32. package/docs/ai-chat/backend.mdx +47 -0
  33. package/docs/ai-chat/patterns/redacting-telemetry.mdx +117 -0
  34. package/docs/ai-chat/patterns/sub-agents.mdx +33 -0
  35. package/docs/ai-chat/pending-messages.mdx +2 -0
  36. package/docs/ai-chat/reference.mdx +53 -2
  37. package/docs/ai-chat/transcript-storage.mdx +1 -1
  38. package/docs/apikeys.mdx +9 -7
  39. package/docs/billing-limits.mdx +1 -1
  40. package/docs/cli-env-commands.mdx +5 -4
  41. package/docs/cli-init-commands.mdx +27 -1
  42. package/docs/cli-login-commands.mdx +20 -0
  43. package/docs/cli-projects-commands.mdx +13 -1
  44. package/docs/cli-runs-commands.mdx +3 -2
  45. package/docs/cli-tasks-commands.mdx +95 -0
  46. package/docs/cli-update-commands.mdx +9 -3
  47. package/docs/cli-whoami-commands.mdx +12 -0
  48. package/docs/concurrency.mdx +32 -0
  49. package/docs/config/config-file.mdx +58 -0
  50. package/docs/config/extensions/audioWaveform.mdx +4 -1
  51. package/docs/config/extensions/overview.mdx +2 -0
  52. package/docs/config/extensions/prismaExtension.mdx +6 -7
  53. package/docs/config/extensions/puppeteer.mdx +3 -5
  54. package/docs/config/extensions/pythonExtension.mdx +9 -1
  55. package/docs/config/extensions/syncEnvVars.mdx +6 -0
  56. package/docs/deploy-environment-variables.mdx +5 -1
  57. package/docs/deployment/atomic-deployment.mdx +5 -3
  58. package/docs/deployment/dev-branches.mdx +5 -5
  59. package/docs/deployment/overview.mdx +9 -8
  60. package/docs/deployment/preview-branches.mdx +7 -4
  61. package/docs/errors-retrying.mdx +4 -4
  62. package/docs/github-actions.mdx +3 -3
  63. package/docs/how-it-works.mdx +5 -5
  64. package/docs/introduction.mdx +6 -0
  65. package/docs/limits.mdx +32 -8
  66. package/docs/logging.mdx +1 -1
  67. package/docs/machines.mdx +1 -1
  68. package/docs/manual-setup.mdx +1 -1
  69. package/docs/mcp-introduction.mdx +8 -7
  70. package/docs/mcp-tools.mdx +113 -3
  71. package/docs/migrating-from-v3.mdx +1 -1
  72. package/docs/observability/dashboards.mdx +64 -0
  73. package/docs/observability/query.mdx +6 -2
  74. package/docs/private-networking/aws-console-setup.mdx +1 -1
  75. package/docs/private-networking/overview.mdx +1 -1
  76. package/docs/quick-start.mdx +3 -40
  77. package/docs/realtime/auth.mdx +1 -1
  78. package/docs/realtime/backend/input-streams.mdx +159 -0
  79. package/docs/realtime/backend/streams.mdx +25 -10
  80. package/docs/realtime/how-it-works.mdx +1 -1
  81. package/docs/realtime/react-hooks/overview.mdx +1 -1
  82. package/docs/realtime/react-hooks/streams.mdx +2 -2
  83. package/docs/realtime/react-hooks/subscribe.mdx +19 -3
  84. package/docs/realtime/react-hooks/triggering.mdx +2 -2
  85. package/docs/realtime/react-hooks/use-wait-token.mdx +1 -1
  86. package/docs/realtime/run-object.mdx +47 -24
  87. package/docs/replaying.mdx +26 -1
  88. package/docs/reports.mdx +4 -2
  89. package/docs/run-tests.mdx +2 -2
  90. package/docs/run-usage.mdx +3 -3
  91. package/docs/runs/heartbeats.mdx +2 -2
  92. package/docs/runs/list-best-practices.mdx +234 -0
  93. package/docs/runs/max-duration.mdx +4 -0
  94. package/docs/runs/metadata.mdx +7 -10
  95. package/docs/runs.mdx +18 -8
  96. package/docs/self-hosting/env/supervisor.mdx +3 -0
  97. package/docs/self-hosting/env/webapp.mdx +5 -0
  98. package/docs/self-hosting/overview.mdx +26 -0
  99. package/docs/tags.mdx +6 -0
  100. package/docs/tasks/scheduled.mdx +11 -5
  101. package/docs/triggering.mdx +8 -0
  102. package/docs/troubleshooting-alerts.mdx +102 -3
  103. package/docs/troubleshooting.mdx +1 -1
  104. package/docs/upgrading-packages.mdx +3 -3
  105. package/docs/vercel-integration.mdx +13 -3
  106. package/docs/versioning.mdx +1 -1
  107. package/docs/wait-for-token.mdx +3 -3
  108. package/docs/webhooks/channels.mdx +158 -0
  109. package/docs/webhooks/connect.mdx +84 -0
  110. package/docs/webhooks/deliveries.mdx +103 -0
  111. package/docs/webhooks/filters.mdx +144 -0
  112. package/docs/webhooks/human-in-the-loop.mdx +162 -0
  113. package/docs/webhooks/linear.mdx +190 -0
  114. package/docs/webhooks/overview.mdx +119 -0
  115. package/docs/webhooks/session-routing.mdx +145 -0
  116. package/docs/webhooks/slack.mdx +397 -0
  117. package/docs/webhooks/sources.mdx +221 -0
  118. package/docs/webhooks/waiters.mdx +194 -0
  119. package/package.json +3 -2
@@ -0,0 +1,159 @@
1
+ ---
2
+ title: Input Streams
3
+ sidebarTitle: Input Streams
4
+ description: Send data into running tasks from your backend code
5
+ ---
6
+
7
+ The Input Streams API allows you to send data into running Trigger.dev tasks from your backend code. This enables bidirectional communication — while [output streams](/realtime/backend/streams) let you read data from tasks, input streams let you push data into them.
8
+
9
+ <Note>
10
+ To learn how to receive input stream data inside your tasks, see [Input
11
+ Streams](/tasks/streams#input-streams) in the Streams doc.
12
+ </Note>
13
+
14
+ <Tip>
15
+ Input streams are keyed by `runId` — they're correct for sending data to a specific live run. If you need a bidirectional channel that survives run boundaries (e.g. a chat that resumes tomorrow, an agent coordinated across many runs), look at [`chat.agent`](/ai-chat/overview): it's built on a durable Session row that owns its runs and exposes the same consumer-side API (`on` / `once` / `wait` / `waitWithIdleTimeout`) on its `.in` channel.
16
+ </Tip>
17
+
18
+ ## Sending data to a running task
19
+
20
+ ### Using defined input streams (Recommended)
21
+
22
+ The recommended approach is to use [defined input streams](/tasks/streams#defining-input-streams) for full type safety:
23
+
24
+ ```ts
25
+ import { cancelSignal, approval } from "./trigger/streams";
26
+
27
+ // Cancel a running AI stream
28
+ await cancelSignal.send(runId, { reason: "User clicked stop" });
29
+
30
+ // Approve a draft
31
+ await approval.send(runId, { approved: true, reviewer: "alice@example.com" });
32
+ ```
33
+
34
+ The `.send()` method is fully typed — the data parameter must match the generic type you defined on the input stream.
35
+
36
+ <Note>
37
+ `.send()` works the same regardless of how the task is listening — whether it uses `.wait()`
38
+ (suspending), `.once()` (non-suspending), or `.on()` (continuous). The sender doesn't need to know
39
+ how the task is consuming the data. See [Input Streams](/tasks/streams#input-streams) for details on each
40
+ receiving method.
41
+ </Note>
42
+
43
+ ## Practical examples
44
+
45
+ ### Cancel from a Next.js API route
46
+
47
+ ```ts app/api/cancel/route.ts
48
+ import { cancelStream } from "@/trigger/streams";
49
+
50
+ export async function POST(req: Request) {
51
+ const { runId } = await req.json();
52
+
53
+ await cancelStream.send(runId, { reason: "User clicked stop" });
54
+
55
+ return Response.json({ cancelled: true });
56
+ }
57
+ ```
58
+
59
+ ### Approval workflow API
60
+
61
+ ```ts app/api/approve/route.ts
62
+ import { approval } from "@/trigger/streams";
63
+
64
+ export async function POST(req: Request) {
65
+ const { runId, approved, reviewer } = await req.json();
66
+
67
+ await approval.send(runId, {
68
+ approved,
69
+ reviewer,
70
+ });
71
+
72
+ return Response.json({ success: true });
73
+ }
74
+ ```
75
+
76
+ ### Remix action handler
77
+
78
+ ```ts app/routes/api.approve.ts
79
+ import { json, type ActionFunctionArgs } from "@remix-run/node";
80
+ import { approval } from "~/trigger/streams";
81
+
82
+ export async function action({ request }: ActionFunctionArgs) {
83
+ const formData = await request.formData();
84
+ const runId = formData.get("runId") as string;
85
+ const approved = formData.get("approved") === "true";
86
+ const reviewer = formData.get("reviewer") as string;
87
+
88
+ await approval.send(runId, { approved, reviewer });
89
+
90
+ return json({ success: true });
91
+ }
92
+ ```
93
+
94
+ ### Express handler
95
+
96
+ ```ts
97
+ import express from "express";
98
+ import { cancelSignal } from "./trigger/streams";
99
+
100
+ const app = express();
101
+ app.use(express.json());
102
+
103
+ app.post("/api/cancel", async (req, res) => {
104
+ const { runId, reason } = req.body;
105
+
106
+ await cancelSignal.send(runId, { reason });
107
+
108
+ res.json({ cancelled: true });
109
+ });
110
+ ```
111
+
112
+ ### Sending from another task
113
+
114
+ You can send input stream data from one task to another running task:
115
+
116
+ ```ts
117
+ import { task } from "@trigger.dev/sdk";
118
+ import { approval } from "./streams";
119
+
120
+ export const reviewerTask = task({
121
+ id: "auto-reviewer",
122
+ run: async (payload: { targetRunId: string }) => {
123
+ // Perform automated review logic...
124
+ const isApproved = await performReview();
125
+
126
+ // Send approval to the waiting task
127
+ await approval.send(payload.targetRunId, {
128
+ approved: isApproved,
129
+ reviewer: "auto-reviewer",
130
+ });
131
+ },
132
+ });
133
+ ```
134
+
135
+ ## Error handling
136
+
137
+ The `.send()` method will throw if:
138
+
139
+ - The run has already completed, failed, or been canceled
140
+ - The payload exceeds the 1MB size limit
141
+ - The run ID is invalid
142
+
143
+ ```ts
144
+ import { cancelSignal } from "./trigger/streams";
145
+
146
+ try {
147
+ await cancelSignal.send(runId, { reason: "User clicked stop" });
148
+ } catch (error) {
149
+ console.error("Failed to send:", error);
150
+ // Handle the error — the run may have already completed
151
+ }
152
+ ```
153
+
154
+ ## Important notes
155
+
156
+ - Maximum payload size per `.send()` call is **1MB**
157
+ - You cannot send data to a completed, failed, or canceled run
158
+ - Data sent before a listener is registered inside the task is **buffered** and delivered when a listener attaches
159
+ - Input streams require the current streams implementation (v2 is the default in SDK 4.1.0+). See [Streams](/tasks/streams) for details.
@@ -90,18 +90,16 @@ async function consumeWithTimeout(runId: string) {
90
90
  timeoutInSeconds: 120, // Wait up to 2 minutes for data
91
91
  });
92
92
 
93
- try {
94
- for await (const chunk of stream) {
95
- console.log("Received chunk:", chunk);
96
- }
97
- } catch (error) {
98
- if (error.name === "TimeoutError") {
99
- console.log("Stream timed out");
100
- }
93
+ for await (const chunk of stream) {
94
+ console.log("Received chunk:", chunk);
101
95
  }
96
+
97
+ // The loop ends normally if no data arrives within the timeout
102
98
  }
103
99
  ```
104
100
 
101
+ If no data arrives within `timeoutInSeconds`, the stream closes and the `for await` loop ends without throwing an error. To detect a timeout, track whether you received the chunk you expected to be last.
102
+
105
103
  ### Start index
106
104
 
107
105
  Resume reading from a specific chunk index (useful for reconnection scenarios):
@@ -122,6 +120,25 @@ async function resumeStream(runId: string, lastChunkIndex: number) {
122
120
  }
123
121
  ```
124
122
 
123
+ ### Start from latest
124
+
125
+ Pass `from: "latest"` to start reading at the end of the stream instead of replaying its history. You may still receive the most recent existing chunk before new chunks arrive. The default is `"beginning"`, which replays the full history first. `from` is ignored when `startIndex` is set:
126
+
127
+ ```ts
128
+ import { streams } from "@trigger.dev/sdk";
129
+ import { aiStream } from "./trigger/streams";
130
+
131
+ async function watchLive(runId: string) {
132
+ const stream = await aiStream.read(runId, {
133
+ from: "latest", // Start at the end of the stream instead of replaying history
134
+ });
135
+
136
+ for await (const chunk of stream) {
137
+ console.log("Received chunk:", chunk);
138
+ }
139
+ }
140
+ ```
141
+
125
142
  ### Abort signal
126
143
 
127
144
  Use an `AbortSignal` to cancel stream reading:
@@ -181,8 +198,6 @@ async function advancedStreamConsumption(runId: string) {
181
198
  } catch (error) {
182
199
  if (error.name === "AbortError") {
183
200
  console.log("Stream was cancelled");
184
- } else if (error.name === "TimeoutError") {
185
- console.log("Stream timed out");
186
201
  } else {
187
202
  console.error("Stream error:", error);
188
203
  }
@@ -80,7 +80,7 @@ See our [run metadata docs](/runs/metadata) for more on how to write tasks that
80
80
 
81
81
  You can combine run metadata with the Realtime API to bridge the gap between your trigger.dev tasks and your applications in two ways:
82
82
 
83
- 1. Using our [React hooks](/realtime/react-hooks/subscribe#using-metadata) to subscribe to metadata updates and update your UI in real-time.
83
+ 1. Using our [React hooks](/realtime/react-hooks/subscribe#using-metadata-to-show-progress-in-your-ui) to subscribe to metadata updates and update your UI in real-time.
84
84
  2. Using our [backend functions](/realtime/backend) to subscribe to metadata updates in your backend.
85
85
 
86
86
  ## Limits
@@ -23,7 +23,7 @@ pnpm add @trigger.dev/react-hooks
23
23
  ```
24
24
 
25
25
  ```bash yarn
26
- yarn install @trigger.dev/react-hooks
26
+ yarn add @trigger.dev/react-hooks
27
27
  ```
28
28
 
29
29
  </CodeGroup>
@@ -466,7 +466,7 @@ function MyComponent({ runId, publicAccessToken }: { runId: string; publicAccess
466
466
 
467
467
  ### Throttling updates
468
468
 
469
- The `useRealtimeRunWithStreams` hook accepts an `experimental_throttleInMs` option to throttle the updates from the server. This can be useful if you are getting too many updates and want to reduce the number of updates.
469
+ The `useRealtimeRunWithStreams` hook accepts a `throttleInMs` option to throttle the updates from the server. This can be useful if you are getting too many updates and want to reduce the number of updates.
470
470
 
471
471
  ```tsx
472
472
  import { useRealtimeRunWithStreams } from "@trigger.dev/react-hooks";
@@ -480,7 +480,7 @@ export function MyComponent({
480
480
  }) {
481
481
  const { run, streams, error } = useRealtimeRunWithStreams(runId, {
482
482
  accessToken: publicAccessToken,
483
- experimental_throttleInMs: 1000, // Throttle updates to once per second
483
+ throttleInMs: 1000, // Throttle updates to once per second
484
484
  });
485
485
 
486
486
  if (error) return <div>Error: {error.message}</div>;
@@ -119,6 +119,15 @@ export function RunStatusBadge({
119
119
 
120
120
  You can skip any of: `payload`, `output`, `metadata`, `startedAt`, `delayUntil`, `queuedAt`, `expiredAt`, `completedAt`, `number`, `isTest`, `usageDurationMs`, `costInCents`, `baseCostInCents`, `ttl`, `payloadType`, `outputType`, `runTags`, `error`. The `useRealtimeRunsWithTag` hook also accepts a `skipColumns` option in the same way.
121
121
 
122
+ By default the hook stops subscribing once the run completes. Pass `stopOnCompletion: false` to keep receiving updates after completion, for example metadata updates from child runs.
123
+
124
+ ```tsx
125
+ const { run, error } = useRealtimeRun(runId, {
126
+ accessToken: publicAccessToken,
127
+ stopOnCompletion: false, // Keep receiving updates after the run completes
128
+ });
129
+ ```
130
+
122
131
  See our [run object reference](/realtime/run-object) for the complete schema and [How it Works documentation](/realtime/how-it-works) for more technical details.
123
132
 
124
133
  ### useRealtimeRunsWithTag
@@ -198,6 +207,14 @@ export function MyComponent({ tag }: { tag: string }) {
198
207
  }
199
208
  ```
200
209
 
210
+ You can also pass an array of tags, and use the `createdAt` option to only subscribe to runs created within a recent period. It accepts a duration string such as `"30m"` or `"1h"` and is applied when the subscription starts. The default and maximum lookback is 24 hours, so longer durations are capped at 24 hours.
211
+
212
+ ```tsx
213
+ const { runs, error } = useRealtimeRunsWithTag(["user:123", "report"], {
214
+ createdAt: "1h", // Only runs created in the last hour
215
+ });
216
+ ```
217
+
201
218
  ### useRealtimeBatch
202
219
 
203
220
  The `useRealtimeBatch` hook allows you to subscribe to a batch of runs by its the batch ID.
@@ -246,13 +263,12 @@ export function ProgressMonitor({
246
263
  runId: string;
247
264
  publicAccessToken: string;
248
265
  }) {
249
- const { run, error, isLoading } = useRealtimeRun(runId, {
266
+ const { run, error } = useRealtimeRun(runId, {
250
267
  accessToken: publicAccessToken,
251
268
  });
252
269
 
253
- if (isLoading) return <div>Loading run...</div>;
254
270
  if (error) return <div>Error: {error.message}</div>;
255
- if (!run) return <div>Run not found</div>;
271
+ if (!run) return <div>Loading run...</div>;
256
272
 
257
273
  const progress = run.metadata?.progress as
258
274
  | {
@@ -84,8 +84,8 @@ export function MyComponent({ publicAccessToken }: { publicAccessToken: string }
84
84
  accessToken: publicAccessToken, // 👈 this is the "trigger" token
85
85
  });
86
86
 
87
- // use the handle object to preserve type-safety 👇
88
- const { run, error: realtimeError } = useRealtimeRun(handle, {
87
+ // pass the run ID and the task type to preserve type-safety 👇
88
+ const { run, error: realtimeError } = useRealtimeRun<typeof myTask>(handle?.id, {
89
89
  accessToken: handle?.publicAccessToken,
90
90
  enabled: !!handle, // Only subscribe to the run if the handle is available
91
91
  });
@@ -15,7 +15,7 @@ const token = await wait.createToken({
15
15
 
16
16
  return {
17
17
  tokenId: token.id,
18
- publicToken: token.publicAccessToken, // An automatically generated public access token that expires in 1 hour
18
+ publicToken: token.publicAccessToken, // An automatically generated public access token that expires in 24 hours
19
19
  };
20
20
  ```
21
21
 
@@ -36,31 +36,26 @@ Type-safety is supported for the run object, so you can infer the types of the r
36
36
  Timestamp when the run was last updated.
37
37
  </ParamField>
38
38
 
39
- <ParamField path="number" type="number" required>
40
- Sequential number assigned to the run.
41
- </ParamField>
42
-
43
39
  <ParamField path="status" type="RunStatus" required>
44
40
  Current status of the run.
45
41
 
46
42
  <Accordion title="RunStatus enum">
47
43
 
48
- | Status | Description |
49
- | -------------------- | --------------------------------------------------------------------------------------------------------- |
50
- | `WAITING_FOR_DEPLOY` | Task hasn't been deployed yet but is waiting to be executed |
51
- | `QUEUED` | Run is waiting to be executed by a worker |
52
- | `EXECUTING` | Run is currently being executed by a worker |
53
- | `REATTEMPTING` | Run has failed and is waiting to be retried |
54
- | `FROZEN` | Run has been paused by the system, and will be resumed by the system |
55
- | `COMPLETED` | Run has been completed successfully |
56
- | `CANCELED` | Run has been canceled by the user |
57
- | `FAILED` | Run has been completed with errors |
58
- | `CRASHED` | Run has crashed and won't be retried, most likely the worker ran out of resources, e.g. memory or storage |
59
- | `INTERRUPTED` | Run was interrupted during execution, mostly this happens in development environments |
60
- | `SYSTEM_FAILURE` | Run has failed to complete, due to an error in the system |
61
- | `DELAYED` | Run has been scheduled to run at a specific time |
62
- | `EXPIRED` | Run has expired and won't be executed |
63
- | `TIMED_OUT` | Run has reached it's maxDuration and has been stopped |
44
+ | Status | Description |
45
+ | ----------------- | --------------------------------------------------------------------------------------------------------- |
46
+ | `PENDING_VERSION` | Run is waiting for a version update because it cannot execute without additional information |
47
+ | `QUEUED` | Run is waiting to be executed by a worker |
48
+ | `DEQUEUED` | Run has been dequeued and is being sent to a worker to start executing |
49
+ | `EXECUTING` | Run is currently being executed by a worker |
50
+ | `WAITING` | Run has been paused by the system, and will be resumed by the system |
51
+ | `COMPLETED` | Run has been completed successfully |
52
+ | `CANCELED` | Run has been canceled by the user |
53
+ | `FAILED` | Run has been completed with errors |
54
+ | `CRASHED` | Run has crashed and won't be retried, most likely the worker ran out of resources, e.g. memory or storage |
55
+ | `SYSTEM_FAILURE` | Run has failed to complete, due to an error in the system |
56
+ | `DELAYED` | Run has been scheduled to run at a specific time |
57
+ | `EXPIRED` | Run has expired and won't be executed |
58
+ | `TIMED_OUT` | Run has reached it's maxDuration and has been stopped |
64
59
 
65
60
  </Accordion>
66
61
  </ParamField>
@@ -89,10 +84,6 @@ Type-safety is supported for the run object, so you can infer the types of the r
89
84
  Timestamp when the run expired.
90
85
  </ParamField>
91
86
 
92
- <ParamField path="ttl" type="string">
93
- Time-to-live duration for the run.
94
- </ParamField>
95
-
96
87
  <ParamField path="finishedAt" type="Date">
97
88
  Timestamp when the run finished.
98
89
  </ParamField>
@@ -121,6 +112,38 @@ Type-safety is supported for the run object, so you can infer the types of the r
121
112
  Indicates whether this is a test run.
122
113
  </ParamField>
123
114
 
115
+ <ParamField path="realtimeStreams" type="string[]" required>
116
+ Names of the Realtime streams on the run.
117
+ </ParamField>
118
+
119
+ <ParamField path="isQueued" type="boolean" required>
120
+ `true` if the run is queued, delayed or waiting for a version update.
121
+ </ParamField>
122
+
123
+ <ParamField path="isExecuting" type="boolean" required>
124
+ `true` if the run is dequeued or executing.
125
+ </ParamField>
126
+
127
+ <ParamField path="isWaiting" type="boolean" required>
128
+ `true` if the run is waiting.
129
+ </ParamField>
130
+
131
+ <ParamField path="isCompleted" type="boolean" required>
132
+ `true` if the run has finished, either successfully or with any failure status.
133
+ </ParamField>
134
+
135
+ <ParamField path="isFailed" type="boolean" required>
136
+ `true` if the run failed, crashed, hit a system failure, expired or timed out.
137
+ </ParamField>
138
+
139
+ <ParamField path="isSuccess" type="boolean" required>
140
+ `true` if the run completed successfully.
141
+ </ParamField>
142
+
143
+ <ParamField path="isCancelled" type="boolean" required>
144
+ `true` if the run was canceled.
145
+ </ParamField>
146
+
124
147
  ## Type-safety
125
148
 
126
149
  You can infer the types of the run's payload and output by passing the type of the task to the `subscribeToRun` function. This will give you type-safe access to the run's payload and output.
@@ -49,10 +49,35 @@ export const myTask = task({
49
49
 
50
50
  You can replay a run using the SDK:
51
51
 
52
- ```ts
52
+ ```ts Your backend code
53
+ import { runs } from "@trigger.dev/sdk";
54
+
53
55
  const replayedRun = await runs.replay(run.id);
56
+ // { id: "run_cmv6ixfn30008ct9kegazjolu" }
54
57
  ```
55
58
 
59
+ The new run reuses the original run's payload, metadata, tags, queue, concurrency key, and machine. Pass options to override any of them for the new run:
60
+
61
+ ```ts Your backend code
62
+ import { runs } from "@trigger.dev/sdk";
63
+
64
+ const replayedRun = await runs.replay(run.id, {
65
+ payload: { userId: "user_456" },
66
+ metadata: { source: "replay" },
67
+ tags: ["replayed"],
68
+ machine: "large-1x",
69
+ delay: "10m",
70
+ });
71
+ ```
72
+
73
+ The options use the same names as [`trigger()` options](/triggering): `payload`, `metadata`, `tags`, `queue`, `concurrencyKey`, `machine`, `version`, `region`, `delay`, `ttl`, `idempotencyKey`, `idempotencyKeyTTL`, `maxAttempts`, `maxDuration`, and `priority`. If you leave out `payload`, `metadata`, `tags`, `queue`, `concurrencyKey`, or `machine`, the new run uses the original run's value. The other options fall back to the task's current defaults, and without `version` the replay runs on the current version. The replay always runs in the same environment as the original run.
74
+
75
+ A `queue` must already exist in the environment, and a `version` must be a version deployed to it. Otherwise the replay fails with an error and no run is created.
76
+
77
+ A replay starts a new run, so the API key or token you replay with needs permission to trigger the task as well as write access to the run.
78
+
79
+ The SDK serializes a `payload` override the same way `trigger()` does, so values like `Date`, `BigInt`, `Map` and `Set` reach the task with their types.
80
+
56
81
  When you call `trigger()` or `batchTrigger()` on a task you receive back a run handle which has an `id` property. You can use that `id` to replay the run.
57
82
 
58
83
  You can also access the run id from inside a run. You could write this to your database and then replay it later.
package/docs/reports.mdx CHANGED
@@ -123,7 +123,7 @@ The MCP server also registers a `report` prompt, which hosts that support MCP pr
123
123
 
124
124
  ### HTTP API: `GET /api/v1/reports/:key`
125
125
 
126
- The endpoint behind every surface. It accepts a `period` and a `format`, and authenticates with a token scoped to read the report's query tables (`read:query`).
126
+ The endpoint behind every surface. It accepts a `period` and a `format`, and authenticates with an environment secret key or a JWT scoped to read the report's query tables (`read:query`).
127
127
 
128
128
  | Query param | Default | Description |
129
129
  | --- | --- | --- |
@@ -134,9 +134,11 @@ The endpoint behind every surface. It accepts a `period` and a `format`, and aut
134
134
 
135
135
  ```bash
136
136
  curl "https://api.trigger.dev/api/v1/reports/health?period=24h&format=json" \
137
- -H "Authorization: Bearer $TRIGGER_ACCESS_TOKEN"
137
+ -H "Authorization: Bearer $TRIGGER_SECRET_KEY"
138
138
  ```
139
139
 
140
+ The environment comes from the key. Use an environment secret key, or a JWT scoped `read:query` for the report's tables. Personal access tokens are not accepted.
141
+
140
142
  An unknown report key returns `404` with the list of available keys.
141
143
 
142
144
  ## Next steps
@@ -7,8 +7,8 @@ You can run a test for any of your tasks, in any environment, from the dashboard
7
7
 
8
8
  <Note>
9
9
  There is no longer a "Test" page in the sidebar. You test a task from the task itself: on the
10
- Tasks page open a task (or use the "Test" action next to a task in the Runs list) and press the
11
- "Test" button to open its test page.
10
+ Tasks page use the "Test" action next to a task, or open the task and press "Test task" ("Test
11
+ schedule" for a scheduled task), to open its test page.
12
12
  </Note>
13
13
 
14
14
  On a task's test page you can:
@@ -38,10 +38,10 @@ export const heavyTask = task({
38
38
  }
39
39
  */
40
40
 
41
- // In the cloud product we do not count waits towards the compute cost or duration.
41
+ // In the cloud product we do not count waits longer than 5 seconds towards the compute cost or duration.
42
42
  // We also don't include time between attempts or before the run starts executing your code.
43
43
  // So this line does not affect the cost or duration.
44
- await wait.for({ seconds: 5 });
44
+ await wait.for({ seconds: 10 });
45
45
 
46
46
  // This will give the same result as before the wait.
47
47
  currentUsage = usage.getCurrent();
@@ -57,7 +57,7 @@ export const heavyTask = task({
57
57
 
58
58
  <Note>
59
59
  In Trigger.dev cloud we do not include time between attempts, before your code executes, or waits
60
- towards the compute cost or duration.
60
+ longer than 5 seconds towards the compute cost or duration. Waits of 5 seconds or less still count.
61
61
  </Note>
62
62
 
63
63
  ## Getting the run cost and duration from your backend
@@ -4,7 +4,7 @@ sidebarTitle: "Heartbeats"
4
4
  description: "Keep long-running or CPU-heavy tasks from being marked as stalled."
5
5
  ---
6
6
 
7
- We send a heartbeat from your task to the platform every 30 seconds. If we don't receive a heartbeat within 5 minutes, we mark the run as stalled and stop it with a `TASK_RUN_STALLED_EXECUTING` error.
7
+ We send a heartbeat from your task to the platform every 20 seconds by default for deployed runs (30 seconds in local dev). If we don't receive a heartbeat within 5 minutes, we mark the run as stalled and stop it with a `TASK_RUN_STALLED_EXECUTING` error.
8
8
 
9
9
  Code that blocks the event loop for too long (for example, a tight loop doing synchronous work on a large dataset) can prevent heartbeats from being sent. In that case, use `heartbeats.yield()` inside the loop so the runtime can yield to the event loop and send a heartbeat. You can call it every iteration; the implementation only yields when needed.
10
10
 
@@ -31,7 +31,7 @@ If you see `TASK_RUN_STALLED_EXECUTING`, see [Task run stalled executing](/troub
31
31
 
32
32
  ## Sending progress to Trigger.dev
33
33
 
34
- To stream progress or status updates to the dashboard and your app, use [run metadata](/runs/metadata). Call `metadata.set()` (or `metadata.append()`) as the task runs. The dashboard and [Realtime](/realtime) (including `runs.subscribeToRun` and the React hooks) receive those updates as they happen. See [Progress monitoring](/realtime/backend/subscribe#progress-monitoring) for a full example.
34
+ To stream progress or status updates to the dashboard and your app, use [run metadata](/runs/metadata). Call `metadata.set()` (or `metadata.append()`) as the task runs. The dashboard and [Realtime](/realtime) (including `runs.subscribeToRun` and the React hooks) receive those updates as they happen. See [Subscribe to metadata updates](/realtime/backend/subscribe#subscribe-to-metadata-updates-from-your-tasks) for a full example.
35
35
 
36
36
  ## Sending updates to your own system
37
37