Skip to main content
The Sail TypeScript SDK (@sailresearch/sdk on npm) runs on Node 22+ and Bun. It shares one engine with the Python and Rust SDKs, so behavior matches across languages.

Install

Prebuilt native binaries are published per platform (Linux, macOS, Windows) and selected automatically at install time. The Sail API warns when your SDK version is nearing the end of its support window. The SDK prints that warning to stderr once per process. A version past the end of its support window is rejected with an upgrade error before any operation runs. Upgrade with npm install @sailresearch/sdk@latest.

Configure

Set SAIL_API_KEY in the environment; the SDK also reads the credential sail auth login stores under ~/.sail. The statics on Sailbox, App, and Volume use this configuration by default, or construct a Client explicitly with Client.fromConfig({ apiKey }). See Configuration.

Quickstart

Errors

Every failure the SDK recognizes extends SailError, so one catch (e) { if (e instanceof SailError) } handles them; a truly unexpected native error surfaces unchanged. Subclasses like NotFoundError and SailboxExecutionError match specific failures, every error carries an advisory retryable flag, and isSailError() is the realm-safe check. See Errors.

Reference

The docs below are auto-generated.

Sailbox

A sandbox (Sailbox): the primary object agent harnesses work with. Create one with Sailbox.create, run commands with exec, move files with fs, expose ports with expose, and manage its lifecycle. The statics use a default env-configured client unless you pass one.

Example

Accessors

appId

Get Signature
get appId(): string | undefined
Identifier of the owning app.
Returns
string | undefined

appName

Get Signature
get appName(): string | undefined
Name of the owning app.
Returns
string | undefined

architecture

Get Signature
get architecture(): string | undefined
CPU architecture (for example arm64).
Returns
string | undefined

checkpointGeneration

Get Signature
get checkpointGeneration(): number | undefined
Checkpoint generation counter as of the snapshot.
Returns
number | undefined

client

Get Signature
get client(): Client
The underlying Client.
Returns
Client

cpuRequestedVcpu

Get Signature
get cpuRequestedVcpu(): number | undefined
Requested CPU, in vCPUs.
Returns
number | undefined

cpuUsedVcpu

Get Signature
get cpuUsedVcpu(): number | undefined
Current CPU usage, in vCPUs, as of the snapshot.
Returns
number | undefined

createdAt

Get Signature
get createdAt(): Date | undefined
When the Sailbox was created.
Returns
Date | undefined

createdByUserId

Get Signature
get createdByUserId(): string | undefined
The user whose credential created this Sailbox (for a fork or restore, the user who ran it). undefined for service-key creates.
Returns
string | undefined

deprecation

Get Signature
get deprecation(): SailboxDeprecation | undefined
Actionable runtime deprecation notice, when an upgrade is needed.
Returns
SailboxDeprecation | undefined

diskRequestedBytes

Get Signature
get diskRequestedBytes(): number | undefined
Requested disk, in bytes.
Returns
number | undefined

diskUsedBytes

Get Signature
get diskUsedBytes(): number | undefined
Current disk usage, in bytes, as of the snapshot.
Returns
number | undefined

errorMessage

Get Signature
get errorMessage(): string | undefined
Failure detail when the status is failed.
Returns
string | undefined

fs

Get Signature
get fs(): SailboxFs
Filesystem operations on this Sailbox’s guest: read and write files (buffered or streaming), and directory helpers.
Returns
SailboxFs

guestSchemaVersion

Get Signature
get guestSchemaVersion(): number | undefined
The Sailbox runtime schema version the Sailbox last booted with.
Returns
number | undefined

imageId

Get Signature
get imageId(): string | undefined
Identifier of the image the Sailbox was created from.
Returns
string | undefined

lastCheckpointedAt

Get Signature
get lastCheckpointedAt(): Date | undefined
When the most recent checkpoint was taken.
Returns
Date | undefined

memoryMib

Get Signature
get memoryMib(): number | undefined
Configured memory, in MiB.
Returns
number | undefined

memoryRequestedBytes

Get Signature
get memoryRequestedBytes(): number | undefined
Requested memory, in bytes.
Returns
number | undefined

memoryUsedBytes

Get Signature
get memoryUsedBytes(): number | undefined
Current memory usage, in bytes, as of the snapshot.
Returns
number | undefined

name

Get Signature
get name(): string
The Sailbox name.
Returns
string

sailboxId

Get Signature
get sailboxId(): string
The Sailbox’s stable identifier.
Returns
string

startedAt

Get Signature
get startedAt(): Date | undefined
When the Sailbox first started running. A resume does not rewrite it.
Returns
Date | undefined

stateDiskSizeGib

Get Signature
get stateDiskSizeGib(): number | undefined
Configured state-disk size, in GiB.
Returns
number | undefined

status

Get Signature
get status(): SailboxStatus
The lifecycle status as of the call that produced this handle (updated by lifecycle calls on this instance). Use Sailbox.get for a fresh snapshot.
Returns
SailboxStatus

updatedAt

Get Signature
get updatedAt(): Date | undefined
When the Sailbox last changed.
Returns
Date | undefined

vcpuCount

Get Signature
get vcpuCount(): number | undefined
Configured number of vCPUs.
Returns
number | undefined

visibility

Get Signature
get visibility(): string | undefined
"private" when access is restricted to the creator; undefined/"org" is the default org-wide access.
Returns
string | undefined

Methods

checkpoint()

checkpoint(options?): Promise<SailboxCheckpoint>
Take a checkpoint of this Sailbox. The returned handle carries expiresAt, after which starting a Sailbox from it fails.
Parameters
Returns
Promise<SailboxCheckpoint>

enableSsh()

enableSsh(options?): Promise<SshEndpoint | null>
Enable SSH on this Sailbox: trust the org SSH CA, start sshd, and expose guest port 22 as TCP once the CA-only daemon owns it. Org members connect with a short-lived certificate (fetched by the sail box ssh CLI); a private Sailbox accepts only its creator’s certificates. Safe to re-run. With wait (the default), polls until the endpoint is reachable and returns it, throwing TimeoutError if it is not within timeoutSeconds; with wait: false, skips the probe and resolves null.
Parameters
Returns
Promise<SshEndpoint | null>

