Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.superserve.ai/llms.txt

Use this file to discover all available pages before exploring further.

Run any shell command inside a sandbox using sandbox.commands.run().
import { Sandbox } from "@superserve/sdk"

const sandbox = await Sandbox.create({ name: "data-analyzer" })
const result = await sandbox.commands.run("python analyze.py")
console.log(result.stdout)
AsyncSandbox exposes the same API with awaitable methods - see the Sandbox reference.

Handling exit codes

run() doesn’t throw for non-zero exit codes - inspect exitCode on the result.
const result = await sandbox.commands.run("exit 42")
if (result.exitCode !== 0) {
  console.error(`Command failed: ${result.stderr}`)
}

Working directory and environment

Pass cwd and env to control the execution context.
const result = await sandbox.commands.run("python script.py", {
  cwd: "/app",
  env: { PORT: "3000", DEBUG: "1" },
  timeoutMs: 60_000,
})
TypeScript uses timeoutMs (milliseconds); Python uses timeout_seconds (integer seconds). Each follows its language’s convention.

Timeouts

Pass a timeout to kill a command that runs longer than you expect.
const result = await sandbox.commands.run("sleep 100", {
  timeoutMs: 5_000,
})
See streaming output for long-running commands where you want to watch stdout as it happens.