@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,30 @@
1
+ ---
2
+ title: "Puppeteer"
3
+ sidebarTitle: "puppeteer"
4
+ description: "Use the puppeteer build extension to enable support for Puppeteer in your project"
5
+ ---
6
+
7
+ <ScrapingWarning />
8
+
9
+ To use Puppeteer in your project, add these build settings to your `trigger.config.ts` file:
10
+
11
+ ```ts trigger.config.ts
12
+ import { defineConfig } from "@trigger.dev/sdk";
13
+ import { puppeteer } from "@trigger.dev/build/extensions/puppeteer";
14
+
15
+ export default defineConfig({
16
+ project: "<project ref>",
17
+ // Your other config settings...
18
+ build: {
19
+ extensions: [puppeteer()],
20
+ },
21
+ });
22
+ ```
23
+
24
+ And add the following environment variable in your Trigger.dev dashboard on the Environment Variables page:
25
+
26
+ ```bash
27
+ PUPPETEER_EXECUTABLE_PATH: "/usr/bin/google-chrome-stable",
28
+ ```
29
+
30
+ Follow [this example](/guides/examples/puppeteer) to get setup with Trigger.dev and Puppeteer in your project.
@@ -0,0 +1,182 @@
1
+ ---
2
+ title: "Python"
3
+ sidebarTitle: "pythonExtension"
4
+ description: "Use the python build extension to add support for executing Python scripts in your project"
5
+ ---
6
+
7
+ If you need to execute Python scripts in your Trigger.dev project, you can use the `pythonExtension` build extension via the `@trigger.dev/python` package.
8
+
9
+ First, you'll need to install the `@trigger.dev/python` package:
10
+
11
+ ```bash
12
+ npm add @trigger.dev/python
13
+ ```
14
+
15
+ Then, you can use the `pythonExtension` build extension in your `trigger.config.ts` file:
16
+
17
+ ```ts
18
+ import { defineConfig } from "@trigger.dev/sdk";
19
+ import { pythonExtension } from "@trigger.dev/python/extension";
20
+
21
+ export default defineConfig({
22
+ project: "<project ref>",
23
+ build: {
24
+ extensions: [pythonExtension()],
25
+ },
26
+ });
27
+ ```
28
+
29
+ This will take care of adding python to the build image and setting up the necessary environment variables to execute Python scripts. You can then use our `python` utilities in the `@trigger.dev/python` package to execute Python scripts in your tasks. For example, running a Python script inline in a task:
30
+
31
+ ```ts
32
+ import { task } from "@trigger.dev/sdk";
33
+ import { python } from "@trigger.dev/python";
34
+
35
+ export const myScript = task({
36
+ id: "my-python-script",
37
+ run: async () => {
38
+ const result = await python.runInline(`print("Hello, world!")`);
39
+ return result.stdout;
40
+ },
41
+ });
42
+ ```
43
+
44
+ ## Adding python scripts
45
+
46
+ You can automatically add python scripts to your project using the `scripts` option in the `pythonExtension` function. This will copy the specified scripts to the build directory during the deploy process. For example:
47
+
48
+ ```ts
49
+ import { defineConfig } from "@trigger.dev/sdk";
50
+ import { pythonExtension } from "@trigger.dev/python/extension";
51
+
52
+ export default defineConfig({
53
+ project: "<project ref>",
54
+ build: {
55
+ extensions: [
56
+ pythonExtension({
57
+ scripts: ["./python/**/*.py"],
58
+ }),
59
+ ],
60
+ },
61
+ });
62
+ ```
63
+
64
+ This will copy all Python files in the `python` directory to the build directory during the deploy process. You can then execute these scripts using the `python.runScript` function:
65
+
66
+ ```ts
67
+ import { task } from "@trigger.dev/sdk";
68
+ import { python } from "@trigger.dev/python";
69
+
70
+ export const myScript = task({
71
+ id: "my-python-script",
72
+ run: async () => {
73
+ const result = await python.runScript("./python/my_script.py", ["hello", "world"]);
74
+ return result.stdout;
75
+ },
76
+ });
77
+ ```
78
+
79
+ <Note>
80
+ The pythonExtension will also take care of moving the scripts to the correct location during `dev`
81
+ mode, so you can use the same exact path in development as you do in production.
82
+ </Note>
83
+
84
+ ## Using requirements files
85
+
86
+ If you have a `requirements.txt` file in your project, you can use the `requirementsFile` option in the `pythonExtension` function to install the required packages during the build process. For example:
87
+
88
+ ```ts
89
+ import { defineConfig } from "@trigger.dev/sdk";
90
+ import { pythonExtension } from "@trigger.dev/python/extension";
91
+
92
+ export default defineConfig({
93
+ project: "<project ref>",
94
+ build: {
95
+ extensions: [
96
+ pythonExtension({
97
+ requirementsFile: "./requirements.txt",
98
+ }),
99
+ ],
100
+ },
101
+ });
102
+ ```
103
+
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
+
106
+ <Note>
107
+ The `requirementsFile` option is only available in production mode. In development mode, you can
108
+ install the required packages manually using the `pip` command.
109
+ </Note>
110
+
111
+ ## Virtual environments
112
+
113
+ If you are using a virtual environment in your project, you can use the `devPythonBinaryPath` option in the `pythonExtension` function to specify the path to the Python binary in the virtual environment. For example:
114
+
115
+ ```ts
116
+ import { defineConfig } from "@trigger.dev/sdk";
117
+ import { pythonExtension } from "@trigger.dev/python/extension";
118
+
119
+ export default defineConfig({
120
+ project: "<project ref>",
121
+ build: {
122
+ extensions: [
123
+ pythonExtension({
124
+ devPythonBinaryPath: ".venv/bin/python",
125
+ }),
126
+ ],
127
+ },
128
+ });
129
+ ```
130
+
131
+ This has no effect in production mode, but in development mode, it will use the specified Python binary to execute Python scripts.
132
+
133
+ ## Streaming output
134
+
135
+ All of the `python` functions have a streaming version that allows you to stream the output of the Python script as it runs. For example:
136
+
137
+ ```ts
138
+ import { task } from "@trigger.dev/sdk";
139
+ import { python } from "@trigger.dev/python";
140
+
141
+ export const myStreamingScript = task({
142
+ id: "my-streaming-python-script",
143
+ run: async () => {
144
+ // You don't need to await the result
145
+ const result = python.stream.runScript("./python/my_script.py", ["hello", "world"]);
146
+
147
+ // result is an async iterable/readable stream
148
+ for await (const chunk of streamingResult) {
149
+ console.log(chunk);
150
+ }
151
+ },
152
+ });
153
+ ```
154
+
155
+ ## Environment variables
156
+
157
+ We automatically inject the environment variables in the `process.env` object when running Python scripts. You can access these environment variables in your Python scripts using the `os.environ` dictionary. For example:
158
+
159
+ ```python
160
+ import os
161
+
162
+ print(os.environ["MY_ENV_VAR"])
163
+ ```
164
+
165
+ You can also pass additional environment variables to the Python script using the `env` option in the `python.runScript` function. For example:
166
+
167
+ ```ts
168
+ import { task } from "@trigger.dev/sdk";
169
+ import { python } from "@trigger.dev/python";
170
+
171
+ export const myScript = task({
172
+ id: "my-python-script",
173
+ run: async () => {
174
+ const result = await python.runScript("./python/my_script.py", ["hello", "world"], {
175
+ env: {
176
+ MY_ENV_VAR: "my value",
177
+ },
178
+ });
179
+ return result.stdout;
180
+ },
181
+ });
182
+ ```
@@ -0,0 +1,291 @@
1
+ ---
2
+ title: "Sync env vars"
3
+ sidebarTitle: "syncEnvVars"
4
+ description: "Use the syncEnvVars build extension to automatically sync environment variables to Trigger.dev"
5
+ ---
6
+
7
+ The `syncEnvVars` build extension will sync env vars from another service into Trigger.dev before the deployment starts. This is useful if you are using a secret store service like Infisical or AWS Secrets Manager to store your secrets.
8
+
9
+ `syncEnvVars` takes an async callback function, and any env vars returned from the callback will be synced to Trigger.dev.
10
+
11
+ ```ts
12
+ import { defineConfig } from "@trigger.dev/sdk";
13
+ import { syncEnvVars } from "@trigger.dev/build/extensions/core";
14
+
15
+ export default defineConfig({
16
+ build: {
17
+ extensions: [
18
+ syncEnvVars(async (ctx) => {
19
+ return [
20
+ { name: "SECRET_KEY", value: "secret-value" },
21
+ { name: "ANOTHER_SECRET", value: "another-secret-value" },
22
+ ];
23
+ }),
24
+ ],
25
+ },
26
+ });
27
+ ```
28
+
29
+ The callback is passed a context object with the following properties:
30
+
31
+ - `environment`: The environment name that the task is being deployed to (e.g. `production`, `staging`, etc.)
32
+ - `projectRef`: The project ref of the Trigger.dev project
33
+ - `env`: The environment variables that are currently set in the Trigger.dev project
34
+
35
+ ### Example: Sync env vars from Infisical
36
+
37
+ In this example we're using env vars from [Infisical](https://infisical.com).
38
+
39
+ ```ts trigger.config.ts
40
+ import { defineConfig } from "@trigger.dev/sdk";
41
+ import { syncEnvVars } from "@trigger.dev/build/extensions/core";
42
+ import { InfisicalSDK } from "@infisical/sdk";
43
+
44
+ export default defineConfig({
45
+ build: {
46
+ extensions: [
47
+ syncEnvVars(async (ctx) => {
48
+ const client = new InfisicalSDK();
49
+
50
+ await client.auth().universalAuth.login({
51
+ clientId: process.env.INFISICAL_CLIENT_ID!,
52
+ clientSecret: process.env.INFISICAL_CLIENT_SECRET!,
53
+ });
54
+
55
+ const { secrets } = await client.secrets().listSecrets({
56
+ environment: ctx.environment,
57
+ projectId: process.env.INFISICAL_PROJECT_ID!,
58
+ });
59
+
60
+ return secrets.map((secret) => ({
61
+ name: secret.secretKey,
62
+ value: secret.secretValue,
63
+ }));
64
+ }),
65
+ ],
66
+ },
67
+ });
68
+ ```
69
+
70
+ ### syncVercelEnvVars
71
+
72
+ The `syncVercelEnvVars` build extension syncs environment variables from your Vercel project to Trigger.dev.
73
+
74
+ <AccordionGroup>
75
+ <Accordion title="Setting up authentication including team projects">
76
+ You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables, or pass
77
+ in the token and project ID as arguments to the `syncVercelEnvVars` build extension. If you're
78
+ working with a team project, you'll also need to set `VERCEL_TEAM_ID`, which can be found in your
79
+ team settings.
80
+
81
+ You can find / generate the `VERCEL_ACCESS_TOKEN` in your Vercel
82
+ [dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers
83
+ the project with the environment variables you want to sync.
84
+ </Accordion>
85
+
86
+ <Accordion title="Running in Vercel build environment">
87
+ When running the build from a Vercel build environment (e.g., during a Vercel deployment), the
88
+ environment variable values will be read from `process.env` instead of fetching them from the
89
+ Vercel API. This is determined by checking if the `VERCEL` environment variable is present.
90
+
91
+ The API is still used to determine which environment variables are configured for your project, but
92
+ the actual values come from the local environment. Reading values from `process.env` allows the
93
+ extension to use values that Vercel integrations (such as the Neon integration) set per preview
94
+ deployment in the "Provisioning Integrations" phase that happens just before the Vercel build
95
+ starts.
96
+ </Accordion>
97
+
98
+ <Accordion title="Using with Neon database Vercel integration">
99
+ If you have the Neon database Vercel integration installed and are running builds outside of the
100
+ Vercel environment, we recommend using `syncNeonEnvVars` in addition to `syncVercelEnvVars` for your
101
+ database environment variables.
102
+
103
+ This ensures that the correct database connection strings are used for your
104
+ selected environment and current branch, as `syncVercelEnvVars` may not accurately reflect
105
+ branch-specific database credentials when run locally.
106
+ </Accordion>
107
+ </AccordionGroup>
108
+
109
+ ```ts
110
+ import { defineConfig } from "@trigger.dev/sdk";
111
+ import { syncVercelEnvVars } from "@trigger.dev/build/extensions/core";
112
+
113
+ export default defineConfig({
114
+ project: "<project ref>",
115
+ // Your other config settings...
116
+ build: {
117
+ // This will automatically use the VERCEL_ACCESS_TOKEN and VERCEL_PROJECT_ID environment variables
118
+ extensions: [syncVercelEnvVars()],
119
+ },
120
+ });
121
+ ```
122
+
123
+ Or you can pass in the token and project ID as arguments:
124
+
125
+ ```ts
126
+ import { defineConfig } from "@trigger.dev/sdk";
127
+ import { syncVercelEnvVars } from "@trigger.dev/build/extensions/core";
128
+
129
+ export default defineConfig({
130
+ project: "<project ref>",
131
+ // Your other config settings...
132
+ build: {
133
+ extensions: [
134
+ syncVercelEnvVars({
135
+ projectId: "your-vercel-project-id",
136
+ vercelAccessToken: "your-vercel-access-token", // optional, we recommend to keep it as env variable
137
+ vercelTeamId: "your-vercel-team-id", // optional
138
+ }),
139
+ ],
140
+ },
141
+ });
142
+ ```
143
+
144
+ ### syncNeonEnvVars
145
+
146
+ 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.
147
+
148
+ <AccordionGroup>
149
+ <Accordion title="Setting up authentication">
150
+ You need to set the `NEON_ACCESS_TOKEN` and `NEON_PROJECT_ID` environment variables, or pass them
151
+ as arguments to the `syncNeonEnvVars` build extension.
152
+
153
+ You can generate a `NEON_ACCESS_TOKEN` in your Neon [dashboard](https://console.neon.tech/app/settings/api-keys).
154
+ </Accordion>
155
+
156
+ <Accordion title="Running in Vercel environment">
157
+ When running the build from a Vercel environment (determined by checking if the `VERCEL`
158
+ environment variable is present), this extension is skipped entirely.
159
+
160
+ This is because Neon's Vercel integration already handles environment variable synchronization in Vercel environments.
161
+ </Accordion>
162
+
163
+ <Accordion title="Using with Neon database Vercel integration">
164
+ If you have the Neon database Vercel integration installed and are running builds outside of the
165
+ Vercel environment, we recommend using `syncNeonEnvVars` in addition to `syncVercelEnvVars` for your
166
+ database environment variables.
167
+
168
+ This ensures that the correct database connection strings are used for your selected environment and current branch, as `syncVercelEnvVars` may not accurately reflect branch-specific database credentials when run locally.
169
+ </Accordion>
170
+ </AccordionGroup>
171
+
172
+ <Note>
173
+ This extension is skipped for `prod` environments. It is designed to sync branch-specific
174
+ database connections for preview/staging environments.
175
+ </Note>
176
+
177
+ ```ts
178
+ import { defineConfig } from "@trigger.dev/sdk";
179
+ import { syncNeonEnvVars } from "@trigger.dev/build/extensions/core";
180
+
181
+ export default defineConfig({
182
+ project: "<project ref>",
183
+ // Your other config settings...
184
+ build: {
185
+ // This will automatically use the NEON_ACCESS_TOKEN and NEON_PROJECT_ID environment variables
186
+ extensions: [syncNeonEnvVars()],
187
+ },
188
+ });
189
+ ```
190
+
191
+ Or you can pass in the token and project ID as arguments:
192
+
193
+ ```ts
194
+ import { defineConfig } from "@trigger.dev/sdk";
195
+ import { syncNeonEnvVars } from "@trigger.dev/build/extensions/core";
196
+
197
+ export default defineConfig({
198
+ project: "<project ref>",
199
+ // Your other config settings...
200
+ build: {
201
+ extensions: [
202
+ syncNeonEnvVars({
203
+ projectId: "your-neon-project-id",
204
+ neonAccessToken: "your-neon-access-token", // optional, we recommend to keep it as env variable
205
+ branch: "your-branch-name", // optional, defaults to ctx.branch
206
+ databaseName: "your-database-name", // optional, defaults to the first database
207
+ roleName: "your-role-name", // optional, defaults to the database owner
208
+ envVarPrefix: "MY_PREFIX_", // optional, prefix for all synced env vars
209
+ }),
210
+ ],
211
+ },
212
+ });
213
+ ```
214
+
215
+ The extension syncs the following environment variables (with optional prefix):
216
+
217
+ - `DATABASE_URL` - Pooled connection string
218
+ - `DATABASE_URL_UNPOOLED` - Direct connection string
219
+ - `POSTGRES_URL`, `POSTGRES_URL_NO_SSL`, `POSTGRES_URL_NON_POOLING`
220
+ - `POSTGRES_PRISMA_URL` - Connection string optimized for Prisma
221
+ - `POSTGRES_HOST`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DATABASE`
222
+ - `PGHOST`, `PGHOST_UNPOOLED`, `PGUSER`, `PGPASSWORD`, `PGDATABASE`
223
+
224
+ ### syncSupabaseEnvVars
225
+
226
+ The `syncSupabaseEnvVars` build extension syncs environment variables from your Supabase project to Trigger.dev. It uses [Supabase Branching](https://supabase.com/docs/guides/deployment/branching) to automatically detect branches and build the appropriate database connection strings and API keys for your environment.
227
+
228
+ <AccordionGroup>
229
+ <Accordion title="Setting up authentication">
230
+ You need to set the `SUPABASE_ACCESS_TOKEN` and `SUPABASE_PROJECT_ID` environment variables, or pass them
231
+ as arguments to the `syncSupabaseEnvVars` build extension.
232
+
233
+ You can generate a `SUPABASE_ACCESS_TOKEN` in your Supabase [dashboard](https://supabase.com/dashboard/account/tokens).
234
+ </Accordion>
235
+
236
+ <Accordion title="Running in Vercel environment">
237
+ When running the build from a Vercel environment (determined by checking if the `VERCEL`
238
+ environment variable is present), this extension is skipped entirely.
239
+ </Accordion>
240
+ </AccordionGroup>
241
+
242
+ <Note>
243
+ For `prod` environments, this extension uses credentials from your default Supabase
244
+ branch. For `preview` and `staging` environments, it matches the git branch name to a Supabase
245
+ branch and syncs the corresponding database connection strings and API keys. `dev` environments are skipped.
246
+ </Note>
247
+
248
+ ```ts
249
+ import { defineConfig } from "@trigger.dev/sdk";
250
+ import { syncSupabaseEnvVars } from "@trigger.dev/build/extensions/core";
251
+
252
+ export default defineConfig({
253
+ project: "<project ref>",
254
+ // Your other config settings...
255
+ build: {
256
+ // This will automatically use the SUPABASE_ACCESS_TOKEN and SUPABASE_PROJECT_ID environment variables
257
+ extensions: [syncSupabaseEnvVars()],
258
+ },
259
+ });
260
+ ```
261
+
262
+ Or you can pass in the token, project ID, and other options as arguments:
263
+
264
+ ```ts
265
+ import { defineConfig } from "@trigger.dev/sdk";
266
+ import { syncSupabaseEnvVars } from "@trigger.dev/build/extensions/core";
267
+
268
+ export default defineConfig({
269
+ project: "<project ref>",
270
+ // Your other config settings...
271
+ build: {
272
+ extensions: [
273
+ syncSupabaseEnvVars({
274
+ projectId: "your-supabase-project-id",
275
+ supabaseAccessToken: "your-supabase-access-token", // optional, we recommend to keep it as env variable
276
+ branch: "your-branch-name", // optional, defaults to ctx.branch
277
+ envVarPrefix: "MY_PREFIX_", // optional, prefix for all synced env vars
278
+ }),
279
+ ],
280
+ },
281
+ });
282
+ ```
283
+
284
+ The extension syncs the following environment variables (with optional prefix):
285
+
286
+ - `DATABASE_URL`, `POSTGRES_URL`, `SUPABASE_DB_URL` — PostgreSQL connection strings
287
+ - `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE` — Individual connection parameters
288
+ - `SUPABASE_URL` — Supabase API URL
289
+ - `SUPABASE_ANON_KEY` — Anonymous API key
290
+ - `SUPABASE_SERVICE_ROLE_KEY` — Service role API key
291
+ - `SUPABASE_JWT_SECRET` — JWT secret