exec()

exec(command, options?): Promise<ExecProcess>
Run a command and return a handle to the live process. A string command is run via /bin/sh -lc; a string[] is exec’d directly. options can set a working directory or detach the command (see ExecOptions). Stopping the command is the caller’s job via ExecProcess.cancel.
Parameters
Returns
Promise<ExecProcess>

expose()

expose(guestPort, options?): Promise<Listener>
Expose a guest port at runtime. Re-exposing a port under the same protocol sets its allowlist to what you pass, so pass the whole list every time; passing none clears the restriction and reopens the port. The returned listener carries the resolved endpoint but an "unknown" route status: the response confirms configuration, not reachability; waitForListener confirms the route is live.
Parameters
Returns
Promise<Listener>

fork()

fork(options?): Promise<Sailbox>
Fork this Sailbox into a new running child in one call. The child copies this Sailbox’s memory and writable disk as they are now, branching from the parent’s current state, and the parent is left as it was. The copy is transient: no durable checkpoint is created. To branch from a saved point in time instead, pair checkpoint with Sailbox.fromCheckpoint, which works even after the parent is gone. Because the memory comes across, processes the parent was running carry on in the child. Commands started with exec stop in the child, though their writes up to the fork are kept, and one started with background: true keeps running there. Start the other execs the child needs. Sometimes the child comes up cold instead, with the disk intact and nothing running, and a child that mounts a volume always does. Volumes are mounted on the child at the same paths as on the parent, and they are the same volumes, so both Sailboxes read and write the same files.
Parameters
Returns
Promise<Sailbox>

ingressAuthHeaders()

ingressAuthHeaders(): Promise<Record<string, string>>
Ingress-identity headers for this Sailbox, as a name→value map.
Returns
Promise<Record<string, string>>

listener()

listener(guestPort): Promise<Listener>
Fetch one listener by guest port without waking the Sailbox.
Parameters
Returns
Promise<Listener>

listeners()

listeners(): Promise<Listener[]>
List this Sailbox’s listeners without waking it.
Returns
Promise<Listener[]>

pause()

pause(): Promise<void>
Pause this Sailbox in memory.
Returns
Promise<void>

resume()

resume(): Promise<void>
Resume this Sailbox (updates status).
Returns
Promise<void>

run()

run(command, options?): Promise<ExecResult>
Run a command to completion and return its buffered result: a one-shot convenience over exec followed by ExecProcess.wait. A string command runs via /bin/sh -lc; a string[] is exec’d directly. Set env in options to add environment variables; cwd sets the working directory (string commands only, like exec); signal force-cancels the command on abort (see RunOptions). The result’s stdout/stderr are the buffered output (capped, drop-oldest); for unbounded output, stream it live via exec instead. openStdin, pty, and background are excluded from RunOptions and rejected at runtime: run() waits for the command to finish and buffers its output, so an interactive command would hang and a backgrounded one would return the launcher’s result, not the command’s; use exec for those.
Parameters
Returns
Promise<ExecResult>

shell()

shell(command?, options?): Promise<number>
Open an interactive pty session on this Sailbox, bridged to the local terminal. With no command, runs a login shell; pass a command to run that under a pty instead (e.g. a REPL or an editor). Blocks until the remote process exits and resolves with its exit code. Requires an interactive terminal (stdin and stdout TTYs) on a Unix machine. While the session is open, browser opens, localhost servers, paste, drag-and-drop, and clipboard are forwarded to your machine (the clipboard is two-way on devbox images); see ShellOptions.noForward.
Parameters
Returns
Promise<number>

sleep()

sleep(wakeAt?): Promise<Date | undefined>
Sleep this Sailbox to disk (wakes on traffic), optionally scheduling a wall-clock wake first. wakeAt, when given, records the wake before the sleep starts and the returned value is the effective wake time: the sooner of this request and any wake already scheduled. If the Sailbox is sleeping when that moment arrives, Sail restores it. The wake can fire a little after the time you set, so treat it as approximate. Sleeping an already-sleeping Sailbox succeeds and just updates the scheduled wake.
Parameters
Returns
Promise<Date | undefined>

terminate()

terminate(): Promise<void>
Terminate (delete) this Sailbox (updates status).
Returns
Promise<void>

unexpose()

unexpose(guestPort): Promise<void>
Remove a runtime ingress port.
Parameters
Returns
Promise<void>

upgrade()

upgrade(): Promise<UpgradeResult>
Upgrade this Sailbox’s runtime.
Returns
Promise<UpgradeResult>

waitForListener()

waitForListener(guestPort, options?): Promise<Listener>
Block until the listener on guestPort is reachable end to end and return it, or throw TimeoutError after timeoutSeconds. An HTTP listener is ready once the guest server answers; a TCP listener once the guest sends bytes or holds the connection open. A connectivity check, not an application health check.
Parameters
Returns
Promise<Listener>

create()

static create(options): Promise<Sailbox>
Create a new Sailbox.A custom image definition passed as image is built first, following the image contract (see Client.buildImageDefinition): the image may boot hidden at build time and periodically while in active use, sharing those boots’ state with every Sailbox created from it via a start snapshot, so generate per-instance identity at runtime, not in boot-time jobs.Sail may sleep a fully idle Sailbox; it wakes transparently on traffic or the next operation.
Parameters
Returns
Promise<Sailbox>

fromCheckpoint()

static fromCheckpoint(options): Promise<Sailbox>
Create a new running Sailbox from a durable checkpoint handle. The new Sailbox restores the memory saved in the checkpoint as well as the writable disk, so processes the original was running carry on here, and it runs independently of the Sailbox that took the checkpoint. Commands started with Sailbox.exec stop here, though their writes up to the checkpoint are kept, and one started with background: true keeps running. Start the other execs the new Sailbox needs. Sometimes it comes up cold instead, with the disk intact and nothing running, and a Sailbox that mounts a volume always does. Volumes are mounted on it at the same paths as on the original, and they are the same volumes, so both Sailboxes read and write the same files.
Parameters
Returns
Promise<Sailbox>

