@trigger.dev/build 0.0.0-chat-prerelease-20260517214402 → 0.0.0-chat-prerelease-20260520150857

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.
@@ -1,15 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addAdditionalFilesToBuild = addAdditionalFilesToBuild;
4
- const promises_1 = require("node:fs/promises");
5
- const node_path_1 = require("node:path");
6
- const tinyglobby_1 = require("tinyglobby");
4
+ const copyFiles_js_1 = require("./copyFiles.js");
7
5
  async function addAdditionalFilesToBuild(source, options, context, manifest) {
8
- // Copy any static assets to the destination
9
- const staticAssets = await findStaticAssetFiles(options.files ?? [], manifest.outputPath, {
10
- cwd: context.workingDir,
11
- });
12
- for (const { assets, matcher } of staticAssets) {
6
+ const matcherResults = await (0, copyFiles_js_1.findFilesByMatchers)(options.files ?? [], manifest.outputPath, { cwd: context.workingDir });
7
+ for (const { assets, matcher } of matcherResults) {
13
8
  if (assets.length === 0) {
14
9
  context.logger.warn(`[${source}] No files found for matcher`, matcher);
15
10
  }
@@ -17,47 +12,8 @@ async function addAdditionalFilesToBuild(source, options, context, manifest) {
17
12
  context.logger.debug(`[${source}] Found ${assets.length} files for matcher`, matcher);
18
13
  }
19
14
  }
20
- await copyStaticAssets(staticAssets, source, context);
21
- }
22
- async function findStaticAssetFiles(matchers, destinationPath, options) {
23
- const result = [];
24
- for (const matcher of matchers) {
25
- const assets = await findStaticAssetsForMatcher(matcher, destinationPath, options);
26
- result.push({ matcher, assets });
27
- }
28
- return result;
29
- }
30
- async function findStaticAssetsForMatcher(matcher, destinationPath, options) {
31
- const result = [];
32
- const files = await (0, tinyglobby_1.glob)({
33
- patterns: [matcher],
34
- cwd: options?.cwd,
35
- ignore: options?.ignore ?? [],
36
- onlyFiles: true,
37
- absolute: true,
15
+ await (0, copyFiles_js_1.copyMatcherResults)(matcherResults, (pair) => {
16
+ context.logger.debug(`[${source}] Copying ${pair.source} to ${pair.destination}`);
38
17
  });
39
- let matches = 0;
40
- for (const file of files) {
41
- matches++;
42
- const pathInsideDestinationDir = (0, node_path_1.relative)(options?.cwd ?? process.cwd(), file)
43
- .split(node_path_1.posix.sep)
44
- .filter((p) => p !== "..")
45
- .join(node_path_1.posix.sep);
46
- const relativeDestinationPath = (0, node_path_1.join)(destinationPath, pathInsideDestinationDir);
47
- result.push({
48
- source: file,
49
- destination: relativeDestinationPath,
50
- });
51
- }
52
- return result;
53
- }
54
- async function copyStaticAssets(staticAssetFiles, sourceName, context) {
55
- for (const { assets } of staticAssetFiles) {
56
- for (const { source, destination } of assets) {
57
- await (0, promises_1.mkdir)((0, node_path_1.dirname)(destination), { recursive: true });
58
- context.logger.debug(`[${sourceName}] Copying ${source} to ${destination}`);
59
- await (0, promises_1.copyFile)(source, destination);
60
- }
61
- }
62
18
  }
63
19
  //# sourceMappingURL=additionalFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"additionalFiles.js","sourceRoot":"","sources":["../../../src/internal/additionalFiles.ts"],"names":[],"mappings":";;AAUA,8DAoBC;AA5BD,+CAAmD;AACnD,yCAA2D;AAC3D,2CAAkC;AAM3B,KAAK,UAAU,yBAAyB,CAC7C,MAAc,EACd,OAA+B,EAC/B,OAAqB,EACrB,QAAuB;IAEvB,4CAA4C;IAC5C,MAAM,YAAY,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,QAAQ,CAAC,UAAU,EAAE;QACxF,GAAG,EAAE,OAAO,CAAC,UAAU;KACxB,CAAC,CAAC;IAEH,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,8BAA8B,EAAE,OAAO,CAAC,CAAC;QACzE,CAAC;aAAM,CA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EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,8BAA8B,EAAE,OAAO,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,WAAW,MAAM,CAAC,MAAM,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;IAED,MAAM,IAAA,iCAAkB,EAAC,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE;QAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,aAAa,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * A single matched asset — source file and its destination inside the
3
+ * build output directory.
4
+ */
5
+ export type CopyPair = {
6
+ source: string;
7
+ destination: string;
8
+ };
9
+ /**
10
+ * Result of a single matcher's glob, grouped with the matcher that
11
+ * produced it so callers can warn on empty matches.
12
+ */
13
+ export type MatcherResult = {
14
+ matcher: string;
15
+ assets: CopyPair[];
16
+ };
17
+ /**
18
+ * Glob a set of matchers relative to `cwd` and return pairs describing
19
+ * where each matched file should be copied to under `destinationDir`.
20
+ *
21
+ * Relative paths are preserved under `destinationDir`. Leading `..`
22
+ * segments (from `../shared/file.txt` style patterns) are stripped so
23
+ * files always land inside the destination.
24
+ */
25
+ export declare function findFilesByMatchers(matchers: string[], destinationDir: string, options?: {
26
+ cwd?: string;
27
+ ignore?: string[];
28
+ }): Promise<MatcherResult[]>;
29
+ /**
30
+ * Copy a single file, creating parent directories as needed.
31
+ */
32
+ export declare function copyFileEnsuringDir(source: string, destination: string): Promise<void>;
33
+ /**
34
+ * Copy every pair in the given matcher results. Parent directories are
35
+ * created automatically. Returns the total number of files copied.
36
+ */
37
+ export declare function copyMatcherResults(matcherResults: MatcherResult[], onCopy?: (pair: CopyPair) => void): Promise<number>;
38
+ /**
39
+ * Recursively copy a directory to another location. Preserves structure;
40
+ * overwrites existing files at the destination.
41
+ *
42
+ * Used by the built-in skill bundler — we copy entire skill folders as a
43
+ * unit, not file-by-file.
44
+ */
45
+ export declare function copyDirectoryRecursive(source: string, destination: string): Promise<void>;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findFilesByMatchers = findFilesByMatchers;
4
+ exports.copyFileEnsuringDir = copyFileEnsuringDir;
5
+ exports.copyMatcherResults = copyMatcherResults;
6
+ exports.copyDirectoryRecursive = copyDirectoryRecursive;
7
+ const promises_1 = require("node:fs/promises");
8
+ const node_path_1 = require("node:path");
9
+ const tinyglobby_1 = require("tinyglobby");
10
+ /**
11
+ * Glob a set of matchers relative to `cwd` and return pairs describing
12
+ * where each matched file should be copied to under `destinationDir`.
13
+ *
14
+ * Relative paths are preserved under `destinationDir`. Leading `..`
15
+ * segments (from `../shared/file.txt` style patterns) are stripped so
16
+ * files always land inside the destination.
17
+ */
18
+ async function findFilesByMatchers(matchers, destinationDir, options) {
19
+ const result = [];
20
+ const cwd = options?.cwd ?? process.cwd();
21
+ for (const matcher of matchers) {
22
+ const files = await (0, tinyglobby_1.glob)({
23
+ patterns: [matcher],
24
+ cwd,
25
+ ignore: options?.ignore ?? [],
26
+ onlyFiles: true,
27
+ absolute: true,
28
+ });
29
+ const assets = files.map((file) => {
30
+ const pathInsideDestinationDir = (0, node_path_1.relative)(cwd, file)
31
+ .split(node_path_1.posix.sep)
32
+ .filter((p) => p !== "..")
33
+ .join(node_path_1.posix.sep);
34
+ return {
35
+ source: file,
36
+ destination: (0, node_path_1.join)(destinationDir, pathInsideDestinationDir),
37
+ };
38
+ });
39
+ result.push({ matcher, assets });
40
+ }
41
+ return result;
42
+ }
43
+ /**
44
+ * Copy a single file, creating parent directories as needed.
45
+ */
46
+ async function copyFileEnsuringDir(source, destination) {
47
+ await (0, promises_1.mkdir)((0, node_path_1.dirname)(destination), { recursive: true });
48
+ await (0, promises_1.copyFile)(source, destination);
49
+ }
50
+ /**
51
+ * Copy every pair in the given matcher results. Parent directories are
52
+ * created automatically. Returns the total number of files copied.
53
+ */
54
+ async function copyMatcherResults(matcherResults, onCopy) {
55
+ let count = 0;
56
+ for (const { assets } of matcherResults) {
57
+ for (const pair of assets) {
58
+ onCopy?.(pair);
59
+ await copyFileEnsuringDir(pair.source, pair.destination);
60
+ count++;
61
+ }
62
+ }
63
+ return count;
64
+ }
65
+ /**
66
+ * Recursively copy a directory to another location. Preserves structure;
67
+ * overwrites existing files at the destination.
68
+ *
69
+ * Used by the built-in skill bundler — we copy entire skill folders as a
70
+ * unit, not file-by-file.
71
+ */
72
+ async function copyDirectoryRecursive(source, destination) {
73
+ await (0, promises_1.mkdir)(destination, { recursive: true });
74
+ await (0, promises_1.cp)(source, destination, { recursive: true, force: true });
75
+ }
76
+ //# sourceMappingURL=copyFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyFiles.js","sourceRoot":"","sources":["../../../src/internal/copyFiles.ts"],"names":[],"mappings":";;AA2BA,kDAgCC;AAKD,kDAGC;AAMD,gDAaC;AASD,wDAGC;AAlGD,+CAAuD;AACvD,yCAA2D;AAC3D,2CAAkC;AAiBlC;;;;;;;GAOG;AACI,KAAK,UAAU,mBAAmB,CACvC,QAAkB,EAClB,cAAsB,EACtB,OAA6C;IAE7C,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAI,EAAC;YACvB,QAAQ,EAAE,CAAC,OAAO,CAAC;YACnB,GAAG;YACH,MAAM,EAAE,OAAO,EAAE,MAAM,IAA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,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,sBAAsB,CAAC,MAAc,EAAE,WAAmB;IAC9E,MAAM,IAAA,gBAAK,EAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,IAAA,aAAE,EAAC,MAAM,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from "./internal/additionalFiles.js";
2
+ export * from "./internal/copyFiles.js";
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./internal/additionalFiles.js"), exports);
18
+ __exportStar(require("./internal/copyFiles.js"), exports);
18
19
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C"}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,0DAAwC"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "0.0.0-chat-prerelease-20260517214402";
4
+ exports.VERSION = "0.0.0-chat-prerelease-20260520150857";
5
5
  //# sourceMappingURL=version.js.map
@@ -1,12 +1,7 @@
1
- import { copyFile, mkdir } from "node:fs/promises";
2
- import { dirname, join, posix, relative } from "node:path";
3
- import { glob } from "tinyglobby";
1
+ import { copyMatcherResults, findFilesByMatchers, } from "./copyFiles.js";
4
2
  export async function addAdditionalFilesToBuild(source, options, context, manifest) {
5
- // Copy any static assets to the destination
6
- const staticAssets = await findStaticAssetFiles(options.files ?? [], manifest.outputPath, {
7
- cwd: context.workingDir,
8
- });
9
- for (const { assets, matcher } of staticAssets) {
3
+ const matcherResults = await findFilesByMatchers(options.files ?? [], manifest.outputPath, { cwd: context.workingDir });
4
+ for (const { assets, matcher } of matcherResults) {
10
5
  if (assets.length === 0) {
11
6
  context.logger.warn(`[${source}] No files found for matcher`, matcher);
12
7
  }
@@ -14,47 +9,8 @@ export async function addAdditionalFilesToBuild(source, options, context, manife
14
9
  context.logger.debug(`[${source}] Found ${assets.length} files for matcher`, matcher);
15
10
  }
16
11
  }
17
- await copyStaticAssets(staticAssets, source, context);
18
- }
19
- async function findStaticAssetFiles(matchers, destinationPath, options) {
20
- const result = [];
21
- for (const matcher of matchers) {
22
- const assets = await findStaticAssetsForMatcher(matcher, destinationPath, options);
23
- result.push({ matcher, assets });
24
- }
25
- return result;
26
- }
27
- async function findStaticAssetsForMatcher(matcher, destinationPath, options) {
28
- const result = [];
29
- const files = await glob({
30
- patterns: [matcher],
31
- cwd: options?.cwd,
32
- ignore: options?.ignore ?? [],
33
- onlyFiles: true,
34
- absolute: true,
12
+ await copyMatcherResults(matcherResults, (pair) => {
13
+ context.logger.debug(`[${source}] Copying ${pair.source} to ${pair.destination}`);
35
14
  });
36
- let matches = 0;
37
- for (const file of files) {
38
- matches++;
39
- const pathInsideDestinationDir = relative(options?.cwd ?? process.cwd(), file)
40
- .split(posix.sep)
41
- .filter((p) => p !== "..")
42
- .join(posix.sep);
43
- const relativeDestinationPath = join(destinationPath, pathInsideDestinationDir);
44
- result.push({
45
- source: file,
46
- destination: relativeDestinationPath,
47
- });
48
- }
49
- return result;
50
- }
51
- async function copyStaticAssets(staticAssetFiles, sourceName, context) {
52
- for (const { assets } of staticAssetFiles) {
53
- for (const { source, destination } of assets) {
54
- await mkdir(dirname(destination), { recursive: true });
55
- context.logger.debug(`[${sourceName}] Copying ${source} to ${destination}`);
56
- await copyFile(source, destination);
57
- }
58
- }
59
15
  }
60
16
  //# sourceMappingURL=additionalFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"additionalFiles.js","sourceRoot":"","sources":["../../../src/internal/additionalFiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMlC,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAc,EACd,OAA+B,EAC/B,OAAqB,EACrB,QAAuB;IAEvB,4CAA4C;IAC5C,MAAM,YAAY,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,QAAQ,CAAC,UAAU,EAAE;QACxF,GAAG,EAAE,OAAO,CAAC,UAAU;KACxB,CAAC,CAAC;IAEH,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,8BAA8B,EAAE,OAAO,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,WAAW,MAAM,CAAC,MAAM,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;IAED,MAAM,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AASD,KAAK,UAAU,oBAAoB,CACjC,QAAkB,EAClB,eAAuB,EACvB,OAA6C;IAE7C,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;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ChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,aAAa,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * A single matched asset — source file and its destination inside the
3
+ * build output directory.
4
+ */
5
+ export type CopyPair = {
6
+ source: string;
7
+ destination: string;
8
+ };
9
+ /**
10
+ * Result of a single matcher's glob, grouped with the matcher that
11
+ * produced it so callers can warn on empty matches.
12
+ */
13
+ export type MatcherResult = {
14
+ matcher: string;
15
+ assets: CopyPair[];
16
+ };
17
+ /**
18
+ * Glob a set of matchers relative to `cwd` and return pairs describing
19
+ * where each matched file should be copied to under `destinationDir`.
20
+ *
21
+ * Relative paths are preserved under `destinationDir`. Leading `..`
22
+ * segments (from `../shared/file.txt` style patterns) are stripped so
23
+ * files always land inside the destination.
24
+ */
25
+ export declare function findFilesByMatchers(matchers: string[], destinationDir: string, options?: {
26
+ cwd?: string;
27
+ ignore?: string[];
28
+ }): Promise<MatcherResult[]>;
29
+ /**
30
+ * Copy a single file, creating parent directories as needed.
31
+ */
32
+ export declare function copyFileEnsuringDir(source: string, destination: string): Promise<void>;
33
+ /**
34
+ * Copy every pair in the given matcher results. Parent directories are
35
+ * created automatically. Returns the total number of files copied.
36
+ */
37
+ export declare function copyMatcherResults(matcherResults: MatcherResult[], onCopy?: (pair: CopyPair) => void): Promise<number>;
38
+ /**
39
+ * Recursively copy a directory to another location. Preserves structure;
40
+ * overwrites existing files at the destination.
41
+ *
42
+ * Used by the built-in skill bundler — we copy entire skill folders as a
43
+ * unit, not file-by-file.
44
+ */
45
+ export declare function copyDirectoryRecursive(source: string, destination: string): Promise<void>;
@@ -0,0 +1,70 @@
1
+ import { cp, copyFile, mkdir } from "node:fs/promises";
2
+ import { dirname, join, posix, relative } from "node:path";
3
+ import { glob } from "tinyglobby";
4
+ /**
5
+ * Glob a set of matchers relative to `cwd` and return pairs describing
6
+ * where each matched file should be copied to under `destinationDir`.
7
+ *
8
+ * Relative paths are preserved under `destinationDir`. Leading `..`
9
+ * segments (from `../shared/file.txt` style patterns) are stripped so
10
+ * files always land inside the destination.
11
+ */
12
+ export async function findFilesByMatchers(matchers, destinationDir, options) {
13
+ const result = [];
14
+ const cwd = options?.cwd ?? process.cwd();
15
+ for (const matcher of matchers) {
16
+ const files = await glob({
17
+ patterns: [matcher],
18
+ cwd,
19
+ ignore: options?.ignore ?? [],
20
+ onlyFiles: true,
21
+ absolute: true,
22
+ });
23
+ const assets = files.map((file) => {
24
+ const pathInsideDestinationDir = relative(cwd, file)
25
+ .split(posix.sep)
26
+ .filter((p) => p !== "..")
27
+ .join(posix.sep);
28
+ return {
29
+ source: file,
30
+ destination: join(destinationDir, pathInsideDestinationDir),
31
+ };
32
+ });
33
+ result.push({ matcher, assets });
34
+ }
35
+ return result;
36
+ }
37
+ /**
38
+ * Copy a single file, creating parent directories as needed.
39
+ */
40
+ export async function copyFileEnsuringDir(source, destination) {
41
+ await mkdir(dirname(destination), { recursive: true });
42
+ await copyFile(source, destination);
43
+ }
44
+ /**
45
+ * Copy every pair in the given matcher results. Parent directories are
46
+ * created automatically. Returns the total number of files copied.
47
+ */
48
+ export async function copyMatcherResults(matcherResults, onCopy) {
49
+ let count = 0;
50
+ for (const { assets } of matcherResults) {
51
+ for (const pair of assets) {
52
+ onCopy?.(pair);
53
+ await copyFileEnsuringDir(pair.source, pair.destination);
54
+ count++;
55
+ }
56
+ }
57
+ return count;
58
+ }
59
+ /**
60
+ * Recursively copy a directory to another location. Preserves structure;
61
+ * overwrites existing files at the destination.
62
+ *
63
+ * Used by the built-in skill bundler — we copy entire skill folders as a
64
+ * unit, not file-by-file.
65
+ */
66
+ export async function copyDirectoryRecursive(source, destination) {
67
+ await mkdir(destination, { recursive: true });
68
+ await cp(source, destination, { recursive: true, force: true });
69
+ }
70
+ //# sourceMappingURL=copyFiles.js.map
@@ -0,0 +1 @@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AAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc,EAAE,WAAmB;IAC3E,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,cAA+B,EAC/B,MAAiC;IAEjC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,cAAc,EAAE,CAAC;QACxC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;YACf,MAAM,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YACzD,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAc,EAAE,WAAmB;IAC9E,MAAM,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from "./internal/additionalFiles.js";
2
+ export * from "./internal/copyFiles.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./internal/additionalFiles.js";
2
+ export * from "./internal/copyFiles.js";
2
3
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC"}
@@ -1,2 +1,2 @@
1
- export const VERSION = "0.0.0-chat-prerelease-20260517214402";
1
+ export const VERSION = "0.0.0-chat-prerelease-20260520150857";
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trigger.dev/build",
3
- "version": "0.0.0-chat-prerelease-20260517214402",
3
+ "version": "0.0.0-chat-prerelease-20260520150857",
4
4
  "description": "trigger.dev build extensions",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -31,8 +31,7 @@
31
31
  "./extensions/typescript": "./src/extensions/typescript.ts",
32
32
  "./extensions/puppeteer": "./src/extensions/puppeteer.ts",
33
33
  "./extensions/playwright": "./src/extensions/playwright.ts",
34
- "./extensions/lightpanda": "./src/extensions/lightpanda.ts",
35
- "./extensions/secureExec": "./src/extensions/secureExec.ts"
34
+ "./extensions/lightpanda": "./src/extensions/lightpanda.ts"
36
35
  },
37
36
  "sourceDialects": [
38
37
  "@triggerdotdev/source"
@@ -66,15 +65,12 @@
66
65
  ],
67
66
  "extensions/lightpanda": [
68
67
  "dist/commonjs/extensions/lightpanda.d.ts"
69
- ],
70
- "extensions/secureExec": [
71
- "dist/commonjs/extensions/secureExec.d.ts"
72
68
  ]
73
69
  }
74
70
  },
75
71
  "dependencies": {
76
72
  "@prisma/config": "^6.10.0",
77
- "@trigger.dev/core": "0.0.0-chat-prerelease-20260517214402",
73
+ "@trigger.dev/core": "0.0.0-chat-prerelease-20260520150857",
78
74
  "mlly": "^1.7.1",
79
75
  "pkg-types": "^1.1.3",
80
76
  "resolve": "^1.22.8",
@@ -203,17 +199,6 @@
203
199
  "types": "./dist/commonjs/extensions/lightpanda.d.ts",
204
200
  "default": "./dist/commonjs/extensions/lightpanda.js"
205
201
  }
206
- },
207
- "./extensions/secureExec": {
208
- "import": {
209
- "@triggerdotdev/source": "./src/extensions/secureExec.ts",
210
- "types": "./dist/esm/extensions/secureExec.d.ts",
211
- "default": "./dist/esm/extensions/secureExec.js"
212
- },
213
- "require": {
214
- "types": "./dist/commonjs/extensions/secureExec.d.ts",
215
- "default": "./dist/commonjs/extensions/secureExec.js"
216
- }
217
202
  }
218
203
  },
219
204
  "main": "./dist/commonjs/index.js",
@@ -1,35 +0,0 @@
1
- import { BuildExtension } from "@trigger.dev/core/v3/build";
2
- export type SecureExecOptions = {
3
- /**
4
- * Packages available inside the sandbox at runtime.
5
- *
6
- * These are `require()`'d inside the V8 isolate at runtime — the bundler
7
- * never sees them statically. They are marked external and installed as
8
- * deploy dependencies.
9
- *
10
- * @example
11
- * ```ts
12
- * secureExec({ packages: ["jszip", "lodash"] })
13
- * ```
14
- */
15
- packages?: string[];
16
- };
17
- /**
18
- * Build extension for [secure-exec](https://secureexec.dev) — run untrusted
19
- * JavaScript/TypeScript in V8 isolates with configurable permissions.
20
- *
21
- * Handles the esbuild workarounds needed for secure-exec's runtime
22
- * `require.resolve` calls, native binaries, and module-scope resolution.
23
- *
24
- * @example
25
- * ```ts
26
- * import { secureExec } from "@trigger.dev/build/extensions/secureExec";
27
- *
28
- * export default defineConfig({
29
- * build: {
30
- * extensions: [secureExec()],
31
- * },
32
- * });
33
- * ```
34
- */
35
- export declare function secureExec(options?: SecureExecOptions): BuildExtension;
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secureExec = secureExec;
4
- const node_path_1 = require("node:path");
5
- const node_fs_1 = require("node:fs");
6
- const node_module_1 = require("node:module");
7
- const pkg_types_1 = require("pkg-types");
8
- /**
9
- * Build extension for [secure-exec](https://secureexec.dev) — run untrusted
10
- * JavaScript/TypeScript in V8 isolates with configurable permissions.
11
- *
12
- * Handles the esbuild workarounds needed for secure-exec's runtime
13
- * `require.resolve` calls, native binaries, and module-scope resolution.
14
- *
15
- * @example
16
- * ```ts
17
- * import { secureExec } from "@trigger.dev/build/extensions/secureExec";
18
- *
19
- * export default defineConfig({
20
- * build: {
21
- * extensions: [secureExec()],
22
- * },
23
- * });
24
- * ```
25
- */
26
- function secureExec(options) {
27
- return new SecureExecExtension(options ?? {});
28
- }
29
- class SecureExecExtension {
30
- name = "SecureExecExtension";
31
- userPackages;
32
- constructor(options) {
33
- this.userPackages = options.packages ?? [];
34
- }
35
- externalsForTarget(_target) {
36
- return [
37
- // esbuild must not be bundled — it locates its native binary via a
38
- // relative path from its JS API entry point. secure-exec uses esbuild
39
- // at runtime to bundle polyfills for sandbox code.
40
- "esbuild",
41
- // User-specified packages are require()'d inside the V8 sandbox at
42
- // runtime — the bundler never sees them statically.
43
- ...this.userPackages,
44
- ];
45
- }
46
- onBuildStart(context) {
47
- context.logger.debug(`Adding ${this.name} esbuild plugins`);
48
- // Plugin 1: Replace node-stdlib-browser with pre-resolved paths.
49
- //
50
- // Trigger's ESM shim anchors require.resolve() to the chunk path, so
51
- // node-stdlib-browser's runtime require.resolve("./mock/empty.js") breaks.
52
- // Fix: load the real node-stdlib-browser at build time (where require.resolve
53
- // works), capture the resolved path map, and inline it as a static export.
54
- const workingDir = context.workingDir;
55
- context.registerPlugin({
56
- name: "secure-exec-stdlib-resolver",
57
- setup(build) {
58
- build.onResolve({ filter: /^node-stdlib-browser$/ }, () => ({
59
- path: "node-stdlib-browser",
60
- namespace: "secure-exec-nsb-resolved",
61
- }));
62
- build.onLoad({ filter: /.*/, namespace: "secure-exec-nsb-resolved" }, () => {
63
- const buildRequire = (0, node_module_1.createRequire)((0, node_path_1.join)(workingDir, "package.json"));
64
- const resolved = buildRequire("node-stdlib-browser");
65
- return {
66
- contents: `export default ${JSON.stringify(resolved)};`,
67
- loader: "js",
68
- };
69
- });
70
- },
71
- });
72
- // Plugin 2: Inline bridge.js at build time.
73
- //
74
- // bridge-loader.js in @secure-exec/node(js) uses __dirname and
75
- // require.resolve("@secure-exec/core") at module scope to locate
76
- // dist/bridge.js on disk. This fails in Trigger's bundled output.
77
- // Fix: read bridge.js content at build time and inline it as a
78
- // string literal so no runtime filesystem resolution is needed.
79
- //
80
- context.registerPlugin({
81
- name: "secure-exec-bridge-inline",
82
- setup(build) {
83
- build.onLoad({ filter: /[\\/]@secure-exec[\\/]node[\\/]dist[\\/]bridge-loader\.js$/ }, (args) => {
84
- try {
85
- const buildRequire = (0, node_module_1.createRequire)(args.path);
86
- const coreEntry = buildRequire.resolve("@secure-exec/core");
87
- const coreRoot = (0, node_path_1.resolve)((0, node_path_1.dirname)(coreEntry), "..");
88
- const bridgeCode = (0, node_fs_1.readFileSync)((0, node_path_1.join)(coreRoot, "dist", "bridge.js"), "utf8");
89
- return {
90
- contents: [
91
- `import { getIsolateRuntimeSource } from "@secure-exec/core";`,
92
- `const bridgeCodeCache = ${JSON.stringify(bridgeCode)};`,
93
- `export function getRawBridgeCode() { return bridgeCodeCache; }`,
94
- `export function getBridgeAttachCode() { return getIsolateRuntimeSource("bridgeAttach"); }`,
95
- ].join("\n"),
96
- loader: "js",
97
- };
98
- }
99
- catch {
100
- // If we can't inline the bridge, let the normal loader handle it.
101
- return undefined;
102
- }
103
- });
104
- },
105
- });
106
- }
107
- async onBuildComplete(context, _manifest) {
108
- if (context.target === "dev") {
109
- return;
110
- }
111
- context.logger.debug(`Adding ${this.name} deploy dependencies`);
112
- const dependencies = {};
113
- // Resolve versions for user-specified sandbox packages
114
- for (const pkg of this.userPackages) {
115
- try {
116
- const modulePath = await context.resolvePath(pkg);
117
- if (!modulePath) {
118
- dependencies[pkg] = "latest";
119
- continue;
120
- }
121
- const packageJSON = await (0, pkg_types_1.readPackageJSON)((0, node_path_1.dirname)(modulePath));
122
- dependencies[pkg] = packageJSON.version ?? "latest";
123
- }
124
- catch {
125
- context.logger.warn(`Could not resolve version for sandbox package ${pkg}, defaulting to latest`);
126
- dependencies[pkg] = "latest";
127
- }
128
- }
129
- context.addLayer({
130
- id: "secureExec",
131
- dependencies,
132
- image: {
133
- // isolated-vm requires native compilation tools
134
- pkgs: ["python3", "make", "g++"],
135
- },
136
- });
137
- }
138
- }
139
- //# sourceMappingURL=secureExec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secureExec.js","sourceRoot":"","sources":["../../../src/extensions/secureExec.ts"],"names":[],"mappings":";;AA0CA,gCAEC;AAzCD,yCAAmD;AACnD,qCAAuC;AACvC,6CAA4C;AAC5C,yCAA4C;AAkB5C;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,UAAU,CAAC,OAA2B;IACpD,OAAO,IAAI,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,mBAAmB;IACP,IAAI,GAAG,qBAAqB,CAAC;IAErC,YAAY,CAAW;IAE/B,YAAY,OAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IAC7C,CAAC;IAED,kBAAkB,CAAC,OAAoB;QACrC,OAAO;YACL,mEAAmE;YACnE,sEAAsE;YACtE,mDAAmD;YACnD,SAAS;YACT,mEAAmE;YACnE,oDAAoD;YACpD,GAAG,IAAI,CAAC,YAAY;SACrB,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,OAAqB;QAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,IAAI,kBAAkB,CAAC,CAAC;QAE5D,iEAAiE;QACjE,EAAE;QACF,qEAAqE;QACrE,2EAA2E;QAC3E,8EAA8E;QAC9E,2EAA2E;QAC3E,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACtC,OAAO,CAAC,cAAc,CAAC;YACrB,IAAI,EAAE,6BAA6B;YACnC,KAAK,CAAC,KAAK;gBACT,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE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,CAAC;QAED,OAAO,CAAC,QAAQ,CAAC;YACf,EAAE,EAAE,YAAY;YAChB,YAAY;YACZ,KAAK,EAAE;gBACL,gDAAgD;gBAChD,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC;aACjC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,35 +0,0 @@
1
- import { BuildExtension } from "@trigger.dev/core/v3/build";
2
- export type SecureExecOptions = {
3
- /**
4
- * Packages available inside the sandbox at runtime.
5
- *
6
- * These are `require()`'d inside the V8 isolate at runtime — the bundler
7
- * never sees them statically. They are marked external and installed as
8
- * deploy dependencies.
9
- *
10
- * @example
11
- * ```ts
12
- * secureExec({ packages: ["jszip", "lodash"] })
13
- * ```
14
- */
15
- packages?: string[];
16
- };
17
- /**
18
- * Build extension for [secure-exec](https://secureexec.dev) — run untrusted
19
- * JavaScript/TypeScript in V8 isolates with configurable permissions.
20
- *
21
- * Handles the esbuild workarounds needed for secure-exec's runtime
22
- * `require.resolve` calls, native binaries, and module-scope resolution.
23
- *
24
- * @example
25
- * ```ts
26
- * import { secureExec } from "@trigger.dev/build/extensions/secureExec";
27
- *
28
- * export default defineConfig({
29
- * build: {
30
- * extensions: [secureExec()],
31
- * },
32
- * });
33
- * ```
34
- */
35
- export declare function secureExec(options?: SecureExecOptions): BuildExtension;
@@ -1,136 +0,0 @@
1
- import { dirname, resolve, join } from "node:path";
2
- import { readFileSync } from "node:fs";
3
- import { createRequire } from "node:module";
4
- import { readPackageJSON } from "pkg-types";
5
- /**
6
- * Build extension for [secure-exec](https://secureexec.dev) — run untrusted
7
- * JavaScript/TypeScript in V8 isolates with configurable permissions.
8
- *
9
- * Handles the esbuild workarounds needed for secure-exec's runtime
10
- * `require.resolve` calls, native binaries, and module-scope resolution.
11
- *
12
- * @example
13
- * ```ts
14
- * import { secureExec } from "@trigger.dev/build/extensions/secureExec";
15
- *
16
- * export default defineConfig({
17
- * build: {
18
- * extensions: [secureExec()],
19
- * },
20
- * });
21
- * ```
22
- */
23
- export function secureExec(options) {
24
- return new SecureExecExtension(options ?? {});
25
- }
26
- class SecureExecExtension {
27
- name = "SecureExecExtension";
28
- userPackages;
29
- constructor(options) {
30
- this.userPackages = options.packages ?? [];
31
- }
32
- externalsForTarget(_target) {
33
- return [
34
- // esbuild must not be bundled — it locates its native binary via a
35
- // relative path from its JS API entry point. secure-exec uses esbuild
36
- // at runtime to bundle polyfills for sandbox code.
37
- "esbuild",
38
- // User-specified packages are require()'d inside the V8 sandbox at
39
- // runtime — the bundler never sees them statically.
40
- ...this.userPackages,
41
- ];
42
- }
43
- onBuildStart(context) {
44
- context.logger.debug(`Adding ${this.name} esbuild plugins`);
45
- // Plugin 1: Replace node-stdlib-browser with pre-resolved paths.
46
- //
47
- // Trigger's ESM shim anchors require.resolve() to the chunk path, so
48
- // node-stdlib-browser's runtime require.resolve("./mock/empty.js") breaks.
49
- // Fix: load the real node-stdlib-browser at build time (where require.resolve
50
- // works), capture the resolved path map, and inline it as a static export.
51
- const workingDir = context.workingDir;
52
- context.registerPlugin({
53
- name: "secure-exec-stdlib-resolver",
54
- setup(build) {
55
- build.onResolve({ filter: /^node-stdlib-browser$/ }, () => ({
56
- path: "node-stdlib-browser",
57
- namespace: "secure-exec-nsb-resolved",
58
- }));
59
- build.onLoad({ filter: /.*/, namespace: "secure-exec-nsb-resolved" }, () => {
60
- const buildRequire = createRequire(join(workingDir, "package.json"));
61
- const resolved = buildRequire("node-stdlib-browser");
62
- return {
63
- contents: `export default ${JSON.stringify(resolved)};`,
64
- loader: "js",
65
- };
66
- });
67
- },
68
- });
69
- // Plugin 2: Inline bridge.js at build time.
70
- //
71
- // bridge-loader.js in @secure-exec/node(js) uses __dirname and
72
- // require.resolve("@secure-exec/core") at module scope to locate
73
- // dist/bridge.js on disk. This fails in Trigger's bundled output.
74
- // Fix: read bridge.js content at build time and inline it as a
75
- // string literal so no runtime filesystem resolution is needed.
76
- //
77
- context.registerPlugin({
78
- name: "secure-exec-bridge-inline",
79
- setup(build) {
80
- build.onLoad({ filter: /[\\/]@secure-exec[\\/]node[\\/]dist[\\/]bridge-loader\.js$/ }, (args) => {
81
- try {
82
- const buildRequire = createRequire(args.path);
83
- const coreEntry = buildRequire.resolve("@secure-exec/core");
84
- const coreRoot = resolve(dirname(coreEntry), "..");
85
- const bridgeCode = readFileSync(join(coreRoot, "dist", "bridge.js"), "utf8");
86
- return {
87
- contents: [
88
- `import { getIsolateRuntimeSource } from "@secure-exec/core";`,
89
- `const bridgeCodeCache = ${JSON.stringify(bridgeCode)};`,
90
- `export function getRawBridgeCode() { return bridgeCodeCache; }`,
91
- `export function getBridgeAttachCode() { return getIsolateRuntimeSource("bridgeAttach"); }`,
92
- ].join("\n"),
93
- loader: "js",
94
- };
95
- }
96
- catch {
97
- // If we can't inline the bridge, let the normal loader handle it.
98
- return undefined;
99
- }
100
- });
101
- },
102
- });
103
- }
104
- async onBuildComplete(context, _manifest) {
105
- if (context.target === "dev") {
106
- return;
107
- }
108
- context.logger.debug(`Adding ${this.name} deploy dependencies`);
109
- const dependencies = {};
110
- // Resolve versions for user-specified sandbox packages
111
- for (const pkg of this.userPackages) {
112
- try {
113
- const modulePath = await context.resolvePath(pkg);
114
- if (!modulePath) {
115
- dependencies[pkg] = "latest";
116
- continue;
117
- }
118
- const packageJSON = await readPackageJSON(dirname(modulePath));
119
- dependencies[pkg] = packageJSON.version ?? "latest";
120
- }
121
- catch {
122
- context.logger.warn(`Could not resolve version for sandbox package ${pkg}, defaulting to latest`);
123
- dependencies[pkg] = "latest";
124
- }
125
- }
126
- context.addLayer({
127
- id: "secureExec",
128
- dependencies,
129
- image: {
130
- // isolated-vm requires native compilation tools
131
- pkgs: ["python3", "make", "g++"],
132
- },
133
- });
134
- }
135
- }
136
- //# sourceMappingURL=secureExec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secureExec.js","sourceRoot":"","sources":["../../../src/extensions/secureExec.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,O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