disk 1.10.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.
@@ -0,0 +1,1581 @@
1
+ import { ConnectionOptions } from "node:tls";
2
+ import { components, paths } from "@archildata/api-types";
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
73
+ //#region src/client.d.ts
74
+ interface ArchilTlsOptions {
75
+ /**
76
+ * Trusted PEM CA certificates for this client's control-plane and S3 requests
77
+ * (Node.js only). Replaces Node's default CA list; include those certificates
78
+ * explicitly to retain them. Certificate and hostname verification stay enabled.
79
+ */
80
+ ca?: ConnectionOptions["ca"];
81
+ }
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
440
+ //#region src/filesystem.d.ts
441
+ /**
442
+ * A key-addressable filesystem over one or more Archil disks — the existing
443
+ * object API a {@link Disk} already exposes ({@link Disk.getObject},
444
+ * `putObject`, `deleteObject`, `listObjects`, `grep`, `exec`), captured as a
445
+ * contract so a multi-disk {@link Workspace} can be used anywhere a single disk
446
+ * is.
447
+ *
448
+ * A single {@link Disk} is the one-disk case: keys are relative to the disk
449
+ * root. A {@link Workspace} spans several disks, each mounted under a name, so
450
+ * its keys carry that name as the first segment (e.g. `data/reports/q1.csv`)
451
+ * and `listObjects`/`grep` fan out across every disk when the key/prefix
452
+ * doesn't name one.
453
+ *
454
+ * Both `Disk` and `Workspace` implement this interface, which is what keeps the
455
+ * two from drifting — adding a method here is a compile error until both do.
456
+ */
457
+ interface FileSystem {
458
+ /** Read an object's full contents. Throws `ArchilS3Error` (404) if absent. */
459
+ getObject(key: string): Promise<Uint8Array>;
460
+ /** Create or overwrite an object. */
461
+ putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
462
+ /** Delete an object (idempotent). */
463
+ deleteObject(key: string): Promise<void>;
464
+ /** List objects and common (directory) prefixes under a key prefix. */
465
+ listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
466
+ /** Constant-time parallel grep. */
467
+ grep(opts: GrepOptions): Promise<GrepResult>;
468
+ /** Run a command in a sandbox with the filesystem mounted. */
469
+ exec(command: string): Promise<ExecResult>;
470
+ }
471
+ //#endregion
472
+ //#region src/types.d.ts
473
+ type DiskResponse = components["schemas"]["DiskResponse"];
474
+ type MountResponse = components["schemas"]["MountResponse"];
475
+ type MountConfigResponse = components["schemas"]["MountConfigResponse"];
476
+ type DiskMetrics = components["schemas"]["DiskMetrics"];
477
+ type ConnectedClient = components["schemas"]["ConnectedClient"];
478
+ type AuthorizedUser = components["schemas"]["AuthorizedUser"];
479
+ type CreateDiskRequest = components["schemas"]["CreateDiskRequest"];
480
+ type RootAttrs = components["schemas"]["RootAttrs"];
481
+ type MountConfig = components["schemas"]["MountConfig"];
482
+ type S3Mount = components["schemas"]["S3Mount"];
483
+ type GCSMount = components["schemas"]["GCSMount"];
484
+ type R2Mount = components["schemas"]["R2Mount"];
485
+ type S3CompatibleMount = components["schemas"]["S3CompatibleMount"];
486
+ type AzureBlobMount = components["schemas"]["AzureBlobMount"];
487
+ type Delegation = components["schemas"]["DelegationEntry"];
488
+ type Branch = components["schemas"]["BranchResponse"];
489
+ type DiskUser = components["schemas"]["DiskUser"];
490
+ type TokenUser = components["schemas"]["TokenUser"];
491
+ type AwsStsUser = components["schemas"]["AwsStsUser"];
492
+ type S3User = components["schemas"]["S3User"];
493
+ type CreateApiTokenRequest = components["schemas"]["CreateApiTokenRequest"];
494
+ type ApiTokenResponse = components["schemas"]["ApiTokenResponse"];
495
+ type ExecDiskResult = components["schemas"]["ExecDiskResult"];
496
+ type ExecRequest = components["schemas"]["ExecRequest"];
497
+ type GrepDiskResult = components["schemas"]["GrepDiskResult"];
498
+ type GrepMatch = components["schemas"]["GrepMatch"];
499
+ type GrepGroup = components["schemas"]["GrepGroup"];
500
+ type GrepGroupLine = components["schemas"]["GrepGroupLine"];
501
+ type GrepStoppedReason = components["schemas"]["GrepStoppedReason"];
502
+ type DiskStatus = DiskResponse["status"];
503
+ //#endregion
504
+ //#region src/disk.d.ts
505
+ interface MountOptions {
506
+ authToken?: string;
507
+ logLevel?: string;
508
+ serverAddress?: string;
509
+ insecure?: boolean;
510
+ }
511
+ interface CreateBranchOptions {
512
+ /** 1-100 letters, digits, hyphens, or underscores. Unique across the disk. */
513
+ name: string;
514
+ /** Name of a committed checkpoint on the source. */
515
+ fromCheckpoint: string;
516
+ /** Branch the checkpoint was taken on. Omit to branch from the root disk. */
517
+ fromBranch?: string;
518
+ /**
519
+ * UUID identifying this create. Pass the same key (and options) when you
520
+ * retry a create yourself, so a retry of one that succeeded returns that
521
+ * branch instead of a 409. Defaults to a fresh key per call; the SDK's own
522
+ * retries always reuse it.
523
+ */
524
+ idempotencyKey?: string;
525
+ }
526
+ type ExecResult = ExecDiskResult;
527
+ type GrepResult = GrepDiskResult;
528
+ interface GrepOptions {
529
+ /**
530
+ * Directory on the disk to search, relative to the disk root. An empty
531
+ * string or "/" means the disk root.
532
+ */
533
+ directory: string;
534
+ /**
535
+ * Regular expression in ripgrep syntax. A newline separates alternative
536
+ * patterns, except with `multiline`, where it matches a line break.
537
+ */
538
+ pattern: string;
539
+ /** Walk subdirectories breadth-first. Defaults to false. */
540
+ recursive?: boolean;
541
+ /** Wall-clock deadline for the entire request. Defaults to 30s. */
542
+ maxDurationSeconds?: number;
543
+ /**
544
+ * Maximum number of parallel grep workers. Higher values finish larger
545
+ * datasets within the deadline but consume more runtime capacity. The
546
+ * controlplane clamps this to the fleet's currently-available capacity.
547
+ * Defaults to 50.
548
+ */
549
+ concurrency?: number;
550
+ /**
551
+ * Stop scanning once the aggregator has this many matches. Returned
552
+ * matches are a sample of whichever workers reported first, not the
553
+ * lexicographically first N. Defaults to 1000.
554
+ */
555
+ maxResults?: number;
556
+ /** Match the pattern case-insensitively (`rg -i`). Defaults to false. */
557
+ ignoreCase?: boolean;
558
+ /**
559
+ * Let a match span lines (`rg -U`): `\n` in the pattern matches a line
560
+ * break, and `.` matches one only after `(?s)`. Files with Windows line
561
+ * endings need `\r?\n`. Matches on adjacent lines come back as one match
562
+ * with `endLine` set, and count once toward `maxResults`. Defaults to false.
563
+ */
564
+ multiline?: boolean;
565
+ /**
566
+ * Path globs with ripgrep's `-g` rules, matched against paths relative to
567
+ * `directory`. A leading `!` excludes. If any non-`!` glob is given, files
568
+ * that match no glob are skipped. A file a glob matches is searched or
569
+ * skipped regardless of `types` and `typesNot`.
570
+ */
571
+ globs?: string[];
572
+ /** Only search files of these ripgrep types (for example `py`, `ts`). */
573
+ types?: string[];
574
+ /** Skip files of these ripgrep types. Takes precedence over `types`. */
575
+ typesNot?: string[];
576
+ /**
577
+ * Lines of context to return before each match (`rg -B`), 0 to 10. When
578
+ * either context field is set, the result includes `groups`.
579
+ */
580
+ contextBefore?: number;
581
+ /**
582
+ * Lines of context to return after each match (`rg -A`), 0 to 10. When
583
+ * either context field is set, the result includes `groups`.
584
+ */
585
+ contextAfter?: number;
586
+ }
587
+ interface ShareUrlOptions {
588
+ /**
589
+ * Lifetime of the URL in seconds — any positive integer, up to 604800
590
+ * (7 days). Defaults to 86400 (24 hours).
591
+ */
592
+ expiresIn?: number;
593
+ }
594
+ interface ShareUrlResult {
595
+ /** Public, signed, time-limited URL that downloads the file. */
596
+ url: string;
597
+ /** Lifetime of the URL in seconds. */
598
+ expiresIn: number;
599
+ }
600
+ interface ListObjectsOptions {
601
+ /**
602
+ * List the entire subtree under the prefix. When false (the default), only
603
+ * the immediate level is returned — direct objects in `objects` and
604
+ * subdirectory prefixes in `commonPrefixes`, like listing a single directory.
605
+ * When true, every key under the prefix is returned flat (and
606
+ * `commonPrefixes` is empty).
607
+ */
608
+ recursive?: boolean;
609
+ /**
610
+ * Return only the first page instead of auto-paginating. By default
611
+ * listObjects follows continuation tokens until the listing is exhausted and
612
+ * returns every matching key. With `singlePage: true` it makes one request
613
+ * and the result carries `isTruncated` / `nextContinuationToken` so you can
614
+ * page manually (pass the token back via `continuationToken`).
615
+ */
616
+ singlePage?: boolean;
617
+ /**
618
+ * Stop after this many objects total (only meaningful when auto-paginating).
619
+ * The result's `isTruncated` is true if the cap cut the listing short.
620
+ */
621
+ limit?: number;
622
+ /** Start listing from this continuation token (from a prior `nextContinuationToken`). */
623
+ continuationToken?: string;
624
+ /** Return keys lexicographically after this one. */
625
+ startAfter?: string;
626
+ }
627
+ interface S3Object {
628
+ /** Object key (path on the disk). */
629
+ key: string;
630
+ /** Size in bytes. */
631
+ size: number;
632
+ /** Entity tag (quoted MD5 for single-part objects). */
633
+ etag?: string;
634
+ /** Last-modified time, if reported by the server. */
635
+ lastModified?: Date;
636
+ }
637
+ interface PutObjectResult {
638
+ /** Entity tag the server assigned (quoted, per S3 — e.g. `"\"abc123\""`). */
639
+ etag?: string;
640
+ }
641
+ interface ObjectMetadata {
642
+ /** Size in bytes. */
643
+ size: number;
644
+ /** Entity tag (quoted MD5 for single-part objects). */
645
+ etag?: string;
646
+ /** MIME type the object was stored with, if any. */
647
+ contentType?: string;
648
+ /** Last-modified time, if reported by the server. */
649
+ lastModified?: Date;
650
+ }
651
+ interface ListObjectsResult {
652
+ /** Objects in this page. */
653
+ objects: S3Object[];
654
+ /** Directory-like prefixes rolled up by `delimiter` (empty if no delimiter). */
655
+ commonPrefixes: string[];
656
+ /** True if more keys exist beyond this page. */
657
+ isTruncated: boolean;
658
+ /** Token to pass as `continuationToken` to fetch the next page. */
659
+ nextContinuationToken?: string;
660
+ /** Number of keys returned in this page. */
661
+ keyCount: number;
662
+ /** The prefix the listing was filtered by, echoed back by the server. */
663
+ prefix?: string;
664
+ }
665
+ /** A part to list in {@link Disk.completeMultipartUpload}. */
666
+ interface UploadPart {
667
+ /** 1-based part number (1..=10000), strictly increasing across the list. */
668
+ partNumber: number;
669
+ /** Entity tag returned by {@link Disk.uploadPart} for this part. */
670
+ etag: string;
671
+ }
672
+ /** Handle to an in-progress multipart upload, returned by {@link Disk.createMultipartUpload}. */
673
+ interface MultipartUpload {
674
+ /** Server-assigned upload id; pass to uploadPart/complete/abort/listParts. */
675
+ uploadId: string;
676
+ /** The object key this upload targets. */
677
+ key: string;
678
+ /** The bucket (disk id) the upload lives in. */
679
+ bucket: string;
680
+ }
681
+ /** The assembled object, returned by {@link Disk.completeMultipartUpload}. */
682
+ interface CompletedMultipartUpload {
683
+ /** Multipart entity tag — S3's `md5(concat(partMd5s))-N` form. */
684
+ etag?: string;
685
+ /** Resource path of the completed object. */
686
+ location?: string;
687
+ /** The bucket (disk id). */
688
+ bucket?: string;
689
+ /** The object key. */
690
+ key?: string;
691
+ }
692
+ /** One part in a {@link Disk.listParts} listing. */
693
+ interface PartInfo {
694
+ /** 1-based part number. */
695
+ partNumber: number;
696
+ /** Entity tag the server assigned to this part. */
697
+ etag?: string;
698
+ /** Size in bytes. */
699
+ size: number;
700
+ /** Time the part was uploaded, if reported. */
701
+ lastModified?: Date;
702
+ }
703
+ interface ListPartsOptions {
704
+ /** Cap parts returned in one page (server clamps to 1000). */
705
+ maxParts?: number;
706
+ /** Return parts after this part number (for pagination). */
707
+ partNumberMarker?: number;
708
+ }
709
+ interface PartListing {
710
+ /** The bucket (disk id), echoed by the server. */
711
+ bucket?: string;
712
+ /** The object key, echoed by the server. */
713
+ key?: string;
714
+ /** The upload id, echoed by the server. */
715
+ uploadId?: string;
716
+ /** Parts in this page, ascending by part number. */
717
+ parts: PartInfo[];
718
+ /** True if more parts exist beyond this page. */
719
+ isTruncated: boolean;
720
+ /** The part-number marker this page started after. */
721
+ partNumberMarker: number;
722
+ /** Pass back as `partNumberMarker` to fetch the next page. */
723
+ nextPartNumberMarker?: number;
724
+ /** Max parts the server was asked to return. */
725
+ maxParts: number;
726
+ }
727
+ /** One in-progress upload in a {@link Disk.listMultipartUploads} listing. */
728
+ interface MultipartUploadSummary {
729
+ /** The object key the upload targets. */
730
+ key: string;
731
+ /** The upload id. */
732
+ uploadId: string;
733
+ /** When the upload was initiated, if reported. */
734
+ initiated?: Date;
735
+ }
736
+ interface ListMultipartUploadsOptions {
737
+ /** Only list uploads whose key begins with this prefix. */
738
+ prefix?: string;
739
+ /** Roll keys up to this delimiter into `commonPrefixes` (S3 supports "/"). */
740
+ delimiter?: string;
741
+ /** Resume listing keys after this one (with `uploadIdMarker`). */
742
+ keyMarker?: string;
743
+ /** Resume listing uploads after this upload id (requires `keyMarker`). */
744
+ uploadIdMarker?: string;
745
+ /** Cap uploads returned in one page (server clamps to 1000). */
746
+ maxUploads?: number;
747
+ }
748
+ interface MultipartUploadListing {
749
+ /** The bucket (disk id), echoed by the server. */
750
+ bucket?: string;
751
+ /** In-progress uploads in this page. */
752
+ uploads: MultipartUploadSummary[];
753
+ /** Key prefixes rolled up by `delimiter` (empty if no delimiter). */
754
+ commonPrefixes: string[];
755
+ /** True if more uploads exist beyond this page. */
756
+ isTruncated: boolean;
757
+ /** The key marker this page started after, echoed back. */
758
+ keyMarker?: string;
759
+ /** The upload-id marker this page started after, echoed back. */
760
+ uploadIdMarker?: string;
761
+ /** Pass back as `keyMarker` (with `nextUploadIdMarker`) for the next page. */
762
+ nextKeyMarker?: string;
763
+ /** Pass back as `uploadIdMarker` (with `nextKeyMarker`) for the next page. */
764
+ nextUploadIdMarker?: string;
765
+ /** The prefix the listing was filtered by, echoed back. */
766
+ prefix?: string;
767
+ /** The delimiter used, echoed back. */
768
+ delimiter?: string;
769
+ /** Max uploads the server was asked to return. */
770
+ maxUploads?: number;
771
+ }
772
+ interface DeleteObjectsOptions {
773
+ /**
774
+ * Quiet mode: the server omits the per-key success list and returns only
775
+ * failures, so the result's `deleted` array is empty. Cuts response size on
776
+ * large batches. Defaults to false.
777
+ */
778
+ quiet?: boolean;
779
+ }
780
+ /** A single per-key failure within a {@link Disk.deleteObjects} batch. */
781
+ interface DeleteObjectsError {
782
+ /** The key that failed to delete. */
783
+ key: string;
784
+ /** S3 error code (e.g. "AccessDenied", "OperationAborted"), if provided. */
785
+ code?: string;
786
+ /** Human-readable failure detail, if provided. */
787
+ message?: string;
788
+ }
789
+ interface DeleteObjectsResult {
790
+ /** Keys the server confirmed deleted (empty in quiet mode). */
791
+ deleted: string[];
792
+ /** Per-key failures; empty when every key was deleted. */
793
+ errors: DeleteObjectsError[];
794
+ }
795
+ /**
796
+ * POSIX attributes to set on a newly created object, sent to the S3 gateway as
797
+ * `x-archil-*` headers. Missing parent directories inherit `uid` / `gid` and
798
+ * use mode `0755`; existing directories are unchanged. All fields are optional
799
+ * — new files default to `root:root 0644`, while directory markers default to
800
+ * `root:root 0755`.
801
+ */
802
+ interface PosixCreateAttrs {
803
+ /** POSIX mode bits for the created file or directory marker. Sent in octal. */
804
+ mode?: number;
805
+ /** Owning user id, e.g. `1000`. */
806
+ uid?: number;
807
+ /** Owning group id, e.g. `1000`. */
808
+ gid?: number;
809
+ }
810
+ interface PutObjectOptions extends PosixCreateAttrs {
811
+ /** MIME type to store the object with. Default "application/octet-stream". */
812
+ contentType?: string;
813
+ /**
814
+ * Bodies larger than this take the multipart path; bodies at or below it take
815
+ * a single PutObject. Defaults to `partSize` (16 MiB), so by default the
816
+ * switch happens at the part size. Set it lower (e.g. 5 MiB) to start using
817
+ * multipart sooner, or to `Infinity` to force a single PutObject.
818
+ */
819
+ multipartThreshold?: number;
820
+ /**
821
+ * Bytes per part on the multipart path. Clamped to a minimum of 5 MiB (the S3
822
+ * floor for every part but the last). Default 16 MiB.
823
+ */
824
+ partSize?: number;
825
+ /** Max parts uploaded in parallel on the multipart path. Default 4. */
826
+ concurrency?: number;
827
+ }
828
+ interface AppendObjectOptions extends PosixCreateAttrs {
829
+ /**
830
+ * MIME type, applied only when the object is newly created. Default
831
+ * "application/octet-stream".
832
+ */
833
+ contentType?: string;
834
+ }
835
+ /**
836
+ * The S3 transport function {@link DiskMultipart} uses, supplied by the owning
837
+ * {@link Disk} so the namespace shares the disk's credential and endpoint.
838
+ * @internal
839
+ */
840
+ type S3RequestFn = (method: "GET" | "PUT" | "DELETE" | "HEAD" | "POST", key: string, opts?: {
841
+ body?: string | Uint8Array | ArrayBuffer;
842
+ contentType?: string;
843
+ query?: Record<string, string | number>;
844
+ retry?: boolean;
845
+ extraHeaders?: Record<string, string>;
846
+ }) => Promise<{
847
+ ok: boolean;
848
+ status: number;
849
+ statusText: string;
850
+ headers: Headers;
851
+ body: Uint8Array;
852
+ }>;
853
+ declare class Disk implements FileSystem {
854
+ readonly id: string;
855
+ readonly name: string;
856
+ readonly organization: string;
857
+ readonly status: DiskStatus;
858
+ readonly provider: string;
859
+ readonly region: string;
860
+ readonly createdAt: string;
861
+ readonly fsHandlerStatus?: string;
862
+ readonly lastAccessed?: string;
863
+ readonly activeDataBytes?: number;
864
+ readonly totalDataBytes?: number;
865
+ /** @deprecated Use {@link activeDataBytes}. */
866
+ readonly dataSize?: number;
867
+ readonly monthlyUsage?: string;
868
+ readonly mounts?: MountResponse[];
869
+ readonly metrics?: DiskMetrics;
870
+ readonly connectedClients?: ConnectedClient[];
871
+ readonly authorizedUsers?: AuthorizedUser[];
872
+ readonly allowedIps?: string[];
873
+ /** Root-directory POSIX attributes recorded at creation, if any. */
874
+ readonly rootAttrs?: RootAttrs;
875
+ /** @internal */
876
+ private readonly _client;
877
+ /** @internal */
878
+ private readonly _archilRegion;
879
+ /** Base URL for the S3-compatible API (port 9000 ingress). Empty if unset. */
880
+ private readonly _s3BaseUrl;
881
+ /** Lazily-constructed multipart namespace (see {@link multipart}). @internal */
882
+ private _multipart?;
883
+ /** @internal */
884
+ constructor(data: DiskResponse, client: ApiClient, archilRegion: string, s3BaseUrl?: string);
885
+ toJSON(): DiskResponse;
886
+ addUser(user: DiskUser): Promise<AuthorizedUser>;
887
+ removeUser(userType: "token" | "awssts" | "s3", identifier: string): Promise<void>;
888
+ createToken(nickname: string): Promise<AuthorizedUser & {
889
+ token: string;
890
+ identifier: string;
891
+ }>;
892
+ removeTokenUser(identifier: string): Promise<void>;
893
+ /**
894
+ * Create an S3 access key pair for this disk's S3 API. The secret key is
895
+ * returned only here. The keys reach the whole disk, read-write unless
896
+ * `readOnly` is set, so keep them server-side and give browsers presigned
897
+ * URLs instead.
898
+ */
899
+ createS3Credentials(options?: Omit<S3User, "type">): Promise<AuthorizedUser & {
900
+ s3AccessKeyId: string;
901
+ s3SecretKey: string;
902
+ identifier: string;
903
+ }>;
904
+ removeS3Credentials(accessKeyId: string): Promise<void>;
905
+ /**
906
+ * List all delegations currently held on this disk. A delegation grants a
907
+ * client exclusive write access to an inode; it has no ID of its own and is
908
+ * identified by the (clientId, inodeId) pair — pass those to
909
+ * `revokeDelegation` to release one. Entries with `isOrphaned: true` are
910
+ * held by clients no longer connected to the disk (disconnected without
911
+ * checking in). `path` is resolved best-effort by the server and may be
912
+ * absent.
913
+ */
914
+ listDelegations(): Promise<Delegation[]>;
915
+ /**
916
+ * Forcibly revoke a delegation, reclaiming write access from a client that
917
+ * is unreachable or crashed without checking its delegations in.
918
+ *
919
+ * Takes the `(clientId, inodeId)` pair identifying the delegation — pass an
920
+ * entry from `listDelegations` directly:
921
+ *
922
+ * ```ts
923
+ * for (const d of await disk.listDelegations()) {
924
+ * if (d.isOrphaned) await disk.revokeDelegation(d);
925
+ * }
926
+ * ```
927
+ */
928
+ revokeDelegation(delegation: Pick<Delegation, "clientId" | "inodeId">): Promise<void>;
929
+ /**
930
+ * Create a branch: an independent, writable fork of this disk that starts
931
+ * from a committed checkpoint. Writes on the branch don't affect its source.
932
+ *
933
+ * Fails with a 409 if a branch with this name already exists or the
934
+ * checkpoint is not yet committed, and a 404 if the checkpoint or
935
+ * `fromBranch` doesn't exist.
936
+ */
937
+ createBranch(options: CreateBranchOptions): Promise<Branch>;
938
+ /** List every branch of this disk, including branches of branches, in no particular order. */
939
+ listBranches(): Promise<Branch[]>;
940
+ getBranch(name: string): Promise<Branch>;
941
+ getAllowedIPs(): Promise<string[]>;
942
+ setAllowedIPs(allowedIps: string[]): Promise<string[]>;
943
+ addAllowedIP(ip: string): Promise<string[]>;
944
+ removeAllowedIP(ip: string): Promise<string[]>;
945
+ delete(): Promise<void>;
946
+ /**
947
+ * Execute a command in a container with this disk mounted.
948
+ * Blocks until the command completes and returns stdout, stderr, and exit code.
949
+ */
950
+ exec(command: string, options?: ExecVmOptions): Promise<ExecResult>;
951
+ /**
952
+ * Constant-time parallel grep across files on this disk. Listing and
953
+ * matching are fanned out across ephemeral exec containers; the request
954
+ * finishes within the supplied time budget regardless of dataset size.
955
+ *
956
+ * The returned `stoppedReason` says whether the search ran to completion
957
+ * or short-circuited on `maxResults` / `maxDurationSeconds`. When
958
+ * stopping early, the matches returned are a sample (whichever workers
959
+ * reported first), not the lexicographically first N.
960
+ */
961
+ grep(opts: GrepOptions): Promise<GrepResult>;
962
+ /**
963
+ * Create a signed, time-limited URL that lets anyone download a single file
964
+ * from this disk without authentication. The returned URL embeds a
965
+ * cryptographically signed token carrying the disk, the file's key, and an
966
+ * expiry — share it directly; no API key is needed to redeem it.
967
+ *
968
+ * @param key Path to the file on the disk (e.g. "reports/2026-01/data.pdf").
969
+ * @param opts `expiresIn` sets the URL lifetime in seconds (any positive
970
+ * integer, max 604800 = 7 days). Defaults to 24h.
971
+ */
972
+ share(key: string, opts?: ShareUrlOptions): Promise<ShareUrlResult>;
973
+ /**
974
+ * Read an object from the disk via the S3-compatible GetObject API and return
975
+ * its full contents as bytes. Throws `ArchilS3Error` if the object does not
976
+ * exist (status 404, code "NoSuchKey") or the request is rejected; use
977
+ * `headObject`/`objectExists` to check existence without throwing.
978
+ *
979
+ * @param key Path on the disk (e.g. "reports/2026-01/data.json")
980
+ */
981
+ getObject(key: string): Promise<Uint8Array>;
982
+ /**
983
+ * Fetch an object's metadata (size, etag, content type, last-modified) without
984
+ * downloading its contents, via the S3-compatible HeadObject API. Returns
985
+ * `null` if the object does not exist.
986
+ *
987
+ * @param key Path on the disk (e.g. "reports/2026-01/data.json")
988
+ */
989
+ headObject(key: string): Promise<ObjectMetadata | null>;
990
+ /** Whether an object exists on the disk (a HeadObject that maps 404 → false). */
991
+ objectExists(key: string): Promise<boolean>;
992
+ /**
993
+ * Write an object to the disk via the S3-compatible API. Handles any size:
994
+ * bodies at or below `multipartThreshold` (defaults to `partSize`, i.e.
995
+ * 16 MiB) go through a single PutObject request; larger bodies are uploaded as
996
+ * a multipart upload — split into `partSize` parts, uploaded with bounded
997
+ * `concurrency` (default 4), and assembled. A failed part aborts the upload so
998
+ * nothing is left half-staged. For manual control over the multipart
999
+ * lifecycle, use the {@link multipart} namespace.
1000
+ *
1001
+ * Faster than exec for large files — no container overhead, no command-length
1002
+ * limits. Returns the entity tag the server assigned (a multipart upload's tag
1003
+ * is S3's `md5(concat(partMd5s))-N` form rather than a plain MD5).
1004
+ *
1005
+ * Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
1006
+ * file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
1007
+ * sandbox). Missing parent directories inherit `uid` / `gid` with mode
1008
+ * `0755`; existing directories remain unchanged. A key ending in `/` creates
1009
+ * an explicit directory marker whose leaf uses the requested attributes.
1010
+ * Defaults are `root:root 0644` for files and `root:root 0755` for directories.
1011
+ *
1012
+ * @param key Path on the disk (e.g. "reports/2026-01/data.json")
1013
+ * @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
1014
+ * @param options Either a content-type string, or {@link PutObjectOptions}
1015
+ * (`contentType`, `multipartThreshold`, `partSize`,
1016
+ * `concurrency`, `mode`, `uid`, `gid`). Content type defaults
1017
+ * to "application/octet-stream".
1018
+ */
1019
+ putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
1020
+ /**
1021
+ * Upload a large body through the multipart lifecycle: split into `partSize`
1022
+ * parts, upload them with bounded concurrency, then complete — aborting the
1023
+ * upload if any part fails so nothing is left half-staged. @internal
1024
+ */
1025
+ private _putMultipart;
1026
+ /**
1027
+ * Append bytes to an object via the S3-compatible PutObject append extension
1028
+ * (`?append=true`). If the object already exists the bytes are appended to it;
1029
+ * if it doesn't, it is created. Returns the entity tag of the full object
1030
+ * after the append.
1031
+ *
1032
+ * Each call may append at most 1 MiB — the server rejects a larger body with
1033
+ * `EntityTooLarge`. To grow an object past that, append in chunks (or use
1034
+ * {@link putObject} for a one-shot large write).
1035
+ *
1036
+ * Unlike most operations this is NOT auto-retried on a transient error:
1037
+ * append isn't idempotent, so retrying a succeeded-but-unacknowledged append
1038
+ * would duplicate the bytes. On a transient failure, re-append yourself only
1039
+ * after confirming the object's size.
1040
+ *
1041
+ * When the object does not yet exist, optional `mode` / `uid` / `gid` set the
1042
+ * POSIX attributes of the newly created file (same headers as
1043
+ * {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
1044
+ * Existing files and directories are unchanged.
1045
+ *
1046
+ * @param key Path on the disk (e.g. "logs/app.log")
1047
+ * @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
1048
+ * @param options Either a content-type string, or {@link AppendObjectOptions}
1049
+ * (`contentType`, `mode`, `uid`, `gid`). Content type defaults
1050
+ * to "application/octet-stream" and applies only when the
1051
+ * object is newly created.
1052
+ */
1053
+ appendObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | AppendObjectOptions): Promise<PutObjectResult>;
1054
+ /**
1055
+ * Delete an object from the disk via the S3-compatible DeleteObject API.
1056
+ * Idempotent: deleting a key that doesn't exist resolves successfully, per
1057
+ * S3 semantics.
1058
+ *
1059
+ * @param key Path on the disk (e.g. "project/dist/server.cjs")
1060
+ */
1061
+ deleteObject(key: string): Promise<void>;
1062
+ /**
1063
+ * List objects on the disk via the S3-compatible ListObjectsV2 API. By
1064
+ * default this follows continuation tokens until the listing is exhausted and
1065
+ * returns every matching key. Use `limit` to cap the total, `singlePage` for a
1066
+ * single request, or {@link listObjectsPages} to stream pages without loading
1067
+ * everything into memory.
1068
+ *
1069
+ * @param prefix Only return keys beginning with this prefix (omit for all).
1070
+ * @param opts Listing and pagination options.
1071
+ */
1072
+ listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
1073
+ /**
1074
+ * Yield ListObjectsV2 pages lazily, following continuation tokens. A
1075
+ * memory-friendly way to process a large listing without materializing it:
1076
+ *
1077
+ * ```ts
1078
+ * for await (const page of disk.listObjectsPages("logs/")) {
1079
+ * for (const obj of page.objects) process(obj);
1080
+ * }
1081
+ * ```
1082
+ *
1083
+ * @param prefix Only return keys beginning with this prefix (omit for all).
1084
+ * @param opts Listing options (`limit` / `singlePage` are ignored here —
1085
+ * control your own loop).
1086
+ */
1087
+ listObjectsPages(prefix?: string, opts?: ListObjectsOptions): AsyncGenerator<ListObjectsResult>;
1088
+ /** Fetch a single ListObjectsV2 page. @internal */
1089
+ private _listObjectsPage;
1090
+ /**
1091
+ * Delete up to many objects in a single S3-compatible DeleteObjects request.
1092
+ * Unlike {@link deleteObject}, failures are reported per key rather than
1093
+ * thrown: the result's `deleted` lists the keys that were removed and
1094
+ * `errors` lists the ones that weren't (with the server's code/message). A
1095
+ * key that didn't exist still counts as deleted, per S3 semantics.
1096
+ *
1097
+ * The server caps a single request at 1000 keys; this method transparently
1098
+ * splits larger inputs into 1000-key batches and merges the results.
1099
+ *
1100
+ * @param keys Object keys to delete.
1101
+ * @param opts `quiet` suppresses the per-key success list server-side.
1102
+ */
1103
+ deleteObjects(keys: string[], opts?: DeleteObjectsOptions): Promise<DeleteObjectsResult>;
1104
+ /**
1105
+ * The advanced, opt-in multipart-upload API. Drive the raw lifecycle
1106
+ * yourself — `create` → `uploadPart` → `complete` (or `abort`), plus
1107
+ * `listParts` / `listUploads`. Most callers don't need this: {@link putObject}
1108
+ * runs the whole lifecycle automatically for large bodies. Reach for it only
1109
+ * when you need manual control (e.g. uploading parts from separate processes),
1110
+ * and note you then own part-size, memory, and concurrency management.
1111
+ */
1112
+ get multipart(): DiskMultipart;
1113
+ /**
1114
+ * Send a single request to the disk's S3-compatible endpoint. This reuses the
1115
+ * control-plane client purely for its credential and transport — the same
1116
+ * `Authorization` header is sent and verified by the same code server-side —
1117
+ * pointed at the S3 host. Returns the response status and fully-buffered body
1118
+ * so callers can inspect both regardless of the verb used.
1119
+ *
1120
+ * The S3 routes (`/{diskId}/{key}` for objects, `/{diskId}` for the bucket)
1121
+ * are not part of the typed control-plane API, so the path and per-request
1122
+ * options are passed untyped. An empty `key` targets the bucket itself (used
1123
+ * by listObjects).
1124
+ *
1125
+ * @internal
1126
+ */
1127
+ private _s3Request;
1128
+ /**
1129
+ * Connect to this disk's data plane via the native ArchilClient.
1130
+ *
1131
+ * Requires the native module to be available (platform-specific .node binary).
1132
+ */
1133
+ mount(opts?: MountOptions): Promise<unknown>;
1134
+ }
1135
+ /**
1136
+ * The advanced, opt-in multipart-upload namespace, reached via {@link Disk.multipart}.
1137
+ * Drives the raw S3 multipart lifecycle — `create` → `uploadPart` → `complete`
1138
+ * (or `abort`), plus `listParts` / `listUploads`. Prefer {@link Disk.putObject},
1139
+ * which runs this lifecycle automatically for large bodies; use this only when
1140
+ * you need manual control, in which case you own part-size, memory, and
1141
+ * concurrency management.
1142
+ */
1143
+ declare class DiskMultipart {
1144
+ private readonly diskId;
1145
+ private readonly s3Request;
1146
+ /** @internal */
1147
+ constructor(diskId: string, s3Request: S3RequestFn);
1148
+ /**
1149
+ * Start a multipart upload (CreateMultipartUpload) and return its `uploadId`.
1150
+ *
1151
+ * @param key Path on the disk the finished object will live at.
1152
+ * @param contentType MIME type to store the object with.
1153
+ * @param attrs Optional POSIX `mode` / `uid` / `gid` for the completed
1154
+ * object (see {@link PosixCreateAttrs}).
1155
+ */
1156
+ create(key: string, contentType?: string, attrs?: PosixCreateAttrs): Promise<MultipartUpload>;
1157
+ /**
1158
+ * Upload one part (UploadPart) and return its entity tag, which you must
1159
+ * collect (with its part number) and pass to {@link complete}. Every part
1160
+ * except the last must be at least 5 MiB.
1161
+ *
1162
+ * @param key The upload's object key.
1163
+ * @param uploadId The id from {@link create}.
1164
+ * @param partNumber 1-based part number (1..=10000).
1165
+ * @param body Part contents as a string, Uint8Array/Buffer, or ArrayBuffer.
1166
+ */
1167
+ uploadPart(key: string, uploadId: string, partNumber: number, body: string | Uint8Array | ArrayBuffer): Promise<UploadPart>;
1168
+ /**
1169
+ * Finish a multipart upload (CompleteMultipartUpload), assembling the listed
1170
+ * parts into one object. Parts are sorted by part number before submission
1171
+ * (the server requires strictly-increasing order).
1172
+ *
1173
+ * Unlike the other operations this is NOT auto-retried on a transient error:
1174
+ * the gateway isn't idempotent for completion, so a retry after a
1175
+ * successful-but-unacknowledged complete would return a spurious NoSuchUpload.
1176
+ * On a transient failure, re-drive completion yourself only after confirming
1177
+ * the object isn't already present.
1178
+ *
1179
+ * @param key The upload's object key.
1180
+ * @param uploadId The id from {@link create}.
1181
+ * @param parts The `{ partNumber, etag }` pairs from {@link uploadPart}.
1182
+ */
1183
+ complete(key: string, uploadId: string, parts: UploadPart[]): Promise<CompletedMultipartUpload>;
1184
+ /**
1185
+ * Abort a multipart upload (AbortMultipartUpload), discarding every staged
1186
+ * part. Idempotent against an upload that's already gone (404 / NoSuchUpload
1187
+ * resolves successfully).
1188
+ *
1189
+ * @param key The upload's object key.
1190
+ * @param uploadId The id from {@link create}.
1191
+ */
1192
+ abort(key: string, uploadId: string): Promise<void>;
1193
+ /**
1194
+ * List the parts already uploaded for an in-progress upload (ListParts).
1195
+ * Returns a single page; follow `nextPartNumberMarker` (when `isTruncated`)
1196
+ * to page through the rest.
1197
+ *
1198
+ * @param key The upload's object key.
1199
+ * @param uploadId The id from {@link create}.
1200
+ * @param opts `maxParts` / `partNumberMarker` pagination controls.
1201
+ */
1202
+ listParts(key: string, uploadId: string, opts?: ListPartsOptions): Promise<PartListing>;
1203
+ /**
1204
+ * List in-progress multipart uploads on the disk (ListMultipartUploads).
1205
+ * Returns a single page; follow `nextKeyMarker` / `nextUploadIdMarker` (when
1206
+ * `isTruncated`) for the rest.
1207
+ *
1208
+ * @param opts Prefix/delimiter filter and pagination markers.
1209
+ */
1210
+ listUploads(opts?: ListMultipartUploadsOptions): Promise<MultipartUploadListing>;
1211
+ }
1212
+ /**
1213
+ * Choose the part size for a `totalBytes` multipart upload. Returns
1214
+ * `requestedPartSize` unless splitting at that size would exceed the server's
1215
+ * 10,000-part cap, in which case it grows the part size (rounded up to a whole
1216
+ * MiB) so the body fits in ≤ 10,000 parts — mirroring boto3's chunk-size
1217
+ * adjustment. Parts only ever get larger, so they stay above the 5 MiB floor.
1218
+ */
1219
+ declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
1220
+ //#endregion
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 };