fromId()

static fromId(sailboxId, options?): Sailbox
Bind a handle to an existing Sailbox id without a network call.The returned handle carries no snapshot fields (its name and status are empty), just the operable surface. The id is not verified to exist: operations on an unknown or inaccessible id reject with NotFoundError. Use get to validate the id and fetch a fresh snapshot instead.
Parameters
Returns
Sailbox

get()

static get(sailboxId, options?): Promise<Sailbox>
Fetch an existing Sailbox by id.
Parameters
Returns
Promise<Sailbox>

list()

static list(params?): Promise<Sailbox[]>
List the Sailboxes that match the filters, fetching pages internally until every match (or limit of them) is collected; use listPage to page through results manually instead. limit caps the total returned, bounding the fetch for large orgs. A client can ride along in the query object.
Parameters
Returns
Promise<Sailbox[]>

listPage()

static listPage(params?): Promise<SailboxPage>
List one page of Sailboxes alongside the pagination envelope (total/hasMore). Takes the same filters as list, plus limit and offset to select the page.
Parameters
Returns
Promise<SailboxPage>

App

An app: the billing/ownership scope a Sailbox belongs to. Look one up (or mint it) with App.find, then pass it (or its App.id) to Sailbox.create.

Properties

Methods

find()

static find(name, options?): Promise<App>
Find an app by name, optionally minting it if missing.
Parameters
Returns
Promise<App>

list()

static list(options?): Promise<App[]>
Every app the current org owns, newest first.
Parameters
Returns
Promise<App[]>

Image

A custom image definition. Immutable and fluent: each method returns a new Image. Local files/dirs are recorded here and hashed + uploaded by the core when the image is resolved to a spec (at Sailbox.create, or via toSpec), so chaining stays synchronous.

Example

Methods

addLocalDir()

addLocalDir(localPath, remotePath, options?): Image
Bake a local directory tree into the image at path. Each regular file is hashed + uploaded at resolve; symlinks are skipped and file modes preserved. ignore takes gitignore-style patterns.
Parameters
Returns
Image

addLocalFile()

addLocalFile(localPath, remotePath, options?): Image
Bake one local file into the image at path (absolute POSIX path; a trailing / appends the source basename). Hashed + uploaded at resolve.
Parameters
Returns
Image

aptInstall()

aptInstall(…packages): Image
Install system packages with apt.
Parameters
Returns
Image

build()

build(options?): Promise<ImageSpec>
Upload any local files and build the image, waiting until it is ready. Returns the resolved ImageSpec. Sailbox.create calls this for a custom image before creating the Sailbox (the backend serves the content-addressed built image); a bare base image skips the build. Local files are re-hashed on every call, so edits always reach the build, and rebuilding an unchanged, already-built image returns quickly.
Parameters
Returns
Promise<ImageSpec>

env()

env(env): Image
Bake environment variables into the image (keys are trimmed).
Parameters
Returns
Image

pipInstall()

pipInstall(…packages): Image
Install Python packages with pip.
Parameters
Returns
Image

runCommand()

runCommand(command): Image
Run a shell command during the build.
Parameters
Returns
Image

toSpec()

toSpec(client?): Promise<ImageSpec>
Resolve to an ImageSpec: walks local files/dirs (honoring gitignore), hashes them, and uploads their content via client (defaults to the env client). Sailbox.create calls this for you; use it directly only if you need the raw spec.
Parameters
Returns
Promise<ImageSpec>

debian()

static debian(architecture?): Image
A Debian base image (defaults to arm64).
Parameters
Returns
Image

devbox()

static devbox(architecture?): Image
The devbox base image (defaults to arm64): a prebuilt Debian base with a baked development layer. Prebuilt-only, so it does not support build steps or env; start from Image.debian to customize.
Parameters
Returns
Image

ExecProcess

A live command running in a Sailbox. Stream stdout/stderr, write to writeStdin, and wait for the result. Not killed on GC; call close to detach, or cancel to stop the command.

Example

Properties

Accessors

execRequestId

Get Signature
get execRequestId(): string
The durable exec request id.
Returns
string

idempotencyKey

Get Signature
get idempotencyKey(): string
The idempotency key used to launch the command.
Returns
string

output

Get Signature
get output(): ExecStream
Alias for stdout: under a pty the two output streams merge onto stdout, and output names that merged terminal stream.
Returns
ExecStream

Methods

[asyncDispose]()

[asyncDispose](): Promise<void>
await using support: detaches on scope exit.
Returns
Promise<void>

[dispose]()

[dispose](): void
using support: detaches on scope exit.
Returns
void

cancel()

cancel(options?): Promise<void>
Cancel the command (SIGINT by default, SIGKILL with force). Transient failures are retried briefly, covering the window right after the command starts when the guest cannot accept signals for it yet.
Parameters
Returns
Promise<void>

close()

close(): void
Stop the output pump and detach (does not kill the command). Call this on early exit from streaming a long-running command so the stream is not held until GC.
Returns
void

closeStdin()

closeStdin(): Promise<void>
Close the command’s stdin (send EOF).
Returns
Promise<void>

poll()

poll(): number | null
The exit code if the exit frame has arrived on the stream, else null. Throws for a host-lost exec (no real exit code), as wait does.
Returns
number | null

resize()

resize(cols, rows): Promise<void>
Resize the pty (no-op without one).
Parameters
Returns
Promise<void>

resync()

resync(): Promise<void>
Ask a pty exec to repaint its current screen (no-op without a pty). A command runs at full speed and never waits for a slow reader, so if you fall far behind the oldest output is dropped. Call this after that happens to receive the current screen instead of a broken, partial one. Advisory and best-effort.
Returns
Promise<void>

wait()

wait(): Promise<ExecResult>
Await the authoritative result (exit code, buffered output, flags).
Returns
Promise<ExecResult>

waitStreamEnded()

waitStreamEnded(timeoutSeconds): Promise<boolean>
Wait up to timeoutSeconds for the streams to end; returns whether they did. Infinity waits indefinitely.
Parameters
Returns
Promise<boolean>

writeStdin()

