@trigger.dev/sdk 4.5.0-rc.6 → 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 (191) hide show
  1. package/dist/commonjs/v3/ai.d.ts +171 -5
  2. package/dist/commonjs/v3/ai.js +309 -22
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/chat-server.d.ts +8 -0
  5. package/dist/commonjs/v3/chat-server.js +32 -10
  6. package/dist/commonjs/v3/chat-server.js.map +1 -1
  7. package/dist/commonjs/v3/chat-server.test.js +51 -0
  8. package/dist/commonjs/v3/chat-server.test.js.map +1 -1
  9. package/dist/commonjs/v3/createStartSessionAction.test.js +30 -0
  10. package/dist/commonjs/v3/createStartSessionAction.test.js.map +1 -1
  11. package/dist/commonjs/v3/sessions.d.ts +3 -2
  12. package/dist/commonjs/v3/sessions.js +3 -2
  13. package/dist/commonjs/v3/sessions.js.map +1 -1
  14. package/dist/commonjs/version.js +1 -1
  15. package/dist/esm/v3/ai.d.ts +171 -5
  16. package/dist/esm/v3/ai.js +309 -22
  17. package/dist/esm/v3/ai.js.map +1 -1
  18. package/dist/esm/v3/chat-server.d.ts +8 -0
  19. package/dist/esm/v3/chat-server.js +32 -10
  20. package/dist/esm/v3/chat-server.js.map +1 -1
  21. package/dist/esm/v3/chat-server.test.js +51 -0
  22. package/dist/esm/v3/chat-server.test.js.map +1 -1
  23. package/dist/esm/v3/createStartSessionAction.test.js +30 -0
  24. package/dist/esm/v3/createStartSessionAction.test.js.map +1 -1
  25. package/dist/esm/v3/sessions.d.ts +3 -2
  26. package/dist/esm/v3/sessions.js +3 -2
  27. package/dist/esm/v3/sessions.js.map +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/docs/ai/prompts.mdx +430 -0
  30. package/docs/ai-chat/actions.mdx +115 -0
  31. package/docs/ai-chat/anatomy.mdx +71 -0
  32. package/docs/ai-chat/backend.mdx +817 -0
  33. package/docs/ai-chat/background-injection.mdx +221 -0
  34. package/docs/ai-chat/changelog.mdx +850 -0
  35. package/docs/ai-chat/chat-local.mdx +174 -0
  36. package/docs/ai-chat/client-protocol.mdx +1081 -0
  37. package/docs/ai-chat/compaction.mdx +411 -0
  38. package/docs/ai-chat/custom-agents.mdx +364 -0
  39. package/docs/ai-chat/error-handling.mdx +415 -0
  40. package/docs/ai-chat/fast-starts.mdx +672 -0
  41. package/docs/ai-chat/frontend.mdx +580 -0
  42. package/docs/ai-chat/how-it-works.mdx +230 -0
  43. package/docs/ai-chat/lifecycle-hooks.mdx +530 -0
  44. package/docs/ai-chat/mcp.mdx +101 -0
  45. package/docs/ai-chat/overview.mdx +90 -0
  46. package/docs/ai-chat/patterns/branching-conversations.mdx +284 -0
  47. package/docs/ai-chat/patterns/code-sandbox.mdx +126 -0
  48. package/docs/ai-chat/patterns/database-persistence.mdx +414 -0
  49. package/docs/ai-chat/patterns/human-in-the-loop.mdx +275 -0
  50. package/docs/ai-chat/patterns/large-payloads.mdx +169 -0
  51. package/docs/ai-chat/patterns/oom-resilience.mdx +120 -0
  52. package/docs/ai-chat/patterns/persistence-and-replay.mdx +211 -0
  53. package/docs/ai-chat/patterns/recovery-boot.mdx +230 -0
  54. package/docs/ai-chat/patterns/skills.mdx +221 -0
  55. package/docs/ai-chat/patterns/sub-agents.mdx +383 -0
  56. package/docs/ai-chat/patterns/tool-result-auditing.mdx +148 -0
  57. package/docs/ai-chat/patterns/trusted-edge-signals.mdx +337 -0
  58. package/docs/ai-chat/patterns/version-upgrades.mdx +172 -0
  59. package/docs/ai-chat/pending-messages.mdx +343 -0
  60. package/docs/ai-chat/prompt-caching.mdx +206 -0
  61. package/docs/ai-chat/quick-start.mdx +161 -0
  62. package/docs/ai-chat/reference.mdx +909 -0
  63. package/docs/ai-chat/server-chat.mdx +263 -0
  64. package/docs/ai-chat/sessions.mdx +333 -0
  65. package/docs/ai-chat/testing.mdx +682 -0
  66. package/docs/ai-chat/tools.mdx +191 -0
  67. package/docs/ai-chat/types.mdx +242 -0
  68. package/docs/ai-chat/upgrade-guide.mdx +515 -0
  69. package/docs/apikeys.mdx +54 -0
  70. package/docs/building-with-ai.mdx +261 -0
  71. package/docs/bulk-actions.mdx +49 -0
  72. package/docs/changelog.mdx +6 -0
  73. package/docs/cli-deploy-commands.mdx +9 -0
  74. package/docs/cli-dev-commands.mdx +9 -0
  75. package/docs/cli-dev.mdx +8 -0
  76. package/docs/cli-init-commands.mdx +58 -0
  77. package/docs/cli-introduction.mdx +25 -0
  78. package/docs/cli-list-profiles-commands.mdx +42 -0
  79. package/docs/cli-login-commands.mdx +33 -0
  80. package/docs/cli-logout-commands.mdx +33 -0
  81. package/docs/cli-preview-archive.mdx +59 -0
  82. package/docs/cli-promote-commands.mdx +9 -0
  83. package/docs/cli-switch.mdx +43 -0
  84. package/docs/cli-update-commands.mdx +42 -0
  85. package/docs/cli-whoami-commands.mdx +33 -0
  86. package/docs/community.mdx +6 -0
  87. package/docs/config/config-file.mdx +602 -0
  88. package/docs/config/extensions/additionalFiles.mdx +38 -0
  89. package/docs/config/extensions/additionalPackages.mdx +40 -0
  90. package/docs/config/extensions/aptGet.mdx +34 -0
  91. package/docs/config/extensions/audioWaveform.mdx +20 -0
  92. package/docs/config/extensions/custom.mdx +380 -0
  93. package/docs/config/extensions/emitDecoratorMetadata.mdx +29 -0
  94. package/docs/config/extensions/esbuildPlugin.mdx +31 -0
  95. package/docs/config/extensions/ffmpeg.mdx +45 -0
  96. package/docs/config/extensions/lightpanda.mdx +56 -0
  97. package/docs/config/extensions/overview.mdx +67 -0
  98. package/docs/config/extensions/playwright.mdx +195 -0
  99. package/docs/config/extensions/prismaExtension.mdx +1014 -0
  100. package/docs/config/extensions/puppeteer.mdx +30 -0
  101. package/docs/config/extensions/pythonExtension.mdx +182 -0
  102. package/docs/config/extensions/syncEnvVars.mdx +291 -0
  103. package/docs/context.mdx +235 -0
  104. package/docs/database-connections.mdx +213 -0
  105. package/docs/deploy-environment-variables.mdx +435 -0
  106. package/docs/deployment/atomic-deployment.mdx +172 -0
  107. package/docs/deployment/overview.mdx +257 -0
  108. package/docs/deployment/preview-branches.mdx +224 -0
  109. package/docs/errors-retrying.mdx +379 -0
  110. package/docs/github-actions.mdx +222 -0
  111. package/docs/github-integration.mdx +136 -0
  112. package/docs/github-repo.mdx +8 -0
  113. package/docs/help-email.mdx +6 -0
  114. package/docs/help-slack.mdx +11 -0
  115. package/docs/hidden-tasks.mdx +56 -0
  116. package/docs/how-it-works.mdx +454 -0
  117. package/docs/how-to-reduce-your-spend.mdx +217 -0
  118. package/docs/idempotency.mdx +504 -0
  119. package/docs/introduction.mdx +223 -0
  120. package/docs/limits.mdx +241 -0
  121. package/docs/logging.mdx +195 -0
  122. package/docs/machines.mdx +952 -0
  123. package/docs/manual-setup.mdx +632 -0
  124. package/docs/mcp-agent-rules.mdx +41 -0
  125. package/docs/mcp-introduction.mdx +385 -0
  126. package/docs/mcp-tools.mdx +273 -0
  127. package/docs/migrating-from-v3.mdx +334 -0
  128. package/docs/observability/dashboards.mdx +102 -0
  129. package/docs/observability/query.mdx +585 -0
  130. package/docs/open-source-contributing.mdx +16 -0
  131. package/docs/open-source-self-hosting.mdx +541 -0
  132. package/docs/private-networking/aws-console-setup.mdx +304 -0
  133. package/docs/private-networking/overview.mdx +144 -0
  134. package/docs/private-networking/troubleshooting.mdx +78 -0
  135. package/docs/queue-concurrency.mdx +354 -0
  136. package/docs/quick-start.mdx +97 -0
  137. package/docs/realtime/auth.mdx +208 -0
  138. package/docs/realtime/backend/overview.mdx +45 -0
  139. package/docs/realtime/backend/streams.mdx +418 -0
  140. package/docs/realtime/backend/subscribe.mdx +225 -0
  141. package/docs/realtime/how-it-works.mdx +94 -0
  142. package/docs/realtime/overview.mdx +63 -0
  143. package/docs/realtime/react-hooks/overview.mdx +73 -0
  144. package/docs/realtime/react-hooks/streams.mdx +449 -0
  145. package/docs/realtime/react-hooks/subscribe.mdx +674 -0
  146. package/docs/realtime/react-hooks/swr.mdx +87 -0
  147. package/docs/realtime/react-hooks/triggering.mdx +194 -0
  148. package/docs/realtime/react-hooks/use-wait-token.mdx +34 -0
  149. package/docs/realtime/run-object.mdx +174 -0
  150. package/docs/replaying.mdx +72 -0
  151. package/docs/request-feature.mdx +6 -0
  152. package/docs/roadmap.mdx +6 -0
  153. package/docs/run-tests.mdx +20 -0
  154. package/docs/run-usage.mdx +113 -0
  155. package/docs/runs/heartbeats.mdx +38 -0
  156. package/docs/runs/max-duration.mdx +139 -0
  157. package/docs/runs/metadata.mdx +734 -0
  158. package/docs/runs/priority.mdx +31 -0
  159. package/docs/runs.mdx +396 -0
  160. package/docs/self-hosting/docker.mdx +458 -0
  161. package/docs/self-hosting/env/supervisor.mdx +74 -0
  162. package/docs/self-hosting/env/webapp.mdx +276 -0
  163. package/docs/self-hosting/kubernetes.mdx +601 -0
  164. package/docs/self-hosting/overview.mdx +108 -0
  165. package/docs/skills.mdx +85 -0
  166. package/docs/tags.mdx +120 -0
  167. package/docs/tasks/overview.mdx +697 -0
  168. package/docs/tasks/scheduled.mdx +382 -0
  169. package/docs/tasks/schemaTask.mdx +413 -0
  170. package/docs/tasks/streams.mdx +884 -0
  171. package/docs/triggering.mdx +1320 -0
  172. package/docs/troubleshooting-alerts.mdx +385 -0
  173. package/docs/troubleshooting-debugging-in-vscode.mdx +8 -0
  174. package/docs/troubleshooting-github-issues.mdx +6 -0
  175. package/docs/troubleshooting-uptime-status.mdx +6 -0
  176. package/docs/troubleshooting.mdx +398 -0
  177. package/docs/upgrading-packages.mdx +80 -0
  178. package/docs/vercel-integration.mdx +207 -0
  179. package/docs/versioning.mdx +56 -0
  180. package/docs/video-walkthrough.mdx +23 -0
  181. package/docs/wait-for-token.mdx +540 -0
  182. package/docs/wait-for.mdx +42 -0
  183. package/docs/wait-until.mdx +53 -0
  184. package/docs/wait.mdx +18 -0
  185. package/docs/writing-tasks-introduction.mdx +33 -0
  186. package/package.json +8 -5
  187. package/skills/trigger-authoring-chat-agent/SKILL.md +296 -0
  188. package/skills/trigger-authoring-tasks/SKILL.md +254 -0
  189. package/skills/trigger-chat-agent-advanced/SKILL.md +368 -0
  190. package/skills/trigger-cost-savings/SKILL.md +116 -0
  191. package/skills/trigger-realtime-and-frontend/SKILL.md +276 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: "Additional Files"
