The bash your agent runs commands in
Models already know the shell. Give yours one bash tool backed by a Lifo box and it can list files, edit them, install packages and run code. If your agent is in JavaScript, Lifo is an import in your API route and nothing else.
A real box, booted in this page. The script types a few commands, then the terminal is yours: try ls, node, npm or a pipe.
One tool is enough.
A box is a full shell line away: pipes, redirects, && and $(...) work, and every command returns stdout, stderr and an exit code.
import { Sandbox } from '@lifo-sh/core'
const box = await Sandbox.create()
// The one tool the model gets
async function bash(command) {
const { stdout, stderr, exitCode } =
await box.commands.run(command, { timeout: 30_000 })
return { stdout, stderr, exitCode }
}
// Your own tools become shell commands
box.commands.register('deploy', async (ctx) => { /* ... */ })The same code runs on both sides. In a browser the box lives in the visitor's tab, so an agent product has no sandbox fleet to run. In Node.js it lives in your process, in a script, a test or a server.
A box is cheap enough to throw away. It boots in about 27 ms in a tab and about 0.5 ms in Node.js, so you can make one per task, per request or per test and drop it afterwards.
If your agent is JavaScript, you need nothing else.
There is no sandbox service to call and no container to keep warm. Lifo is an import, so the box is created inside the API route that runs your agent.
// app/api/bash/route.ts
import { Sandbox } from '@lifo-sh/core'
export const runtime = 'nodejs'
export async function POST(req: Request) {
const { command } = await req.json()
const box = await Sandbox.create()
const { stdout, stderr, exitCode } =
await box.commands.run(command, { timeout: 30_000 })
return Response.json({ stdout, stderr, exitCode })
}Node.js API routes, today. A Next.js route handler, an Express handler or a serverless function on the Node.js runtime creates a box per request and throws it away with the response.
Edge API routes are coming. Edge runtimes do not allow code to be evaluated at run time, which is how a box runs node programs, so a route with the edge runtime does not work yet.
Or skip the server. The same import runs in the browser, so the box can live in the user's tab while only the model call goes through your API.
What the agent gets.
- 01
A real working directory
A POSIX-like filesystem with 60+ commands: ls, cat, grep, sed, find, curl, tar and the rest. Files persist to IndexedDB when you ask.
- 02
npm and Node.js
npm install pulls real packages. node runs scripts, tests and servers through a Node.js compatibility layer, and Python runs on WebAssembly.
- 03
A box that moves
Snapshot a box to a tar.gz and restore it in another tab, in Node.js or in Lifo Cloud, with its files, environment and working directory.
Know before you build
A box is not a security boundary. Code it runs shares the JavaScript engine with the page or process that created it, so it suits code the user asked for or would run anyway. In a browser, run the box in a Web Worker or on a separate origin to keep it off your page. For code you do not trust on a server, put it in a container or a VM. Security and isolation
The shell is bash-like, not bash: everyday syntax works, while arrays, [[ ]] and trap do not yet. Shell and commands
Other things the same box does.
$ npm install && npm run dev
➜ Local: http://localhost:5173/
Dev environments
Vite, Expo and Express run unmodified with npm install, dev servers and hot reload, next to Postgres, Supabase, Python and git.
$ npm i -g @anthropic-ai/claude-code@2.1.112
$ claude
> add a /health route
⏺ Bash(ls src)
⏺ Update(src/server.js)
Claude Code in the browserComing
Anthropic's Claude Code runs in a box: its terminal UI, its Bash tool and its file edits, with nothing installed on the machine.
$ browser open news.ycombinator.com
✓ Hacker News
$ browser state
[1] new [2] past
$ browser click 1
Browser-use agents
Firefox, compiled to WebAssembly, runs next to the box. An agent opens pages, reads them and clicks, all inside the tab.
$ desktop snap firefox left
$ desktop windows --json
Desktop and computer usePreview
Lifo Desktop is a full desktop in a tab. Its windows and apps are scriptable through one API and a desktop command.