writeStdin(data): Promise<void>
Write to the command’s stdin (requires openStdin).
Parameters
Returns
Promise<void>

ExecStream

An async-iterable view of one exec stream (stdout or stderr). Default iteration yields string chunks, incrementally decoded as UTF-8 (a multibyte character split across chunks is carried until complete); use raw for the unmodified byte stream.

Example

Implements

  • AsyncIterable<string>

Methods

[asyncIterator]()

[asyncIterator](): AsyncIterator<string>
Returns
AsyncIterator<string>
Implementation of
AsyncIterable.[asyncIterator]

bytes()

bytes(): Promise<Buffer<ArrayBufferLike>>
Collect the whole raw byte stream into a single Buffer.
Returns
Promise<Buffer<ArrayBufferLike>>

raw()

raw(): AsyncIterableIterator<Buffer<ArrayBufferLike>>
Iterate the raw byte stream, exactly as the command wrote it (escape sequences and binary payloads included).
Returns
AsyncIterableIterator<Buffer<ArrayBufferLike>>

text()

text(): Promise<string>
Collect the whole stream into a single string.
Returns
Promise<string>

toReadable()

toReadable(): Readable
Adapt to a Node Readable of string chunks (e.g. to .pipe() it).
Returns
Readable

SailboxFs

Filesystem operations on a Sailbox’s guest, reached via Sailbox.fs. File I/O streams bytes to/from the guest; the directory helpers create, remove, and test paths.

Methods

exists()

exists(path): Promise<boolean>
Whether path exists in the guest. Follows symlinks (like test -e), so a dangling symlink reports false even though ls lists it.
Parameters
Returns
Promise<boolean>

ls()

ls(path): Promise<DirEntry[]>
List a directory’s immediate entries as DirEntry records (no recursion). A missing path throws, as does a path that is not a directory and a listing too large for the exec output cap. An entry whose name is not valid UTF-8 fails the listing, since the path API cannot address it.
Parameters
Returns
Promise<DirEntry[]>

mkdir()

mkdir(path): Promise<void>
Create a directory and any missing parents (like mkdir -p); a no-op if it already exists.
Parameters
Returns
Promise<void>

read()

read(path): Promise<Buffer<ArrayBufferLike>>
Read a guest file fully into memory (convenience over readStream).
Parameters
Returns
Promise<Buffer<ArrayBufferLike>>

readStream()

readStream(path): Promise<FileStream>
Open a streaming read of a guest file.
Parameters
Returns
Promise<FileStream>

remove()

remove(path): Promise<void>
Remove a file or directory tree (like rm -rf); a no-op if it is already absent.
Parameters
Returns
Promise<void>

write()

write(path, data, options?): Promise<void>
Write bytes (a string is encoded as UTF-8) to a guest file, creating it and any missing parent directories (convenience over writeStream; pass createParents: false to opt out).
Parameters
Returns
Promise<void>

writeStream()

writeStream(path, options?): Promise<FileWriter>
Open a streaming upload to a guest file.
Parameters
Returns
Promise<FileWriter>

FileWriter

A streaming write to a guest file. Push chunks with write, then confirm with finish; only finish commits the write. A writer that goes away without finishing (abort, an error path, or garbage collection) cancels the transfer instead; the guest file state is then unspecified.

Methods

[asyncDispose]()

[asyncDispose](): Promise<void>
await using support; same semantics as the synchronous form.
Returns
Promise<void>

[dispose]()

[dispose](): void
using support: aborts the write if it was never finished, so leaving scope on an error path cancels instead of committing a partial file. abort is synchronous, so the plain form suffices.
Returns
void

abort()

abort(): void
Abort the write: cancel the RPC so the server does not commit it. Idempotent. A later finish reports the abort instead of succeeding; the guest file state after an abort is unspecified.
Returns
void

finish()

finish(): Promise<void>
Confirm the write, creating an empty file if nothing was written.
Returns
Promise<void>

toWritable()

toWritable(): Writable
Adapt to a Node Writable: end() runs finish (only that commits the write), destroying the stream aborts it, and backpressure follows the underlying transfer since each chunk’s callback fires when the core accepts the bytes.
Returns
Writable

write()

write(data): Promise<void>
Write bytes (a string is encoded as UTF-8). The core splits them into transport-sized chunks.
Parameters
Returns
Promise<void>

FileStream

An async-iterable download of a guest file. Chunks are Buffers; iteration ends at end of file. The underlying stream is released when iteration finishes or is abandoned (via a generator finally), or explicitly via close.

Implements

  • AsyncIterable<Buffer>

Methods

[asyncDispose]()

[asyncDispose](): Promise<void>
await using support.
Returns
Promise<void>

[asyncIterator]()

[asyncIterator](): AsyncIterator<Buffer<ArrayBufferLike>>
Returns
AsyncIterator<Buffer<ArrayBufferLike>>
Implementation of
AsyncIterable.[asyncIterator]

bytes()

bytes(): Promise<Buffer<ArrayBufferLike>>
Collect the whole file into a single Buffer.
Returns
Promise<Buffer<ArrayBufferLike>>

close()

close(): Promise<void>
Release the underlying download stream (idempotent).
Returns
Promise<void>

toReadable()

toReadable(): Readable
Adapt to a Node Readable.
Returns
Readable

Volume

A managed NFS volume that can be mounted into Sailboxes. Look one up (or mint it) with Volume.find, then pass it (or its Volume.id) in a Sailbox’s volumes mapping.Volumes are currently in Alpha. To pilot them, reach out in the Sail Slack: https://join.slack.com/t/sailresearchcrew/shared_invite/zt-41pdcym9j-UU0Ey~A~r6n2H0DQVQsQHQ.

Properties

Methods

delete()

delete(options?): Promise<boolean>
Delete this volume. Resolves true if it was deleted, false if it was already gone (only possible with allowMissing).
Parameters
Returns
Promise<boolean>

find()

static find(name, options?): Promise<Volume>
Look up an NFS volume by name, optionally minting it if missing.
Parameters
Returns
Promise<Volume>

fromMount()

static fromMount(path): Volume
Guest-side: load the volume handle for a path mounted into this Sailbox (reads the mount’s metadata; only available inside a guest).
Parameters
Returns
Volume

