Skip to content

feat(cli): add boxlite serve — REST API server#357

Merged
DorianZheng merged 2 commits intoboxlite-ai:mainfrom
yan5xu:feat/serve
Mar 11, 2026
Merged

feat(cli): add boxlite serve — REST API server#357
DorianZheng merged 2 commits intoboxlite-ai:mainfrom
yan5xu:feat/serve

Conversation

@yan5xu
Copy link
Copy Markdown
Contributor

@yan5xu yan5xu commented Mar 9, 2026

Summary

  • Add boxlite serve command — a long-running REST API server that holds a single BoxliteRuntime
  • Solves runtime lock contention when multiple callers need concurrent box access (e.g. Pinix Server executing nested clip-to-clip calls)
  • 9 MVP endpoints following the existing OpenAPI spec, including SSE streaming for exec output
  • Exec supports stdin field for piping input to commands

Motivation

When Pinix Server forks boxlite exec CLI for each ClipService.Invoke, each process creates its own BoxliteRuntime and acquires ~/.boxlite/.lock. Nested calls (clip A invoking clip B through the same server) cause deadlock. boxlite serve eliminates this by holding a single runtime instance.

Test plan

  • cargo build -p boxlite-cli
  • cargo clippy -p boxlite-cli -- -D warnings
  • Manual test: boxlite serve --port 8100 + curl endpoints
  • End-to-end: Pinix Server with --boxlite-rest flag, clip-to-clip nested calls verified

Generated with Claude Code

yan5xu and others added 2 commits March 11, 2026 22:56
Holds a single BoxliteRuntime and exposes box lifecycle + exec operations
over HTTP. Solves runtime lock contention when multiple callers need
concurrent access (e.g. Pinix Server executing nested clip-to-clip calls).

Endpoints (9, MVP):
- GET  /v1/config
- POST /v1/local/boxes (create)
- GET  /v1/local/boxes (list)
- GET  /v1/local/boxes/{id} (info)
- POST /v1/local/boxes/{id}/start
- POST /v1/local/boxes/{id}/stop
- POST /v1/local/boxes/{id}/exec (returns execution_id, supports stdin)
- GET  /v1/local/boxes/{id}/executions/{eid}/output (SSE stream)
- DELETE /v1/local/boxes/{id}

SSE exec protocol:
  event: stdout, data: {"data":"<base64>"}
  event: stderr, data: {"data":"<base64>"}
  event: exit, data: {"exit_code":0,"duration_ms":1234}

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@DorianZheng DorianZheng merged commit ef71b04 into boxlite-ai:main Mar 11, 2026
18 checks passed
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.

2 participants