Skip to content

feat(serve): complete REST API server and add --url flag#384

Merged
DorianZheng merged 2 commits into
mainfrom
feat/serve-rest-api-complete
Mar 14, 2026
Merged

feat(serve): complete REST API server and add --url flag#384
DorianZheng merged 2 commits into
mainfrom
feat/serve-rest-api-complete

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

  • Refactor boxlite serve into a complete REST API server compatible with the Boxlite.rest() client
  • Add --url CLI flag (and BOXLITE_REST_URL env var) so all CLI commands can operate against a remote server
  • Fix pre-existing test_images_format test failure (empty image list returns [])

Server changes

  • Split monolithic serve.rs into module directory with 8 dedicated handler files
  • Fix route prefix from /v1/local/ to /v1/default/ (matching client expectation)
  • Add OAuth endpoint (POST /v1/oauth/tokens)
  • Add execution control endpoints (input, signal, resize, status)
  • Add file transfer, metrics, snapshot, clone/export/import endpoints
  • Fix config response format to return capabilities

CLI changes

  • Add --url global flag to connect to a remote boxlite serve instance
  • Enable rest feature on boxlite dependency
  • All 14 CLI commands automatically work against remote server

Test plan

  • cargo clippy -p boxlite-cli --tests -- -D warnings passes
  • cargo fmt -p boxlite-cli --check passes
  • All 137 tests pass (including fixed test_images_format)
  • Manual: boxlite serve --port 8100 + boxlite --url http://localhost:8100 list
  • Manual: python examples/python/08_rest_api/run_commands.py against boxlite serve

…onnections

Refactor `boxlite serve` from a partial implementation into a complete REST API
server compatible with the `Boxlite.rest()` client, and add `--url` CLI flag so
all commands can operate against a remote server.

Server changes:
- Split monolithic serve.rs into module directory with dedicated handlers
- Fix route prefix from /v1/local/ to /v1/default/ (matching client expectation)
- Add OAuth endpoint (POST /v1/oauth/tokens) for client authentication
- Add execution control endpoints (input, signal, resize, status)
- Add file transfer (PUT/GET tar-based upload/download)
- Add metrics endpoints (runtime and per-box)
- Add snapshot CRUD and restore endpoints
- Add clone, export, and import endpoints
- Fix config response format to return capabilities

CLI changes:
- Add --url flag (also reads BOXLITE_REST_URL env var) to GlobalFlags
- Enable rest feature on boxlite dependency
- When --url is set, create_runtime() returns REST-backed runtime
- All 14 CLI commands automatically work against remote server

Also fix REST API example to use default serve port (8100) and fix
test_images_format to handle empty image list (returns [] with no images).
@DorianZheng DorianZheng merged commit c8d5a0d into main Mar 14, 2026
17 checks passed
@DorianZheng DorianZheng deleted the feat/serve-rest-api-complete branch March 14, 2026 15:35
lilongen pushed a commit to lilongen/boxlite that referenced this pull request Jun 2, 2026
Make copy_in/copy_out over REST behave identically to the local backend
(docker-cp semantics), with the local backend as the reference.

- REST client (rest/litebox.rs): honor CopyOptions instead of dropping
  them — overwrite rides a PUT query param, include_parent/follow_symlinks
  a GET query param; pack/extract via boxlite_shared::tar (the bespoke
  create_tar_from_path is gone). Fail-fast on an empty path, mirroring the
  local backend's guard + ordering. Fixes F-010: box->host now extracts a
  single file to the exact path instead of unpacking the raw tar into a
  freshly-created directory.
- serve (serve/handlers/files.rs): faithful temp-dir bridge — stage_upload_tar
  + copy_into(include_parent:false) removes the historical 'extracted/' leak
  (boxlite-ai#384); download success response built infallibly via into_response().
- serve types: FileQuery carries optional overwrite/include_parent/
  follow_symlinks query params, defaulting to docker-cp defaults.
- CLI: --include-parent (presence-only, unsettable) -> --no-include-parent.
- lib.rs re-exports boxlite_shared::tar; serde_urlencoded dev-dep for the
  FileQuery parse test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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