list()

static list(options?): Promise<Volume[]>
List NFS volumes in the current org.
Parameters
Returns
Promise<Volume[]>

ingressAuthHeaders()

ingressAuthHeaders(): Record<string, string>
Guest-side: headers that authenticate this Sailbox as an ingress allowlist source (only available inside a Sailbox guest).

Returns

Record<string, string>

Client

A configured Sail client: the low-level surface over the native core (one config snapshot; env vars are read at construction). Every client operation is here. The object-model API (Sailbox, App, Volume) is built on top of it.Construct with Client.fromEnv or Client.fromConfig.

Methods

buildImageDefinition()

buildImageDefinition(def, timeoutSeconds): Promise<ImageSpec>
Resolve an image definition and build it to ready, returning the content-addressed ImageSpec to create Sailboxes from. A bare builtin base skips the build; timeoutSeconds bounds the whole pipeline (hashing, uploads, and the build).Sail may boot the image outside of any Sailbox — once as the final stage of the build, and again periodically while the image is in active use — to capture and refresh a start snapshot so Sailboxes created from it skip the cold boot. Boot-time initialization therefore runs at times you don’t control, and anything it writes becomes part of the snapshot shared by every Sailbox created from this image — generate per-instance identity (machine IDs, nonces, cached credentials) at runtime, not during boot. Per-Sailbox environment, networking, and credentials are injected at create time either way. See “Hidden boots and start snapshots” in the Sailbox images guide.
Parameters
Returns
Promise<ImageSpec>

buildSpecToReady()

buildSpecToReady(spec, timeoutSeconds): Promise<ImageBuild>
Build an already-resolved spec to ready (submit + poll), bounded by timeoutSeconds.
Parameters
Returns
Promise<ImageBuild>

checkpointSailbox()

checkpointSailbox(sailboxId, options?): Promise<SailboxCheckpoint>
Take a checkpoint of a Sailbox. name sets the handle’s display name; ttlSeconds, when given, overrides the server’s default retention window.
Parameters
Returns
Promise<SailboxCheckpoint>

createFromCheckpoint()

createFromCheckpoint(params): Promise<SailboxHandle>
Create a new Sailbox from a checkpoint.
Parameters
Returns
Promise<SailboxHandle>

createSailbox()

createSailbox(req, timeoutSeconds?): Promise<SailboxHandle>
Create a Sailbox. timeoutSeconds bounds each create attempt (default 600s); pass 0 for no client-side timeout. A timed-out attempt is retried, and a retry usually reattaches to the Sailbox already coming up rather than starting another. When the overall budget is exhausted the Sailbox may still be coming up server-side: find or terminate it by name. image defaults to a plain Debian base.
Parameters
Returns
Promise<SailboxHandle>

deleteVolume()

deleteVolume(volumeId, allowMissing?): Promise<VolumeInfo | null>
Delete a volume by id. allowMissing tolerates an already-deleted volume, resolving null instead of throwing.
Parameters
Returns
Promise<VolumeInfo | null>

enableSsh()

enableSsh(sailboxId, options?): Promise<SshEndpoint | null>
Enable SSH on a Sailbox: trust the org SSH CA, start sshd, and expose guest port 22 as TCP once the CA-only daemon owns it. A non-empty allowlist restricts port 22 to those source addresses or ranges, replacing any existing restriction. With wait (the default), polls until the endpoint is reachable and returns it, throwing TimeoutError if it is not within timeoutSeconds; with wait: false, skips the probe and resolves null.
Parameters
Returns
Promise<SshEndpoint | null>

exec()

exec(sailboxId, command, options?): Promise<ExecProcess>
Run a command in a Sailbox and return a handle to the live process. A string command is run via /bin/sh -lc; a string[] is exec’d directly. cwd/background apply to string commands (see ExecOptions). Stopping the command is the caller’s job via ExecProcess.cancel.
Parameters
Returns
Promise<ExecProcess>

exposeListener()

exposeListener(sailboxId, guestPort, protocol?, allowlist?): Promise<Listener>
Expose a guest port at runtime. Re-exposing a port under the same protocol sets its allowlist to what you pass, so pass the whole list every time; an empty one clears the restriction and reopens the port. The route status starts “unknown”: the response confirms configuration, not reachability.
Parameters
Returns
Promise<Listener>

findApp()

findApp(name, mintIfMissing?): Promise<AppInfo>
Find an app by name; mintIfMissing creates it when absent.
Parameters
Returns
Promise<AppInfo>

forkSailbox()

forkSailbox(sailboxId, options?): Promise<SailboxHandle>
Fork a Sailbox into a new running child: a copy of its memory and writable disk as they are now, with no durable checkpoint created (see Sailbox.fork). Sometimes the child comes up cold instead, with the disk intact and nothing running, and a child that mounts a volume always does. The parent may be running, sleeping, or paused.
Parameters
Returns
Promise<SailboxHandle>

getListener()

getListener(sailboxId, guestPort): Promise<Listener>
Fetch one listener by guest port without waking the Sailbox.
Parameters
Returns
Promise<Listener>

getSailbox()

getSailbox(sailboxId): Promise<SailboxInfo>
Fetch one Sailbox by id.
Parameters
Returns
Promise<SailboxInfo>

getVolume()

getVolume(name, mintIfMissing?): Promise<VolumeInfo>
Look up an NFS volume by name; mintIfMissing creates it when absent.
Parameters
Returns
Promise<VolumeInfo>

ingressAuthHeaders()

ingressAuthHeaders(sailboxId): Promise<Record<string, string>>
Ingress-identity headers for this Sailbox, as a name→value map.
Parameters
Returns
Promise<Record<string, string>>

isBuiltinBaseSpec()

isBuiltinBaseSpec(spec): boolean
Whether a spec is a bare builtin base the backend ships prebuilt (no build needed).
Parameters
Returns
boolean

listApps()

listApps(): Promise<AppInfo[]>
Every app the current org owns, newest first.
Returns
Promise<AppInfo[]>

listDir()

listDir(sailboxId, path): Promise<DirEntry[]>
List a directory’s immediate entries as structured records.
Parameters
Returns
Promise<DirEntry[]>

listListeners()

listListeners(sailboxId): Promise<Listener[]>
List a Sailbox’s listeners without waking it.
Parameters
Returns
Promise<Listener[]>

listSailboxes()

listSailboxes(params?): Promise<SailboxInfoPage>
List one page of Sailboxes in the current org.
Parameters
Returns
Promise<SailboxInfoPage>

listVolumes()

listVolumes(maxObjects?): Promise<VolumeInfo[]>
List NFS volumes in the current org.
Parameters
Returns
Promise<VolumeInfo[]>

makeDir()

makeDir(sailboxId, path): Promise<void>
Create a directory and any missing parents (like mkdir -p); a no-op if it already exists.
Parameters
Returns
Promise<void>

orgSshCaPublicKey()

orgSshCaPublicKey(): Promise<string>
Fetch (creating on first use) the org SSH certificate authority public key. Used to preflight SSH before a Sailbox is provisioned.
Returns
Promise<string>

pathExists()

pathExists(sailboxId, path): Promise<boolean>
Whether path exists in the guest.
Parameters
Returns
Promise<boolean>

pauseSailbox()

pauseSailbox(sailboxId): Promise<void>
Pause a Sailbox in memory.
Parameters
Returns
Promise<void>

readStream()

readStream(sailboxId, path): Promise<FileStream>
Open a streaming read of a guest file.
Parameters
Returns
Promise<FileStream>

removePath()

removePath(sailboxId, path): Promise<void>
Remove a file or directory tree (like rm -rf); a no-op if it is already absent.
Parameters
Returns
Promise<void>

resolveImage()

resolveImage(def): Promise<ImageSpec>
Resolve an image definition into a content-addressed ImageSpec: the core walks local directories (gitignore-style ignore), hashes every file, and uploads content the server does not already have.
Parameters
Returns
Promise<ImageSpec>

resumeSailbox()

resumeSailbox(sailboxId): Promise<SailboxHandle>
Resume a paused or sleeping Sailbox.
Parameters
Returns
Promise<SailboxHandle>

shell()

shell(sailboxId, command?, options?): Promise<number>
Open an interactive pty session on a Sailbox, bridged to the local terminal: raw keystrokes reach the remote process, output renders locally, and resizes propagate. Resolves with the remote process’s exit code. Requires an interactive terminal (stdin and stdout TTYs).
Parameters
Returns
Promise<number>

sleepSailbox()

sleepSailbox(sailboxId, wakeAt?): Promise<string | null>
Sleep a Sailbox to disk (wakes on traffic), optionally scheduling a wall-clock wake first. wakeAt is an RFC 3339 timestamp; the returned value is the effective (sooner) wake time, or null when no wake was requested. Most callers use Sailbox.sleep, which takes and returns Date.
Parameters
Returns
Promise<string | null>

terminateSailbox()

terminateSailbox(sailboxId): Promise<void>
Terminate a Sailbox (idempotent).
Parameters
Returns
Promise<void>

unexposeListener()

unexposeListener(sailboxId, guestPort): Promise<void>
Remove a runtime ingress port.
Parameters
Returns
Promise<void>

upgradeSailbox()

upgradeSailbox(sailboxId): Promise<UpgradeResult>
Upgrade a Sailbox’s runtime (now if running, else at next wake).
Parameters
Returns
Promise<UpgradeResult>

waitForListener()

waitForListener(sailboxId, guestPort, timeoutSeconds): Promise<Listener>
Block until the listener on guestPort is reachable end to end and return it, throwing TimeoutError after timeoutSeconds. An HTTP listener is ready once the guest server answers; a TCP listener once the guest sends bytes or holds the connection open. A connectivity check, not an application health check.
Parameters
Returns
Promise<Listener>

writeStream()

writeStream(sailboxId, path, options?): Promise<FileWriter>
Open a streaming upload to a guest file.
Parameters
Returns
Promise<FileWriter>

fromConfig()

static fromConfig(config): Client
Build a client from an explicit ClientConfig.
Parameters
Returns
Client

fromEnv()

static fromEnv(): Client
Build a client from the environment (SAIL_API_KEY, …).
Returns
Client

defaultClient()

defaultClient(): Client
The process-wide client used by the object-model statics (Sailbox, App, Volume) when no explicit client is passed. Created lazily from the environment on first use.

Returns

Client

setDefaultClient()

setDefaultClient(client): void
Override (or clear, with undefined) the process-wide default client. Useful for tests or to point the object-model API at an explicitly configured client.

Parameters

Returns

void

resolveConfig()

resolveConfig(): ResolvedConfig
Resolve the SDK config from the environment (SAIL_API_KEY, SAIL_API_URL, SAILBOX_API_URL, …) and ~/.sail, without requiring an API key. The core is the single source of truth for endpoint resolution.

Returns

ResolvedConfig

isSailError()

isSailError(err): err is SailError
Whether err is a SailError, matched on the stable shape (code string plus retryable boolean) rather than the prototype chain. Use it where instanceof can lie: across realms (worker threads, vm contexts) or when two copies of the SDK are loaded. It does not survive structuredClone or postMessage serialization, which strip an Error’s custom fields; send { name, message, code, retryable } yourself when an error must cross a serialization boundary.

Parameters

Returns

err is SailError

Types

Plain data types accepted by and returned from the calls above.

AddLocalDir

A tree of local files copied into the image.

Properties


AddLocalDirFile

One file within an addLocalDir step.

Properties


AddLocalDirOptions

Options for Image.addLocalDir.

Properties


AddLocalFile

One local file copied into the image, referenced by content hash.

Properties


AddLocalFileOptions

Options for Image.addLocalFile.

Properties


AppInfo

A Sail app.

Properties


BaseImage

BaseImage = "debian" | "devbox"

CancelOptions

Options for cancelling an exec.

Properties


CheckpointOptions

Options for Sailbox.checkpoint.

Properties


ClientConfig

Explicit client configuration (an alternative to environment resolution).

Extends

  • Omit<native.ClientConfig, "mode">

Properties


