@trigger.dev/sdk 4.5.0-rc.5 → 4.5.0-rc.7

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 (213) hide show
  1. package/dist/commonjs/v3/ai.d.ts +178 -5
  2. package/dist/commonjs/v3/ai.js +603 -119
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/chat-client.js +3 -0
  5. package/dist/commonjs/v3/chat-client.js.map +1 -1
  6. package/dist/commonjs/v3/chat-react.js +10 -7
  7. package/dist/commonjs/v3/chat-react.js.map +1 -1
  8. package/dist/commonjs/v3/chat-server.d.ts +8 -0
  9. package/dist/commonjs/v3/chat-server.js +32 -10
  10. package/dist/commonjs/v3/chat-server.js.map +1 -1
  11. package/dist/commonjs/v3/chat-server.test.js +51 -0
  12. package/dist/commonjs/v3/chat-server.test.js.map +1 -1
  13. package/dist/commonjs/v3/chat.js +34 -6
  14. package/dist/commonjs/v3/chat.js.map +1 -1
  15. package/dist/commonjs/v3/chat.test.js +53 -0
  16. package/dist/commonjs/v3/chat.test.js.map +1 -1
  17. package/dist/commonjs/v3/createStartSessionAction.test.js +30 -0
  18. package/dist/commonjs/v3/createStartSessionAction.test.js.map +1 -1
  19. package/dist/commonjs/v3/sessions.d.ts +11 -6
  20. package/dist/commonjs/v3/sessions.js +10 -5
  21. package/dist/commonjs/v3/sessions.js.map +1 -1
  22. package/dist/commonjs/v3/test/mock-chat-agent.d.ts +6 -0
  23. package/dist/commonjs/v3/test/mock-chat-agent.js +1 -0
  24. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  25. package/dist/commonjs/version.js +1 -1
  26. package/dist/esm/v3/ai.d.ts +178 -5
  27. package/dist/esm/v3/ai.js +603 -120
  28. package/dist/esm/v3/ai.js.map +1 -1
  29. package/dist/esm/v3/chat-client.js +3 -0
  30. package/dist/esm/v3/chat-client.js.map +1 -1
  31. package/dist/esm/v3/chat-react.js +10 -7
  32. package/dist/esm/v3/chat-react.js.map +1 -1
  33. package/dist/esm/v3/chat-server.d.ts +8 -0
  34. package/dist/esm/v3/chat-server.js +32 -10
  35. package/dist/esm/v3/chat-server.js.map +1 -1
  36. package/dist/esm/v3/chat-server.test.js +51 -0
  37. package/dist/esm/v3/chat-server.test.js.map +1 -1
  38. package/dist/esm/v3/chat.js +34 -6
  39. package/dist/esm/v3/chat.js.map +1 -1
  40. package/dist/esm/v3/chat.test.js +53 -0
  41. package/dist/esm/v3/chat.test.js.map +1 -1
  42. package/dist/esm/v3/createStartSessionAction.test.js +30 -0
  43. package/dist/esm/v3/createStartSessionAction.test.js.map +1 -1
  44. package/dist/esm/v3/sessions.d.ts +11 -6
  45. package/dist/esm/v3/sessions.js +10 -5
  46. package/dist/esm/v3/sessions.js.map +1 -1
  47. package/dist/esm/v3/test/mock-chat-agent.d.ts +6 -0
  48. package/dist/esm/v3/test/mock-chat-agent.js +1 -0
  49. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  50. package/dist/esm/version.js +1 -1
  51. package/docs/ai/prompts.mdx +430 -0
  52. package/docs/ai-chat/actions.mdx +115 -0
  53. package/docs/ai-chat/anatomy.mdx +71 -0
  54. package/docs/ai-chat/backend.mdx +817 -0
  55. package/docs/ai-chat/background-injection.mdx +221 -0
  56. package/docs/ai-chat/changelog.mdx +850 -0
  57. package/docs/ai-chat/chat-local.mdx +174 -0
  58. package/docs/ai-chat/client-protocol.mdx +1081 -0
  59. package/docs/ai-chat/compaction.mdx +411 -0
  60. package/docs/ai-chat/custom-agents.mdx +364 -0
  61. package/docs/ai-chat/error-handling.mdx +415 -0
  62. package/docs/ai-chat/fast-starts.mdx +672 -0
  63. package/docs/ai-chat/frontend.mdx +580 -0
  64. package/docs/ai-chat/how-it-works.mdx +230 -0
  65. package/docs/ai-chat/lifecycle-hooks.mdx +530 -0
  66. package/docs/ai-chat/mcp.mdx +101 -0
  67. package/docs/ai-chat/overview.mdx +90 -0
  68. package/docs/ai-chat/patterns/branching-conversations.mdx +284 -0
  69. package/docs/ai-chat/patterns/code-sandbox.mdx +126 -0
  70. package/docs/ai-chat/patterns/database-persistence.mdx +414 -0
  71. package/docs/ai-chat/patterns/human-in-the-loop.mdx +275 -0
  72. package/docs/ai-chat/patterns/large-payloads.mdx +169 -0
  73. package/docs/ai-chat/patterns/oom-resilience.mdx +120 -0
  74. package/docs/ai-chat/patterns/persistence-and-replay.mdx +211 -0
  75. package/docs/ai-chat/patterns/recovery-boot.mdx +230 -0
  76. package/docs/ai-chat/patterns/skills.mdx +221 -0
  77. package/docs/ai-chat/patterns/sub-agents.mdx +383 -0
  78. package/docs/ai-chat/patterns/tool-result-auditing.mdx +148 -0
  79. package/docs/ai-chat/patterns/trusted-edge-signals.mdx +337 -0
  80. package/docs/ai-chat/patterns/version-upgrades.mdx +172 -0
  81. package/docs/ai-chat/pending-messages.mdx +343 -0
  82. package/docs/ai-chat/prompt-caching.mdx +206 -0
  83. package/docs/ai-chat/quick-start.mdx +161 -0
  84. package/docs/ai-chat/reference.mdx +909 -0
  85. package/docs/ai-chat/server-chat.mdx +263 -0
  86. package/docs/ai-chat/sessions.mdx +333 -0
  87. package/docs/ai-chat/testing.mdx +682 -0
  88. package/docs/ai-chat/tools.mdx +191 -0
  89. package/docs/ai-chat/types.mdx +242 -0
  90. package/docs/ai-chat/upgrade-guide.mdx +515 -0
  91. package/docs/apikeys.mdx +54 -0
  92. package/docs/building-with-ai.mdx +261 -0
  93. package/docs/bulk-actions.mdx +49 -0
  94. package/docs/changelog.mdx +6 -0
  95. package/docs/cli-deploy-commands.mdx +9 -0
  96. package/docs/cli-dev-commands.mdx +9 -0
  97. package/docs/cli-dev.mdx +8 -0
  98. package/docs/cli-init-commands.mdx +58 -0
  99. package/docs/cli-introduction.mdx +25 -0
  100. package/docs/cli-list-profiles-commands.mdx +42 -0
  101. package/docs/cli-login-commands.mdx +33 -0
  102. package/docs/cli-logout-commands.mdx +33 -0
  103. package/docs/cli-preview-archive.mdx +59 -0
  104. package/docs/cli-promote-commands.mdx +9 -0
  105. package/docs/cli-switch.mdx +43 -0
  106. package/docs/cli-update-commands.mdx +42 -0
  107. package/docs/cli-whoami-commands.mdx +33 -0
  108. package/docs/community.mdx +6 -0
  109. package/docs/config/config-file.mdx +602 -0
  110. package/docs/config/extensions/additionalFiles.mdx +38 -0
  111. package/docs/config/extensions/additionalPackages.mdx +40 -0
  112. package/docs/config/extensions/aptGet.mdx +34 -0
  113. package/docs/config/extensions/audioWaveform.mdx +20 -0
  114. package/docs/config/extensions/custom.mdx +380 -0
  115. package/docs/config/extensions/emitDecoratorMetadata.mdx +29 -0
  116. package/docs/config/extensions/esbuildPlugin.mdx +31 -0
  117. package/docs/config/extensions/ffmpeg.mdx +45 -0
  118. package/docs/config/extensions/lightpanda.mdx +56 -0
  119. package/docs/config/extensions/overview.mdx +67 -0
  120. package/docs/config/extensions/playwright.mdx +195 -0
  121. package/docs/config/extensions/prismaExtension.mdx +1014 -0
  122. package/docs/config/extensions/puppeteer.mdx +30 -0
  123. package/docs/config/extensions/pythonExtension.mdx +182 -0
  124. package/docs/config/extensions/syncEnvVars.mdx +291 -0
  125. package/docs/context.mdx +235 -0
  126. package/docs/database-connections.mdx +213 -0
  127. package/docs/deploy-environment-variables.mdx +435 -0
  128. package/docs/deployment/atomic-deployment.mdx +172 -0
  129. package/docs/deployment/overview.mdx +257 -0
  130. package/docs/deployment/preview-branches.mdx +224 -0
  131. package/docs/errors-retrying.mdx +379 -0
  132. package/docs/github-actions.mdx +222 -0
  133. package/docs/github-integration.mdx +136 -0
  134. package/docs/github-repo.mdx +8 -0
  135. package/docs/help-email.mdx +6 -0
  136. package/docs/help-slack.mdx +11 -0
  137. package/docs/hidden-tasks.mdx +56 -0
  138. package/docs/how-it-works.mdx +454 -0
  139. package/docs/how-to-reduce-your-spend.mdx +217 -0
  140. package/docs/idempotency.mdx +504 -0
  141. package/docs/introduction.mdx +223 -0
  142. package/docs/limits.mdx +241 -0
  143. package/docs/logging.mdx +195 -0
  144. package/docs/machines.mdx +952 -0
  145. package/docs/manual-setup.mdx +632 -0
  146. package/docs/mcp-agent-rules.mdx +41 -0
  147. package/docs/mcp-introduction.mdx +385 -0
  148. package/docs/mcp-tools.mdx +273 -0
  149. package/docs/migrating-from-v3.mdx +334 -0
  150. package/docs/observability/dashboards.mdx +102 -0
  151. package/docs/observability/query.mdx +585 -0
  152. package/docs/open-source-contributing.mdx +16 -0
  153. package/docs/open-source-self-hosting.mdx +541 -0
  154. package/docs/private-networking/aws-console-setup.mdx +304 -0
  155. package/docs/private-networking/overview.mdx +144 -0
  156. package/docs/private-networking/troubleshooting.mdx +78 -0
  157. package/docs/queue-concurrency.mdx +354 -0
  158. package/docs/quick-start.mdx +97 -0
  159. package/docs/realtime/auth.mdx +208 -0
  160. package/docs/realtime/backend/overview.mdx +45 -0
  161. package/docs/realtime/backend/streams.mdx +418 -0
  162. package/docs/realtime/backend/subscribe.mdx +225 -0
  163. package/docs/realtime/how-it-works.mdx +94 -0
  164. package/docs/realtime/overview.mdx +63 -0
  165. package/docs/realtime/react-hooks/overview.mdx +73 -0
  166. package/docs/realtime/react-hooks/streams.mdx +449 -0
  167. package/docs/realtime/react-hooks/subscribe.mdx +674 -0
  168. package/docs/realtime/react-hooks/swr.mdx +87 -0
  169. package/docs/realtime/react-hooks/triggering.mdx +194 -0
  170. package/docs/realtime/react-hooks/use-wait-token.mdx +34 -0
  171. package/docs/realtime/run-object.mdx +174 -0
  172. package/docs/replaying.mdx +72 -0
  173. package/docs/request-feature.mdx +6 -0
  174. package/docs/roadmap.mdx +6 -0
  175. package/docs/run-tests.mdx +20 -0
  176. package/docs/run-usage.mdx +113 -0
  177. package/docs/runs/heartbeats.mdx +38 -0
  178. package/docs/runs/max-duration.mdx +139 -0
  179. package/docs/runs/metadata.mdx +734 -0
  180. package/docs/runs/priority.mdx +31 -0
  181. package/docs/runs.mdx +396 -0
  182. package/docs/self-hosting/docker.mdx +458 -0
  183. package/docs/self-hosting/env/supervisor.mdx +74 -0
  184. package/docs/self-hosting/env/webapp.mdx +276 -0
  185. package/docs/self-hosting/kubernetes.mdx +601 -0
  186. package/docs/self-hosting/overview.mdx +108 -0
  187. package/docs/skills.mdx +85 -0
  188. package/docs/tags.mdx +120 -0
  189. package/docs/tasks/overview.mdx +697 -0
  190. package/docs/tasks/scheduled.mdx +382 -0
  191. package/docs/tasks/schemaTask.mdx +413 -0
  192. package/docs/tasks/streams.mdx +884 -0
  193. package/docs/triggering.mdx +1320 -0
  194. package/docs/troubleshooting-alerts.mdx +385 -0
  195. package/docs/troubleshooting-debugging-in-vscode.mdx +8 -0
  196. package/docs/troubleshooting-github-issues.mdx +6 -0
  197. package/docs/troubleshooting-uptime-status.mdx +6 -0
  198. package/docs/troubleshooting.mdx +398 -0
  199. package/docs/upgrading-packages.mdx +80 -0
  200. package/docs/vercel-integration.mdx +207 -0
  201. package/docs/versioning.mdx +56 -0
  202. package/docs/video-walkthrough.mdx +23 -0
  203. package/docs/wait-for-token.mdx +540 -0
  204. package/docs/wait-for.mdx +42 -0
  205. package/docs/wait-until.mdx +53 -0
  206. package/docs/wait.mdx +18 -0
  207. package/docs/writing-tasks-introduction.mdx +33 -0
  208. package/package.json +10 -6
  209. package/skills/trigger-authoring-chat-agent/SKILL.md +296 -0
  210. package/skills/trigger-authoring-tasks/SKILL.md +254 -0
  211. package/skills/trigger-chat-agent-advanced/SKILL.md +368 -0
  212. package/skills/trigger-cost-savings/SKILL.md +116 -0
  213. package/skills/trigger-realtime-and-frontend/SKILL.md +276 -0