3
+ sidebarTitle: "additionalFiles"
4
+ description: "Use the additionalFiles build extension to copy additional files to the build directory"
5
+ ---
6
+
7
+ Import the `additionalFiles` build extension and use it in your `trigger.config.ts` file:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { additionalFiles } from "@trigger.dev/build/extensions/core";
12
+
13
+ export default defineConfig({
14
+ project: "<project ref>",
15
+ // Your other config settings...
16
+ // We strongly recommend setting this to false
17
+ // When set to `false`, the current working directory will be set to the build directory, which more closely matches production behavior.
18
+ legacyDevProcessCwdBehaviour: false, // Default: true
19
+ build: {
20
+ extensions: [additionalFiles({ files: ["./assets/**", "wrangler/wrangler.toml"] })],
21
+ },
22
+ });
23
+ ```
24
+
25
+ This will copy the files specified in the `files` array to the build directory. The `files` array can contain globs. The output paths will match the path of the file, relative to the root of the project.
26
+
27
+ This extension effects both the `dev` and the `deploy` commands, and the resulting paths will be the same for both.
28
+
29
+ If you use `legacyDevProcessCwdBehaviour: false`, you can then do this:
30
+
31
+ ```ts
32
+ import path from "node:path";
33
+
34
+ // You can use `process.cwd()` if you use `legacyDevProcessCwdBehaviour: false`
35
+ const interRegularFont = path.join(process.cwd(), "assets/Inter-Regular.ttf");
36
+ ```
37
+
38
+ <Note>The root of the project is the directory that contains the trigger.config.ts file</Note>
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: "Additional Packages"
3
+ sidebarTitle: "additionalPackages"
4
+ description: "Use the additionalPackages build extension to include additional packages in the build"
5
+ ---
6
+
7
+ Import the `additionalPackages` build extension and use it in your `trigger.config.ts` file:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { additionalPackages } from "@trigger.dev/build/extensions/core";
12
+
13
+ export default defineConfig({
14
+ project: "<project ref>",
15
+ // Your other config settings...
16
+ build: {
17
+ // Omit version for auto-resolution; for reproducible builds use e.g. packages: ["wrangler@X.Y.Z"]
18
+ extensions: [additionalPackages({ packages: ["wrangler"] })],
19
+ },
20
+ });
21
+ ```
22
+
23
+ This allows you to include additional packages in the build that are not automatically included via imports. This is useful if you want to install a package that includes a CLI tool you can invoke in your tasks via `exec`. We will try to automatically resolve the version of the package but you can specify the version by using the `@` symbol.
24
+
25
+ If you omit the version, the build may use a cached or older resolution. For reproducible builds, pin the exact version (e.g. `wrangler@X.Y.Z`).
26
+
27
+ ```ts
28
+ import { defineConfig } from "@trigger.dev/sdk";
29
+ import { additionalPackages } from "@trigger.dev/build/extensions/core";
30
+
31
+ export default defineConfig({
32
+ project: "<project ref>",
33
+ // Your other config settings...
34
+ build: {
35
+ extensions: [additionalPackages({ packages: ["wrangler@X.Y.Z"] })],
36
+ },
37
+ });
38
+ ```
39
+
40
+ This extension does not do anything in `dev` mode, but it will install the packages in the build directory when you run `deploy`. The packages will be installed in the `node_modules` directory in the build directory.
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: "apt-get"
3
+ sidebarTitle: "aptGet"
4
+ description: "Use the aptGet build extension to install system packages into the deployed image"
5
+ ---
6
+
7
+ You can install system packages into the deployed image using the `aptGet` extension:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { aptGet } from "@trigger.dev/build/extensions/core";
12
+
13
+ export default defineConfig({
14
+ project: "<project ref>",
15
+ // Your other config settings...
16
+ build: {
17
+ extensions: [aptGet({ packages: ["ffmpeg"] })],
18
+ },
19
+ });
20
+ ```
21
+
22
+ If you want to install a specific version of a package, you can specify the version like this:
23
+
24
+ ```ts
25
+ import { defineConfig } from "@trigger.dev/sdk";
26
+
27
+ export default defineConfig({
28
+ project: "<project ref>",
29
+ // Your other config settings...
30
+ build: {
31
+ extensions: [aptGet({ packages: ["ffmpeg=6.0-4"] })],
32
+ },
33
+ });
34
+ ```
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: "Audio Waveform"
3
+ sidebarTitle: "audioWaveform"
4
+ description: "Use the audioWaveform build extension to add support for Audio Waveform in your project"
5
+ ---
6
+
7
+ Previously, we installed [Audio Waveform](https://github.com/bbc/audiowaveform) in the build image. That's been moved to a build extension:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { audioWaveform } from "@trigger.dev/build/extensions/audioWaveform";
12
+
13
+ export default defineConfig({
14
+ project: "<project ref>",
15
+ // Your other config settings...
16
+ build: {
17
+ extensions: [audioWaveform()], // uses verson 1.1.0 of audiowaveform by default
18
+ },
19
+ });
20
+ ```
@@ -0,0 +1,380 @@
1
+ ---
2
+ title: "Custom build extensions"
3
+ sidebarTitle: "Custom"
4
+ description: "Customize how your project is built and deployed to Trigger.dev with your own custom build extensions"
5
+ ---
6
+
7
+ Build extensions allow you to hook into the build system and customize the build process or the resulting bundle and container image (in the case of deploying). See our [build extension overview](/config/extensions/overview) for more information on how to install and use our built-in extensions. Build extensions can do the following:
8
+
9
+ - Add additional files to the build
10
+ - Add dependencies to the list of externals
11
+ - Add esbuild plugins
12
+ - Add additional npm dependencies
13
+ - Add additional system packages to the image build container
14
+ - Add commands to run in the image build container
15
+ - Add environment variables to the image build container
16
+ - Sync environment variables to your Trigger.dev project
17
+
18
+ ## Creating a build extension
19
+
20
+ Build extensions are added to your `trigger.config.ts` file, with a required `name` and optional build hook functions. Here's a simple example of a build extension that just logs a message when the build starts:
21
+
22
+ ```ts
23
+ import { defineConfig } from "@trigger.dev/sdk";
24
+
25
+ export default defineConfig({
26
+ project: "my-project",
27
+ build: {
28
+ extensions: [
29
+ {
30
+ name: "my-extension",
31
+ onBuildStart: async (context) => {
32
+ console.log("Build starting!");
33
+ },
34
+ },
35
+ ],
36
+ },
37
+ });
38
+ ```
39
+
40
+ You can also extract that out into a function instead of defining it inline, in which case you will need to import the `BuildExtension` type from the `@trigger.dev/build` package:
41
+
42
+ <Note>
43
+ You'll need to add the `@trigger.dev/build` package to your `devDependencies` before the below
44
+ code will work. Make sure it's version matches that of the installed `@trigger.dev/sdk` package.
45
+ </Note>
46
+
47
+ ```ts
48
+ import { defineConfig } from "@trigger.dev/sdk";
49
+ import { BuildExtension } from "@trigger.dev/build";
50
+
51
+ export default defineConfig({
52
+ project: "my-project",
53
+ build: {
54
+ extensions: [myExtension()],
55
+ },
56
+ });
57
+
58
+ function myExtension(): BuildExtension {
59
+ return {
60
+ name: "my-extension",
61
+ onBuildStart: async (context) => {
62
+ console.log("Build starting!");
63
+ },
64
+ };
65
+ }
66
+ ```
67
+
68
+ ## Build hooks
69
+
70
+ ### externalsForTarget
71
+
72
+ This allows the extension to add additional dependencies to the list of externals for the build. This is useful for dependencies that are not included in the bundle, but are expected to be available at runtime.
73
+
74
+ ```ts
75
+ import { defineConfig } from "@trigger.dev/sdk";
76
+
77
+ export default defineConfig({
78
+ project: "my-project",
79
+ build: {
80
+ extensions: [
81
+ {
82
+ name: "my-extension",
83
+ externalsForTarget: async (target) => {
84
+ return ["my-dependency"];
85
+ },
86
+ },
87
+ ],
88
+ },
89
+ });
90
+ ```
91
+
92
+ ### onBuildStart
93
+
94
+ This hook runs before the build starts. It receives the `BuildContext` object as an argument.
95
+
96
+ ```ts
97
+ import { defineConfig } from "@trigger.dev/sdk";
98
+
99
+ export default defineConfig({
100
+ project: "my-project",
101
+ build: {
102
+ extensions: [
103
+ {
104
+ name: "my-extension",
105
+ onBuildStart: async (context) => {
106
+ console.log("Build starting!");
107
+ },
108
+ },
109
+ ],
110
+ },
111
+ });
112
+ ```
113
+
114
+ If you want to add an esbuild plugin, you must do so in the `onBuildStart` hook. Here's an example of adding a custom esbuild plugin:
115
+
116
+ ```ts
117
+ import { defineConfig } from "@trigger.dev/sdk";
118
+
119
+ export default defineConfig({
120
+ project: "my-project",
121
+ build: {
122
+ extensions: [
123
+ {
124
+ name: "my-extension",
125
+ onBuildStart: async (context) => {
126
+ context.registerPlugin({
127
+ name: "my-plugin",
128
+ setup(build) {
129
+ build.onLoad({ filter: /.*/, namespace: "file" }, async (args) => {
130
+ return {
131
+ contents: "console.log('Hello, world!')",
132
+ loader: "js",
133
+ };
134
+ });
135
+ },
136
+ });
137
+ },
138
+ },
139
+ ],
140
+ },
141
+ });
142
+ ```
143
+
144
+ You can use the `BuildContext.target` property to determine if the build is for `dev` or `deploy`:
145
+
146
+ ```ts
147
+ import { defineConfig } from "@trigger.dev/sdk";
148
+
149
+ export default defineConfig({
150
+ project: "my-project",
151
+ build: {
152
+ extensions: [
153
+ {
154
+ name: "my-extension",
155
+ onBuildStart: async (context) => {
156
+ if (context.target === "dev") {
157
+ console.log("Building for dev");
158
+ } else {
159
+ console.log("Building for deploy");
160
+ }
161
+ },
162
+ },
163
+ ],
164
+ },
165
+ });
166
+ ```
167
+
168
+ ### onBuildComplete
169
+
170
+ This hook runs after the build completes. It receives the `BuildContext` object and a `BuildManifest` object as arguments. This is where you can add in one or more `BuildLayer`'s to the context.
171
+
172
+ ```ts
173
+ import { defineConfig } from "@trigger.dev/sdk";
174
+
175
+ export default defineConfig({
176
+ project: "my-project",
177
+ build: {
178
+ extensions: [
179
+ {
180
+ name: "my-extension",
181
+ onBuildComplete: async (context, manifest) => {
182
+ context.addLayer({
183
+ id: "more-dependencies",
184
+ dependencies,
185
+ });
186
+ },
187
+ },
188
+ ],
189
+ },
190
+ });
191
+ ```
192
+
193
+ See the [addLayer](#addlayer) documentation for more information on how to use `addLayer`.
194
+
195
+ ## BuildTarget
196
+
197
+ Can either be `dev` or `deploy`, matching the CLI command name that is being run.
198
+
199
+ ```sh
200
+ npx trigger.dev@latest dev # BuildTarget is "dev"
201
+ npx trigger.dev@latest deploy # BuildTarget is "deploy"
202
+ ```
203
+
204
+ ## BuildContext
205
+
206
+ ### addLayer()
207
+
208
+ <ParamField path="layer" type="BuildLayer">
209
+ The layer to add to the build context. See the [BuildLayer](#buildlayer) documentation for more
210
+ information.
211
+ </ParamField>
212
+
213
+ ### registerPlugin()
214
+
215
+ <ParamField path="plugin" type="esbuild.Plugin" required>
216
+ The esbuild plugin to register.
217
+ </ParamField>
218
+
219
+ <ParamField path="options" type="object">
220
+ <Expandable title="properties">
221
+ <ResponseField name="target" type="BuildTarget">
222
+ An optional target to register the plugin for. If not provided, the plugin will be registered
223
+ for all targets.
224
+ </ResponseField>
225
+ <ResponseField name="placement" type="first | last">
226
+ An optional placement for the plugin. If not provided, the plugin will be registered in place.
227
+ This allows you to control the order of plugins.
228
+ </ResponseField>
229
+ </Expandable>
230
+ </ParamField>
231
+
232
+ ### resolvePath()
233
+
234
+ Resolves a path relative to the project's working directory.
235
+
236
+ <ParamField path="path" type="string">
237
+ The path to resolve.
238
+ </ParamField>
239
+
240
+ ```ts
241
+ const resolvedPath = context.resolvePath("my-other-dependency");
242
+ ```
243
+
244
+ ### properties
245
+
246
+ <ParamField path="target" type="BuildTarget">
247
+ The target of the build, either `dev` or `deploy`.
248
+ </ParamField>
249
+
250
+ <ParamField path="config" type="ResolvedConfig">
251
+ <Expandable title="properties">
252
+ <ResponseField name="runtime" type="string">
253
+ The runtime of the project (either node or bun)
254
+ </ResponseField>
255
+ <ResponseField name="project" type="string">
256
+ The project ref
257
+ </ResponseField>
258
+ <ResponseField name="dirs" type="string[]">
259
+ The trigger directories to search for tasks
260
+ </ResponseField>
261
+ <ResponseField name="build" type="object">
262
+ The build configuration object
263
+ </ResponseField>
264
+ <ResponseField name="workingDir" type="string">
265
+ The working directory of the project
266
+ </ResponseField>
267
+ <ResponseField name="workspaceDir" type="string">
268
+ The root workspace directory of the project
269
+ </ResponseField>
270
+ <ResponseField name="packageJsonPath" type="string">
271
+ The path to the package.json file
272
+ </ResponseField>
273
+ <ResponseField name="lockfilePath" type="string">
274
+ The path to the lockfile (package-lock.json, yarn.lock, or pnpm-lock.yaml)
275
+ </ResponseField>
276
+ <ResponseField name="configFile" type="string">
277
+ The path to the trigger.config.ts file
278
+ </ResponseField>
279
+ <ResponseField name="tsconfigPath" type="string">
280
+ The path to the tsconfig.json file
281
+ </ResponseField>
282
+ </Expandable>
283
+ </ParamField>
284
+
285
+ <ParamField path="logger" type="BuildLogger">
286
+ A logger object that can be used to log messages to the console.
287
+ </ParamField>
288
+
289
+ ## BuildLayer
290
+
291
+ <ParamField path="id" type="string">
292
+ A unique identifier for the layer.
293
+ </ParamField>
294
+
295
+ <ParamField path="commands" type="string[]">
296
+ An array of commands to run in the image build container.
297
+
298
+ ```ts
299
+ commands: ["echo 'Hello, world!'"];
300
+ ```
301
+
302
+ These commands are run after packages have been installed and the code copied into the container in the "build" stage of the Dockerfile. This means you cannot install system packages in these commands because they won't be available in the final stage. To do that, please use the `pkgs` property of the `image` object.
303
+
304
+ </ParamField>
305
+
306
+ <ParamField path="image" type="object">
307
+ <Expandable title="properties">
308
+ <ResponseField name="pkgs" type="string[]">
309
+ An array of system packages to install in the image build container.
310
+ </ResponseField>
311
+ <ResponseField name="instructions" type="string[]">
312
+ An array of instructions to add to the Dockerfile.
313
+ </ResponseField>
314
+ </Expandable>
315
+ </ParamField>
316
+
317
+ <ParamField path="build" type="object">
318
+ <Expandable title="properties">
319
+ <ResponseField name="env" type="Record<string, string>">
320
+ Environment variables to add to the image build container, but only during the "build" stage
321
+ of the Dockerfile. This is where you'd put environment variables that are needed when running
322
+ any of the commands in the `commands` array.
323
+ </ResponseField>
324
+ </Expandable>
325
+ </ParamField>
326
+
327
+ <ParamField path="deploy" type="object">
328
+ <Expandable title="properties">
329
+ <ResponseField name="env" type="Record<string, string>">
330
+ Environment variables that should sync to the Trigger.dev project, which will then be avalable
331
+ in your tasks at runtime. Importantly, these are NOT added to the image build container, but
332
+ are instead added to the Trigger.dev project and stored securely.
333
+ </ResponseField>
334
+ </Expandable>
335
+ </ParamField>
336
+
337
+ <ParamField path="dependencies" type="Record<string, string>">
338
+ An object of dependencies to add to the build. The key is the package name and the value is the
339
+ version.
340
+
341
+ ```ts
342
+ dependencies: {
343
+ "my-dependency": "^1.0.0",
344
+ };
345
+ ```
346
+
347
+ </ParamField>
348
+
349
+ ### examples
350
+
351
+ Add a command that will echo the value of an environment variable:
352
+
353
+ ```ts
354
+ context.addLayer({
355
+ id: "my-layer",
356
+ commands: [`echo $MY_ENV_VAR`],
357
+ build: {
358
+ env: {
359
+ MY_ENV_VAR: "Hello, world!",
360
+ },
361
+ },
362
+ });
363
+ ```
364
+
365
+ ## Troubleshooting
366
+
367
+ When creating a build extension, you may run into issues with the build process. One thing that can help is turning on `debug` logging when running either `dev` or `deploy`:
368
+
369
+ ```sh
370
+ npx trigger.dev@latest dev --log-level debug
371
+ npx trigger.dev@latest deploy --log-level debug
372
+ ```
373
+
374
+ Another helpful tool is the `--dry-run` flag on the `deploy` command, which will bundle your project and generate the Containerfile (e.g. the Dockerfile) without actually deploying it. This can help you see what the final image will look like and debug any issues with the build process.
375
+
376
+ ```sh
377
+ npx trigger.dev@latest deploy --dry-run
378
+ ```
379
+
380
+ You should also take a look at our built in extensions for inspiration on how to create your own. You can find them in in [the source code here](https://github.com/triggerdotdev/trigger.dev/tree/main/packages/build/src/extensions).
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: "Emit Decorator Metadata"
3
+ sidebarTitle: "emitDecoratorMetadata"
4
+ description: "Use the emitDecoratorMetadata build extension to enable support for the emitDecoratorMetadata TypeScript compiler option"
5
+ ---
6
+
7
+ If you need support for the `emitDecoratorMetadata` typescript compiler option, import the `emitDecoratorMetadata` build extension and use it in your `trigger.config.ts` file:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { emitDecoratorMetadata } from "@trigger.dev/build/extensions/typescript";
12
+
13
+ export default defineConfig({
14
+ project: "<project ref>",
15
+ // Your other config settings...
16
+ build: {
17
+ extensions: [emitDecoratorMetadata()],
18
+ },
19
+ });
20
+ ```
21
+
22
+ This is usually required if you are using certain ORMs, like TypeORM, that require this option to be enabled. It's not enabled by default because there is a performance cost to enabling it.
23
+
24
+ <Note>
25
+ emitDecoratorMetadata works by hooking into the esbuild bundle process and using the TypeScript
26
+ compiler API to compile files where we detect the use of decorators. This means you must have
27
+ `emitDecoratorMetadata` enabled in your `tsconfig.json` file, as well as `typescript` installed in
28
+ your `devDependencies`.
29
+ </Note>
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: "esbuild Plugin"
3
+ sidebarTitle: "esbuildPlugin"
4
+ description: "Use the esbuildPlugin build extension to add existing or custom esbuild plugins to your build process"
5
+ ---
6
+
7
+ You can easily add existing or custom esbuild plugins to your build process using the `esbuildPlugin` extension:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { esbuildPlugin } from "@trigger.dev/build/extensions";
12
+ import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
13
+
14
+ export default defineConfig({
15
+ project: "<project ref>",
16
+ // Your other config settings...
17
+ build: {
18
+ extensions: [
19
+ esbuildPlugin(
20
+ sentryEsbuildPlugin({
21
+ org: process.env.SENTRY_ORG,
22
+ project: process.env.SENTRY_PROJECT,
23
+ authToken: process.env.SENTRY_AUTH_TOKEN,
24
+ }),
25
+ // optional - only runs during the deploy command, and adds the plugin to the end of the list of plugins
26
+ { placement: "last", target: "deploy" }
27
+ ),
28
+ ],
29
+ },
30
+ });
31
+ ```
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: "FFmpeg"
3
+ sidebarTitle: "ffmpeg"
4
+ description: "Use the ffmpeg build extension to include FFmpeg in your project"
5
+ ---
6
+
7
+ You can add the `ffmpeg` build extension to your build process:
8
+
9
+ ```ts
10
+ import { defineConfig } from "@trigger.dev/sdk";
11
+ import { ffmpeg } from "@trigger.dev/build/extensions/core";
12
+
13
+ export default defineConfig({
14
+ project: "<project ref>",
15
+ // Your other config settings...
16
+ build: {
17
+ extensions: [ffmpeg()],
18
+ },
19
+ });
20
+ ```
21
+
22
+ By default, this will install the version of `ffmpeg` that is available in the Debian package manager (via `apt`).
23
+
24
+ ## FFmpeg 7.x (static build)
25
+
26
+ If you need FFmpeg 7.x, you can pass `{ version: "7" }` to the extension. This will install a static build of FFmpeg 7.x instead of using the Debian package:
27
+
28
+ ```ts
29
+ import { defineConfig } from "@trigger.dev/sdk";
30
+ import { ffmpeg } from "@trigger.dev/build/extensions/core";
31
+
32
+ export default defineConfig({
33
+ project: "<project ref>",
34
+ // Your other config settings...
35
+ build: {
36
+ extensions: [ffmpeg({ version: "7" })],
37
+ },
38
+ });
39
+ ```
40
+
41
+ This extension will also add the `FFMPEG_PATH` and `FFPROBE_PATH` to your environment variables, making it easy to use popular ffmpeg libraries like `fluent-ffmpeg`.
42
+
43
+ Note that `fluent-ffmpeg` needs to be added to [`external`](/config/config-file#external) in your `trigger.config.ts` file.
44
+
45
+ Follow [this example](/guides/examples/ffmpeg-video-processing) to get setup with Trigger.dev and FFmpeg in your project.
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: "Lightpanda"
3
+ sidebarTitle: "lightpanda"
4
+ description: "Use the lightpanda build extension to add Lightpanda browser to your project"
5
+ tag: "v4"
6
+ ---
7
+
8
+ To use the Lightpanda browser in your project, add the extension to your `trigger.config.ts` file:
9
+
10
+ ```ts trigger.config.ts
11
+ import { defineConfig } from "@trigger.dev/sdk";
12
+ import { lightpanda } from "@trigger.dev/build/extensions/lightpanda";
13
+
14
+ export default defineConfig({
15
+ project: "<project ref>",
16
+ build: {
17
+ extensions: [lightpanda()],
18
+ },
19
+ });
20
+ ```
21
+
22
+ ## Options
23
+
24
+ - `version`: The version of the browser to install. Default: `"latest"`.
25
+ - `disableTelemetry`: Whether to disable telemetry. Default: `false`.
26
+
27
+ For example:
28
+
29
+ ```ts trigger.config.ts
30
+ import { defineConfig } from "@trigger.dev/sdk";
31
+ import { lightpanda } from "@trigger.dev/build/extensions/lightpanda";
32
+
33
+ export default defineConfig({
34
+ project: "<project ref>",
35
+ build: {
36
+ extensions: [
37
+ lightpanda({
38
+ version: "nightly",
39
+ disableTelemetry: true,
40
+ }),
41
+ ],
42
+ },
43
+ });
44
+ ```
45
+
46
+ ## Development
47
+
48
+ When running in dev, you will first have to download the Lightpanda browser binary and make sure it's in your `PATH`. See [Lightpanda's installation guide](https://lightpanda.io/docs/getting-started/installation).
49
+
50
+ ## Next steps
51
+
52
+ <CardGroup>
53
+ <Card title="Lightpanda" color="#6ac6e2" icon="bolt" href="/guides/examples/lightpanda">
54
+ Learn how to use Lightpanda in your project.
55
+ </Card>
56
+ </CardGroup>