Toolbox
The toolbox is the API inside every sandbox. A daemon in the sandbox runs your commands, processes, terminals and file operations, and your calls reach it only through Daytona’s toolbox proxy, which checks your API key and passes each call into the sandbox. Ports are reached the same way, through preview URLs, and a shell through SSH access you create.
Every call goes through the toolbox proxy
Section titled “Every call goes through the toolbox proxy”Every sandbox handle carries the toolbox, with Daytona’s own parameters. Get a handle from CreateSandbox or ConnectSandbox.
Run a shell command
Section titled “Run a shell command”const result = yield* sandbox.exec("ls -la && cat package.json", { cwd: "/home/daytona/repo" });// { exitCode: 0, result: "..." }A non-zero exit comes back in exitCode; it doesn’t fail the Effect. Daytona combines stdout and stderr into result.
An array runs as an argument vector, with no shell to quote for:
yield* sandbox.exec(["git", "commit", "-m", message], { cwd: "/home/daytona/repo" });Start a process
Section titled “Start a process”const server = yield* sandbox.start(["python3", "-m", "http.server", "8080"], { cwd: "/srv" });yield* server.output.pipe( Stream.runForEach((out) => Console.log(out.fd, new TextDecoder().decode(out.data))),);start runs the command in its own session and returns while it runs: output streams stdout and stderr, write types into its stdin, wait resolves with its exit code, and kill() ends it (Daytona takes no signal). Closing the scope only detaches.
Keep a shell session
Section titled “Keep a shell session”yield* sandbox.process.createSession({ sessionId: "dev" });yield* sandbox.process.sessionExecuteCommand({ sessionId: "dev", command: "pnpm dev --port 3000", runAsync: true,});For a shell whose state carries from command to command, use a session. Sessions keep running between calls. getSessionCommandLogs returns the output so far, with stdout and stderr apart.
Follow a command’s output
Section titled “Follow a command’s output”yield* sandbox.process .followSessionCommandLogs({ sessionId: "dev", commandId: started.cmdId }) .pipe(Stream.runForEach((piece) => Console.log(piece.stream, piece.text)));The stream ends when the command exits. followEntrypointLogs() follows the sandbox’s entrypoint the same way.
Open a terminal
Section titled “Open a terminal”const pty = yield* sandbox.pty.open({ cols: 120, rows: 30 });yield* pty.write("pnpm install && exit\n");yield* pty.output.pipe(Stream.decodeText(), Stream.runForEach(Console.log));const { exitCode } = yield* pty.exit;The connection closes with its scope, and the terminal keeps running until it exits or you kill it. pty.connect(sessionId) attaches to a terminal that already runs. Daytona starts the user’s shell; type the command you want into it.
Read and write files
Section titled “Read and write files”yield* sandbox.files.makeDir("/home/daytona/out");yield* sandbox.files.write("/home/daytona/out/report.json", JSON.stringify(report));const text = yield* sandbox.files.readText("/home/daytona/out/report.json");const entries = yield* sandbox.files.list("/home/daytona/out");files also has read (bytes), stat and remove. Daytona’s own file API is on fs, with search and replace:
const hits = yield* sandbox.fs.findInFiles({ path: "/home/daytona/repo/src", pattern: "TODO" });Move many files at once
Section titled “Move many files at once”yield* sandbox.fs.uploadFiles({ files: [ { path: "/home/daytona/repo/.env", content: "PORT=3000\n" }, { path: "/home/daytona/repo/logo.png", content: pngBytes }, ],});const { files, errors } = yield* sandbox.fs.downloadFiles({ paths: ["/home/daytona/out/a.json", "/home/daytona/out/b.json"] });A path that can’t be read comes back in errors; the rest still download.
Clone and commit with git
Section titled “Clone and commit with git”yield* sandbox.git.cloneRepository({ url: "https://github.com/alchemy-run/alchemy", path: "/home/daytona/repo" });const status = yield* sandbox.git.getStatus({ path: "/home/daytona/repo" });Open a port’s preview
Section titled “Open a port’s preview”const port = yield* sandbox.getTcpPort(3000);const res = yield* port.fetch(HttpClientRequest.get("/health"));getTcpPort gives you a port by its preview URL, and its fetch sends a request there with the token, or proxies one your Worker received. Preview URLs, signed URLs and public are in Network and previews.
Open an SSH session
Section titled “Open an SSH session”const ssh = yield* sandbox.createSshAccess({ expiresInMinutes: 60 });Run a language server or code interpreter
Section titled “Run a language server or code interpreter”yield* sandbox.lsp.start({ languageId: "typescript", pathToProject: "/home/daytona/repo" });const ctx = yield* sandbox.interpreter.createInterpreterContext({ language: "python" });const run = yield* sandbox.interpreter.executeInterpreterCode({ contextId: ctx.id, code: "import pandas as pd\nprint(pd.__version__)", timeout: 30,});// { stdout: "2.2.3\n", stderr: "", error: undefined }A context keeps its variables between runs. An exception the code raises comes back in error; a run past its timeout fails with InterpreterTimeout. streamInterpreterCode streams the same output as it is produced.
Drive a desktop with computer use
Section titled “Drive a desktop with computer use”yield* sandbox.computerUse.startComputerUse();const shot = yield* sandbox.computerUse.takeScreenshot();Computer use needs a snapshot with a desktop. It is billed like any running sandbox.
Read a sandbox’s telemetry
Section titled “Read a sandbox’s telemetry”const logs = yield* sandbox.getSandboxLogs({ from, to });Point the whole organization’s telemetry at your own backend with OrganizationOtelConfig.