disk 1.11.0 → 1.12.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.
@@ -1,9 +1,76 @@
1
- import { Client } from "openapi-fetch";
2
- import { components, paths } from "@archildata/api-types";
3
1
  import { ConnectionOptions } from "node:tls";
2
+ import { components, paths } from "@archildata/api-types";
4
3
 
4
+ //#region src/api-fetch.d.ts
5
+ type HttpMethod = "get" | "put" | "post" | "delete" | "patch";
6
+ type PathsWith<M extends HttpMethod> = { [P in keyof paths]: paths[P] extends { [K in M]: unknown } ? P : never }[keyof paths];
7
+ type Operation<P extends keyof paths, M extends HttpMethod> = paths[P] extends { [K in M]: infer O } ? O : never;
8
+ type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
9
+ type ParamsInit<O> = O extends {
10
+ parameters: infer P;
11
+ } ? [RequiredKeys<P>] extends [never] ? {
12
+ params?: P;
13
+ } : {
14
+ params: P;
15
+ } : {
16
+ params?: never;
17
+ };
18
+ type JsonBodyInit<O> = O extends {
19
+ requestBody: {
20
+ content: {
21
+ "application/json": infer B;
22
+ };
23
+ };
24
+ } ? {
25
+ body: B;
26
+ } : O extends {
27
+ requestBody?: {
28
+ content: {
29
+ "application/json": infer B;
30
+ };
31
+ };
32
+ } ? {
33
+ body?: B;
34
+ } : {
35
+ body?: never;
36
+ };
37
+ type RequestOptions<O> = ParamsInit<O> & JsonBodyInit<O>;
38
+ type InitArgs<O> = [RequiredKeys<RequestOptions<O>>] extends [never] ? [init?: RequestOptions<O>] : [init: RequestOptions<O>];
39
+ type SuccessStatus = 200 | 201 | 202 | 203 | 204 | 206;
40
+ type ResponseData<O> = O extends {
41
+ responses: infer R;
42
+ } ? R[Extract<keyof R, SuccessStatus>] extends infer S ? S extends {
43
+ content: {
44
+ "application/json": infer J;
45
+ };
46
+ } ? J : undefined : never : never;
47
+ type FetchResult<O> = {
48
+ data: ResponseData<O>;
49
+ error?: undefined;
50
+ response: Response;
51
+ } | {
52
+ data?: undefined;
53
+ error: unknown;
54
+ response: Response;
55
+ };
56
+ type MethodFn<M extends HttpMethod> = <P extends PathsWith<M>>(path: P, ...init: InitArgs<Operation<P, M>>) => Promise<FetchResult<Operation<P, M>>>;
57
+ interface ApiClient {
58
+ GET: MethodFn<"get">;
59
+ PUT: MethodFn<"put">;
60
+ POST: MethodFn<"post">;
61
+ DELETE: MethodFn<"delete">;
62
+ PATCH: MethodFn<"patch">;
63
+ /**
64
+ * Send an untyped request through the client's transport and default
65
+ * headers, returning the raw response (used for the S3 gateway).
66
+ */
67
+ raw(method: string, url: string, init?: {
68
+ headers?: Record<string, string>;
69
+ body?: string | Uint8Array | ArrayBuffer;
70
+ }): Promise<Response>;
71
+ }
72
+ //#endregion
5
73
  //#region src/client.d.ts
