Self-hosted Linux boxes for agents, like instabox but on your own server
npx @tomasko/serbox create --name dev
npx @tomasko/serbox exec dev -- 'apt-get update && apt-get install -y ripgrep'
npx @tomasko/serbox ssh dev
npx @tomasko/serbox rm dev --yesnpm install -g @tomasko/serbox # or: npx @tomasko/serbox ...# install script
curl -LsSf https://raw.githubusercontent.com/tomasky/serbox/main/install.sh | bash
# from source (MoonBit)
moon build --target native --release
./_build/native/release/build/cmd/main/main.exe versionserbox create --name dev --template node # pull image, start container
serbox exec dev -- 'node --version' # one command, exit code preserved
serbox ssh dev # interactive shell
serbox push dev ./src /data/src # copy in
serbox pull dev /data/out.log ./out.log # copy out
serbox suspend dev # pause (frees CPU, keeps disk)
serbox resume dev # unpause
serbox snapshot save dev --name ready # commit the box to an image
serbox create --name dev2 --snapshot ready # start another box from it
serbox port publish dev 3000 --host 3000 # expose a port on this server
serbox rm dev --yesserbox serve --ensure # start on 127.0.0.1:7373, prints the token
serbox serve --print-token # show the token later# uses ssh: checks/installs serbox on the server, starts the daemon,
# opens a local tunnel and stores a per-host token
serbox host add prod me@prod.example.com
serbox host use prod # make it the default
serbox create --name dev --template node
serbox exec dev -- 'node --version'
serbox ssh dev # ssh -t through the server
serbox host use local # back to this machineserbox host add prod --address 127.0.0.1:7373 --token TOKEN| command | what it does |
|---|---|
| create --name N [--template T] [--env K=V] [--publish P] [--setup-file F] | start a box |
| ls, get N | list / inspect boxes |
| exec N -- CMD | run a command (--timeout, --stream, --background, --json) |
| ssh N | interactive shell |
| push, pull, cp, files N PATH | move files, list or cat them |
| suspend / resume, start / stop, restart | lifecycle |
| snapshot save/ls/rm/restore/import, fork N | images and copies |
| port publish/unpublish/ls | forward a box port to this server |
| secrets set/ls/rm/select/push | keep credentials out of command lines |
| auto-suspend N 30m, max-run N 2h, gc | idle cleanup |
| run -- CMD | create, run, delete in one step (--keep to keep) |
| jobs ls/logs/wait/kill | background commands started by exec --background |
| ps, history, output, disk, metrics, logs | look inside |
| templates, usage, doctor, completion, update | host and shell help |
| skills list/install | install the bundled agent skills |
| serve, host add/ls/use/current/rm | run and use boxes on other servers |
serbox exec dev -- 'echo $HOME && ls /data' # shell
serbox exec dev -- printf '%s\n' 'a b' # argvserbox skills list # what ships in the binary
serbox skills install -y # every skill, every agent it finds
serbox skills install --target claude,codex
serbox skills install --only serbox-snapshots -y| Skill | Covers |
|---|---|
| serbox | create, exec, files, jobs, ports, pause, remote hosts |
| serbox-snapshots | save, restore, fork, import and delete snapshots |
| serbox-move-repo | copy a git checkout, its worktrees and uncommitted work into a box, then install dependencies |
| serbox-basic-setup | store tokens as secrets, copy git and editor config, verify what still needs a manual step |
serbox secrets set GITHUB_TOKEN # reads the value from stdin
serbox create --name dev --secrets GITHUB_TOKEN
serbox exec dev -- 'gh auth status' # value is in the environmentboxes/ one JSON file per box
snapshots/ snapshot metadata
jobs/ background job metadata
history/ per-box command history
ports/ published port records
secrets.json credentials (0600)| serbox | instabox | |
|---|---|---|
| where boxes run | the server you run it on | instabox's cloud |
| account | none | sign in / API key |
| isolation | Docker on your kernel | microVM |
| snapshots | docker commit images | VM snapshots |
| port URLs | your server's host and port | public URLs |
| offline | yes (after images are pulled) | no |
moon test --target native # unit tests (no docker needed)
moon build --target native --release
node --test npmjs/ # npm launcher tests
scripts/build-linux-static.sh # static musl binary in dist/SERBOX_HOME=$(mktemp -d) scripts/test-e2e.sh ./_build/native/release/build/cmd/main/main.exe# bump the version in moon.mod, serbox.mbt and npmjs/package.json
git tag v0.1.1 && git push origin v0.1.1cd npmjs && npm publish --access publicpub suberror CliError {
Usage(String)
Failed(Int, String)
}pub(all) struct BoxConfig {
name : String
template : String
image : String
shell : String
created_at : Int64
env : Map[String, String]
meta : Map[String, String]
ports : Array[PortMap]
secrets : Array[String]
auto_suspend_secs : Int64
max_run_secs : Int64
paused_by : String
last_used_at : Int64
running_since : Int64
delete_at : Int64
setup_exit : Int
} derive(Debug, FromJson, ToJson)pub struct DockerResult {
code : Int
out : String
err : String
}pub struct SkillFile {
skill : String
path : String
body : String
}async fn allocate_host_port(preferred : Int) -> Intfn ascii_lowercase(text : String) -> Stringlet box_data_root : Stringasync fn box_path_exists(box : String, path : String) -> Boolasync fn box_path_is_dir(box : String, path : String) -> Boolasync fn cmd_version() -> Unitfn colors_enabled() -> Boolfn compact_time(epoch : Int64) -> Stringasync fn confirm(question : String) -> Boolasync fn container_exists(box : String) -> Boolasync fn container_ip(box : String) -> String?async fn container_logs(box : String, tail : Int, follow : Bool) -> Intlet container_prefix : Stringasync fn container_state(box : String) -> Stringfn copies_contents(path : String) -> Boolasync fn current_host() -> Stringlet default_template : Stringfn display_state(container_state : String, paused_by : String) -> Stringasync fn ensure_image(image : String) -> Boolfn error_code_name(code : Int) -> Stringasync fn exec_in_box_capture_argv(box : String, argv : Array[String], cwd : String?, env : Map[String, String], stdin : Bool) -> DockerResultfn format_age(seconds : Int64) -> Stringfn format_duration(secs : Int64) -> Stringfn format_size(bytes : Int64) -> Stringfn generate_box_name(prefix : String) -> Stringfn hex_decode(text : String) -> Bytes?fn hex_encode(data : Bytes) -> Stringfn host_name() -> Stringasync fn host_path_is_dir(path : String) -> Boolasync fn job_exit_code(box : String, job_id : String) -> Int?async fn local_port_open(port : Int) -> Boolfn pad_right(text : String, width : Int) -> Stringfn parse_assignment(text : String, flag : String) -> (String, String) raisefn parse_duration(text : String, default_unit_secs? : Int64) -> Int64?fn path_basename(path : String) -> Stringfn path_dirname(path : String) -> Stringfn path_join(left : String, right : String) -> Stringasync fn print_command_help(command : String) -> Unitasync fn print_usage() -> Unitasync fn publish_port(config : BoxConfig, container_port : Int, host_port : Int, bind : String) -> PortForwardasync fn pull_image(image : String) -> Boolasync fn pull_path(box : String, remote : String, host_path : String?) -> Unitasync fn push_path(box : String, host_path : String, remote : String?, parents : Bool) -> Unitasync fn read_text(path : String) -> String?async fn run_forwarder(box : String, host_port : Int, container_port : Int, bind : String) -> Unitasync fn self_exe() -> Stringfn serbox_echo(on : Int) -> Unitfn serbox_exit(status : Int) -> Unitlet serbox_version : Stringasync fn serve_loop(bind : String, port : Int) -> Unitasync fn serve_token(create : Bool) -> Stringfn shell_quote(arg : String) -> Stringfn skill_description(name : String) -> Stringfn snapshot_image(snapshot : String) -> Stringlet snapshot_image_prefix : Stringfn split_assignment(text : String) -> (String, String)?fn stdout_is_tty() -> Boolfn template_image(template : String) -> String?fn trim_trailing_slash(path : String) -> Stringfn truncate_utf8(text : String, limit : Int) -> Stringasync fn unpublish_box_ports(box : String) -> Unitasync fn unpublish_port(box : String, container_port : Int) -> Unitfn user_home() -> Stringfn valid_box_name(name : String) -> Boolfn valid_env_key(key : String) -> Boolfn valid_secret_name(name : String) -> Boolfn valid_snapshot_name(name : String) -> Boolasync fn write_secret(path : String, text : String) -> UnitInstall
Download zipSelf-hosted Linux boxes for agents, like instabox but on your own server