REFERENCE

Node API

The devsandboxes npm package: the native devsandbox binary plus a typed, promise-based API over its JSON output. Generated from the package's index.d.ts.


Install

The package ships the devsandbox binary for your platform next to the typed API, so one dependency covers both.

TERMINAL
npm i devsandboxes

Usage

example.ts
import { spawn } from 'node:child_process';
import * as devsandbox from 'devsandboxes';

const { name, worktree } = await devsandbox.run('web', { dir: './sandboxes', stderr: 'inherit' });
const { instances } = await devsandbox.status({ dir: './sandboxes' });
for (const i of instances) console.log(i.name, i.status.state, i.drift);

const { exitCode, stdout } = await devsandbox.exec(name, ['git', 'status']);

// Your own process or pty (node-pty takes the same file/args): a login shell.
const { file, args } = devsandbox.execArgv(name, [], { interactive: true, tty: true });
spawn(file, args, { stdio: 'inherit' });

await devsandbox.rm(name, { deleteBranch: true });

Every function takes { dir, cwd, env, signal, stderr }, except the synchronous binaryPath() and execArgv(), and connect() (below). dir is the config root (-C). A failed command rejects with DevsandboxError (exitCode, stdout, stderr).

At a glance

FunctionResolves toDescription
binaryPath()stringsyncAbsolute path of the native binary for this platform (DEVSANDBOX_BINARY overrides)
cli()CliResultRun the CLI with raw arguments
ls()SandboxRow[]Sandbox configs in devsandboxes.toml
ps()ContainerRow[]Running devsandbox containers (all includes stopped ones)
stats()StatsRow[]CPU/memory of running devsandbox containers
status()SnapshotSandboxes, instances, and services in one snapshot
inspect()TThe runtime's own inspect document (docker/podman: an array of containers)
run()RunRecordCreate and start an instance of sandbox
start()void—
stop()void—
rebuild()voidRecreate from current config when drifted (force: even without drift)
rename()void—
done()voidMark an instance done: kept as is (container, worktree), shown dimmed until removed
undone()voidClear an instance's done mark
rm()voidRemove container, worktree, and state entry
gc()voidRemove unreferenced services (force: also orphaned shell-history files)
logs()stringLast lines (default 50) lines of a container's merged stdout/stderr
exec()CliResultRun command in an instance
execArgv()ExecInvocationsyncArgv for running cmd in an instance under your own process or pty (node-pty, child_process.spawn)
service.ls()ServiceRow[]—
service.rebuild()voidRecreate a service's containers and rewire running sandboxes in place
connect()ApiConnect to the host daemon through devsandbox api --stdio, starting the daemon if needed, and say hello

Functions

Named exports of devsandboxes. Everything but binaryPath() and execArgv() runs the CLI and returns a promise.

binaryPath()function

Absolute path of the native binary for this platform (DEVSANDBOX_BINARY overrides).

function binaryPath(): string

Returnsstring

cli()function

Run the CLI with raw arguments.

function cli(args: readonly string[], opts?: CliOptions): Promise<CliResult>
function cli(
  args: readonly string[],
  opts?: CliOptions,
): Promise<CliResult>
ParameterType
argsreadonly string[]
optsoptionalCliOptions

ReturnsPromise<CliResult>

ls()function

Sandbox configs in devsandboxes.toml.

function ls(opts?: CommonOptions): Promise<SandboxRow[]>
function ls(
  opts?: CommonOptions,
): Promise<SandboxRow[]>
ParameterType
optsoptionalCommonOptions

ReturnsPromise<SandboxRow[]>

ps()function

Running devsandbox containers (all includes stopped ones).

function ps(opts?: CommonOptions & { all?: boolean }): Promise<ContainerRow[]>
function ps(
  opts?: CommonOptions & { all?: boolean },
): Promise<ContainerRow[]>
ParameterTypeDescription
optsoptionalCommonOptions & { all?: boolean }

Every option of CommonOptions, plus:

opts.alloptionalboolean—

ReturnsPromise<ContainerRow[]>

stats()function

CPU/memory of running devsandbox containers.

function stats(opts?: CommonOptions): Promise<StatsRow[]>
function stats(
  opts?: CommonOptions,
): Promise<StatsRow[]>
ParameterType
optsoptionalCommonOptions

ReturnsPromise<StatsRow[]>

status()function

Sandboxes, instances, and services in one snapshot.

function status(opts?: CommonOptions): Promise<Snapshot>
function status(
  opts?: CommonOptions,
): Promise<Snapshot>
ParameterType
optsoptionalCommonOptions

ReturnsPromise<Snapshot>

inspect()function

The runtime's own inspect document (docker/podman: an array of containers).

function inspect<T = unknown>(name: string, opts?: CommonOptions): Promise<T>
function inspect<T = unknown>(
  name: string,
  opts?: CommonOptions,
): Promise<T>
ParameterType
namestring
optsoptionalCommonOptions

ReturnsPromise<T>

run()function

Create and start an instance of sandbox; resolves with where it lives.

function run(sandbox: string, opts?: RunOptions): Promise<RunRecord>
function run(
  sandbox: string,
  opts?: RunOptions,
): Promise<RunRecord>
ParameterType
sandboxstring
optsoptionalRunOptions

ReturnsPromise<RunRecord>

start()function

function start(target: Target, opts?: CommonOptions): Promise<void>
function start(
  target: Target,
  opts?: CommonOptions,
): Promise<void>
ParameterType
targetTarget
optsoptionalCommonOptions

ReturnsPromise<void>

stop()function

function stop(target: Target, opts?: CommonOptions): Promise<void>
function stop(
  target: Target,
  opts?: CommonOptions,
): Promise<void>
ParameterType
targetTarget
optsoptionalCommonOptions

ReturnsPromise<void>

rebuild()function

Recreate from current config when drifted (force: even without drift).

function rebuild(
  target: Target,
  opts?: CommonOptions & { force?: boolean },
): Promise<void>
ParameterTypeDescription
targetTarget—
optsoptionalCommonOptions & { force?: boolean }

Every option of CommonOptions, plus:

opts.forceoptionalboolean—

ReturnsPromise<void>

rename()function

function rename(name: string, newName: string, opts?: CommonOptions): Promise<void>
function rename(
  name: string,
  newName: string,
  opts?: CommonOptions,
): Promise<void>
ParameterType
namestring
newNamestring
optsoptionalCommonOptions

ReturnsPromise<void>

done()function

Mark an instance done: kept as is (container, worktree), shown dimmed until removed.

function done(name: string, opts?: CommonOptions): Promise<void>
function done(
  name: string,
  opts?: CommonOptions,
): Promise<void>
ParameterType
namestring
optsoptionalCommonOptions

ReturnsPromise<void>

undone()function