@@ -0,0 +1,632 @@
1
+ ---
2
+ title: "Manual setup"
3
+ description: "How to manually setup Trigger.dev in your project."
4
+ ---
5
+
6
+ This guide covers how to manually set up Trigger.dev in your project, including configuration for different package managers, monorepos, and build extensions. This guide replicates all the steps performed by the `trigger.dev init` command. Follow our [Quickstart](/quick-start) for a more streamlined setup.
7
+
8
+ ## Prerequisites
9
+
10
+ - Node.js 18.20+ (or Bun runtime)
11
+ - A Trigger.dev account (sign up at [trigger.dev](https://trigger.dev))
12
+ - TypeScript 5.0.4 or later (for TypeScript projects)
13
+
14
+ ## CLI Authentication
15
+
16
+ Before setting up your project, you need to authenticate the CLI with Trigger.dev:
17
+
18
+ ```bash
19
+ # Login to Trigger.dev
20
+ npx trigger.dev@latest login
21
+
22
+ # Or with a specific API URL (for self-hosted instances)
23
+ npx trigger.dev@latest login --api-url https://your-trigger-instance.com
24
+ ```
25
+
26
+ This will open your browser to authenticate. Once authenticated, you'll need to select or create a project in the Trigger.dev dashboard to get your project reference (e.g., `proj_abc123`).
27
+
28
+ ## Package installation
29
+
30
+ Install the required packages based on your package manager:
31
+
32
+ <CodeGroup>
33
+
34
+ ```bash npm
35
+ npm add @trigger.dev/sdk@latest
36
+ npm add --save-dev @trigger.dev/build@latest
37
+ ```
38
+
39
+ ```bash pnpm
40
+ pnpm add @trigger.dev/sdk@latest
41
+ pnpm add -D @trigger.dev/build@latest
42
+ ```
43
+
44
+ ```bash yarn
45
+ yarn add @trigger.dev/sdk@latest
46
+ yarn add -D @trigger.dev/build@latest
47
+ ```
48
+
49
+ ```bash bun
50
+ bun add @trigger.dev/sdk@latest
51
+ bun add -D @trigger.dev/build@latest
52
+ ```
53
+
54
+ </CodeGroup>
55
+
56
+ ## Environment variables
57
+
58
+ For local development, you need to set up the `TRIGGER_SECRET_KEY` environment variable. This key authenticates your application with Trigger.dev.
59
+
60
+ 1. Go to your project dashboard in Trigger.dev
61
+ 2. Navigate to the "API Keys" page
62
+ 3. Copy the **DEV** secret key
63
+ 4. Add it to your local environment file:
64
+
65
+ ```bash
66
+ TRIGGER_SECRET_KEY=tr_dev_xxxxxxxxxx
67
+ ```
68
+
69
+ ### Self-hosted instances
70
+
71
+ If you're using a self-hosted Trigger.dev instance, also set:
72
+
73
+ ```bash
74
+ TRIGGER_API_URL=https://your-trigger-instance.com
75
+ ```
76
+
77
+ ## CLI setup
78
+
79
+ You can run the Trigger.dev CLI in two ways:
80
+
81
+ ### Option 1: Using npx/pnpm dlx/yarn dlx
82
+
83
+ ```bash
84
+ # npm
85
+ npx trigger.dev@latest dev
86
+
87
+ # pnpm
88
+ pnpm dlx trigger.dev@latest dev
89
+
90
+ # yarn
91
+ yarn dlx trigger.dev@latest dev
92
+ ```
93
+
94
+ ### Option 2: Add as dev dependency
95
+
96
+ Add the CLI to your `package.json`:
97
+
98
+ ```json
99
+ {
100
+ "devDependencies": {
101
+ "trigger.dev": "^4.0.0"
102
+ }
103
+ }
104
+ ```
105
+
106
+ Then add scripts to your `package.json`:
107
+
108
+ ```json
109
+ {
110
+ "scripts": {
111
+ "dev:trigger": "trigger dev",
112
+ "deploy:trigger": "trigger deploy"
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Version pinning
118
+
119
+ Make sure to pin the version of the CLI to the same version as the SDK that you are using:
120
+
121
+ ```json
122
+ "devDependencies": {
123
+ "trigger.dev": "^4.0.0",
124
+ "@trigger.dev/build": "^4.0.0"
125
+ },
126
+ "dependencies": {
127
+ "@trigger.dev/sdk": "^4.0.0"
128
+ }
129
+ ```
130
+
131
+ While running the CLI `dev` or `deploy` commands, the CLI will automatically detect mismatched versions and warn you.
132
+
133
+ ## Configuration file
134
+
135
+ Create a `trigger.config.ts` file in your project root (or `trigger.config.mjs` for JavaScript projects):
136
+
137
+ ```typescript
138
+ import { defineConfig } from "@trigger.dev/sdk";
139
+
140
+ export default defineConfig({
141
+ // Your project ref from the Trigger.dev dashboard
142
+ project: "<your-project-ref>", // e.g., "proj_abc123"
143
+
144
+ // Directories containing your tasks
145
+ dirs: ["./src/trigger"], // Customize based on your project structure
146
+
147
+ // Retry configuration
148
+ retries: {
149
+ enabledInDev: false, // Enable retries in development
150
+ default: {
151
+ maxAttempts: 3,
152
+ minTimeoutInMs: 1000,
153
+ maxTimeoutInMs: 10000,
154
+ factor: 2,
155
+ randomize: true,
156
+ },
157
+ },
158
+
159
+ // Build configuration (optional)
160
+ build: {
161
+ extensions: [], // Build extensions go here
162
+ },
163
+
164
+ // Max duration of a task in seconds
165
+ maxDuration: 3600,
166
+ });
167
+ ```
168
+
169
+ ### Using the Bun runtime
170
+
171
+ By default, Trigger.dev will use the Node.js runtime. If you're using Bun, you can specify the runtime:
172
+
173
+ ```typescript
174
+ import { defineConfig } from "@trigger.dev/sdk";
175
+
176
+ export default defineConfig({
177
+ project: "<your-project-ref>",
178
+ runtime: "bun",
179
+ dirs: ["./src/trigger"],
180
+ });
181
+ ```
182
+
183
+ See our [Bun runtime documentation](/guides/frameworks/bun) for more information.
184
+
185
+ ## Add your first task
186
+
187
+ Create a `trigger` directory (matching the `dirs` in your config) and add an example task:
188
+
189
+ ```typescript src/trigger/example.ts
190
+ import { task } from "@trigger.dev/sdk";
191
+
192
+ export const helloWorld = task({
193
+ id: "hello-world",
194
+ run: async (payload: { name: string }) => {
195
+ console.log(`Hello ${payload.name}!`);
196
+
197
+ return {
198
+ message: `Hello ${payload.name}!`,
199
+ timestamp: new Date().toISOString(),
200
+ };
201
+ },
202
+ });
203
+ ```
204
+
205
+ See our [Tasks](/tasks/overview) docs for more information on how to create tasks.
206
+
207
+ ## TypeScript config
208
+
209
+ If you're using TypeScript, add `trigger.config.ts` to your `tsconfig.json` include array:
210
+
211
+ ```json
212
+ {
213
+ "compilerOptions": {
214
+ // ... your existing options
215
+ },
216
+ "include": [
217
+ // ... your existing includes
218
+ "trigger.config.ts"
219
+ ]
220
+ }
221
+ ```
222
+
223
+ ## Git config
224
+
225
+ Add `.trigger` to your `.gitignore` file to exclude Trigger.dev's local development files:
226
+
227
+ ```bash
228
+ # Trigger.dev
229
+ .trigger
230
+ ```
231
+
232
+ If you don't have a `.gitignore` file, create one with this content.
233
+
234
+ ## React hooks setup
235
+
236
+ If you're building a React frontend application and want to display task status in real-time, install the React hooks package:
237
+
238
+ ### Installation
239
+
240
+ ```bash
241
+ # npm
242
+ npm install @trigger.dev/react-hooks@latest
243
+
244
+ # pnpm
245
+ pnpm add @trigger.dev/react-hooks@latest
246
+
247
+ # yarn
248
+ yarn add @trigger.dev/react-hooks@latest
249
+
250
+ # bun
251
+ bun add @trigger.dev/react-hooks@latest
252
+ ```
253
+
254
+ ### Basic usage
255
+
256
+ 1. **Generate a Public Access Token** in your backend:
257
+
258
+ ```typescript
259
+ import { auth } from "@trigger.dev/sdk";
260
+
261
+ // In your backend API
262
+ export async function getPublicAccessToken() {
263
+ const publicAccessToken = await auth.createPublicToken({
264
+ scopes: ["read:runs"], // Customize based on needs
265
+ });
266
+
267
+ return publicAccessToken;
268
+ }
269
+ ```
270
+
271
+ 2. **Use hooks to monitor tasks**:
272
+
273
+ ```tsx
274
+ import { useRealtimeRun } from "@trigger.dev/react-hooks";
275
+
276
+ export function TaskStatus({
277
+ runId,
278
+ publicAccessToken,
279
+ }: {
280
+ runId: string;
281
+ publicAccessToken: string;
282
+ }) {
283
+ const { run, error } = useRealtimeRun(runId, {
284
+ accessToken: publicAccessToken,
285
+ });
286
+
287
+ if (error) return <div>Error: {error.message}</div>;
288
+ if (!run) return <div>Loading...</div>;
289
+
290
+ return (
291
+ <div>
292
+ <p>Status: {run.status}</p>
293
+ <p>Progress: {run.completedAt ? "Complete" : "Running..."}</p>
294
+ </div>
295
+ );
296
+ }
297
+ ```
298
+
299
+ For more information, see the [React Hooks documentation](/realtime/react-hooks/overview).
300
+
301
+ ## Build extensions
302
+
303
+ Build extensions allow you to customize the build process. Ensure you have the `@trigger.dev/build` package installed in your project (see [package installation](#package-installation)).
304
+
305
+ Now you can use any of the built-in extensions:
306
+
307
+ ```typescript
308
+ import { defineConfig } from "@trigger.dev/sdk";
309
+ import { prismaExtension } from "@trigger.dev/build/extensions/prisma";
310
+
311
+ export default defineConfig({
312
+ project: "<project-ref>",
313
+ build: {
314
+ extensions: [
315
+ prismaExtension({
316
+ mode: "legacy",
317
+ schema: "prisma/schema.prisma",
318
+ migrate: true, // Run migrations on deploy
319
+ }),
320
+ ],
321
+ },
322
+ });
323
+ ```
324
+
325
+ See our [Build extensions](/config/extensions/overview) docs for more information on how to use build extensions and the available extensions.
326
+
327
+ ## Monorepo setup
328
+
329
+ There are two main approaches for setting up Trigger.dev in a monorepo:
330
+
331
+ 1. **Tasks as a package**: Create a separate package for your Trigger.dev tasks that can be shared across apps
332
+ 2. **Tasks in apps**: Install Trigger.dev directly in individual apps that need background tasks
333
+
334
+ Both approaches work well depending on your needs. Use the tasks package approach if you want to share tasks across multiple applications, or the app-based approach if tasks are specific to individual apps.
335
+
336
+ ### Approach 1: Tasks as a package (Turborepo)
337
+
338
+ This approach creates a dedicated tasks package that can be consumed by multiple apps in your monorepo.
339
+
340
+ #### 1. Set up workspace configuration
341
+
342
+ **Root `package.json`**:
343
+
344
+ ```json
345
+ {
346
+ "name": "my-monorepo",
347
+ "private": true,
348
+ "scripts": {
349
+ "build": "turbo run build",
350
+ "dev": "turbo run dev",
351
+ "lint": "turbo run lint"
352
+ },
353
+ "devDependencies": {
354
+ "turbo": "^2.4.4",
355
+ "typescript": "5.8.2"
356
+ },
357
+ "packageManager": "pnpm@9.0.0"
358
+ }
359
+ ```
360
+
361
+ **`pnpm-workspace.yaml`**:
362
+
363
+ ```yaml
364
+ packages:
365
+ - "apps/*"
366
+ - "packages/*"
367
+ ```
368
+
369
+ **`turbo.json`**:
370
+
371
+ ```json
372
+ {
373
+ "$schema": "https://turbo.build/schema.json",
374
+ "ui": "tui",
375
+ "tasks": {
376
+ "build": {
377
+ "dependsOn": ["^build"],
378
+ "outputs": [".next/**", "!.next/cache/**"]
379
+ },
380
+ "dev": {
381
+ "cache": false,
382
+ "persistent": true
383
+ },
384
+ "lint": {
385
+ "dependsOn": ["^lint"]
386
+ }
387
+ }
388
+ }
389
+ ```
390
+
391
+ #### 2. Create the tasks package
392
+
393
+ **`packages/tasks/package.json`**:
394
+
395
+ ```json
396
+ {
397
+ "name": "@repo/tasks",
398
+ "version": "0.0.0",
399
+ "dependencies": {
400
+ "@trigger.dev/sdk": "^4.0.0"
401
+ },
402
+ "devDependencies": {
403
+ "@trigger.dev/build": "^4.0.0"
404
+ },
405
+ "exports": {
406
+ ".": "./src/trigger/index.ts",
407
+ "./trigger": "./src/index.ts"
408
+ }
409
+ }
410
+ ```
411
+
412
+ **`packages/tasks/trigger.config.ts`**:
413
+
414
+ ```typescript
415
+ import { defineConfig } from "@trigger.dev/sdk";
416
+
417
+ export default defineConfig({
418
+ project: "<your-project-ref>", // Replace with your project reference
419
+ dirs: ["./src/trigger"],
420
+ retries: {
421
+ enabledInDev: true,
422
+ default: {
423
+ maxAttempts: 3,
424
+ minTimeoutInMs: 1000,
425
+ maxTimeoutInMs: 10000,
426
+ factor: 2,
427
+ randomize: true,
428
+ },
429
+ },
430
+ maxDuration: 3600,
431
+ });
432
+ ```
433
+
434
+ **`packages/tasks/src/index.ts`**:
435
+
436
+ ```typescript
437
+ export * from "@trigger.dev/sdk"; // Export values and types from the Trigger.dev sdk
438
+ ```
439
+
440
+ **`packages/tasks/src/trigger/index.ts`**:
441
+
442
+ ```typescript
443
+ // Export tasks
444
+ export * from "./example";
445
+ ```
446
+
447
+ **`packages/tasks/src/trigger/example.ts`**:
448
+
449
+ ```typescript
450
+ import { task } from "@trigger.dev/sdk";
451
+
452
+ export const helloWorld = task({
453
+ id: "hello-world",
454
+ run: async (payload: { name: string }) => {
455
+ console.log(`Hello ${payload.name}!`);
456
+
457
+ return {
458
+ message: `Hello ${payload.name}!`,
459
+ timestamp: new Date().toISOString(),
460
+ };
461
+ },
462
+ });
463
+ ```
464
+
465
+ See our [turborepo-prisma-tasks-package example](https://github.com/triggerdotdev/examples/tree/main/monorepos/turborepo-prisma-tasks-package) for a more complete example.
466
+
467
+ #### 3. Use tasks in your apps
468
+
469
+ **`apps/web/package.json`**:
470
+
471
+ ```json
472
+ {
473
+ "name": "web",
474
+ "dependencies": {
475
+ "@repo/tasks": "workspace:*",
476
+ "next": "^15.2.1",
477
+ "react": "^19.0.0",
478
+ "react-dom": "^19.0.0"
479
+ }
480
+ }
481
+ ```
482
+
483
+ **`apps/web/app/api/actions.ts`**:
484
+
485
+ ```typescript
486
+ "use server";
487
+
488
+ import { tasks } from "@repo/tasks/trigger";
489
+ import type { helloWorld } from "@repo/tasks";
490
+ // 👆 type only import
491
+
492
+ export async function triggerHelloWorld(name: string) {
493
+ try {
494
+ const handle = await tasks.trigger<typeof helloWorld>("hello-world", {
495
+ name: name,
496
+ });
497
+
498
+ return handle.id;
499
+ } catch (error) {
500
+ console.error(error);
501
+ return { error: "something went wrong" };
502
+ }
503
+ }
504
+ ```
505
+
506
+ #### 4. Development workflow
507
+
508
+ Run the development server for the tasks package:
509
+
510
+ ```bash
511
+ # From the root of your monorepo
512
+ cd packages/tasks
513
+ npx trigger.dev@latest dev
514
+
515
+ # Or using turbo (if you add dev:trigger script to tasks package.json)
516
+ turbo run dev:trigger --filter=@repo/tasks
517
+ ```
518
+
519
+ ### Approach 2: Tasks in apps (Turborepo)
520
+
521
+ This approach installs Trigger.dev directly in individual apps that need background tasks.
522
+
523
+ #### 1. Install in your app
524
+
525
+ **`apps/web/package.json`**:
526
+
527
+ ```json
528
+ {
529
+ "name": "web",
530
+ "dependencies": {
531
+ "@trigger.dev/sdk": "^4.0.0",
532
+ "next": "^15.2.1",
533
+ "react": "^19.0.0",
534
+ "react-dom": "^19.0.0"
535
+ },
536
+ "devDependencies": {
537
+ "@trigger.dev/build": "^4.0.0"
538
+ }
539
+ }
540
+ ```
541
+
542
+ #### 2. Add configuration
543
+
544
+ **`apps/web/trigger.config.ts`**:
545
+
546
+ ```typescript
547
+ import { defineConfig } from "@trigger.dev/sdk";
548
+
549
+ export default defineConfig({
550
+ project: "<your-project-ref>", // Replace with your project reference
551
+ dirs: ["./src/trigger"],
552
+ retries: {
553
+ enabledInDev: true,
554
+ default: {
555
+ maxAttempts: 3,
556
+ minTimeoutInMs: 1000,
557
+ maxTimeoutInMs: 10000,
558
+ factor: 2,
559
+ randomize: true,
560
+ },
561
+ },
562
+ maxDuration: 3600,
563
+ });
564
+ ```
565
+
566
+ #### 3. Create tasks
567
+
568
+ **`apps/web/src/trigger/example.ts`**:
569
+
570
+ ```typescript
571
+ import { task } from "@trigger.dev/sdk";
572
+
573
+ export const helloWorld = task({
574
+ id: "hello-world",
575
+ run: async (payload: { name: string }) => {
576
+ console.log(`Hello ${payload.name}!`);
577
+
578
+ return {
579
+ message: `Hello ${payload.name}!`,
580
+ timestamp: new Date().toISOString(),
581
+ };
582
+ },
583
+ });
584
+ ```
585
+
586
+ #### 4. Use tasks in your app
587
+
588
+ **`apps/web/app/api/actions.ts`**:
589
+
590
+ ```typescript
591
+ "use server";
592
+
593
+ import { tasks } from "@trigger.dev/sdk";
594
+ import type { helloWorld } from "../../src/trigger/example";
595
+ // 👆 type only import
596
+
597
+ export async function triggerHelloWorld(name: string) {
598
+ try {
599
+ const handle = await tasks.trigger<typeof helloWorld>("hello-world", {
600
+ name: name,
601
+ });
602
+
603
+ return handle.id;
604
+ } catch (error) {
605
+ console.error(error);
606
+ return { error: "something went wrong" };
607
+ }
608
+ }
609
+ ```
610
+
611
+ #### 5. Development workflow
612
+
613
+ ```bash
614
+ # From the app directory
615
+ cd apps/web
616
+ npx trigger.dev@latest dev
617
+
618
+ # Or from the root using turbo
619
+ turbo run dev:trigger --filter=web
620
+ ```
621
+
622
+ ## Example projects
623
+
624
+ You can find a growing list of example projects in our [examples](/guides/introduction) section.
625
+
626
+ ## Troubleshooting
627
+
628
+ If you run into any issues, please check our [Troubleshooting](/troubleshooting) page.
629
+
630
+ ## Feedback
631
+
632
+ If you have any feedback, please let us know by [opening an issue](https://github.com/triggerdotdev/trigger.dev/issues).
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: "Agent rules"
3
+ description: "Trigger.dev agent rules are now agent skills, installed with the trigger.dev CLI."
4
+ sidebarTitle: "Agent rules"
5
+ ---
6
+
7
+ <Note>
8
+ Agent rules are now **agent skills**. The standalone rule files have been replaced by skills that
9
+ work across every major AI assistant from a single install. See [Skills](/skills).
10
+ </Note>
11
+
12
+ ## What changed
13
+
14
+ Trigger.dev used to install per-tool *rule files* (`.cursor/rules/trigger.*.mdc`, regions in `CLAUDE.md`, and so on) fetched from GitHub. That has been replaced by [agent skills](/skills): `SKILL.md` directories in the open [Agent Skills standard](https://agentskills.io) that install with the CLI, draw their API guidance from a version-pinned reference in `@trigger.dev/sdk`, and load on demand instead of always sitting in your context.
15
+
16
+ The install command is the same, and now installs skills:
17
+
18
+ ```bash
19
+ npx trigger.dev@latest skills
20
+ ```
21
+
22
+ `npx trigger.dev@latest install-rules` still works as an alias, and `trigger dev` offers to install the skills on first run.
23
+
24
+ The old task and realtime guidance now lives in the `trigger-authoring-tasks` and `trigger-realtime-and-frontend` skills, alongside two new skills for building `chat.agent` AI agents. See [Skills](/skills) for the full list and supported assistants.
25
+
26
+ ## Next steps
27
+
28
+ <CardGroup cols={2}>
29
+ <Card title="Skills" icon="wand-magic-sparkles" href="/skills">
30
+ Install Trigger.dev agent skills into your AI coding assistant.
31
+ </Card>
32
+ <Card title="MCP Server" icon="sparkles" href="/mcp-introduction">
33
+ Give your AI assistant direct access to Trigger.dev tools and APIs.
34
+ </Card>
35
+ <Card title="Building with AI" icon="layer-group" href="/building-with-ai">
36
+ See how skills and the MCP server compare.
37
+ </Card>
38
+ <Card title="Writing tasks" icon="code" href="/tasks/overview">
39
+ Learn the task patterns that skills teach your AI assistant.
40
+ </Card>
41
+ </CardGroup>