Skip to content

Add GroundboxProvider and openenv groundbox login - #1800

Open
Ktryberceo wants to merge 2 commits into
openenv:mainfrom
Ktryberceo:groundbox-provider
Open

Ktryberceo wants to merge 2 commits into
openenv:mainfrom
Ktryberceo:groundbox-provider

Conversation

@Ktryberceo

@Ktryberceo Ktryberceo commented Dec 4, 2026 •

Copy link
Copy Markdown

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 adds openenv 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.

from openenv.core.containers.runtime.groundbox_provider import GroundboxProvider
from openenv.core.generic_client import GenericEnvClient

provider = GroundboxProvider(image="registry.hf.space/openenv-echo-env:latest")
with GenericEnvClient(provider=provider).sync() as env:
    env.reset()

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • New environment
  • Refactoring

What it does

  • Provider (src/openenv/core/containers/runtime/groundbox_provider.py, extra openenv[groundbox], which pulls the standard-library-only groundbox SDK). It follows DaytonaProvider: 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's openenv.yaml or cmd=; it starts with nohup and a PID file, so wait_for_ready reports a crashed server with its log instead of waiting out the timeout. It supports the provider-owned flow (EnvClient(provider=...)).
  • Reaching the port. The server's port gets an HTTPS preview URL (https://<slug>-8000.groundbox.page), and EnvClient connects over wss://. 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, which EnvClient cannot carry because it appends /ws to base_url, so this is the same model as Modal's tunnel URLs.
  • Cleanup. stop_container() deletes the sandbox, and timeout_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.
  • Errors. A create refused for the account's concurrency limit (429) is retried until 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.
  • Sign-in (openenv groundbox login). OAuth 2.1 with PKCE (S256) through OpenEnv's public OAuth client on Groundbox (no secret), with a loopback redirect to 127.0.0.1 on a free port. GROUNDBOX_OAUTH_CLIENT_ID overrides the client; set empty, each sign-in registers its own client through dynamic client registration. It asks for sandboxes:read sandboxes:write only, 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=, then GROUNDBOX_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 / hf

openenv groundbox login is a sign-in for a third-party provider, not Hub behavior, so nothing on the Hub side changes. It mirrors hf auth login where it can: one command, the credential kept in the provider's own config location (as hf keeps its token in ~/.cache/huggingface/token), and an environment variable (GROUNDBOX_API_KEY, like HF_TOKEN) taking precedence.

Alignment Checklist

  • I have read .claude/docs/PRINCIPLES.md and this PR aligns with our principles
  • I have checked .claude/docs/INVARIANTS.md and no invariants are violated
  • I have run bash .claude/hooks/lint.sh and the tests, and addressed all issues

RFC Status

  • Not required (a new provider behind the existing ContainerProvider contract, an optional extra, no core API change)
  • RFC exists: #___
  • RFC needed (will create before merge)

Test Plan

  • Unit tests with a fake SDK: 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).
  • Full suite as in CI and bash .claude/hooks/lint.sh: pass.
  • Live, against real Groundbox:
    • examples/groundbox_echo_env.py: sandbox from registry.hf.space/openenv-echo-env:latest, reset(), step(CallToolAction("echo_message")) returned Hello, World!, sandbox deleted.
    • GenericEnvClient(provider=GroundboxProvider(...)) over WebSocket: reset and step work, env_vars reach 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

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

No deployments
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