Clear an instance's done mark.

function undone(name: string, opts?: CommonOptions): Promise<void>
function undone(
  name: string,
  opts?: CommonOptions,
): Promise<void>
ParameterType
namestring
optsoptionalCommonOptions

ReturnsPromise<void>

rm()function

Remove container, worktree, and state entry. Rejects, removing nothing, when the worktree has uncommitted or untracked changes, unless force.

function rm(
  name: string,
  opts?: CommonOptions & { /** * The worktree branch `run` created: `true` deletes it (`git branch -D`, * unmerged commits too), `false` or omitted keeps it. Branches `run` * reused are always kept. */ deleteBranch?: boolean; /** * Remove anyway: uncommitted or untracked worktree changes are * discarded, and a failed step (logged on stderr) is skipped so the * instance still leaves state; what failed stays on disk. */ force?: boolean; },
): Promise<void>
ParameterTypeDescription
namestring—
optsoptionalCommonOptions & { /** * The worktree branch `run` created: `true` deletes it (`git branch -D`, * unmerged commits too), `false` or omitted keeps it. Branches `run` * reused are always kept. */ deleteBranch?: boolean; /** * Remove anyway: uncommitted or untracked worktree changes are * discarded, and a failed step (logged on stderr) is skipped so the * instance still leaves state; what failed stays on disk. */ force?: boolean; }

Every option of CommonOptions, plus:

opts.deleteBranchoptionalboolean

The worktree branch run created: true deletes it (git branch -D, unmerged commits too), false or omitted keeps it. Branches run reused are always kept.

opts.forceoptionalboolean

Remove anyway: uncommitted or untracked worktree changes are discarded, and a failed step (logged on stderr) is skipped so the instance still leaves state; what failed stays on disk.

ReturnsPromise<void>

gc()function

Remove unreferenced services (force: also orphaned shell-history files).

function gc(opts?: CommonOptions & { force?: boolean }): Promise<void>
function gc(
  opts?: CommonOptions & { force?: boolean },
): Promise<void>
ParameterTypeDescription
optsoptionalCommonOptions & { force?: boolean }

Every option of CommonOptions, plus:

opts.forceoptionalboolean—

ReturnsPromise<void>

logs()function

Last lines (default 50) lines of a container's merged stdout/stderr.

function logs(
  name: string,
  opts?: CommonOptions & { lines?: number },
): Promise<string>
ParameterTypeDescription
namestring—
optsoptionalCommonOptions & { lines?: number }

Every option of CommonOptions, plus:

opts.linesoptionalnumber—

ReturnsPromise<string>

exec()function

Run command in an instance. Resolves with its exit code rather than rejecting on non-zero.

function exec(
  name: string,
  command: readonly string[],
  opts?: ExecOptions,
): Promise<CliResult>
ParameterType
namestring
commandreadonly string[]
optsoptionalExecOptions

ReturnsPromise<CliResult>

execArgv()function

Argv for running cmd in an instance under your own process or pty (node-pty, child_process.spawn). Without cmd, a login shell (zsh, bash, or sh). With neither flag set the CLI picks: -i, plus -t when its stdin is a TTY (as under a pty); setting either passes exactly what you set, so set both for an interactive shell.

function execArgv(
  name: string,
  cmd?: readonly string[],
  opts?: ExecArgvOptions,
): ExecInvocation
ParameterType
namestring
cmdoptionalreadonly string[]
optsoptionalExecArgvOptions

ReturnsExecInvocation

connect()function

Connect to the host daemon through devsandbox api --stdio, starting the daemon if needed, and say hello. Rejects with DevsandboxApiError: unsupported on Windows (the daemon is unix only), protocol when the daemon speaks another protocol, closed when the relay exits first.

function connect(opts?: ConnectOptions): Promise<Api>
function connect(
  opts?: ConnectOptions,
): Promise<Api>
ParameterType
optsoptionalConnectOptions

ReturnsPromise<Api>

service

Methods of the exported service object: devsandbox.service.ls().

service.ls()method

ls(opts?: CommonOptions): Promise<ServiceRow[]>
ls(
  opts?: CommonOptions,
): Promise<ServiceRow[]>
ParameterType
optsoptionalCommonOptions

ReturnsPromise<ServiceRow[]>

service.rebuild()method

Recreate a service's containers and rewire running sandboxes in place.

rebuild(name: string, opts?: CommonOptions): Promise<void>
rebuild(
  name: string,
  opts?: CommonOptions,
): Promise<void>
ParameterType
namestring
optsoptionalCommonOptions

ReturnsPromise<void>

Types

Payloads mirror the CLI's --json output field for field: names stay snake_case and a Rust Option<T> arrives asT | null.

Payloads

ContainerStatustype

Container liveness; text is the runtime's raw status (e.g. "Up 3 minutes"). unknown: the runtime wasn't asked (instances.list with depth: 'disk'); never in status().

type ContainerStatus =
  | { state: 'running'; text: string }
  | { state: 'exited'; text: string }
  | { state: 'missing' }
  | { state: 'unknown' };

Used byInstanceRow ServiceRow

PhaseRowtype

Where an instance's creation stands while it isn't ready. step is preparing, building, creating or a lifecycle step's name (postCreateCommand, …); a failed one is kept until rebuild retries it or rm removes it (error is interrupted when its process died).

type PhaseRow =
  | { state: 'in-flight'; step: string }
  | { state: 'failed'; step: string; error: string };

Used byInstanceRow ContainerRow

InstanceRowinterface

One instance (status().instances).

PropertyTypeDescription
namestring—
sandboxstring—
containerstring—
statusContainerStatus—
uptime_secsnumber—
cpustring | null—
memstring | null—
folderstring—
worktreeboolean—
servicesstring[]—
workspacestring—
remote_userstring | null—
remote_env_lennumber—
base_folderstring—
driftboolean

Container no longer matches the current config/dockerfile; rebuild recreates it.

doneboolean

Marked done (done()); kept as is until removed.

phaseoptionalPhaseRow

Still being created, or failed; absent once ready. Shown instead of status while set.

rootstring | null

The config root it was made from; null for instances older than that record.

machineoptionalstring

The machine it's on, in a federated snapshot (instances.watch with machines); absent for this host's.

Used bySnapshot

SandboxRowinterface

One [sandbox.*] from devsandboxes.toml (ls(), status().sandboxes).

PropertyTypeDescription
namestring—
sourcestring

image X, dockerfile Y, or ? when the sandbox failed to resolve.

folderstring | null—
servicesstring[]—
extendsstring[]

extends template chain.

config_hashstring—
build_hashstring—
issuesstring[]

Config-validation problems (folder / mount resolution).

dispatcherboolean

Has a dispatcher table (docs/architecture/automations/dispatchers.md).

