@ship.zone/runner 0.2.4 → 1.1.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.
package/dist_npm/mod.d.ts CHANGED
@@ -83,19 +83,27 @@ export declare class LeaseLostError extends CoordinatorError { constructor(messa
83
83
  }
84
84
  export declare class ProtocolError extends CoordinatorError { constructor(message: string, options?: ErrorOptions);
85
85
  }
86
+ /**
87
+ * An archive prepared for publication contains a member of the attempt's redaction set in an entry
88
+ * path, a link target, or file content. The archive is never published.
89
+ */
90
+ export declare class SecretDisclosureError extends RunnerError { constructor(message?: string);
91
+ }
86
92
  export declare const runnerVersion: string;
87
- export declare const runnerProtocolIdentifier: 'foss-ci-runner/2.0-draft.2';
88
- export type TRunnerProtocolIdentifier = typeof runnerProtocolIdentifier;
89
- export type TExecutionProfile = 'oci.v1';
90
- export type TRunnerFeature = 'source.tar-gz' | 'artifacts.v1' | 'caches.v1';
91
- export type TJobNetwork = 'none' | 'bridge';
93
+ export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
94
+ export type TIsolation = 'container' | 'microvm';
95
+ export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
96
+ export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
97
+ export type TNetworkMode = 'none' | 'egress';
92
98
  export type TSourceFormat = 'tar.gz';
93
99
  export type TOciRuntime = 'docker' | 'podman';
94
100
  export type TArtifactPermission = 'none' | 'write';
95
101
  export type TCachePermission = 'none' | 'read' | 'read-write';
102
+ export type TImagePermission = 'none' | 'push';
96
103
  export type TCacheAccess = 'read' | 'read-write';
97
104
  export type TArtifactWhen = 'always' | 'success' | 'failure';
98
105
  export type TLogStream = 'stdout' | 'stderr' | 'runner';
106
+ export type TImageGrantAccess = 'pull' | 'push';
99
107
  export type TJobCompletionStatus = 'succeeded' | 'failed' | 'canceled' | 'timed_out' | 'system_error';
100
108
  export type TCancellationReason = 'user_requested' | 'superseded' | 'policy' | 'coordinator_shutdown';
101
109
  export type TAbandonReason = 'runner_shutdown' | 'runner_error';
@@ -110,8 +118,8 @@ export interface IProtocolLimits { maximumJsonBytes: number;
110
118
  minimumLeaseSeconds: number;
111
119
  maximumLeaseSeconds: number;
112
120
  }
113
- export interface IDiscoveryResponse { protocol: TRunnerProtocolIdentifier;
114
- basePath: '/api/runner/v2';
121
+ export interface IDiscoveryResponse { spec: string;
122
+ basePath: '/api/runner';
115
123
  status: 'draft';
116
124
  serverTime: string;
117
125
  limits: IProtocolLimits;
@@ -138,32 +146,45 @@ export interface ITransferLimits { maximumSourceArchiveBytes: number;
138
146
  maximumWorkspaceBytes: number;
139
147
  maximumWorkspaceEntries: number;
140
148
  }
149
+ export interface IResourceLimits { maximumMemoryBytes: number;
150
+ maximumCpus: number;
151
+ maximumPids: number;
152
+ maximumSharedMemoryBytes: number;
153
+ }
141
154
  export interface IRunnerCapabilities { executionProfiles: TExecutionProfile[];
155
+ isolation: TIsolation[];
156
+ platforms: string[];
142
157
  labels: string[];
143
158
  features: TRunnerFeature[];
144
- networks: TJobNetwork[];
159
+ networks: TNetworkMode[];
145
160
  sourceFormats: TSourceFormat[];
146
161
  limits: ITransferLimits;
162
+ /** Defined from specification 1.1.0 on. */
163
+ resources?: IResourceLimits;
164
+ /** Defined from specification 1.2.0 on: the lease contents the runner uses. */
165
+ leaseFeatures?: TLeaseFeature[];
166
+ /** Defined from specification 1.2.0 on: the largest job `timeoutMs` the runner executes. */
167
+ maximumTimeoutMs?: number;
147
168
  }
148
169
  export interface IRegisterRunnerRequest { registrationRequestId: string;
149
- protocol: TRunnerProtocolIdentifier;
170
+ spec: string;
150
171
  runnerVersion: string;
151
172
  name: string;
152
173
  capabilities: IRunnerCapabilities;
153
174
  }
154
- export interface IRegisterRunnerResponse { protocol: TRunnerProtocolIdentifier;
175
+ export interface IRegisterRunnerResponse { spec: string;
155
176
  serverTime: string;
156
177
  registrationReplayUntil: string;
157
178
  credential: IRunnerCredential;
158
179
  }
159
180
  export interface IStartSessionRequest { sessionRequestId: string;
160
181
  runnerId: string;
161
- protocol: TRunnerProtocolIdentifier;
182
+ spec: string;
162
183
  runnerVersion: string;
163
184
  capabilities: IRunnerCapabilities;
164
185
  }
165
186
  export interface IStartSessionResponse { sessionId: string;
166
- protocol: TRunnerProtocolIdentifier;
187
+ spec: string;
167
188
  serverTime: string;
168
189
  credential?: IRunnerCredential;
169
190
  }
@@ -183,12 +204,44 @@ export interface IClaimJobResponse { serverTime: string;
183
204
  retryAfterMs?: number;
184
205
  lease: unknown | null;
185
206
  }
207
+ /** Attempt-scoped registry credential for one registry, repository, and access mode. */
208
+ export interface IImageGrant { grantId: string;
209
+ access: TImageGrantAccess;
210
+ registry: string;
211
+ repository: string;
212
+ username: string;
213
+ secret: string;
214
+ expiresAt: string;
215
+ }
216
+ /** Resolution of one candidate reference of the job to a digest-pinned image. */
217
+ export interface IImageBinding { candidate: string;
218
+ image: string;
219
+ }
220
+ /** Attempt-scoped read-only npm registry token for one `npmRead` entry of the job. */
221
+ export interface INpmGrant { grantId: string;
222
+ registry: string;
223
+ scopes: string[];
224
+ secret: string;
225
+ expiresAt: string;
226
+ }
227
+ /** A lease exactly as the protocol defines it, for every execution profile. */
186
228
  export interface IJobLease { jobId: string;
187
229
  attemptId: string;
188
230
  leaseId: string;
189
231
  fencingToken: string;
190
232
  leaseExpiresAt: string;
191
- job: ICompiledRunnerJob;
233
+ job: TCompiledRunnerJob;
234
+ grants: IImageGrant[];
235
+ bindings: IImageBinding[];
236
+ npmGrants?: INpmGrant[];
237
+ }
238
+ /**
239
+ * A lease this runner executes: an `oci` job in `container` isolation with a digest-pinned image,
240
+ * no image grants or bindings, and no npm grants.
241
+ */
242
+ export interface IOciJobLease extends Omit<IJobLease, 'job' | 'grants' | 'bindings' | 'npmGrants'> { job: IOciRunnerJob;
243
+ grants: [];
244
+ bindings: [];
192
245
  }
193
246
  export interface IJobIdentity { runnerId: string;
194
247
  sessionId: string;
@@ -258,6 +311,8 @@ export interface IErrorResponse { error: { code: string;
258
311
  };
259
312
  }
260
313
  export interface IJobRequirements { executionProfile: TExecutionProfile;
314
+ isolation: TIsolation;
315
+ platform?: string;
261
316
  labels: string[];
262
317
  features: TRunnerFeature[];
263
318
  limits: ITransferLimits;
@@ -265,13 +320,42 @@ export interface IJobRequirements { executionProfile: TExecutionProfile;
265
320
  export interface IJobPermissions { source: 'read';
266
321
  artifacts: TArtifactPermission;
267
322
  caches: TCachePermission;
268
- packages: 'none';
323
+ images: TImagePermission;
269
324
  }
270
- export interface IOciExecution { profile: 'oci.v1';
271
- image: string;
272
- network: TJobNetwork;
325
+ export interface IEgressRule { host: string;
326
+ ports: number[];
327
+ }
328
+ export interface INoNetwork { mode: 'none';
329
+ }
330
+ export interface IEgressNetwork { mode: 'egress';
331
+ allow: IEgressRule[];
332
+ }
333
+ export type TJobNetwork = INoNetwork | IEgressNetwork;
334
+ export interface ICandidateReference { candidate: string;
335
+ }
336
+ export type TImageReference = string | ICandidateReference;
337
+ export interface IOciExecution { profile: 'oci';
338
+ image: TImageReference;
273
339
  workingDirectory?: string;
274
340
  }
341
+ export interface IVmExecution { profile: 'vm';
342
+ image: TImageReference;
343
+ workingDirectory?: string;
344
+ }
345
+ export interface IBuildSecret { id: string;
346
+ environment: string;
347
+ }
348
+ export interface IBaseImage { name: string;
349
+ image: TImageReference;
350
+ }
351
+ export interface IImageBuild { context: string;
352
+ dockerfile: string;
353
+ target?: string;
354
+ buildArgs: Record<string, string>;
355
+ secrets: IBuildSecret[];
356
+ labels: Record<string, string>;
357
+ baseImages: IBaseImage[];
358
+ }
275
359
  export interface ICompiledStep { name?: string;
276
360
  command: string[];
277
361
  environment: Record<string, string>;
@@ -285,6 +369,10 @@ export interface IJobSource { format: 'tar.gz';
285
369
  export interface IJobResources { memoryBytes?: number;
286
370
  cpus?: number;
287
371
  pids?: number;
372
+ sharedMemoryBytes?: number;
373
+ }
374
+ export interface INpmReadEntry { registry: string;
375
+ scopes: string[];
288
376
  }
289
377
  export interface IArtifactDeclaration { name: string;
290
378
  path: string;
@@ -296,30 +384,56 @@ export interface IArtifactDeclaration { name: string;
296
384
  maximumEntries: number;
297
385
  retentionDays?: number;
298
386
  }
299
- export interface ICacheDeclaration { name: string;
387
+ export interface IBuildCacheDeclaration { name: string;
300
388
  key: string;
301
- paths: string[];
302
389
  access: TCacheAccess;
303
390
  maximumBytes: number;
304
391
  maximumExtractedBytes: number;
305
392
  maximumEntries: number;
306
393
  retentionDays?: number;
307
394
  }
308
- export interface ICompiledRunnerJob { specVersion: '2.0-draft.2';
395
+ export interface ICacheDeclaration extends IBuildCacheDeclaration { paths: string[];
396
+ }
397
+ interface ICompiledRunnerJobBase {
398
+ spec: string;
309
399
  sourceObjectId: string;
310
400
  workflowDigest: string;
311
401
  compiledPlanDigest: string;
312
402
  requirements: IJobRequirements;
313
403
  permissions: IJobPermissions;
314
- execution: IOciExecution;
315
- steps: ICompiledStep[];
404
+ network: TJobNetwork;
316
405
  source: IJobSource;
317
406
  secrets: Record<string, string>;
318
407
  timeoutMs: number;
319
408
  resources?: IJobResources;
409
+ npmRead?: INpmReadEntry[];
320
410
  artifacts: IArtifactDeclaration[];
411
+ }
412
+ /** A compiled `oci` job: ordered argument-array steps in fresh containers. */
413
+ export interface IContainerRunnerJob extends ICompiledRunnerJobBase { execution: IOciExecution;
414
+ steps: ICompiledStep[];
321
415
  caches: ICacheDeclaration[];
322
416
  }
417
+ /** A compiled `vm` job: ordered steps as root in one microVM guest per attempt. */
418
+ export interface IVmRunnerJob extends ICompiledRunnerJobBase { execution: IVmExecution;
419
+ steps: ICompiledStep[];
420
+ caches: ICacheDeclaration[];
421
+ }
422
+ /** A compiled `oci-image` job: one single-platform image build in a microVM guest. */
423
+ export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase { build: IImageBuild;
424
+ caches: IBuildCacheDeclaration[];
425
+ }
426
+ /** Every compiled job shape the published runner job schema admits. */
427
+ export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
428
+ /** An `oci` job this runner executes: container isolation, no network, a digest-pinned image. */
429
+ export interface IOciRunnerJob extends IContainerRunnerJob { requirements: IJobRequirements & { executionProfile: 'oci';
430
+ isolation: 'container';
431
+ };
432
+ network: INoNetwork;
433
+ execution: IOciExecution & {
434
+ image: string;
435
+ };
436
+ }
323
437
  export interface ITransferMetadata { sha256: string;
324
438
  sizeBytes: number;
325
439
  extractedSizeBytes: number;
@@ -357,7 +471,7 @@ export interface IOciExecutorConfig { runtime: TOciRuntime;
357
471
  runtimePath: string;
358
472
  workspaceHelperPath?: string;
359
473
  requireRootless: boolean;
360
- allowedNetworks: TJobNetwork[];
474
+ allowedNetworks: TNetworkMode[];
361
475
  containerUser: string;
362
476
  defaultTimeoutMs: number;
363
477
  maximumTimeoutMs: number;
@@ -367,6 +481,8 @@ export interface IOciExecutorConfig { runtime: TOciRuntime;
367
481
  maximumCpus: number;
368
482
  defaultPids: number;
369
483
  maximumPids: number;
484
+ defaultSharedMemoryBytes: number;
485
+ maximumSharedMemoryBytes: number;
370
486
  workspaceSizeBytes: number;
371
487
  temporarySizeBytes: number;
372
488
  stopTimeoutSeconds: number;
@@ -398,9 +514,14 @@ export interface IRunnerConfig extends ITransferManagerConfig { controlPlaneUrl:
398
514
  }
399
515
  export interface IExecutionContext { runnerId: string;
400
516
  sessionId: string;
401
- lease: IJobLease;
517
+ lease: IOciJobLease;
402
518
  preparedLease: IPreparedOciLease;
403
519
  workspacePath: string;
520
+ /**
521
+ * Milliseconds left until the attempt deadline when execution starts: the job `timeoutMs`
522
+ * counted from the acceptance 204, less the time source extraction and cache restoration took.
523
+ */
524
+ timeoutMs: number;
404
525
  signal: AbortSignal;
405
526
  terminationDeadline?: () => number | undefined;
406
527
  onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
@@ -417,7 +538,7 @@ export interface IOciRuntimeFacts { readonly runtime: TOciRuntime;
417
538
  }
418
539
  export interface IPrepareOciLeaseContext { runnerId: string;
419
540
  sessionId: string;
420
- lease: IJobLease;
541
+ lease: IOciJobLease;
421
542
  signal: AbortSignal;
422
543
  }
423
544
  export interface IPreparedOciLease { readonly preparationId: string;
@@ -456,15 +577,24 @@ export interface IPreparedWorkspace { path: string;
456
577
  cleanup(): Promise<void>;
457
578
  }
458
579
  export interface ISourcePrepareContext { identity: IJobIdentity;
459
- job: Pick<ICompiledRunnerJob, 'source' | 'permissions' | 'requirements'>;
580
+ job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
460
581
  signal: AbortSignal;
461
582
  }
462
583
  export interface IRunnerRunResult { claimed: boolean;
463
584
  status?: TJobCompletionStatus;
464
585
  }
586
+ /** A streaming check of bytes against the attempt's redaction set. */
587
+ export interface ISecretContentMatcher { /** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */ push(bytes: Uint8Array): boolean;
588
+ }
589
+ /** The attempt's redaction set as the archive publication check consumes it. */
590
+ export interface ISecretRedactionSet { readonly empty: boolean;
591
+ occursIn(text: string): boolean;
592
+ createContentMatcher(): ISecretContentMatcher;
593
+ }
465
594
  export interface IArtifactUploadContext { workspace: IRuntimeWorkspaceExporter;
466
- job: Pick<ICompiledRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
595
+ job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
467
596
  status: TJobCompletionStatus;
597
+ redactionSet: ISecretRedactionSet;
468
598
  identity: IJobIdentity;
469
599
  signal: AbortSignal;
470
600
  }
@@ -472,19 +602,21 @@ export interface IArtifactManager { upload(context: IArtifactUploadContext): Pro
472
602
  }
473
603
  export interface ICacheRestoreContext { workspacePath: string;
474
604
  workspaceEntryCount: number;
475
- job: Pick<ICompiledRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
605
+ job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
476
606
  identity: IJobIdentity;
477
607
  signal: AbortSignal;
478
608
  }
479
609
  export interface ICacheSaveContext { workspace: IRuntimeWorkspaceExporter;
480
- job: Pick<ICompiledRunnerJob, 'caches' | 'permissions' | 'requirements'>;
610
+ job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
481
611
  status: TJobCompletionStatus;
612
+ redactionSet: ISecretRedactionSet;
482
613
  identity: IJobIdentity;
483
614
  signal: AbortSignal;
484
615
  }
485
616
  export interface ICacheManager { restore(context: ICacheRestoreContext): Promise<void>;
486
617
  save(context: ICacheSaveContext): Promise<void>;
487
618
  }
619
+ export {};
488
620
  export interface ILogApi { appendLog(chunk: ILogChunk, signal?: AbortSignal): Promise<ILogAcknowledgement>;
489
621
  }
490
622
  export declare class LogSender { private readonly api;
@@ -493,13 +625,14 @@ export declare class LogSender { private readonly api;
493
625
  private readonly maximumChunkBytes;
494
626
  private readonly signal?;
495
627
  private readonly redactors;
628
+ private readonly sequenceRedactor;
496
629
  private sequence;
497
630
  private sentBytes;
498
631
  private operationQueue;
499
632
  private terminalError;
500
633
  private observationSequence;
501
634
  private readonly lastObservation;
502
- constructor(api: ILogApi, identity: IJobIdentity, secrets: Iterable<string>, maximumBytes: number, maximumChunkBytes: number, signal?: AbortSignal | undefined);
635
+ constructor(api: ILogApi, identity: IJobIdentity, redactionSet: SecretRedactionSet, maximumBytes: number, maximumChunkBytes: number, signal?: AbortSignal | undefined);
503
636
  write(stream: 'stdout' | 'stderr', rawData: string): Promise<void>;
504
637
  writeRunnerMessage(data: string): Promise<void>;
505
638
  flush(): Promise<void>;
@@ -568,7 +701,7 @@ export interface IOciRunCommand { args: string[];
568
701
  }
569
702
  export interface IOciStepCommandInput { runnerId: string;
570
703
  sessionId: string;
571
- lease: IJobLease;
704
+ lease: IOciJobLease;
572
705
  step: ICompiledStep;
573
706
  containerName: string;
574
707
  volumeName: string;
@@ -645,22 +778,108 @@ export declare const copyOciConfig: (config: IOciExecutorConfig) => IOciExecutor
645
778
  export declare const canonicalizeJson: (value: unknown) => string;
646
779
  export declare const projectCompiledPlan: (job: unknown) => TJsonObject;
647
780
  export declare const computeCompiledPlanDigest: (job: unknown) => Promise<string>;
781
+ /** A leased job this runner does not execute; it is refused as `runner_error` before acceptance. */
782
+ export declare class UnsupportedJobError extends ProtocolError { constructor(message: string);
783
+ }
784
+ /**
785
+ * Validates capabilities against the published `RunnerCapabilities` schema and returns an
786
+ * immutable copy, the snapshot every lease is checked against.
787
+ */
648
788
  export declare const createRunnerCapabilitySnapshot: (capabilities: IRunnerCapabilities) => IRunnerCapabilities;
649
- export declare const validateCapabilityFit: (job: ICompiledRunnerJob, capabilities: IRunnerCapabilities) => void;
650
- export declare class RunnerProtocolValidator { private readonly capabilities;
651
- constructor(capabilities: IRunnerCapabilities);
652
- validateJob(jobUnknown: unknown): Promise<ICompiledRunnerJob>;
789
+ /**
790
+ * Narrows a coherent lease to the one shape this runner executes and refuses every other shape:
791
+ * the `vm` and `oci-image` profiles, `microvm` isolation, egress networking, candidate images and
792
+ * image grants, and npm read grants.
793
+ */
794
+ export declare const requireExecutableLease: (lease: IJobLease) => IOciJobLease;
795
+ export declare const validateCapabilityFit: (job: TCompiledRunnerJob, capabilities: IRunnerCapabilities) => void;
796
+ export declare class RunnerProtocolValidator { private readonly implementedSpec;
797
+ private readonly capabilities;
798
+ constructor(capabilities: IRunnerCapabilities, implementedSpec?: string);
799
+ /**
800
+ * Validates a compiled job: the published schema, the specification version acceptance rule,
801
+ * the compiled plan digest, internal coherence, and fit against the capability snapshot.
802
+ */
803
+ validateJob(jobUnknown: unknown): Promise<TCompiledRunnerJob>;
804
+ /**
805
+ * Validates a lease against the published `JobLease` schema, its job, lease coherence, and the
806
+ * lease features of the capability snapshot.
807
+ */
653
808
  validateJobLease(leaseUnknown: unknown): Promise<IJobLease>;
809
+ /** Validates a lease and narrows it to the `oci` shape this runner executes. */
810
+ validateExecutableLease(leaseUnknown: unknown): Promise<IOciJobLease>;
654
811
  }
655
812
  export declare const validateJobLease: (leaseUnknown: unknown, capabilities: IRunnerCapabilities) => Promise<IJobLease>;
656
- export declare class StreamingSecretRedactor { private readonly secrets;
657
- private readonly maximumSecretLength;
813
+ /** Redaction set members shorter than this many UTF-8 bytes are left out by the protocol. */
814
+ export declare const minimumRedactionMemberBytes = 8;
815
+ /** The secret-bearing values of one lease: job secret values and npm grant tokens. */
816
+ export interface IRedactionSource { job: { secrets: Readonly<Record<string, string>>;
817
+ };
818
+ npmGrants?: readonly {
819
+ secret: string;
820
+ }[];
821
+ }
822
+ /**
823
+ * The redaction set of an attempt: every secret value, every npm grant token, and each line of a
824
+ * multi-line value, leaving out members shorter than eight UTF-8 bytes.
825
+ */
826
+ export declare class SecretRedactionSet implements ISecretRedactionSet { readonly members: readonly string[];
827
+ private readonly membersByFirstCodeUnit;
828
+ private readonly memberBytes;
829
+ constructor(values: Iterable<string>);
830
+ static forLease(source: IRedactionSource): SecretRedactionSet;
831
+ get empty(): boolean;
832
+ /** The longest member in UTF-16 code units, the look-ahead a streaming redactor retains. */
833
+ get maximumMemberLength(): number;
834
+ /** The longest member at `index` of `text`, when one starts there. */
835
+ memberAt(text: string, index: number): string | undefined;
836
+ /** Whether any member occurs in `text`. */
837
+ occursIn(text: string): boolean;
838
+ /** A streaming matcher over bytes that reports whether any member occurs in them. */
839
+ createContentMatcher(): SecretContentMatcher;
840
+ }
841
+ /**
842
+ * Aho-Corasick matcher over the UTF-8 bytes of the redaction set. It is fed a byte stream in
843
+ * arbitrary chunks and detects members that span chunk boundaries. Transitions live in one map
844
+ * keyed by `state * 256 + byte`, so memory stays proportional to the total member bytes.
845
+ */
846
+ export declare class SecretContentMatcher implements ISecretContentMatcher { private readonly transitions;
847
+ private readonly failure;
848
+ private readonly terminal;
849
+ private state;
850
+ private matched;
851
+ constructor(members: readonly Uint8Array[]);
852
+ /** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */
853
+ push(bytes: Uint8Array): boolean;
854
+ get found(): boolean;
855
+ }
856
+ /**
857
+ * Replaces every member occurring in one text stream with `***`, retaining just enough look-ahead
858
+ * to catch members split across writes.
859
+ */
860
+ export declare class StreamingSecretRedactor { private readonly redactionSet;
658
861
  private buffer;
659
- constructor(secrets: Iterable<string>);
862
+ constructor(redactionSet: SecretRedactionSet);
660
863
  push(chunk: string): string;
661
864
  flush(): string;
662
865
  private consume;
663
866
  }
867
+ export interface IRedactedLogSegment { stream: TLogStream;
868
+ data: string;
869
+ }
870
+ /**
871
+ * Redacts the attempt's log output in emission order across all streams, so that no log chunk and
872
+ * no concatenation of consecutive chunks contains a member. A replacement spanning streams is
873
+ * attributed to the stream in which the member started.
874
+ */
875
+ export declare class LogSequenceRedactor { private readonly redactionSet;
876
+ private text;
877
+ private streams;
878
+ constructor(redactionSet: SecretRedactionSet);
879
+ push(stream: TLogStream, data: string): IRedactedLogSegment[];
880
+ flush(): IRedactedLogSegment[];
881
+ private consume;
882
+ }
664
883
  export interface IRunnerCoordinatorClient { discover(signal?: AbortSignal): Promise<IDiscoveryResponse>;
665
884
  setRunnerToken(token: string): void;
666
885
  startSession(request: IStartSessionRequest, signal?: AbortSignal): Promise<IStartSessionResponse>;
@@ -683,15 +902,29 @@ export interface IRunnerDependencies { api: IRunnerCoordinatorClient;
683
902
  onCredential?: (credential: IRunnerCredential) => Promise<void>;
684
903
  onMessage?: (message: string) => void;
685
904
  now?: () => number;
905
+ /** Monotonic milliseconds that measure the attempt deadline; `performance.now` by default. */
906
+ monotonicNow?: () => number;
686
907
  sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
687
908
  }
688
- export declare const runnerCapabilities: (config: IRunnerConfig) => IRunnerCapabilities;
909
+ /**
910
+ * The capabilities this runner advertises: the `oci` profile in `container` isolation on the
911
+ * native linux platform of its verified OCI engine, the `none` network mode, the configured
912
+ * transfer limits, the resource ceilings it enforces per attempt, no lease features (it uses no
913
+ * image grants, candidate bindings, or npm read grants), and its configured longest job timeout.
914
+ */
915
+ export declare const runnerCapabilities: (config: IRunnerConfig, runtime: Pick<IOciRuntimeFacts, "os" | "architecture">) => IRunnerCapabilities;
916
+ /**
917
+ * Restricts capabilities to the constructs defined at the lower of the coordinator and runner
918
+ * specification versions, the version every non-job message may use.
919
+ */
920
+ export declare const capabilitiesForCoordinator: (capabilities: IRunnerCapabilities, discovery: Pick<IDiscoveryResponse, "spec">) => IRunnerCapabilities;
689
921
  export declare const reconcileProtocolLimits: (config: IRunnerConfig, discovery: IDiscoveryResponse, capabilities: IRunnerCapabilities) => void;
690
922
  export declare class ShipRunner { private readonly config;
691
923
  private readonly dependencies;
692
924
  private drainRequested;
693
925
  private sessionInvalid;
694
926
  private readonly now;
927
+ private readonly monotonicNow;
695
928
  private readonly sleep;
696
929
  constructor(config: IRunnerConfig, dependencies: IRunnerDependencies);
697
930
  run(options?: {
@@ -715,4 +948,29 @@ export declare class SourceWorkspaceManager { private readonly config;
715
948
  constructor(config: ITransferManagerConfig, api: ISourceApiClient);
716
949
  prepare(context: ISourcePrepareContext): Promise<IPreparedWorkspace>;
717
950
  }
951
+ /**
952
+ * Outcome of the specification version acceptance rule of the runner protocol: a declared
953
+ * version is accepted when it is canonical, has the implemented major version, and is not newer.
954
+ */
955
+ export type TSpecAcceptance = 'accepted' | 'malformed' | 'major-mismatch' | 'newer';
956
+ /** The specification version this runner implements: the ci-spec package it is built against. */
957
+ export declare const runnerSpecVersion: string;
958
+ /** Applies the acceptance rule of an implementation of version `implemented` to `declared`. */
959
+ export declare const acceptSpecVersion: (implemented: string, declared: unknown) => TSpecAcceptance;
960
+ /** Returns whether two canonical versions share a major version, the coordinator session rule. */
961
+ export declare const specMajorVersionsMatch: (left: string, right: string) => boolean;
962
+ /** Compares two canonical specification versions numerically. */
963
+ export declare const compareSpecVersions: (left: string, right: string) => number;
964
+ /** The lower of two canonical versions: the version whose constructs a message may use. */
965
+ export declare const lowerSpecVersion: (left: string, right: string) => string;
718
966
  export declare const scavengeRunnerStaging: (stateDirectory: string) => Promise<void>;
967
+ /** OpenAPI component schemas of the published runner protocol that this runner validates. */
968
+ export declare const wireSchemaNames: readonly ["AbandonJobRequest", "AcceptJobRequest", "ClaimJobRequest", "ClaimJobResponse", "CompleteJobRequest", "CompleteJobResponse", "DiscoveryResponse", "ErrorResponse", "ImageBinding", "ImageGrant", "ImageRecord", "JobHeartbeatRequest", "JobHeartbeatResponse", "JobLease", "LogAcknowledgement", "LogChunk", "NpmGrant", "RecordImageRequest", "RecoverAttemptRequest", "RegisterRunnerRequest", "RegisterRunnerResponse", "RunnerCapabilities", "RunnerHeartbeatRequest", "RunnerHeartbeatResponse", "StartSessionRequest", "StartSessionResponse", "TransferRecord"];
969
+ export type TWireSchemaName = (typeof wireSchemaNames)[number];
970
+ export declare const isWireSchemaName: (value: unknown) => value is TWireSchemaName;
971
+ /** Returns whether a value is valid against one published runner protocol component. */
972
+ export declare const isValidWireMessage: (name: TWireSchemaName, value: unknown) => boolean;
973
+ /** Validates a value against one published runner protocol component and returns it typed. */
974
+ export declare const validateWireMessage: <T>(name: TWireSchemaName, value: unknown) => T;
975
+ /** Validates a compiled runner job against the published runner job schema. */
976
+ export declare const validateCompiledJobSchema: <T>(value: unknown) => T;