Skip to main content

OpenShell sandbox

Goal: run a project's commands in an OpenShell gateway, with the network and the credentials the project declares.

Prerequisites​

  • Docker, reachable from the machine that runs the worker.
  • The afe-openshell plugin installed (sandboxes/openshell). It is pinned to OpenShell 0.1.8.

Steps​

  1. Start a development gateway:

    make openshell-up

    It starts the 0.1.8 gateway, pinned by image digest, with TLS on. The CLI and the supervisor are downloaded and checked against a SHA-256 kept in the repository. The certificates are generated under .openshell/, never committed. Stop it, and remove everything it created, with make openshell-down.

  2. Select the plugin in the Runtime, and point it at the gateway:

    sandbox:
    type: openshell
    options:
    gateway: 127.0.0.1:8080
    tlsDir: .openshell/home/.config/openshell/gateways/openshell/mtls
    workspace: default
    providers:
    OPENROUTER_API_KEY: openrouter

    gateway is the only required key. tlsDir holds ca.crt, tls.crt and tls.key, as the CLI writes them; without it the channel is plaintext. tokenEnv names the environment variable that holds a bearer token, never the token itself, and it needs tlsDir.

  3. Map each environment name an agent uses to an OpenShell provider. In options.providers the key is the variable name and the value is the provider's name. Create the provider in the gateway first. A name in the project's sandbox.env with no entry here makes open fail with a clear error.

  4. Declare the network in the Project, as on Docker:

    sandbox:
    image: afe-sandbox-acp:test
    egress: ["pypi.org"]

    A provider's endpoint is the rule that admits its host. Do not repeat that host in egress: the gateway refuses the create as ambiguous.

  5. Run afe validate. It checks options against the plugin's schema: an unknown key or a wrong type is an error with its path.

What the policy allows​

afe generates the policy for each sandbox. It is never read from the image.

  • No egress: no network rule at all, so no host is reachable.
  • With egress: one rule for the listed hosts, on port 443 only, for every program in the sandbox. Any other host or port is refused.
  • Files: the sandbox's own paths and /workspace.

The workspace​

The ticket's volume is mounted at /workspace, the path every backend uses. A paused ticket keeps its sandbox, as on Docker. The volume is removed with the ticket.

A sandbox survives a restart of the gateway: it stays ready and the next open reuses it. A sandbox the restart leaves in error, or removes, is recreated by the engine.

Known limits​

  • The openshell-prover 0.1.8 does not verify TLS. The nightly run proves hosts, ports, paths and processes against deploy/openshell/boundary.yaml, and proves a copy of the policy without its tls field.
  • A placeholder replaced on an HTTPS request is proven only against a public echo service, under the live marker. The 0.1.8 proxy never reaches a loopback or private address, so a local upstream proves nothing.
  • The sandbox images have no CA bundle, so HTTPS from the sandbox fails certificate checks.
  • make openshell-up is a development gateway, not a deployment target.

Troubleshooting​

open fails with an environment name that has no provider The name is in sandbox.env and not in options.providers. Add it, or remove it from the project.

The plugin refuses tokenEnv A bearer token over a plaintext channel would travel in the clear. Set tlsDir too.

The sandbox never becomes ready on the bridge network Set OPENSHELL_NETWORK_MODE=bridge and OPENSHELL_HOST_GATEWAY_IP before make openshell-up, so the supervisor reaches the gateway. The default is the host network.

See also​