@trebired/git-host 2.1.0 → 3.0.0

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 (162) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +327 -6
  3. package/bin/git-host-actions-runner-darwin-arm64 +0 -0
  4. package/bin/git-host-actions-runner-darwin-x64 +0 -0
  5. package/bin/git-host-actions-runner-linux-arm64-gnu +0 -0
  6. package/bin/git-host-actions-runner-linux-x64-gnu +0 -0
  7. package/dist/api/forge/actions.d.ts +6 -3
  8. package/dist/api/forge/actions.d.ts.map +1 -1
  9. package/dist/api/forge/actions.js +46 -10
  10. package/dist/api/forge/actions.js.map +1 -1
  11. package/dist/api/forge/route.d.ts +10 -0
  12. package/dist/api/forge/route.d.ts.map +1 -1
  13. package/dist/api/forge/route.js +6 -0
  14. package/dist/api/forge/route.js.map +1 -1
  15. package/dist/api/forge/socket.d.ts.map +1 -1
  16. package/dist/api/forge/socket.js +4 -148
  17. package/dist/api/forge/socket.js.map +1 -1
  18. package/dist/api/forge/socket_subscription.d.ts +10 -0
  19. package/dist/api/forge/socket_subscription.d.ts.map +1 -0
  20. package/dist/api/forge/socket_subscription.js +202 -0
  21. package/dist/api/forge/socket_subscription.js.map +1 -0
  22. package/dist/api/handler/action.d.ts.map +1 -1
  23. package/dist/api/handler/action.js +24 -18
  24. package/dist/api/handler/action.js.map +1 -1
  25. package/dist/api/socket/linguist_connection.d.ts +9 -0
  26. package/dist/api/socket/linguist_connection.d.ts.map +1 -0
  27. package/dist/api/socket/linguist_connection.js +167 -0
  28. package/dist/api/socket/linguist_connection.js.map +1 -0
  29. package/dist/api/socket/server.d.ts.map +1 -1
  30. package/dist/api/socket/server.js +4 -119
  31. package/dist/api/socket/server.js.map +1 -1
  32. package/dist/core/actions/artifacts.d.ts +21 -0
  33. package/dist/core/actions/artifacts.d.ts.map +1 -0
  34. package/dist/core/actions/artifacts.js +121 -0
  35. package/dist/core/actions/artifacts.js.map +1 -0
  36. package/dist/core/actions/environment.d.ts +9 -0
  37. package/dist/core/actions/environment.d.ts.map +1 -0
  38. package/dist/core/actions/environment.js +64 -0
  39. package/dist/core/actions/environment.js.map +1 -0
  40. package/dist/core/actions/expressions.d.ts +15 -0
  41. package/dist/core/actions/expressions.d.ts.map +1 -0
  42. package/dist/core/actions/expressions.js +279 -0
  43. package/dist/core/actions/expressions.js.map +1 -0
  44. package/dist/core/actions/go_runner.d.ts +6 -0
  45. package/dist/core/actions/go_runner.d.ts.map +1 -0
  46. package/dist/core/actions/go_runner.js +106 -0
  47. package/dist/core/actions/go_runner.js.map +1 -0
  48. package/dist/core/actions/local_runner.d.ts +33 -0
  49. package/dist/core/actions/local_runner.d.ts.map +1 -0
  50. package/dist/core/actions/local_runner.js +173 -0
  51. package/dist/core/actions/local_runner.js.map +1 -0
  52. package/dist/core/actions/node_runner.d.ts +4 -0
  53. package/dist/core/actions/node_runner.d.ts.map +1 -0
  54. package/dist/core/actions/node_runner.js +176 -0
  55. package/dist/core/actions/node_runner.js.map +1 -0
  56. package/dist/core/actions/normalize.d.ts +7 -0
  57. package/dist/core/actions/normalize.d.ts.map +1 -0
  58. package/dist/core/actions/normalize.js +401 -0
  59. package/dist/core/actions/normalize.js.map +1 -0
  60. package/dist/core/actions/planner.d.ts +13 -0
  61. package/dist/core/actions/planner.d.ts.map +1 -0
  62. package/dist/core/actions/planner.js +106 -0
  63. package/dist/core/actions/planner.js.map +1 -0
  64. package/dist/core/actions/redaction.d.ts +16 -0
  65. package/dist/core/actions/redaction.d.ts.map +1 -0
  66. package/dist/core/actions/redaction.js +43 -0
  67. package/dist/core/actions/redaction.js.map +1 -0
  68. package/dist/core/actions/release_assets.d.ts +31 -0
  69. package/dist/core/actions/release_assets.d.ts.map +1 -0
  70. package/dist/core/actions/release_assets.js +114 -0
  71. package/dist/core/actions/release_assets.js.map +1 -0
  72. package/dist/core/actions/runner/launch.d.ts +5 -0
  73. package/dist/core/actions/runner/launch.d.ts.map +1 -0
  74. package/dist/core/actions/runner/launch.js +100 -0
  75. package/dist/core/actions/runner/launch.js.map +1 -0
  76. package/dist/core/actions/runner/protocol.d.ts +7 -0
  77. package/dist/core/actions/runner/protocol.d.ts.map +1 -0
  78. package/dist/core/actions/runner/protocol.js +66 -0
  79. package/dist/core/actions/runner/protocol.js.map +1 -0
  80. package/dist/core/actions/runner.d.ts +6 -0
  81. package/dist/core/actions/runner.d.ts.map +1 -0
  82. package/dist/core/actions/runner.js +13 -0
  83. package/dist/core/actions/runner.js.map +1 -0
  84. package/dist/core/actions/sandbox.d.ts +4 -0
  85. package/dist/core/actions/sandbox.d.ts.map +1 -0
  86. package/dist/core/actions/sandbox.js +46 -0
  87. package/dist/core/actions/sandbox.js.map +1 -0
  88. package/dist/core/{actions_runner.d.ts → actions/types.d.ts} +38 -6
  89. package/dist/core/actions/types.d.ts.map +1 -0
  90. package/dist/core/actions/types.js +2 -0
  91. package/dist/core/actions/types.js.map +1 -0
  92. package/dist/core/{actions_workflows.d.ts → actions/workflows.d.ts} +4 -4
  93. package/dist/core/actions/workflows.d.ts.map +1 -0
  94. package/dist/core/{actions_workflows.js → actions/workflows.js} +40 -100
  95. package/dist/core/actions/workflows.js.map +1 -0
  96. package/dist/core/actions/workspace.d.ts +7 -0
  97. package/dist/core/actions/workspace.d.ts.map +1 -0
  98. package/dist/core/actions/workspace.js +47 -0
  99. package/dist/core/actions/workspace.js.map +1 -0
  100. package/dist/core/activity.d.ts.map +1 -1
  101. package/dist/core/activity.js +57 -39
  102. package/dist/core/activity.js.map +1 -1
  103. package/dist/core/archive_cache_filesystem.d.ts.map +1 -1
  104. package/dist/core/archive_cache_filesystem.js +39 -33
  105. package/dist/core/archive_cache_filesystem.js.map +1 -1
  106. package/dist/core/create/git/forge.d.ts.map +1 -1
  107. package/dist/core/create/git/forge.js +12 -2
  108. package/dist/core/create/git/forge.js.map +1 -1
  109. package/dist/core/create_git_host/remote_methods.js.map +1 -1
  110. package/dist/core/forge_actions.d.ts +10 -2
  111. package/dist/core/forge_actions.d.ts.map +1 -1
  112. package/dist/core/forge_actions.js +1025 -160
  113. package/dist/core/forge_actions.js.map +1 -1
  114. package/dist/core/git_forge/storage_memory.d.ts.map +1 -1
  115. package/dist/core/git_forge/storage_memory.js +72 -2
  116. package/dist/core/git_forge/storage_memory.js.map +1 -1
  117. package/dist/core/repository/parsers.d.ts.map +1 -1
  118. package/dist/core/repository/parsers.js +45 -32
  119. package/dist/core/repository/parsers.js.map +1 -1
  120. package/dist/core/run_git/process.d.ts.map +1 -1
  121. package/dist/core/run_git/process.js +19 -18
  122. package/dist/core/run_git/process.js.map +1 -1
  123. package/dist/core/working_tree/read.d.ts.map +1 -1
  124. package/dist/core/working_tree/read.js +26 -32
  125. package/dist/core/working_tree/read.js.map +1 -1
  126. package/dist/index.d.ts +2 -1
  127. package/dist/index.d.ts.map +1 -1
  128. package/dist/index.js +1 -0
  129. package/dist/index.js.map +1 -1
  130. package/dist/types/forge/activity.d.ts +52 -0
  131. package/dist/types/forge/activity.d.ts.map +1 -0
  132. package/dist/types/forge/activity.js +2 -0
  133. package/dist/types/forge/activity.js.map +1 -0
  134. package/dist/types/forge/api.d.ts +116 -0
  135. package/dist/types/forge/api.d.ts.map +1 -0
  136. package/dist/types/forge/api.js +2 -0
  137. package/dist/types/forge/api.js.map +1 -0
  138. package/dist/types/forge/releases.d.ts +98 -0
  139. package/dist/types/forge/releases.d.ts.map +1 -0
  140. package/dist/types/forge/releases.js +2 -0
  141. package/dist/types/forge/releases.js.map +1 -0
  142. package/dist/types/forge/social_forks.d.ts +51 -0
  143. package/dist/types/forge/social_forks.d.ts.map +1 -0
  144. package/dist/types/forge/social_forks.js +2 -0
  145. package/dist/types/forge/social_forks.js.map +1 -0
  146. package/dist/types/forge/workflows.d.ts +361 -0
  147. package/dist/types/forge/workflows.d.ts.map +1 -0
  148. package/dist/types/forge/workflows.js +2 -0
  149. package/dist/types/forge/workflows.js.map +1 -0
  150. package/dist/types/forge.d.ts +5 -475
  151. package/dist/types/forge.d.ts.map +1 -1
  152. package/dist/types/host/archive.d.ts.map +1 -1
  153. package/dist/types/host/options.d.ts.map +1 -1
  154. package/dist/types/host/service.d.ts.map +1 -1
  155. package/dist/types/index.d.ts +1 -1
  156. package/dist/types/index.d.ts.map +1 -1
  157. package/package.json +38 -9
  158. package/dist/core/actions_runner.d.ts.map +0 -1
  159. package/dist/core/actions_runner.js +0 -414
  160. package/dist/core/actions_runner.js.map +0 -1
  161. package/dist/core/actions_workflows.d.ts.map +0 -1
  162. package/dist/core/actions_workflows.js.map +0 -1
