@ship.zone/runner 3.0.0 → 5.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 (80) hide show
  1. package/.smartconfig.json +19 -1
  2. package/changelog.md +61 -0
  3. package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
  4. package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +4 -4
  5. package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
  6. package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +4 -4
  7. package/dist_ts/00_commitinfo_data.js +3 -3
  8. package/dist_ts/api-client.d.ts +2 -1
  9. package/dist_ts/api-client.js +10 -2
  10. package/dist_ts/artifact-manager.js +1 -1
  11. package/dist_ts/attempt-state.js +1 -1
  12. package/dist_ts/cache-manager.js +1 -1
  13. package/dist_ts/cli-entry.js +17 -3
  14. package/dist_ts/cli.d.ts +7 -0
  15. package/dist_ts/cli.js +155 -35
  16. package/dist_ts/config.js +75 -22
  17. package/dist_ts/egress-proxy.d.ts +99 -0
  18. package/dist_ts/egress-proxy.js +607 -0
  19. package/dist_ts/errors.js +1 -1
  20. package/dist_ts/filesystem.js +1 -1
  21. package/dist_ts/index.d.ts +5 -1
  22. package/dist_ts/index.js +6 -2
  23. package/dist_ts/interfaces.d.ts +85 -31
  24. package/dist_ts/interfaces.js +1 -1
  25. package/dist_ts/log-sender.js +1 -1
  26. package/dist_ts/microvm-executor.d.ts +90 -0
  27. package/dist_ts/microvm-executor.js +1078 -0
  28. package/dist_ts/node-version.d.ts +11 -0
  29. package/dist_ts/node-version.js +43 -0
  30. package/dist_ts/npm-grants.d.ts +9 -0
  31. package/dist_ts/npm-grants.js +44 -0
  32. package/dist_ts/oci-registry.d.ts +73 -0
  33. package/dist_ts/oci-registry.js +508 -0
  34. package/dist_ts/plugins.d.ts +6 -2
  35. package/dist_ts/plugins.js +7 -3
  36. package/dist_ts/protocol-validator.d.ts +3 -5
  37. package/dist_ts/protocol-validator.js +27 -51
  38. package/dist_ts/redactor.js +1 -1
  39. package/dist_ts/registration-state.js +1 -1
  40. package/dist_ts/runner.d.ts +5 -5
  41. package/dist_ts/runner.js +47 -22
  42. package/dist_ts/source-workspace.js +1 -1
  43. package/dist_ts/spec-version.js +1 -1
  44. package/dist_ts/staging-scavenger.js +1 -1
  45. package/dist_ts/state-owner.js +4 -2
  46. package/dist_ts/transfer-archive.js +1 -1
  47. package/dist_ts/validation.js +1 -1
  48. package/dist_ts/vsock-protocol.d.ts +130 -0
  49. package/dist_ts/vsock-protocol.js +336 -0
  50. package/dist_ts/wire-schema.js +1 -1
  51. package/package.json +19 -15
  52. package/readme.md +106 -108
  53. package/rust/Cargo.lock +1 -0
  54. package/rust/Cargo.toml +2 -1
  55. package/rust/src/cpio.rs +147 -0
  56. package/rust/src/extfs.rs +747 -0
  57. package/rust/src/guest.rs +2411 -0
  58. package/rust/src/lib.rs +41 -0
  59. package/rust/src/main.rs +6 -1
  60. package/rust/src/oci_tar.rs +842 -0
  61. package/ts/00_commitinfo_data.ts +2 -2
  62. package/ts/api-client.ts +19 -1
  63. package/ts/cli-entry.ts +15 -2
  64. package/ts/cli.ts +172 -40
  65. package/ts/config.ts +100 -25
  66. package/ts/egress-proxy.ts +649 -0
  67. package/ts/index.ts +5 -1
  68. package/ts/interfaces.ts +97 -30
  69. package/ts/microvm-executor.ts +1310 -0
  70. package/ts/node-version.ts +49 -0
  71. package/ts/npm-grants.ts +49 -0
  72. package/ts/oci-registry.ts +649 -0
  73. package/ts/plugins.ts +6 -2
  74. package/ts/protocol-validator.ts +29 -58
  75. package/ts/runner.ts +48 -21
  76. package/ts/state-owner.ts +8 -1
  77. package/ts/vsock-protocol.ts +437 -0
  78. package/dist_ts/oci-executor.d.ts +0 -155
  79. package/dist_ts/oci-executor.js +0 -2238
  80. package/ts/oci-executor.ts +0 -2989
