@ship.zone/runner 2.0.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 (180) hide show
  1. package/.smartconfig.json +101 -3
  2. package/changelog.md +69 -0
  3. package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
  4. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.json +679 -0
  5. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.txt +15719 -0
  6. package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +5 -5
  7. package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
  8. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.json +679 -0
  9. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.txt +15719 -0
  10. package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +5 -5
  11. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  12. package/dist_ts/00_commitinfo_data.js +9 -0
  13. package/dist_ts/api-client.d.ts +46 -0
  14. package/dist_ts/api-client.js +592 -0
  15. package/dist_ts/artifact-manager.d.ts +11 -0
  16. package/dist_ts/artifact-manager.js +140 -0
  17. package/dist_ts/attempt-state.d.ts +18 -0
  18. package/dist_ts/attempt-state.js +151 -0
  19. package/dist_ts/cache-manager.d.ts +13 -0
  20. package/dist_ts/cache-manager.js +300 -0
  21. package/dist_ts/cli-entry.d.ts +2 -0
  22. package/dist_ts/cli-entry.js +4 -0
  23. package/dist_ts/cli.d.ts +14 -0
  24. package/dist_ts/cli.js +215 -0
  25. package/dist_ts/config.d.ts +8 -0
  26. package/dist_ts/config.js +445 -0
  27. package/dist_ts/errors.d.ts +41 -0
  28. package/dist_ts/errors.js +90 -0
  29. package/dist_ts/filesystem.d.ts +73 -0
  30. package/dist_ts/filesystem.js +207 -0
  31. package/dist_ts/index.d.ts +16 -0
  32. package/dist_ts/index.js +17 -0
  33. package/dist_ts/interfaces.d.ts +614 -0
  34. package/dist_ts/interfaces.js +3 -0
  35. package/dist_ts/log-sender.d.ts +26 -0
  36. package/dist_ts/log-sender.js +124 -0
  37. package/dist_ts/oci-executor.d.ts +155 -0
  38. package/dist_ts/oci-executor.js +2238 -0
  39. package/dist_ts/plugins.d.ts +19 -0
  40. package/dist_ts/plugins.js +23 -0
  41. package/dist_ts/protocol-validator.d.ts +39 -0
  42. package/dist_ts/protocol-validator.js +483 -0
  43. package/dist_ts/redactor.d.ts +78 -0
  44. package/dist_ts/redactor.js +235 -0
  45. package/dist_ts/registration-state.d.ts +16 -0
  46. package/dist_ts/registration-state.js +171 -0
  47. package/dist_ts/runner.d.ts +64 -0
  48. package/dist_ts/runner.js +882 -0
  49. package/dist_ts/source-workspace.d.ts +10 -0
  50. package/dist_ts/source-workspace.js +125 -0
  51. package/dist_ts/spec-version.d.ts +11 -0
  52. package/dist_ts/spec-version.js +41 -0
  53. package/dist_ts/staging-scavenger.d.ts +7 -0
  54. package/dist_ts/staging-scavenger.js +63 -0
  55. package/dist_ts/state-owner.d.ts +74 -0
  56. package/dist_ts/state-owner.js +289 -0
  57. package/dist_ts/transfer-archive.d.ts +78 -0
  58. package/dist_ts/transfer-archive.js +1619 -0
  59. package/dist_ts/validation.d.ts +11 -0
  60. package/dist_ts/validation.js +79 -0
  61. package/dist_ts/wire-schema.d.ts +10 -0
  62. package/dist_ts/wire-schema.js +114 -0
  63. package/native-notices/crates/bitflags-2.13.1/license-apache +201 -0
  64. package/native-notices/crates/bitflags-2.13.1/license-mit +25 -0
  65. package/native-notices/crates/cc-1.8.0/license-apache +201 -0
  66. package/native-notices/crates/cc-1.8.0/license-mit +25 -0
  67. package/native-notices/crates/cfg-if-1.0.4/license-apache +201 -0
  68. package/native-notices/crates/cfg-if-1.0.4/license-mit +25 -0
  69. package/native-notices/crates/cfg_aliases-0.2.2/license +9 -0
  70. package/native-notices/crates/cfg_aliases-0.2.2/notices.md +26 -0
  71. package/native-notices/crates/find-msvc-tools-0.1.14/license-apache +201 -0
  72. package/native-notices/crates/find-msvc-tools-0.1.14/license-mit +25 -0
  73. package/native-notices/crates/itoa-1.0.18/license-apache +176 -0
  74. package/native-notices/crates/itoa-1.0.18/license-mit +23 -0
  75. package/native-notices/crates/libc-0.2.189/license-apache +176 -0
  76. package/native-notices/crates/libc-0.2.189/license-mit +25 -0
  77. package/native-notices/crates/memchr-2.8.3/copying +3 -0
  78. package/native-notices/crates/memchr-2.8.3/license-mit +21 -0
  79. package/native-notices/crates/memchr-2.8.3/unlicense +24 -0
  80. package/native-notices/crates/nix-0.30.1/license +21 -0
  81. package/native-notices/crates/proc-macro2-1.0.107/license-apache +176 -0
  82. package/native-notices/crates/proc-macro2-1.0.107/license-mit +23 -0
  83. package/native-notices/crates/quote-1.0.47/license-apache +176 -0
  84. package/native-notices/crates/quote-1.0.47/license-mit +23 -0
  85. package/native-notices/crates/serde-1.0.229/license-apache +176 -0
  86. package/native-notices/crates/serde-1.0.229/license-mit +23 -0
  87. package/native-notices/crates/serde_core-1.0.229/license-apache +176 -0
  88. package/native-notices/crates/serde_core-1.0.229/license-mit +23 -0
  89. package/native-notices/crates/serde_derive-1.0.229/license-apache +176 -0
  90. package/native-notices/crates/serde_derive-1.0.229/license-mit +23 -0
  91. package/native-notices/crates/serde_json-1.0.151/license-apache +176 -0
  92. package/native-notices/crates/serde_json-1.0.151/license-mit +23 -0
  93. package/native-notices/crates/shlex-2.0.1/license-apache +13 -0
  94. package/native-notices/crates/shlex-2.0.1/license-mit +21 -0
  95. package/native-notices/crates/syn-3.0.3/license-apache +176 -0
  96. package/native-notices/crates/syn-3.0.3/license-mit +23 -0
  97. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-apache +201 -0
  98. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-mit +25 -0
  99. package/native-notices/crates/tikv-jemallocator-0.7.0/license-apache +201 -0
  100. package/native-notices/crates/tikv-jemallocator-0.7.0/license-mit +25 -0
  101. package/native-notices/crates/unicode-ident-1.0.24/license-apache +176 -0
  102. package/native-notices/crates/unicode-ident-1.0.24/license-mit +23 -0
  103. package/native-notices/crates/unicode-ident-1.0.24/license-unicode +39 -0
  104. package/native-notices/crates/zmij-1.0.23/license-mit +23 -0
  105. package/native-notices/manifest.json +763 -0
  106. package/native-notices/native/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/jemalloc-5.3.1/jemalloc-copying +27 -0
  107. package/native-notices/readme.md +46 -0
  108. package/native-notices/runtime/gcc/gpl-3.0.txt +674 -0
  109. package/native-notices/runtime/gcc/runtime-library-exception-3.1.txt +73 -0
  110. package/native-notices/runtime/libunwind-22.1.2/license.txt +311 -0
  111. package/native-notices/runtime/musl-1.2.5/copyright +193 -0
  112. package/native-notices/rust/compiler-builtins-license.txt +275 -0
  113. package/native-notices/rust/copyright-library.html +8266 -0
  114. package/native-notices/rust/crates/addr2line-0.25.1/license-apache +201 -0
  115. package/native-notices/rust/crates/addr2line-0.25.1/license-mit +25 -0
  116. package/native-notices/rust/crates/adler2-2.0.1/license-0bsd +12 -0
  117. package/native-notices/rust/crates/adler2-2.0.1/license-apache +201 -0
  118. package/native-notices/rust/crates/adler2-2.0.1/license-mit +23 -0
  119. package/native-notices/rust/crates/memchr-2.7.6/copying +3 -0
  120. package/native-notices/rust/crates/memchr-2.7.6/license-mit +21 -0
  121. package/native-notices/rust/crates/memchr-2.7.6/unlicense +24 -0
  122. package/native-notices/rust/crates/miniz_oxide-0.8.9/license +25 -0
  123. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-apache.md +177 -0
  124. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-mit.md +24 -0
  125. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-zlib.md +14 -0
  126. package/native-notices/rust/crates/object-0.37.3/license-apache +201 -0
  127. package/native-notices/rust/crates/object-0.37.3/license-mit +25 -0
  128. package/native-notices/rust/licenses/apache-2.0.txt +73 -0
  129. package/native-notices/rust/licenses/bsd-2-clause.txt +9 -0
  130. package/native-notices/rust/licenses/cc-by-sa-4.0.txt +427 -0
  131. package/native-notices/rust/licenses/gcc-exception-3.1.txt +30 -0
  132. package/native-notices/rust/licenses/gpl-2.0-only.txt +133 -0
  133. package/native-notices/rust/licenses/gpl-3.0-or-later.txt +202 -0
  134. package/native-notices/rust/licenses/isc.txt +7 -0
  135. package/native-notices/rust/licenses/llvm-exception.txt +15 -0
  136. package/native-notices/rust/licenses/mit.txt +9 -0
  137. package/native-notices/rust/licenses/ncsa.txt +29 -0
  138. package/native-notices/rust/licenses/ofl-1.1.txt +43 -0
  139. package/native-notices/rust/licenses/unicode-3.0.txt +39 -0
  140. package/package.json +24 -21
  141. package/readme.md +91 -40
  142. package/rust/.cargo/config.toml +1 -1
  143. package/rust/Cargo.lock +43 -0
  144. package/rust/Cargo.toml +4 -1
  145. package/rust/src/lib.rs +156 -1
  146. package/rust/src/main.rs +5 -1
  147. package/rust-toolchain.toml +4 -0
  148. package/ts/00_commitinfo_data.ts +1 -1
  149. package/ts/api-client.ts +10 -7
  150. package/ts/artifact-manager.ts +9 -7
  151. package/ts/attempt-state.ts +75 -84
  152. package/ts/cache-manager.ts +22 -28
  153. package/ts/cli-entry.ts +4 -0
  154. package/ts/cli.ts +56 -45
  155. package/ts/config.ts +50 -39
  156. package/ts/errors.ts +19 -0
  157. package/ts/filesystem.ts +316 -0
  158. package/ts/index.ts +16 -15
  159. package/ts/interfaces.ts +2 -2
  160. package/ts/log-sender.ts +4 -4
  161. package/ts/oci-executor.ts +235 -383
  162. package/ts/plugins.ts +21 -3
  163. package/ts/protocol-validator.ts +5 -5
  164. package/ts/redactor.ts +2 -2
  165. package/ts/registration-state.ts +82 -90
  166. package/ts/runner.ts +30 -17
  167. package/ts/source-workspace.ts +11 -8
  168. package/ts/spec-version.ts +2 -2
  169. package/ts/staging-scavenger.ts +37 -26
  170. package/ts/state-owner.ts +346 -0
  171. package/ts/transfer-archive.ts +214 -243
  172. package/ts/validation.ts +1 -1
  173. package/ts/wire-schema.ts +3 -3
  174. package/deno.json +0 -56
  175. package/deno.lock +0 -1762
  176. package/dist_npm/mod.d.ts +0 -967
  177. package/dist_npm/mod.js +0 -10058
  178. package/mod.ts +0 -8
  179. package/musl-copyright.md +0 -81
  180. package/third-party-licenses.md +0 -95
