disk 0.8.23 → 0.10.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
@@ -83,23 +83,38 @@ const client = new archil.Archil({
83
83
  apiKey: process.env.ARCHIL_API_KEY,
84
84
  region: "aws-us-east-1",
85
85
  });
86
- const sandbox = await client.sandboxes.create({ vcpuCount: 2, memSizeMiB: 4096 });
86
+ const sandbox = await client.sandboxes.create({
87
+ name: "prepared-environment",
88
+ vcpuCount: 4,
89
+ memSizeMiB: 8192,
90
+ });
87
91
 
88
92
  const result = await sandbox.exec("uname -a");
89
93
  console.log(result.stdout);
90
94
 
91
- await sandbox.stop();
92
95
  await sandbox.start();
93
- await sandbox.pause();
94
96
  await sandbox.resume();
95
97
 
98
+ // Return the initial state immediately instead of waiting for completion.
99
+ const runningExec = await sandbox.exec("sleep 60", { wait: false });
100
+
101
+ await sandbox.stop();
102
+ const fork = await sandbox.fork({ name: "agent-task" });
103
+ const connection = await fork.createConnection();
104
+ await fork.stop();
105
+ await fork.delete();
106
+
96
107
  const all = await client.sandboxes.list();
97
108
  const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
98
109
  ```
99
110
 
100
- `create`, `start`, `stop`, `pause`, `resume`, and `exec` wait up to 30 seconds by default.
101
- Set `timeoutMs` to change the limit. A `SandboxWaitTimeoutError` includes the latest
102
- resource state.
111
+ Sandboxes support 1–32 vCPUs and 256–65,536 MiB of memory. When omitted,
112
+ `vcpuCount` defaults to 1 and `memSizeMiB` defaults to 2,048 MiB.
113
+
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.
103
118
 
104
119
  API keys live at the account level, so those helpers are top-level:
105
120
 
@@ -134,6 +149,79 @@ if (await d.objectExists("reports/2026-01/data.json")) { /* … */ }
134
149
  await d.deleteObject("reports/2026-01/data.json");
135
150
  ```
136
151
 
152
+ #### POSIX ownership and directories
153
+
154
+ Pass `uid`, `gid`, and `mode` when the files will be used by a non-root process:
155
+
156
+ ```ts
157
+ await d.putObject("path/a/b/file.txt", "hello", {
158
+ uid: 1000,
159
+ gid: 1001,
160
+ mode: 0o640,
161
+ });
162
+ ```
163
+
164
+ If `path/` already exists as `2000:2000 0700` and `a/` and `b/` are missing,
165
+ the resulting tree is:
166
+
167
+ | Path | Owner | Mode | Result |
168
+ | --- | --- | --- | --- |
169
+ | `path/` | `2000:2000` | `0700` | Existing directory; unchanged |
170
+ | `path/a/` | `1000:1001` | `0755` | Implicit parent created by the upload |
171
+ | `path/a/b/` | `1000:1001` | `0755` | Implicit parent created by the upload |
172
+ | `path/a/b/file.txt` | `1000:1001` | `0640` | Published file with the requested attributes |
173
+
174
+ The requested file mode never applies to implicit parents; they use `0755` so
175
+ they remain traversable. Existing directories are never re-owned or re-moded,
176
+ so in this example a FUSE process running as uid 1000 still cannot traverse the
177
+ pre-existing `path/` directory.
178
+
179
+ Create an explicit directory by putting an empty directory-marker key ending in
180
+ `/`:
181
+
182
+ ```ts
183
+ await d.putObject("path/a/private/", "", {
184
+ uid: 4000,
185
+ gid: 4001,
186
+ mode: 0o750,
187
+ });
188
+ ```
189
+
190
+ This creates `private/` as `4000:4001 0750`. If the marker already exists, its
191
+ attributes are unchanged. When attributes are omitted, files default to
192
+ `root:root 0644` and directories to `root:root 0755`. Automatic multipart
193
+ uploads and append-created files use the same directory rules.
194
+
195
+ The disk **root** itself defaults to `root:root 0755`, which means an
196
+ unprivileged process cannot create entries directly under the mount root. To
197
+ avoid a post-mount `chown`, set the root's owner and mode when creating the
198
+ disk (creation-time only; a later `chown`/`chmod` through a mount changes the
199
+ live attributes as usual):
200
+
201
+ ```ts
202
+ const { disk } = await archil.createDisk({
203
+ name: "my-disk",
204
+ rootAttrs: { uid: 1000, gid: 1000, mode: 0o755 },
205
+ });
206
+ ```
207
+
208
+ `mode` is octal (pass `0o750`, not `750`). On regions that don't support
209
+ `rootAttrs` yet the field is ignored and the disk is created with the
210
+ defaults — check the `rootAttrs` field on the created disk to confirm it
211
+ was applied.
212
+
213
+ `rootAttrs` only sets the root directory itself — it does not change how
214
+ later writes get their attributes:
215
+
216
+ - **Through a mount**, normal POSIX rules apply: entries are owned by the
217
+ creating process's uid/gid, with mode derived from its umask. A process
218
+ running as the `rootAttrs` uid therefore owns everything it creates, with
219
+ no attributes to pass anywhere.
220
+ - **Through `putObject` and friends**, omitted attributes still mean the
221
+ server defaults (`root:root 0644` files, `root:root 0755` directories) —
222
+ the disk's `rootAttrs` is *not* used as a fallback. Keep passing
223
+ `uid`/`gid` on object writes when a non-root process will read them.
224
+
137
225
  `listObjects` auto-paginates by default, returning every matching key. The first