ClientOptions

Options for statics that select which Client to use.

Extended by

Properties


CreateSailboxOptions

Options for Sailbox.create: the create request plus a per-attempt timeout and an optional explicit client. image defaults to a Debian base.

Extends

Properties


CreateSailboxRequest

Extends

  • Omit<native.CreateSailboxRequest, "image" | "ingressPorts" | "size" | "volumeMounts">

Properties


DeleteVolumeOptions

Options for Volume.delete.

Properties


DirEntry

One entry in a directory listing from Sailbox.fs.ls. The shape comes from the core, with type narrowed to the closed set the SDK emits; the generated declaration widens it to string.

Extends

  • Omit<native.DirEntry, "type">

Properties


DirEntryType

DirEntryType = "file" | "directory" | "symlink" | "other"
The kind of a directory entry, reported for the entry itself: a symlink is "symlink" regardless of what it points at.

EnableSshOptions

Options for enabling SSH on a Sailbox.

Properties


ExecOptions

Options for starting an exec (see the field docs on the generated ExecStartOptions).

Extends

  • Omit<native.ExecStartOptions, "env">

Properties


ExecResult

The authoritative result of a finished exec.The buffered stdout/stderr are a capped, drop-oldest tail (the server keeps a bounded ring). To capture the complete output of a large-output command, stream it live and consult the *Truncated/*Complete flags.

Properties


ExposeOptions

Options for Sailbox.expose.

Properties


FindAppOptions

Options for App.find.

Extends

Properties


FindVolumeOptions

Options for Volume.find.

Extends

Properties


ForkSailboxOptions

Options for Sailbox.fork.

Properties


FromCheckpointOptions

Options for Sailbox.fromCheckpoint.

Extends

Properties


FromCheckpointRequest

The create-from-checkpoint request.

Extended by

Properties


HttpEndpoint

The routable HTTPS address of an http listener.

Properties


ImageArchitecture

ImageArchitecture = "amd64" | "arm64"

ImageBuild

The state of a custom image build.

Extends

  • Omit<native.ImageBuild, "status">

Properties


ImageBuildOptions

Options for Image.build.

Properties


ImageBuildStatus

ImageBuildStatus = "unknown" | "queued" | "building" | "ready" | "failed"
The status of a custom image build.

ImageBuildStep

ImageBuildStep = { addLocalDir?: never; addLocalFile?: never; aptInstall: PackageInstall; pipInstall?: never; runCommand?: never; } | { addLocalDir?: never; addLocalFile?: never; aptInstall?: never; pipInstall: PackageInstall; runCommand?: never; } | { addLocalDir?: never; addLocalFile?: never; aptInstall?: never; pipInstall?: never; runCommand: RunCommand; } | { addLocalDir?: never; addLocalFile: AddLocalFile; aptInstall?: never; pipInstall?: never; runCommand?: never; } | { addLocalDir: AddLocalDir; addLocalFile?: never; aptInstall?: never; pipInstall?: never; runCommand?: never; }
One build step: exactly one operation. Each union member never-types the other operations, so a step that sets two of them is a compile error (a bare union of the operations would accept it).

ImageDefinition

A custom image definition: a base image plus ordered build steps, where local-file steps still reference paths on this machine.

Properties


ImageDefinitionStep

One image-definition step. Exactly one of the fields must be set.

Properties


ImageSpec

A Sailbox image: a base image plus ordered build steps.

Extends

  • Omit<native.ImageSpec, "base" | "buildSteps" | "architecture" | "filesystem">

Properties


IngressPortInput

A guest port to reserve for ingress at create time.

Extends

  • Omit<native.IngressPortInput, "protocol" | "allowlist">

Properties


IngressProtocol

IngressProtocol = "tcp" | "http"
The protocol you request when exposing a port.

IngressScheme

IngressScheme = "path" | "subdomain"
How a listener’s URL is addressed under ingressBase.

ListSailboxesOptions

Options for Sailbox.list: the server-side filters, a total-cap limit, and an optional client.

Extends

Properties


ListSailboxesPageOptions

Options for Sailbox.listPage: the same filters as ListSailboxesOptions, plus limit/offset page selection and an optional client.

Extends

Properties


ListSailboxesQuery

Filters for listing Sailboxes.

Extends

  • Omit<native.ListSailboxesQuery, "status" | "order">

Properties


ListVolumesOptions

Options for Volume.list.

Extends

Properties


Listener

An exposed guest port and how to reach it.

Properties


ListenerEndpoint

ListenerEndpoint = HttpEndpoint | TcpEndpoint
How to reach an exposed listener; discriminate on kind.

ListenerRouteStatus

ListenerRouteStatus = "unknown" | "pending" | "active" | "restoring" | "unavailable" | string & object
Status of a listener’s ingress route (open: tolerates unknown values).

LocalDirInput

A local directory tree to bake into the image (walked, hashed, and uploaded at resolve; symlinks skipped, file modes preserved).

Properties


LocalFileInput

One local file to bake into the image (hashed and uploaded at resolve).

Properties


PackageInstall

A set of packages to install (apt or pip).

Properties


Protocol

Protocol = "tcp" | "http" | string & object
The protocol reported on a listener (open: tolerates unknown values).

ResolvedConfig

The config resolved from the environment and ~/.sail.

Extends

  • Omit<native.ResolvedConfig, "ingressScheme" | "mode">

Properties


RunCommand

A shell command to run during the build.

Properties


RunOptions

Options for Sailbox.run: the subset of ExecOptions that fits a buffered, run-to-completion command.

Extends

  • Pick<ExecOptions, "timeoutSeconds" | "cwd" | "env" | "idempotencyKey">

Properties


SailboxCheckpoint

A durable checkpoint handle.

Extends

  • Omit<native.SailboxCheckpoint, "status" | "expiresAt">

Properties


SailboxDeprecation

SailboxDeprecation = native.SailboxDeprecation
Actionable notice that a Sailbox’s runtime should be upgraded: a deadline date and a message with upgrade instructions.

SailboxHandle

Returned by create / resume / fromCheckpoint: the Sailbox’s identity and lifecycle status.

Properties


SailboxInfo

A read snapshot of a Sailbox (get / list). Timestamps are RFC 3339 strings.

Extends

  • Omit<native.SailboxInfo, "status">

Properties


SailboxInfoPage

One page of list results plus the pagination envelope.

Extends

  • Omit<native.SailboxInfoPage, "items">

Properties


SailboxListOrder

SailboxListOrder = "newest_active" | "newest_created"
Result ordering for a Sailbox list: most recently active first, or newest created first.

SailboxPage

One page of Sailbox instances plus the pagination envelope.

Extends

Properties


SailboxSize

SailboxSize = "s" | "m" | "l"
Named resource size; each sets the vCPU count plus default memory/disk.

SailboxStatus

SailboxStatus = "running" | "paused" | "sleeping" | "failed" | "terminated" | string & object
Lifecycle status of a Sailbox. Open: tolerates values added server-side.

SailboxStatusFilter

SailboxStatusFilter = "running" | "paused" | "sleeping" | "failed" | "terminated"
The closed set of statuses accepted as a list filter.

ShellOptions

Options for Sailbox.shell.

Properties


SshEndpoint

The public TCP endpoint a Sailbox’s SSH listener is reachable at.

Properties


TcpEndpoint

The address to dial for a tcp listener.

Properties


UpgradeResult

The outcome of a Sailbox runtime upgrade.

Extends

  • Omit<native.UpgradeResult, "status">

Properties


VolumeInfo

A managed NFS volume. Timestamps are RFC 3339 strings.

Properties


VolumeMountInput

An NFS volume to mount at create time.

Properties


WaitForListenerOptions

Options for Sailbox.waitForListener.

Properties


WriteOptions

Options for uploading a file.

Properties

Errors

Errors thrown by this SDK surface. All of them extend SailError, so an instanceof SailError check matches everything below.

SailError

Base class for every error surfaced by the SDK.

Extends

  • Error

Extended by

Constructors

Constructor
new SailError(message, code?, details?): SailError
Parameters
Returns
SailError
Overrides
Error.constructor

Properties


ApiError

A non-2xx API response.

Extends

Constructors

Constructor
new ApiError(message, details?): ApiError
Parameters
Returns
ApiError
Overrides
SailError.constructor

Properties


BrokenPipeError

A stream (e.g. exec stdin) was closed and can no longer be written.

Extends

Constructors

Constructor
new BrokenPipeError(message, details?): BrokenPipeError
Parameters
Returns
BrokenPipeError
Overrides
SailError.constructor

Properties


CommandFailedError

Thrown by Sailbox.run with check when the command exits nonzero or times out. Carries the completed result as result.

Extends

Constructors

Constructor
new CommandFailedError(message, result): CommandFailedError
Parameters
Returns
CommandFailedError
Overrides
SailboxExecutionError.constructor

Properties


FileNotFoundError

A remote file path does not exist.

Extends

Constructors

Constructor
new FileNotFoundError(message, details?): FileNotFoundError
Parameters
Returns
FileNotFoundError
Overrides
SailError.constructor

Properties


ImageBuildError

A custom image could not be built or its local content could not be uploaded.

Extends

Constructors

Constructor
new ImageBuildError(message, details?): ImageBuildError
Parameters
Returns
ImageBuildError
Overrides
SailError.constructor

Properties


InternalError

An unexpected internal SDK/core failure.

Extends

Constructors

Constructor
new InternalError(message, details?): InternalError
Parameters
Returns
InternalError
Overrides
SailError.constructor

Properties


InvalidArgumentError

Invalid arguments or configuration (bad request, missing/invalid API key).

Extends

Constructors

Constructor
new InvalidArgumentError(message, details?): InvalidArgumentError
Parameters
Returns
InvalidArgumentError
Overrides
SailError.constructor

Properties


NotFoundError

The Sailbox, volume, or other resource does not exist (or is another org’s).

Extends

Constructors

Constructor
new NotFoundError(message, details?): NotFoundError
Parameters
Returns
NotFoundError
Overrides
SailError.constructor

Properties


PermissionDeniedError

The credential is not permitted to perform the operation.

Extends

Constructors

Constructor
new PermissionDeniedError(message, details?): PermissionDeniedError
Parameters
Returns
PermissionDeniedError
Overrides
SailError.constructor

Properties


SailboxCreationError

A Sailbox could not be created (provisioning failed).

Extends

Constructors

Constructor
new SailboxCreationError(message, details?): SailboxCreationError
Parameters
Returns
SailboxCreationError
Overrides
SailError.constructor

Properties


SailboxExecRequestNotFoundError

The exec request could not be found (for example after the Sailbox moved machines).

Extends

Constructors

Constructor
new SailboxExecRequestNotFoundError(message, details?): SailboxExecRequestNotFoundError
Parameters
Returns
SailboxExecRequestNotFoundError
Overrides
SailboxExecutionError.constructor

Properties


SailboxExecutionError

Base class for failures during an exec.

Extends

Extended by

Constructors

Constructor
new SailboxExecutionError(message, code?, details?): SailboxExecutionError
Parameters
Returns
SailboxExecutionError
Overrides
SailError.constructor

Properties


SailboxHostLostError

The machine hosting the Sailbox was lost while an exec was in flight.

Extends

Constructors

Constructor
new SailboxHostLostError(message, details?): SailboxHostLostError
Parameters
Returns
SailboxHostLostError
Overrides
SailboxExecutionError.constructor

Properties


SailboxTerminatedError

The Sailbox was terminated while an exec was in flight.

Extends

Constructors

Constructor
new SailboxTerminatedError(message, details?): SailboxTerminatedError
Parameters
Returns
SailboxTerminatedError
Overrides
SailboxExecutionError.constructor

Properties


TimeoutError

A request exceeded its timeout.

Extends

Constructors

Constructor
new TimeoutError(message, details?): TimeoutError
Parameters
Returns
TimeoutError
Overrides
SailError.constructor

Properties


TransportError

A network/connection transport failure.

Extends

Constructors

Constructor
new TransportError(message, details?): TransportError
Parameters
Returns
TransportError
Overrides
SailError.constructor

Properties