Skip to main content

Import

import {
  createAgentServiceSandboxClient,
  createAgentServiceSandboxTools,
  createProjectScopedExecOptions,
  createSandboxShellTools,
  normalizeBashToolSet,
  renameSandboxFileTools,
} from "veryfront/sandbox";

Examples

import { Sandbox } from "veryfront/sandbox";

const sandbox = await Sandbox.create();
const result = await sandbox.executeCommand("echo hello");
console.log(result.stdout); // "hello\n"
await sandbox.close();

API

Sandbox.create()

Create a new sandbox session. Claims a warm pod or creates a new one. Returns: Promise<Sandbox>

Sandbox.get(id, )

Reconnect to an existing sandbox session. Returns: Promise<Sandbox>

Sandbox.attach(attachment)

Attach to an already-known sandbox session and endpoint without a reconnect lookup. Returns: Sandbox

Sandbox.list()

List sandbox sessions with optional pagination. Returns: Promise<SandboxListResult>

Sandbox.createLazy()

Create a lazily-provisioned sandbox session with automatic heartbeats. Returns: LazySandbox

sandbox.executeCommand(command, options)

Execute a bash command in the sandbox and return buffered result. Returns: Promise<ExecResult>

sandbox.executeStream(command, options)

Execute a bash command with streaming output (NDJSON). Returns: AsyncGenerator<ExecStreamEvent>

sandbox.readFile(path)

Read a file from the sandbox workspace. Returns: Promise<string>

sandbox.writeFiles(files)

Write files to the sandbox workspace. Returns: Promise<void>

sandbox.startBackgroundCommand(command, options)

Start an async background command in the sandbox. Returns: Promise<BackgroundCommand>

sandbox.getBackgroundCommand(commandId)

Get the status of an async background command. Returns: Promise<BackgroundCommand>

sandbox.getBackgroundCommandOutput(commandId)

Get the output of an async background command. Returns: Promise<BackgroundCommandOutput>

sandbox.listBackgroundCommands()

List all background commands in the sandbox. Returns: Promise<BackgroundCommand[]>

sandbox.cancelBackgroundCommand(commandId)

Cancel an async background command. Returns: Promise<BackgroundCommand>

sandbox.heartbeat()

Send a heartbeat to prevent idle timeout. Returns: Promise<void>

sandbox.close()

Close the sandbox session and mark for deletion. Returns: Promise<void>

sandbox.id

Get the session ID. Returns: string

sandbox.url

Get the sandbox endpoint URL. Returns: string

Type Reference

SandboxOptions

Options for creating a sandbox session.
PropertyTypeDescriptionSource
apiUrl?stringBase URL of the Veryfront API. Defaults to VERYFRONT_API_URL, then the Veryfront Cloud API.source
authToken?stringExplicit Veryfront auth token or API key override.source
projectId?stringOptional project context for project-billed / project-scoped sandbox sessions.source

ExecResult

Result of a command execution: stdout, stderr, and exit code.
PropertyTypeDescriptionSource
stdoutstringBuffered standard output from command execution.source
stderrstringBuffered standard error from command execution.source
exitCodenumberProcess exit code.source

ExecStreamEvent

Streaming event emitted during command execution.
PropertyTypeDescriptionSource
type"stdout" | "stderr" | "exit" | "error"Event type (stdout, stderr, exit, error).source
data?stringChunk payload for stdout/stderr/error events.source
exitCode?numberExit code for exit events.source

Exports

Functions

NameDescriptionSource
createAgentServiceSandboxClientCreate agent service sandbox client.source
createAgentServiceSandboxToolsCreate agent service sandbox tools.source
createProjectScopedExecOptionsOptions accepted by create project scoped exec.source
createSandboxShellToolsCreate sandbox shell tools.source
normalizeBashToolSetNormalizes bash tool set.source
renameSandboxFileToolsRename sandbox file tools.source
resolveDefaultSandboxRuntimeEndpointResolves default sandbox runtime endpoint.source
unwrapSandboxWorkingDirectoryCommandUnwrap sandbox working directory command.source

Classes

NameDescriptionSource
LazySandboxLazily provisions sandbox sessions and keeps them alive while in use.source
SandboxClient for isolated ephemeral compute environments with command execution and file I/O.source

Types

NameDescriptionSource
AgentServiceSandboxBackgroundCommandClientPublic API contract for agent service sandbox background command client.source
AgentServiceSandboxClientPublic API contract for agent service sandbox client.source
AgentServiceSandboxClientOptionsOptions accepted by agent service sandbox client.source
AgentServiceSandboxToolsOptionsOptions accepted by agent service sandbox tools.source
AgentServiceSandboxToolsResultResult returned from agent service sandbox tools.source
BackgroundCommandAn async background command running in a sandbox.source
BackgroundCommandHeartbeatStatusHeartbeat health status for a background command.source
BackgroundCommandOutputA background command with its captured output.source
BackgroundCommandStatusStatus of an async background command.source
BashToolSandboxLikePublic API contract for sandbox shell client.source
CreateSandboxBashToolPublic API contract for sandbox shell tools provider.source
ExecOptionsOptions for command execution: working directory, timeout, environment variables, and optional project reference.source
ExecResultResult of a command execution: stdout, stderr, and exit code.source
ExecStreamEventStreaming event emitted during command execution.source
HostedSandboxBackgroundCommandClientPublic API contract for hosted sandbox background command client.source
HostedSandboxClientPublic API contract for hosted sandbox client.source
HostedSandboxClientOptionsOptions accepted by hosted sandbox client.source
HostedSandboxToolsOptionsOptions accepted by hosted sandbox tools.source
HostedSandboxToolsResultResult returned from hosted sandbox tools.source
LazySandboxOptionsOptions accepted by lazy sandbox.source
SandboxAttachmentKnown sandbox session connection details used to attach without a lookup round-trip.source
SandboxListOptionsOptions for listing sandbox sessions.source
SandboxListResultPaginated result of sandbox sessions.source
SandboxOptionsOptions for creating a sandbox session.source
SandboxSessionA sandbox session summary returned by list.source
SandboxShellToolDefinitionDefinition for sandbox shell tool.source
SandboxShellToolSetPublic API contract for sandbox shell tool set.source

Constants

NameDescriptionSource
createHostedSandboxClientCreate hosted sandbox client.source
createHostedSandboxToolsCreate hosted sandbox tools.source