@beamcloud/beam-js 1.1.0 or later. Configure the SDK before running them.
Execute commands
exec options before the VM name. Everything after the name is the remote command. -- makes the boundary explicit. Arguments are literal; use sh -c or bash -lc for shell variables, pipes, and redirection.
Foreground execution streams stdout and stderr and returns the command’s exit status. --timeout sets a command deadline in seconds; 0, the default, waits indefinitely. This deadline is separate from the VM’s idle TTL.
Processes from the SDK
- Python
- JavaScript
process.exec() returns a handle immediately. Supply text, bytes, or a binary file as stdin; SDK input is uploaded before execution and followed by EOF. Use SSH for an interactive terminal.
For live logs:
- Python
- JavaScript
process.wait(timeout=30) bounds how long the caller waits; it does not itself kill the command. Use process.kill() to cancel it. See process management for run_code, environment overrides, process handles, and async behavior. The same process API is available through vm.process and vm.aio.process.
Detached commands and logs
--container-id prevents killing a reused PID after the VM has restarted. Managed process handles belong to the current runtime; use a systemd unit for a service that must start again after a cold boot.
Use only one log selector at a time: --pid, --unit, or --session. Without a selector, logs reads the systemd journal. Detached work does not maintain an idle lease after the CLI exits; disable the TTL for unattended jobs.
SSH and browser terminal
ssh, ssh-keygen, and scp) to use these commands.
The browser terminal uses port 7681, protected by default on new VMs. terminal opens an authenticated browser session; --url prints its entry URL. See networking for public opt-outs and protecting existing VMs.
Copy and sync files
NAME:/path argument. Quote paths with spaces. Sync uploads the local directory’s contents to /workspace/, excludes .git, and can watch for local changes. Install rsync locally to use sync; it is installed in the prepared VM image. Sync is an upload operation, not bidirectional synchronization, and does not delete remote files absent locally.
JavaScript SSH, SCP and sync
vm.fs provides uploads and downloads through the SDK without local SSH tools.
Systemd services
Create a systemd unit to start a web server on every cold boot:- Python
- JavaScript
Coding agents
Prepared VM images include Claude Code and Codex CLIs. Configure the selected agent’s authentication or provider credentials inside the VM;beam vm prompt does not supply an agent subscription or API key.
prompt-... session ID and starts a systemd transient unit. Read its durable output with:
/workspace/.beam-vm/logs/. Those files survive stop/start; an agent launched as a transient unit does not automatically rerun after a cold boot.
JavaScript prompts and logs
vm.prompt() returns a managed process for foreground execution, or { session, unit } for a background systemd unit. vm.logs() accepts one of pid, unit, or session. vm.getProcess(pid, { containerId }) guards against PID reuse after a reboot.
Metrics
vm.metrics() samples guest CPU, memory, and root-disk usage over one second. It counts as activity and can wake a VM with automatic resume enabled. Use the dashboard Usage page for historical costs.