@@ -0,0 +1,124 @@
1
+ import { ProtocolError } from './errors.js';
2
+ import { LogSequenceRedactor, StreamingSecretRedactor, } from './redactor.js';
3
+ import { utf8Length } from './validation.js';
4
+ const splitByUtf8Bytes = (value, maximumBytes) => {
5
+ const chunks = [];
6
+ let current = '';
7
+ let currentBytes = 0;
8
+ for (const codePoint of value) {
9
+ const codePointBytes = utf8Length(codePoint);
10
+ if (codePointBytes > maximumBytes) {
11
+ throw new ProtocolError('A log code point exceeds the negotiated chunk limit');
12
+ }
13
+ if (currentBytes + codePointBytes > maximumBytes) {
14
+ chunks.push(current);
15
+ current = '';
16
+ currentBytes = 0;
17
+ }
18
+ current += codePoint;
19
+ currentBytes += codePointBytes;
20
+ }
21
+ if (current)
22
+ chunks.push(current);
23
+ return chunks;
24
+ };
25
+ export class LogSender {
26
+ api;
27
+ identity;
28
+ maximumBytes;
29
+ maximumChunkBytes;
30
+ signal;
31
+ redactors;
32
+ sequenceRedactor;
33
+ sequence = 0;
34
+ sentBytes = 0;
35
+ operationQueue = Promise.resolve();
36
+ terminalError;
37
+ observationSequence = 0;
38
+ lastObservation = { stdout: 0, stderr: 0 };
39
+ constructor(api, identity, redactionSet, maximumBytes, maximumChunkBytes, signal) {
40
+ this.api = api;
41
+ this.identity = identity;
42
+ this.maximumBytes = maximumBytes;
43
+ this.maximumChunkBytes = maximumChunkBytes;
44
+ this.signal = signal;
45
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 0) {
46
+ throw new ProtocolError('Maximum total log bytes must be a non-negative integer');
47
+ }
48
+ if (!Number.isSafeInteger(maximumChunkBytes) || maximumChunkBytes <= 0) {
49
+ throw new ProtocolError('Maximum log chunk bytes must be a positive integer');
50
+ }
51
+ this.redactors = {
52
+ stdout: new StreamingSecretRedactor(redactionSet),
53
+ stderr: new StreamingSecretRedactor(redactionSet),
54
+ };
55
+ this.sequenceRedactor = new LogSequenceRedactor(redactionSet);
56
+ }
57
+ write(stream, rawData) {
58
+ return this.schedule(async () => {
59
+ this.lastObservation[stream] = ++this.observationSequence;
60
+ await this.sendBatch(this.sequenceRedactor.push(stream, this.redactors[stream].push(rawData)));
61
+ });
62
+ }
63
+ writeRunnerMessage(data) {
64
+ return this.schedule(() => this.sendBatch(this.sequenceRedactor.push('runner', data)));
65
+ }
66
+ flush() {
67
+ return this.schedule(async () => {
68
+ const streams = ['stdout', 'stderr'];
69
+ streams.sort((left, right) => this.lastObservation[left] - this.lastObservation[right]);
70
+ const writes = streams.flatMap((stream) => this.sequenceRedactor.push(stream, this.redactors[stream].flush()));
71
+ await this.sendBatch([...writes, ...this.sequenceRedactor.flush()]);
72
+ });
73
+ }
74
+ schedule(operation) {
75
+ const result = this.operationQueue.then(async () => {
76
+ if (this.terminalError !== undefined)
77
+ throw this.terminalError;
78
+ try {
79
+ await operation();
80
+ }
81
+ catch (error) {
82
+ this.terminalError = error;
83
+ throw error;
84
+ }
85
+ });
86
+ this.operationQueue = result.catch(() => undefined);
87
+ return result;
88
+ }
89
+ async sendBatch(writes) {
90
+ const nonEmpty = writes.filter((write) => write.data.length > 0);
91
+ const batchBytes = nonEmpty.reduce((total, write) => {
92
+ const next = total + utf8Length(write.data);
93
+ if (!Number.isSafeInteger(next))
94
+ throw new ProtocolError('Log byte count overflow');
95
+ return next;
96
+ }, 0);
97
+ if (batchBytes > this.maximumBytes - this.sentBytes) {
98
+ throw new ProtocolError('Redacted log output exceeds the negotiated total byte limit');
99
+ }
100
+ const chunks = nonEmpty.flatMap((write) => splitByUtf8Bytes(write.data, this.maximumChunkBytes).map((data) => ({
101
+ stream: write.stream,
102
+ data,
103
+ })));
104
+ for (const value of chunks) {
105
+ if (this.signal?.aborted)
106
+ throw this.signal.reason;
107
+ const sequence = this.sequence;
108
+ const chunk = {
109
+ identity: this.identity,
110
+ sequence,
111
+ stream: value.stream,
112
+ data: value.data,
113
+ timestamp: new Date().toISOString(),
114
+ };
115
+ const acknowledgement = await this.api.appendLog(chunk, this.signal);
116
+ if (acknowledgement.nextSequence !== sequence + 1) {
117
+ throw new ProtocolError('Coordinator returned an invalid log acknowledgement');
118
+ }
119
+ this.sequence++;
120
+ this.sentBytes += utf8Length(value.data);
121
+ }
122
+ }
123
+ }
124
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nLXNlbmRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xvZy1zZW5kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU1QyxPQUFPLEVBQ0wsbUJBQW1CLEVBRW5CLHVCQUF1QixHQUN4QixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFXN0MsTUFBTSxnQkFBZ0IsR0FBRyxDQUFDLEtBQWEsRUFBRSxZQUFvQixFQUFZLEVBQUU7SUFDekUsTUFBTSxNQUFNLEdBQWEsRUFBRSxDQUFDO0lBQzVCLElBQUksT0FBTyxHQUFHLEVBQUUsQ0FBQztJQUNqQixJQUFJLFlBQVksR0FBRyxDQUFDLENBQUM7SUFDckIsS0FBSyxNQUFNLFNBQVMsSUFBSSxLQUFLLEVBQUUsQ0FBQztRQUM5QixNQUFNLGNBQWMsR0FBRyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDN0MsSUFBSSxjQUFjLEdBQUcsWUFBWSx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MsQ0FBQztZQUNyRSxJQUFJLGVBQWUsQ0FBQyxZQUFZLEtBQUssUUFBUSxHQUFHLENBQUMsRUFBRSxDQUFDO2dCQUNsRCxNQUFNLElBQUksYUFBYSxDQUFDLHFEQUFxRCxDQUFDLENBQUM7WUFDakYsQ0FBQztZQUNELElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQztZQUNoQixJQUFJLENBQUMsU0FBUyxJQUFJLFVBQVUsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDM0MsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
@@ -0,0 +1,155 @@
1
+ import { type RunnerStateOwner } from './state-owner.js';
2
+ import type { ICompiledStep, IExecutionContext, IExecutionResult, IJobExecutor, IOciExecutorConfig, IOciJobLease, IOciRuntimeFacts, IPreparedOciLease, IPrepareOciLeaseContext, IRunnerConfig, TOciHelperTarget } from './interfaces.js';
3
+ export declare const workspaceHelperReserveBytes: number;
4
+ export declare const workspaceFixedInodes = 3;
5
+ export interface IOciRuntimeCommandRequest {
6
+ executable: string;
7
+ args: string[];
8
+ environment: Record<string, string>;
9
+ timeoutMs: number;
10
+ signal?: AbortSignal;
11
+ maximumOutputBytes?: number;
12
+ onOutput?: (stream: 'stdout' | 'stderr', chunk: Uint8Array) => Promise<void>;
13
+ }
14
+ export interface IOciRuntimeCommandResult {
15
+ success: boolean;
16
+ code: number;
17
+ stdout: Uint8Array;
18
+ stderr: Uint8Array;
19
+ }
20
+ export type TOciRuntimeCommandRunner = (request: IOciRuntimeCommandRequest) => Promise<IOciRuntimeCommandResult>;
21
+ export interface IRuntimeMakeTempOptions {
22
+ dir?: string;
23
+ prefix?: string;
24
+ suffix?: string;
25
+ }
26
+ export interface IRuntimeRemoveOptions {
27
+ recursive?: boolean;
28
+ }
29
+ export interface IRuntimeDirectoryEntry {
30
+ name: string;
31
+ isFile: boolean;
32
+ isDirectory: boolean;
33
+ isSymlink: boolean;
34
+ }
35
+ export interface IRuntimeFileInfo {
36
+ isDirectory: boolean;
37
+ isSymlink: boolean;
38
+ uid: number | null;
39
+ mtime: Date | null;
40
+ dev: number | null;
41
+ ino: number | null;
42
+ }
43
+ export interface IOciExecutorDependencies {
44
+ commandRunner?: TOciRuntimeCommandRunner;
45
+ runtimeEnvironment?: Record<string, string>;
46
+ resolveHelperPath?: (target: TOciHelperTarget) => Promise<string>;
47
+ probeTmpfs?: (helperPath: string) => Promise<number>;
48
+ randomId?: () => string;
49
+ now?: () => number;
50
+ makeTempDir?: (options: IRuntimeMakeTempOptions) => Promise<string>;
51
+ chmod?: (path: string, mode: number) => Promise<void>;
52
+ remove?: (path: string, options?: IRuntimeRemoveOptions) => Promise<void>;
53
+ }
54
+ export interface IHostTmpfsProbeScavengerDependencies {
55
+ getUid?: () => number | undefined;
56
+ now?: () => number;
57
+ readDir?: (path: string) => AsyncIterable<IRuntimeDirectoryEntry>;
58
+ lstat?: (path: string) => Promise<IRuntimeFileInfo>;
59
+ remove?: (path: string, options?: IRuntimeRemoveOptions) => Promise<void>;
60
+ }
61
+ export interface IWorkspaceVolumeLimits {
62
+ blockSize: number;
63
+ logicalBytes: number;
64
+ maximumEntries: number;
65
+ reserveBytes: number;
66
+ sizeBytes: number;
67
+ inodeLimit: number;
68
+ }
69
+ export interface IOciRunCommand {
70
+ args: string[];
71
+ environment: Record<string, string>;
72
+ }
73
+ export interface IOciStepCommandInput {
74
+ runnerId: string;
75
+ sessionId: string;
76
+ lease: IOciJobLease;
77
+ step: ICompiledStep;
78
+ containerName: string;
79
+ volumeName: string;
80
+ }
81
+ export interface IOciHelperCommandInput {
82
+ runnerId: string;
83
+ sessionId: string;
84
+ attemptId: string;
85
+ containerName: string;
86
+ image: string;
87
+ helperPath: string;
88
+ command: string[];
89
+ volumeName?: string;
90
+ sourcePath?: string;
91
+ destinationPath?: string;
92
+ }
93
+ export declare const scavengeHostTmpfsProbes: (directory?: string, dependencies?: IHostTmpfsProbeScavengerDependencies, runtimeProbeOwnerId?: string) => Promise<void>;
94
+ export declare const calculateWorkspaceVolumeLimits: (logicalBytes: number, maximumEntries: number, blockSize: number) => IWorkspaceVolumeLimits;
95
+ export declare const buildOciRunCommand: (config: IRunnerConfig, input: IOciStepCommandInput) => IOciRunCommand;
96
+ export declare const buildOciHelperCreateCommand: (config: IRunnerConfig, input: IOciHelperCommandInput) => string[];
97
+ export declare class OciExecutor implements IJobExecutor {
98
+ private readonly config;
99
+ private readonly stateOwner;
100
+ private readonly runtimeEnvironment;
101
+ private readonly commandRunner;
102
+ private readonly randomId;
103
+ private readonly now;
104
+ private readonly resolveHelperPathImplementation;
105
+ private readonly probeTmpfsImplementation;
106
+ private readonly makeTempDir;
107
+ private readonly chmod;
108
+ private readonly remove;
109
+ private runtimeFacts?;
110
+ private readonly preparedLeases;
111
+ /**
112
+ * @param stateOwner Ownership of `config.stateDirectory`, where the executor keeps its workspace
113
+ * helpers, runtime probe owner marker and workspace exports.
114
+ */
115
+ constructor(config: IRunnerConfig, stateOwner: RunnerStateOwner, dependencies?: IOciExecutorDependencies);
116
+ verifyRuntime(): Promise<IOciRuntimeFacts>;
117
+ prepareLease(context: IPrepareOciLeaseContext): Promise<IPreparedOciLease>;
118
+ reconcileOrphans(runnerId: string, currentSessionId: string): Promise<void>;
119
+ execute(context: IExecutionContext): Promise<IExecutionResult>;
120
+ private requireRuntimeFacts;
121
+ private validateLeaseIdentity;
122
+ private resolvePackagedHelper;
123
+ private materializeWorkspaceHelper;
124
+ private ensureWorkspaceHelperDirectory;
125
+ private ensureRuntimeProbeOwner;
126
+ private validateRuntimeProbeOwnerMarker;
127
+ private scavengeWorkspaceHelpers;
128
+ private recoverInterruptedWorkspaceHelperPublication;
129
+ private validateMaterializedWorkspaceHelper;
130
+ private syncDirectory;
131
+ private probeHostTmpfs;
132
+ private readFilesystemProbe;
133
+ private reconcileRuntimeProbeVolumes;
134
+ private probeRuntimeVolume;
135
+ private volumeCreateArgs;
136
+ private parseImageInspection;
137
+ private parseContainerState;
138
+ private parseCounts;
139
+ private runHostHelper;
140
+ private runRuntime;
141
+ private runInertContainer;
142
+ private runWorkspaceHelper;
143
+ private startVolumeHolder;
144
+ private measureWorkspace;
145
+ private readWorkspaceCapacity;
146
+ private runStepContainer;
147
+ private stopContainer;
148
+ private stopAndRemoveContainer;
149
+ private removeContainer;
150
+ private removeVolume;
151
+ private removePath;
152
+ private createResourceName;
153
+ private randomHex;
154
+ }
155
+ export declare const copyOciConfig: (config: IOciExecutorConfig) => IOciExecutorConfig;