138
226
  argument is a key prefix; a non-recursive listing (the default) returns the
139
227
  immediate level as `objects` plus subdirectory `commonPrefixes`:
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { D 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-DgL0HTS-.mjs";
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-DyVzhbAB.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { Command, Option } from "commander";
5
5
  //#region bin/cli.ts
@@ -80,7 +80,8 @@ function printDisk(d) {
80
80
  ["region", d.region],
81
81
  ["created", d.createdAt],
82
82
  ["last accessed", d.lastAccessed],
83
- ["data size", formatBytes(d.dataSize)],
83
+ ["active data", formatBytes(d.activeDataBytes)],
84
+ ["total data", formatBytes(d.totalDataBytes)],
84
85
  ["monthly usage", d.monthlyUsage]
85
86
  ].filter(([, v]) => v !== void 0 && v !== null && v !== "").map(([k, v]) => [k, String(v)]);
86
87
  console.log("");
@@ -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"];
@@ -308,11 +309,13 @@ interface DeleteObjectsResult {
308
309
  }
309
310
  /**
310
311
  * POSIX attributes to set on a newly created object, sent to the S3 gateway as
311
- * `x-archil-*` headers. All optional — anything omitted falls back to the
312
- * server-side defaults (currently `root:root`, mode `0644`).
312
+ * `x-archil-*` headers. Missing parent directories inherit `uid` / `gid` and
313
+ * use mode `0755`; existing directories are unchanged. All fields are optional
314
+ * — new files default to `root:root 0644`, while directory markers default to
315
+ * `root:root 0755`.
313
316
  */
314
317
  interface PosixCreateAttrs {
315
- /** POSIX mode bits for the created file, e.g. `0o644`. Sent in octal. */
318
+ /** POSIX mode bits for the created file or directory marker. Sent in octal. */
316
319
  mode?: number;
317
320
  /** Owning user id, e.g. `1000`. */
318
321
  uid?: number;
@@ -372,6 +375,9 @@ declare class Disk implements FileSystem {
372
375
  readonly createdAt: string;
373
376
  readonly fsHandlerStatus?: string;
374
377
  readonly lastAccessed?: string;
378
+ readonly activeDataBytes?: number;
379
+ readonly totalDataBytes?: number;
380
+ /** @deprecated Use {@link activeDataBytes}. */
375
381
  readonly dataSize?: number;
376
382
  readonly monthlyUsage?: string;
377
383
  readonly mounts?: MountResponse[];
@@ -379,6 +385,8 @@ declare class Disk implements FileSystem {
379
385
  readonly connectedClients?: ConnectedClient[];
380
386
  readonly authorizedUsers?: AuthorizedUser[];
381
387
  readonly allowedIps?: string[];
388
+ /** Root-directory POSIX attributes recorded at creation, if any. */
389
+ readonly rootAttrs?: RootAttrs;
382
390
  /** @internal */
383
391
  private readonly _client;
384
392
  /** @internal */
@@ -487,7 +495,10 @@ declare class Disk implements FileSystem {
487
495
  *
488
496
  * Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
489
497
  * file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
490
- * sandbox). Defaults are server-side (currently `root:root` mode `0644`).
498
+ * sandbox). Missing parent directories inherit `uid` / `gid` with mode
499
+ * `0755`; existing directories remain unchanged. A key ending in `/` creates
500
+ * an explicit directory marker whose leaf uses the requested attributes.
501
+ * Defaults are `root:root 0644` for files and `root:root 0755` for directories.
491
502
  *
492
503
  * @param key Path on the disk (e.g. "reports/2026-01/data.json")
493
504
  * @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
@@ -520,7 +531,8 @@ declare class Disk implements FileSystem {
520
531
  *
521
532
  * When the object does not yet exist, optional `mode` / `uid` / `gid` set the
522
533
  * POSIX attributes of the newly created file (same headers as
523
- * {@link putObject}); they have no effect on an append to an existing object.
534
+ * {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
535
+ * Existing files and directories are unchanged.
524
536
  *
525
537
  * @param key Path on the disk (e.g. "logs/app.log")
526
538
  * @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
@@ -697,4 +709,4 @@ declare class DiskMultipart {
697
709
  */
698
710
  declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
699
711
  //#endregion
700
- 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"];
@@ -308,11 +309,13 @@ interface DeleteObjectsResult {
308
309
  }
309
310
  /**
310
311
  * POSIX attributes to set on a newly created object, sent to the S3 gateway as
311
- * `x-archil-*` headers. All optional — anything omitted falls back to the
312
- * server-side defaults (currently `root:root`, mode `0644`).
312
+ * `x-archil-*` headers. Missing parent directories inherit `uid` / `gid` and
313
+ * use mode `0755`; existing directories are unchanged. All fields are optional
314
+ * — new files default to `root:root 0644`, while directory markers default to
315
+ * `root:root 0755`.
313
316
  */
314
317
  interface PosixCreateAttrs {
315
- /** POSIX mode bits for the created file, e.g. `0o644`. Sent in octal. */
318
+ /** POSIX mode bits for the created file or directory marker. Sent in octal. */
316
319
  mode?: number;
317
320
  /** Owning user id, e.g. `1000`. */
318
321
  uid?: number;
@@ -372,6 +375,9 @@ declare class Disk implements FileSystem {
372
375
  readonly createdAt: string;
373
376
  readonly fsHandlerStatus?: string;
374
377
  readonly lastAccessed?: string;
378
+ readonly activeDataBytes?: number;
379
+ readonly totalDataBytes?: number;
380
+ /** @deprecated Use {@link activeDataBytes}. */
375
381
  readonly dataSize?: number;
376
382
  readonly monthlyUsage?: string;
377
383
  readonly mounts?: MountResponse[];
@@ -379,6 +385,8 @@ declare class Disk implements FileSystem {
379
385
  readonly connectedClients?: ConnectedClient[];
380
386
  readonly authorizedUsers?: AuthorizedUser[];
381
387
  readonly allowedIps?: string[];
388
+ /** Root-directory POSIX attributes recorded at creation, if any. */
389
+ readonly rootAttrs?: RootAttrs;
382
390
  /** @internal */
383
391
  private readonly _client;
384
392
  /** @internal */
@@ -487,7 +495,10 @@ declare class Disk implements FileSystem {
487
495
  *
488
496
  * Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
489
497
  * file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
490
- * sandbox). Defaults are server-side (currently `root:root` mode `0644`).
498
+ * sandbox). Missing parent directories inherit `uid` / `gid` with mode
499
+ * `0755`; existing directories remain unchanged. A key ending in `/` creates
500
+ * an explicit directory marker whose leaf uses the requested attributes.
501
+ * Defaults are `root:root 0644` for files and `root:root 0755` for directories.
491
502
  *
492
503
  * @param key Path on the disk (e.g. "reports/2026-01/data.json")
493
504
  * @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
@@ -520,7 +531,8 @@ declare class Disk implements FileSystem {
520
531
  *
521
532
  * When the object does not yet exist, optional `mode` / `uid` / `gid` set the
522
533
  * POSIX attributes of the newly created file (same headers as
523
- * {@link putObject}); they have no effect on an append to an existing object.
534
+ * {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
535
+ * Existing files and directories are unchanged.
524
536
  *
525
537
  * @param key Path on the disk (e.g. "logs/app.log")
526
538
  * @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
@@ -697,4 +709,4 @@ declare class DiskMultipart {
697
709
  */
698
710
  declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
699
711
  //#endregion
700
- 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 };