6
- type ApiClient = Client<paths>;
7
74
  interface ArchilTlsOptions {
8
75
  /**
9
76
  * Trusted PEM CA certificates for this client's control-plane and S3 requests
@@ -13,6 +80,363 @@ interface ArchilTlsOptions {
13
80
  ca?: ConnectionOptions["ca"];
14
81
  }
15
82
  //#endregion
83
+ //#region src/sandbox-process.d.ts
84
+ type SandboxProcessStatus = "running" | "completed" | "failed" | "cancelled" | "timed_out";
85
+ type SandboxProcessStream = "stdout" | "stderr";
86
+ interface SandboxProcessOutput {
87
+ stream: SandboxProcessStream;
88
+ offset: number;
89
+ data: Uint8Array;
90
+ }
91
+ type SandboxProcessOutputHandler = (output: SandboxProcessOutput) => void;
92
+ interface SandboxTerminalOptions {
93
+ cols?: number;
94
+ rows?: number;
95
+ }
96
+ interface SandboxProcessConnectOptions {
97
+ offset?: number;
98
+ /**
99
+ * Watch alongside the connection that owns the process instead of taking it
100
+ * over. By default, attaching takes the process over and the runtime closes
101
+ * the previous connection. A shared connection is closed when the owner's
102
+ * closes.
103
+ */
104
+ shared?: boolean;
105
+ onOutput?: SandboxProcessOutputHandler;
106
+ /** Retain decoded stdout and stderr on the handle and result. Defaults to true. */
107
+ collectOutput?: boolean;
108
+ }
109
+ interface SandboxProcessStartOptions {
110
+ /** Absolute working directory inside the sandbox. */
111
+ cwd?: string;
112
+ /** Enables a PTY. PTY output is merged into stdout and stderr remains empty. */
113
+ terminal?: boolean | SandboxTerminalOptions;
114
+ env?: Record<string, string>;
115
+ timeoutSeconds?: number;
116
+ onOutput?: SandboxProcessOutputHandler;
117
+ /** Retain decoded stdout and stderr on the handle and result. Defaults to true. */
118
+ collectOutput?: boolean;
119
+ }
120
+ interface SandboxProcessResult {
121
+ status: Exclude<SandboxProcessStatus, "running">;
122
+ exitCode?: number;
123
+ exitReason?: string;
124
+ stdout: string;
125
+ stderr: string;
126
+ }
127
+ type ProcessConnectionRequest = {
128
+ type: "start";
129
+ command: string;
130
+ cwd?: string;
131
+ terminal?: boolean | {
132
+ cols: number;
133
+ rows: number;
134
+ };
135
+ env: Record<string, string>;
136
+ timeout_seconds?: number;
137
+ } | {
138
+ type: "attach";
139
+ process_id: string;
140
+ offset: number;
141
+ shared?: true;
142
+ };
143
+ type ProcessControlRequest = {
144
+ type: "kill";
145
+ process_id: string;
146
+ } | {
147
+ type: "resize";
148
+ process_id: string;
149
+ cols: number;
150
+ rows: number;
151
+ };
152
+ /** Where to open a process WebSocket, and the subprotocols that carry its token. */
153
+ interface ProcessEndpoint {
154
+ url: string;
155
+ protocols?: string[];
156
+ }
157
+ /** A WebSocket URL with the token in its query string, or a {@link ProcessEndpoint}. */
158
+ type ProcessConnectionTarget = string | ProcessEndpoint;
159
+ /** @deprecated Use Sandbox.run() and Sandbox.attach(). Removed in the next version. */
160
+ declare class SandboxProcesses {
161
+ private readonly _sandbox;
162
+ /** @internal */
163
+ constructor(_sandbox: Pick<Sandbox, "run" | "attach">);
164
+ /** @deprecated Use sandbox.run(). Removed in the next version. */
165
+ start(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
166
+ /** @deprecated Use sandbox.attach(). Removed in the next version. */
167
+ connect(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
168
+ }
169
+ declare class SandboxProcess {
170
+ status: SandboxProcessStatus;
171
+ stdout: string;
172
+ stderr: string;
173
+ private _id;
174
+ private _cursor;
175
+ private readonly _onOutput?;
176
+ private readonly _collectOutput;
177
+ private readonly _connectionEndpoint;
178
+ private readonly _controlProcess;
179
+ private readonly _stdoutDecoder;
180
+ private readonly _stderrDecoder;
181
+ private readonly _terminal;
182
+ private _resolveTerminal;
183
+ private _result?;
184
+ private _socket?;
185
+ private _connectionClosed?;
186
+ private _connectionError?;
187
+ private _stdinClosed;
188
+ /** @internal */
189
+ constructor(processId: string, cursor: number, onOutput: SandboxProcessOutputHandler | undefined, collectOutput: boolean, connectionEndpoint: () => Promise<ProcessConnectionTarget>, controlProcess: (request: ProcessControlRequest) => Promise<void>);
190
+ get id(): string;
191
+ get cursor(): number;
192
+ get connected(): boolean;
193
+ sendInput(data: string | Uint8Array): Promise<void>;
194
+ resize(size: {
195
+ cols: number;
196
+ rows: number;
197
+ }): Promise<void>;
198
+ /** Close stdin. Piped processes only. */
199
+ closeStdin(): Promise<void>;
200
+ /** Close this client connection without terminating the process. */
201
+ disconnect(): Promise<void>;
202
+ wait(): Promise<SandboxProcessResult>;
203
+ kill(): Promise<void>;
204
+ /** @internal */
205
+ _connect(request: ProcessConnectionRequest): Promise<void>;
206
+ private _openSocket;
207
+ private _sendControl;
208
+ private _sendInput;
209
+ private _handleMessage;
210
+ private _handleOutput;
211
+ private _appendText;
212
+ private _flushDecoders;
213
+ private _finish;
214
+ }
215
+ //#endregion
216
+ //#region src/sandbox-files.d.ts
217
+ type SandboxFileSource = Uint8Array | ArrayBuffer | Blob | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>;
218
+ type SandboxFileWriter = (chunk: Uint8Array) => void | Promise<void>;
219
+ interface SandboxFileUploadOptions {
220
+ mode?: number;
221
+ }
222
+ declare class SandboxFiles {
223
+ private readonly _sandbox;
224
+ /** @internal */
225
+ constructor(sandbox: Pick<Sandbox, "run">);
226
+ uploadFile(source: SandboxFileSource, remotePath: string, options?: SandboxFileUploadOptions): Promise<void>;
227
+ downloadFile(remotePath: string, write: SandboxFileWriter): Promise<void>;
228
+ }
229
+ //#endregion
230
+ //#region src/sandbox.d.ts
231
+ type SandboxNetworkAction = components["schemas"]["SandboxNetworkAction"];
232
+ type SandboxEgressPolicy = components["schemas"]["SandboxEgressPolicy"] & {
233
+ /** Host patterns supporting * anywhere. All paths count; selectors do not grant network access. */drain_on_pause?: string[];
234
+ };
235
+ type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
236
+ type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
237
+ type SandboxNetwork = Omit<components["schemas"]["SandboxNetwork"], "egress"> & {
238
+ egress?: SandboxEgressPolicy;
239
+ };
240
+ /** @internal */
241
+ type SandboxWire = components["schemas"]["Sandbox"];
242
+ /**
243
+ * One Archil disk to mount inside a sandbox. `path` is the absolute guest
244
+ * directory; it may be omitted only for a sole mount, which then lands at
245
+ * `/mnt/archil`. A plain mount is exclusive and `queueMs` bounds the wait for
246
+ * its root delegation; `readOnly` and `conditional` mounts never take it.
247
+ */
248
+ interface SandboxMountSpec extends Omit<ExecMountSpec, "checkoutPaths" | "queueMs"> {
249
+ path?: string;
250
+ /**
251
+ * Milliseconds a plain mount waits for the disk's exclusive root delegation
252
+ * before the boot fails. Cannot be combined with `readOnly` or `conditional`.
253
+ */
254
+ queueMs?: number;
255
+ }
256
+ /** An Archil disk mounted inside the sandbox, as currently configured. */
257
+ interface SandboxMount {
258
+ diskId: string;
259
+ /** Absolute guest directory the disk is mounted at. */
260
+ path: string;
261
+ subdirectory?: string;
262
+ readOnly: boolean;
263
+ conditional: boolean;
264
+ queueMs?: number;
265
+ }
266
+ type SandboxStatus = components["schemas"]["SandboxState"];
267
+ interface SandboxEndpoint {
268
+ port: number;
269
+ hostname: string;
270
+ }
271
+ /** Port-token metadata. The secret and hostname are returned only on creation. */
272
+ interface SandboxPortToken {
273
+ id: string;
274
+ port: number;
275
+ createdAt: Date;
276
+ expiresAt?: Date;
277
+ }
278
+ interface CreatedSandboxPortToken extends SandboxPortToken {
279
+ hostname: string;
280
+ /** Send in X-Archil-Token. Save it now; it cannot be retrieved again. */
281
+ token: string;
282
+ }
283
+ interface CreateSandboxPortTokenOptions {
284
+ /** Duration such as "1h" or "30m", up to "8760h" (365 days). Omit for no expiration. */
285
+ ttl?: string;
286
+ }
287
+ interface ListSandboxPortTokensOptions {
288
+ limit?: number;
289
+ cursor?: string;
290
+ }
291
+ interface SandboxPortTokenPage {
292
+ tokens: SandboxPortToken[];
293
+ nextCursor?: string;
294
+ }
295
+ interface SandboxResponse {
296
+ id: string;
297
+ name: string;
298
+ status: SandboxStatus;
299
+ vcpuCount: number;
300
+ memSizeMiB: number;
301
+ /** Empty for sandboxes created from `imageId`. */
302
+ baseImage: string;
303
+ /** Digest of the image the sandbox was created from; may be empty. */
304
+ imageDigest: string;
305
+ platform?: "arm64" | "amd64";
306
+ maxTtlSeconds: number;
307
+ idleTtlSeconds: number;
308
+ /** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
309
+ maxConcurrentExecs: number;
310
+ endpoints?: SandboxEndpoint[];
311
+ /** Disks mounted inside the guest on every boot. */
312
+ mounts: SandboxMount[];
313
+ createdAt: Date;
314
+ runningAt?: Date;
315
+ finishedAt?: Date;
316
+ lastActiveAt: Date;
317
+ exitReason?: string;
318
+ /** Disk checkpoint the current session leaves behind; present while pausing, paused, stopping, or stopped. */
319
+ checkpoint?: string;
320
+ }
321
+ interface SandboxWaitOptions {
322
+ /**
323
+ * Wait for the operation to finish. Defaults to true.
324
+ * The SDK polls if the server's wait budget expires first.
325
+ */
326
+ wait?: boolean;
327
+ }
328
+ interface SandboxStartOptions extends SandboxWaitOptions {
329
+ /**
330
+ * Replace the sandbox's disk mounts for this and later sessions. Omit to
331
+ * keep the current ones. A cold start only: resume keeps the paused
332
+ * session's mounts.
333
+ */
334
+ mounts?: SandboxMountSpec[];
335
+ }
336
+ interface SandboxForkOptions extends SandboxWaitOptions {
337
+ /** Name for the fork. The server generates one when omitted. */
338
+ name?: string;
339
+ }
340
+ interface SandboxTimeoutOptions {
341
+ /** Hard lifetime in seconds. Omit to leave its deadline unchanged. */
342
+ timeoutSeconds?: number;
343
+ /** Seconds without a direct process connection. Zero disables idle expiry; omit to leave unchanged. */
344
+ idleTtlSeconds?: number;
345
+ }
346
+ declare class Sandbox {
347
+ id: string;
348
+ name: string;
349
+ status: SandboxStatus;
350
+ vcpuCount: number;
351
+ memSizeMiB: number;
352
+ baseImage: string;
353
+ imageDigest: string;
354
+ platform?: "arm64" | "amd64";
355
+ maxTtlSeconds: number;
356
+ idleTtlSeconds: number;
357
+ maxConcurrentExecs: number;
358
+ endpoints?: SandboxEndpoint[];
359
+ mounts: SandboxMount[];
360
+ createdAt: Date;
361
+ runningAt?: Date;
362
+ finishedAt?: Date;
363
+ lastActiveAt: Date;
364
+ exitReason?: string;
365
+ checkpoint?: string;
366
+ /** @deprecated Use run() and attach(). Removed in the next version. */
367
+ readonly processes: SandboxProcesses;
368
+ readonly files: SandboxFiles;
369
+ /** @internal */
370
+ private readonly _client;
371
+ /** @internal */
372
+ constructor(data: SandboxWire, client: ApiClient);
373
+ /** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
374
+ private _apply;
375
+ toJSON(): SandboxResponse;
376
+ /** Start a process and return its handle without waiting for exit. */
377
+ run(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
378
+ /** Reattach to a process, optionally resuming output from a cursor. */
379
+ attach(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
380
+ private _connectionEndpoint;
381
+ private _control;
382
+ /** Run a process and wait for it to exit. */
383
+ exec(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcessResult>;
384
+ /** Re-fetch this sandbox. */
385
+ refresh(): Promise<this>;
386
+ /** Start this sandbox. */
387
+ start(options?: SandboxStartOptions): Promise<Sandbox | this>;
388
+ /** Stop this sandbox. */
389
+ stop(options?: SandboxWaitOptions): Promise<Sandbox | this>;
390
+ /** Pause this sandbox, preserving its CPU and memory state. */
391
+ pause(options?: SandboxWaitOptions): Promise<this>;
392
+ /** Resume this sandbox from its preserved CPU and memory state. */
393
+ resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
394
+ /**
395
+ * Create an isolated writable branch from this sandbox's current state.
396
+ * A running sandbox is paused for the snapshot and resumed once the fork is
397
+ * accepted; a paused or stopped sandbox is left as it is. The fork names the
398
+ * checkpoint the pause returned, so it does not depend on the source still
399
+ * being paused when the request lands. Resuming the source is best effort:
400
+ * the child is returned even if the source could not be resumed, so check
401
+ * the source's status afterwards if that matters.
402
+ */
403
+ fork(options?: SandboxForkOptions): Promise<Sandbox>;
404
+ /** Expose a TCP port publicly (1–65535), returning its hostname. */
405
+ exposePort(port: number): Promise<string>;
406
+ /** List explicitly exposed public ports. Service-published ports are in `endpoints`. */
407
+ listPorts(): Promise<SandboxEndpoint[]>;
408
+ /** Remove explicit public exposure. A service publishing the same port remains reachable. */
409
+ unexposePort(port: number): Promise<void>;
410
+ /** Authorize HTTP access to one port without making it public. */
411
+ createPortToken(port: number, options?: CreateSandboxPortTokenOptions): Promise<CreatedSandboxPortToken>;
412
+ /** Get token metadata. Expired and revoked tokens return not found. */
413
+ getPortToken(tokenId: string): Promise<SandboxPortToken>;
414
+ /** List token metadata across pages. `limit` caps the total number returned. */
415
+ listPortTokens(options?: ListSandboxPortTokensOptions): Promise<SandboxPortToken[]>;
416
+ /** Fetch one page of token metadata; pass `nextCursor` back as `cursor`. */
417
+ listPortTokensPage(options?: ListSandboxPortTokensOptions): Promise<SandboxPortTokenPage>;
418
+ /** Revoke a token for new connections. Existing connections remain open. */
419
+ deletePortToken(token: SandboxPortToken | string): Promise<void>;
420
+ /** Get this running sandbox's effective network policy. */
421
+ getNetwork(): Promise<SandboxNetwork>;
422
+ /** Replace this running sandbox's complete network policy and return the effective policy. */
423
+ updateNetwork(network: SandboxNetwork): Promise<SandboxNetwork>;
424
+ /** Update either or both TTLs in seconds. Omitted settings remain unchanged. */
425
+ setTimeout(timeout: number | SandboxTimeoutOptions): Promise<this>;
426
+ /** Delete this sandbox and its backing disk. */
427
+ delete(): Promise<void>;
428
+ }
429
+ //#endregion
430
+ //#region src/exec-options.d.ts
431
+ /** Network policy for an exec's container, using the sandbox egress rules. */
432
+ type ExecNetwork = Omit<components["schemas"]["ExecNetwork"], "egress"> & {
433
+ egress?: SandboxEgressPolicy;
434
+ };
435
+ /** The image, size, and network of the VM an exec runs in. */
436
+ type ExecVmOptions = Omit<components["schemas"]["ExecDiskRequest"], "command" | "network"> & {
437
+ network?: ExecNetwork;
438
+ };
439
+ //#endregion
16
440
  //#region src/filesystem.d.ts
17
441
  /**
18
442
  * A key-addressable filesystem over one or more Archil disks — the existing
@@ -523,7 +947,7 @@ declare class Disk implements FileSystem {
523
947
  * Execute a command in a container with this disk mounted.
524
948
  * Blocks until the command completes and returns stdout, stderr, and exit code.
525
949
  */
526
- exec(command: string): Promise<ExecResult>;
950
+ exec(command: string, options?: ExecVmOptions): Promise<ExecResult>;
527
951
  /**
528
952
  * Constant-time parallel grep across files on this disk. Listing and
529
953
  * matching are fanned out across ephemeral exec containers; the request
@@ -794,4 +1218,364 @@ declare class DiskMultipart {
794
1218
  */
795
1219
  declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
796
1220
  //#endregion
797
- export { MountResponse as $, effectiveUploadPartSize as A, DiskMetrics as B, PosixCreateAttrs as C, ShareUrlOptions as D, S3Object as E, Branch as F, ExecRequest as G, DiskStatus as H, ConnectedClient as I, GrepGroupLine as J, GCSMount as K, CreateApiTokenRequest as L, AuthorizedUser as M, AwsStsUser as N, ShareUrlResult as O, AzureBlobMount as P, MountConfigResponse as Q, CreateDiskRequest as R, PartListing as S, PutObjectResult as T, DiskUser as U, DiskResponse as V, ExecDiskResult as W, GrepStoppedReason as X, GrepMatch as Y, MountConfig as Z, MultipartUpload as _, DeleteObjectsOptions as a, TokenUser as at, ObjectMetadata as b, DiskMultipart as c, ArchilTlsOptions as ct, GrepResult as d, R2Mount as et, ListMultipartUploadsOptions as f, MountOptions as g, ListPartsOptions as h, DeleteObjectsError as i, S3User as it, ApiTokenResponse as j, UploadPart as k, ExecResult as l, ListObjectsResult as m, CompletedMultipartUpload as n, S3CompatibleMount as nt, DeleteObjectsResult as o, FileSystem as ot, ListObjectsOptions as p, GrepGroup as q, CreateBranchOptions as r, S3Mount as rt, Disk as s, ApiClient as st, AppendObjectOptions as t, RootAttrs as tt, GrepOptions as u, MultipartUploadListing as v, PutObjectOptions as w, PartInfo as x, MultipartUploadSummary as y, Delegation as z };
1221
+ //#region src/disks.d.ts
1222
+ interface ListDisksOptions {
1223
+ /** Cap on the total number of disks returned. */
1224
+ limit?: number;
1225
+ /** Resume listing from a previous page's `nextCursor`. */
1226
+ cursor?: string;
1227
+ name?: string;
1228
+ }
1229
+ interface DiskListPage {
1230
+ disks: Disk[];
1231
+ /**
1232
+ * Set when more disks remain beyond this page; pass it back as `cursor` to
1233
+ * fetch the next one. Undefined on the last page.
1234
+ */
1235
+ nextCursor?: string;
1236
+ }
1237
+ interface CreateDiskResult {
1238
+ disk: Disk;
1239
+ token: string | null;
1240
+ tokenIdentifier: string | null;
1241
+ authorizedUsers: AuthorizedUser[];
1242
+ }
1243
+ declare class Disks {
1244
+ /** @internal */
1245
+ private readonly _client;
1246
+ /** @internal */
1247
+ private readonly _region;
1248
+ /** @internal */
1249
+ private readonly _s3BaseUrl?;
1250
+ /** @internal */
1251
+ constructor(client: ApiClient, region: string, s3BaseUrl?: string);
1252
+ /**
1253
+ * List the account's disks. Fetches in cursor-driven pages (bounded server
1254
+ * work per request) and follows `nextCursor` until exhausted, so the result
1255
+ * is complete even for very large accounts. Use `limit` to cap the total, or
1256
+ * {@link listPage} to walk pages yourself.
1257
+ */
1258
+ list(opts?: ListDisksOptions): Promise<Disk[]>;
1259
+ /**
1260
+ * Fetch a single page of disks. `nextCursor` on the result resumes the
1261
+ * listing (it can also be persisted, e.g. across requests of a paginated UI).
1262
+ */
1263
+ listPage(opts?: ListDisksOptions): Promise<DiskListPage>;
1264
+ get(id: string): Promise<Disk>;
1265
+ /**
1266
+ * Create a new disk with an auto-generated mount token.
1267
+ *
1268
+ * Returns the Disk, the one-time token (save it — it cannot be retrieved
1269
+ * again), and the token identifier for later management.
1270
+ *
1271
+ * `rootAttrs` sets the POSIX owner and mode of the disk's root directory
1272
+ * (e.g. `{ uid: 1000, gid: 1000, mode: 0o755 }` so an unprivileged process
1273
+ * can create entries under the mount root without a post-mount `chown`).
1274
+ * Creation-time only.
1275
+ */
1276
+ create(req: CreateDiskRequest): Promise<CreateDiskResult>;
1277
+ /**
1278
+ * Execute a command on a disk that is already known to exist. Accepts the
1279
+ * disk ID directly so callers that do not need its metadata can execute
1280
+ * without fetching the disk first.
1281
+ */
1282
+ exec(id: string, command: string, options?: ExecVmOptions): Promise<ExecResult>;
1283
+ }
1284
+ //#endregion
1285
+ //#region src/images.d.ts
1286
+ type ImageWire = components["schemas"]["Image"];
1287
+ type ImageStatus = components["schemas"]["ImageState"];
1288
+ /**
1289
+ * Why a build failed. `invalid_source`: the registry reported the image missing
1290
+ * or denied access, so retrying won't help. `interrupted`: the build did not
1291
+ * finish; requesting it again starts a new build.
1292
+ */
1293
+ type ImageFailureReason = NonNullable<ImageWire["failure_reason"]>;
1294
+ interface Image {
1295
+ /** 64-character hex id; pass it to `sandboxes.create({ imageId })`. */
1296
+ imageId: string;
1297
+ /** Normalized OCI reference. */
1298
+ source: string;
1299
+ private: boolean;
1300
+ status: ImageStatus;
1301
+ /** `sha256:` digest of the last successful build, kept while a tag rebuilds. */
1302
+ digest?: string;
1303
+ /** `repo@sha256:` reference of the last successful build. */
1304
+ canonicalSource?: string;
1305
+ /** Present only when `status` is `failed`. */
1306
+ failureReason?: ImageFailureReason;
1307
+ createdAt: Date;
1308
+ updatedAt: Date;
1309
+ }
1310
+ /** Registry credentials for a private image. Archil never stores them. */
1311
+ type RegistryAuth = components["schemas"]["RegistryAuth"];
1312
+ interface BuildImageRequest {
1313
+ /** OCI image reference, such as `node:24-bookworm` or `ghcr.io/owner/app@sha256:<digest>`. */
1314
+ source: string;
1315
+ /** Required for private images on every build request; without it `source` names the public image. */
1316
+ registryAuth?: RegistryAuth;
1317
+ }
1318
+ interface BuildImageOptions {
1319
+ /** Seconds to wait for the build. Defaults to 1800 (30 minutes). */
1320
+ timeoutSeconds?: number;
1321
+ }
1322
+ declare class Images {
1323
+ /** @internal */
1324
+ private readonly _client;
1325
+ /** @internal */
1326
+ constructor(client: ApiClient);
1327
+ get(imageId: string): Promise<Image>;
1328
+ /**
1329
+ * Build a sandbox image from an OCI reference and wait until it is ready.
1330
+ * Returns at once when the image is already built from a digest reference
1331
+ * and joins a build that is already running. A tag is rebuilt on each call
1332
+ * in case it moved, so call this once and reuse `imageId`. Interrupted
1333
+ * builds are requested again up to three times; other failures throw
1334
+ * {@link ImageBuildError}.
1335
+ */
1336
+ build(request: BuildImageRequest, options?: BuildImageOptions): Promise<Image>;
1337
+ private _request;
1338
+ }
1339
+ //#endregion
1340
+ //#region src/sandboxes.d.ts
1341
+ interface CreateSandboxRequest {
1342
+ /** Name for the sandbox. The server generates one when omitted. */
1343
+ name?: string;
1344
+ /** Number of virtual CPUs allocated to the sandbox, from 1 to 32. Defaults to 1. */
1345
+ vcpuCount?: number;
1346
+ /** Memory allocated to the sandbox in MiB, from 256 to 65536. Defaults to 2048. */
1347
+ memSizeMiB?: number;
1348
+ /**
1349
+ * Public Linux OCI image reference for the sandbox's root filesystem.
1350
+ * Docker Hub shorthand and any public registry are accepted; the tag
1351
+ * defaults to `latest`, and mutable tags are pinned to immutable digests
1352
+ * when the sandbox is created. Defaults to `ubuntu:26.04`.
1353
+ *
1354
+ * Examples: `ubuntu`, `node:24-bookworm`, `ghcr.io/owner/app:v2`,
1355
+ * `alpine@sha256:<digest>`.
1356
+ */
1357
+ baseImage?: string;
1358
+ /** Ready image from `images.build()`. Cannot be combined with `baseImage`. */
1359
+ imageId?: string;
1360
+ env?: Record<string, string>;
1361
+ maxTtlSeconds?: number;
1362
+ /** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
1363
+ idleTtlSeconds?: number;
1364
+ /** Maximum concurrently attached exec sessions. Detached processes and one-shot controls do not count. */
1365
+ maxConcurrentExecs?: number;
1366
+ /** Creation-time network policy. Egress is unrestricted when omitted. */
1367
+ network?: SandboxNetwork;
1368
+ /** TCP ports to expose publicly, from 1 to 65535. */
1369
+ ports?: number[];
1370
+ /**
1371
+ * Disks mounted inside the guest for the first session; `sandbox.start()`
1372
+ * can replace them later. A sandbox with mounts must be stopped before it
1373
+ * is forked.
1374
+ */
1375
+ mounts?: SandboxMountSpec[];
1376
+ }
1377
+ interface ListSandboxesOptions {
1378
+ /** Only return sandboxes that mount this disk. */
1379
+ disk?: Disk | string;
1380
+ }
1381
+ declare class Sandboxes {
1382
+ /** @internal */
1383
+ private readonly _client;
1384
+ /** @internal */
1385
+ constructor(client: ApiClient);
1386
+ /** List the account's sandboxes, oldest first. */
1387
+ list(options?: ListSandboxesOptions): Promise<Sandbox[]>;
1388
+ get(id: string): Promise<Sandbox>;
1389
+ create(request?: CreateSandboxRequest, options?: SandboxWaitOptions): Promise<Sandbox>;
1390
+ }
1391
+ //#endregion
1392
+ //#region src/tokens.d.ts
1393
+ interface ListTokensOptions {
1394
+ limit?: number;
1395
+ cursor?: string;
1396
+ }
1397
+ declare class Tokens {
1398
+ /** @internal */
1399
+ private readonly _client;
1400
+ /** @internal */
1401
+ constructor(client: ApiClient);
1402
+ list(opts?: ListTokensOptions): Promise<ApiTokenResponse[]>;
1403
+ create(req: CreateApiTokenRequest): Promise<ApiTokenResponse & {
1404
+ token?: string;
1405
+ }>;
1406
+ delete(id: string): Promise<void>;
1407
+ }
1408
+ //#endregion
1409
+ //#region src/workspace.d.ts
1410
+ /** Anything that can run a multi-disk exec — i.e. an `Archil` client. A narrow
1411
+ * structural type so this module doesn't import the Archil class (avoiding a
1412
+ * value-import cycle with archil.ts). */
1413
+ interface WorkspaceExecCapable {
1414
+ exec(opts: ExecOptions): Promise<ExecResult>;
1415
+ }
1416
+ /**
1417
+ * A key-routed filesystem spanning several Archil disks. Each disk is mounted
1418
+ * under a name and addressed as the first segment of a key (`<name>/...`);
1419
+ * `getObject`, `putObject`, `deleteObject`, `listObjects`, and `grep` route to
1420
+ * the right disk by that segment (and `listObjects` / `grep` fan out across all
1421
+ * of them when the key/prefix doesn't name one). Implements the same
1422
+ * {@link FileSystem} surface as a single {@link Disk}, so it works anywhere a
1423
+ * disk does. Mounts can be changed at runtime with {@link addDisk} /
1424
+ * {@link removeDisk}.
1425
+ */
1426
+ declare class Workspace implements FileSystem {
1427
+ private readonly client;
1428
+ private readonly mounts;
1429
+ /** @internal Use `archil.workspace({ ... })`. */
1430
+ constructor(client: WorkspaceExecCapable, mounts: Record<string, ExecMount>);
1431
+ /** Mount (or replace) a disk at `name`; its objects are addressed as
1432
+ * `<name>/...`. Accepts a `Disk` or a mount spec (read-only / subdirectory /
1433
+ * conditional / delegation checkouts); a bare disk-id string is rejected —
1434
+ * fetch the disk first. */
1435
+ addDisk(name: string, disk: ExecMount): this;
1436
+ /** Unmount the disk at `name`. Returns whether a disk was removed. Refuses to
1437
+ * remove the last disk — a workspace must always have at least one (the same
1438
+ * invariant the constructor enforces), else fan-out/exec would have nothing to
1439
+ * route to. */
1440
+ removeDisk(name: string): boolean;
1441
+ /** The names of the currently-mounted disks. */
1442
+ diskNames(): string[];
1443
+ private unknownDisk;
1444
+ /** Resolve a workspace key (`<name>/...`) to the disk and the disk-relative key. */
1445
+ private route;
1446
+ /** Mounts touched by a key prefix; an empty prefix fans out to all of them. */
1447
+ private covered;
1448
+ /** Route grep globs written against the workspace root to the mounts they
1449
+ * can match. A glob that starts with a mount's name goes to that mount without
1450
+ * the name. One with no `/`, or that starts with `**` + `/` with or without a
1451
+ * leading `/`, goes to every mount as written, and also applies to a mount it
1452
+ * names exactly, like `!cache` or `**` + `/logs/**`. Mount names are matched
1453
+ * literally, so `!l*` doesn't skip a `logs` mount. Leaves out a mount whose
1454
+ * directory an exclude names, or that no include reaches, and throws for any
1455
+ * other glob with a `/`. */
1456
+ private rootGlobs;
1457
+ /** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
1458
+ private diskKey;
1459
+ /** Map a disk key back to its workspace key (`<name>/...`), stripping the mount subdirectory. */
1460
+ private abs;
1461
+ getObject(key: string): Promise<Uint8Array>;
1462
+ putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
1463
+ deleteObject(key: string): Promise<void>;
1464
+ listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
1465
+ /**
1466
+ * Grep the disks `directory` covers in parallel and merge their results. At
1467
+ * the workspace root, a glob with a `/` must start with a mount name, like
1468
+ * `data/src/**`, which applies to that mount only, or with `**` + `/`. A glob
1469
+ * with no `/`, like `*.ts`, or one starting with `**` + `/` with or without a
1470
+ * leading `/`, applies inside every mount, and also to a mount it names
1471
+ * exactly, so `!cache` skips the cache mount. Mount names are matched
1472
+ * literally, not as patterns: `!l*` applies inside every mount, but doesn't
1473
+ * skip a mount named `logs`.
1474
+ */
1475
+ grep(opts: GrepOptions): Promise<GrepResult>;
1476
+ exec(command: string): Promise<ExecResult>;
1477
+ }
1478
+ //#endregion
1479
+ //#region src/archil.d.ts
1480
+ interface ArchilOptions {
1481
+ /** API key. Falls back to ARCHIL_API_KEY env var if not provided. */
1482
+ apiKey?: string;
1483
+ /** Region. Falls back to ARCHIL_REGION env var if not provided. */
1484
+ region?: string;
1485
+ /** Override the control plane base URL (useful for testing). */
1486
+ baseUrl?: string;
1487
+ /**
1488
+ * Override the S3-compatible API base URL used by Disk#getObject /
1489
+ * putObject / deleteObject. Falls back to ARCHIL_S3_BASE_URL, then to the
1490
+ * control plane URL with its `control.` hostname prefix swapped for `s3.`.
1491
+ */
1492
+ s3BaseUrl?: string;
1493
+ /** Per-client TLS trust for control-plane and S3 requests (Node.js only). */
1494
+ tls?: ArchilTlsOptions;
1495
+ }
1496
+ /**
1497
+ * Options that apply to a single mounted disk in an exec request.
1498
+ * Use this object form when you need to pin the mount to a subdirectory
1499
+ * of the disk, mount it read-only, mount it in conditional mode, or request
1500
+ * delegation checkouts; for the default case (mount the disk's root,
1501
+ * read-write with no checkout), pass a `Disk` or disk-id string instead.
1502
+ */
1503
+ interface ExecMountSpec {
1504
+ /** Disk to mount, by `Disk` instance or raw disk id string. */
1505
+ disk: Disk | string;
1506
+ /**
1507
+ * Subdirectory of the disk to expose at the mountpoint. Must be a
1508
+ * relative path with no `.` or `..` segments. When omitted, the disk's
1509
+ * root is exposed.
1510
+ */
1511
+ subdirectory?: string;
1512
+ /**
1513
+ * When true, mount the disk read-only inside the container. Writes
1514
+ * against the mount fail with EROFS. Defaults to false.
1515
+ */
1516
+ readOnly?: boolean;
1517
+ /**
1518
+ * When true, mount the disk in conditional mode, which lets this mount
1519
+ * write without a delegation checkout. This enables concurrent writes from
1520
+ * multiple clients to the same disk.
1521
+ * Defaults to false.
1522
+ */
1523
+ conditional?: boolean;
1524
+ /**
1525
+ * Milliseconds to wait in the delegation queue for each requested checkout.
1526
+ * If set without `checkoutPaths`, the exposed mount root is acquired during
1527
+ * mount setup. Cannot be combined with `readOnly: true`.
1528
+ */
1529
+ queueMs?: number;
1530
+ /**
1531
+ * Paths relative to this disk's exposed mount root to check out before the
1532
+ * command starts. May be set without `queueMs`; those checkouts try
1533
+ * immediately without waiting in the delegation queue. Cannot be combined
1534
+ * with `readOnly: true`.
1535
+ */
1536
+ checkoutPaths?: string[];
1537
+ }
1538
+ /**
1539
+ * One disk to mount in an exec request. Either a `Disk`/disk-id string
1540
+ * (mounts the disk's root, read-write) or an `ExecMountSpec` object that
1541
+ * additionally selects a subdirectory of the disk and/or marks the mount as
1542
+ * read-only, conditional, or requests delegation checkouts. Used
1543
+ * by Archil#exec, where the map key is the relative path under /mnt/archil at
1544
+ * which to mount the disk.
1545
+ */
1546
+ type ExecMount = Disk | string | ExecMountSpec;
1547
+ interface ExecOptions extends ExecVmOptions {
1548
+ /**
1549
+ * Disks to mount, keyed by the relative path under `/mnt/archil` at which
1550
+ * to mount each one. At least one entry is required. Paths must be
1551
+ * non-empty, non-absolute, and contain no `.` or `..` segments.
1552
+ */
1553
+ disks: Record<string, ExecMount>;
1554
+ /** Shell command to run inside the container. */
1555
+ command: string;
1556
+ }
1557
+ declare class Archil {
1558
+ readonly disks: Disks;
1559
+ readonly images: Images;
1560
+ readonly sandboxes: Sandboxes;
1561
+ readonly tokens: Tokens;
1562
+ /** @internal */
1563
+ private readonly _client;
1564
+ constructor(opts?: ArchilOptions);
1565
+ /**
1566
+ * Run a command in a container with multiple disks mounted simultaneously,
1567
+ * each at its own relative path under `/mnt/archil`. Blocks until the
1568
+ * command completes and returns its stdout, stderr, exit code, and timing.
1569
+ */
1570
+ exec(opts: ExecOptions): Promise<ExecDiskResult>;
1571
+ /**
1572
+ * Build an agent filesystem toolset spanning several disks at once. `mounts`
1573
+ * maps a relative path to a disk (or `ExecMountSpec`), exactly like
1574
+ * {@link exec}; each disk appears under `/mnt/archil/<path>`. Hand the result
1575
+ * to a framework adapter (`createDiskTools(workspace)`) to get tools that route
1576
+ * file operations by path and fan `grep`/`list_files` out across the disks.
1577
+ */
1578
+ workspace(mounts: Record<string, ExecMount>): Workspace;
1579
+ }
1580
+ //#endregion
1581
+ export { ApiTokenResponse as $, SandboxFileWriter as $t, DiskMultipart as A, ExecVmOptions as At, MultipartUploadListing as B, SandboxMount as Bt, AppendObjectOptions as C, RootAttrs as Ct, DeleteObjectsOptions as D, TokenUser as Dt, DeleteObjectsError as E, S3User as Et, ListObjectsOptions as F, SandboxEgressPolicy as Ft, PosixCreateAttrs as G, SandboxPortTokenPage as Gt, ObjectMetadata as H, SandboxNetwork as Ht, ListObjectsResult as I, SandboxEgressRule as It, S3Object as J, SandboxStatus as Jt, PutObjectOptions as K, SandboxResponse as Kt, ListPartsOptions as L, SandboxEgressTransform as Lt, GrepOptions as M, CreatedSandboxPortToken as Mt, GrepResult as N, ListSandboxPortTokensOptions as Nt, DeleteObjectsResult as O, FileSystem as Ot, ListMultipartUploadsOptions as P, Sandbox as Pt, effectiveUploadPartSize as Q, SandboxFileUploadOptions as Qt, MountOptions as R, SandboxEndpoint as Rt, ListDisksOptions as S, R2Mount as St, CreateBranchOptions as T, S3Mount as Tt, PartInfo as U, SandboxNetworkAction as Ut, MultipartUploadSummary as V, SandboxMountSpec as Vt, PartListing as W, SandboxPortToken as Wt, ShareUrlResult as X, SandboxWaitOptions as Xt, ShareUrlOptions as Y, SandboxTimeoutOptions as Yt, UploadPart as Z, SandboxFileSource as Zt, Images as _, GrepMatch as _t, ExecOptions as a, SandboxProcessResult as an, CreateApiTokenRequest as at, DiskListPage as b, MountConfigResponse as bt, Tokens as c, SandboxProcessStream as cn, DiskMetrics as ct, Sandboxes as d, ArchilTlsOptions as dn, DiskUser as dt, SandboxFiles as en, AuthorizedUser as et, BuildImageOptions as f, ExecDiskResult as ft, ImageStatus as g, GrepGroupLine as gt, ImageFailureReason as h, GrepGroup as ht, ExecMountSpec as i, SandboxProcessOutputHandler as in, ConnectedClient as it, ExecResult as j, CreateSandboxPortTokenOptions as jt, Disk as k, ExecNetwork as kt, CreateSandboxRequest as l, SandboxProcesses as ln, DiskResponse as lt, Image as m, GCSMount as mt, ArchilOptions as n, SandboxProcessConnectOptions as nn, AzureBlobMount as nt, Workspace as o, SandboxProcessStartOptions as on, CreateDiskRequest as ot, BuildImageRequest as p, ExecRequest as pt, PutObjectResult as q, SandboxStartOptions as qt, ExecMount as r, SandboxProcessOutput as rn, Branch as rt, ListTokensOptions as s, SandboxProcessStatus as sn, Delegation as st, Archil as t, SandboxProcess as tn, AwsStsUser as tt, ListSandboxesOptions as u, SandboxTerminalOptions as un, DiskStatus as ut, RegistryAuth as v, GrepStoppedReason as vt, CompletedMultipartUpload as w, S3CompatibleMount as wt, Disks as x, MountResponse as xt, CreateDiskResult as y, MountConfig as yt, MultipartUpload as z, SandboxForkOptions as zt };