disk 1.11.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,698 +1,5 @@
1
- import { $ as MountResponse, A as effectiveUploadPartSize, B as DiskMetrics, C as PosixCreateAttrs, D as ShareUrlOptions, E as S3Object, F as Branch, G as ExecRequest, H as DiskStatus, I as ConnectedClient, J as GrepGroupLine, K as GCSMount, L as CreateApiTokenRequest, M as AuthorizedUser, N as AwsStsUser, O as ShareUrlResult, P as AzureBlobMount, Q as MountConfigResponse, R as CreateDiskRequest, S as PartListing, T as PutObjectResult, U as DiskUser, V as DiskResponse, W as ExecDiskResult, X as GrepStoppedReason, Y as GrepMatch, Z as MountConfig, _ as MultipartUpload, a as DeleteObjectsOptions, at as TokenUser, b as ObjectMetadata, c as DiskMultipart, ct as ArchilTlsOptions, d as GrepResult, et as R2Mount, f as ListMultipartUploadsOptions, g as MountOptions, h as ListPartsOptions, i as DeleteObjectsError, it as S3User, j as ApiTokenResponse, k as UploadPart, l as ExecResult, m as ListObjectsResult, n as CompletedMultipartUpload, nt as S3CompatibleMount, o as DeleteObjectsResult, ot as FileSystem, p as ListObjectsOptions, q as GrepGroup, r as CreateBranchOptions, rt as S3Mount, s as Disk, st as ApiClient, t as AppendObjectOptions, tt as RootAttrs, u as GrepOptions, v as MultipartUploadListing, w as PutObjectOptions, x as PartInfo, y as MultipartUploadSummary, z as Delegation } from "./disk-BmBSYT8h.cjs";
2
- import { components } from "@archildata/api-types";
1
+ import { $ as ApiTokenResponse, $t as SandboxFileWriter, A as DiskMultipart, At as ExecVmOptions, B as MultipartUploadListing, Bt as SandboxMount, C as AppendObjectOptions, Ct as RootAttrs, D as DeleteObjectsOptions, Dt as TokenUser, E as DeleteObjectsError, Et as S3User, F as ListObjectsOptions, Ft as SandboxEgressPolicy, G as PosixCreateAttrs, Gt as SandboxPortTokenPage, H as ObjectMetadata, Ht as SandboxNetwork, I as ListObjectsResult, It as SandboxEgressRule, J as S3Object, Jt as SandboxStatus, K as PutObjectOptions, Kt as SandboxResponse, L as ListPartsOptions, Lt as SandboxEgressTransform, M as GrepOptions, Mt as CreatedSandboxPortToken, N as GrepResult, Nt as ListSandboxPortTokensOptions, O as DeleteObjectsResult, Ot as FileSystem, P as ListMultipartUploadsOptions, Pt as Sandbox, Q as effectiveUploadPartSize, Qt as SandboxFileUploadOptions, R as MountOptions, Rt as SandboxEndpoint, S as ListDisksOptions, St as R2Mount, T as CreateBranchOptions, Tt as S3Mount, U as PartInfo, Ut as SandboxNetworkAction, V as MultipartUploadSummary, Vt as SandboxMountSpec, W as PartListing, Wt as SandboxPortToken, X as ShareUrlResult, Xt as SandboxWaitOptions, Y as ShareUrlOptions, Yt as SandboxTimeoutOptions, Z as UploadPart, Zt as SandboxFileSource, _ as Images, _t as GrepMatch, a as ExecOptions, an as SandboxProcessResult, at as CreateApiTokenRequest, b as DiskListPage, bt as MountConfigResponse, c as Tokens, cn as SandboxProcessStream, ct as DiskMetrics, d as Sandboxes, dn as ArchilTlsOptions, dt as DiskUser, en as SandboxFiles, et as AuthorizedUser, f as BuildImageOptions, ft as ExecDiskResult, g as ImageStatus, gt as GrepGroupLine, h as ImageFailureReason, ht as GrepGroup, i as ExecMountSpec, in as SandboxProcessOutputHandler, it as ConnectedClient, j as ExecResult, jt as CreateSandboxPortTokenOptions, k as Disk, kt as ExecNetwork, l as CreateSandboxRequest, ln as SandboxProcesses, lt as DiskResponse, m as Image, mt as GCSMount, n as ArchilOptions, nn as SandboxProcessConnectOptions, nt as AzureBlobMount, o as Workspace, on as SandboxProcessStartOptions, ot as CreateDiskRequest, p as BuildImageRequest, pt as ExecRequest, q as PutObjectResult, qt as SandboxStartOptions, r as ExecMount, rn as SandboxProcessOutput, rt as Branch, s as ListTokensOptions, sn as SandboxProcessStatus, st as Delegation, t as Archil, tn as SandboxProcess, tt as AwsStsUser, u as ListSandboxesOptions, un as SandboxTerminalOptions, ut as DiskStatus, v as RegistryAuth, vt as GrepStoppedReason, w as CompletedMultipartUpload, wt as S3CompatibleMount, x as Disks, xt as MountResponse, y as CreateDiskResult, yt as MountConfig, z as MultipartUpload, zt as SandboxForkOptions } from "./archil-CLQrudfP.cjs";
3
2
 
