disk package on npm. It’s a pure-JavaScript control-plane client and CLI: create disks, list and inspect them, manage who can mount them, and run commands against them with disk.exec.
disk has no native dependencies and works on any platform Node.js does. For the rare case where you need raw protocol access from Node (inodes, delegations, byte-level reads), there’s a separate @archildata/native package — most users will not need it.
| Package | When to use |
|---|---|
disk | Manage disks, run commands with disk.exec, manage API keys. The default. |
@archildata/native | Speak the Archil filesystem protocol directly from Node. Linux/macOS only. Not recommended unless you’re building a custom client runtime. |
Looking for the FUSE mount client? That’s the
archil CLI, which mounts a disk as a real local filesystem. The TypeScript SDK does not mount disks; it talks to the control plane and runs serverless commands.Configuration
The recommended pattern is a module-namespace import with a one-timeconfigure call:
ARCHIL_API_KEY, ARCHIL_REGION) if omitted, so in most environments configure({}) — or skipping configure entirely — is enough.
For multi-tenant scripts that need multiple credentials in one process, instantiate Archil directly instead:
The API key is an account-level credential and is not the same thing as a disk token. API keys authenticate calls to the control plane (everything in this page); a disk token grants mount access to a single disk. See the disk users concept page.
Managing disks
Disk object itself, not top-level functions:
Executing commands
Disk.exec(command) runs a bash command inside a container with the file system already mounted, and returns stdout, stderr, exit code, and timing. See the Serverless Execution concept page for the full picture.
archil.exec({ disks, command }) instead of Disk.exec. See Mounting multiple disks in one command.
ExecResult
executeMs — the wall-clock time your command runs — in 1ms increments, with a 100ms minimum per call. Queue time is not billed. The HTTP response returns after 5 minutes, and stdout and stderr are each capped at 128 KiB per invocation — pipe larger outputs to a file on the disk instead.
Fan-out
Because eachexec runs in its own container, Promise.all is a map-reduce:
Disk.grep, which fans the same work out for you and returns structured matches. See the bash tool for agents guide for an end-to-end example wiring disk.exec into an AI agent loop.
Searching files
Disk.grep(opts) searches the files on a disk for lines matching a regular expression, fanning the listing and matching out across many ephemeral containers so the search scales across many machines instead of one. It’s the productized version of the fan-out above — reach for it instead of Promise.all over exec("grep …") whenever you just want matching lines. See Search Files for the full model.
maxDurationSeconds— wall-clock deadline (default 30, capped at 30).concurrency— max parallel workers (default 50). More workers scan a large dataset faster, at proportionally more compute.maxResults— short-circuit once this many matches are collected (default 1000).
stoppedReason — it tells you whether the search was exhaustive. When it stops early, the returned matches are a sample of whichever workers reported first, not the lexicographically first N:
stoppedReason | Meaning |
|---|---|
completed | Every file under the directory was scanned successfully. The matches are exhaustive. |
max_results | Stopped after collecting maxResults matches before scanning everything. |
deadline | Hit maxDurationSeconds before scanning everything. |
incomplete | The pipeline finished but one or more batches errored (invalid regex, unreadable file). Results may be partial. |
list_failed | Directory listing failed; only partial results, if any, are present. |
GrepResult
exec, so it bills the same way — on computeSecondsUsed, the summed execution time across the containers it dispatched.
Reading and writing objects
ADisk doubles as an S3-compatible bucket: read, write, delete, and list its files by key without mounting it. These methods talk to Archil’s S3 endpoint using your same API key — no separate S3 credentials or SigV4 signing on your part.
putObject handles any size with one call: small bodies go through a single request, and larger bodies are uploaded as a multipart upload automatically — split into parts, uploaded with bounded concurrency, and assembled, aborting the upload if any part fails so nothing is left half-staged. You don’t pick a different method for big files. Tune the switch point and parallelism with options:
listObjects auto-paginates by default, returning every matching key. The first argument is a key prefix; a non-recursive listing (the default) returns the immediate level as objects plus subdirectory commonPrefixes:
deleteObjects removes many keys in one round trip (auto-batched at S3’s 1,000-key limit). Unlike deleteObject, per-key failures are returned rather than thrown:
appendObject appends bytes to an existing object (creating it if absent) — handy for log-style writes. Each call may append at most 1 MiB; append in chunks to grow past that:
d.multipart namespace — create, uploadPart, complete, abort, listParts, listUploads. Most code never needs these; prefer putObject, which runs the lifecycle for you.
completeMultipartUpload and appendObject — are not auto-retried, since a retry after a succeeded-but-unacknowledged call would return a spurious NoSuchUpload or duplicate the appended bytes.
Object-API failures throw ArchilS3Error (a subclass of ArchilError) with status (HTTP status), code (the S3 error code, e.g. "NoSuchKey"), requestId, and the raw XML body on raw. getObject on a missing key throws a 404 — use headObject / objectExists to probe without catching.
Managing API keys
API keys are account-level, so these helpers live at the top level rather than on aDisk:
CLI
disk ships a CLI under the same name. See the disk CLI reference for the full command list.
Low-level protocol access
For the small number of integrations that need to speak Archil’s filesystem protocol directly from Node — inodes, delegations, byte-level reads, paginated directory enumeration — install@archildata/native alongside disk:
Disk.mount(), which lazy-loads the native client:
@archildata/native ships prebuilt binaries for Linux (x64, arm64, glibc) and macOS (arm64). On other platforms, mount() throws; the rest of disk still works.
If you’re tempted to reach for
@archildata/native to “run a bash command on a disk,” use disk.exec instead — it gives you a real shell with the filesystem mounted in a container, with no native dependencies on the caller side.Need a bash executor inside Node?
The legacy@archildata/just-bash package implements a JavaScript bash interpreter that talks to a disk through @archildata/native. It’s still published, but for almost every use case disk.exec is the better answer — it runs your command in a real container with the filesystem mounted, returns stdout/stderr/exit code, and has no native dependencies on the caller.