worktree_branchstring | null

The resolved worktree-branch; null when unset or unresolved.

rootstring | null

The config root it was read from.

machineoptionalstring

As InstanceRow.machine.

Used bySnapshot ls()

ServiceRowinterface

One [services.*] from devsandboxes.toml (service.ls(), status().services).

PropertyTypeDescription
namestring—
scope'global' | 'isolated'—
sourcestring—
portsstring[]—
containersArray<[string, ContainerStatus]>

Backing containers as [containerName, status] pairs.

used_bystring[]

Instances whose sandbox references this service.

env_lennumber—
commandstring | null—
config_hashstring—
driftboolean—
rootstring | null

The config root it was read from.

machineoptionalstring

As InstanceRow.machine.

Used bySnapshot service.ls()

Snapshotinterface

Full snapshot (status()), the same data the TUI renders.

PropertyTypeDescription
instancesInstanceRow[]—
sandboxesSandboxRow[]—
servicesServiceRow[]—
sandbox_countnumber—
runtime_name'docker' | 'podman' | 'container'—
runtime_versionstring | null—
errorstring | null

Collection problem (e.g. runtime down); rows still come from local state.

Used byInstancesList status()

SnapshotDepthtype

How much of the runtime instances.list asks: full (the default) adds cpu/mem.

type SnapshotDepth = 'disk' | 'listing' | 'full';

Used byApiMethods

InstancesListinterface

instances.list: the Snapshot plus the dispatchers' children.

ExtendsSnapshotinherits instances sandboxes services sandbox_count runtime_name runtime_version error

PropertyTypeDescription
thread_childrenRecord<string, Record<string, string>>

Dispatcher instance_id → thread key → child instance name.

Used byInstancesSnapshot ApiMethods ApiInstances

InstancesSnapshotinterface

instances.snapshot: a watched root's InstancesList, pushed on every poll (about every 2 s; cpu/mem refreshed at most every 7 s and carried over in between), so its arrival says how fresh it is.

ExtendsInstancesListinherits thread_children instances sandboxes services sandbox_count runtime_name runtime_version error

PropertyTypeDescription
dirstring

The config root, as instances.watch named it.

machinesoptionalSnapshotMachine[]

With instances.watch's machines: every registered machine, sorted by name. The rows then include each machine's (tagged machine), last known while it isn't connected.

Used byApiEvents

LinkStatetype

Where a machine's link stands. idle: not wanted, so not connected.

type LinkState = 'idle' | 'connecting' | 'connected' | 'unreachable';

Used bySnapshotMachine MachineRow

SnapshotMachineinterface

One machine of a federated InstancesSnapshot.

PropertyTypeDescription
namestring—
targetstring

What ssh takes, or an ssh:// URL.

stateLinkState—
errorstring | null

Why it's unreachable (or a root it refused).

versionstring | null

Its devsandbox semver, once reached.

runtimestring | null

Its runtime (runtime_name), once a snapshot came.

commandstring | null

The remote devsandbox as shell text; null is devsandbox on its PATH (for an ssh argv).

agentboolean

This host's ssh-agent is relayed to it (machines.set).

Used byInstancesSnapshot

RunRecordinterface

The instance run() just created (run --json). Fields match InstanceRow where they overlap, except worktree, which is the path.

PropertyTypeDescription
namestring

Instance name; what every name argument accepts.

instance_idstring

Persistent id; differs from name after a rename.

sandboxstring—
containerstring—
workspacestring

Workspace folder inside the container.

folderstring

Host folder mounted as the workspace (the worktree for a worktree instance).

base_folderstring

Host base repo folder the instance derives from.

worktreestring | null

Host worktree path; null when the instance runs on base_folder.

branchstring | null

Worktree branch; null without a worktree.

Used byrun() VerbDetached

ContainerRowinterface

One container from the runtime listing (ps()).

PropertyTypeDescription
namestring—
imagestring—
statusstring

Human status (Up 3 minutes, Exited (0) 1 hour ago, …).

statestring

running, or anything else (stopped/exited/created…).

labelsRecord<string, string>—
host_portsstring[]—
doneboolean

The container's instance is marked done (false for service containers).

phaseoptionalPhaseRow

The container's instance is still being created, or failed; absent once ready.

Used byps()

StatsRowinterface

Resource usage of one running container (stats()), pre-rendered.

PropertyType
namestring
cpustring
memstring

Used bystats()

Options & results

CommonOptionsinterface

PropertyTypeDescription
diroptionalstring

