@ship.zone/runner 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 (179) hide show
  1. package/.smartconfig.json +99 -2
  2. package/changelog.md +58 -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 -22
  141. package/readme.md +91 -40
  142. package/rust/.cargo/config.toml +1 -1
  143. package/rust/Cargo.toml +1 -1
  144. package/rust/src/lib.rs +156 -1
  145. package/rust/src/main.rs +1 -1
  146. package/rust-toolchain.toml +4 -0
  147. package/ts/00_commitinfo_data.ts +1 -1
  148. package/ts/api-client.ts +10 -7
  149. package/ts/artifact-manager.ts +9 -7
  150. package/ts/attempt-state.ts +75 -84
  151. package/ts/cache-manager.ts +22 -28
  152. package/ts/cli-entry.ts +4 -0
  153. package/ts/cli.ts +56 -45
  154. package/ts/config.ts +50 -39
  155. package/ts/errors.ts +19 -0
  156. package/ts/filesystem.ts +316 -0
  157. package/ts/index.ts +16 -15
  158. package/ts/interfaces.ts +2 -2
  159. package/ts/log-sender.ts +4 -4
  160. package/ts/oci-executor.ts +235 -383
  161. package/ts/plugins.ts +21 -3
  162. package/ts/protocol-validator.ts +5 -5
  163. package/ts/redactor.ts +2 -2
  164. package/ts/registration-state.ts +82 -90
  165. package/ts/runner.ts +30 -17
  166. package/ts/source-workspace.ts +11 -8
  167. package/ts/spec-version.ts +2 -2
  168. package/ts/staging-scavenger.ts +37 -26
  169. package/ts/state-owner.ts +346 -0
  170. package/ts/transfer-archive.ts +214 -243
  171. package/ts/validation.ts +1 -1
  172. package/ts/wire-schema.ts +3 -3
  173. package/deno.json +0 -56
  174. package/deno.lock +0 -1495
  175. package/dist_npm/mod.d.ts +0 -967
  176. package/dist_npm/mod.js +0 -10058
  177. package/mod.ts +0 -8
  178. package/musl-copyright.md +0 -81
  179. package/third-party-licenses.md +0 -187
