disk 1.16.0 → 1.16.1-next.20261201221409

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/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # disk
2
2
 
3
- SDK and CLI for [Archil](https://archil.com) disks. Create disks, list and inspect them, manage who can mount them, and run commands against them — all from scripts, CI, or an interactive terminal. It also ships **drop-in [filesystem tools](#filesystem-tools)** for AI SDK, Mastra, and Langchain.
3
+ The TypeScript SDK and CLI for [Archil](https://archil.com) disks and sandboxes. Create
4
+ disks, read and write their files, run commands against them, and start persistent
5
+ sandboxes, from scripts, servers, CI, or a terminal.
4
6
 
5
- `disk` talks to the Archil control plane over HTTPS and has no native dependencies. If you also want to mount a disk's data plane from Node (rare — most users want `disk exec` or the `archil` CLI), install [`@archildata/native`](https://www.npmjs.com/package/@archildata/native) alongside `disk`.
7
+ Full documentation is at [docs.archil.com](https://docs.archil.com/sdks/typescript).
6
8
 
7
9
  ## Install
8
10
 
@@ -10,991 +12,73 @@ SDK and CLI for [Archil](https://archil.com) disks. Create disks, list and inspe
10
12
  npm install disk
11
13
  ```
12
14
 
13
- ## CLI
14
-
15
- The `archil` command manages disks and sandboxes. Run it with `npx archil`, or install
16
- it with `npm install -g archil`:
17
-
18
- ```bash
19
- npx archil login # sign in through your browser
20
- npx archil sandbox create dev
21
- npx archil sandbox ssh dev # real SSH, no ports opened
22
- npx archil sandbox forward dev 3000 # http://localhost:3000, privately
23
- npx archil disk list
24
- ```
25
-
26
- `archil login` opens the Archil console, where you approve access for this machine. The
27
- console creates an API key named "CLI on <hostname>" and hands it back to the CLI, which
28
- saves it as the default profile. `archil whoami` shows which account and profile commands
29
- use, and `archil logout` removes the saved key. To revoke the key itself, delete it under
30
- API Keys in the console. In CI or on machines without a browser, set `ARCHIL_API_KEY` and
31
- `ARCHIL_REGION`, or save a key with `archil profile create`.
32
-
33
- ```bash
34
- # Disks. `create` prints a one-time disk token you'll need to mount the disk.
35
- npx archil disk create my-disk
36
- npx archil disk get dsk-abc123
37
- npx archil disk dsk-abc123 exec "ls -la /mnt" # runs in a container with the disk mounted
38
- npx archil disk delete dsk-abc123
39
- npx archil disk api-keys create ci-bot
40
-
41
- # Sandboxes
42
- npx archil sandbox create dev --vcpu-count 4 --mem-size-mib 8192 --env NODE_ENV=development
43
- npx archil sandbox list
44
- npx archil sandbox shell dev
45
- npx archil sandbox run dev -- sh -c 'echo "$NODE_ENV"'
46
- npx archil sandbox pause dev
47
- npx archil sandbox fork dev agent-task
48
- npx archil sandbox delete dev
49
- ```
50
-
51
- In a terminal, commands show progress and print tables. When stdout is piped, `list`,
52
- `get`, `create`, and the lifecycle commands print JSON instead; pass `-o table` or
53
- `-o json` to choose. Sandbox commands accept an exact ID or a unique name. Lifecycle
54
- commands wait by default; use `--no-wait` to return once accepted. Starting a paused
55
- sandbox discards its memory snapshot and prompts unless `--yes` is passed. In a shell,
56
- `Ctrl+]` is the emergency escape. `NO_COLOR` turns colors off.
57
-
58
- Mount commands (`archil mount`, `archil unmount`, ...) belong to the native
59
- [Archil client](https://docs.archil.com) (`curl https://archil.com/install | sh`), which is
60
- also called `archil`. This CLI passes any command it doesn't own through to that client.
61
- When the client comes first on your `PATH`, run `npx archil disk ...` and
62
- `npx archil sandbox ...` instead.
63
-
64
- The `disk` and `sandbox` executables in this package still work and take the same
65
- commands as `archil disk` and `archil sandbox`. Note that `npx sandbox` runs an unrelated
66
- npm package, so use `npx archil sandbox`.
67
-
68
- ### SSH
69
-
70
- `archil sandbox ssh` is real OpenSSH. The connection runs over the Archil API instead of an
71
- open port: ssh's `ProxyCommand` runs `archil sandbox ssh-proxy`. That command wakes the
72
- sandbox if it's paused and installs `openssh-server` the first time if the image doesn't
73
- have it. It authorizes the CLI's own key (`~/.ssh/archil_ed25519`) and pins the sandbox's
74
- host key, which it fetches over the API, so there's no trust-on-first-use prompt.
75
-
76
- ```bash
77
- npx archil sandbox ssh dev
78
- npx archil sandbox ssh dev -- uname -a
79
- npx archil sandbox ssh dev -- -L 5432:localhost:5432 # any ssh option
80
- ```
81
-
82
- To use scp, rsync, and editor remotes, add the `*.archil` hosts to `~/.ssh/config` once:
83
-
84
- ```bash
85
- archil sandbox ssh-config --install
86
- ssh dev.archil
87
- scp ./data.csv dev.archil:/root/
88
- rsync -a ./src/ dev.archil:/root/src/
89
- ```
90
-
91
- In VS Code or Cursor, choose **Remote-SSH: Connect to Host...** and enter `dev.archil`.
92
- The config runs the installed CLI by its full path, so install it globally first
93
- (`npm install -g archil`).
94
-
95
- ### Forwarding ports
96
-
97
- `archil sandbox forward dev 3000` serves the sandbox's port 3000 on
98
- `http://localhost:3000` until you press Ctrl-C. The port stays private: the tunnel
99
- authenticates with a short-lived port token, and nothing is exposed publicly. It carries
100
- HTTP and WebSockets. For other protocols, such as databases, use `ssh -L`.
101
-
102
- ### Shell completion
103
-
104
- ```bash
105
- source <(archil completion zsh) # in ~/.zshrc; also bash and fish
106
- ```
107
-
108
- Completion covers commands, options, profile names, and your sandbox names.
15
+ `disk` runs on Node.js 22.19 or later, Bun, and in browsers.
109
16
 
110
- ### Desktops
17
+ ## Credentials
111
18
 
112
- A sandbox can run a full Linux desktop (Ubuntu with XFCE and Firefox) that you open in your
113
- browser:
114
-
115
- ```bash
116
- npx archil sandbox create my-desk --desktop
117
- npx archil sandbox desktop my-desk # opens it in your browser, privately
118
- npx archil sandbox desktop my-desk --share # prints a public link instead
119
- npx archil sandbox desktop my-desk --unshare # invalidates links and disconnects viewers
120
- ```
121
-
122
- `desktop` resumes the sandbox if it's paused or stopped. By default it keeps the desktop
123
- private: it gets a short-lived port token and serves the desktop on `localhost` until you
124
- press Ctrl-C. `--share` exposes it on a public HTTPS hostname. Anyone with that link can see
125
- and control the desktop until you run `--unshare`.
126
-
127
- `--desktop` starts from `ghcr.io/archil-data/sandbox-desktop` with 2 vCPUs and 4 GiB, and turns off the idle
128
- timeout, because viewer traffic doesn't count as sandbox activity. Sessions are capped at
129
- 4 hours instead; override that with `--max-ttl-seconds`. To add your own software, build
130
- an image `FROM` that one and pass it with `--base-image`. See
131
- [archil-data/sandbox-desktop](https://github.com/archil-data/sandbox-desktop).
132
-
133
- ### Profiles
134
-
135
- `archil login` saves a profile for you. To manage profiles by hand:
136
-
137
- ```bash
138
- npx archil profile create --profile test-yellow --region aws-us-east-1
139
- npx archil profile use test-yellow
140
- npx archil sandbox list
141
- ```
142
-
143
- `profile create` securely prompts for the API key. Flags override environment variables,
144
- which override the selected profile. The library API does not read profiles.
145
-
146
- ## Library
147
-
148
- Setup:
19
+ Set `ARCHIL_API_KEY` and `ARCHIL_REGION` (for example `aws-us-east-1`), or pass them to
20
+ `configure`:
149
21
 
150
22
  ```ts
151
23
  import * as archil from "disk";
152
24
 
153
- // Configure once per process — falls back to ARCHIL_API_KEY / ARCHIL_REGION env vars.
154
25
  archil.configure({ apiKey: process.env.ARCHIL_API_KEY, region: "aws-us-east-1" });
155
-
156
- // Create a disk. `token` here is the disk token — the one-time credential for mounting.
157
- const { disk, token } = await archil.createDisk({ name: "my-disk" });
158
- console.log(`Created ${disk.id}, disk token: ${token}`);
159
-
160
- // List and look up disks
161
- const all = await archil.listDisks();
162
- const d = await archil.getDisk(disk.id);
163
- ```
164
-
165
- Per-disk operations are methods on the `Disk` object itself, not top-level functions:
166
-
167
- ```ts
168
- const d = await archil.getDisk("dsk-abc123");
169
-
170
- // Run a command in a container with the disk mounted
171
- const { stdout, stderr, exitCode } = await d.exec("ls -la /mnt && cat /mnt/config.json");
172
-
173
- // Choose the image, size, and egress policy of the exec's VM
174
- await d.exec("python3 train.py", {
175
- baseImage: "python:3.12-slim",
176
- vcpuCount: 4,
177
- memSizeMib: 8192,
178
- network: { egress: { default: "deny", allow: ["pypi.org", "files.pythonhosted.org"] } },
179
- });
180
-
181
- // Manage who can mount the disk
182
- const user = await d.addUser({ type: "token", nickname: "ci" });
183
- await d.removeUser("token", user.identifier!);
184
-
185
- // Delete
186
- await d.delete();
187
- ```
188
-
189
- ### Streaming an exec (Node.js)
190
-
191
- With `stream: true`, `archil.exec()` streams the command's input and output
192
- while it runs, instead of returning them when it exits. It takes the same
193
- options as a waiting exec, plus the process options `sandbox.run()` takes, and
194
- resolves once the command has started with the same handle `sandbox.run()`
195
- returns:
196
-
197
- ```ts
198
- const proc = await archil.exec({
199
- stream: true,
200
- command: "python3 train.py",
201
- disks: { data: d }, // mounted at /mnt/archil/data, as for a waiting exec
202
- baseImage: "python:3.12-slim",
203
- vcpuCount: 4,
204
- memSizeMib: 8192,
205
- timeoutSeconds: 3600,
206
- });
207
- for await (const chunk of proc.output) {
208
- process.stdout.write(chunk.data);
209
- }
210
- const { exitCode } = await proc.wait();
211
- ```
212
-
213
- Send input with `sendInput()` and end it with `closeStdin()`. Streamed execs
214
- share connections: up to 32 run at once on one, and later ones reuse it, so an
215
- exec after the first skips connection setup. `kill()` and `disconnect()` both
216
- stop the command and its VM. `disks` may be empty for a command that needs no
217
- disk, which takes the `workspace:exec` permission. Streaming needs Node.js or
218
- Bun, because a browser WebSocket cannot send the API key.
219
-
220
- ### Private certificate authorities (Node.js)
221
-
222
- For BYOC endpoints signed by a private CA, configure trust on the client:
223
-
224
- ```ts
225
- import { readFileSync } from "node:fs";
226
- import { getCACertificates } from "node:tls";
227
- import { Archil } from "disk";
228
-
229
- const client = new Archil({
230
- apiKey: process.env.ARCHIL_API_KEY,
231
- region: "aws-us-east-2",
232
- baseUrl: "https://control.archil.example.internal",
233
- s3BaseUrl: "https://s3.archil.example.internal",
234
- tls: {
235
- ca: [...getCACertificates(), readFileSync("archil-ca.pem")],
236
- },
237
- });
238
- ```
239
-
240
- `tls.ca` accepts a PEM string, a `Buffer`, or an array of either. As with Node's
241
- TLS `ca` option, it **replaces** the default trust list. The example includes Node's
242
- defaults as well as the private CA; `getCACertificates()` requires Node 22.15+.
243
- Omitting `tls.ca` preserves Node's default trust behavior.
244
-
245
- The configuration applies to this client's control-plane and S3-compatible requests,
246
- with certificate and hostname verification enabled. It does not change Node's global
247
- dispatcher or default trust. HTTP/2 pooling is preserved, and clients only share pools
248
- when their endpoint, API key, and CA configuration match. CA arrays and buffers are
249
- copied at construction; create a new client to change trust settings. Custom CAs are
250
- not supported in browsers.
251
-
252
- ### Sandboxes
253
-
254
- Use `Archil.sandboxes` to manage persistent VMs:
255
-
256
- ```ts
257
- const client = new archil.Archil({
258
- apiKey: process.env.ARCHIL_API_KEY,
259
- region: "aws-us-east-1",
260
- });
261
- const sandbox = await client.sandboxes.create({
262
- name: "prepared-environment",
263
- vcpuCount: 4,
264
- memSizeMiB: 8192,
265
- });
266
-
267
- const result = await sandbox.exec("uname -a");
268
- console.log(result.stdout);
269
-
270
- const terminal = await sandbox.run("codex", {
271
- terminal: { cols: 120, rows: 40 },
272
- });
273
- // Iteration ends with an error once the handle disconnects.
274
- void (async () => {
275
- for await (const { data } of terminal.output) process.stdout.write(data);
276
- })().catch(() => {});
277
- const processId = terminal.id;
278
- await terminal.sendInput("Review this repository\n");
279
- await terminal.resize({ cols: 160, rows: 50 });
280
- const cursor = terminal.cursor;
281
- await terminal.disconnect();
282
-
283
- const resumed = await sandbox.attach(processId, { offset: cursor });
284
- await resumed.kill();
285
-
286
- await sandbox.start();
287
- await sandbox.resume();
288
-
289
- await sandbox.stop();
290
- const fork = await sandbox.fork({ name: "agent-task" });
291
- await fork.stop();
292
- await fork.delete();
293
-
294
- const all = await client.sandboxes.list();
295
- const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
296
- ```
297
-
298
- Label sandboxes when you create or fork them, then find them by label or name:
299
-
300
- ```ts
301
- const agent = await client.sandboxes.create({ labels: { trial: "t-42", role: "agent" } });
302
- const verifier = await agent.fork({ labels: { trial: "t-42", role: "verifier" } });
303
-
304
- const trial = await client.sandboxes.list({ labels: { trial: "t-42" } });
305
- const named = await client.sandboxes.list({ namePrefix: "harbor-" });
306
- ```
307
-
308
- A fork keeps its source's labels unless `labels` is given; `{}` clears them.
309
- `list()` follows the server's pages until none remain.
310
-
311
- Build a sandbox image from an OCI reference, then create sandboxes from it:
312
-
313
- ```ts
314
- const image = await client.images.build({
315
- source: "ghcr.io/acme/agent:v3",
316
- // Private images only.
317
- registryAuth: { username: "bot", password: process.env.GHCR_TOKEN! },
318
- });
319
- const agent = await client.sandboxes.create({ imageId: image.imageId });
320
- console.log(agent.imageDigest);
321
- ```
322
-
323
- `build()` waits until the image is ready, joining a build already in progress.
324
- It times out after 30 minutes by default (`{ timeoutSeconds }` changes this)
325
- with an `ArchilError` whose `code` is `IMAGE_BUILD_TIMEOUT`. Building a tag
326
- again rebuilds it in case the tag moved, so build once and reuse `imageId`; a
327
- built digest reference (`repo@sha256:...`) returns immediately. Archil never
328
- stores registry credentials: pass `registryAuth` on every build of a private
329
- image, since without it the same `source` names the public image. Interrupted
330
- builds are requested again up to three times. A failed build throws
331
- `ImageBuildError`; its `reason` is `invalid_source` when the registry reported
332
- the image missing or denied access, or `interrupted`. `images.get(imageId)`
333
- returns the image's current state. `imageId` cannot be combined with
334
- `baseImage`, and creating a sandbox from an image without a successful build
335
- fails with a 409 `ArchilApiError` whose `code` is `image_not_ready`.
336
-
337
- Expose TCP ports publicly when creating a sandbox or later with `exposePort`:
338
-
339
- ```ts
340
- const web = await client.sandboxes.create({ baseImage: "python:3.12-slim", ports: [8080] });
341
- const server = await web.run("python -m http.server 8080 --bind 0.0.0.0");
342
- await server.disconnect(); // The server keeps running.
343
-
344
- const hostname = await web.exposePort(8080); // Returns the hostname, including if already public.
345
- console.log(`https://${hostname}`); // Available once the server is listening.
346
- console.log(await web.listPorts()); // [{ port: 8080, hostname: "..." }]
347
- await web.unexposePort(8080);
348
- ```
349
-
350
- Ports must be between 1 and 65535. Exposing a port makes it publicly accessible
351
- without authentication; your application must listen on that port. HTTP services
352
- are reached through HTTPS on the returned hostname.
353
- `listPorts()` returns only explicitly exposed ports; `sandbox.endpoints` contains
354
- service-published ports. Deleting explicit exposure leaves a service publishing
355
- the same port reachable and does not stop the listening process. Routing changes
356
- may take a few seconds to propagate, and existing connections remain open.
357
-
358
- `fork` pauses a running sandbox while the snapshot is taken and resumes it once the
359
- fork is accepted. A paused or stopped sandbox is forked in place and left as it is.
360
-
361
- For private HTTP access, create a port token without exposing the port publicly:
362
-
363
- ```ts
364
- const privateWeb = await client.sandboxes.create({ baseImage: "python:3.12-slim" });
365
- const server = await privateWeb.run("python -m http.server 8080 --bind 0.0.0.0");
366
- await server.disconnect();
367
-
368
- const access = await privateWeb.createPortToken(8080, { ttl: "1h" });
369
- // Once the server is listening:
370
- const response = await fetch(`https://${access.hostname}/`, {
371
- headers: { "X-Archil-Token": access.token },
372
- });
373
- console.log(await response.text());
374
-
375
- const metadata = await privateWeb.getPortToken(access.id);
376
- const tokens = await privateWeb.listPortTokens();
377
- const page = await privateWeb.listPortTokensPage({ limit: 10 });
378
- await privateWeb.deletePortToken(access);
379
- await privateWeb.delete();
380
- ```
381
-
382
- The secret and hostname are returned only by `createPortToken`; get/list return
383
- metadata. Save the secret when creating it. Omit `ttl` for no expiration, or use
384
- a duration up to `"8760h"` (365 days). `listPortTokens` follows all pages (its
385
- `limit` caps the total); `listPortTokensPage` returns `nextCursor` for pagination.
386
- Public ports bypass token authentication. Revocation and expiry deny new
387
- connections with HTTP 401; existing connections remain open.
388
-
389
- Sandboxes can run a full Linux desktop (Ubuntu with XFCE and Firefox). Create one with
390
- `desktop: true`, which picks the desktop image, 2 vCPUs, 4 GiB, no idle expiry (viewer
391
- traffic doesn't count as activity), and a 4-hour session cap unless you set them:
392
-
393
- ```ts
394
- const desk = await client.sandboxes.create({ name: "agent-desk", desktop: true });
395
- await desk.desktop.start(); // idempotent; returns { token }
396
-
397
- const link = await desk.desktop.share(); // public viewer URL; anyone with it controls the desktop
398
- await desk.desktop.unshare(); // revokes every link and disconnects viewers
399
-
400
- // Drive it like a computer-use agent
401
- const png = await desk.desktop.screenshot(); // Uint8Array (PNG)
402
- const { width, height } = await desk.desktop.size();
403
- await desk.desktop.launch(["firefox", "https://example.com"]);
404
- await desk.desktop.click(640, 400); // { button: "right", double: true } also work
405
- await desk.desktop.type("hello");
406
- await desk.desktop.key("ctrl+l"); // xdotool key names: Return, ctrl+shift+t, alt+F4
407
- await desk.desktop.scroll("down", 5);
408
- ```
409
-
410
- Each call runs one command in the sandbox, so it works wherever the SDK does. A fork shares
411
- its parent's viewer token; call `fork.desktop.token({ rotate: true })` before sharing it.
412
-
413
- To view a desktop privately, or reach any HTTP port without exposing it, use `disk/tunnel`
414
- (Node.js only). It serves the port on localhost with a short-lived access token that renews
415
- itself, and keeps the sandbox awake until you close it:
416
-
417
- ```ts
418
- import { forwardPort, openDesktopTunnel } from "disk/tunnel";
419
-
420
- const viewer = await openDesktopTunnel(desk); // localhost:6080, or any free port
421
- console.log(viewer.viewerUrl); // open in a browser on this machine
422
- await viewer.close();
423
-
424
- const app = await forwardPort(desk, 3000); // http://localhost:3000 → port 3000 in the sandbox
425
- await app.close();
426
- ```
427
-
428
- Archil disks can be mounted inside the sandbox at creation. They are mounted on every
429
- boot and persist across stop/start and pause/resume. A sandbox with mounts must be stopped
430
- before it is forked; the fork inherits them:
431
-
432
- ```ts
433
- const workspace = await client.sandboxes.create({
434
- mounts: [
435
- { disk: "dsk-0123456789abcdef", path: "/mnt/archil" },
436
- { disk: "dsk-fedcba9876543210", path: "/mnt/models", subdirectory: "llama", readOnly: true },
437
- { disk: "dsk-0000000000000001", path: "/workspace", conditional: true },
438
- ],
439
- });
440
- console.log(workspace.mounts.map((mount) => mount.path));
441
-
442
- await workspace.stop();
443
- await workspace.start({ mounts: [{ disk: "dsk-0123456789abcdef", path: "/mnt/other" }] });
444
- ```
445
-
446
- These disks are additional mounts; the sandbox retains its internal root disk.
447
- A sole mount defaults to `/mnt/archil`; `path` is required for every mount when
448
- more than one disk is mounted. Options: `readOnly`, `conditional`
449
- (concurrent writers without delegation checkouts), `subdirectory`, and `queueMs` (how long a
450
- plain mount waits for the disk's exclusive root delegation). A plain read-write mount holds
451
- that delegation for as long as the sandbox does, including while paused, so use `readOnly`
452
- or `conditional` for disks that other clients or forks also write.
453
-
454
- On a cold start, omit `mounts` to retain the current list, pass `mounts: []` to
455
- clear it, or supply a list to replace it. Mounts cannot be changed on resume or
456
- while the sandbox is running. `queueMs` cannot be combined with `readOnly` or `conditional`.
457
-
458
- Network egress can optionally be restricted when creating a sandbox:
459
-
460
- ```ts
461
- const restricted = await client.sandboxes.create({
462
- network: {
463
- egress: {
464
- default: "deny",
465
- allow: [
466
- "github.com",
467
- "*.github.com",
468
- "140.82.112.0/20",
469
- {
470
- target: "api.openai.com",
471
- transform: {
472
- headers: { Authorization: `Bearer ${process.env.OPENAI_API_KEY}` },
473
- },
474
- },
475
- ],
476
- },
477
- },
478
- });
479
- ```
480
-
481
- An egress policy accepts IPv4 addresses, CIDR ranges, exact domains, and `*.`
482
- wildcard domains. The `default` action applies when no target matches. `allow`
483
- and `deny` can both be specified; deny matches take precedence. Domain matching
484
- applies to plaintext HTTP and HTTPS traffic, and a wildcard such as
485
- `*.github.com` matches subdomains, not `github.com` itself. An object-form allow
486
- rule can transform outbound HTTPS requests to its exact lowercase domain.
487
- Header transformations overwrite values supplied by the sandbox; matching
488
- plaintext HTTP requests are rejected. Omit `network` for unrestricted egress. A
489
- running sandbox's complete policy can be replaced without restarting it;
490
- existing connections are not terminated:
491
-
492
- ```ts
493
- const effective = await restricted.updateNetwork({
494
- egress: { default: "deny", allow: ["api.github.com"] },
495
- });
496
- console.log(effective, await restricted.getNetwork());
497
-
498
- await restricted.updateNetwork({}); // Restore unrestricted egress.
499
- ```
500
-
501
- Set hard and idle TTLs at creation or edit them while running. All values are
502
- seconds, matching the Python SDK:
503
-
504
- ```ts
505
- const timed = await archil.sandboxes.create({ maxTtlSeconds: 3600, idleTtlSeconds: 300 });
506
- await timed.setTimeout(7200);
507
- await timed.setTimeout({ idleTtlSeconds: 60 });
508
- await timed.setTimeout({ timeoutSeconds: 3600, idleTtlSeconds: 300 });
509
- await timed.setTimeout({ idleTtlSeconds: 0 });
510
- console.log(timed.maxTtlSeconds, timed.idleTtlSeconds);
511
- ```
512
-
513
- Omitted settings stay unchanged on edits. Updating the hard TTL resets its
514
- deadline from now; an idle-only edit does not. Changes made while inactive apply
515
- to the next powered-on session. Idle TTL accepts 0–86,400 seconds; omitted or
516
- zero at creation disables it, and zero on edits disables it again.
517
-
518
- Both TTLs pause the sandbox, preserving memory and processes. Open direct
519
- process connections prevent idle expiry, but not hard expiry. The idle countdown
520
- starts when the last connection closes; detached processes and service-port
521
- traffic do not keep it alive. Disable idle TTL for unattended jobs.
522
-
523
- Create a sandbox with `onTimeout: "delete"` to delete it and its disk, without a
524
- memory snapshot, when either TTL runs out. With the default 30-minute idle TTL,
525
- such a sandbox is also deleted after 30 minutes without a direct process
526
- connection; set `idleTtlSeconds: 0` to delete it only at the hard TTL. A sandbox
527
- whose forks still exist is left stopped instead. Forks inherit `onTimeout`, and
528
- it cannot be changed after creation; `sandbox.onTimeout` reads it back.
529
-
530
- Sandboxes support 1–32 vCPUs and 256–65,536 MiB of memory. When omitted,
531
- `vcpuCount` defaults to 1 and `memSizeMiB` defaults to 2,048 MiB. Sandbox
532
- timeouts default to 24 hours and can be reset up to 24 hours from now.
533
-
534
- Pass an absolute `cwd` to `sandbox.run()` or `sandbox.exec()` to choose the
535
- working directory, for example `sandbox.exec("pytest", { cwd: "/workspace/app" })`.
536
- Omitting it keeps the sandbox's default working directory.
537
-
538
- `sandbox.run()` always returns a runtime-owned process immediately.
539
- Pass `terminal: true` when the command needs terminal behavior, or provide
540
- `{ cols, rows }` for an initial size. Terminal processes merge stdout and stderr
541
- into `stdout`; non-terminal processes keep the streams separate. Disconnecting
542
- leaves the process running. Reconnect with `sandbox.attach(id)` to
543
- replay buffered output from the beginning, or pass `{ offset: process.cursor }`
544
- to continue where the previous connection stopped. Iterating `output` yields
545
- raw bytes with their stream and absolute offset; one iterator may consume each
546
- handle. Call `closeStdin()` to deliver EOF
547
- to a non-terminal process. `sendInput()` resolves once the runtime has
548
- accepted the input, waiting while the process is not reading it. Set `collectOutput: false` to stream through `output` without
549
- retaining decoded output in the process handle or result. The `onOutput`
550
- option is deprecated; iterate `output` instead. Resize and kill use
551
- separate one-shot process controls, so they do not wait behind stdin.
552
- `kill()` returns after the control is acknowledged; `wait()` observes exit.
553
- `maxConcurrentExecs` limits attached process sessions; detached processes and
554
- one-shot controls do not count. Pausing a sandbox disconnects attachments but
555
- preserves its processes for reattachment after resume. Processes end when
556
- their sandbox is stopped or expires.
557
- `sandbox.exec()` is the one-call start-and-wait convenience for ordinary
558
- commands. It uses `sandbox.run()` internally and does not create a durable
559
- control-plane exec record; use `sandbox.run()` when you need the
560
- process handle. Replace `sandbox.processes.start()` with `sandbox.run()` and
561
- `sandbox.processes.connect()` with `sandbox.attach()`. The old methods and the
562
- `SandboxProcesses` export remain available as deprecated compatibility APIs and will
563
- be removed in the next version.
564
-
565
- Transfer files through the sandbox process connection without buffering the
566
- whole file in memory:
567
-
568
- ```ts
569
- await sandbox.files.uploadFile(file.stream(), "/workspace/input.tar.gz");
570
-
571
- const writable = await fileHandle.createWritable();
572
- await sandbox.files.downloadFile("/workspace/result.json", (chunk) =>
573
- writable.write(chunk),
574
- );
575
- await writable.close();
576
- ```
577
-
578
- Downloads request one bounded chunk at a time. A short or empty chunk marks
579
- end-of-file, so the source does not need to be sized before transfer.
580
-
581
- `uploadFile()` accepts a `Uint8Array`, `ArrayBuffer`, `Blob`, async iterable, or
582
- `ReadableStream`. `downloadFile()` passes each chunk to the provided writer and
583
- waits for it before requesting more data. Uploads replace the remote target only
584
- after the transfer succeeds.
585
-
586
- API keys live at the account level, so those helpers are top-level:
587
-
588
- ```ts
589
- await archil.listApiKeys();
590
- await archil.createApiKey({ name: "ci-bot", description: "GitHub Actions" });
591
- await archil.deleteApiKey("key-abc123");
592
- ```
593
-
594
- ### Reading and writing objects
595
-
596
- A `Disk` doubles as an S3-compatible bucket: read, write, delete, and list its
597
- files by key without mounting it. These methods talk to Archil's S3 endpoint
598
- using your same API key (no separate S3 credentials or SigV4 signing on your
599
- part).
600
-
601
- ```ts
602
- const d = await archil.getDisk("dsk-abc123");
603
-
604
- // Write — accepts a string, Uint8Array/Buffer, or ArrayBuffer. Returns the etag.
605
- const { etag } = await d.putObject("reports/2026-01/data.json", JSON.stringify(report), "application/json");
606
-
607
- // Read — returns the bytes (a Uint8Array).
608
- const bytes = await d.getObject("reports/2026-01/data.json");
609
- const text = new TextDecoder().decode(bytes);
610
-
611
- // Metadata / existence without downloading the body
612
- const meta = await d.headObject("reports/2026-01/data.json"); // null if absent
613
- if (await d.objectExists("reports/2026-01/data.json")) { /* … */ }
614
-
615
- // Delete (idempotent — deleting a missing key succeeds)
616
- await d.deleteObject("reports/2026-01/data.json");
617
- ```
618
-
619
- #### POSIX ownership and directories
620
-
621
- Pass `uid`, `gid`, and `mode` when the files will be used by a non-root process:
622
-
623
- ```ts
624
- await d.putObject("path/a/b/file.txt", "hello", {
625
- uid: 1000,
626
- gid: 1001,
627
- mode: 0o640,
628
- });
629
- ```
630
-
631
- If `path/` already exists as `2000:2000 0700` and `a/` and `b/` are missing,
632
- the resulting tree is:
633
-
634
- | Path | Owner | Mode | Result |
635
- | --- | --- | --- | --- |
636
- | `path/` | `2000:2000` | `0700` | Existing directory; unchanged |
637
- | `path/a/` | `1000:1001` | `0755` | Implicit parent created by the upload |
638
- | `path/a/b/` | `1000:1001` | `0755` | Implicit parent created by the upload |
639
- | `path/a/b/file.txt` | `1000:1001` | `0640` | Published file with the requested attributes |
640
-
641
- The requested file mode never applies to implicit parents; they use `0755` so
642
- they remain traversable. Existing directories are never re-owned or re-moded,
643
- so in this example a FUSE process running as uid 1000 still cannot traverse the
644
- pre-existing `path/` directory.
645
-
646
- Create an explicit directory by putting an empty directory-marker key ending in
647
- `/`:
648
-
649
- ```ts
650
- await d.putObject("path/a/private/", "", {
651
- uid: 4000,
652
- gid: 4001,
653
- mode: 0o750,
654
- });
655
- ```
656
-
657
- This creates `private/` as `4000:4001 0750`. If the marker already exists, its
658
- attributes are unchanged. When attributes are omitted, files default to
659
- `root:root 0644` and directories to `root:root 0755`. Automatic multipart
660
- uploads and append-created files use the same directory rules.
661
-
662
- The disk **root** itself defaults to `root:root 0755`, which means an
663
- unprivileged process cannot create entries directly under the mount root. To
664
- avoid a post-mount `chown`, set the root's owner and mode when creating the
665
- disk (creation-time only; a later `chown`/`chmod` through a mount changes the
666
- live attributes as usual):
667
-
668
- ```ts
669
- const { disk } = await archil.createDisk({
670
- name: "my-disk",
671
- rootAttrs: { uid: 1000, gid: 1000, mode: 0o755 },
672
- });
673
- ```
674
-
675
- `mode` is octal (pass `0o750`, not `750`). On regions that don't support
676
- `rootAttrs` yet the field is ignored and the disk is created with the
677
- defaults — check the `rootAttrs` field on the created disk to confirm it
678
- was applied.
679
-
680
- `rootAttrs` only sets the root directory itself — it does not change how
681
- later writes get their attributes:
682
-
683
- - **Through a mount**, normal POSIX rules apply: entries are owned by the
684
- creating process's uid/gid, with mode derived from its umask. A process
685
- running as the `rootAttrs` uid therefore owns everything it creates, with
686
- no attributes to pass anywhere.
687
- - **Through `putObject` and friends**, omitted attributes still mean the
688
- server defaults (`root:root 0644` files, `root:root 0755` directories) —
689
- the disk's `rootAttrs` is *not* used as a fallback. Keep passing
690
- `uid`/`gid` on object writes when a non-root process will read them.
691
-
692
- `listObjects` auto-paginates by default, returning every matching key. The first
693
- argument is a key prefix; a non-recursive listing (the default) returns the
694
- immediate level as `objects` plus subdirectory `commonPrefixes`:
695
-
696
- ```ts
697
- const { objects, commonPrefixes } = await d.listObjects("reports/"); // one level
698
- const all = await d.listObjects("reports/", { recursive: true }); // whole subtree
699
- const first100 = await d.listObjects("reports/", { limit: 100 }); // cap the total
700
-
701
- // Stream pages instead of buffering everything (large listings):
702
- for await (const page of d.listObjectsPages("reports/")) {
703
- for (const obj of page.objects) console.log(obj.key, obj.size, obj.lastModified);
704
- }
705
-
706
- // Or drive pagination yourself:
707
- const page = await d.listObjects("reports/", { singlePage: true });
708
- if (page.isTruncated) {
709
- const next = await d.listObjects("reports/", { singlePage: true, continuationToken: page.nextContinuationToken });
710
- }
711
- ```
712
-
713
- ### Large uploads and bulk delete
714
-
715
- `putObject` handles any size with one call. Small bodies go through a single
716
- request; large ones are uploaded as a multipart upload automatically — split into
717
- parts, uploaded with bounded concurrency, and assembled, aborting the upload if
718
- any part fails so nothing is left half-staged. You don't pick a different method
719
- for big files. For very large objects the part size is grown automatically so the
720
- upload never exceeds S3's 10,000-part limit.
721
-
722
- ```ts
723
- // Small or multi-gigabyte — same call.
724
- await d.putObject("reports/2026-01/data.json", JSON.stringify(report), "application/json");
725
-
726
- const { etag } = await d.putObject("backups/2026-01.tar", bigBytes, {
727
- contentType: "application/x-tar",
728
- multipartThreshold: 5 * 1024 * 1024, // switch to multipart above 5 MiB; default = partSize
729
- partSize: 32 * 1024 * 1024, // ≥ 5 MiB; default 16 MiB
730
- concurrency: 8, // parts in flight at once; default 4
731
- });
732
- ```
733
-
734
- For manual control over the multipart lifecycle (e.g. uploading parts from
735
- separate processes), the raw S3 primitives live in the opt-in `d.multipart`
736
- namespace — `create`, `uploadPart`, `complete`, `abort`, `listParts`,
737
- `listUploads`. Most code never needs these.
738
-
739
- ```ts
740
- const { uploadId } = await d.multipart.create("big.bin");
741
- const p1 = await d.multipart.uploadPart("big.bin", uploadId, 1, firstChunk);
742
- const p2 = await d.multipart.uploadPart("big.bin", uploadId, 2, secondChunk);
743
- await d.multipart.complete("big.bin", uploadId, [p1, p2]);
744
- ```
745
-
746
- `deleteObjects` removes many keys in one round trip (auto-batched at S3's 1000-key
747
- limit). Unlike `deleteObject`, per-key failures are returned rather than thrown:
748
-
749
- ```ts
750
- const { deleted, errors } = await d.deleteObjects(["a.txt", "logs/b.txt", "c.txt"]);
751
- for (const e of errors) console.warn(`${e.key}: ${e.code} ${e.message}`);
752
- ```
753
-
754
- `appendObject` appends bytes to an existing object (creating it if absent) — handy
755
- for log-style writes. Each call may append at most 1 MiB; append in chunks to grow
756
- past that.
757
-
758
- ```ts
759
- await d.appendObject("logs/app.log", "first line\n");
760
- await d.appendObject("logs/app.log", "second line\n"); // concatenated
761
- ```
762
-
763
- Transient failures (HTTP 429 and 5xx, plus network errors) are retried
764
- automatically with jittered exponential backoff before surfacing; caller errors
765
- (other 4xx) are not retried. The two non-idempotent operations —
766
- `completeMultipartUpload` and `appendObject` — are *not* auto-retried, since a
767
- retry after a succeeded-but-unacknowledged call would return a spurious
768
- `NoSuchUpload` (complete) or duplicate the appended bytes (append).
769
-
770
- Failures throw `ArchilS3Error` with `status` (HTTP status), `code` (the S3 error
771
- code, e.g. `"NoSuchKey"`), `requestId`, and the raw body on `raw`. `getObject`
772
- on a missing key throws a 404 — use `headObject`/`objectExists` to probe without
773
- catching. All SDK errors extend `ArchilError`, so `catch (e) { if (e instanceof
774
- ArchilError) … }` handles control-plane and S3 failures uniformly.
775
-
776
- The S3 endpoint is derived from your region automatically. To target a custom
777
- environment, set `s3BaseUrl` on the `Archil` constructor (or the
778
- `ARCHIL_S3_BASE_URL` env var).
779
-
780
- ### Sharing files
781
-
782
- `share` mints a signed, time-limited link to a single file. Anyone with the link
783
- can download that file — no API key, no mounting. The link carries a
784
- cryptographically signed token (disk + key + expiry); when it expires it stops
785
- working.
786
-
787
- ```ts
788
- const d = await archil.getDisk("dsk-abc123");
789
-
790
- // Default lifetime is 24 hours.
791
- const { url, expiresIn } = await d.share("reports/2026-01/summary.pdf");
792
- console.log(url); // https://control.…/api/shared/<token>
793
-
794
- // Set the lifetime in seconds (any positive integer, up to 604800 = 7 days):
795
- const weekLink = await d.share("reports/2026-01/summary.pdf", { expiresIn: 604800 });
796
- ```
797
-
798
- ### Multiple accounts or regions
799
-
800
- For multi-tenant scripts, instantiate `Archil` directly instead of using the module-level `configure`:
801
-
802
- ```ts
803
- import { Archil } from "disk";
804
-
805
- const prod = new Archil({ apiKey: prodKey, region: "aws-us-east-1" });
806
- const staging = new Archil({ apiKey: stagingKey, region: "aws-us-east-1" });
807
-
808
- const prodDisks = await prod.disks.list();
809
- const stagingDisks = await staging.disks.list();
810
- ```
811
-
812
- ## Filesystem tools
813
-
814
- Support for providing agents with a set of tools for using an Archil disk live in their own `@archildata/*` packages.
815
- | Package | Framework |
816
- | --- | --- |
817
- | `@archildata/ai-sdk` | AI SDK |
818
- | `@archildata/eve` | eve |
819
- | `@archildata/mastra` | Mastra |
820
- | `@archildata/langchain` | LangChain / LangGraph |
821
-
822
- ## Workspaces
823
- For usage with multiple disks, you can create a workspace, which acts as a virtual disk where each mounted disk appears as a top-level directory:
824
-
825
- ```ts
826
- import { Archil } from "disk";
827
-
828
- const archil = new Archil();
829
- const source = await archil.disks.get(process.env.ARCHIL_SOURCE_DISK_ID!);
830
- const output = await archil.disks.get(process.env.ARCHIL_OUTPUT_DISK_ID!);
831
-
832
- const workspace = archil.workspace({
833
- source: { disk: source, readOnly: true },
834
- output,
835
- });
836
- ```
837
-
838
- Workspace paths route to the right disk by their first segment. `readOnly` mounts
839
- return an error from operations that mutate the disk.
840
-
841
- Workspace mounts can also request delegations:
842
-
843
- ```ts
844
- const workspace = archil.workspace({
845
- repo: {
846
- disk: repoDisk,
847
- checkoutPaths: ["src", "tmp/cache"],
848
- queueMs: 5_000,
849
- },
850
- });
851
- ```
852
-
853
- When `queueMs` is set without `checkoutPaths`, the mount root is acquired
854
- during mount setup instead.
855
-
856
- ## Delegations
857
-
858
- A delegation grants a client exclusive write access to an inode on a shared
859
- disk. List the delegations currently held on a disk and forcibly revoke one —
860
- useful for reclaiming write access from a client that crashed or lost
861
- connectivity without checking its delegations in:
862
-
863
- ```ts
864
- const disk = await archil.disks.get("dsk-0123456789abcdef");
865
-
866
- for (const d of await disk.listDelegations()) {
867
- // { clientId, inodeId, path?, isPending, isOrphaned }
868
- if (d.isOrphaned) {
869
- await disk.revokeDelegation(d);
870
- }
871
- }
872
26
  ```
873
27
 
874
- A delegation has no ID of its own — it is identified by the
875
- `(clientId, inodeId)` pair. `isOrphaned` entries are held by clients no longer
876
- connected to the disk. `path` is resolved best-effort by the server and may be
877
- absent.
28
+ To work with several accounts or regions in one process, create clients with
29
+ `new Archil({ apiKey, region })`.
878
30
 
879
- ## Branches
880
-
881
- A branch is an independent, writable fork of a disk that starts from a
882
- committed checkpoint. Writes on a branch don't affect its source. Create a
883
- checkpoint from a mounted disk with `archil checkpoints create <mountpoint> <name>`,
884
- then branch from it:
31
+ ## Quickstart
885
32
 
886
33
  ```ts
887
- const disk = await archil.disks.get("dsk-0123456789abcdef");
888
-
889
- const branch = await disk.createBranch({ name: "experiment", fromCheckpoint: "nightly" });
890
- // { branch_name, filesystem_id, from_checkpoint_name, created_at, ... }
891
-
892
- // Branch from a checkpoint taken on another branch:
893
- await disk.createBranch({ name: "experiment-2", fromCheckpoint: "cp1", fromBranch: "experiment" });
894
-
895
- await disk.listBranches();
896
- await disk.getBranch("experiment");
897
- ```
34
+ import * as archil from "disk";
898
35
 
899
- Branch names are 1-100 letters, digits, hyphens, or underscores, and are unique
900
- across the disk. `createBranch` rejects with a 409 `ArchilApiError` when the
901
- name is taken or the checkpoint isn't committed yet. The SDK's own retries are
902
- safe: it sends the same idempotency key on every attempt. To retry a create
903
- yourself, pass your own key and reuse it, so a retry of a create that already
904
- succeeded returns that branch instead of a 409:
36
+ // Create a disk, or open an existing one with archil.getDisk("dsk-...")
37
+ const { disk } = await archil.createDisk({ name: "my-disk" });
905
38
 
906
- ```ts
907
- const idempotencyKey = crypto.randomUUID(); // store it alongside the job
908
- await disk.createBranch({ name: "experiment", fromCheckpoint: "nightly", idempotencyKey });
909
- ```
39
+ // Read and write files through the object API
40
+ await disk.putObject("notes/hello.txt", "hello from disk");
41
+ const text = new TextDecoder().decode(await disk.getObject("notes/hello.txt"));
910
42
 
911
- A `Workspace` is a full filesystem in its own right — it has the same object API
912
- a `Disk` does (`getObject` / `putObject` / `deleteObject` / `listObjects` /
913
- `grep` / `exec`; both implement the `FileSystem` interface), so you can use it
914
- directly, and add or remove disks at runtime. A
915
- workspace's keys carry the disk name as their first segment:
43
+ // Run a command with the disk mounted at /mnt/archil
44
+ const result = await disk.exec("cat notes/hello.txt && ls -la");
45
+ console.log(result.stdout, result.exitCode);
916
46
 
917
- ```ts
918
- const data = await ws.getObject("data/reports/q1.csv"); // routes to the "data" disk
919
- ws.addDisk("scratch", diskTmp); // mount another disk live; ws.removeDisk("scratch")
47
+ // Start a persistent sandbox and run a command in it
48
+ const sandbox = await archil.createSandbox({ name: "dev" });
49
+ const run = await sandbox.exec("uname -a");
50
+ console.log(run.stdout);
51
+ await sandbox.delete();
920
52
  ```
921
53
 
922
- ## Connecting to a disk's data plane
923
-
924
- To run a command against a disk, use `Disk.exec()` — it returns stdout, stderr, and an exit code from an Archil-managed container with the disk pre-mounted. No local filesystem involved.
925
-
926
- To mount a disk as a real filesystem on your machine, use the [`archil`](https://archil.com) CLI — it mounts through the OS kernel via FUSE, so any program can read and write files with standard APIs.
54
+ ## CLI
927
55
 
928
- For the rare case where you need raw Archil protocol access from Node.js (inodes, delegations, byte-level reads), install [`@archildata/native`](https://www.npmjs.com/package/@archildata/native) alongside `disk`:
56
+ The `archil` command manages disks and sandboxes. Run it with `npx archil`, or install it
57
+ with `npm install -g archil`:
929
58
 
930
59
  ```bash
931
- npm install disk @archildata/native
932
- ```
933
-
934
- Then `Disk.mount()` lazy-loads the native client:
935
-
936
- ```ts
937
- import { getDisk } from "disk";
938
-
939
- const d = await getDisk("dsk-abc123");
940
- const client = await d.mount({ authToken: "<disk-token>" });
941
- // `client` is an ArchilClient from @archildata/native — see that package's README.
942
- await client.close();
60
+ npx archil login # sign in through your browser
61
+ npx archil disk list
62
+ npx archil sandbox create dev
63
+ npx archil sandbox ssh dev
64
+ npx archil sandbox forward dev 3000 # http://localhost:3000, privately
943
65
  ```
944
66
 
945
- `@archildata/native` supports Linux (x64 / arm64, glibc) and macOS (arm64). On other platforms, `mount()` throws; the rest of `disk` still works.
946
-
947
- ## Supported regions
948
-
949
- | Region | Provider |
950
- | ----------------- | -------- |
951
- | `aws-us-east-1` | AWS |
952
- | `aws-us-west-2` | AWS |
953
- | `aws-eu-west-1` | AWS |
954
- | `gcp-us-central1` | GCP |
67
+ See the [CLI reference](https://docs.archil.com/reference/archil-npm-cli) for every
68
+ command.
955
69
 
956
- ## FAQ
70
+ ## Documentation
957
71
 
958
- ### What's the difference between an API key and a disk token?
959
-
960
- Archil has two credential types, and the examples above use both:
961
-
962
- - **API key** — account-level credential for the control plane. You use one whenever you call `disk` (CLI or library). Create and manage them at [console.archil.com](https://console.archil.com) or with `disk api-keys create`. Goes in the `ARCHIL_API_KEY` env var or the `--api-key` flag.
963
- - **Disk token** — per-disk credential that lets a client mount a specific disk. Created automatically when you `disk create <name>` (the value is shown once; save it). You don't need one to run `disk` itself — only when something is actually mounting a disk.
72
+ - [SDK overview](https://docs.archil.com/sdks/overview): packages, credentials, and regions
73
+ - [TypeScript SDK](https://docs.archil.com/sdks/typescript): clients, errors, and Node.js options
74
+ - [Disks and data sources](https://docs.archil.com/data-sources/s3-object-storage): create disks backed by S3, GCS, R2, and more
75
+ - [Serverless execution](https://docs.archil.com/compute/serverless-execution): run commands against one or more disks
76
+ - [Search files](https://docs.archil.com/compute/search-files): grep a disk on the server
77
+ - [Sandboxes](https://docs.archil.com/compute/sandboxes/introduction): persistent microVMs, processes, ports, and files
78
+ - [Sandbox images](https://docs.archil.com/compute/sandboxes/images), [firewall](https://docs.archil.com/compute/sandboxes/firewall), [desktops](https://docs.archil.com/compute/sandboxes/desktops), and [SSH and port forwarding](https://docs.archil.com/compute/sandboxes/ssh-and-ports)
79
+ - [Branches and checkpoints](https://docs.archil.com/concepts/branches-and-checkpoints) and [sharing disks](https://docs.archil.com/concepts/sharing-disks)
80
+ - [Integrations](https://docs.archil.com/integrations/ai-sdk): tools for AI SDK, Mastra, LangChain, and eve
964
81
 
965
82
  ## Support
966
83
 
967
84
  Questions, feature requests, or issues? Reach us at **support@archil.com**.
968
-
969
-
970
- To finish selected model requests before pausing, opt in when creating the sandbox:
971
-
972
- ```ts
973
- const sandbox = await archil.sandboxes.create({
974
- network: {
975
- egress: {
976
- default: "allow",
977
- drain_on_pause: [
978
- "*.anthropic.com",
979
- "api.openai.com",
980
- "bedrock-runtime.*.amazonaws.com",
981
- ],
982
- },
983
- },
984
- });
985
- await sandbox.pause();
986
- ```
987
-
988
- Each entry is a lowercase hostname pattern without a scheme, port, or path.
989
- `*` works anywhere; `"*"` selects every host. Leading `*.` excludes the apex domain.
990
- All URL paths on a selected host count. Matching happens before forwarding. Selectors
991
- do not grant network access. Pausing gates new matches and waits for active HTTP(S)
992
- responses, including streams, to reach the guest. Requests to other hosts do not delay the drain.
993
- The drain waits up to ten minutes by default, starting when pause begins. Request errors
994
- stop counting; expiry proceeds with the snapshot. Requests have no added timeout during
995
- normal operation.
996
- HTTP ports 80 and 443 are supported. Clients must trust the sandbox egress CA for HTTPS
997
- and retry stale connections after resume. Set selectors at creation to cover every
998
- connection; live network updates cannot intercept existing passthrough connections.
999
- A snapshot failure leaves the sandbox in `failed` with the failure reason and raises
1000
- `SandboxPauseError` when waiting; `error.latest` contains the resulting sandbox state.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { p as Archil } from "./src-B_nMppCu.mjs";
3
- import { C as printError, _ as writeProfileCredential, a as addGlobalOptions, d as saveProfiles, g as resolveCliCredentials, l as deleteProfile, m as deleteProfileCredential, o as addProfileCommands, p as validateCredentialAndResolveRegion, u as loadProfiles, v as diskConfigDir, x as createUi, y as Command } from "./sandbox-options-Ck_EAl3Z.mjs";
4
- import { n as rewriteDiskExecSugar, t as addDiskCommands } from "./disk-command-e1AyXrI4.mjs";
5
- import { r as openInBrowser, t as addSandboxCommands } from "./sandbox-command-qj_ZlLev.mjs";
2
+ import { p as Archil } from "./src-DIXY3t3v.mjs";
3
+ import { C as printError, _ as writeProfileCredential, a as addGlobalOptions, d as saveProfiles, g as resolveCliCredentials, l as deleteProfile, m as deleteProfileCredential, o as addProfileCommands, p as validateCredentialAndResolveRegion, u as loadProfiles, v as diskConfigDir, x as createUi, y as Command } from "./sandbox-options-Bd4jIgUs.mjs";
4
+ import { n as rewriteDiskExecSugar, t as addDiskCommands } from "./disk-command-D39MC_NH.mjs";
5
+ import { r as openInBrowser, t as addSandboxCommands } from "./sandbox-command-n_y2bRTc.mjs";
6
6
  import { createRequire } from "node:module";
7
7
  import { mkdir, readFile, writeFile } from "node:fs/promises";
8
8
  import { delimiter, join } from "node:path";
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { C as printError, a as addGlobalOptions, o as addProfileCommands, y as Command } from "./sandbox-options-Ck_EAl3Z.mjs";
3
- import { n as rewriteDiskExecSugar, t as addDiskCommands } from "./disk-command-e1AyXrI4.mjs";
2
+ import { C as printError, a as addGlobalOptions, o as addProfileCommands, y as Command } from "./sandbox-options-Bd4jIgUs.mjs";
3
+ import { n as rewriteDiskExecSugar, t as addDiskCommands } from "./disk-command-D39MC_NH.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  //#region bin/cli.ts
6
6
  const pkg = createRequire(import.meta.url)("../package.json");
@@ -1,5 +1,5 @@
1
- import { a as deleteApiKey, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks, w as ArchilApiError } from "./src-B_nMppCu.mjs";
2
- import { C as printError, c as resolveProgramCredentials, f as renderTable, s as isProfileCommand, t as optionalInteger, x as createUi } from "./sandbox-options-Ck_EAl3Z.mjs";
1
+ import { a as deleteApiKey, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks, w as ArchilApiError } from "./src-DIXY3t3v.mjs";
2
+ import { C as printError, c as resolveProgramCredentials, f as renderTable, s as isProfileCommand, t as optionalInteger, x as createUi } from "./sandbox-options-Bd4jIgUs.mjs";
3
3
  //#region src/cli/disk-command.ts
4
4
  const DISK_COMMANDS = [
5
5
  "list",
package/dist/index.cjs CHANGED
@@ -122,7 +122,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
122
122
  }
123
123
  //#endregion
124
124
  //#region src/version.ts
125
- const VERSION = "1.16.0";
125
+ const VERSION = "1.16.1-next.20261201221409";
126
126
  const USER_AGENT = `archil-js/${VERSION}`;
127
127
  //#endregion
128
128
  //#region src/client.ts
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { A as SandboxProcess, C as effectiveUploadPartSize, D as ImageBuildError, E as ArchilS3Error, M as USER_AGENT, N as VERSION, O as SandboxFileTransferError, S as DiskMultipart, T as ArchilError, _ as Sandbox, a as deleteApiKey, b as Disks, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as SandboxProcesses, k as SandboxPauseError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as ArchilApiError, x as Disk, y as Images } from "./src-B_nMppCu.mjs";
1
+ import { A as SandboxProcess, C as effectiveUploadPartSize, D as ImageBuildError, E as ArchilS3Error, M as USER_AGENT, N as VERSION, O as SandboxFileTransferError, S as DiskMultipart, T as ArchilError, _ as Sandbox, a as deleteApiKey, b as Disks, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as SandboxProcesses, k as SandboxPauseError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as ArchilApiError, x as Disk, y as Images } from "./src-DIXY3t3v.mjs";
2
2
  import { a as DESKTOP_VCPUS, c as desktopViewerPath, i as DESKTOP_PORT, n as DESKTOP_MAX_TTL_SECONDS, o as DesktopNotInstalledError, r as DESKTOP_MEMORY_MIB, s as SandboxDesktop, t as DESKTOP_IMAGE } from "./sandbox-desktop-CrvuoiGi.mjs";
3
3
  export { Archil, ArchilApiError, ArchilError, ArchilS3Error, DESKTOP_IMAGE, DESKTOP_MAX_TTL_SECONDS, DESKTOP_MEMORY_MIB, DESKTOP_PORT, DESKTOP_VCPUS, DesktopNotInstalledError, Disk, DiskMultipart, Disks, ImageBuildError, Images, Sandbox, SandboxDesktop, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, desktopViewerPath, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
@@ -122,7 +122,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
122
122
  }
123
123
  //#endregion
124
124
  //#region src/version.ts
125
- const VERSION = "1.16.0";
125
+ const VERSION = "1.16.1-next.20261201221409";
126
126
  const USER_AGENT = `archil-js/${VERSION}`;
127
127
  //#endregion
128
128
  //#region src/client.ts
@@ -121,7 +121,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
121
121
  }
122
122
  //#endregion
123
123
  //#region src/version.ts
124
- const VERSION = "1.16.0";
124
+ const VERSION = "1.16.1-next.20261201221409";
125
125
  const USER_AGENT = `archil-js/${VERSION}`;
126
126
  //#endregion
127
127
  //#region src/client.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { p as Archil } from "./src-B_nMppCu.mjs";
3
- import { C as printError } from "./sandbox-options-Ck_EAl3Z.mjs";
4
- import { n as createSandboxProgram } from "./sandbox-command-qj_ZlLev.mjs";
2
+ import { p as Archil } from "./src-DIXY3t3v.mjs";
3
+ import { C as printError } from "./sandbox-options-Bd4jIgUs.mjs";
4
+ import { n as createSandboxProgram } from "./sandbox-command-n_y2bRTc.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  //#region bin/sandbox-cli.ts
7
7
  const pkg = createRequire(import.meta.url)("../package.json");
@@ -1,6 +1,6 @@
1
1
  import { c as desktopViewerPath, i as DESKTOP_PORT } from "./sandbox-desktop-CrvuoiGi.mjs";
2
2
  import { forwardPort, openPortTunnel } from "./tunnel.mjs";
3
- import { S as formatDuration, T as styles, a as addGlobalOptions, b as colorEnabled, c as resolveProgramCredentials, f as renderTable, h as readProfileCredential, i as validateSandboxName, n as parseCreateSandboxOptions, o as addProfileCommands, r as parseRunOptions, s as isProfileCommand, t as optionalInteger, u as loadProfiles, v as diskConfigDir, w as statusStyle, x as createUi, y as Command } from "./sandbox-options-Ck_EAl3Z.mjs";
3
+ import { S as formatDuration, T as styles, a as addGlobalOptions, b as colorEnabled, c as resolveProgramCredentials, f as renderTable, h as readProfileCredential, i as validateSandboxName, n as parseCreateSandboxOptions, o as addProfileCommands, r as parseRunOptions, s as isProfileCommand, t as optionalInteger, u as loadProfiles, v as diskConfigDir, w as statusStyle, x as createUi, y as Command } from "./sandbox-options-Bd4jIgUs.mjs";
4
4
  import { mkdir, open, readFile, rename, stat, unlink, writeFile } from "node:fs/promises";
5
5
  import { dirname, join } from "node:path";
6
6
  import { homedir } from "node:os";
@@ -1,4 +1,4 @@
1
- import { P as REGION_URLS, p as Archil, w as ArchilApiError } from "./src-B_nMppCu.mjs";
1
+ import { P as REGION_URLS, p as Archil, w as ArchilApiError } from "./src-DIXY3t3v.mjs";
2
2
  import "./sandbox-desktop-CrvuoiGi.mjs";
3
3
  import { chmod, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
@@ -121,7 +121,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
121
121
  }
122
122
  //#endregion
123
123
  //#region src/version.ts
124
- const VERSION = "1.16.0";
124
+ const VERSION = "1.16.1-next.20261201221409";
125
125
  const USER_AGENT = `archil-js/${VERSION}`;
126
126
  //#endregion
127
127
  //#region src/client.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disk",
3
- "version": "1.16.0",
3
+ "version": "1.16.1-next.20261201221409",
4
4
  "description": "Pure-JS client and CLIs for Archil disks and sandboxes",
5
5
  "keywords": [
6
6
  "archil",