Config root containing devsandboxes.toml (the CLI's -C). Defaults to cwd.

cwdoptionalstring—
envoptionalNodeJS.ProcessEnv—
signaloptionalAbortSignal—
stderroptional'pipe' | 'inherit'

inherit streams the CLI's progress output to this process's stderr. Default pipe.

Used byCliOptions ls() ps() stats() status() inspect() RunOptions start() stop() rebuild() rename() done() undone() rm() gc() logs() ExecOptions service.ls() service.rebuild()

CliOptionsinterface

ExtendsCommonOptionsinherits dir cwd env signal stderr

PropertyTypeDescription
inputoptionalstring | Buffer

Written to the process's stdin; stdin is closed otherwise.

rejectoptionalboolean

Reject with DevsandboxError on a non-zero exit. Default true.

Used bycli()

CliResultinterface

PropertyTypeDescription
exitCodenumber | null—
signalNodeJS.Signals | null—
stdoutstring—
stderrstring

Empty when stderr: 'inherit'.

Used bycli() exec()

Targettype

An instance name (or sandbox / folder name), or every instance.

type Target = string | { all: true };

Used bystart() stop() rebuild()

API

RunOptionsinterface

ExtendsCommonOptionsinherits dir cwd env signal stderr

PropertyTypeDescription
nameoptionalstring

Instance name; generated when omitted.

branchoptionalstring

Worktree branch (supports ${instance}).

baseoptionalstring

Start point for the worktree branch, e.g. origin/develop.

Used byrun()

ExecOptionsinterface

ExtendsCommonOptionsinherits dir cwd env signal stderr

PropertyTypeDescription
inputoptionalstring | Buffer

Piped to the command's stdin (passes -i).

Used byexec()

ExecArgvOptionsinterface

PropertyTypeDescription
ttyoptionalboolean

Pass -t (allocate a pseudo-TTY).

interactiveoptionalboolean

Pass -i (keep stdin open).

Used byexecArgv()

ExecInvocationinterface

A spawnable devsandbox exec invocation: spawn(file, args), no shell quoting.

PropertyTypeDescription
filestring

The native binary, as binaryPath() returns it.

argsstring[]—

Used byexecArgv()

Daemon API

HelloParamsinterface

hello params: what connect() sends first.

PropertyTypeDescription
versionstring

The client's devsandbox version; connect() sends 0.0.0 (the relay already handled any version handoff).

buildnumber

Unix mtime of a dev build; 0 otherwise.

clientstring

Who's calling (npm:<name>), for serve.log.

HelloResultinterface

The daemon's answer to hello (api.daemon).

PropertyTypeDescription
versionstring—
buildnumber—
protocolnumber

The API protocol number; see PROTOCOL.

handoffoptionalboolean

The client is newer: the daemon is exiting.

Used byApi

ApiErrorBodyinterface

An error response's body: code is stable, message is for humans.

PropertyTypeDescription
codestring—
messagestring—
dataoptionalunknown

Details some codes carry: VerbFailedData for failed.

OkResultinterface

What a mutation answers.

PropertyType
oktrue

Used byApiMethods

ThreadStatetype

A thread state; needs-you is waiting on the user.

type ThreadState = 'needs-you' | 'active' | 'done';

Used byThreadSummary

InboxViewtype

An inbox.threads.list view, as in the dashboard.

type InboxView = 'needs-you' | 'active' | 'done' | 'all';

Used byApiMethods ApiInbox

ApiTopictype

A notification topic for subscribe.

type ApiTopic = 'inbox' | 'instances' | 'forwards';

Used byApiMethods Api

ThreadSummaryinterface

One Inbox thread (inbox.list()), and the head of ThreadDetail.

PropertyTypeDescription
idnumber

Store id, stable for the thread's life: what { thread: id } takes.

ownerstring

Owner's instance_id.

owner_namestring

Owner's instance name when it last wrote.

keystring | null

Thread key; null on an unkeyed notification.

kind'thread' | 'notify'

thread (devsbd thread put) or notify (devsbd notify records).

stateThreadState | null

null on a notification.

statusstring | null

The owner's status line.

titlestring

A thread's title; a notification's newest message, first line.

level'info' | 'warn' | 'error' | null

A notification's newest level.

unreadboolean—
archivedboolean

The owner was removed: read-only history.

needs_youboolean

In the needs-you view (what badges count).

changed_atnumber

Unix seconds of the last change.

Used byThreadDetail ApiMethods ApiInbox

ThreadDetailinterface

A thread with everything the dashboard's pane shows (inbox.get()).

ExtendsThreadSummaryinherits id owner owner_name key kind state status title level unread archived needs_you changed_at

PropertyTypeDescription
linkstring | null

http(s) link.

childstring | null

The key, among the owner's dispatcher children, of the child it's about; null: the owner itself.

composeThreadCompose | null

Set when the thread takes replies (inbox.reply()).

actionsThreadAction[]—
feedFeedItem[]

An owner thread's feed, oldest first (first-insert order).

notesThreadNote[]

A notification's records, newest first.

events_pendingnumber

Events the owner hasn't acked yet.

Used byApiMethods ApiInbox

ThreadComposeinterface

How a thread takes free-text replies.

PropertyTypeDescription
placeholderstring | null—
hintstring | null

What sending does now, shown under the box.

Used byThreadDetail

ThreadActioninterface

An owner's action button (inbox.act()).

PropertyTypeDescription
idstring—
labelstring—
doneboolean

Pressing it also sets the thread done.

host'vscode' | 'terminal' | 'logs' | 'forward' | 'open' | 'rm' | null

The host verb it runs in the client that shows it; the API runs none.

sends_eventboolean

false: host-only, which inbox.act() refuses.

Used byThreadDetail

FeedItemtype

One item of a thread's feed, by type.

Used byThreadDetail

FeedItemBaseinterface

What every feed item carries.

PropertyTypeDescription
seqnumber

Arrival order across the whole Inbox.

atnumber

Unix seconds of first insert.

Used byFeedMessage FeedReply FeedAction FeedSubmission FeedMarker

FeedMessageinterface

A message from the thread's owner.

ExtendsFeedItemBaseinherits seq at

PropertyTypeDescription
type'message'—
idstring

The owner's id for it, unique in the thread.

blocksMessageBlock[]—
editedboolean

Replaced in place since it was first sent.

withdrawnboolean

The owner took it back.

Used byFeedItem

FeedReplyinterface

The user's reply (inbox.reply()).

ExtendsFeedItemBaseinherits seq at

PropertyType
type'reply'
textstring

Used byFeedItem

FeedActioninterface

The user pressed an action (inbox.act()).

ExtendsFeedItemBaseinherits seq at

PropertyTypeDescription
type'action'—
actionstring

The action's id.

labelstring

Its label when pressed.

Used byFeedItem

FeedSubmissioninterface

The user submitted a form (inbox.form.submit).

ExtendsFeedItemBaseinherits seq at

PropertyTypeDescription
type'submission'—
messagestring

The message holding the form.

formstring

The form's id.

answersRecord<string, FormAnswer | null>

Every question's answer; null for an optional one left unanswered, or a follow-up that doesn't apply.

Used byFeedItem

FeedMarkerinterface

A one-line marker: the user's done/reopen, the owner's state or status change.

ExtendsFeedItemBaseinherits seq at

PropertyTypeDescription
type'marker'—
marker'done' | 'reopen' | 'state' | 'status'—
fromstring | null

state/status: the value before; null otherwise (or no status).

tostring | null

state/status: the value after; null otherwise (or no status).

Used byFeedItem

MessageBlocktype

One block of a message, by type.

Used byFeedMessage

MarkdownBlockinterface

Markdown text.

PropertyType
type'markdown'
textstring

Used byMessageBlock

FieldsBlockinterface

A compact key/value list, shown as aligned label value rows.

PropertyType
type'fields'
itemsMessageField[]

Used byMessageBlock

MessageFieldinterface

One row of a fields block.

PropertyType
labelstring
valuestring

Used byFieldsBlock

FormBlockinterface

Questions for the user, answered once (inbox.form.submit). A submitted form is frozen: re-sends of its message never change it.

PropertyTypeDescription
type'form'—
idstring—
titlestring | null—
submitstring

The submit button's label.

questionsFormQuestion[]—
state'open' | 'submitted' | 'withdrawn'

withdrawn: the owner withdrew the message or dropped the form.

draftRecord<string, FormAnswer>

Saved partial answers (inbox.form.saveDraft) of an open form; {} otherwise.

answersRecord<string, FormAnswer | null> | null

Once submitted, every question's answer (null: optional and unanswered, or a follow-up that doesn't apply); null before.

Used byMessageBlock

FormQuestiontype

One question of a form, by type.

Used byFormBlock

FormAnswertype

An answer: an option id (choice), option ids (multiple choice), text, or a confirm's yes/no.

type FormAnswer = string | string[] | boolean;

Used byFeedSubmission FormBlock FormParams

QuestionBaseinterface

What every question carries.

PropertyTypeDescription
idstring

