@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
package/ts/interfaces.ts CHANGED
@@ -3,12 +3,8 @@ import { commitinfo } from './00_commitinfo_data.js';
3
3
  export const runnerVersion: string = commitinfo.version;
4
4
 
5
5
  export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
6
- export type TIsolation = 'container' | 'microvm';
7
6
  export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
8
- export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
9
7
  export type TNetworkMode = 'none' | 'egress';
10
- export type TSourceFormat = 'tar.gz';
11
- export type TOciRuntime = 'docker' | 'podman';
12
8
  export type TArtifactPermission = 'none' | 'write';
13
9
  export type TCachePermission = 'none' | 'read' | 'read-write';
14
10
  export type TImagePermission = 'none' | 'push';
@@ -83,17 +79,13 @@ export interface IResourceLimits {
83
79
 
84
80
  export interface IRunnerCapabilities {
85
81
  executionProfiles: TExecutionProfile[];
86
- isolation: TIsolation[];
87
82
  platforms: string[];
88
83
  labels: string[];
89
84
  features: TRunnerFeature[];
90
85
  networks: TNetworkMode[];
91
- sourceFormats: TSourceFormat[];
92
86
  limits: ITransferLimits;
93
87
  /** The largest resource ceilings the runner enforces per attempt. */
94
88
  resources?: IResourceLimits;
95
- /** The lease contents the runner uses. */
96
- leaseFeatures?: TLeaseFeature[];
97
89
  /** The largest job `timeoutMs` the runner executes. */
98
90
  maximumTimeoutMs?: number;
99
91
  }
@@ -143,7 +135,6 @@ export interface IClaimJobRequest {
143
135
  claimRequestId: string;
144
136
  runnerId: string;
145
137
  sessionId: string;
146
- capabilities: IRunnerCapabilities;
147
138
  }
148
139
 
149
140
  export interface IClaimJobResponse {
@@ -192,13 +183,11 @@ export interface IJobLease {
192
183
  }
193
184
 
194
185
  /**
195
- * A lease this runner executes: an `oci` job in `container` isolation with a digest-pinned image,
196
- * no image grants or bindings, and no npm grants.
186
+ * A lease this runner executes in Firecracker `microvm` isolation (`oci`, `vm`, or `oci-image`),
187
+ * including optional attempt-scoped image grants, candidate bindings, and npm read grants.
197
188
  */
198
- export interface IOciJobLease extends Omit<IJobLease, 'job' | 'grants' | 'bindings' | 'npmGrants'> {
199
- job: IOciRunnerJob;
200
- grants: [];
201
- bindings: [];
189
+ export interface IOciJobLease extends Omit<IJobLease, 'job'> {
190
+ job: TExecutableRunnerJob;
202
191
  }
203
192
 
204
193
  export interface IJobIdentity {
@@ -278,6 +267,32 @@ export interface IRecoverAttemptRequest {
278
267
  reason: 'runner_restarted';
279
268
  }
280
269
 
270
+ export interface IRecordImageRequest {
271
+ recordRequestId: string;
272
+ identity: IJobIdentity;
273
+ manifestDigest: string;
274
+ mediaType: 'application/vnd.oci.image.manifest.v1+json';
275
+ sizeBytes: number;
276
+ platform: string;
277
+ }
278
+
279
+ export interface IImageRecord {
280
+ registry: string;
281
+ repository: string;
282
+ manifestDigest: string;
283
+ mediaType: 'application/vnd.oci.image.manifest.v1+json';
284
+ sizeBytes: number;
285
+ platform: string;
286
+ createdAt: string;
287
+ }
288
+
289
+ export interface IProducedImageManifest {
290
+ readonly manifestDigest: string;
291
+ readonly mediaType: 'application/vnd.oci.image.manifest.v1+json';
292
+ readonly sizeBytes: number;
293
+ readonly platform: string;
294
+ }
295
+
281
296
  export interface ITransferRecord {
282
297
  name: string;
283
298
  format: 'tar.gz';
@@ -297,7 +312,6 @@ export interface IErrorResponse {
297
312
 
298
313
  export interface IJobRequirements {
299
314
  executionProfile: TExecutionProfile;
300
- isolation: TIsolation;
301
315
  platform?: string;
302
316
  labels: string[];
303
317
  features: TRunnerFeature[];
@@ -456,13 +470,30 @@ export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase {
456
470
  /** Every compiled job shape the published runner job schema admits. */
457
471
  export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
458
472
 
459
- /** An `oci` job this runner executes: container isolation, no network, a digest-pinned image. */
473
+ /** An `oci` job this runner executes in a Firecracker microVM. */
460
474
  export interface IOciRunnerJob extends IContainerRunnerJob {
461
- requirements: IJobRequirements & { executionProfile: 'oci'; isolation: 'container' };
462
- network: INoNetwork;
463
- execution: IOciExecution & { image: string };
475
+ requirements: IJobRequirements & { executionProfile: 'oci' };
476
+ }
477
+
478
+ /** A `vm` job this runner executes in a Firecracker microVM. */
479
+ export interface IVmExecutableRunnerJob extends IVmRunnerJob {
480
+ requirements: IJobRequirements & { executionProfile: 'vm'; platform: string };
481
+ }
482
+
483
+ /** An `oci-image` job this runner executes in a Firecracker microVM. */
484
+ export interface IImageBuildExecutableRunnerJob extends IImageBuildRunnerJob {
485
+ requirements: IJobRequirements & {
486
+ executionProfile: 'oci-image';
487
+ platform: string;
488
+ };
464
489
  }
465
490
 
491
+ /** Every compiled job shape this unified Firecracker runner executes. */
492
+ export type TExecutableRunnerJob =
493
+ | IOciRunnerJob
494
+ | IVmExecutableRunnerJob
495
+ | IImageBuildExecutableRunnerJob;
496
+
466
497
  export interface ITransferMetadata {
467
498
  sha256: string;
468
499
  sizeBytes: number;
@@ -519,10 +550,29 @@ export type TOciArchitecture = 'amd64' | 'arm64';
519
550
  export type TOciHelperTarget = 'linux_amd64' | 'linux_arm64';
520
551
 
521
552
  export interface IOciExecutorConfig {
522
- runtime: TOciRuntime;
523
- runtimePath: string;
553
+ /** Pinned Linux vmlinux kernel path for Firecracker microVMs. */
554
+ kernelPath: string;
555
+ /** Optional pinned ext2 guest rootfs containing rootless BuildKit (`buildkitd` + `buildctl`) for `oci-image` jobs. */
556
+ builderRootfsPath?: string;
557
+ /** Optional digest-pinned OCI image containing rootless BuildKit (pulled on demand when `builderRootfsPath` is not set). */
558
+ builderImage?: string;
559
+ /** Optional override for the `buildctl` binary path inside the builder guest. */
560
+ buildctlPath?: string;
561
+ /** Optional smartvm-helper Unix socket path (defaults to `/run/smartvm/helper.sock`). */
562
+ smartvmSocketPath?: string;
563
+ /** Optional smartvm-bridge runtime directory for vsock relay sockets. */
564
+ smartvmRuntimeDir?: string;
565
+ /** Optional explicit path to the smartvm-bridge binary. */
566
+ smartvmBridgePath?: string;
567
+ /** Kernel boot arguments passed to Firecracker. */
568
+ bootArgs: string;
569
+ /** Maximum extracted OCI rootfs image bytes accepted during image materialization. */
570
+ maximumRootfsBytes: number;
571
+ /** Guest memory headroom reserved for the guest kernel and init agent on top of step memory. */
572
+ guestMemoryOverheadBytes: number;
573
+ /** Extra internal CIDRs blocked by the host egress proxy (e.g. coordinator network ranges). */
574
+ egressBlockedCidrs: string[];
524
575
  workspaceHelperPath?: string;
525
- requireRootless: boolean;
526
576
  allowedNetworks: TNetworkMode[];
527
577
  containerUser: string;
528
578
  defaultTimeoutMs: number;
@@ -583,16 +633,24 @@ export interface IExecutionContext {
583
633
  onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
584
634
  }
585
635
 
636
+ export interface IMicroVmShapeInfo {
637
+ readonly id: string;
638
+ readonly vcpus: number;
639
+ readonly memMib: number;
640
+ }
641
+
586
642
  export interface IOciRuntimeFacts {
587
- readonly runtime: TOciRuntime;
643
+ readonly engine: 'firecracker';
644
+ readonly firecrackerVersion: string;
588
645
  readonly endpoint: string;
589
- readonly rootless: boolean;
590
646
  readonly os: 'linux';
591
647
  readonly architecture: TOciArchitecture;
592
648
  readonly helperTarget: TOciHelperTarget;
593
649
  readonly helperPath: string;
594
650
  readonly helperSha256: string;
595
- readonly workspaceBlockSize: number;
651
+ readonly initrdPath: string;
652
+ readonly kernelPath: string;
653
+ readonly shapes: readonly IMicroVmShapeInfo[];
596
654
  }
597
655
 
598
656
  export interface IPrepareOciLeaseContext {
@@ -607,6 +665,11 @@ export interface IPreparedOciLease {
607
665
  readonly attemptId: string;
608
666
  readonly image: string;
609
667
  readonly imageArchitecture: TOciArchitecture;
668
+ readonly rootfsPath?: string;
669
+ readonly imageDigest?: string;
670
+ readonly shapeId?: string;
671
+ readonly defaultEnv?: Record<string, string>;
672
+ readonly defaultWorkingDir?: string;
610
673
  cleanup(): Promise<void>;
611
674
  }
612
675
 
@@ -636,6 +699,7 @@ export interface IRuntimeWorkspaceExporter {
636
699
  export interface IExecutionResult {
637
700
  exitCode: number | null;
638
701
  stopReason?: TExecutionStopReason;
702
+ producedImage?: IProducedImageManifest;
639
703
  workspace?: IRuntimeWorkspaceExporter;
640
704
  }
641
705
 
@@ -655,7 +719,7 @@ export interface IPreparedWorkspace {
655
719
 
656
720
  export interface ISourcePrepareContext {
657
721
  identity: IJobIdentity;
658
- job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
722
+ job: Pick<TExecutableRunnerJob, 'source' | 'permissions' | 'requirements'>;
659
723
  signal: AbortSignal;
660
724
  }
661
725
 
@@ -679,7 +743,7 @@ export interface ISecretRedactionSet {
679
743
 
680
744
  export interface IArtifactUploadContext {
681
745
  workspace: IRuntimeWorkspaceExporter;
682
- job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
746
+ job: Pick<IOciRunnerJob | IVmExecutableRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
683
747
  status: TJobCompletionStatus;
684
748
  redactionSet: ISecretRedactionSet;
685
749
  identity: IJobIdentity;
@@ -693,14 +757,17 @@ export interface IArtifactManager {
693
757
  export interface ICacheRestoreContext {
694
758
  workspacePath: string;
695
759
  workspaceEntryCount: number;
696
- job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
760
+ job: Pick<
761
+ IOciRunnerJob | IVmExecutableRunnerJob,
762
+ 'caches' | 'permissions' | 'requirements' | 'source'
763
+ >;
697
764
  identity: IJobIdentity;
698
765
  signal: AbortSignal;
699
766
  }
700
767
 
701
768
  export interface ICacheSaveContext {
702
769
  workspace: IRuntimeWorkspaceExporter;
703
- job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
770
+ job: Pick<IOciRunnerJob | IVmExecutableRunnerJob, 'caches' | 'permissions' | 'requirements'>;
704
771
  status: TJobCompletionStatus;
705
772
  redactionSet: ISecretRedactionSet;
706
773
  identity: IJobIdentity;