package/dist_npm/mod.d.ts DELETED
@@ -1,967 +0,0 @@
1
- #!/usr/bin/env -S deno run --allow-all
2
- export type TRunnerFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
3
- export interface IRunnerApiClientOptions { controlPlaneUrl: string;
4
- allowInsecureLoopback: boolean;
5
- requestTimeoutMs: number;
6
- sourceTransferTimeoutMs?: number;
7
- artifactUploadTimeoutMs?: number;
8
- cacheTransferTimeoutMs?: number;
9
- maximumResponseBytes: number;
10
- runnerToken?: string;
11
- fetch?: TRunnerFetch;
12
- sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
13
- }
14
- export declare class RunnerApiClient { private readonly options;
15
- private readonly origin;
16
- private readonly baseUrl;
17
- private readonly fetchImplementation;
18
- private readonly sleep;
19
- private runnerToken?;
20
- constructor(options: IRunnerApiClientOptions);
21
- setRunnerToken(token: string): void;
22
- discover(signal?: AbortSignal): Promise<IDiscoveryResponse>;
23
- register(request: IRegisterRunnerRequest, bootstrapToken: string, signal?: AbortSignal): Promise<IRegisterRunnerResponse>;
24
- startSession(request: IStartSessionRequest, signal?: AbortSignal): Promise<IStartSessionResponse>;
25
- heartbeatRunner(request: IRunnerHeartbeatRequest, signal?: AbortSignal): Promise<IRunnerHeartbeatResponse>;
26
- claimJob(request: IClaimJobRequest, signal?: AbortSignal): Promise<IClaimJobResponse>;
27
- acceptJob(request: IAcceptJobRequest, signal?: AbortSignal): Promise<void>;
28
- heartbeatJob(request: IJobHeartbeatRequest, signal?: AbortSignal): Promise<IJobHeartbeatResponse>;
29
- appendLog(chunk: ILogChunk, signal?: AbortSignal): Promise<ILogAcknowledgement>;
30
- completeJob(request: ICompleteJobRequest, signal?: AbortSignal): Promise<ICompleteJobResponse>;
31
- abandonJob(request: IAbandonJobRequest, signal?: AbortSignal): Promise<void>;
32
- recoverAttempt(request: IRecoverAttemptRequest, signal?: AbortSignal): Promise<void>;
33
- downloadSource(identity: IJobIdentity, source: IJobSource, signal?: AbortSignal): Promise<ITransferDownload>;
34
- downloadCache(identity: IJobIdentity, name: string, signal?: AbortSignal): Promise<TCacheDownload>;
35
- uploadArtifact(identity: IJobIdentity, name: string, transferRequestId: string, metadata: ITransferMetadata, openBody: TOpenTransferBody, signal?: AbortSignal): Promise<ITransferRecord>;
36
- uploadCache(identity: IJobIdentity, name: string, transferRequestId: string, metadata: ITransferMetadata, openBody: TOpenTransferBody, signal?: AbortSignal): Promise<ITransferRecord>;
37
- private requireRunnerToken;
38
- private jobPath;
39
- private requestJson;
40
- private fetchTransfer;
41
- private uploadTransfer;
42
- private parseTransferDownload;
43
- private throwResponseError;
44
- }
45
- export interface IArtifactApiClient { uploadArtifact(identity: IJobIdentity, name: string, transferRequestId: string, metadata: ITransferMetadata, openBody: TOpenTransferBody, signal?: AbortSignal): Promise<ITransferRecord>;
46
- }
47
- export declare class ArtifactManager implements IArtifactManager { private readonly config;
48
- private readonly api;
49
- private readonly onMessage?;
50
- constructor(config: ITransferManagerConfig, api: IArtifactApiClient, onMessage?: ((message: string) => void) | undefined);
51
- upload(context: IArtifactUploadContext): Promise<void>;
52
- }
53
- export interface ICacheApiClient { downloadCache(identity: IJobIdentity, name: string, signal?: AbortSignal): Promise<TCacheDownload>;
54
- uploadCache(identity: IJobIdentity, name: string, transferRequestId: string, metadata: ITransferMetadata, openBody: TOpenTransferBody, signal?: AbortSignal): Promise<ITransferRecord>;
55
- }
56
- export declare class CacheManager implements ICacheManager { private readonly config;
57
- private readonly api;
58
- private readonly onMessage?;
59
- constructor(config: ITransferManagerConfig, api: ICacheApiClient, onMessage?: ((message: string) => void) | undefined);
60
- restore(context: ICacheRestoreContext): Promise<void>;
61
- save(context: ICacheSaveContext): Promise<void>;
62
- }
63
- export declare const defaultRunnerConfig: () => IRunnerConfig;
64
- export declare const parseRunnerConfig: (input: unknown) => IRunnerConfig;
65
- export declare const validateRunnerConfig: (config: IRunnerConfig) => void;
66
- export declare const loadRunnerConfig: (path: string) => Promise<IRunnerConfig>;
67
- export declare const saveRunnerConfig: (path: string, config: IRunnerConfig) => Promise<void>;
68
- export declare const withRunnerCredential: (config: IRunnerConfig, credential: IRunnerCredential) => IRunnerConfig;
69
- export declare const maskRunnerConfig: (config: IRunnerConfig) => Record<string, unknown>;
70
- export declare class RunnerError extends Error { constructor(message: string, options?: ErrorOptions);
71
- }
72
- export declare class ResourceCleanupError extends RunnerError { readonly errors: readonly unknown[];
73
- constructor(message: string, errors: readonly unknown[]);
74
- }
75
- export declare class ConfigurationError extends RunnerError { constructor(message: string);
76
- }
77
- export declare class CoordinatorError extends RunnerError { readonly status?: number | undefined;
78
- constructor(message: string, status?: number | undefined, options?: ErrorOptions);
79
- }
80
- export declare class AuthenticationError extends CoordinatorError { constructor(message?: string);
81
- }
82
- export declare class LeaseLostError extends CoordinatorError { constructor(message?: string);
83
- }
84
- export declare class ProtocolError extends CoordinatorError { constructor(message: string, options?: ErrorOptions);
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
- }
92
- export declare const runnerVersion: string;
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';
98
- export type TSourceFormat = 'tar.gz';
99
- export type TOciRuntime = 'docker' | 'podman';
100
- export type TArtifactPermission = 'none' | 'write';
101
- export type TCachePermission = 'none' | 'read' | 'read-write';
102
- export type TImagePermission = 'none' | 'push';
103
- export type TCacheAccess = 'read' | 'read-write';
104
- export type TArtifactWhen = 'always' | 'success' | 'failure';
105
- export type TLogStream = 'stdout' | 'stderr' | 'runner';
106
- export type TImageGrantAccess = 'pull' | 'push';
107
- export type TJobCompletionStatus = 'succeeded' | 'failed' | 'canceled' | 'timed_out' | 'system_error';
108
- export type TCancellationReason = 'user_requested' | 'superseded' | 'policy' | 'coordinator_shutdown';
109
- export type TAbandonReason = 'runner_shutdown' | 'runner_error';
110
- export type TJsonPrimitive = null | boolean | number | string;
111
- export type TJsonValue = TJsonPrimitive | TJsonValue[] | { [key: string]: TJsonValue;
112
- };
113
- export type TJsonObject = { [key: string]: TJsonValue;
114
- };
115
- export interface IProtocolLimits { maximumJsonBytes: number;
116
- maximumLogChunkBytes: number;
117
- maximumTotalLogBytes: number;
118
- minimumLeaseSeconds: number;
119
- maximumLeaseSeconds: number;
120
- }
121
- export interface IDiscoveryResponse { spec: string;
122
- basePath: '/api/runner';
123
- status: 'draft';
124
- serverTime: string;
125
- limits: IProtocolLimits;
126
- }
127
- export interface IRunnerCredential { credentialId: string;
128
- runnerId: string;
129
- token: string;
130
- expiresAt: string;
131
- previousCredentialValidUntil?: string;
132
- }
133
- export interface ITransferLimits { maximumSourceArchiveBytes: number;
134
- maximumSourceExtractedBytes: number;
135
- maximumSourceEntries: number;
136
- maximumArtifactArchiveBytes: number;
137
- maximumArtifactExtractedBytes: number;
138
- maximumArtifactEntries: number;
139
- maximumArtifacts: number;
140
- maximumCacheArchiveBytes: number;
141
- maximumCacheExtractedBytes: number;
142
- maximumCacheEntries: number;
143
- maximumCaches: number;
144
- maximumLogChunkBytes: number;
145
- maximumTotalLogBytes: number;
146
- maximumWorkspaceBytes: number;
147
- maximumWorkspaceEntries: number;
148
- }
149
- export interface IResourceLimits { maximumMemoryBytes: number;
150
- maximumCpus: number;
151
- maximumPids: number;
152
- maximumSharedMemoryBytes: number;
153
- }
154
- export interface IRunnerCapabilities { executionProfiles: TExecutionProfile[];
155
- isolation: TIsolation[];
156
- platforms: string[];
157
- labels: string[];
158
- features: TRunnerFeature[];
159
- networks: TNetworkMode[];
160
- sourceFormats: TSourceFormat[];
161
- limits: ITransferLimits;
162
- /** The largest resource ceilings the runner enforces per attempt. */
163
- resources?: IResourceLimits;
164
- /** The lease contents the runner uses. */
165
- leaseFeatures?: TLeaseFeature[];
166
- /** The largest job `timeoutMs` the runner executes. */
167
- maximumTimeoutMs?: number;
168
- }
169
- export interface IRegisterRunnerRequest { registrationRequestId: string;
170
- spec: string;
171
- runnerVersion: string;
172
- name: string;
173
- capabilities: IRunnerCapabilities;
174
- }
175
- export interface IRegisterRunnerResponse { spec: string;
176
- serverTime: string;
177
- registrationReplayUntil: string;
178
- credential: IRunnerCredential;
179
- }
180
- export interface IStartSessionRequest { sessionRequestId: string;
181
- runnerId: string;
182
- spec: string;
183
- runnerVersion: string;
184
- capabilities: IRunnerCapabilities;
185
- }
186
- export interface IStartSessionResponse { sessionId: string;
187
- spec: string;
188
- serverTime: string;
189
- credential?: IRunnerCredential;
190
- }
191
- export interface IRunnerHeartbeatRequest { runnerId: string;
192
- sessionId: string;
193
- }
194
- export interface IRunnerHeartbeatResponse { serverTime: string;
195
- drainRequested: boolean;
196
- credential?: IRunnerCredential;
197
- }
198
- export interface IClaimJobRequest { claimRequestId: string;
199
- runnerId: string;
200
- sessionId: string;
201
- capabilities: IRunnerCapabilities;
202
- }
203
- export interface IClaimJobResponse { serverTime: string;
204
- retryAfterMs?: number;
205
- lease: unknown | null;
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. */
228
- export interface IJobLease { jobId: string;
229
- attemptId: string;
230
- leaseId: string;
231
- fencingToken: string;
232
- leaseExpiresAt: string;
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: [];
245
- }
246
- export interface IJobIdentity { runnerId: string;
247
- sessionId: string;
248
- jobId: string;
249
- attemptId: string;
250
- leaseId: string;
251
- fencingToken: string;
252
- }
253
- export interface IAcceptJobRequest { acceptRequestId: string;
254
- identity: IJobIdentity;
255
- }
256
- export interface IJobHeartbeatRequest { identity: IJobIdentity;
257
- observedCancellationRequestId?: string;
258
- }
259
- export interface ICancellationDirective { requestId: string;
260
- requestedAt: string;
261
- reason: TCancellationReason;
262
- terminateBy: string;
263
- }
264
- export interface IJobHeartbeatResponse { serverTime: string;
265
- leaseExpiresAt: string;
266
- cancellation?: ICancellationDirective;
267
- }
268
- export interface ILogChunk { identity: IJobIdentity;
269
- sequence: number;
270
- stream: TLogStream;
271
- data: string;
272
- timestamp: string;
273
- }
274
- export interface ILogAcknowledgement { serverTime: string;
275
- nextSequence: number;
276
- }
277
- export interface ICompleteJobRequest { completionRequestId: string;
278
- identity: IJobIdentity;
279
- status: TJobCompletionStatus;
280
- exitCode: number | null;
281
- startedAt: string;
282
- completedAt: string;
283
- cancellationRequestId?: string;
284
- error?: string;
285
- }
286
- export interface ICompleteJobResponse { serverTime: string;
287
- accepted: true;
288
- }
289
- export interface IAbandonJobRequest { abandonRequestId: string;
290
- identity: IJobIdentity;
291
- reason: TAbandonReason;
292
- }
293
- export interface IRecoverAttemptRequest { recoveryRequestId: string;
294
- runnerId: string;
295
- currentSessionId: string;
296
- previousSessionId: string;
297
- jobId: string;
298
- attemptId: string;
299
- reason: 'runner_restarted';
300
- }
301
- export interface ITransferRecord { name: string;
302
- format: 'tar.gz';
303
- sha256: string;
304
- sizeBytes: number;
305
- extractedSizeBytes: number;
306
- entryCount: number;
307
- createdAt: string;
308
- }
309
- export interface IErrorResponse { error: { code: string;
310
- message: string;
311
- };
312
- }
313
- export interface IJobRequirements { executionProfile: TExecutionProfile;
314
- isolation: TIsolation;
315
- platform?: string;
316
- labels: string[];
317
- features: TRunnerFeature[];
318
- limits: ITransferLimits;
319
- }
320
- export interface IJobPermissions { source: 'read';
321
- artifacts: TArtifactPermission;
322
- caches: TCachePermission;
323
- images: TImagePermission;
324
- }
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;
339
- workingDirectory?: string;
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
- }
359
- export interface ICompiledStep { name?: string;
360
- command: string[];
361
- environment: Record<string, string>;
362
- }
363
- export interface IJobSource { format: 'tar.gz';
364
- sha256: string;
365
- sizeBytes: number;
366
- extractedSizeBytes: number;
367
- entryCount: number;
368
- }
369
- export interface IJobResources { memoryBytes?: number;
370
- cpus?: number;
371
- pids?: number;
372
- sharedMemoryBytes?: number;
373
- }
374
- export interface INpmReadEntry { registry: string;
375
- scopes: string[];
376
- }
377
- export interface IArtifactDeclaration { name: string;
378
- path: string;
379
- format: 'tar.gz';
380
- when: TArtifactWhen;
381
- required: boolean;
382
- maximumBytes: number;
383
- maximumExtractedBytes: number;
384
- maximumEntries: number;
385
- retentionDays?: number;
386
- }
387
- export interface IBuildCacheDeclaration { name: string;
388
- key: string;
389
- access: TCacheAccess;
390
- maximumBytes: number;
391
- maximumExtractedBytes: number;
392
- maximumEntries: number;
393
- retentionDays?: number;
394
- }
395
- export interface ICacheDeclaration extends IBuildCacheDeclaration { paths: string[];
396
- }
397
- interface ICompiledRunnerJobBase {
398
- spec: string;
399
- sourceObjectId: string;
400
- workflowDigest: string;
401
- compiledPlanDigest: string;
402
- requirements: IJobRequirements;
403
- permissions: IJobPermissions;
404
- network: TJobNetwork;
405
- source: IJobSource;
406
- secrets: Record<string, string>;
407
- timeoutMs: number;
408
- resources?: IJobResources;
409
- npmRead?: INpmReadEntry[];
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[];
415
- caches: ICacheDeclaration[];
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
- }
437
- export interface ITransferMetadata { sha256: string;
438
- sizeBytes: number;
439
- extractedSizeBytes: number;
440
- entryCount: number;
441
- }
442
- export interface ITransferDownload extends ITransferMetadata { body: ReadableStream<Uint8Array>;
443
- }
444
- export interface ICacheDownloadMiss { hit: false;
445
- }
446
- export interface ICacheDownloadHit extends ITransferDownload { hit: true;
447
- }
448
- export type TCacheDownload = ICacheDownloadMiss | ICacheDownloadHit;
449
- export type TOpenTransferBody = () => ReadableStream<Uint8Array> | Promise<ReadableStream<Uint8Array>>;
450
- export interface ITransferManagerConfig { stateDirectory: string;
451
- transferStagingReserveBytes: number;
452
- transferStagingReserveInodes: number;
453
- maximumSourceArchiveBytes: number;
454
- maximumSourceExtractedBytes: number;
455
- maximumSourceEntries: number;
456
- maximumArtifactBytes: number;
457
- maximumArtifactExtractedBytes: number;
458
- maximumArtifactEntries: number;
459
- maximumArtifacts: number;
460
- maximumCacheArchiveBytes: number;
461
- maximumCacheExtractedBytes: number;
462
- maximumCacheEntries: number;
463
- maximumCaches: number;
464
- maximumWorkspaceEntries: number;
465
- oci: Pick<IOciExecutorConfig, 'workspaceSizeBytes'>;
466
- }
467
- export type TExecutionStopReason = 'job_canceled' | 'lease_lost' | 'lease_expired' | 'runner_shutdown' | 'job_timeout' | 'log_delivery_failed' | 'resource_limit';
468
- export type TOciArchitecture = 'amd64' | 'arm64';
469
- export type TOciHelperTarget = 'linux_amd64' | 'linux_arm64';
470
- export interface IOciExecutorConfig { runtime: TOciRuntime;
471
- runtimePath: string;
472
- workspaceHelperPath?: string;
473
- requireRootless: boolean;
474
- allowedNetworks: TNetworkMode[];
475
- containerUser: string;
476
- defaultTimeoutMs: number;
477
- maximumTimeoutMs: number;
478
- defaultMemoryBytes: number;
479
- maximumMemoryBytes: number;
480
- defaultCpus: number;
481
- maximumCpus: number;
482
- defaultPids: number;
483
- maximumPids: number;
484
- defaultSharedMemoryBytes: number;
485
- maximumSharedMemoryBytes: number;
486
- workspaceSizeBytes: number;
487
- temporarySizeBytes: number;
488
- stopTimeoutSeconds: number;
489
- }
490
- export interface IRunnerConfig extends ITransferManagerConfig { controlPlaneUrl: string;
491
- allowInsecureLoopback: boolean;
492
- name: string;
493
- labels: string[];
494
- bootstrapToken?: string;
495
- runnerId?: string;
496
- runnerCredentialId?: string;
497
- runnerToken?: string;
498
- runnerTokenExpiresAt?: string;
499
- pollIntervalMs: number;
500
- runnerHeartbeatIntervalMs: number;
501
- jobHeartbeatIntervalMs: number;
502
- leaseSafetyMarginMs: number;
503
- requestTimeoutMs: number;
504
- maximumResponseBytes: number;
505
- sourceTransferTimeoutMs: number;
506
- maximumLogBytes: number;
507
- maximumLogChunkBytes: number;
508
- artifactUploadTimeoutMs: number;
509
- cacheTransferTimeoutMs: number;
510
- maximumEnvironmentVariables: number;
511
- maximumEnvironmentValueBytes: number;
512
- maximumSecretBytes: number;
513
- oci: IOciExecutorConfig;
514
- }
515
- export interface IExecutionContext { runnerId: string;
516
- sessionId: string;
517
- lease: IOciJobLease;
518
- preparedLease: IPreparedOciLease;
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;
525
- signal: AbortSignal;
526
- terminationDeadline?: () => number | undefined;
527
- onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
528
- }
529
- export interface IOciRuntimeFacts { readonly runtime: TOciRuntime;
530
- readonly endpoint: string;
531
- readonly rootless: boolean;
532
- readonly os: 'linux';
533
- readonly architecture: TOciArchitecture;
534
- readonly helperTarget: TOciHelperTarget;
535
- readonly helperPath: string;
536
- readonly helperSha256: string;
537
- readonly workspaceBlockSize: number;
538
- }
539
- export interface IPrepareOciLeaseContext { runnerId: string;
540
- sessionId: string;
541
- lease: IOciJobLease;
542
- signal: AbortSignal;
543
- }
544
- export interface IPreparedOciLease { readonly preparationId: string;
545
- readonly attemptId: string;
546
- readonly image: string;
547
- readonly imageArchitecture: TOciArchitecture;
548
- cleanup(): Promise<void>;
549
- }
550
- export interface IWorkspaceTreeMetadata { logicalBytes: number;
551
- entryCount: number;
552
- }
553
- export interface IWorkspaceExportRequest { selections: string[];
554
- maximumBytes: number;
555
- maximumEntries: number;
556
- signal?: AbortSignal;
557
- }
558
- export interface IWorkspaceExport { path: string;
559
- metadata: IWorkspaceTreeMetadata;
560
- cleanup(): Promise<void>;
561
- }
562
- export interface IRuntimeWorkspaceExporter { exportSelected(request: IWorkspaceExportRequest): Promise<IWorkspaceExport>;
563
- cleanup(): Promise<void>;
564
- }
565
- export interface IExecutionResult { exitCode: number | null;
566
- stopReason?: TExecutionStopReason;
567
- workspace?: IRuntimeWorkspaceExporter;
568
- }
569
- export interface IJobExecutor { verifyRuntime(): Promise<IOciRuntimeFacts>;
570
- prepareLease(context: IPrepareOciLeaseContext): Promise<IPreparedOciLease>;
571
- reconcileOrphans(runnerId: string, currentSessionId: string): Promise<void>;
572
- execute(context: IExecutionContext): Promise<IExecutionResult>;
573
- }
574
- export interface IPreparedWorkspace { path: string;
575
- metadata: IWorkspaceTreeMetadata;
576
- materializedEntryCount: number;
577
- cleanup(): Promise<void>;
578
- }
579
- export interface ISourcePrepareContext { identity: IJobIdentity;
580
- job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
581
- signal: AbortSignal;
582
- }
583
- export interface IRunnerRunResult { claimed: boolean;
584
- status?: TJobCompletionStatus;
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
- }
594
- export interface IArtifactUploadContext { workspace: IRuntimeWorkspaceExporter;
595
- job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
596
- status: TJobCompletionStatus;
597
- redactionSet: ISecretRedactionSet;
598
- identity: IJobIdentity;
599
- signal: AbortSignal;
600
- }
601
- export interface IArtifactManager { upload(context: IArtifactUploadContext): Promise<void>;
602
- }
603
- export interface ICacheRestoreContext { workspacePath: string;
604
- workspaceEntryCount: number;
605
- job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
606
- identity: IJobIdentity;
607
- signal: AbortSignal;
608
- }
609
- export interface ICacheSaveContext { workspace: IRuntimeWorkspaceExporter;
610
- job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
611
- status: TJobCompletionStatus;
612
- redactionSet: ISecretRedactionSet;
613
- identity: IJobIdentity;
614
- signal: AbortSignal;
615
- }
616
- export interface ICacheManager { restore(context: ICacheRestoreContext): Promise<void>;
617
- save(context: ICacheSaveContext): Promise<void>;
618
- }
619
- export {};
620
- export interface ILogApi { appendLog(chunk: ILogChunk, signal?: AbortSignal): Promise<ILogAcknowledgement>;
621
- }
622
- export declare class LogSender { private readonly api;
623
- private readonly identity;
624
- private readonly maximumBytes;
625
- private readonly maximumChunkBytes;
626
- private readonly signal?;
627
- private readonly redactors;
628
- private readonly sequenceRedactor;
629
- private sequence;
630
- private sentBytes;
631
- private operationQueue;
632
- private terminalError;
633
- private observationSequence;
634
- private readonly lastObservation;
635
- constructor(api: ILogApi, identity: IJobIdentity, redactionSet: SecretRedactionSet, maximumBytes: number, maximumChunkBytes: number, signal?: AbortSignal | undefined);
636
- write(stream: 'stdout' | 'stderr', rawData: string): Promise<void>;
637
- writeRunnerMessage(data: string): Promise<void>;
638
- flush(): Promise<void>;
639
- private schedule;
640
- private sendBatch;
641
- }
642
- export declare const workspaceHelperReserveBytes: number;
643
- export declare const workspaceFixedInodes = 3;
644
- export interface IOciRuntimeCommandRequest { executable: string;
645
- args: string[];
646
- environment: Record<string, string>;
647
- timeoutMs: number;
648
- signal?: AbortSignal;
649
- maximumOutputBytes?: number;
650
- onOutput?: (stream: 'stdout' | 'stderr', chunk: Uint8Array) => Promise<void>;
651
- }
652
- export interface IOciRuntimeCommandResult { success: boolean;
653
- code: number;
654
- stdout: Uint8Array;
655
- stderr: Uint8Array;
656
- }
657
- export type TOciRuntimeCommandRunner = (request: IOciRuntimeCommandRequest) => Promise<IOciRuntimeCommandResult>;
658
- export interface IRuntimeMakeTempOptions { dir?: string;
659
- prefix?: string;
660
- suffix?: string;
661
- }
662
- export interface IRuntimeRemoveOptions { recursive?: boolean;
663
- }
664
- export interface IRuntimeDirectoryEntry { name: string;
665
- isFile: boolean;
666
- isDirectory: boolean;
667
- isSymlink: boolean;
668
- }
669
- export interface IRuntimeFileInfo { isDirectory: boolean;
670
- isSymlink: boolean;
671
- uid: number | null;
672
- mtime: Date | null;
673
- dev: number | null;
674
- ino: number | null;
675
- }
676
- export interface IOciExecutorDependencies { commandRunner?: TOciRuntimeCommandRunner;
677
- runtimeEnvironment?: Record<string, string>;
678
- resolveHelperPath?: (target: TOciHelperTarget) => Promise<string>;
679
- probeTmpfs?: (helperPath: string) => Promise<number>;
680
- randomId?: () => string;
681
- now?: () => number;
682
- makeTempDir?: (options: IRuntimeMakeTempOptions) => Promise<string>;
683
- chmod?: (path: string, mode: number) => Promise<void>;
684
- remove?: (path: string, options?: IRuntimeRemoveOptions) => Promise<void>;
685
- }
686
- export interface IHostTmpfsProbeScavengerDependencies { getUid?: () => number | undefined;
687
- now?: () => number;
688
- readDir?: (path: string) => AsyncIterable<IRuntimeDirectoryEntry>;
689
- lstat?: (path: string) => Promise<IRuntimeFileInfo>;
690
- remove?: (path: string, options?: IRuntimeRemoveOptions) => Promise<void>;
691
- }
692
- export interface IWorkspaceVolumeLimits { blockSize: number;
693
- logicalBytes: number;
694
- maximumEntries: number;
695
- reserveBytes: number;
696
- sizeBytes: number;
697
- inodeLimit: number;
698
- }
699
- export interface IOciRunCommand { args: string[];
700
- environment: Record<string, string>;
701
- }
702
- export interface IOciStepCommandInput { runnerId: string;
703
- sessionId: string;
704
- lease: IOciJobLease;
705
- step: ICompiledStep;
706
- containerName: string;
707
- volumeName: string;
708
- }
709
- export interface IOciHelperCommandInput { runnerId: string;
710
- sessionId: string;
711
- attemptId: string;
712
- containerName: string;
713
- image: string;
714
- helperPath: string;
715
- command: string[];
716
- volumeName?: string;
717
- sourcePath?: string;
718
- destinationPath?: string;
719
- }
720
- export declare const scavengeHostTmpfsProbes: (directory?: string, dependencies?: IHostTmpfsProbeScavengerDependencies, runtimeProbeOwnerId?: string) => Promise<void>;
721
- export declare const calculateWorkspaceVolumeLimits: (logicalBytes: number, maximumEntries: number, blockSize: number) => IWorkspaceVolumeLimits;
722
- export declare const buildOciRunCommand: (config: IRunnerConfig, input: IOciStepCommandInput) => IOciRunCommand;
723
- export declare const buildOciHelperCreateCommand: (config: IRunnerConfig, input: IOciHelperCommandInput) => string[];
724
- export declare class OciExecutor implements IJobExecutor { private readonly config;
725
- private readonly runtimeEnvironment;
726
- private readonly commandRunner;
727
- private readonly randomId;
728
- private readonly now;
729
- private readonly resolveHelperPathImplementation;
730
- private readonly probeTmpfsImplementation;
731
- private readonly makeTempDir;
732
- private readonly chmod;
733
- private readonly remove;
734
- private runtimeFacts?;
735
- private readonly preparedLeases;
736
- constructor(config: IRunnerConfig, dependencies?: IOciExecutorDependencies);
737
- verifyRuntime(): Promise<IOciRuntimeFacts>;
738
- prepareLease(context: IPrepareOciLeaseContext): Promise<IPreparedOciLease>;
739
- reconcileOrphans(runnerId: string, currentSessionId: string): Promise<void>;
740
- execute(context: IExecutionContext): Promise<IExecutionResult>;
741
- private requireRuntimeFacts;
742
- private validateLeaseIdentity;
743
- private resolvePackagedHelper;
744
- private materializeWorkspaceHelper;
745
- private ensureWorkspaceHelperDirectory;
746
- private ensureRuntimeProbeOwner;
747
- private validateRuntimeProbeOwnerMarker;
748
- private withWorkspaceHelperLock;
749
- private scavengeWorkspaceHelpers;
750
- private recoverInterruptedWorkspaceHelperPublication;
751
- private validateMaterializedWorkspaceHelper;
752
- private syncDirectory;
753
- private probeHostTmpfs;
754
- private readFilesystemProbe;
755
- private reconcileRuntimeProbeVolumes;
756
- private probeRuntimeVolume;
757
- private volumeCreateArgs;
758
- private parseImageInspection;
759
- private parseContainerState;
760
- private parseCounts;
761
- private runHostHelper;
762
- private runRuntime;
763
- private runInertContainer;
764
- private runWorkspaceHelper;
765
- private startVolumeHolder;
766
- private measureWorkspace;
767
- private readWorkspaceCapacity;
768
- private runStepContainer;
769
- private stopContainer;
770
- private stopAndRemoveContainer;
771
- private removeContainer;
772
- private removeVolume;
773
- private removePath;
774
- private createResourceName;
775
- private randomHex;
776
- }
777
- export declare const copyOciConfig: (config: IOciExecutorConfig) => IOciExecutorConfig;
778
- export declare const canonicalizeJson: (value: unknown) => string;
779
- export declare const projectCompiledPlan: (job: unknown) => TJsonObject;
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
- */
788
- export declare const createRunnerCapabilitySnapshot: (capabilities: IRunnerCapabilities) => IRunnerCapabilities;
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
- */
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>;
811
- }
812
- export declare const validateJobLease: (leaseUnknown: unknown, capabilities: IRunnerCapabilities) => Promise<IJobLease>;
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;
861
- private buffer;
862
- constructor(redactionSet: SecretRedactionSet);
863
- push(chunk: string): string;
864
- flush(): string;
865
- private consume;
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
- }
883
- export interface IRunnerCoordinatorClient { discover(signal?: AbortSignal): Promise<IDiscoveryResponse>;
884
- setRunnerToken(token: string): void;
885
- startSession(request: IStartSessionRequest, signal?: AbortSignal): Promise<IStartSessionResponse>;
886
- heartbeatRunner(request: IRunnerHeartbeatRequest, signal?: AbortSignal): Promise<IRunnerHeartbeatResponse>;
887
- claimJob(request: IClaimJobRequest, signal?: AbortSignal): Promise<IClaimJobResponse>;
888
- acceptJob(request: IAcceptJobRequest, signal?: AbortSignal): Promise<void>;
889
- heartbeatJob(request: IJobHeartbeatRequest, signal?: AbortSignal): Promise<IJobHeartbeatResponse>;
890
- appendLog(chunk: ILogChunk, signal?: AbortSignal): Promise<ILogAcknowledgement>;
891
- completeJob(request: ICompleteJobRequest, signal?: AbortSignal): Promise<ICompleteJobResponse>;
892
- abandonJob(request: IAbandonJobRequest, signal?: AbortSignal): Promise<void>;
893
- recoverAttempt(request: IRecoverAttemptRequest, signal?: AbortSignal): Promise<void>;
894
- }
895
- export interface IRunnerWorkspaceManager { prepare(context: ISourcePrepareContext): Promise<IPreparedWorkspace>;
896
- }
897
- export interface IRunnerDependencies { api: IRunnerCoordinatorClient;
898
- executor: IJobExecutor;
899
- workspaceManager: IRunnerWorkspaceManager;
900
- artifactManager?: IArtifactManager;
901
- cacheManager?: ICacheManager;
902
- onCredential?: (credential: IRunnerCredential) => Promise<void>;
903
- onMessage?: (message: string) => void;
904
- now?: () => number;
905
- /** Monotonic milliseconds that measure the attempt deadline; `performance.now` by default. */
906
- monotonicNow?: () => number;
907
- sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
908
- }
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
- export declare const reconcileProtocolLimits: (config: IRunnerConfig, discovery: IDiscoveryResponse, capabilities: IRunnerCapabilities) => void;
917
- export declare class ShipRunner { private readonly config;
918
- private readonly dependencies;
919
- private drainRequested;
920
- private sessionInvalid;
921
- private readonly now;
922
- private readonly monotonicNow;
923
- private readonly sleep;
924
- constructor(config: IRunnerConfig, dependencies: IRunnerDependencies);
925
- run(options?: {
926
- once?: boolean;
927
- signal?: AbortSignal;
928
- }): Promise<IRunnerRunResult>;
929
- private recoverInterruptedAttempt;
930
- private runOnce;
931
- private runAcceptedAttempt;
932
- private completionStatus;
933
- private jobHeartbeatLoop;
934
- private observeCancellation;
935
- private runnerHeartbeatLoop;
936
- private abandon;
937
- private applyCredential;
938
- }
939
- export interface ISourceApiClient { downloadSource(identity: IJobIdentity, source: IJobSource, signal?: AbortSignal): Promise<ITransferDownload>;
940
- }
941
- export declare class SourceWorkspaceManager { private readonly config;
942
- private readonly api;
943
- constructor(config: ITransferManagerConfig, api: ISourceApiClient);
944
- prepare(context: ISourcePrepareContext): Promise<IPreparedWorkspace>;
945
- }
946
- /**
947
- * Outcome of the specification version acceptance rule of the runner protocol: a declared
948
- * version is accepted when it is canonical, has the implemented major version, and is not newer.
949
- */
950
- export type TSpecAcceptance = 'accepted' | 'malformed' | 'major-mismatch' | 'newer';
951
- /** The specification version this runner implements: the ci-spec package it is built against. */
952
- export declare const runnerSpecVersion: string;
953
- /** Applies the acceptance rule of an implementation of version `implemented` to `declared`. */
954
- export declare const acceptSpecVersion: (implemented: string, declared: unknown) => TSpecAcceptance;
955
- /** Returns whether two canonical versions share a major version, the coordinator session rule. */
956
- export declare const specMajorVersionsMatch: (left: string, right: string) => boolean;
957
- export declare const scavengeRunnerStaging: (stateDirectory: string) => Promise<void>;
958
- /** OpenAPI component schemas of the published runner protocol that this runner validates. */
959
- 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"];
960
- export type TWireSchemaName = (typeof wireSchemaNames)[number];
961
- export declare const isWireSchemaName: (value: unknown) => value is TWireSchemaName;
962
- /** Returns whether a value is valid against one published runner protocol component. */
963
- export declare const isValidWireMessage: (name: TWireSchemaName, value: unknown) => boolean;
964
- /** Validates a value against one published runner protocol component and returns it typed. */
965
- export declare const validateWireMessage: <T>(name: TWireSchemaName, value: unknown) => T;
966
- /** Validates a compiled runner job against the published runner job schema. */
967
- export declare const validateCompiledJobSchema: <T>(value: unknown) => T;