4
- //#region src/disks.d.ts
5
- interface ListDisksOptions {
6
- /** Cap on the total number of disks returned. */
7
- limit?: number;
8
- /** Resume listing from a previous page's `nextCursor`. */
9
- cursor?: string;
10
- name?: string;
11
- }
12
- interface DiskListPage {
13
- disks: Disk[];
14
- /**
15
- * Set when more disks remain beyond this page; pass it back as `cursor` to
16
- * fetch the next one. Undefined on the last page.
17
- */
18
- nextCursor?: string;
19
- }
20
- interface CreateDiskResult {
21
- disk: Disk;
22
- token: string | null;
23
- tokenIdentifier: string | null;
24
- authorizedUsers: AuthorizedUser[];
25
- }
26
- declare class Disks {
27
- /** @internal */
28
- private readonly _client;
29
- /** @internal */
30
- private readonly _region;
31
- /** @internal */
32
- private readonly _s3BaseUrl?;
33
- /** @internal */
34
- constructor(client: ApiClient, region: string, s3BaseUrl?: string);
35
- /**
36
- * List the account's disks. Fetches in cursor-driven pages (bounded server
37
- * work per request) and follows `nextCursor` until exhausted, so the result
38
- * is complete even for very large accounts. Use `limit` to cap the total, or
39
- * {@link listPage} to walk pages yourself.
40
- */
41
- list(opts?: ListDisksOptions): Promise<Disk[]>;
42
- /**
43
- * Fetch a single page of disks. `nextCursor` on the result resumes the
44
- * listing (it can also be persisted, e.g. across requests of a paginated UI).
45
- */
46
- listPage(opts?: ListDisksOptions): Promise<DiskListPage>;
47
- get(id: string): Promise<Disk>;
48
- /**
49
- * Create a new disk with an auto-generated mount token.
50
- *
51
- * Returns the Disk, the one-time token (save it — it cannot be retrieved
52
- * again), and the token identifier for later management.
53
- *
54
- * `rootAttrs` sets the POSIX owner and mode of the disk's root directory
55
- * (e.g. `{ uid: 1000, gid: 1000, mode: 0o755 }` so an unprivileged process
56
- * can create entries under the mount root without a post-mount `chown`).
57
- * Creation-time only.
58
- */
59
- create(req: CreateDiskRequest): Promise<CreateDiskResult>;
60
- /**
61
- * Execute a command on a disk that is already known to exist. Accepts the
62
- * disk ID directly so callers that do not need its metadata can execute
63
- * without fetching the disk first.
64
- */
65
- exec(id: string, command: string): Promise<ExecResult>;
66
- }
67
- //#endregion
68
- //#region src/images.d.ts
69
- type ImageWire = components["schemas"]["Image"];
70
- type ImageStatus = components["schemas"]["ImageState"];
71
- /**
72
- * Why a build failed. `invalid_source`: the registry reported the image missing
73
- * or denied access, so retrying won't help. `interrupted`: the build did not
74
- * finish; requesting it again starts a new build.
75
- */
76
- type ImageFailureReason = NonNullable<ImageWire["failure_reason"]>;
77
- interface Image {
78
- /** 64-character hex id; pass it to `sandboxes.create({ imageId })`. */
79
- imageId: string;
80
- /** Normalized OCI reference. */
81
- source: string;
82
- private: boolean;
83
- status: ImageStatus;
84
- /** `sha256:` digest of the last successful build, kept while a tag rebuilds. */
85
- digest?: string;
86
- /** `repo@sha256:` reference of the last successful build. */
87
- canonicalSource?: string;
88
- /** Present only when `status` is `failed`. */
89
- failureReason?: ImageFailureReason;
90
- createdAt: Date;
91
- updatedAt: Date;
92
- }
93
- /** Registry credentials for a private image. Archil never stores them. */
94
- type RegistryAuth = components["schemas"]["RegistryAuth"];
95
- interface BuildImageRequest {
96
- /** OCI image reference, such as `node:24-bookworm` or `ghcr.io/owner/app@sha256:<digest>`. */
97
- source: string;
98
- /** Required for private images on every build request; without it `source` names the public image. */
99
- registryAuth?: RegistryAuth;
100
- }
101
- interface BuildImageOptions {
102
- /** Seconds to wait for the build. Defaults to 1800 (30 minutes). */
103
- timeoutSeconds?: number;
104
- }
105
- declare class Images {
106
- /** @internal */
107
- private readonly _client;
108
- /** @internal */
109
- constructor(client: ApiClient);
110
- get(imageId: string): Promise<Image>;
111
- /**
112
- * Build a sandbox image from an OCI reference and wait until it is ready.
113
- * Returns at once when the image is already built from a digest reference
114
- * and joins a build that is already running. A tag is rebuilt on each call
115
- * in case it moved, so call this once and reuse `imageId`. Interrupted
116
- * builds are requested again up to three times; other failures throw
117
- * {@link ImageBuildError}.
118
- */
119
- build(request: BuildImageRequest, options?: BuildImageOptions): Promise<Image>;
120
- private _request;
121
- }
122
- //#endregion
123
- //#region src/sandbox-process.d.ts
124
- type SandboxProcessStatus = "running" | "completed" | "failed" | "cancelled" | "timed_out";
125
- type SandboxProcessStream = "stdout" | "stderr";
126
- interface SandboxProcessOutput {
127
- stream: SandboxProcessStream;
128
- offset: number;
129
- data: Uint8Array;
130
- }
131
- type SandboxProcessOutputHandler = (output: SandboxProcessOutput) => void;
132
- interface SandboxTerminalOptions {
133
- cols?: number;
134
- rows?: number;
135
- }
136
- interface SandboxProcessConnectOptions {
137
- offset?: number;
138
- onOutput?: SandboxProcessOutputHandler;
139
- /** Retain decoded stdout and stderr on the handle and result. Defaults to true. */
140
- collectOutput?: boolean;
141
- }
142
- interface SandboxProcessStartOptions {
143
- /** Absolute working directory inside the sandbox. */
144
- cwd?: string;
145
- /** Enables a PTY. PTY output is merged into stdout and stderr remains empty. */
146
- terminal?: boolean | SandboxTerminalOptions;
147
- env?: Record<string, string>;
148
- timeoutSeconds?: number;
149
- onOutput?: SandboxProcessOutputHandler;
150
- /** Retain decoded stdout and stderr on the handle and result. Defaults to true. */
151
- collectOutput?: boolean;
152
- }
153
- interface SandboxProcessResult {
154
- status: Exclude<SandboxProcessStatus, "running">;
155
- exitCode?: number;
156
- exitReason?: string;
157
- stdout: string;
158
- stderr: string;
159
- }
160
- type ProcessConnectionRequest = {
161
- type: "start";
162
- command: string;
163
- cwd?: string;
164
- terminal?: boolean | {
165
- cols: number;
166
- rows: number;
167
- };
168
- env: Record<string, string>;
169
- timeout_seconds?: number;
170
- } | {
171
- type: "attach";
172
- process_id: string;
173
- offset: number;
174
- };
175
- type ProcessControlRequest = {
176
- type: "kill";
177
- process_id: string;
178
- } | {
179
- type: "resize";
180
- process_id: string;
181
- cols: number;
182
- rows: number;
183
- };
184
- /** @deprecated Use Sandbox.run() and Sandbox.attach(). Removed in the next version. */
185
- declare class SandboxProcesses {
186
- private readonly _sandbox;
187
- /** @internal */
188
- constructor(_sandbox: Pick<Sandbox, "run" | "attach">);
189
- /** @deprecated Use sandbox.run(). Removed in the next version. */
190
- start(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
191
- /** @deprecated Use sandbox.attach(). Removed in the next version. */
192
- connect(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
193
- }
194
- declare class SandboxProcess {
195
- status: SandboxProcessStatus;
196
- stdout: string;
197
- stderr: string;
198
- private _id;
199
- private _cursor;
200
- private readonly _onOutput?;
201
- private readonly _collectOutput;
202
- private readonly _connectionUrl;
203
- private readonly _controlProcess;
204
- private readonly _stdoutDecoder;
205
- private readonly _stderrDecoder;
206
- private readonly _terminal;
207
- private _resolveTerminal;
208
- private _result?;
209
- private _socket?;
210
- private _connectionClosed?;
211
- private _connectionError?;
212
- private _stdinClosed;
213
- /** @internal */
214
- constructor(processId: string, cursor: number, onOutput: SandboxProcessOutputHandler | undefined, collectOutput: boolean, connectionUrl: () => Promise<string>, controlProcess: (request: ProcessControlRequest) => Promise<void>);
215
- get id(): string;
216
- get cursor(): number;
217
- get connected(): boolean;
218
- sendInput(data: string | Uint8Array): Promise<void>;
219
- resize(size: {
220
- cols: number;
221
- rows: number;
222
- }): Promise<void>;
223
- /** Close stdin. Piped processes only. */
224
- closeStdin(): Promise<void>;
225
- /** Close this client connection without terminating the process. */
226
- disconnect(): Promise<void>;
227
- wait(): Promise<SandboxProcessResult>;
228
- kill(): Promise<void>;
229
- /** @internal */
230
- _connect(request: ProcessConnectionRequest): Promise<void>;
231
- private _openSocket;
232
- private _sendControl;
233
- private _sendInput;
234
- private _handleMessage;
235
- private _handleOutput;
236
- private _appendText;
237
- private _flushDecoders;
238
- private _finish;
239
- }
240
- //#endregion
241
- //#region src/sandbox-files.d.ts
242
- type SandboxFileSource = Uint8Array | ArrayBuffer | Blob | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>;
243
- type SandboxFileWriter = (chunk: Uint8Array) => void | Promise<void>;
244
- interface SandboxFileUploadOptions {
245
- mode?: number;
246
- }
247
- declare class SandboxFiles {
248
- private readonly _sandbox;
249
- /** @internal */
250
- constructor(sandbox: Pick<Sandbox, "run">);
251
- uploadFile(source: SandboxFileSource, remotePath: string, options?: SandboxFileUploadOptions): Promise<void>;
252
- downloadFile(remotePath: string, write: SandboxFileWriter): Promise<void>;
253
- }
254
- //#endregion
255
- //#region src/sandbox.d.ts
256
- type SandboxNetworkAction = components["schemas"]["SandboxNetworkAction"];
257
- type SandboxEgressPolicy = components["schemas"]["SandboxEgressPolicy"] & {
258
- /** Host patterns supporting * anywhere. All paths count; selectors do not grant network access. */drain_on_pause?: string[];
259
- };
260
- type SandboxEgressRule = components["schemas"]["SandboxEgressRule"];
261
- type SandboxEgressTransform = components["schemas"]["SandboxEgressTransform"];
262
- type SandboxNetwork = Omit<components["schemas"]["SandboxNetwork"], "egress"> & {
263
- egress?: SandboxEgressPolicy;
264
- };
265
- /** @internal */
266
- type SandboxWire = components["schemas"]["Sandbox"];
267
- /**
268
- * One Archil disk to mount inside a sandbox. `path` is the absolute guest
269
- * directory; it may be omitted only for a sole mount, which then lands at
270
- * `/mnt/archil`. A plain mount is exclusive and `queueMs` bounds the wait for
271
- * its root delegation; `readOnly` and `conditional` mounts never take it.
272
- */
273
- interface SandboxMountSpec extends Omit<ExecMountSpec, "checkoutPaths" | "queueMs"> {
274
- path?: string;
275
- /**
276
- * Milliseconds a plain mount waits for the disk's exclusive root delegation
277
- * before the boot fails. Cannot be combined with `readOnly` or `conditional`.
278
- */
279
- queueMs?: number;
280
- }
281
- /** An Archil disk mounted inside the sandbox, as currently configured. */
282
- interface SandboxMount {
283
- diskId: string;
284
- /** Absolute guest directory the disk is mounted at. */
285
- path: string;
286
- subdirectory?: string;
287
- readOnly: boolean;
288
- conditional: boolean;
289
- queueMs?: number;
290
- }
291
- type SandboxStatus = components["schemas"]["SandboxState"];
292
- interface SandboxEndpoint {
293
- port: number;
294
- hostname: string;
295
- }
296
- /** Port-token metadata. The secret and hostname are returned only on creation. */
297
- interface SandboxPortToken {
298
- id: string;
299
- port: number;
300
- createdAt: Date;
301
- expiresAt?: Date;
302
- }
303
- interface CreatedSandboxPortToken extends SandboxPortToken {
304
- hostname: string;
305
- /** Send in X-Archil-Token. Save it now; it cannot be retrieved again. */
306
- token: string;
307
- }
308
- interface CreateSandboxPortTokenOptions {
309
- /** Duration such as "1h" or "30m", up to "8760h" (365 days). Omit for no expiration. */
310
- ttl?: string;
311
- }
312
- interface ListSandboxPortTokensOptions {
313
- limit?: number;
314
- cursor?: string;
315
- }
316
- interface SandboxPortTokenPage {
317
- tokens: SandboxPortToken[];
318
- nextCursor?: string;
319
- }
320
- interface SandboxResponse {
321
- id: string;
322
- name: string;
323
- status: SandboxStatus;
324
- vcpuCount: number;
325
- memSizeMiB: number;
326
- /** Empty for sandboxes created from `imageId`. */
327
- baseImage: string;
328
- /** Digest of the image the sandbox was created from; may be empty. */
329
- imageDigest: string;
330
- platform?: "arm64" | "amd64";
331
- maxTtlSeconds: number;
332
- idleTtlSeconds: number;
333
- /** Maximum concurrently attached process sessions. Detached processes and one-shot controls do not count. */
334
- maxConcurrentExecs: number;
335
- endpoints?: SandboxEndpoint[];
336
- /** Disks mounted inside the guest on every boot. */
337
- mounts: SandboxMount[];
338
- createdAt: Date;
339
- runningAt?: Date;
340
- finishedAt?: Date;
341
- lastActiveAt: Date;
342
- exitReason?: string;
343
- /** Disk checkpoint the current session leaves behind; present while pausing, paused, stopping, or stopped. */
344
- checkpoint?: string;
345
- }
346
- interface SandboxWaitOptions {
347
- /**
348
- * Wait for the operation to finish. Defaults to true.
349
- * The SDK polls if the server's wait budget expires first.
350
- */
351
- wait?: boolean;
352
- }
353
- interface SandboxStartOptions extends SandboxWaitOptions {
354
- /**
355
- * Replace the sandbox's disk mounts for this and later sessions. Omit to
356
- * keep the current ones. A cold start only: resume keeps the paused
357
- * session's mounts.
358
- */
359
- mounts?: SandboxMountSpec[];
360
- }
361
- interface SandboxForkOptions extends SandboxWaitOptions {
362
- /** Name for the fork. The server generates one when omitted. */
363
- name?: string;
364
- }
365
- interface SandboxTimeoutOptions {
366
- /** Hard lifetime in seconds. Omit to leave its deadline unchanged. */
367
- timeoutSeconds?: number;
368
- /** Seconds without a direct process connection. Zero disables idle expiry; omit to leave unchanged. */
369
- idleTtlSeconds?: number;
370
- }
371
- declare class Sandbox {
372
- id: string;
373
- name: string;
374
- status: SandboxStatus;
375
- vcpuCount: number;
376
- memSizeMiB: number;
377
- baseImage: string;
378
- imageDigest: string;
379
- platform?: "arm64" | "amd64";
380
- maxTtlSeconds: number;
381
- idleTtlSeconds: number;
382
- maxConcurrentExecs: number;
383
- endpoints?: SandboxEndpoint[];
384
- mounts: SandboxMount[];
385
- createdAt: Date;
386
- runningAt?: Date;
387
- finishedAt?: Date;
388
- lastActiveAt: Date;
389
- exitReason?: string;
390
- checkpoint?: string;
391
- /** @deprecated Use run() and attach(). Removed in the next version. */
392
- readonly processes: SandboxProcesses;
393
- readonly files: SandboxFiles;
394
- /** @internal */
395
- private readonly _client;
396
- /** @internal */
397
- constructor(data: SandboxWire, client: ApiClient);
398
- /** @internal Overwrite this sandbox's fields in place from a fresh wire snapshot. */
399
- private _apply;
400
- toJSON(): SandboxResponse;
401
- /** Start a process and return its handle without waiting for exit. */
402
- run(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcess>;
403
- /** Reattach to a process, optionally resuming output from a cursor. */
404
- attach(processId: string, options?: SandboxProcessConnectOptions): Promise<SandboxProcess>;
405
- private _connectionUrl;
406
- private _control;
407
- /** Run a process and wait for it to exit. */
408
- exec(command: string, options?: SandboxProcessStartOptions): Promise<SandboxProcessResult>;
409
- /** Re-fetch this sandbox. */
410
- refresh(): Promise<this>;
411
- /** Start this sandbox. */
412
- start(options?: SandboxStartOptions): Promise<Sandbox | this>;
413
- /** Stop this sandbox. */
414
- stop(options?: SandboxWaitOptions): Promise<Sandbox | this>;
415
- /** Pause this sandbox, preserving its CPU and memory state. */
416
- pause(options?: SandboxWaitOptions): Promise<this>;
417
- /** Resume this sandbox from its preserved CPU and memory state. */
418
- resume(options?: SandboxWaitOptions): Promise<Sandbox | this>;
419
- /**
420
- * Create an isolated writable branch from this sandbox's current state.
421
- * A running sandbox is paused for the snapshot and resumed once the fork is
422
- * accepted; a paused or stopped sandbox is left as it is. The fork names the
423
- * checkpoint the pause returned, so it does not depend on the source still
424
- * being paused when the request lands. Resuming the source is best effort:
425
- * the child is returned even if the source could not be resumed, so check
426
- * the source's status afterwards if that matters.
427
- */
428
- fork(options?: SandboxForkOptions): Promise<Sandbox>;
429
- /** Expose a TCP port publicly (1–65535), returning its hostname. */
430
- exposePort(port: number): Promise<string>;
431
- /** List explicitly exposed public ports. Service-published ports are in `endpoints`. */
432
- listPorts(): Promise<SandboxEndpoint[]>;
433
- /** Remove explicit public exposure. A service publishing the same port remains reachable. */
434
- unexposePort(port: number): Promise<void>;
435
- /** Authorize HTTP access to one port without making it public. */
436
- createPortToken(port: number, options?: CreateSandboxPortTokenOptions): Promise<CreatedSandboxPortToken>;
437
- /** Get token metadata. Expired and revoked tokens return not found. */
438
- getPortToken(tokenId: string): Promise<SandboxPortToken>;
439
- /** List token metadata across pages. `limit` caps the total number returned. */
440
- listPortTokens(options?: ListSandboxPortTokensOptions): Promise<SandboxPortToken[]>;
441
- /** Fetch one page of token metadata; pass `nextCursor` back as `cursor`. */
442
- listPortTokensPage(options?: ListSandboxPortTokensOptions): Promise<SandboxPortTokenPage>;
443
- /** Revoke a token for new connections. Existing connections remain open. */
444
- deletePortToken(token: SandboxPortToken | string): Promise<void>;
445
- /** Get this running sandbox's effective network policy. */
446
- getNetwork(): Promise<SandboxNetwork>;
447
- /** Replace this running sandbox's complete network policy and return the effective policy. */
448
- updateNetwork(network: SandboxNetwork): Promise<SandboxNetwork>;
449
- /** Update either or both TTLs in seconds. Omitted settings remain unchanged. */
450
- setTimeout(timeout: number | SandboxTimeoutOptions): Promise<this>;
451
- /** Delete this sandbox and its backing disk. */
452
- delete(): Promise<void>;
453
- }
454
- //#endregion
455
- //#region src/sandboxes.d.ts
456
- interface CreateSandboxRequest {
457
- /** Name for the sandbox. The server generates one when omitted. */
458
- name?: string;
459
- /** Number of virtual CPUs allocated to the sandbox, from 1 to 32. Defaults to 1. */
460
- vcpuCount?: number;
461
- /** Memory allocated to the sandbox in MiB, from 256 to 65536. Defaults to 2048. */
462
- memSizeMiB?: number;
463
- /**
464
- * Public Linux OCI image reference for the sandbox's root filesystem.
465
- * Docker Hub shorthand and any public registry are accepted; the tag
466
- * defaults to `latest`, and mutable tags are pinned to immutable digests
467
- * when the sandbox is created. Defaults to `ubuntu:26.04`.
468
- *
469
- * Examples: `ubuntu`, `node:24-bookworm`, `ghcr.io/owner/app:v2`,
470
- * `alpine@sha256:<digest>`.
471
- */
472
- baseImage?: string;
473
- /** Ready image from `images.build()`. Cannot be combined with `baseImage`. */
474
- imageId?: string;
475
- env?: Record<string, string>;
476
- maxTtlSeconds?: number;
477
- /** Seconds without a direct process connection before pausing. Omitted or zero disables idle expiry. */
478
- idleTtlSeconds?: number;
479
- /** Maximum concurrently attached exec sessions. Detached processes and one-shot controls do not count. */
480
- maxConcurrentExecs?: number;
481
- /** Creation-time network policy. Egress is unrestricted when omitted. */
482
- network?: SandboxNetwork;
483
- /** TCP ports to expose publicly, from 1 to 65535. */
484
- ports?: number[];
485
- /**
486
- * Disks mounted inside the guest for the first session; `sandbox.start()`
487
- * can replace them later. A sandbox with mounts must be stopped before it
488
- * is forked.
489
- */
490
- mounts?: SandboxMountSpec[];
491
- }
492
- interface ListSandboxesOptions {
493
- /** Only return sandboxes that mount this disk. */
494
- disk?: Disk | string;
495
- }
496
- declare class Sandboxes {
497
- /** @internal */
498
- private readonly _client;
499
- /** @internal */
500
- constructor(client: ApiClient);
501
- /** List the account's sandboxes, oldest first. */
502
- list(options?: ListSandboxesOptions): Promise<Sandbox[]>;
503
- get(id: string): Promise<Sandbox>;
504
- create(request?: CreateSandboxRequest, options?: SandboxWaitOptions): Promise<Sandbox>;
505
- }
506
- //#endregion
507
- //#region src/tokens.d.ts
508
- interface ListTokensOptions {
509
- limit?: number;
510
- cursor?: string;
511
- }
512
- declare class Tokens {
513
- /** @internal */
514
- private readonly _client;
515
- /** @internal */
516
- constructor(client: ApiClient);
517
- list(opts?: ListTokensOptions): Promise<ApiTokenResponse[]>;
518
- create(req: CreateApiTokenRequest): Promise<ApiTokenResponse & {
519
- token?: string;
520
- }>;
521
- delete(id: string): Promise<void>;
522
- }
523
- //#endregion
524
- //#region src/workspace.d.ts
525
- /** Anything that can run a multi-disk exec — i.e. an `Archil` client. A narrow
526
- * structural type so this module doesn't import the Archil class (avoiding a
527
- * value-import cycle with archil.ts). */
528
- interface WorkspaceExecCapable {
529
- exec(opts: ExecOptions): Promise<ExecResult>;
530
- }
531
- /**
532
- * A key-routed filesystem spanning several Archil disks. Each disk is mounted
533
- * under a name and addressed as the first segment of a key (`<name>/...`);
534
- * `getObject`, `putObject`, `deleteObject`, `listObjects`, and `grep` route to
535
- * the right disk by that segment (and `listObjects` / `grep` fan out across all
536
- * of them when the key/prefix doesn't name one). Implements the same
537
- * {@link FileSystem} surface as a single {@link Disk}, so it works anywhere a
538
- * disk does. Mounts can be changed at runtime with {@link addDisk} /
539
- * {@link removeDisk}.
540
- */
541
- declare class Workspace implements FileSystem {
542
- private readonly client;
543
- private readonly mounts;
544
- /** @internal Use `archil.workspace({ ... })`. */
545
- constructor(client: WorkspaceExecCapable, mounts: Record<string, ExecMount>);
546
- /** Mount (or replace) a disk at `name`; its objects are addressed as
547
- * `<name>/...`. Accepts a `Disk` or a mount spec (read-only / subdirectory /
548
- * conditional / delegation checkouts); a bare disk-id string is rejected —
549
- * fetch the disk first. */
550
- addDisk(name: string, disk: ExecMount): this;
551
- /** Unmount the disk at `name`. Returns whether a disk was removed. Refuses to
552
- * remove the last disk — a workspace must always have at least one (the same
553
- * invariant the constructor enforces), else fan-out/exec would have nothing to
554
- * route to. */
555
- removeDisk(name: string): boolean;
556
- /** The names of the currently-mounted disks. */
557
- diskNames(): string[];
558
- private unknownDisk;
559
- /** Resolve a workspace key (`<name>/...`) to the disk and the disk-relative key. */
560
- private route;
561
- /** Mounts touched by a key prefix; an empty prefix fans out to all of them. */
562
- private covered;
563
- /** Route grep globs written against the workspace root to the mounts they
564
- * can match. A glob that starts with a mount's name goes to that mount without
565
- * the name. One with no `/`, or that starts with `**` + `/` with or without a
566
- * leading `/`, goes to every mount as written, and also applies to a mount it
567
- * names exactly, like `!cache` or `**` + `/logs/**`. Mount names are matched
568
- * literally, so `!l*` doesn't skip a `logs` mount. Leaves out a mount whose
569
- * directory an exclude names, or that no include reaches, and throws for any
570
- * other glob with a `/`. */
571
- private rootGlobs;
572
- /** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
573
- private diskKey;
574
- /** Map a disk key back to its workspace key (`<name>/...`), stripping the mount subdirectory. */
575
- private abs;
576
- getObject(key: string): Promise<Uint8Array>;
577
- putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
578
- deleteObject(key: string): Promise<void>;
579
- listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
580
- /**
581
- * Grep the disks `directory` covers in parallel and merge their results. At
582
- * the workspace root, a glob with a `/` must start with a mount name, like
583
- * `data/src/**`, which applies to that mount only, or with `**` + `/`. A glob
584
- * with no `/`, like `*.ts`, or one starting with `**` + `/` with or without a
585
- * leading `/`, applies inside every mount, and also to a mount it names
586
- * exactly, so `!cache` skips the cache mount. Mount names are matched
587
- * literally, not as patterns: `!l*` applies inside every mount, but doesn't
588
- * skip a mount named `logs`.
589
- */
590
- grep(opts: GrepOptions): Promise<GrepResult>;
591
- exec(command: string): Promise<ExecResult>;
592
- }
593
- //#endregion
594
- //#region src/archil.d.ts
595
- interface ArchilOptions {
596
- /** API key. Falls back to ARCHIL_API_KEY env var if not provided. */
597
- apiKey?: string;
598
- /** Region. Falls back to ARCHIL_REGION env var if not provided. */
599
- region?: string;
600
- /** Override the control plane base URL (useful for testing). */
601
- baseUrl?: string;
602
- /**
603
- * Override the S3-compatible API base URL used by Disk#getObject /
604
- * putObject / deleteObject. Falls back to ARCHIL_S3_BASE_URL, then to the
605
- * control plane URL with its `control.` hostname prefix swapped for `s3.`.
606
- */
607
- s3BaseUrl?: string;
608
- /** Per-client TLS trust for control-plane and S3 requests (Node.js only). */
609
- tls?: ArchilTlsOptions;
610
- }
611
- /**
612
- * Options that apply to a single mounted disk in an exec request.
613
- * Use this object form when you need to pin the mount to a subdirectory
614
- * of the disk, mount it read-only, mount it in conditional mode, or request
615
- * delegation checkouts; for the default case (mount the disk's root,
616
- * read-write with no checkout), pass a `Disk` or disk-id string instead.
617
- */
618
- interface ExecMountSpec {
619
- /** Disk to mount, by `Disk` instance or raw disk id string. */
620
- disk: Disk | string;
621
- /**
622
- * Subdirectory of the disk to expose at the mountpoint. Must be a
623
- * relative path with no `.` or `..` segments. When omitted, the disk's
624
- * root is exposed.
625
- */
626
- subdirectory?: string;
627
- /**
628
- * When true, mount the disk read-only inside the container. Writes
629
- * against the mount fail with EROFS. Defaults to false.
630
- */
631
- readOnly?: boolean;
632
- /**
633
- * When true, mount the disk in conditional mode, which lets this mount
634
- * write without a delegation checkout. This enables concurrent writes from
635
- * multiple clients to the same disk.
636
- * Defaults to false.
637
- */
638
- conditional?: boolean;
639
- /**
640
- * Milliseconds to wait in the delegation queue for each requested checkout.
641
- * If set without `checkoutPaths`, the exposed mount root is acquired during
642
- * mount setup. Cannot be combined with `readOnly: true`.
643
- */
644
- queueMs?: number;
645
- /**
646
- * Paths relative to this disk's exposed mount root to check out before the
647
- * command starts. May be set without `queueMs`; those checkouts try
648
- * immediately without waiting in the delegation queue. Cannot be combined
649
- * with `readOnly: true`.
650
- */
651
- checkoutPaths?: string[];
652
- }
653
- /**
654
- * One disk to mount in an exec request. Either a `Disk`/disk-id string
655
- * (mounts the disk's root, read-write) or an `ExecMountSpec` object that
656
- * additionally selects a subdirectory of the disk and/or marks the mount as
657
- * read-only, conditional, or requests delegation checkouts. Used
658
- * by Archil#exec, where the map key is the relative path under /mnt/archil at
659
- * which to mount the disk.
660
- */
661
- type ExecMount = Disk | string | ExecMountSpec;
662
- interface ExecOptions {
663
- /**
664
- * Disks to mount, keyed by the relative path under `/mnt/archil` at which
665
- * to mount each one. At least one entry is required. Paths must be
666
- * non-empty, non-absolute, and contain no `.` or `..` segments.
667
- */
668
- disks: Record<string, ExecMount>;
669
- /** Shell command to run inside the container. */
670
- command: string;
671
- }
672
- declare class Archil {
673
- readonly disks: Disks;
674
- readonly images: Images;
675
- readonly sandboxes: Sandboxes;
676
- readonly tokens: Tokens;
677
- /** @internal */
678
- private readonly _client;
679
- constructor(opts?: ArchilOptions);
680
- /**
681
- * Run a command in a container with multiple disks mounted simultaneously,
682
- * each at its own relative path under `/mnt/archil`. Blocks until the
683
- * command completes and returns its stdout, stderr, exit code, and timing.
684
- */
685
- exec(opts: ExecOptions): Promise<ExecDiskResult>;
686
- /**
687
- * Build an agent filesystem toolset spanning several disks at once. `mounts`
688
- * maps a relative path to a disk (or `ExecMountSpec`), exactly like
689
- * {@link exec}; each disk appears under `/mnt/archil/<path>`. Hand the result
690
- * to a framework adapter (`createDiskTools(workspace)`) to get tools that route
691
- * file operations by path and fan `grep`/`list_files` out across the disks.
692
- */
693
- workspace(mounts: Record<string, ExecMount>): Workspace;
694
- }
695
- //#endregion
696
3
  //#region src/errors.d.ts
697
4
  /**
698
5
  * Base class for every error the SDK throws. Catch with `instanceof ArchilError`
@@ -775,4 +82,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
775
82
  */
776
83
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
777
84
  //#endregion
778
- export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, type S3User, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
85
+ export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecNetwork, type ExecOptions, type ExecRequest, type ExecResult, type ExecVmOptions, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, type S3User, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };