disk 0.9.0 → 0.11.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
@@ -89,13 +89,30 @@ const sandbox = await client.sandboxes.create({
89
89
  memSizeMiB: 8192,
90
90
  });
91
91
 
92
- const result = await sandbox.exec("uname -a");
92
+ const execution = await sandbox.processes.start("uname -a");
93
+ const result = await execution.wait();
93
94
  console.log(result.stdout);
94
95
 
96
+ const terminal = await sandbox.processes.start("codex", {
97
+ terminal: { cols: 120, rows: 40 },
98
+ onOutput: ({ data }) => process.stdout.write(data),
99
+ });
100
+ const processId = terminal.id;
101
+ await terminal.sendInput("Review this repository\n");
102
+ await terminal.resize({ cols: 160, rows: 50 });
103
+ const cursor = terminal.cursor;
104
+ await terminal.disconnect();
105
+
106
+ const resumed = await sandbox.processes.connect(processId, {
107
+ offset: cursor,
108
+ onOutput: ({ data }) => process.stdout.write(data),
109
+ });
110
+ await resumed.kill();
111
+
95
112
  await sandbox.start();
96
113
  await sandbox.resume();
97
114
 
98
- // Return the initial state immediately instead of waiting for completion.
115
+ // Existing exec API for durable control-plane exec records.
99
116
  const runningExec = await sandbox.exec("sleep 60", { wait: false });
100
117
 
101
118
  await sandbox.stop();
@@ -111,10 +128,45 @@ const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
111
128
  Sandboxes support 1–32 vCPUs and 256–65,536 MiB of memory. When omitted,
112
129
  `vcpuCount` defaults to 1 and `memSizeMiB` defaults to 2,048 MiB.
113
130
 
114
- `create`, `start`, `stop`, `pause`, `resume`, `fork`, and `exec` wait for
115
- completion by default. The server handles the initial wait; if its wait budget
116
- expires first, the SDK continues polling. Pass `{ wait: false }` to return as
117
- soon as the operation is accepted.
131
+ `sandbox.processes.start()` always returns a runtime-owned process immediately.
132
+ Pass `terminal: true` when the command needs terminal behavior, or provide
133
+ `{ cols, rows }` for an initial size. Terminal processes merge stdout and stderr
134
+ into `stdout`; non-terminal processes keep the streams separate. Disconnecting
135
+ leaves the process running. Reconnect with `sandbox.processes.connect(id)` to
136
+ replay buffered output from the beginning, or pass `{ offset: process.cursor }`
137
+ to continue where the previous connection stopped. `onOutput` receives raw
138
+ bytes with their stream and absolute offset. Call `closeStdin()` to deliver EOF
139
+ to a non-terminal process. `sendInput()` streams large input as 1 MiB WebSocket
140
+ frames. Set `collectOutput: false` to stream through `onOutput` without
141
+ retaining decoded output in the process handle or result. Resize and kill use
142
+ separate one-shot process controls, so they do not wait behind stdin.
143
+ `kill()` returns after the control is acknowledged; `wait()` observes exit.
144
+ `maxConcurrentExecs` limits attached exec sessions; detached processes and
145
+ one-shot controls do not count. Pausing a sandbox disconnects attachments but
146
+ preserves its processes for reattachment after resume. Processes end when
147
+ their sandbox is stopped or expires.
148
+ The existing `exec` API remains available for durable control-plane exec records.
149
+
150
+ Transfer files through the sandbox process connection without buffering the
151
+ whole file in memory:
152
+
153
+ ```ts
154
+ await sandbox.files.uploadFile(file.stream(), "/workspace/input.tar.gz");
155
+
156
+ const writable = await fileHandle.createWritable();
157
+ await sandbox.files.downloadFile("/workspace/result.json", (chunk) =>
158
+ writable.write(chunk),
159
+ );
160
+ await writable.close();
161
+ ```
162
+
163
+ Downloads request one bounded chunk at a time. A short or empty chunk marks
164
+ end-of-file, so the source does not need to be sized before transfer.
165
+
166
+ `uploadFile()` accepts a `Uint8Array`, `ArrayBuffer`, `Blob`, async iterable, or
167
+ `ReadableStream`. `downloadFile()` passes each chunk to the provided writer and
168
+ waits for it before requesting more data. Uploads replace the remote target only
169
+ after the transfer succeeds.
118
170
 
119
171
  API keys live at the account level, so those helpers are top-level:
120
172
 
@@ -192,6 +244,36 @@ attributes are unchanged. When attributes are omitted, files default to
192
244
  `root:root 0644` and directories to `root:root 0755`. Automatic multipart
193
245
  uploads and append-created files use the same directory rules.
194
246
 
247
+ The disk **root** itself defaults to `root:root 0755`, which means an
248
+ unprivileged process cannot create entries directly under the mount root. To
249
+ avoid a post-mount `chown`, set the root's owner and mode when creating the
250
+ disk (creation-time only; a later `chown`/`chmod` through a mount changes the
251
+ live attributes as usual):
252
+
253
+ ```ts
254
+ const { disk } = await archil.createDisk({
255
+ name: "my-disk",
256
+ rootAttrs: { uid: 1000, gid: 1000, mode: 0o755 },
257
+ });
258
+ ```
259
+
260
+ `mode` is octal (pass `0o750`, not `750`). On regions that don't support
261
+ `rootAttrs` yet the field is ignored and the disk is created with the
262
+ defaults — check the `rootAttrs` field on the created disk to confirm it
263
+ was applied.
264
+
265
+ `rootAttrs` only sets the root directory itself — it does not change how
266
+ later writes get their attributes:
267
+
268
+ - **Through a mount**, normal POSIX rules apply: entries are owned by the
269
+ creating process's uid/gid, with mode derived from its umask. A process
270
+ running as the `rootAttrs` uid therefore owns everything it creates, with
271
+ no attributes to pass anywhere.
272
+ - **Through `putObject` and friends**, omitted attributes still mean the
273
+ server defaults (`root:root 0644` files, `root:root 0755` directories) —
274
+ the disk's `rootAttrs` is *not* used as a fallback. Keep passing
275
+ `uid`/`gid` on object writes when a non-root process will read them.
276
+
195
277
  `listObjects` auto-paginates by default, returning every matching key. The first
196
278
  argument is a key prefix; a non-recursive listing (the default) returns the
