feat(box): add box runtime package and lbp box CLI command#44
Open
huanghuoguoguo wants to merge 34 commits into
Open
feat(box): add box runtime package and lbp box CLI command#44huanghuoguoguo wants to merge 34 commits into
lbp box CLI command#44huanghuoguoguo wants to merge 34 commits into
Conversation
033f09e to
4bdc2c4
Compare
Move sandbox box runtime code from LangBot core into the plugin SDK as `langbot_plugin.box` package. Add `lbp box` CLI command to start the box runtime standalone, similar to `lbp rt` for the plugin runtime. New package includes: actions, backend (Docker/Podman), client, errors, models, runtime, security, server, and `__main__` entry point
- add mount_path to box specs and session metadata - mount host paths at spec.mount_path instead of hard-coded /workspace - default workdir/cwd from mount_path when omitted - update runtime/backend logging and nsjail tests for custom mount paths
Accept Windows-style absolute paths (e.g. C:\Users\...) in host_path validation, and make security path comparison case-insensitive and separator-aware on Windows. Only the Docker backend is supported on Windows (via Docker Desktop); Podman and nsjail remain Linux-only.
Replace the two-port scheme (5410 relay + 5411 RPC) with a single aiohttp
server on port 5410, using path-based routing:
/rpc/ws — Action RPC (control channel)
/v1/sessions/{id}/managed-process/ws — Managed process stdio relay
Add AiohttpWSConnection adapter to bridge aiohttp WebSocketResponse to
the SDK Connection interface, keeping Handler/BoxServerHandler unchanged.
…ners Add BoxMountSpec model and extra_mounts field to BoxSpec, allowing multiple bind mounts per container. Docker and nsjail backends iterate extra_mounts to append additional -v / --rw_bind flags at session creation time. Backward compatible — existing single-mount usage is unchanged.
…and multi-process - Add persistent flag to BoxSpec/BoxSessionInfo to keep sessions across shutdowns - Change managed_process to managed_processes dict (keyed by process_id) - Support multiple managed processes per session for shared containers - Skip persistent sessions during shutdown and TTL reaping - Conditionally add --rm flag only for non-persistent containers - Add process_id to RPC handlers and WebSocket relay routes - Update nsjail backend to pass persistent field
- Add E2BSandboxBackend for E2B cloud and self-hosted CubeSandbox - Add e2b>=2.15 as core dependency - Add INIT action for configuration passing via WebSocket - Runtime creates all backends at init; each backend determines availability via is_available() - Configuration applied to backends by name (config[backend.name] -> backend.configure()) - Support BOX_BACKEND env var for explicit backend override
- E2B backend: rename config key 'default_template' -> 'template'; rename
internal attribute _default_template -> _template.
- Runtime backend selection: honor top-level box.backend config field,
with BOX_BACKEND env var still taking precedence. 'local' fans out to
docker -> nsjail; specific names ('docker'/'nsjail'/'e2b') match exactly.
Box previously had three launch paths while the plugin runtime had one.
Align box with the runtime so both are launched exclusively via the lbp
CLI subcommand:
- Delete box/__main__.py (removes `python -m langbot_plugin.box`).
- Remove the `if __name__ == "__main__"` guard from box/server.py
(removes `python -m langbot_plugin.box.server`).
- server.main() now takes the parsed argparse.Namespace, mirroring how
`lbp rt` drives langbot_plugin.runtime.app.main; the box subparser in
langbot_plugin.cli is the single source of the argument schema.
- Drop the legacy hidden `--mode {auto,stdio,ws}` flag and the hidden
`--port` alias of `--ws-control-port`. Mode is selected solely by
`-s`/`--stdio-control` (WebSocket by default), identical to `lbp rt`.
The box CLI surface is now --host, -s/--stdio-control, --ws-control-port.
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.
关联查看 langbot-app/LangBot#2072