Unique in the form; what answers are keyed by.

labelstring

Inline markdown, one line.

contextstring | null

Markdown shown above the input.

requiredboolean

Must be answered to submit (text: not blank; multiple: one pick at least).

understring | null

A follow-up of this earlier question, shown under it; null: top-level.

whenstring | null

With under a choice: the option this follow-up is for. It applies only while that option is picked (else hidden, never required, answered null).

Used byChoiceQuestion TextQuestion ConfirmQuestion

ChoiceQuestioninterface

Pick one option, or several when multiple.

ExtendsQuestionBaseinherits id label context required under when

PropertyTypeDescription
type'choice'—
optionsChoiceOption[]—
multipleboolean—
defaultstring | string[] | null

An option id, or ids when multiple.

Used byFormQuestion

ChoiceOptioninterface

One option of a choice question.

PropertyType
idstring
labelstring
descriptionstring | null

Used byChoiceQuestion

TextQuestioninterface

Free text.

ExtendsQuestionBaseinherits id label context required under when

PropertyTypeDescription
type'text'—
placeholderstring | null—
defaultstring | null

Prefilled, editable.

multilineboolean—
maxnumber

Longest answer, in bytes.

Used byFormQuestion

ConfirmQuestioninterface

Yes or no.

ExtendsQuestionBaseinherits id label context required under when

PropertyTypeDescription
type'confirm'—
yesstring | null

Label of the yes choice; null: the client's own.

nostring | null

Label of the no choice; null: the client's own.

defaultboolean | null—

Used byFormQuestion

FormParamstype

inbox.form.* params: the message holding the form, and answers by question id.

type FormParams = ThreadAddress & { message: string; answers?: Record<string, FormAnswer> };

Used byApiMethods

ThreadNoteinterface

One record of a notification thread.

PropertyTypeDescription
idnumber—
level'info' | 'warn' | 'error'—
msgstring—
linkstring | null—
atnumber

Unix seconds.

Used byThreadDetail

ThreadAddresstype

A thread by store id, or an owner thread by owner (instance name or id) and key.

type ThreadAddress = { thread: number } | { owner: string; key: string };

Used byFormParams ApiMethods ApiInbox

NotifyTargettype

One notification thread by store id, or every one.

type NotifyTarget = { thread: number } | { all: true };

Used byApiMethods ApiInbox

ForwardRowinterface

One daemon port forward (forwards.list()).

PropertyTypeDescription
idnumber

Daemon-wide id: what forwards.rm() takes.

dirstring

The canonical config root; with machine, the root on that machine.

localstring

The bound host address, e.g. 127.0.0.1:3000.

targetstring

Route label, e.g. api:3000; empty until the route first resolves. A remote forward's is <machine>/<label>, best effort until the machine first answers.

processstring | null

The listening process (node (pid 412)).

statestring

active, connecting, or error: <reason>.

connsnumber

Open connections.

configuredboolean

From a sandbox's forwardPorts, not forwards.add().

machineoptionalstring

The machine whose instance or service it reaches (forwards.add() with machine); absent for this host's.

Used byApiMethods ApiForwards

ForwardAddParamsinterface

forwards.add() params; instance, service, or both.

PropertyTypeDescription
dirstring

