Documentation
TypeScript SDK reference
Classes, methods, fields, and return types for @syva/sdk.
Model
| Name | Type | Description |
|---|---|---|
Sandbox | class | Sandbox instance returned by create, get, and list. |
Image | class | Immutable image recipe used as a sandbox image input. |
sandbox.process | SandboxProcess | Foreground and background command namespace. |
sandbox.fs | FileSystem | Absolute-path filesystem namespace. |
classclassSandboxProcessFileSystemCreate Sandboxes
Sandbox Object
| Name | Type | Description |
|---|---|---|
id | string | Sandbox id. |
state | string | Lifecycle state. |
image | string | Resolved image ref. |
resources | Record<string, number> | Allocated CPU, memory, and disk. |
networkPolicy | string | Outbound network policy. |
labels | string[] | Labels attached at creation. |
ports | JsonObject[] | Declared port bindings and preview URLs. |
createdAt | string | ISO timestamp. |
expiresAt | string | undefined | ISO timestamp when an expiry was requested. |
error | string | undefined | Terminal error when present. |
name | string | undefined | Unique sandbox name when assigned. |
persistent | boolean | Whether stop snapshots the filesystem. |
currentSnapshotId | string | undefined | Snapshot the next start resumes from. |
lastSnapshot | Snapshot | undefined | Snapshot captured by the most recent stop(). |
fs | FileSystem | Filesystem namespace. |
process | SandboxProcess | Command namespace. |
stringstringstringRecord<string, number>stringstring[]JsonObject[]stringstring | undefinedstring | undefinedstring | undefinedbooleanstring | undefinedSnapshot | undefinedFileSystemSandboxProcessSandbox.configure(config)Sets default baseUrl, apiKey, retry, timeout, or fetch implementation.
Returns: void
Sandbox.create(options, config)Creates a sandbox and waits for it to become ready or fail.
Returns: Promise<Sandbox>
Sandbox.get(sandboxId, config)Fetches an existing sandbox.
Returns: Promise<Sandbox>
Sandbox.list(options, config)Lists sandboxes for the API key.
Returns: Promise<Sandbox[]>
sandbox.refresh()Reloads sandbox state.
Returns: Promise<Sandbox>
Sandbox.getByName(name, config)Fetches a sandbox by its unique name.
Returns: Promise<Sandbox>
Sandbox.getOrCreate(options, config)Resumes the named sandbox, or creates it when missing.
Returns: Promise<Sandbox>
sandbox.destroy()Permanently deletes the sandbox, its snapshots, and frees its name.
Returns: Promise<Sandbox>
sandbox.stop()Stops the sandbox; persistent sandboxes snapshot their filesystem first.
Returns: Promise<Sandbox>
sandbox.start()Resumes a stopped persistent sandbox from its latest snapshot.
Returns: Promise<Sandbox>
sandbox.snapshot(options)Takes a manual snapshot; the sandbox stops.
Returns: Promise<Snapshot | undefined>
sandbox.snapshots()Lists this sandbox's live snapshots.
Returns: Promise<Snapshot[]>
sandbox.fork(options)Creates a new sandbox from this sandbox's latest snapshot.
Returns: Promise<Sandbox>
sandbox.update(options)Updates persistence, expiration, retention, or rolls back via currentSnapshotId.
Returns: Promise<Sandbox>
Snapshot.list(options, config)Lists snapshots in the project.
Returns: Promise<Snapshot[]>
Snapshot.delete(snapshotId, config)Deletes a snapshot and its stored data.
Returns: Promise<Snapshot>
sandbox.kill()Alias for destroy.
Returns: Promise<Sandbox>
sandbox.extendTtl(options)Sets or extends the expiry window.
Returns: Promise<Sandbox>
sandbox.extendTimeout(durationMs)Extends the expiry window by milliseconds.
Returns: Promise<Sandbox>
sandbox.wait(options)Polls until the sandbox reaches a lifecycle state.
Returns: Promise<Sandbox>
sandbox.domain(port)Returns the preview URL for an exposed port.
Returns: string
Snapshots
Persistent sandboxes snapshot their filesystem on stop() and resume with start(). See the Snapshots guide.
| Name | Type | Description |
|---|---|---|
id | string | Snapshot id. |
state | string | created, deleted, or failed. |
source | string | auto (taken on stop) or manual. |
sandboxId | string | undefined | Owning sandbox. |
sizeBytes | number | Stored (compressed) bytes; the billing basis. |
expiresAt | string | undefined | Expiry, refreshed each time the snapshot is used. |
stringstringstringstring | undefinednumberstring | undefinedCommands
sandbox.runCommand(command, options)Runs a command. Set detached to return immediately.
Returns: Promise<CommandFinished | Command>
sandbox.process.exec(command, options)Runs a foreground command.
Returns: Promise<CommandFinished>
sandbox.process.start(command, options)Starts a background command.
Returns: Promise<Command>
sandbox.process.get(commandId)Fetches the latest command state.
Returns: Promise<Command>
sandbox.process.output(commandId)Returns stdout and stderr snapshot.
Returns: Promise<CommandOutput>
sandbox.process.logs(commandId, options)Returns stdout, stderr, or combined log text.
Returns: Promise<string>
sandbox.process.stream(commandId)Streams stdout, stderr, and final status events.
Returns: AsyncIterable<CommandOutputEvent>
sandbox.process.stop(commandId)Stops a running command.
Returns: Promise<Command>
sandbox.process.list(options)Lists recent commands.
Returns: Promise<Command[]>
command.refresh()Reloads command state.
Returns: Promise<Command>
command.wait(options)Waits for command completion.
Returns: Promise<Command>
command.output()Returns stdout and stderr snapshot.
Returns: Promise<CommandOutput>
command.readLogs(stream)Returns stdout, stderr, or combined log text.
Returns: Promise<string>
command.stream(options)Streams command output events.
Returns: AsyncIterable<CommandOutputEvent>
CommandFinished
| Name | Type | Description |
|---|---|---|
exitCode | number | Process exit code. |
stdout | string | Captured stdout. |
stderr | string | Captured stderr. |
durationMs | number | Runtime duration. |
timedOut | boolean | True when the timeout killed the command. |
numberstringstringnumberbooleanFilesystem
Top-level helpers default to /workspace. sandbox.fs uses absolute paths.
sandbox.writeFile(path, data, options)Writes under /workspace unless path is absolute.
Returns: Promise<void>
sandbox.writeFiles(files, options)Writes multiple files under /workspace unless paths are absolute.
Returns: Promise<void>
sandbox.readFile(path, options)Returns a readable stream, or null when missing.
Returns: Promise<ReadableStream | null>
sandbox.readFileToBuffer(path, options)Reads bytes into memory, or null when missing.
Returns: Promise<Uint8Array | null>
sandbox.mkDir(path, options)Creates a directory under /workspace unless path is absolute.
Returns: Promise<FileInfo>
sandbox.fs.writeFile(path, data, options)Writes bytes or text to an absolute path.
Returns: Promise<void>
sandbox.fs.writeFiles(files)Writes multiple absolute-path files.
Returns: Promise<void>
sandbox.fs.readFile(path)Reads bytes from an absolute path.
Returns: Promise<Uint8Array>
sandbox.fs.stat(path)Returns path metadata.
Returns: Promise<FileInfo>
sandbox.fs.list(path)Lists directory entries.
Returns: Promise<FileInfo[]>
sandbox.fs.find(path, options)Finds files and directories by type or pattern.
Returns: Promise<FileInfo[]>
sandbox.fs.grep(query, options)Searches file contents and returns matching lines.
Returns: Promise<GrepMatch[]>
sandbox.fs.mkdir(path, options)Creates a directory.
Returns: Promise<FileInfo>
sandbox.fs.rm(path, options)Removes a file or directory.
Returns: Promise<void>
Images
String images are Syva image refs. Public registry refs such as node:22 should be wrapped with Image.fromRegistry; Sandbox.create builds that recipe into a reusable Syva image before launch.
Image recipes are immutable. Every mutating method returns a new Image.
new Image(reference)Creates a base image recipe from a Syva base ref.
Returns: Image
Image.fromRegistry(reference)Starts a recipe from a public Docker or OCI registry image.
Returns: Image
image.python(version)Adds Python tooling.
Returns: Image
image.aptInstall(packages)Installs Debian packages.
Returns: Image
image.pipInstall(packages)Installs Python packages.
Returns: Image
image.npmInstall(packages, options)Installs npm packages.
Returns: Image
image.runCmd(command)Adds a build-time command.
Returns: Image
image.env(values)Adds default environment variables.
Returns: Image
image.workdir(path)Sets the default workdir.
Returns: Image
image.user(user)Sets the default user.
Returns: Image
image.copy(src, dest, options)Copies files into the build context.
Returns: Image
image.setStartCommand(command, readyCommand)Sets boot and optional readiness commands.
Returns: Image
image.digest()Returns a stable recipe digest.
Returns: string
Errors
| Name | Type | Description |
|---|---|---|
message | string | Human-readable error. |
code | string | undefined | Stable Syva error code. |
status | number | undefined | HTTP status when available. |
sandboxId | string | undefined | Related sandbox id when available. |
retryable | boolean | undefined | Whether retrying may succeed. |
stringstring | undefinednumber | undefinedstring | undefinedboolean | undefined