Repository navigation
Add GroundboxProvider and openenv groundbox login - #1800
Open
Ktryberceo wants to merge 2 commits into
Open
Ktryberceo wants to merge 2 commits into
Ktryberceo wants to merge 2 commits into
Conversation
GroundboxProvider runs an environment server in a Groundbox sandbox from a Docker image or a Groundbox template, discovers the server command from openenv.yaml, and exposes its port as an HTTPS preview URL. openenv groundbox login signs in through Groundbox's OAuth (PKCE, dynamic client registration, loopback redirect) and saves the API key where the Groundbox CLI keeps it.
openenv groundbox login now signs in with OpenEnv's registered public client. GROUNDBOX_OAUTH_CLIENT_ID overrides it; set empty, each login registers a client through dynamic client registration as before.
This branch has not been deployed
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.
Summary
Adds
GroundboxProvider, a runtime provider that runs an environment server in a Groundbox sandbox (a Linux microVM per environment), next to Daytona, Modal and Novita. It also addsopenenv groundbox login, a browser sign-in that saves an API key, so a new user goes from nothing to a running environment without copying a key by hand.Type of Change
What it does
src/openenv/core/containers/runtime/groundbox_provider.py, extraopenenv[groundbox], which pulls the standard-library-onlygroundboxSDK). It followsDaytonaProvider: the SDK is imported lazily; the sandbox starts from a Docker image (for example an environment's Space image) or a Groundbox template; the server command comes from the image'sopenenv.yamlorcmd=; it starts withnohupand a PID file, sowait_for_readyreports a crashed server with its log instead of waiting out the timeout. It supports the provider-owned flow (EnvClient(provider=...)).https://<slug>-8000.groundbox.page), andEnvClientconnects overwss://. The preview is public, with an unguessable host name, and ends with the sandbox. Groundbox's private previews take their token as a query parameter, whichEnvClientcannot carry because it appends/wstobase_url, so this is the same model as Modal's tunnel URLs.stop_container()deletes the sandbox, andtimeout_minutes(default 60) deletes it even if the process dies first. A sandbox that fails to start (for example an image pull error) is deleted and its error raised.create_timeout. Free-trial refusals (credit used up, sandbox too large or too long-lived for free credit) raise a message that says what to change.openenv groundbox login). OAuth 2.1 with PKCE (S256) through OpenEnv's public OAuth client on Groundbox (no secret), with a loopback redirect to127.0.0.1on a free port.GROUNDBOX_OAUTH_CLIENT_IDoverrides the client; set empty, each sign-in registers its own client through dynamic client registration. It asks forsandboxes:read sandboxes:writeonly, and opens on sign-up for new accounts. The key is saved with mode 0600 in~/.config/groundbox/credentials.json, the file the Groundbox CLI uses, so either tool's sign-in works for both. Key order in the provider:api_key=, thenGROUNDBOX_API_KEY, then that file.If you would rather review the sign-in on its own, I can split it into a second PR.
Comparison with
huggingface_hub/hfopenenv groundbox loginis a sign-in for a third-party provider, not Hub behavior, so nothing on the Hub side changes. It mirrorshf auth loginwhere it can: one command, the credential kept in the provider's own config location (ashfkeeps its token in~/.cache/huggingface/token), and an environment variable (GROUNDBOX_API_KEY, likeHF_TOKEN) taking precedence.Alignment Checklist
.claude/docs/PRINCIPLES.mdand this PR aligns with our principles.claude/docs/INVARIANTS.mdand no invariants are violatedbash .claude/hooks/lint.shand the tests, and addressed all issuesRFC Status
ContainerProvidercontract, an optional extra, no core API change)Test Plan
PYTHONPATH=src:envs uv run pytest tests/test_core/test_groundbox_provider.py tests/test_cli/test_groundbox_login.py -v(27 tests: key lookup order, image and template starts, server discovery, failed sandboxes cleaned up, 429 retry, trial refusals, crash detection, and the full OAuth round trip with a simulated browser, including PKCE verification, the client-id override and the registration fallback, a denied sign-in and a forged state).bash .claude/hooks/lint.sh: pass.examples/groundbox_echo_env.py: sandbox fromregistry.hf.space/openenv-echo-env:latest,reset(),step(CallToolAction("echo_message"))returnedHello, World!, sandbox deleted.GenericEnvClient(provider=GroundboxProvider(...))over WebSocket: reset and step work,env_varsreach the server process, closing the client deletes the sandbox.openenv groundbox login --no-browser: the authorize URL with OpenEnv's client redirects (302) to Groundbox's consent page, and with nobody signing in it times out without saving anything.Claude Code Review
N/A