Config root (the CLI's -C); resolved against process.cwd(). With machine, the absolute root on that machine.

instanceoptionalstring

Instance name, as the CLI takes it (never prompts).

serviceoptionalstring

Forward one of its services instead.

addressoptionalstring

Host address to bind. Default 127.0.0.1.

specstring

port (that host port or the next free one up) or host:port (exactly).

machineoptionalstring

A registered machine's instance or service (then dir is its config root there and instance its name there); the forward still binds on this host.

Used byApiMethods ApiForwards

ForwardAddedinterface

A forward forwards.add() bound.

PropertyTypeDescription
idnumber—
localstring—
targetstring

Route label, best effort this early.

Used byApiMethods ApiForwards

InstancesResolvedinterface

instances.resolve's answer: every instance the name could mean, sorted (several: the caller picks).

PropertyTypeDescription
matchesstring[]

With machines: a machine's matches qualified, <machine>/<name>.

foundoptionalResolvedInstance[]

matches in order, with where each lives (absent from older daemons).

Used byApiMethods

ResolvedInstanceinterface

PropertyTypeDescription
namestring

Its name on its own host (unqualified).

machinestring | null

null: this host.

rootstring | null

Its config root on its host; null when not recorded.

Used byInstancesResolved

InstanceCancelledinterface

instances.cancel's answer: the in-flight verb's pid was SIGINTed.

PropertyType
oktrue
pidnumber

Used byApiMethods

InstanceRenamedinterface

instances.rename's answer: the new (trimmed) name.

PropertyType
instancestring

Used byApiMethods

InstanceDoneinterface

instances.done's answer: the instance's done flag as it now is.

PropertyType
instancestring
doneboolean

Used byApiMethods

SandboxEntryinterface

One sandboxes.list entry (not the snapshot's SandboxRow).

PropertyTypeDescription
namestring—
machineoptionalstring

With sandboxes.list's machines: the machine defining it; absent for this host's.

rootoptionalstring

The config root defining it: always in sandboxes.list, absent in roots.list.

Used byRootCandidate ApiMethods

RootCandidateinterface

One roots.list entry: a config root this host knows of.

PropertyTypeDescription
rootstring

Absolute, canonicalized (a root that's gone: as recorded).

sandboxesSandboxEntry[]

Sorted; [] when error is set or there's no config file.

errorstring | null

Why the root's sandboxes can't be read (gone, a config that doesn't load).

Used byMachineProbe ApiMethods

MachineProbeinterface

machines.probe's answer: the machine's devsandbox and its candidate roots.

PropertyType
versionstring
protocolnumber
rootsRootCandidate[]

Used byApiMethods

MachineAddedinterface

machines.add's answer.

PropertyTypeDescription
namestring—
rootsstring[]

As saved: the machine's canonical paths, deduplicated.

versionstring

The machine's devsandbox semver.

warningstring | null

Set when that semver differs from this daemon's.

Used byApiMethods

MachineInfointerface

machines.get's answer: what an ssh command to the machine needs.

PropertyTypeDescription
namestring—
targetstring

What ssh takes, or an ssh:// URL.

commandstring | null

The remote devsandbox as shell text; null is devsandbox on its PATH.

rootsstring[]

Config roots on the machine.

agentboolean

This host's ssh-agent is relayed to it (machines.set).

Used byApiMethods

MachineHeldinterface

machines.hold's answer.

PropertyTypeDescription
oktrue—
agentboolean

The machine's agent relay is up; always false for a machine with agent off.

Used byApiMethods

MachineRowinterface

One registered machine (machines.list).

PropertyTypeDescription
namestring—
targetstring

What ssh takes, or an ssh:// URL.

rootsstring[]

Config roots on the machine.

commandstring | null

The remote devsandbox as shell text; null is devsandbox on its PATH.

agentboolean

This host's ssh-agent is relayed to it (machines.set).

stateLinkState—
errorstring | null

Why it's unreachable (or a root it refused).

versionstring | null

The machine's devsandbox semver, once reached.

Used byApiMethods

ProcessRowinterface

One process of an instance, as ps printed it.

PropertyType
pidstring
ppidstring
argsstring

Used byProcsListing

RunRowinterface

One tracked run of an instance's helper (devsbd run ls).

PropertyTypeDescription
idstring—
statestring

running, lost, or with its code: exited 4, killed 9.

startedstring

RFC 3339.

argvstring

The command, space-joined.

Used byProcsListing

ProcsListinginterface

A running instance's processes and runs (instances.procs).

PropertyTypeDescription
processesProcessRow[]—
signalableboolean

The pids are the container's own, so the process can be signalled; false for the runtime's host-side top fallback.

runsRunRow[]

Oldest first; [] without a helper that tracks runs.

Used byInstanceProcs

ProcsErrorinterface

Why an instance has no listing: no such instance, not running, or the listing failed.

PropertyType
errorstring

Used byInstanceProcs

InstanceProcstype

One instance's instances.procs entry.

Used byApiMethods

BuildLogTailinterface

instances.buildLog's answer: the end of the instance's build log.

PropertyTypeDescription
textstring—
cutboolean

Earlier lines were left out.

Used byApiMethods

ContainerLogsinterface

containers.logs's answer: the container's last output lines.

PropertyType
textstring

Used byApiMethods

SandboxConfiginterface

sandboxes.get's answer: the sandbox's config as TOML text.

PropertyTypeDescription
originalstring

The table as written, extends included.

resolvedstring

Merged with what it extends, or why it doesn't merge.

hashstring

The merged table's config hash; empty when it doesn't merge.

Used byApiMethods

ServiceConfiginterface

services.get's answer: the service's table as TOML text (services don't extends).

PropertyType
originalstring

Used byApiMethods

ForwardRemovedinterface

What forwards.rm() stopped.

PropertyTypeDescription
oktrue—
localstring—
configuredboolean

A configured forward stays stopped until its owner runs again.

Used byApiMethods ApiForwards

InboxChangedinterface

inbox.changed params: the store changed, re-fetch.

PropertyTypeDescription
generationnumber

Grows per change this daemon saw; compare within one connection only.

Used byApiEvents

InboxShowninterface

inbox.shown params: a container message worth a status line.

PropertyTypeDescription
instancestring—
linestring

The dashboard's status-line text.

Used byApiEvents

ForwardsStatusinterface

forwards.status params: a one-line forward status.

PropertyType
linestring

Used byApiEvents

VerbParamsinterface

What every verb (run, rebuild, start, stop, rm, services.rebuild) takes: the config root and the env the verb runs with (the caller's whole env, never the daemon's).

PropertyTypeDescription
rootstring

Absolute config root (the CLI's -C); with machine, a path on that machine.

envRecord<string, string>—
machineoptionalstring

Run it on that machine (a fresh ssh); answered as it answers there. A hang-up cancels it there unless detach, and so does this daemon exiting.

Used byRunParams RebuildParams StartParams StopParams RmParams ServicesRebuildParams

TtySizeinterface

A terminal's size in cells.

PropertyType
colsnumber
rowsnumber

Used byRunParams RebuildParams StartParams

RunParamsinterface

run params: the CLI's flags.

ExtendsVerbParamsinherits root env machine

PropertyTypeDescription
sandboxstring—
nameoptionalstring | null—
branchoptionalstring | null—
baseoptionalstring | null—
jsonoptionalboolean

The run record arrives on stdout (and in a detached answer's record).

detachoptionalboolean

Answer once the instance is registered.

ttyoptionalTtySize | null

Run the verb's commands on a pty of this size (each side 1 to 1000), so output is coloured and docker build shows its TTY progress, as on a terminal; stdout then carries both streams, with \r\n line ends and terminal escapes. The build log records the size. Absent: pipes, plain output.

Used byApiMethods

RebuildParamsinterface

rebuild params: instance or all: true.

ExtendsVerbParamsinherits root env machine

PropertyTypeDescription
instanceoptionalstring | null—
alloptionalboolean—
forceoptionalboolean—
detachoptionalboolean—
ttyoptionalTtySize | null

As RunParams.tty.

Used byApiMethods

StartParamsinterface

start params: instance or all: true.

ExtendsVerbParamsinherits root env machine

PropertyTypeDescription
instanceoptionalstring | null—
alloptionalboolean—
detachoptionalboolean—
ttyoptionalTtySize | null

As RunParams.tty.

Used byApiMethods

StopParamsinterface

stop params: instance or all: true.

ExtendsVerbParamsinherits root env machine

PropertyTypeDescription
instanceoptionalstring | null—
alloptionalboolean—
detachoptionalboolean

A hang-up before the answer leaves it running instead of cancelling it; the answer still comes at the exit.

Used byApiMethods

RmParamsinterface

rm params.

ExtendsVerbParamsinherits root env machine

PropertyTypeDescription
instancestring—
deleteBranchoptionalboolean | null

true deletes the branch, false keeps it; absent: merged or gone branches go, local work stays.

forceoptionalboolean—
askoptionalboolean

Where the branch question would come up, answer confirm (the question as its message) having removed nothing; resend with deleteBranch.

detachoptionalboolean

A hang-up before the answer leaves it running instead of cancelling it; the answer still comes at the exit.

Used byApiMethods

ServicesRebuildParamsinterface

services.rebuild params: the service's name in the config root.

ExtendsVerbParamsinherits root env machine

PropertyTypeDescription
namestring—
detachoptionalboolean

A hang-up before the answer leaves it running instead of cancelling it; the answer still comes at the exit.

Used byApiMethods

VerbResultinterface

A verb's answer once it exited 0.

PropertyTypeDescription
instancestring | null

The instance it acted on; null for all or when unknown.

exit0—

Used byApiMethods

VerbDetachedinterface

A detach verb's early answer; the verb runs on.

PropertyTypeDescription
instancestring | null—
detachedtrue—
recordoptionalRunRecord

run with json: the in-flight instance's record.

Used byApiMethods

VerbFailedDatainterface

data of a failed error: the verb exited non-zero.

PropertyType
exitnumber
instancestring | null

VerbOutputinterface

output params: a chunk of a verb's stdout or stderr.

PropertyTypeDescription
requestnumber

The verb request's id.

stream'stdout' | 'stderr'—
datastring

UTF-8 (lossy), as read.

Used byApiEvents

VerbProgressinterface

progress params: a verb's instance changed phase.

PropertyTypeDescription
requestnumber—
instancestring—
phasestring

preparing, building, creating, a lifecycle step, or failed.

Used byApiEvents

Closinginterface

closing params: the daemon is exiting; connect again (which starts a new one).

PropertyType
reason'handoff' | 'idle' | 'shutdown'

Used byApiEvents

ApiNotificationinterface

Any daemon notification, known or not (the notification event).

PropertyType
methodstring
paramsunknown

Used byApiEvents

ApiCloseinterface

Why a connection closed (the close event).

PropertyTypeDescription
codenumber | null

The relay's exit code: 0 after close(), 75 when the daemon hung up.

signalNodeJS.Signals | null—

Used byApiEvents

ApiEventsinterface

Events an Api emits, by name. Notifications need subscribe() first.

PropertyTypeDescription
inbox.changedInboxChanged—
inbox.shownInboxShown—
instances.changed{}—
instances.snapshotInstancesSnapshot

A root this connection watches (instances.watch); needs the instances topic.

forwards.changed{}—
forwards.statusForwardsStatus—
outputVerbOutput

A verb request's output; sent to its connection, no subscribe needed.

progressVerbProgress

A verb request's phase change; sent to its connection, no subscribe needed.

closingClosing—
notificationApiNotification

Every notification, including ones this package doesn't know yet.

closeApiClose

The relay exited; pending calls were rejected with code closed.

Used byApi

ApiMethodsinterface

Params and result of each typed method, for Api's call.

PropertyTypeDescription
inbox.threads.list{ params: { view?: InboxView }; result: ThreadSummary[] }—
inbox.thread.get{ params: ThreadAddress; result: ThreadDetail }—
inbox.thread.markRead{ params: ThreadAddress; result: OkResult }—
inbox.thread.act{ params: ThreadAddress & { action: string }; result: OkResult }—
inbox.thread.reply{ params: ThreadAddress & { text: string }; result: OkResult }—
inbox.thread.done{ params: ThreadAddress; result: OkResult }—
inbox.thread.reopen{ params: ThreadAddress; result: OkResult }—
inbox.form.saveDraft{ params: FormParams; result: OkResult }

Merge answers (any subset) into an open form's draft; no event.

inbox.form.submit{ params: FormParams; result: OkResult }

Submit an open form: answers over the draft over the defaults; the owner gets one submit event.

inbox.notify.dismiss{ params: NotifyTarget; result: OkResult }—
inbox.notify.markRead{ params: NotifyTarget; result: OkResult }—
instances.list{ params: { dir: string; depth?: SnapshotDepth; machine?: string }; result: InstancesList }

depth: disk (state + config, statuses unknown), listing (+ statuses, drift), full (+ cpu/mem; the default). machine: ask that machine (its dir), answered as it answers; not-found for a machine that isn't registered.

instances.watch{ params: { dir: string; machines?: boolean }; result: OkResult }

Push instances.snapshot for config root dir (absolute) while connected; subscribe to instances first (else invalid). The first one comes at once (cached, or from disk). machines: every push also carries the machines' rows and machines.

instances.unwatch{ params: { dir: string }; result: OkResult }

Stop instances.watching dir; not watching it is fine.

instances.resolve{ params: { name: string; machines?: boolean; machine?: string }; result: InstancesResolved }

not-found when nothing matches. machines: this host and every machine (5 s each); a not-found then names the machines that didn't answer. machine (here and on every instance, container and config method below): ask that machine, answered as it answers; not-found for a machine that isn't registered.

instances.cancel{ params: { instance: string; machine?: string }; result: InstanceCancelled }

SIGINT an in-flight run/rebuild (it rolls back or records failed); invalid when not in flight.

instances.procs{ params: { instances: string[]; machine?: string }; result: Record<string, InstanceProcs> }

Per named instance (exact names), its processes and runs or an error; a per-instance failure never fails the call.

instances.buildLog{ params: { instance: string; lines?: number; ansi?: boolean; machine?: string }; result: BuildLogTail | null }

instance: exact name or instance id; lines default 500, at most 10000. null: no build log yet. A pty log is replayed: plain lines, or with ansi lines carrying SGR escapes only.

instances.signal{ params: { instance: string; pid: string; signal: 'TERM' | 'KILL'; machine?: string }; result: OkResult }

Signal a process in the instance's container (exact name; pid from instances.procs, digits).

instances.rename{ params: { instance: string; newName: string; machine?: string }; result: InstanceRenamed }

Exact name; invalid for a bad or taken name, or an instance mid-build.

instances.done{ params: { instance: string; done: boolean; machine?: string }; result: InstanceDone }

Set or clear the done flag (exact name); idempotent.

containers.logs{ params: { container: string; lines?: number; machine?: string }; result: ContainerLogs }

devsandbox-… containers only; lines default 50, at most 10000.

containers.inspect{ params: { container: string; machine?: string }; result: unknown }

devsandbox-… containers only: the runtime's inspect JSON (docker's: an array of one object).

sandboxes.list{ params: { root: string; machines?: boolean; machine?: string }; result: SandboxEntry[] }

The config root's sandboxes, sorted; [] without a config file. machines: then every machine's registered roots' (5 s; one that doesn't answer adds nothing, see machines.list).

roots.list{ params: { paths?: string[] }; result: RootCandidate[] }

This host's config roots: every one its instances were made from, plus ~/.devsandboxes; sorted. With paths: exactly those, in order (~ expanded here, canonicalized; a bad one has its error).

machines.probe{ params: { target: string; command?: string }; result: MachineProbe }

Dial a target over ssh and list its candidate roots; failed when ssh or the hello fails. command: the machine's devsandbox as shell text (default devsandbox); invalid when empty.

machines.add{ params: { target: string; name?: string; roots: string[]; agent?: boolean; command?: string }; result: MachineAdded }

Check roots on the machine (a quoted ~ is its home) and register it; invalid for a taken name, a bad root or an empty command. command as machines.probe's, saved as the machine's.

machines.list{ params: {}; result: MachineRow[] }—
machines.set{ params: { name: string; agent: boolean }; result: OkResult }

Change a registered machine's settings; not-found for an unknown name.

machines.rm{ params: { name: string }; result: OkResult }—
machines.get{ params: { name: string }; result: MachineInfo }

One registered machine, to build an ssh command to it; not-found for an unknown name.

machines.hold{ params: { name: string; agent?: string }; result: MachineHeld }

Hold a machine's link (and, with agent on, its agent relay) up until this connection closes; agent is the caller's absolute SSH_AUTH_SOCK. Waits up to 5 s for the relay; not-found for an unknown name.

sandboxes.get{ params: { root: string; name: string; machine?: string }; result: SandboxConfig }

not-found for an unknown sandbox; one that doesn't merge answers why in resolved.

services.get{ params: { root: string; name: string; machine?: string }; result: ServiceConfig }—
forwards.list{ params: { dir?: string; machines?: boolean }; result: ForwardRow[] }—
forwards.add{ params: ForwardAddParams; result: ForwardAdded }—
forwards.rm{ params: { id: number }; result: ForwardRemoved }—
run{ params: RunParams; result: VerbResult | VerbDetached }

Verbs hold the connection until they exit (or a detach answer); hanging up cancels.

rebuild{ params: RebuildParams; result: VerbResult | VerbDetached }—
start{ params: StartParams; result: VerbResult | VerbDetached }—
stop{ params: StopParams; result: VerbResult }—
rm{ params: RmParams; result: VerbResult }—
services.rebuild{ params: ServicesRebuildParams; result: VerbResult }

No instance verb: instance is always null; detach only keeps it running past a hang-up, the answer comes at its exit.

subscribe{ params: { topics: ApiTopic[] }; result: OkResult }—
unsubscribe{ params: { topics: ApiTopic[] }; result: OkResult }—
shutdown{ params: {}; result: OkResult }

Stop the daemon (it drains, then exits); devsandbox serve install sends it.

Used byApi

ApiInboxinterface

inbox.* methods; mutations resolve once the store is written.

PropertyTypeDescription
list(view?: InboxView) => Promise<ThreadSummary[]>

Threads in view (default all), last change first.

get(thread: ThreadAddress) => Promise<ThreadDetail>—
markRead(thread: ThreadAddress) => Promise<void>—
act(thread: ThreadAddress, action: string) => Promise<void>

Press an owner's action (its event; host-only actions are refused).

reply(thread: ThreadAddress, text: string) => Promise<void>

Send a reply; trimmed, cut at 2000 chars.

done(thread: ThreadAddress) => Promise<void>—
reopen(thread: ThreadAddress) => Promise<void>—
dismiss(target: NotifyTarget) => Promise<void>

Remove one notification thread, or every one.

markNotifyRead(target: NotifyTarget) => Promise<void>

Mark one notification thread read, or every one.

Used byApi

ApiInstancesinterface

instances.* methods.

PropertyTypeDescription
list(dir: string) => Promise<InstancesList>

The status snapshot of config root dir (resolved against process.cwd()), full depth.

Used byApi

ApiForwardsinterface

forwards.* methods. Ad-hoc forwards outlive the connection until rm.

PropertyTypeDescription
list(dir?: string) => Promise<ForwardRow[]>

Forwards of config root dir, or of every root.

add(params: ForwardAddParams) => Promise<ForwardAdded>

Start an ad-hoc forward; resolves once its listener is bound.

rm(id: number) => Promise<ForwardRemoved>—

Used byApi

Apiinterface

A connection to the daemon (connect()), an EventEmitter of ApiEvents.

PropertyTypeDescription
daemonreadonlyHelloResult

The daemon's hello answer.

closedreadonlyboolean

The relay has exited; calls reject with code closed.

call<M extends string>( method: M, params?: M extends keyof ApiMethods ? ApiMethods[M]['params'] : unknown, ) => Promise<M extends keyof ApiMethods ? ApiMethods[M]['result'] : unknown>

Any method; typed for ApiMethods, unknown for the rest.

subscribe(topics: readonly ApiTopic[]) => Promise<void>

Start notifications for topics; subscribe first, then fetch.

unsubscribe(topics: readonly ApiTopic[]) => Promise<void>—
on<E extends keyof ApiEvents>(event: E, listener: (params: ApiEvents[E]) => void) => Api—
once<E extends keyof ApiEvents>(event: E, listener: (params: ApiEvents[E]) => void) => Api—
off<E extends keyof ApiEvents>(event: E, listener: (params: ApiEvents[E]) => void) => Api—
close() => Promise<void>

Hang up: closes the relay's stdin, resolves once it exited.

inboxApiInbox—
instancesApiInstances—
forwardsApiForwards—

Used byconnect()

ConnectOptionsinterface

PropertyTypeDescription
nameoptionalstring

Sent as npm:<name> in the hello and passed to the relay, for serve.log. Default node.

envoptionalNodeJS.ProcessEnv—
stderroptional'pipe' | 'inherit'

inherit passes the relay's diagnostics to this process's stderr. Default pipe (kept for error messages).

Used byconnect()

Errors

A command that exits non-zero rejects with a DevsandboxError carrying its arguments and captured output. exec() is the exception: it resolves with the command's exit code, and cli() does the same with reject: false.

DevsandboxErrorclass

Rejection for a failed CLI invocation.

ExtendsError

PropertyType
namereadonly'DevsandboxError'
argsreadonlystring[]
exitCodereadonlynumber | null
signalreadonlyNodeJS.Signals | null
stdoutreadonlystring
stderrreadonlystring

DevsandboxApiErrorclass

Rejection of an API call. code is the daemon's (not-found, invalid, denied, closed-form, bind-failed, failed, unknown-method, internal, …) or the client's own: closed (the connection ended), protocol, unsupported.

ExtendsError

PropertyTypeDescription
namereadonly'DevsandboxApiError'—
codereadonlystring—
methodreadonlystring

The method called; hello for a failed connect.

datareadonlyoptionalunknown

The error body's data, when its code carries some (VerbFailedData for failed).

TS
try {
  await devsandbox.start('web');
} catch (e) {
  if (!(e instanceof devsandbox.DevsandboxError)) throw e;
  console.error(e.args, e.exitCode, e.stderr);
}

Constants

SCHEMAconst

JSON envelope version this package understands.

const SCHEMA: 1;

PROTOCOLconst

The API protocol number this package speaks; connect() rejects any other.

const PROTOCOL: 1;

Source: npm/devsandboxes/index.d.tsView source on GitHub(opens in a new tab)

MENU /
View on GitHub
EXAMPLES
All examplesEvery recipe on one page.Parallel coding agentsSeveral coding agents on one repo, fully isolated from one another.One shared PostgresOne development database for all your sandboxes and their instances.Private services per instanceEvery instance gets its own Postgres and Redis, so agents never touch each other's data.Shared package cachesNew sandboxes stop downloading the same packages again.ssh-agent and git pushAgents push over ssh with your host's keys, which never enter the container.Port forwarding on demandOpen a sandbox's dev server or database from your host, without restarting anything.Attach VS CodeOpen any instance in VS Code with one key.devcontainer FeaturesAdd Node, Rust or the GitHub CLI to any image, in TOML.Babysit pull requestsAn agent keeps your open PRs merged with their base, and pings you when it can't.Port a devcontainer.jsonTurn an existing devcontainer.json into a devsandbox config.