197
279
  immediate level as `objects` plus subdirectory `commonPrefixes`:
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { E 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-CR3Ksi_s.mjs";
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-Cpv1TIWC.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { Command, Option } from "commander";
5
5
  //#region bin/cli.ts
@@ -44,6 +44,7 @@ type DiskMetrics = components["schemas"]["DiskMetrics"];
44
44
  type ConnectedClient = components["schemas"]["ConnectedClient"];
45
45
  type AuthorizedUser = components["schemas"]["AuthorizedUser"];
46
46
  type CreateDiskRequest = components["schemas"]["CreateDiskRequest"];
47
+ type RootAttrs = components["schemas"]["RootAttrs"];
47
48
  type MountConfig = components["schemas"]["MountConfig"];
48
49
  type S3Mount = components["schemas"]["S3Mount"];
49
50
  type GCSMount = components["schemas"]["GCSMount"];
@@ -384,6 +385,8 @@ declare class Disk implements FileSystem {
384
385
  readonly connectedClients?: ConnectedClient[];
385
386
  readonly authorizedUsers?: AuthorizedUser[];
386
387
  readonly allowedIps?: string[];
388
+ /** Root-directory POSIX attributes recorded at creation, if any. */
389
+ readonly rootAttrs?: RootAttrs;
387
390
  /** @internal */
388
391
  private readonly _client;
389
392
  /** @internal */
@@ -706,4 +709,4 @@ declare class DiskMultipart {
706
709
  */
707
710
  declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
708
711
  //#endregion
709
- export { TokenUser as $, ApiTokenResponse as A, DiskStatus as B, PutObjectOptions as C, ShareUrlResult as D, ShareUrlOptions as E, CreateApiTokenRequest as F, GrepMatch as G, ExecDiskResult as H, CreateDiskRequest as I, MountConfigResponse as J, GrepStoppedReason as K, Delegation as L, AwsStsUser as M, AzureBlobMount as N, UploadPart as O, ConnectedClient as P, S3Mount as Q, DiskMetrics as R, PosixCreateAttrs as S, S3Object as T, ExecRequest as U, DiskUser as V, GCSMount as W, R2Mount as X, MountResponse as Y, S3CompatibleMount as Z, MultipartUploadListing as _, DeleteObjectsResult as a, PartInfo as b, ExecResult as c, ListMultipartUploadsOptions as d, FileSystem as et, ListObjectsOptions as f, MultipartUpload as g, MountOptions as h, DeleteObjectsOptions as i, AuthorizedUser as j, effectiveUploadPartSize as k, GrepOptions as l, ListPartsOptions as m, CompletedMultipartUpload as n, Disk as o, ListObjectsResult as p, MountConfig as q, DeleteObjectsError as r, DiskMultipart as s, AppendObjectOptions as t, ApiClient as tt, GrepResult as u, MultipartUploadSummary as v, PutObjectResult as w, PartListing as x, ObjectMetadata as y, DiskResponse as z };
712
+ export { S3Mount as $, ApiTokenResponse as A, DiskStatus as B, PutObjectOptions as C, ShareUrlResult as D, ShareUrlOptions as E, CreateApiTokenRequest as F, GrepMatch as G, ExecDiskResult as H, CreateDiskRequest as I, MountConfigResponse as J, GrepStoppedReason as K, Delegation as L, AwsStsUser as M, AzureBlobMount as N, UploadPart as O, ConnectedClient as P, S3CompatibleMount as Q, DiskMetrics as R, PosixCreateAttrs as S, S3Object as T, ExecRequest as U, DiskUser as V, GCSMount as W, R2Mount as X, MountResponse as Y, RootAttrs as Z, MultipartUploadListing as _, DeleteObjectsResult as a, PartInfo as b, ExecResult as c, ListMultipartUploadsOptions as d, TokenUser as et, ListObjectsOptions as f, MultipartUpload as g, MountOptions as h, DeleteObjectsOptions as i, AuthorizedUser as j, effectiveUploadPartSize as k, GrepOptions as l, ListPartsOptions as m, CompletedMultipartUpload as n, ApiClient as nt, Disk as o, ListObjectsResult as p, MountConfig as q, DeleteObjectsError as r, DiskMultipart as s, AppendObjectOptions as t, FileSystem as tt, GrepResult as u, MultipartUploadSummary as v, PutObjectResult as w, PartListing as x, ObjectMetadata as y, DiskResponse as z };
@@ -44,6 +44,7 @@ type DiskMetrics = components["schemas"]["DiskMetrics"];
44
44
  type ConnectedClient = components["schemas"]["ConnectedClient"];
45
45
  type AuthorizedUser = components["schemas"]["AuthorizedUser"];
46
46
  type CreateDiskRequest = components["schemas"]["CreateDiskRequest"];
47
+ type RootAttrs = components["schemas"]["RootAttrs"];
47
48
  type MountConfig = components["schemas"]["MountConfig"];
48
49
  type S3Mount = components["schemas"]["S3Mount"];
49
50
  type GCSMount = components["schemas"]["GCSMount"];
@@ -384,6 +385,8 @@ declare class Disk implements FileSystem {
384
385
  readonly connectedClients?: ConnectedClient[];
385
386
  readonly authorizedUsers?: AuthorizedUser[];
386
387
  readonly allowedIps?: string[];
388
+ /** Root-directory POSIX attributes recorded at creation, if any. */
389
+ readonly rootAttrs?: RootAttrs;
387
390
  /** @internal */
388
391
  private readonly _client;
389
392
  /** @internal */
@@ -706,4 +709,4 @@ declare class DiskMultipart {
706
709
  */
707
710
  declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
708
711
  //#endregion
709
- export { TokenUser as $, ApiTokenResponse as A, DiskStatus as B, PutObjectOptions as C, ShareUrlResult as D, ShareUrlOptions as E, CreateApiTokenRequest as F, GrepMatch as G, ExecDiskResult as H, CreateDiskRequest as I, MountConfigResponse as J, GrepStoppedReason as K, Delegation as L, AwsStsUser as M, AzureBlobMount as N, UploadPart as O, ConnectedClient as P, S3Mount as Q, DiskMetrics as R, PosixCreateAttrs as S, S3Object as T, ExecRequest as U, DiskUser as V, GCSMount as W, R2Mount as X, MountResponse as Y, S3CompatibleMount as Z, MultipartUploadListing as _, DeleteObjectsResult as a, PartInfo as b, ExecResult as c, ListMultipartUploadsOptions as d, FileSystem as et, ListObjectsOptions as f, MultipartUpload as g, MountOptions as h, DeleteObjectsOptions as i, AuthorizedUser as j, effectiveUploadPartSize as k, GrepOptions as l, ListPartsOptions as m, CompletedMultipartUpload as n, Disk as o, ListObjectsResult as p, MountConfig as q, DeleteObjectsError as r, DiskMultipart as s, AppendObjectOptions as t, ApiClient as tt, GrepResult as u, MultipartUploadSummary as v, PutObjectResult as w, PartListing as x, ObjectMetadata as y, DiskResponse as z };
712
+ export { S3Mount as $, ApiTokenResponse as A, DiskStatus as B, PutObjectOptions as C, ShareUrlResult as D, ShareUrlOptions as E, CreateApiTokenRequest as F, GrepMatch as G, ExecDiskResult as H, CreateDiskRequest as I, MountConfigResponse as J, GrepStoppedReason as K, Delegation as L, AwsStsUser as M, AzureBlobMount as N, UploadPart as O, ConnectedClient as P, S3CompatibleMount as Q, DiskMetrics as R, PosixCreateAttrs as S, S3Object as T, ExecRequest as U, DiskUser as V, GCSMount as W, R2Mount as X, MountResponse as Y, RootAttrs as Z, MultipartUploadListing as _, DeleteObjectsResult as a, PartInfo as b, ExecResult as c, ListMultipartUploadsOptions as d, TokenUser as et, ListObjectsOptions as f, MultipartUpload as g, MountOptions as h, DeleteObjectsOptions as i, AuthorizedUser as j, effectiveUploadPartSize as k, GrepOptions as l, ListPartsOptions as m, CompletedMultipartUpload as n, ApiClient as nt, Disk as o, ListObjectsResult as p, MountConfig as q, DeleteObjectsError as r, DiskMultipart as s, AppendObjectOptions as t, FileSystem as tt, GrepResult as u, MultipartUploadSummary as v, PutObjectResult as w, PartListing as x, ObjectMetadata as y, DiskResponse as z };