disk 0.8.22 → 0.9.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 +85 -0
- package/dist/cli.mjs +3 -2
- package/dist/{disk-DEqV3mtA.d.cts → disk-DseHuBL7.d.cts} +14 -5
- package/dist/{disk-DEqV3mtA.d.mts → disk-DseHuBL7.d.mts} +14 -5
- package/dist/index.cjs +378 -8
- package/dist/index.d.cts +203 -2
- package/dist/index.d.mts +203 -2
- package/dist/index.mjs +2 -2
- package/dist/internal/tools.d.cts +1 -1
- package/dist/internal/tools.d.mts +1 -1
- package/dist/{src-BepELcl6.mjs → src-CR3Ksi_s.mjs} +372 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -74,6 +74,48 @@ await d.removeUser("token", user.identifier!);
|
|
|
74
74
|
await d.delete();
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
### Sandboxes
|
|
78
|
+
|
|
79
|
+
Use `Archil.sandboxes` to manage persistent VMs:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
const client = new archil.Archil({
|
|
83
|
+
apiKey: process.env.ARCHIL_API_KEY,
|
|
84
|
+
region: "aws-us-east-1",
|
|
85
|
+
});
|
|
86
|
+
const sandbox = await client.sandboxes.create({
|
|
87
|
+
name: "prepared-environment",
|
|
88
|
+
vcpuCount: 4,
|
|
89
|
+
memSizeMiB: 8192,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const result = await sandbox.exec("uname -a");
|
|
93
|
+
console.log(result.stdout);
|
|
94
|
+
|
|
95
|
+
await sandbox.start();
|
|
96
|
+
await sandbox.resume();
|
|
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
|
+
|
|
107
|
+
const all = await client.sandboxes.list();
|
|
108
|
+
const usingDisk = await client.sandboxes.list({ disk: "dsk-abc123" });
|
|
109
|
+
```
|
|
110
|
+
|
|
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.
|
|
118
|
+
|
|
77
119
|
API keys live at the account level, so those helpers are top-level:
|
|
78
120
|
|
|
79
121
|
```ts
|
|
@@ -107,6 +149,49 @@ if (await d.objectExists("reports/2026-01/data.json")) { /* … */ }
|
|
|
107
149
|
await d.deleteObject("reports/2026-01/data.json");
|
|
108
150
|
```
|
|
109
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
|
+
|
|
110
195
|
`listObjects` auto-paginates by default, returning every matching key. The first
|
|
111
196
|
argument is a key prefix; a non-recursive listing (the default) returns the
|
|
112
197
|
immediate level as `objects` plus subdirectory `commonPrefixes`:
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
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";
|
|
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
|
|
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("");
|
|
@@ -308,11 +308,13 @@ interface DeleteObjectsResult {
|
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* POSIX attributes to set on a newly created object, sent to the S3 gateway as
|
|
311
|
-
* `x-archil-*` headers.
|
|
312
|
-
*
|
|
311
|
+
* `x-archil-*` headers. Missing parent directories inherit `uid` / `gid` and
|
|
312
|
+
* use mode `0755`; existing directories are unchanged. All fields are optional
|
|
313
|
+
* — new files default to `root:root 0644`, while directory markers default to
|
|
314
|
+
* `root:root 0755`.
|
|
313
315
|
*/
|
|
314
316
|
interface PosixCreateAttrs {
|
|
315
|
-
/** POSIX mode bits for the created file
|
|
317
|
+
/** POSIX mode bits for the created file or directory marker. Sent in octal. */
|
|
316
318
|
mode?: number;
|
|
317
319
|
/** Owning user id, e.g. `1000`. */
|
|
318
320
|
uid?: number;
|
|
@@ -372,6 +374,9 @@ declare class Disk implements FileSystem {
|
|
|
372
374
|
readonly createdAt: string;
|
|
373
375
|
readonly fsHandlerStatus?: string;
|
|
374
376
|
readonly lastAccessed?: string;
|
|
377
|
+
readonly activeDataBytes?: number;
|
|
378
|
+
readonly totalDataBytes?: number;
|
|
379
|
+
/** @deprecated Use {@link activeDataBytes}. */
|
|
375
380
|
readonly dataSize?: number;
|
|
376
381
|
readonly monthlyUsage?: string;
|
|
377
382
|
readonly mounts?: MountResponse[];
|
|
@@ -487,7 +492,10 @@ declare class Disk implements FileSystem {
|
|
|
487
492
|
*
|
|
488
493
|
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
489
494
|
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
490
|
-
* sandbox).
|
|
495
|
+
* sandbox). Missing parent directories inherit `uid` / `gid` with mode
|
|
496
|
+
* `0755`; existing directories remain unchanged. A key ending in `/` creates
|
|
497
|
+
* an explicit directory marker whose leaf uses the requested attributes.
|
|
498
|
+
* Defaults are `root:root 0644` for files and `root:root 0755` for directories.
|
|
491
499
|
*
|
|
492
500
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
493
501
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
@@ -520,7 +528,8 @@ declare class Disk implements FileSystem {
|
|
|
520
528
|
*
|
|
521
529
|
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
522
530
|
* POSIX attributes of the newly created file (same headers as
|
|
523
|
-
* {@link putObject});
|
|
531
|
+
* {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
|
|
532
|
+
* Existing files and directories are unchanged.
|
|
524
533
|
*
|
|
525
534
|
* @param key Path on the disk (e.g. "logs/app.log")
|
|
526
535
|
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|
|
@@ -308,11 +308,13 @@ interface DeleteObjectsResult {
|
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* POSIX attributes to set on a newly created object, sent to the S3 gateway as
|
|
311
|
-
* `x-archil-*` headers.
|
|
312
|
-
*
|
|
311
|
+
* `x-archil-*` headers. Missing parent directories inherit `uid` / `gid` and
|
|
312
|
+
* use mode `0755`; existing directories are unchanged. All fields are optional
|
|
313
|
+
* — new files default to `root:root 0644`, while directory markers default to
|
|
314
|
+
* `root:root 0755`.
|
|
313
315
|
*/
|
|
314
316
|
interface PosixCreateAttrs {
|
|
315
|
-
/** POSIX mode bits for the created file
|
|
317
|
+
/** POSIX mode bits for the created file or directory marker. Sent in octal. */
|
|
316
318
|
mode?: number;
|
|
317
319
|
/** Owning user id, e.g. `1000`. */
|
|
318
320
|
uid?: number;
|
|
@@ -372,6 +374,9 @@ declare class Disk implements FileSystem {
|
|
|
372
374
|
readonly createdAt: string;
|
|
373
375
|
readonly fsHandlerStatus?: string;
|
|
374
376
|
readonly lastAccessed?: string;
|
|
377
|
+
readonly activeDataBytes?: number;
|
|
378
|
+
readonly totalDataBytes?: number;
|
|
379
|
+
/** @deprecated Use {@link activeDataBytes}. */
|
|
375
380
|
readonly dataSize?: number;
|
|
376
381
|
readonly monthlyUsage?: string;
|
|
377
382
|
readonly mounts?: MountResponse[];
|
|
@@ -487,7 +492,10 @@ declare class Disk implements FileSystem {
|
|
|
487
492
|
*
|
|
488
493
|
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
489
494
|
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
490
|
-
* sandbox).
|
|
495
|
+
* sandbox). Missing parent directories inherit `uid` / `gid` with mode
|
|
496
|
+
* `0755`; existing directories remain unchanged. A key ending in `/` creates
|
|
497
|
+
* an explicit directory marker whose leaf uses the requested attributes.
|
|
498
|
+
* Defaults are `root:root 0644` for files and `root:root 0755` for directories.
|
|
491
499
|
*
|
|
492
500
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
493
501
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
@@ -520,7 +528,8 @@ declare class Disk implements FileSystem {
|
|
|
520
528
|
*
|
|
521
529
|
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
522
530
|
* POSIX attributes of the newly created file (same headers as
|
|
523
|
-
* {@link putObject});
|
|
531
|
+
* {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
|
|
532
|
+
* Existing files and directories are unchanged.
|
|
524
533
|
*
|
|
525
534
|
* @param key Path on the disk (e.g. "logs/app.log")
|
|
526
535
|
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|