disk 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -155,7 +155,7 @@ const sandbox = await client.sandboxes.create({
155
155
  const result = await sandbox.exec("uname -a");
156
156
  console.log(result.stdout);
157
157
 
158
- const terminal = await sandbox.processes.start("codex", {
158
+ const terminal = await sandbox.run("codex", {
159
159
  terminal: { cols: 120, rows: 40 },
160
160
  onOutput: ({ data }) => process.stdout.write(data),
161
161
  });
@@ -165,7 +165,7 @@ await terminal.resize({ cols: 160, rows: 50 });
165
165
  const cursor = terminal.cursor;
166
166
  await terminal.disconnect();
167
167
 
168
- const resumed = await sandbox.processes.connect(processId, {
168
+ const resumed = await sandbox.attach(processId, {
169
169
  offset: cursor,
170
170
  onOutput: ({ data }) => process.stdout.write(data),
171
171
  });
@@ -183,11 +183,37 @@ const all = await client.sandboxes.list();
183
183
  const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
184
184
  ```
185
185
 
186
+ Build a sandbox image from an OCI reference, then create sandboxes from it:
187
+
188
+ ```ts
189
+ const image = await client.images.build({
190
+ source: "ghcr.io/acme/agent:v3",
191
+ // Private images only.
192
+ registryAuth: { username: "bot", password: process.env.GHCR_TOKEN! },
193
+ });
194
+ const agent = await client.sandboxes.create({ imageId: image.imageId });
195
+ console.log(agent.imageDigest);
196
+ ```
197
+
198
+ `build()` waits until the image is ready, joining a build already in progress.
199
+ It times out after 30 minutes by default (`{ timeoutSeconds }` changes this)
200
+ with an `ArchilError` whose `code` is `IMAGE_BUILD_TIMEOUT`. Building a tag
201
+ again rebuilds it in case the tag moved, so build once and reuse `imageId`; a
202
+ built digest reference (`repo@sha256:...`) returns immediately. Archil never
203
+ stores registry credentials: pass `registryAuth` on every build of a private
204
+ image, since without it the same `source` names the public image. Interrupted
205
+ builds are requested again up to three times. A failed build throws
206
+ `ImageBuildError`; its `reason` is `invalid_source` when the registry reported
207
+ the image missing or denied access, or `interrupted`. `images.get(imageId)`
208
+ returns the image's current state. `imageId` cannot be combined with
209
+ `baseImage`, and creating a sandbox from an image without a successful build
210
+ fails with a 409 `ArchilApiError` whose `code` is `image_not_ready`.
211
+
186
212
  Expose TCP ports publicly when creating a sandbox or later with `exposePort`:
187
213
 
188
214
  ```ts
189
215
  const web = await client.sandboxes.create({ baseImage: "python:3.12-slim", ports: [8080] });
190
- const server = await web.processes.start("python -m http.server 8080 --bind 0.0.0.0");
216
+ const server = await web.run("python -m http.server 8080 --bind 0.0.0.0");
191
217
  await server.disconnect(); // The server keeps running.
192
218
 
193
219
  const hostname = await web.exposePort(8080); // Returns the hostname, including if already public.
@@ -211,7 +237,7 @@ For private HTTP access, create a port token without exposing the port publicly:
211
237
 
212
238
  ```ts
213
239
  const privateWeb = await client.sandboxes.create({ baseImage: "python:3.12-slim" });
214
- const server = await privateWeb.processes.start("python -m http.server 8080 --bind 0.0.0.0");
240
+ const server = await privateWeb.run("python -m http.server 8080 --bind 0.0.0.0");
215
241
  await server.disconnect();
216
242
 
217
243
  const access = await privateWeb.createPortToken(8080, { ttl: "1h" });
@@ -304,11 +330,15 @@ Sandboxes support 1–32 vCPUs and 256–65,536 MiB of memory. When omitted,
304
330
  `vcpuCount` defaults to 1 and `memSizeMiB` defaults to 2,048 MiB. Sandbox
305
331
  timeouts default to 24 hours and can be reset up to 24 hours from now.
306
332
 
307
- `sandbox.processes.start()` always returns a runtime-owned process immediately.
333
+ Pass an absolute `cwd` to `sandbox.run()` or `sandbox.exec()` to choose the
334
+ working directory, for example `sandbox.exec("pytest", { cwd: "/workspace/app" })`.
335
+ Omitting it keeps the sandbox's default working directory.
336
+
337
+ `sandbox.run()` always returns a runtime-owned process immediately.
308
338
  Pass `terminal: true` when the command needs terminal behavior, or provide
309
339
  `{ cols, rows }` for an initial size. Terminal processes merge stdout and stderr
310
340
  into `stdout`; non-terminal processes keep the streams separate. Disconnecting
311
- leaves the process running. Reconnect with `sandbox.processes.connect(id)` to
341
+ leaves the process running. Reconnect with `sandbox.attach(id)` to
312
342
  replay buffered output from the beginning, or pass `{ offset: process.cursor }`
313
343
  to continue where the previous connection stopped. `onOutput` receives raw
314
344
  bytes with their stream and absolute offset. Call `closeStdin()` to deliver EOF
@@ -322,9 +352,12 @@ one-shot controls do not count. Pausing a sandbox disconnects attachments but
322
352
  preserves its processes for reattachment after resume. Processes end when
323
353
  their sandbox is stopped or expires.
324
354
  `sandbox.exec()` is the one-call start-and-wait convenience for ordinary
325
- commands. It uses `sandbox.processes` internally and does not create a durable
326
- control-plane exec record; use `sandbox.processes.start()` when you need the
327
- process handle.
355
+ commands. It uses `sandbox.run()` internally and does not create a durable
356
+ control-plane exec record; use `sandbox.run()` when you need the
357
+ process handle. Replace `sandbox.processes.start()` with `sandbox.run()` and
358
+ `sandbox.processes.connect()` with `sandbox.attach()`. The old methods and the
359
+ `SandboxProcesses` export remain available as deprecated compatibility APIs and will
360
+ be removed in the next version.
328
361
 
329
362
  Transfer files through the sandbox process connection without buffering the
330
363
  whole file in memory:
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { O as ArchilApiError, a as deleteApiKey, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-r2oVqVK_.mjs";
3
- import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-Bi2YnNf6.mjs";
2
+ import { a as deleteApiKey, k as ArchilApiError, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-CXTEUmMV.mjs";
3
+ import { a as renderTable, i as resolveProgramCredentials, n as addProfileCommands, r as isProfileCommand, t as addGlobalOptions } from "./common-BkH4aHPf.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { Command } from "commander";
6
6
  //#region bin/cli.ts
@@ -1,4 +1,4 @@
1
- import { D as REGION_URLS, p as Archil } from "./src-r2oVqVK_.mjs";
1
+ import { O as REGION_URLS, p as Archil } from "./src-CXTEUmMV.mjs";
2
2
  import { Option } from "commander";
3
3
  import { isCancel, password, spinner } from "@clack/prompts";
4
4
  import { chmod, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";