Repository navigation
feat(cli): stop a running VM with bxc sandbox stop (0.11.0) - #25
Merged
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Stopped sandbox …; its files are kept. Start it again with 'bxc sandbox resume …'.orSandbox … was not running (cold); nothing to stop.. With--jsonit prints{ sandbox, stopped }.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/sdk0.4.0 has no stop method yet, sosrc/stop.tscalls the endpoint directly, assrc/resume.tsdoes for start.docs/vm-sandbox-beta.mdand the bundledboxcompute-sandboxskill 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.validate-release-change.mjspasses.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 typecheckpasses.bun run lint: 0 warnings, 0 errors.bun test: 75 pass, 0 fail across 12 files, including the newtest/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 buildpasses, andnode dist/cli.jsprints 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
Need help on this PR? Tag
@codesmith-botwith what you need.