Skip to content

feat(cli): stop a running VM with bxc sandbox stop (0.11.0) - #25

Merged
farhan-helmy merged 1 commit into
mainfrom
feat/sandbox-stop
Oct 17, 2026
Merged

farhan-helmy merged 1 commit into
mainfrom
feat/sandbox-stop

Conversation

@farhan-helmy

@farhan-helmy farhan-helmy commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Why

Until now the API could start a VM but not stop one, so a running VM billed until its 30-minute idle stop. Server PR boxcompute/web-agent#341 adds POST /api/v2/sandboxes/{id}/stop; this exposes it in the CLI.

What

  • bxc sandbox stop SANDBOX_ID (also --json). It stops compute billing now and keeps the VM's disk and files.
    • It prints either Stopped sandbox …; its files are kept. Start it again with 'bxc sandbox resume …'. or Sandbox … was not running (cold); nothing to stop.. With --json it prints { sandbox, stopped }.
    • 409 means the VM is still starting, stopping or in use; the CLI says to run it again in a moment.
    • 400 (not a VM) and other API errors are shown with their message and code, like sibling commands.
    • A server without the route gets "does not support stopping a sandbox yet". A transport failure says to check status, then retry.
    • Safety checks match sandbox resume: HTTPS or loopback origin only, valid sandbox ID, redirects refused, a 60 s timeout, and response reading capped at 64 KiB. Stop is idempotent and never wakes compute, so server errors are shown rather than masked.
    • @boxcompute/sdk 0.4.0 has no stop method yet, so src/stop.ts calls the endpoint directly, as src/resume.ts does for start.
  • Docs: help, README, docs/vm-sandbox-beta.md and the bundled boxcompute-sandbox skill now document stop and the idle rule. A VM stops by itself 30 minutes after its last resume, exec, file transfer or preview; status, logs, analytics, costs and processes inside the VM don't count. Several places said an idle VM "keeps billing until you delete it", which hasn't been true.
  • Version 0.11.0 with a CHANGELOG entry. Not yet on npm; validate-release-change.mjs passes.

Needs the server first

This requires web-agent 0.62.0 live (#341). Per the release rule, merge or publish only after that server release is deployed. Against an older server, the command reports that stop isn't supported.

Tests

Run on the worker with Bun 1.3.14 (the CI pin) on Node 22:

  • bun run typecheck passes.
  • bun run lint: 0 warnings, 0 errors.
  • bun test: 75 pass, 0 fail across 12 files, including the new test/stop.test.ts. It covers the request shape, origin and ID refusals, 409/400 formatting, the unsupported-server message, transport failure, malformed or oversized responses, text and JSON output, and unknown options.
  • bun run build passes, and node dist/cli.js prints 0.11.0 and the new help.

Not run: test:native (Go helpers are unchanged), npm pack --dry-run, and the Node 20/24 matrix, all of which CI runs. No live call was made against a real VM.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

`bxc sandbox stop SANDBOX_ID` calls POST /api/v2/sandboxes/{id}/stop
(server 0.62.0+): it stops compute billing now and keeps the VM's disk and
files, reports whether it was running, never wakes a stopped VM and is safe
to repeat. HTTP 409 tells the user to retry in a moment.

Help, README, the VM guide and the bundled skill also stop claiming an idle
VM bills until deleted: a VM stops 30 minutes after its last resume, exec,
file transfer or preview, and reads, logs and in-VM work do not count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@farhan-helmy
farhan-helmy merged commit 1dcb46b into main Oct 17, 2026
4 checks passed
@farhan-helmy
farhan-helmy deleted the feat/sandbox-stop branch October 17, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant