@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
npm install @sailresearch/sdk@latest.
Configure
SetSAIL_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 extendsSailError, 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():Identifier of the owning app.string|undefined
Returns
string | undefinedappName
Get Signature
get appName():Name of the owning app.string|undefined
Returns
string | undefinedarchitecture
Get Signature
get architecture():CPU architecture (for examplestring|undefined
arm64).Returns
string | undefinedcheckpointGeneration
Get Signature
get checkpointGeneration():Checkpoint generation counter as of the snapshot.number|undefined
Returns
number | undefinedclient
Get Signature
get client(): Client
The underlying Client.Returns
ClientcpuRequestedVcpu
Get Signature
get cpuRequestedVcpu():Requested CPU, in vCPUs.number|undefined
Returns
number | undefinedcpuUsedVcpu
Get Signature
get cpuUsedVcpu():Current CPU usage, in vCPUs, as of the snapshot.number|undefined
Returns
number | undefinedcreatedAt
Get Signature
get createdAt():When the Sailbox was created.Date|undefined
Returns
Date | undefinedcreatedByUserId
Get Signature
get createdByUserId():The user whose credential created this Sailbox (for a fork or restore, the user who ran it).string|undefined
undefined for service-key creates.Returns
string | undefineddeprecation
Get Signature
get deprecation():Actionable runtime deprecation notice, when an upgrade is needed.SailboxDeprecation|undefined
Returns
SailboxDeprecation | undefineddiskRequestedBytes
Get Signature
get diskRequestedBytes():Requested disk, in bytes.number|undefined
Returns
number | undefineddiskUsedBytes
Get Signature
get diskUsedBytes():Current disk usage, in bytes, as of the snapshot.number|undefined
Returns
number | undefinederrorMessage
Get Signature
get errorMessage():Failure detail when the status isstring|undefined
failed.Returns
string | undefinedfs
Get Signature
get fs(): SailboxFs
Filesystem operations on this Sailbox’s guest: read and write files
(buffered or streaming), and directory helpers.Returns
SailboxFsguestSchemaVersion
Get Signature
get guestSchemaVersion():The Sailbox runtime schema version the Sailbox last booted with.number|undefined
Returns
number | undefinedimageId
Get Signature
get imageId():Identifier of the image the Sailbox was created from.string|undefined
Returns
string | undefinedlastCheckpointedAt
Get Signature
get lastCheckpointedAt():When the most recent checkpoint was taken.Date|undefined
Returns
Date | undefinedmemoryMib
Get Signature
get memoryMib():Configured memory, in MiB.number|undefined
Returns
number | undefinedmemoryRequestedBytes
Get Signature
get memoryRequestedBytes():Requested memory, in bytes.number|undefined
Returns
number | undefinedmemoryUsedBytes
Get Signature
get memoryUsedBytes():Current memory usage, in bytes, as of the snapshot.number|undefined
Returns
number | undefinedname
Get Signature
get name(): string
The Sailbox name.Returns
stringsailboxId
Get Signature
get sailboxId(): string
The Sailbox’s stable identifier.Returns
stringstartedAt
Get Signature
get startedAt():When the Sailbox first started running. A resume does not rewrite it.Date|undefined
Returns
Date | undefinedstateDiskSizeGib
Get Signature
get stateDiskSizeGib():Configured state-disk size, in GiB.number|undefined
Returns
number | undefinedstatus
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
SailboxStatusupdatedAt
Get Signature
get updatedAt():When the Sailbox last changed.Date|undefined
Returns
Date | undefinedvcpuCount
Get Signature
get vcpuCount():Configured number of vCPUs.number|undefined
Returns
number | undefinedvisibility
Get Signature
get visibility():string|undefined
"private" when access is restricted to the creator; undefined/"org"
is the default org-wide access.Returns
string | undefinedMethods
checkpoint()
checkpoint(Take a checkpoint of this Sailbox. The returned handle carriesoptions?):Promise<SailboxCheckpoint>
expiresAt, after which starting a Sailbox from it fails.Parameters
Returns
Promise<SailboxCheckpoint>enableSsh()
enableSsh(Enable SSH on this Sailbox: trust the org SSH CA, startoptions?):Promise<SshEndpoint|null>
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(Run a command and return a handle to the live process. Acommand,options?):Promise<ExecProcess>
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(Expose a guest port at runtime. Re-exposing a port under the same protocol sets itsguestPort,options?):Promise<Listener>
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(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 withoptions?):Promise<Sailbox>
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():Ingress-identity headers for this Sailbox, as a name→value map.Promise<Record<string,string>>
Returns
Promise<Record<string, string>>listener()
listener(Fetch one listener by guest port without waking the Sailbox.guestPort):Promise<Listener>
Parameters
Returns
Promise<Listener>listeners()
listeners():List this Sailbox’s listeners without waking it.Promise<Listener[]>
Returns
Promise<Listener[]>pause()
pause():Pause this Sailbox in memory.Promise<void>
Returns
Promise<void>resume()
resume():Resume this Sailbox (updates status).Promise<void>
Returns
Promise<void>run()
run(Run a command to completion and return its buffered result: a one-shot convenience over exec followed by ExecProcess.wait. Acommand,options?):Promise<ExecResult>
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(Open an interactive pty session on this Sailbox, bridged to the local terminal. With nocommand?,options?):Promise<number>
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(Sleep this Sailbox to disk (wakes on traffic), optionally scheduling a wall-clock wake first.wakeAt?):Promise<Date|undefined>
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():Terminate (delete) this Sailbox (updates status).Promise<void>
Returns
Promise<void>unexpose()
unexpose(Remove a runtime ingress port.guestPort):Promise<void>
Parameters
Returns
Promise<void>upgrade()
upgrade():Upgrade this Sailbox’s runtime.Promise<UpgradeResult>
Returns
Promise<UpgradeResult>waitForListener()
waitForListener(Block until the listener onguestPort,options?):Promise<Listener>
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()
Create a new Sailbox.A custom image definition passed asstaticcreate(options):Promise<Sailbox>
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()
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 withstaticfromCheckpoint(options):Promise<Sailbox>
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()
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.staticfromId(sailboxId,options?):Sailbox
Parameters
Returns
Sailboxget()
Fetch an existing Sailbox by id.staticget(sailboxId,options?):Promise<Sailbox>
Parameters
Returns
Promise<Sailbox>list()
List the Sailboxes that match the filters, fetching pages internally until every match (orstaticlist(params?):Promise<Sailbox[]>
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()
List one page of Sailboxes alongside the pagination envelope (staticlistPage(params?):Promise<SailboxPage>
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()
Find an app by name, optionally minting it if missing.staticfind(name,options?):Promise<App>
Parameters
Returns
Promise<App>list()
Every app the current org owns, newest first.staticlist(options?):Promise<App[]>
Parameters
Returns
Promise<App[]>Image
A custom image definition. Immutable and fluent: each method returns a newImage. 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(Bake a local directory tree into the image atlocalPath,remotePath,options?):Image
path. Each regular
file is hashed + uploaded at resolve; symlinks are skipped and file modes
preserved. ignore takes gitignore-style patterns.Parameters
Returns
ImageaddLocalFile()
addLocalFile(Bake one local file into the image atlocalPath,remotePath,options?):Image
path (absolute POSIX path;
a trailing / appends the source basename). Hashed + uploaded at resolve.Parameters
Returns
ImageaptInstall()
aptInstall(…Install system packages with apt.packages):Image
Parameters
Returns
Imagebuild()
build(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.options?):Promise<ImageSpec>
Parameters
Returns
Promise<ImageSpec>env()
env(Bake environment variables into the image (keys are trimmed).env):Image
Parameters
Returns
ImagepipInstall()
pipInstall(…Install Python packages with pip.packages):Image
Parameters
Returns
ImagerunCommand()
runCommand(Run a shell command during the build.command):Image
Parameters
Returns
ImagetoSpec()
toSpec(Resolve to an ImageSpec: walks local files/dirs (honoring gitignore), hashes them, and uploads their content viaclient?):Promise<ImageSpec>
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()
A Debian base image (defaults to arm64).staticdebian(architecture?):Image
Parameters
Returns
Imagedevbox()
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.staticdevbox(architecture?):Image
Parameters
Returns
ImageExecProcess
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
stringidempotencyKey
Get Signature
get idempotencyKey(): string
The idempotency key used to launch the command.Returns
stringoutput
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
ExecStreamMethods
[asyncDispose]()
[asyncDispose]():Promise<void>
await using support: detaches on scope exit.Returns
Promise<void>[dispose]()
[dispose](): void
using support: detaches on scope exit.Returns
voidcancel()
cancel(Cancel the command (SIGINT by default, SIGKILL withoptions?):Promise<void>
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
voidcloseStdin()
closeStdin():Close the command’s stdin (send EOF).Promise<void>
Returns
Promise<void>poll()
poll():The exit code if the exit frame has arrived on the stream, elsenumber|null
null.
Throws for a host-lost exec (no real exit code), as wait does.Returns
number | nullresize()
resize(Resize the pty (no-op without one).cols,rows):Promise<void>
Parameters
Returns
Promise<void>resync()
resync():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.Promise<void>
Returns
Promise<void>wait()
wait():Await the authoritative result (exit code, buffered output, flags).Promise<ExecResult>
Returns
Promise<ExecResult>waitStreamEnded()
waitStreamEnded(Wait up totimeoutSeconds):Promise<boolean>
timeoutSeconds for the streams to end; returns whether they
did. Infinity waits indefinitely.Parameters
Returns
Promise<boolean>writeStdin()
writeStdin(Write to the command’s stdin (requiresdata):Promise<void>
openStdin).Parameters
Returns
Promise<void>ExecStream
An async-iterable view of one exec stream (stdout or stderr). Default iteration yieldsstring 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():Collect the whole raw byte stream into a singlePromise<Buffer<ArrayBufferLike>>
Buffer.Returns
Promise<Buffer<ArrayBufferLike>>raw()
raw():Iterate the raw byte stream, exactly as the command wrote it (escape sequences and binary payloads included).AsyncIterableIterator<Buffer<ArrayBufferLike>>
Returns
AsyncIterableIterator<Buffer<ArrayBufferLike>>text()
text():Collect the whole stream into a single string.Promise<string>
Returns
Promise<string>toReadable()
toReadable(): Readable
Adapt to a Node Readable of string chunks (e.g. to .pipe() it).Returns
ReadableSailboxFs
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(Whetherpath):Promise<boolean>
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(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.path):Promise<DirEntry[]>
Parameters
Returns
Promise<DirEntry[]>mkdir()
mkdir(Create a directory and any missing parents (likepath):Promise<void>
mkdir -p); a no-op if
it already exists.Parameters
Returns
Promise<void>read()
read(Read a guest file fully into memory (convenience over readStream).path):Promise<Buffer<ArrayBufferLike>>
Parameters
Returns
Promise<Buffer<ArrayBufferLike>>readStream()
readStream(Open a streaming read of a guest file.path):Promise<FileStream>
Parameters
Returns
Promise<FileStream>remove()
remove(Remove a file or directory tree (likepath):Promise<void>
rm -rf); a no-op if it is already
absent.Parameters
Returns
Promise<void>write()
write(Write bytes (apath,data,options?):Promise<void>
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(Open a streaming upload to a guest file.path,options?):Promise<FileWriter>
Parameters
Returns
Promise<FileWriter>FileWriter
A streaming write to a guest file. Push chunks with write, then confirm with finish; onlyfinish 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
voidabort()
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
voidfinish()
finish():Confirm the write, creating an empty file if nothing was written.Promise<void>
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
Writablewrite()
write(Write bytes (adata):Promise<void>
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 areBuffers; 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():Collect the whole file into a singlePromise<Buffer<ArrayBufferLike>>
Buffer.Returns
Promise<Buffer<ArrayBufferLike>>close()
close():Release the underlying download stream (idempotent).Promise<void>
Returns
Promise<void>toReadable()
toReadable(): Readable
Adapt to a Node Readable.Returns
ReadableVolume
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’svolumes 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(Delete this volume. Resolvesoptions?):Promise<boolean>
true if it was deleted, false if it was
already gone (only possible with allowMissing).Parameters
Returns
Promise<boolean>find()
Look up an NFS volume by name, optionally minting it if missing.staticfind(name,options?):Promise<Volume>
Parameters
Returns
Promise<Volume>fromMount()
Guest-side: load the volume handle for a path mounted into this Sailbox (reads the mount’s metadata; only available inside a guest).staticfromMount(path):Volume
Parameters
Returns
Volumelist()
List NFS volumes in the current org.staticlist(options?):Promise<Volume[]>
Parameters
Returns
Promise<Volume[]>ingressAuthHeaders()
ingressAuthHeaders():Guest-side: headers that authenticate this Sailbox as an ingress allowlist source (only available inside a Sailbox guest).Record<string,string>
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(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;def,timeoutSeconds):Promise<ImageSpec>
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(Build an already-resolved spec to ready (submit + poll), bounded byspec,timeoutSeconds):Promise<ImageBuild>
timeoutSeconds.Parameters
Returns
Promise<ImageBuild>checkpointSailbox()
checkpointSailbox(Take a checkpoint of a Sailbox.sailboxId,options?):Promise<SailboxCheckpoint>
name sets the handle’s display name;
ttlSeconds, when given, overrides the server’s default retention
window.Parameters
Returns
Promise<SailboxCheckpoint>createFromCheckpoint()
createFromCheckpoint(Create a new Sailbox from a checkpoint.params):Promise<SailboxHandle>
Parameters
Returns
Promise<SailboxHandle>createSailbox()
createSailbox(Create a Sailbox.req,timeoutSeconds?):Promise<SailboxHandle>
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(Delete a volume by id.volumeId,allowMissing?):Promise<VolumeInfo|null>
allowMissing tolerates an already-deleted
volume, resolving null instead of throwing.Parameters
Returns
Promise<VolumeInfo | null>enableSsh()
enableSsh(Enable SSH on a Sailbox: trust the org SSH CA, startsailboxId,options?):Promise<SshEndpoint|null>
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(Run a command in a Sailbox and return a handle to the live process. AsailboxId,command,options?):Promise<ExecProcess>
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(Expose a guest port at runtime. Re-exposing a port under the same protocol sets itssailboxId,guestPort,protocol?,allowlist?):Promise<Listener>
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(Find an app by name;name,mintIfMissing?):Promise<AppInfo>
mintIfMissing creates it when absent.Parameters
Returns
Promise<AppInfo>forkSailbox()
forkSailbox(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.sailboxId,options?):Promise<SailboxHandle>
Parameters
Returns
Promise<SailboxHandle>getListener()
getListener(Fetch one listener by guest port without waking the Sailbox.sailboxId,guestPort):Promise<Listener>
Parameters
Returns
Promise<Listener>getSailbox()
getSailbox(Fetch one Sailbox by id.sailboxId):Promise<SailboxInfo>
Parameters
Returns
Promise<SailboxInfo>getVolume()
getVolume(Look up an NFS volume by name;name,mintIfMissing?):Promise<VolumeInfo>
mintIfMissing creates it when absent.Parameters
Returns
Promise<VolumeInfo>ingressAuthHeaders()
ingressAuthHeaders(Ingress-identity headers for this Sailbox, as a name→value map.sailboxId):Promise<Record<string,string>>
Parameters
Returns
Promise<Record<string, string>>isBuiltinBaseSpec()
isBuiltinBaseSpec(Whether a spec is a bare builtin base the backend ships prebuilt (no build needed).spec):boolean
Parameters
Returns
booleanlistApps()
listApps():Every app the current org owns, newest first.Promise<AppInfo[]>
Returns
Promise<AppInfo[]>listDir()
listDir(List a directory’s immediate entries as structured records.sailboxId,path):Promise<DirEntry[]>
Parameters
Returns
Promise<DirEntry[]>listListeners()
listListeners(List a Sailbox’s listeners without waking it.sailboxId):Promise<Listener[]>
Parameters
Returns
Promise<Listener[]>listSailboxes()
listSailboxes(List one page of Sailboxes in the current org.params?):Promise<SailboxInfoPage>
Parameters
Returns
Promise<SailboxInfoPage>listVolumes()
listVolumes(List NFS volumes in the current org.maxObjects?):Promise<VolumeInfo[]>
Parameters
Returns
Promise<VolumeInfo[]>makeDir()
makeDir(Create a directory and any missing parents (likesailboxId,path):Promise<void>
mkdir -p); a no-op if
it already exists.Parameters
Returns
Promise<void>orgSshCaPublicKey()
orgSshCaPublicKey():Fetch (creating on first use) the org SSH certificate authority public key. Used to preflight SSH before a Sailbox is provisioned.Promise<string>
Returns
Promise<string>pathExists()
pathExists(WhethersailboxId,path):Promise<boolean>
path exists in the guest.Parameters
Returns
Promise<boolean>pauseSailbox()
pauseSailbox(Pause a Sailbox in memory.sailboxId):Promise<void>
Parameters
Returns
Promise<void>readStream()
readStream(Open a streaming read of a guest file.sailboxId,path):Promise<FileStream>
Parameters
Returns
Promise<FileStream>removePath()
removePath(Remove a file or directory tree (likesailboxId,path):Promise<void>
rm -rf); a no-op if it is already
absent.Parameters
Returns
Promise<void>resolveImage()
resolveImage(Resolve an image definition into a content-addressed ImageSpec: the core walks local directories (gitignore-styledef):Promise<ImageSpec>
ignore), hashes every
file, and uploads content the server does not already have.Parameters
Returns
Promise<ImageSpec>resumeSailbox()
resumeSailbox(Resume a paused or sleeping Sailbox.sailboxId):Promise<SailboxHandle>
Parameters
Returns
Promise<SailboxHandle>shell()
shell(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).sailboxId,command?,options?):Promise<number>
Parameters
Returns
Promise<number>sleepSailbox()
sleepSailbox(Sleep a Sailbox to disk (wakes on traffic), optionally scheduling a wall-clock wake first.sailboxId,wakeAt?):Promise<string|null>
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(Terminate a Sailbox (idempotent).sailboxId):Promise<void>
Parameters
Returns
Promise<void>unexposeListener()
unexposeListener(Remove a runtime ingress port.sailboxId,guestPort):Promise<void>
Parameters
Returns
Promise<void>upgradeSailbox()
upgradeSailbox(Upgrade a Sailbox’s runtime (now if running, else at next wake).sailboxId):Promise<UpgradeResult>
Parameters
Returns
Promise<UpgradeResult>waitForListener()
waitForListener(Block until the listener onsailboxId,guestPort,timeoutSeconds):Promise<Listener>
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(Open a streaming upload to a guest file.sailboxId,path,options?):Promise<FileWriter>
Parameters
Returns
Promise<FileWriter>fromConfig()
Build a client from an explicit ClientConfig.staticfromConfig(config):Client
Parameters
Returns
ClientfromEnv()
Build a client from the environment (staticfromEnv():Client
SAIL_API_KEY, …).Returns
ClientdefaultClient()
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
ClientsetDefaultClient()
setDefaultClient(Override (or clear, withclient):void
undefined) the process-wide default client. Useful
for tests or to point the object-model API at an explicitly configured client.Parameters
Returns
voidresolveConfig()
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
ResolvedConfigisSailError()
isSailError(Whethererr):err is SailError
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 SailErrorTypes
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 anaddLocalDir 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
FindAppOptionsFindVolumeOptionsListVolumesOptionsCreateSailboxOptionsFromCheckpointOptionsListSailboxesOptionsListSailboxesPageOptions
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
Omit<CreateSailboxRequest,"image"|"appId"|"volumeMounts"|"ingressPorts">.ClientOptions
Properties
CreateSailboxRequest
Extends
Omit<native.CreateSailboxRequest,"image"|"ingressPorts"|"size"|"volumeMounts">
Properties
DeleteVolumeOptions
Options for Volume.delete.Properties
DirEntry
One entry in a directory listing fromSailbox.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 =The kind of a directory entry, reported for the entry itself: a symlink is"file"|"directory"|"symlink"|"other"
"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 generatedExecStartOptions).Extends
Omit<native.ExecStartOptions,"env">
Properties
ExecResult
The authoritative result of a finished exec.The bufferedstdout/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 anhttp 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 =The status of a custom image build."unknown"|"queued"|"building"|"ready"|"failed"
ImageBuildStep
ImageBuildStep = {One build step: exactly one operation. Each union memberaddLocalDir?: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; }
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 =The protocol you request when exposing a port."tcp"|"http"
IngressScheme
IngressScheme =How a listener’s URL is addressed under"path"|"subdomain"
ingressBase.ListSailboxesOptions
Options for Sailbox.list: the server-side filters, a total-caplimit, and an optional client.Extends
Omit<ListSailboxesQuery,"limit"|"offset">.ClientOptions
Properties
ListSailboxesPageOptions
Options for Sailbox.listPage: the same filters as ListSailboxesOptions, pluslimit/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 =How to reach an exposed listener; discriminate onHttpEndpoint|TcpEndpoint
kind.ListenerRouteStatus
ListenerRouteStatus =Status of a listener’s ingress route (open: tolerates unknown values)."unknown"|"pending"|"active"|"restoring"|"unavailable"|string&object
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 =The protocol reported on a listener (open: tolerates unknown values)."tcp"|"http"|string&object
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 =Result ordering for a Sailbox list: most recently active first, or newest created first."newest_active"|"newest_created"
SailboxPage
One page of Sailbox instances plus the pagination envelope.Extends
Omit<SailboxInfoPage,"items">
Properties
SailboxSize
SailboxSize =Named resource size; each sets the vCPU count plus default memory/disk."s"|"m"|"l"
SailboxStatus
SailboxStatus =Lifecycle status of a Sailbox. Open: tolerates values added server-side."running"|"paused"|"sleeping"|"failed"|"terminated"|string&object
SailboxStatusFilter
SailboxStatusFilter =The closed set of statuses accepted as a list filter."running"|"paused"|"sleeping"|"failed"|"terminated"
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 atcp 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 aninstanceof SailError check matches everything below.SailError
Base class for every error surfaced by the SDK.Extends
Error
Extended by
InvalidArgumentErrorInternalErrorNotFoundErrorPermissionDeniedErrorFileNotFoundErrorBrokenPipeErrorTimeoutErrorTransportErrorApiErrorSailboxCreationErrorImageBuildErrorSailboxExecutionError
Constructors
Constructor
new SailError(message,code?,details?):SailError
Parameters
Returns
SailErrorOverrides
Error.constructorProperties
ApiError
A non-2xx API response.Extends
Constructors
Constructor
new ApiError(message,details?):ApiError
Parameters
Returns
ApiErrorOverrides
SailError.constructorProperties
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
BrokenPipeErrorOverrides
SailError.constructorProperties
CommandFailedError
Thrown by Sailbox.run withcheck when the command exits nonzero
or times out. Carries the completed result as result.Extends
Constructors
Constructor
new CommandFailedError(message,result):CommandFailedError
Parameters
Returns
CommandFailedErrorOverrides
SailboxExecutionError.constructorProperties
FileNotFoundError
A remote file path does not exist.Extends
Constructors
Constructor
new FileNotFoundError(message,details?):FileNotFoundError
Parameters
Returns
FileNotFoundErrorOverrides
SailError.constructorProperties
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
ImageBuildErrorOverrides
SailError.constructorProperties
InternalError
An unexpected internal SDK/core failure.Extends
Constructors
Constructor
new InternalError(message,details?):InternalError
Parameters
Returns
InternalErrorOverrides
SailError.constructorProperties
InvalidArgumentError
Invalid arguments or configuration (bad request, missing/invalid API key).Extends
Constructors
Constructor
new InvalidArgumentError(message,details?):InvalidArgumentError
Parameters
Returns
InvalidArgumentErrorOverrides
SailError.constructorProperties
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
NotFoundErrorOverrides
SailError.constructorProperties
PermissionDeniedError
The credential is not permitted to perform the operation.Extends
Constructors
Constructor
new PermissionDeniedError(message,details?):PermissionDeniedError
Parameters
Returns
PermissionDeniedErrorOverrides
SailError.constructorProperties
SailboxCreationError
A Sailbox could not be created (provisioning failed).Extends
Constructors
Constructor
new SailboxCreationError(message,details?):SailboxCreationError
Parameters
Returns
SailboxCreationErrorOverrides
SailError.constructorProperties
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
SailboxExecRequestNotFoundErrorOverrides
SailboxExecutionError.constructorProperties
SailboxExecutionError
Base class for failures during an exec.Extends
Extended by
Constructors
Constructor
new SailboxExecutionError(message,code?,details?):SailboxExecutionError
Parameters
Returns
SailboxExecutionErrorOverrides
SailError.constructorProperties
SailboxHostLostError
The machine hosting the Sailbox was lost while an exec was in flight.Extends
Constructors
Constructor
new SailboxHostLostError(message,details?):SailboxHostLostError
Parameters
Returns
SailboxHostLostErrorOverrides
SailboxExecutionError.constructorProperties
SailboxTerminatedError
The Sailbox was terminated while an exec was in flight.Extends
Constructors
Constructor
new SailboxTerminatedError(message,details?):SailboxTerminatedError
Parameters
Returns
SailboxTerminatedErrorOverrides
SailboxExecutionError.constructorProperties
TimeoutError
A request exceeded its timeout.Extends
Constructors
Constructor
new TimeoutError(message,details?):TimeoutError
Parameters
Returns
TimeoutErrorOverrides
SailError.constructorProperties
TransportError
A network/connection transport failure.Extends
Constructors
Constructor
new TransportError(message,details?):TransportError
Parameters
Returns
TransportErrorOverrides
SailError.constructor