@@ -0,0 +1,437 @@
1
+ import * as plugins from './plugins.js';
2
+ import { RunnerError } from './errors.js';
3
+
4
+ export const GUEST_VSOCK_PORT = 1024;
5
+
6
+ export const FRAME_JSON_REQ = 0x01;
7
+ export const FRAME_JSON_RES = 0x02;
8
+ export const FRAME_DATA = 0x03;
9
+ export const FRAME_DATA_EOF = 0x04;
10
+ export const FRAME_STDOUT = 0x05;
11
+ export const FRAME_STDERR = 0x06;
12
+ export const FRAME_CANCEL = 0x07;
13
+
14
+ const MAXIMUM_FRAME_BYTES = 4 * 1024 * 1024;
15
+ const STREAM_CHUNK_BYTES = 32 * 1024;
16
+
17
+ export interface IGuestFrame {
18
+ kind: number;
19
+ payload: Buffer;
20
+ }
21
+
22
+ export interface IGuestHello {
23
+ ok: true;
24
+ version: string;
25
+ os: string;
26
+ architecture: string;
27
+ }
28
+
29
+ export interface IGuestTransferResult {
30
+ ok: true;
31
+ bytes: number;
32
+ entries: number;
33
+ }
34
+
35
+ export interface IGuestStepRequest {
36
+ command: string[];
37
+ env: Record<string, string>;
38
+ workingDirectory: string;
39
+ uid: number;
40
+ gid: number;
41
+ rootMode?: boolean;
42
+ timeoutMs: number;
43
+ memoryBytes: number;
44
+ cpus: number;
45
+ pids: number;
46
+ sharedMemoryBytes: number;
47
+ temporarySizeBytes: number;
48
+ maximumWorkspaceBytes: number;
49
+ maximumWorkspaceEntries: number;
50
+ }
51
+
52
+ export interface IGuestImageBuildRequest {
53
+ context: string;
54
+ dockerfile: string;
55
+ target?: string;
56
+ platform: string;
57
+ buildArgs: Record<string, string>;
58
+ secrets: Record<string, string>;
59
+ labels: Record<string, string>;
60
+ baseImages: Array<{ name: string; image: string }>;
61
+ npmrcContent?: string;
62
+ pushRegistry: string;
63
+ pushRepository: string;
64
+ grants: Array<{ registry: string; username: string; secret: string }>;
65
+ timeoutMs: number;
66
+ importCacheDir?: string;
67
+ exportCacheDir?: string;
68
+ buildctlPath?: string;
69
+ }
70
+
71
+ export interface IGuestImageBuildResult {
72
+ ok: true;
73
+ exitCode: number | null;
74
+ timedOut: boolean;
75
+ canceled: boolean;
76
+ manifestDigest: string | null;
77
+ mediaType: string | null;
78
+ sizeBytes: number | null;
79
+ cacheExported: boolean;
80
+ }
81
+
82
+ export interface IGuestStepResult {
83
+ ok: true;
84
+ exitCode: number | null;
85
+ signal: number | null;
86
+ timedOut: boolean;
87
+ canceled: boolean;
88
+ oomKilled: boolean;
89
+ workspaceBytes: number;
90
+ workspaceEntries: number;
91
+ }
92
+
93
+ export interface IGuestRunStepCallbacks {
94
+ onStdout?: (chunk: Uint8Array) => Promise<void>;
95
+ onStderr?: (chunk: Uint8Array) => Promise<void>;
96
+ signal?: AbortSignal;
97
+ }
98
+
99
+ class FrameReader {
100
+ private chunks: Buffer[] = [];
101
+ private buffered = 0;
102
+ private ended = false;
103
+ private failure?: Error;
104
+ private waiters: Array<() => void> = [];
105
+
106
+ constructor(private readonly socket: plugins.net.Socket) {
107
+ socket.on('data', (chunk: Buffer) => {
108
+ this.chunks.push(chunk);
109
+ this.buffered += chunk.length;
110
+ this.wake();
111
+ });
112
+ socket.on('end', () => {
113
+ this.ended = true;
114
+ this.wake();
115
+ });
116
+ socket.on('close', () => {
117
+ this.ended = true;
118
+ this.wake();
119
+ });
120
+ socket.on('error', (error: Error) => {
121
+ this.failure = error;
122
+ this.ended = true;
123
+ this.wake();
124
+ });
125
+ }
126
+
127
+ private wake(): void {
128
+ const list = this.waiters;
129
+ this.waiters = [];
130
+ for (const resolve of list) resolve();
131
+ }
132
+
133
+ private async ensure(bytes: number): Promise<boolean> {
134
+ while (this.buffered < bytes) {
135
+ if (this.failure) throw new RunnerError(`Guest vsock stream error: ${this.failure.message}`, { cause: this.failure });
136
+ if (this.ended) return false;
137
+ await new Promise<void>((resolve) => {
138
+ this.waiters.push(resolve);
139
+ });
140
+ }
141
+ return true;
142
+ }
143
+
144
+ private take(bytes: number): Buffer {
145
+ const parts: Buffer[] = [];
146
+ let remaining = bytes;
147
+ while (remaining > 0) {
148
+ const head = this.chunks[0];
149
+ if (head.length <= remaining) {
150
+ parts.push(head);
151
+ this.chunks.shift();
152
+ remaining -= head.length;
153
+ } else {
154
+ parts.push(head.subarray(0, remaining));
155
+ this.chunks[0] = head.subarray(remaining);
156
+ remaining = 0;
157
+ }
158
+ }
159
+ this.buffered -= bytes;
160
+ return parts.length === 1 ? parts[0] : Buffer.concat(parts, bytes);
161
+ }
162
+
163
+ async nextFrame(): Promise<IGuestFrame | null> {
164
+ const hasHeader = await this.ensure(5);
165
+ if (!hasHeader) {
166
+ if (this.buffered > 0) {
167
+ throw new RunnerError('Guest vsock stream closed mid-frame');
168
+ }
169
+ return null;
170
+ }
171
+ const header = this.take(5);
172
+ const length = header.readUInt32BE(0);
173
+ const kind = header[4];
174
+ if (length > MAXIMUM_FRAME_BYTES) {
175
+ throw new RunnerError('Guest vsock frame exceeds maximum allowed size');
176
+ }
177
+ if (length === 0) return { kind, payload: Buffer.alloc(0) };
178
+ const hasPayload = await this.ensure(length);
179
+ if (!hasPayload) throw new RunnerError('Guest vsock stream closed before frame payload completed');
180
+ return { kind, payload: this.take(length) };
181
+ }
182
+ }
183
+
184
+ const writeAllSocket = (socket: plugins.net.Socket, data: Uint8Array): Promise<void> =>
185
+ new Promise((resolve, reject) => {
186
+ if (socket.destroyed) {
187
+ reject(new RunnerError('Guest vsock socket is closed'));
188
+ return;
189
+ }
190
+ socket.write(data, (error?: Error | null) => {
191
+ if (error) reject(new RunnerError(`Guest vsock write failed: ${error.message}`, { cause: error }));
192
+ else resolve();
193
+ });
194
+ });
195
+
196
+ const encodeFrame = (kind: number, payload: Uint8Array): Buffer => {
197
+ if (payload.byteLength > MAXIMUM_FRAME_BYTES) {
198
+ throw new RunnerError('Outbound vsock frame exceeds maximum allowed size');
199
+ }
200
+ const buf = Buffer.allocUnsafe(5 + payload.byteLength);
201
+ buf.writeUInt32BE(payload.byteLength, 0);
202
+ buf[4] = kind;
203
+ if (payload.byteLength > 0) buf.set(payload, 5);
204
+ return buf;
205
+ };
206
+
207
+ /**
208
+ * Framed binary/JSON RPC client talking to `runnerworkspace guest-init` inside a Firecracker
209
+ * microVM over vsock (or over a Unix socket in unit tests).
210
+ */
211
+ export class GuestVsockClient {
212
+ private readonly reader: FrameReader;
213
+
214
+ constructor(private readonly socket: plugins.net.Socket) {
215
+ this.reader = new FrameReader(socket);
216
+ }
217
+
218
+ close(): void {
219
+ if (!this.socket.destroyed) this.socket.destroy();
220
+ }
221
+
222
+ private async sendJson(request: Record<string, unknown>): Promise<void> {
223
+ const payload = Buffer.from(JSON.stringify(request), 'utf8');
224
+ await writeAllSocket(this.socket, encodeFrame(FRAME_JSON_REQ, payload));
225
+ }
226
+
227
+ private async readJsonResponse<T extends { ok: true }>(): Promise<T> {
228
+ const frame = await this.reader.nextFrame();
229
+ if (!frame) throw new RunnerError('Guest closed vsock connection before responding');
230
+ if (frame.kind !== FRAME_JSON_RES) {
231
+ throw new RunnerError(`Guest returned unexpected frame type ${frame.kind}`);
232
+ }
233
+ let parsed: unknown;
234
+ try {
235
+ parsed = JSON.parse(frame.payload.toString('utf8'));
236
+ } catch (error) {
237
+ throw new RunnerError('Guest returned malformed JSON response', { cause: error });
238
+ }
239
+ if (typeof parsed !== 'object' || parsed === null) {
240
+ throw new RunnerError('Guest returned non-object JSON response');
241
+ }
242
+ const record = parsed as Record<string, unknown>;
243
+ if (record.ok !== true) {
244
+ const message = typeof record.error === 'string' ? record.error : 'Unknown guest error';
245
+ throw new RunnerError(`Guest operation failed: ${message}`);
246
+ }
247
+ return record as T;
248
+ }
249
+
250
+ async hello(): Promise<IGuestHello> {
251
+ await this.sendJson({ op: 'hello' });
252
+ return await this.readJsonResponse<IGuestHello>();
253
+ }
254
+
255
+ async prepareWorkspace(options: {
256
+ workspaceSizeBytes: number;
257
+ maximumWorkspaceEntries: number;
258
+ uid: number;
259
+ gid: number;
260
+ mode?: 'oci' | 'vm' | 'oci-image';
261
+ npmrcContent?: string;
262
+ }): Promise<void> {
263
+ await this.sendJson({ op: 'prepare_workspace', ...options });
264
+ await this.readJsonResponse<{ ok: true }>();
265
+ }
266
+
267
+ async importTar(
268
+ tarBytes: Uint8Array,
269
+ options: { maximumBytes: number; maximumEntries: number; uid: number; gid: number },
270
+ ): Promise<IGuestTransferResult> {
271
+ await this.sendJson({ op: 'import_tar', ...options });
272
+ for (let offset = 0; offset < tarBytes.byteLength; offset += STREAM_CHUNK_BYTES) {
273
+ const slice = tarBytes.subarray(offset, Math.min(tarBytes.byteLength, offset + STREAM_CHUNK_BYTES));
274
+ await writeAllSocket(this.socket, encodeFrame(FRAME_DATA, slice));
275
+ }
276
+ await writeAllSocket(this.socket, encodeFrame(FRAME_DATA_EOF, Buffer.alloc(0)));
277
+ return await this.readJsonResponse<IGuestTransferResult>();
278
+ }
279
+
280
+ async runStep(
281
+ spec: IGuestStepRequest,
282
+ callbacks: IGuestRunStepCallbacks = {},
283
+ ): Promise<IGuestStepResult> {
284
+ let cancelSent = false;
285
+ const sendCancel = (): void => {
286
+ if (cancelSent || this.socket.destroyed) return;
287
+ cancelSent = true;
288
+ void writeAllSocket(this.socket, encodeFrame(FRAME_CANCEL, Buffer.alloc(0))).catch(() => {});
289
+ };
290
+ const onAbort = (): void => sendCancel();
291
+ callbacks.signal?.addEventListener('abort', onAbort, { once: true });
292
+ try {
293
+ await this.sendJson({ op: 'run_step', ...spec });
294
+ if (callbacks.signal?.aborted) sendCancel();
295
+
296
+ for (;;) {
297
+ const frame = await this.reader.nextFrame();
298
+ if (!frame) throw new RunnerError('Guest closed vsock connection while step was running');
299
+ if (frame.kind === FRAME_STDOUT) {
300
+ if (callbacks.onStdout && frame.payload.byteLength > 0) {
301
+ await callbacks.onStdout(frame.payload);
302
+ }
303
+ continue;
304
+ }
305
+ if (frame.kind === FRAME_STDERR) {
306
+ if (callbacks.onStderr && frame.payload.byteLength > 0) {
307
+ await callbacks.onStderr(frame.payload);
308
+ }
309
+ continue;
310
+ }
311
+ if (frame.kind === FRAME_JSON_RES) {
312
+ let parsed: unknown;
313
+ try {
314
+ parsed = JSON.parse(frame.payload.toString('utf8'));
315
+ } catch (error) {
316
+ throw new RunnerError('Guest returned malformed step JSON response', { cause: error });
317
+ }
318
+ const record = parsed as Record<string, unknown>;
319
+ if (record.ok !== true) {
320
+ const message = typeof record.error === 'string' ? record.error : 'Step failed in guest';
321
+ throw new RunnerError(`Guest step execution failed: ${message}`);
322
+ }
323
+ return record as unknown as IGuestStepResult;
324
+ }
325
+ throw new RunnerError(`Guest sent unexpected frame ${frame.kind} during step execution`);
326
+ }
327
+ } finally {
328
+ callbacks.signal?.removeEventListener('abort', onAbort);
329
+ }
330
+ }
331
+
332
+ async exportTar(options: {
333
+ selections: string[];
334
+ maximumBytes: number;
335
+ maximumEntries: number;
336
+ maximumStreamBytes?: number;
337
+ }): Promise<{ tarBytes: Buffer; bytes: number; entries: number }> {
338
+ const maximumStreamBytes = options.maximumStreamBytes ??
339
+ options.maximumBytes + options.maximumEntries * 1024 + 1024 * 1024;
340
+ await this.sendJson({
341
+ op: 'export_tar',
342
+ selections: options.selections,
343
+ maximumBytes: options.maximumBytes,
344
+ maximumEntries: options.maximumEntries,
345
+ });
346
+ const chunks: Buffer[] = [];
347
+ let total = 0;
348
+ for (;;) {
349
+ const frame = await this.reader.nextFrame();
350
+ if (!frame) throw new RunnerError('Guest closed vsock connection during workspace export');
351
+ if (frame.kind === FRAME_DATA) {
352
+ total += frame.payload.byteLength;
353
+ if (total > maximumStreamBytes) {
354
+ throw new RunnerError('Exported workspace stream exceeds maximum allowed size');
355
+ }
356
+ chunks.push(frame.payload);
357
+ continue;
358
+ }
359
+ if (frame.kind === FRAME_DATA_EOF) {
360
+ const result = await this.readJsonResponse<IGuestTransferResult>();
361
+ return {
362
+ tarBytes: chunks.length === 1 ? chunks[0] : Buffer.concat(chunks, total),
363
+ bytes: result.bytes,
364
+ entries: result.entries,
365
+ };
366
+ }
367
+ if (frame.kind === FRAME_JSON_RES) {
368
+ // Guest returned an error before streaming any data frames.
369
+ const parsed = JSON.parse(frame.payload.toString('utf8')) as Record<string, unknown>;
370
+ const message = typeof parsed.error === 'string' ? parsed.error : 'Workspace export failed';
371
+ throw new RunnerError(`Guest workspace export failed: ${message}`);
372
+ }
373
+ throw new RunnerError(`Guest sent unexpected frame ${frame.kind} during workspace export`);
374
+ }
375
+ }
376
+
377
+ async runImageBuild(
378
+ spec: IGuestImageBuildRequest,
379
+ callbacks: IGuestRunStepCallbacks = {},
380
+ ): Promise<IGuestImageBuildResult> {
381
+ let cancelSent = false;
382
+ const sendCancel = (): void => {
383
+ if (cancelSent || this.socket.destroyed) return;
384
+ cancelSent = true;
385
+ void writeAllSocket(this.socket, encodeFrame(FRAME_CANCEL, Buffer.alloc(0))).catch(() => {});
386
+ };
387
+ const onAbort = (): void => sendCancel();
388
+ callbacks.signal?.addEventListener('abort', onAbort, { once: true });
389
+ try {
390
+ await this.sendJson({ op: 'run_image_build', ...spec });
391
+ if (callbacks.signal?.aborted) sendCancel();
392
+
393
+ for (;;) {
394
+ const frame = await this.reader.nextFrame();
395
+ if (!frame) throw new RunnerError('Guest closed vsock connection during image build');
396
+ if (frame.kind === FRAME_STDOUT) {
397
+ if (callbacks.onStdout && frame.payload.byteLength > 0) {
398
+ await callbacks.onStdout(frame.payload);
399
+ }
400
+ continue;
401
+ }
402
+ if (frame.kind === FRAME_STDERR) {
403
+ if (callbacks.onStderr && frame.payload.byteLength > 0) {
404
+ await callbacks.onStderr(frame.payload);
405
+ }
406
+ continue;
407
+ }
408
+ if (frame.kind === FRAME_JSON_RES) {
409
+ let parsed: unknown;
410
+ try {
411
+ parsed = JSON.parse(frame.payload.toString('utf8'));
412
+ } catch (error) {
413
+ throw new RunnerError('Guest returned malformed image build JSON response', {
414
+ cause: error,
415
+ });
416
+ }
417
+ const record = parsed as Record<string, unknown>;
418
+ if (record.ok !== true) {
419
+ const message = typeof record.error === 'string'
420
+ ? record.error
421
+ : 'Image build failed in guest';
422
+ throw new RunnerError(`Guest image build failed: ${message}`);
423
+ }
424
+ return record as unknown as IGuestImageBuildResult;
425
+ }
426
+ throw new RunnerError(`Guest sent unexpected frame ${frame.kind} during image build`);
427
+ }
428
+ } finally {
429
+ callbacks.signal?.removeEventListener('abort', onAbort);
430
+ }
431
+ }
432
+
433
+ async shutdown(): Promise<void> {
434
+ await this.sendJson({ op: 'shutdown' });
435
+ await this.readJsonResponse<{ ok: true }>();
436
+ }
437
+ }
@@ -1,155 +0,0 @@
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;