@@ -0,0 +1,106 @@
1
+ import { GitHostError } from "../../errors.js";
2
+ import { text } from "../../utils/text.js";
3
+ function cartesianProduct(entries) {
4
+ if (!entries.length)
5
+ return [{}];
6
+ const [[key, values], ...rest] = entries;
7
+ const remainder = cartesianProduct(rest);
8
+ const rows = [];
9
+ for (const value of values) {
10
+ for (const tail of remainder) {
11
+ rows.push({
12
+ [key]: value,
13
+ ...tail,
14
+ });
15
+ }
16
+ }
17
+ return rows;
18
+ }
19
+ function matrixKey(matrix) {
20
+ return Object.entries(matrix)
21
+ .sort(([left], [right]) => left.localeCompare(right))
22
+ .map(([key, value]) => `${key}=${String(value)}`)
23
+ .join("|");
24
+ }
25
+ function expandJobMatrix(job) {
26
+ const matrix = job.strategy?.matrix;
27
+ if (!matrix)
28
+ return [undefined];
29
+ const baseRows = cartesianProduct(Object.entries(matrix.values || {}));
30
+ const seen = new Set(baseRows.map((entry) => matrixKey(entry)));
31
+ const extras = (matrix.include || []).filter((entry) => {
32
+ const key = matrixKey(entry);
33
+ if (seen.has(key))
34
+ return false;
35
+ seen.add(key);
36
+ return true;
37
+ });
38
+ const rows = [...baseRows, ...extras];
39
+ return rows.length ? rows : [undefined];
40
+ }
41
+ function jobDisplayName(job, matrix) {
42
+ if (!matrix || !Object.keys(matrix).length)
43
+ return job.name;
44
+ const suffix = Object.entries(matrix)
45
+ .map(([key, value]) => `${key}=${String(value)}`)
46
+ .join(", ");
47
+ return `${job.name} (${suffix})`;
48
+ }
49
+ function planWorkflowJobs(workflow) {
50
+ const planned = [];
51
+ let index = 0;
52
+ for (const job of workflow.jobs) {
53
+ for (const matrix of expandJobMatrix(job)) {
54
+ planned.push({
55
+ index,
56
+ job,
57
+ ...(matrix ? { matrix } : {}),
58
+ name: jobDisplayName(job, matrix),
59
+ });
60
+ index += 1;
61
+ }
62
+ }
63
+ return planned;
64
+ }
65
+ function assertAcyclicWorkflow(workflow) {
66
+ const byId = new Map(workflow.jobs.map((job) => [job.id, job]));
67
+ const visiting = new Set();
68
+ const visited = new Set();
69
+ function visit(jobId, trail) {
70
+ if (visited.has(jobId))
71
+ return;
72
+ if (visiting.has(jobId)) {
73
+ throw new GitHostError("forge_invalid_workflow_definition", `Workflow "${workflow.id}" has a circular needs graph.`, {
74
+ cycle: [...trail, jobId],
75
+ workflowId: workflow.id,
76
+ });
77
+ }
78
+ visiting.add(jobId);
79
+ const job = byId.get(jobId);
80
+ if (!job) {
81
+ throw new GitHostError("forge_invalid_workflow_definition", `Workflow "${workflow.id}" references unknown job "${jobId}".`, {
82
+ jobId,
83
+ workflowId: workflow.id,
84
+ });
85
+ }
86
+ for (const need of job.needs || []) {
87
+ visit(need, [...trail, jobId]);
88
+ }
89
+ visiting.delete(jobId);
90
+ visited.add(jobId);
91
+ }
92
+ for (const job of workflow.jobs) {
93
+ visit(job.id, []);
94
+ }
95
+ }
96
+ function resolveRefName(ref) {
97
+ const value = text(ref);
98
+ if (value.startsWith("refs/heads/"))
99
+ return value.slice("refs/heads/".length);
100
+ if (value.startsWith("refs/tags/"))
101
+ return value.slice("refs/tags/".length);
102
+ const segments = value.split("/");
103
+ return segments[segments.length - 1] || value;
104
+ }
105
+ export { assertAcyclicWorkflow, planWorkflowJobs, resolveRefName, };
106
+ //# sourceMappingURL=planner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.js","sourceRoot":"","sources":["../../../src/core/actions/planner.ts"],"names":[],"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ActionsOptions, GitForgeWorkflowRun, GitForgeWorkflowRunStep } from "../../types.js";
2
+ declare function collectSensitiveValues(input: {
3
+ env?: Record<string, string>;
4
+ secrets?: Record<string, string>;
5
+ sensitiveKeys?: string[];
6
+ }): string[];
7
+ declare function redactSecrets(input: string, secrets: string[]): string;
8
+ declare function createRunRedactor(input: {
9
+ actions: CreateGitForgeActionsOptions | undefined;
10
+ env?: Record<string, string>;
11
+ run: GitForgeWorkflowRun;
12
+ secrets: Record<string, string> | undefined;
13
+ step: GitForgeWorkflowRunStep;
14
+ }): (chunk: string, stream?: "stderr" | "stdout") => Promise<string>;
15
+ export { collectSensitiveValues, createRunRedactor, redactSecrets, };
16
+ //# sourceMappingURL=redaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../../src/core/actions/redaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAUhH,iBAAS,sBAAsB,CAAC,KAAK,EAAE;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,YAMA;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAMtD;AAED,iBAAS,iBAAiB,CAAC,KAAK,EAAE;IAChC,OAAO,EAAE,4BAA4B,GAAG,SAAS,CAAC;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,EAAE,mBAAmB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC5C,IAAI,EAAE,uBAAuB,CAAC;CAC/B,IAOkC,OAAO,MAAM,EAAE,SAAQ,QAAQ,GAAG,QAAmB,qBAYvF;AAED,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,GACd,CAAC"}
@@ -0,0 +1,43 @@
1
+ function sanitizeSecretValues(values) {
2
+ return Array.from(new Set([...values].filter((value) => Boolean(value))))
3
+ .sort((left, right) => right.length - left.length);
4
+ }
5
+ // Gathers every value that must be masked from streamed and persisted output:
6
+ // all values in the secrets map plus, for any caller-declared sensitive key, the
7
+ // resolved value from secrets and from the step environment.
8
+ function collectSensitiveValues(input) {
9
+ const values = [...Object.values(input.secrets || {})];
10
+ for (const key of input.sensitiveKeys || []) {
11
+ values.push(input.secrets?.[key], input.env?.[key]);
12
+ }
13
+ return sanitizeSecretValues(values);
14
+ }
15
+ function redactSecrets(input, secrets) {
16
+ let next = input;
17
+ for (const secret of secrets) {
18
+ next = next.split(secret).join("***");
19
+ }
20
+ return next;
21
+ }
22
+ function createRunRedactor(input) {
23
+ const { actions, run, step } = input;
24
+ const secretValues = collectSensitiveValues({
25
+ env: input.env,
26
+ secrets: input.secrets,
27
+ sensitiveKeys: actions?.environment?.sensitiveKeys,
28
+ });
29
+ return async function redactText(chunk, stream = "stdout") {
30
+ let next = redactSecrets(String(chunk || ""), secretValues);
31
+ if (actions?.redactOutput) {
32
+ next = await actions.redactOutput({
33
+ chunk: next,
34
+ run,
35
+ step,
36
+ stream,
37
+ });
38
+ }
39
+ return next;
40
+ };
41
+ }
42
+ export { collectSensitiveValues, createRunRedactor, redactSecrets, };
43
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../../../src/core/actions/redaction.ts"],"names":[],"mappings":"AAEA,SAAS,oBAAoB,CAAC,MAAoC;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,E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A8B,QAAQ;QACpF,IAAI,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,OAAO,EAAE,YAAY,EAAE,CAAC;YAC1B,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC;gBAChC,KAAK,EAAE,IAAI;gBACX,GAAG;gBACH,IAAI;gBACJ,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,GACd,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { GitForgeRelease, GitForgeReleaseAsset, GitForgeReleaseStorage } from "../../types/forge/releases.js";
2
+ type ReleaseAssetArchiveFormat = "tar.gz" | "zip";
3
+ declare function releaseAssetStoragePath(input: {
4
+ assetId: string;
5
+ fileName: string;
6
+ releaseAssetsRoot: string;
7
+ releaseId: string;
8
+ repositoryId: string;
9
+ }): string;
10
+ declare function compressDirectoryToArchive(input: {
11
+ destinationPath: string;
12
+ format: ReleaseAssetArchiveFormat;
13
+ sourcePath: string;
14
+ }): Promise<{
15
+ size: number;
16
+ }>;
17
+ declare function publishReleaseAsset(input: {
18
+ assetName: string;
19
+ format: ReleaseAssetArchiveFormat;
20
+ releaseAssetsRoot: string;
21
+ releaseId?: string;
22
+ releases: GitForgeReleaseStorage;
23
+ repositoryId: string;
24
+ sourcePath: string;
25
+ tagName: string;
26
+ }): Promise<{
27
+ asset: GitForgeReleaseAsset;
28
+ release: GitForgeRelease;
29
+ }>;
30
+ export { compressDirectoryToArchive, publishReleaseAsset, releaseAssetStoragePath, };
31
+ //# sourceMappingURL=release_assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release_assets.d.ts","sourceRoot":"","sources":["../../../src/core/actions/release_assets.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAGvC,KAAK,yBAAyB,GAAG,QAAQ,GAAG,KAAK,CAAC;AAOlD,iBAAS,uBAAuB,CAAC,KAAK,EAAE;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,UAOA;AAuBD,iBAAe,0BAA0B,CAAC,KAAK,EAAE;IAC/C,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,yBAAyB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;;GAyBA;AAmCD,iBAAe,mBAAmB,CAAC,KAAK,EAAE;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,yBAAyB,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,oBAAoB,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC,CAsCrE;AAED,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,114 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { spawn } from "node:child_process";
4
+ import { GitHostError } from "../../errors.js";
5
+ import { text } from "../../utils/text.js";
6
+ function sanitizeAssetFileNameComponent(value) {
7
+ const next = text(value).replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
8
+ return next || "asset";
9
+ }
10
+ function releaseAssetStoragePath(input) {
11
+ return path.join(input.releaseAssetsRoot, input.repositoryId, input.releaseId, `${input.assetId}-${sanitizeAssetFileNameComponent(input.fileName)}`);
12
+ }
13
+ function archiveContentType(format) {
14
+ return format === "zip" ? "application/zip" : "application/gzip";
15
+ }
16
+ function shellQuotePosix(value) {
17
+ return `'${value.replace(/'/g, "'\\''")}'`;
18
+ }
19
+ function runArchiveCommand(command) {
20
+ return new Promise((resolve, reject) => {
21
+ const child = spawn("/bin/sh", ["-lc", command], { stdio: ["ignore", "ignore", "pipe"] });
22
+ let stderr = "";
23
+ child.stderr?.setEncoding("utf8");
24
+ child.stderr?.on("data", (chunk) => {
25
+ stderr += chunk;
26
+ });
27
+ child.on("error", reject);
28
+ child.on("close", (code) => resolve({ exitCode: typeof code === "number" ? code : 1, stderr }));
29
+ });
30
+ }
31
+ async function compressDirectoryToArchive(input) {
32
+ if (!fs.existsSync(input.sourcePath)) {
33
+ throw new GitHostError("forge_actions_runner_failed", `Path "${input.sourcePath}" does not exist.`, {
34
+ sourcePath: input.sourcePath,
35
+ });
36
+ }
37
+ fs.mkdirSync(path.dirname(input.destinationPath), { recursive: true });
38
+ fs.rmSync(input.destinationPath, { force: true });
39
+ const parentDir = path.dirname(input.sourcePath);
40
+ const baseName = path.basename(input.sourcePath);
41
+ const command = input.format === "zip"
42
+ ? `cd ${shellQuotePosix(parentDir)} && zip -rq ${shellQuotePosix(input.destinationPath)} ${shellQuotePosix(baseName)}`
43
+ : `tar -czf ${shellQuotePosix(input.destinationPath)} -C ${shellQuotePosix(parentDir)} ${shellQuotePosix(baseName)}`;
44
+ const result = await runArchiveCommand(command);
45
+ if (result.exitCode !== 0 || !fs.existsSync(input.destinationPath)) {
46
+ throw new GitHostError("forge_actions_runner_failed", `Failed to create ${input.format} archive for release asset.`, {
47
+ destinationPath: input.destinationPath,
48
+ exitCode: result.exitCode,
49
+ sourcePath: input.sourcePath,
50
+ stderr: result.stderr,
51
+ });
52
+ }
53
+ return { size: fs.statSync(input.destinationPath).size };
54
+ }
55
+ async function findReleaseByTag(releases, repositoryId, tagName) {
56
+ const existing = await releases.listReleases(repositoryId);
57
+ return existing.find((release) => release.tag_name === tagName) || null;
58
+ }
59
+ // The actions runtime only has the raw release storage, not the orchestrated
60
+ // GitForge.createRelease() (which validates actors, creates the git tag, resolves
61
+ // target_ref, and runs the host's normalizeAssets hook) — that method lives one
62
+ // layer up and isn't constructed yet when the actions runtime is wired together.
63
+ // Rather than half-reimplement release creation here with a worse-validated path,
64
+ // this step requires the release to already exist: either create it first (via the
65
+ // release UI/API, which is also what a `release.create`-triggered workflow already
66
+ // has), or trigger this workflow from `release.create` so `github.event.release_id`
67
+ // is populated automatically.
68
+ async function resolveTargetRelease(input) {
69
+ if (input.releaseId) {
70
+ const byId = await input.releases.readRelease(input.repositoryId, input.releaseId);
71
+ if (byId)
72
+ return byId;
73
+ }
74
+ const byTag = await findReleaseByTag(input.releases, input.repositoryId, input.tagName);
75
+ if (byTag)
76
+ return byTag;
77
+ throw new GitHostError("forge_actions_runner_failed", `No release exists for tag "${input.tagName}". Create the release first, then re-run, or trigger this workflow from a release.create event.`, { repositoryId: input.repositoryId, tagName: input.tagName });
78
+ }
79
+ async function publishReleaseAsset(input) {
80
+ const release = await resolveTargetRelease({
81
+ releaseId: input.releaseId,
82
+ releases: input.releases,
83
+ repositoryId: input.repositoryId,
84
+ tagName: input.tagName,
85
+ });
86
+ const assetId = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
87
+ const fileName = `${input.assetName}${input.format === "zip" ? ".zip" : ".tar.gz"}`;
88
+ const destinationPath = releaseAssetStoragePath({
89
+ assetId,
90
+ fileName,
91
+ releaseAssetsRoot: input.releaseAssetsRoot,
92
+ releaseId: release.id,
93
+ repositoryId: input.repositoryId,
94
+ });
95
+ const compressed = await compressDirectoryToArchive({
96
+ destinationPath,
97
+ format: input.format,
98
+ sourcePath: input.sourcePath,
99
+ });
100
+ const asset = {
101
+ content_type: archiveContentType(input.format),
102
+ id: assetId,
103
+ name: fileName,
104
+ size: compressed.size,
105
+ storage_pointer: destinationPath,
106
+ };
107
+ const updated = await input.releases.updateRelease(input.repositoryId, release.id, {
108
+ assets: [...release.assets.filter((existing) => existing.name !== fileName), asset],
109
+ updated_at: new Date().toISOString(),
110
+ });
111
+ return { asset, release: updated || { ...release, assets: [...release.assets, asset] } };
112
+ }
113
+ export { compressDirectoryToArchive, publishReleaseAsset, releaseAssetStoragePath, };
114
+ //# sourceMappingURL=release_assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release_assets.js","sourceRoot":"","sources":["../../../src/core/actions/release_assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAM/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI3C,SAAS,8BAA8B,CAAC,KAAa;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACnF,OAAO,IAAI,IAAI,OAAO,CAAC;AACzB,CAAC;AAED,SAAS,uBAAuB,CAAC,KAMhC;IACC,OAAO,IAAI,CAAC,IAAI,CACd,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,SAAS,EACf,GAAG,KAAK,CAAC,OAAO,IAAI,8BAA8B,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CACrE,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAiC;IAC3D,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;AACnE,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,IAAI,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E,OAAO,IAAI,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;AAC3F,CAAC;AAED,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { CreateGitForgeActionsOptions } from "../../../types.js";
2
+ import type { RunnerLaunch } from "../types.js";
3
+ declare function resolveRunnerLaunch(options: CreateGitForgeActionsOptions | undefined): RunnerLaunch;
4
+ export { resolveRunnerLaunch };
5
+ //# sourceMappingURL=launch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../../../src/core/actions/runner/launch.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAoFlD,iBAAS,mBAAmB,CAAC,OAAO,EAAE,4BAA4B,GAAG,SAAS,GAAG,YAAY,CAqB5F;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { GitHostError } from "../../../errors.js";
7
+ import { text } from "../../../utils/text.js";
8
+ const RUNNER_BINARY_NAMES = {
9
+ "darwin-arm64": "git-host-actions-runner-darwin-arm64",
10
+ "darwin-x64": "git-host-actions-runner-darwin-x64",
11
+ "linux-arm64": "git-host-actions-runner-linux-arm64-gnu",
12
+ "linux-x64": "git-host-actions-runner-linux-x64-gnu",
13
+ };
14
+ let sourceCheckoutGoRunnerPath;
15
+ function findPackageRoot(startPath) {
16
+ let current = path.resolve(startPath);
17
+ while (current !== path.dirname(current)) {
18
+ if (fs.existsSync(path.join(current, "package.json"))) {
19
+ return current;
20
+ }
21
+ current = path.dirname(current);
22
+ }
23
+ throw new GitHostError("forge_actions_runner_not_found", "Unable to resolve the package root for the actions runner.");
24
+ }
25
+ function packageRootIsSourceCheckout(packageRoot) {
26
+ return fs.existsSync(path.join(packageRoot, ".git"));
27
+ }
28
+ function resolvePackagedRunnerPath(options) {
29
+ const explicit = text(options?.runnerBinaryPath);
30
+ if (explicit)
31
+ return explicit;
32
+ const packageRoot = findPackageRoot(path.dirname(fileURLToPath(import.meta.url)));
33
+ if (packageRootIsSourceCheckout(packageRoot)) {
34
+ return null;
35
+ }
36
+ const key = `${process.platform}-${process.arch}`;
37
+ const binary = RUNNER_BINARY_NAMES[key];
38
+ if (!binary)
39
+ return null;
40
+ const candidate = path.join(packageRoot, "bin", binary);
41
+ return fs.existsSync(candidate) ? candidate : null;
42
+ }
43
+ function resolveGoFallbackCommand() {
44
+ if (sourceCheckoutGoRunnerPath !== undefined) {
45
+ return sourceCheckoutGoRunnerPath
46
+ ? { args: [], command: sourceCheckoutGoRunnerPath }
47
+ : null;
48
+ }
49
+ const packageRoot = findPackageRoot(path.dirname(fileURLToPath(import.meta.url)));
50
+ const sourcePath = path.join(packageRoot, "go", "cmd", "git-host-actions-runner");
51
+ if (!fs.existsSync(sourcePath)) {
52
+ sourceCheckoutGoRunnerPath = null;
53
+ return null;
54
+ }
55
+ const probe = spawnSync("go", ["version"], {
56
+ encoding: "utf8",
57
+ });
58
+ if (probe.status !== 0) {
59
+ sourceCheckoutGoRunnerPath = null;
60
+ return null;
61
+ }
62
+ const binaryDirectory = path.join(os.tmpdir(), "@trebired-git-host-actions-runner", `${process.platform}-${process.arch}`);
63
+ const binaryPath = path.join(binaryDirectory, "git-host-actions-runner");
64
+ fs.mkdirSync(binaryDirectory, { recursive: true });
65
+ const build = spawnSync("go", ["build", "-o", binaryPath, "./go/cmd/git-host-actions-runner"], {
66
+ cwd: packageRoot,
67
+ encoding: "utf8",
68
+ });
69
+ if (build.status !== 0 || !fs.existsSync(binaryPath)) {
70
+ sourceCheckoutGoRunnerPath = null;
71
+ return null;
72
+ }
73
+ sourceCheckoutGoRunnerPath = binaryPath;
74
+ return {
75
+ args: [],
76
+ command: binaryPath,
77
+ };
78
+ }
79
+ function resolveRunnerLaunch(options) {
80
+ const packaged = resolvePackagedRunnerPath(options);
81
+ if (packaged) {
82
+ return {
83
+ args: [],
84
+ command: packaged,
85
+ kind: "go",
86
+ };
87
+ }
88
+ const goFallback = resolveGoFallbackCommand();
89
+ if (goFallback) {
90
+ return {
91
+ ...goFallback,
92
+ kind: "go",
93
+ };
94
+ }
95
+ return {
96
+ kind: "node",
97
+ };
98
+ }
99
+ export { resolveRunnerLaunch };
100
+ //# sourceMappingURL=launch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.js","sourceRoot":"","sources":["../../../../src/core/actions/runner/launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,MAAM,mBAAmB,GAAG;IAC1B,cAAc,EAAE,sCAAsC;IACtD,YAAY,EAAE,oCAAoC;IAClD,aAAa,EAAE,yCAAyC;IACxD,WAAW,EAAE,uCAAuC;CACpB,CAAC;AAEnC,IAAI,0BAAqD,CAAC;AAE1D,SAAS,eAAe,CAAC,SAAiB;IACxC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,OAAO,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,IAAI,EAAE,CAAC,UAAU,CAAC,I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KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,0BAA0B,GAAG,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0BAA0B,GAAG,UAAU,CAAC;IACxC,OAAO;QACL,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,UAAU;KACpB,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAiD;IAC5E,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACpD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,wBAAwB,EAAE,CAAC;IAC9C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO;YACL,GAAG,UAAU;YACb,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM;KACb,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ActionsRunnerEvent, ActionsRunnerInput, ExecuteActionsRunnerInput, RunnerStepState } from "../types.js";
2
+ declare function normalizeRunnerInput(input: ExecuteActionsRunnerInput): ActionsRunnerInput;
3
+ declare function parseRunnerEvent(line: string): ActionsRunnerEvent;
4
+ declare function updateLastStep(event: ActionsRunnerEvent, state: RunnerStepState): void;
5
+ declare function appendPreview(current: string, chunk: string): string;
6
+ export { appendPreview, normalizeRunnerInput, parseRunnerEvent, updateLastStep, };
7
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/core/actions/runner/protocol.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EAChB,MAAM,eAAe,CAAC;AAavB,iBAAS,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,kBAAkB,CAuBlF;AAED,iBAAS,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAmB1D;AAED,iBAAS,cAAc,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,eAAe,QAOxE;AAED,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAGpD;AAED,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACf,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { GitHostError } from "../../../errors.js";
2
+ import { text } from "../../../utils/text.js";
3
+ function normalizeStepEnv(step) {
4
+ if (!step.metadata?.env || typeof step.metadata.env !== "object") {
5
+ return undefined;
6
+ }
7
+ return Object.fromEntries(Object.entries(step.metadata.env)
8
+ .map(([key, value]) => [text(key), text(value)])
9
+ .filter(([key, value]) => key && value));
10
+ }
11
+ function normalizeRunnerInput(input) {
12
+ return {
13
+ branch: text(input.run.branch),
14
+ commit_hash: text(input.run.commit_hash),
15
+ env: input.actions?.env,
16
+ heartbeat_interval_ms: input.heartbeatIntervalMs,
17
+ ref: text(input.run.ref, "HEAD"),
18
+ release_id: text(input.run.release_id),
19
+ repository_id: input.run.repository_id,
20
+ repository_path: input.repositoryPath,
21
+ run_id: input.run.id,
22
+ shell: text(input.actions?.shell, "bash"),
23
+ steps: input.steps.map((step) => ({
24
+ command: step.command,
25
+ env: normalizeStepEnv(step),
26
+ id: step.id,
27
+ index: step.index,
28
+ name: step.name,
29
+ shell: text(step.metadata?.shell),
30
+ })),
31
+ workflow_id: input.run.workflow_id,
32
+ workspace_root: input.workspaceRoot,
33
+ };
34
+ }
35
+ function parseRunnerEvent(line) {
36
+ const parsed = JSON.parse(line);
37
+ if (!parsed || typeof parsed !== "object" || typeof parsed.type !== "string") {
38
+ throw new GitHostError("forge_actions_runner_protocol_error", "Actions runner emitted an invalid event payload.", {
39
+ line,
40
+ });
41
+ }
42
+ if (parsed.type !== "run.status"
43
+ && parsed.type !== "step.started"
44
+ && parsed.type !== "step.output"
45
+ && parsed.type !== "step.heartbeat"
46
+ && parsed.type !== "step.finished") {
47
+ throw new GitHostError("forge_actions_runner_protocol_error", `Actions runner emitted unsupported event "${parsed.type}".`, {
48
+ line,
49
+ });
50
+ }
51
+ return parsed;
52
+ }
53
+ function updateLastStep(event, state) {
54
+ if ("step_index" in event && typeof event.step_index === "number") {
55
+ state.lastStepIndex = event.step_index;
56
+ }
57
+ if ("step_name" in event && typeof event.step_name === "string") {
58
+ state.lastStepName = event.step_name;
59
+ }
60
+ }
61
+ function appendPreview(current, chunk) {
62
+ const next = `${current}${chunk}`;
63
+ return next.length <= 4000 ? next : next.slice(-4000);
64
+ }
65
+ export { appendPreview, normalizeRunnerInput, parseRunnerEvent, updateLastStep, };
66
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../../src/core/actions/runner/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AASrC,SAAS,gBAAgB,CAAC,IAA6B;IACrD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAA8B,CAAC;SACzD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,C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,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACf,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ActionsRunnerExecution, ExecuteActionsRunnerInput } from "./types.js";
2
+ import { resolveActionsWorkspaceRoot } from "./workspace.js";
3
+ declare function executeActionsRunner(input: ExecuteActionsRunnerInput): ActionsRunnerExecution;
4
+ export { executeActionsRunner, resolveActionsWorkspaceRoot, };
5
+ export type { ActionsRunnerEvent, ActionsRunnerExecution, ActionsRunnerHandle, ActionsRunnerInput, ExecuteActionsRunnerInput, } from "./types.js";
6
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/core/actions/runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,iBAAS,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,sBAAsB,CAMtF;AAED,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,CAAC;AAEF,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { executeGoRunner } from "./go_runner.js";
2
+ import { executeNodeRunner } from "./node_runner.js";
3
+ import { resolveRunnerLaunch } from "./runner/launch.js";
4
+ import { resolveActionsWorkspaceRoot } from "./workspace.js";
5
+ function executeActionsRunner(input) {
6
+ const launch = resolveRunnerLaunch(input.actions);
7
+ if (launch.kind === "go") {
8
+ return executeGoRunner(input, launch);
9
+ }
10
+ return executeNodeRunner(input);
11
+ }
12
+ export { executeActionsRunner, resolveActionsWorkspaceRoot, };
13
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/core/actions/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { GitForgeBubblewrapSandboxOptions, GitForgeLocalRunnerChildSpec } from "../../types.js";
2
+ declare function createBubblewrapSandbox(options?: GitForgeBubblewrapSandboxOptions): (child: GitForgeLocalRunnerChildSpec) => GitForgeLocalRunnerChildSpec;
3
+ export { createBubblewrapSandbox, };
4
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/core/actions/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAuCpG,iBAAS,uBAAuB,CAAC,OAAO,GAAE,gCAAqC,IAEjD,OAAO,4BAA4B,KAAG,4BAA4B,CAO/F;AAED,OAAO,EACL,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import fs from "node:fs";
2
+ // System paths bound read-only so a shell and common tooling can run while the
3
+ // rest of the host filesystem stays invisible to the sandboxed step.
4
+ const DEFAULT_SYSTEM_PATHS = ["/usr", "/bin", "/sbin", "/lib", "/lib64", "/etc"];
5
+ function roBindArgs(paths) {
6
+ return paths.flatMap((entry) => (fs.existsSync(entry) ? ["--ro-bind", entry, entry] : []));
7
+ }
8
+ function bindArgs(paths) {
9
+ return paths.flatMap((entry) => ["--bind", entry, entry]);
10
+ }
11
+ function buildBubblewrapArgs(child, options) {
12
+ const systemPaths = options.systemPaths || DEFAULT_SYSTEM_PATHS;
13
+ const workspace = child.cwd || process.cwd();
14
+ return [
15
+ "--unshare-all",
16
+ ...(options.allowNetwork ? ["--share-net"] : []),
17
+ "--die-with-parent",
18
+ "--proc", "/proc",
19
+ "--dev", "/dev",
20
+ "--tmpfs", "/tmp",
21
+ ...roBindArgs(systemPaths),
22
+ ...roBindArgs(options.roBind || []),
23
+ "--bind", workspace, workspace,
24
+ ...bindArgs(options.bind || []),
25
+ "--chdir", workspace,
26
+ "--",
27
+ child.command,
28
+ ...child.args,
29
+ ];
30
+ }
31
+ // Returns a `localRunner.beforeSpawn` hook that wraps each step in bubblewrap
32
+ // (`bwrap`). By default the step gets an isolated filesystem view (read-only
33
+ // system paths plus a writable job workspace), no network, and fresh
34
+ // pid/ipc/uts/user namespaces. Linux-only; requires `bwrap` on PATH.
35
+ function createBubblewrapSandbox(options = {}) {
36
+ const bwrapPath = options.bwrapPath || "bwrap";
37
+ return function beforeSpawn(child) {
38
+ return {
39
+ ...child,
40
+ args: buildBubblewrapArgs(child, options),
41
+ command: bwrapPath,
42
+ };
43
+ };
44
+ }
45
+ export { createBubblewrapSandbox, };
46
+ //# sourceMappingURL=sandbox.js.map