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-openshellplugin installed (sandboxes/openshell). It is pinned to OpenShell 0.1.8.
Steps
-
Start a development gateway:
make openshell-upIt 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, withmake openshell-down. -
Select the plugin in the
Runtime, and point it at the gateway:sandbox:type: openshelloptions:gateway: 127.0.0.1:8080tlsDir: .openshell/home/.config/openshell/gateways/openshell/mtlsworkspace: defaultproviders:OPENROUTER_API_KEY: openroutergatewayis the only required key.tlsDirholdsca.crt,tls.crtandtls.key, as the CLI writes them; without it the channel is plaintext.tokenEnvnames the environment variable that holds a bearer token, never the token itself, and it needstlsDir. -
Map each environment name an agent uses to an OpenShell provider. In
options.providersthe 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'ssandbox.envwith no entry here makesopenfail with a clear error. -
Declare the network in the
Project, as on Docker:sandbox:image: afe-sandbox-acp:testegress: ["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. -
Run
afe validate. It checksoptionsagainst 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-prover0.1.8 does not verify TLS. The nightly run proves hosts, ports, paths and processes againstdeploy/openshell/boundary.yaml, and proves a copy of the policy without itstlsfield. - A placeholder replaced on an HTTPS request is proven only against a public echo service, under
the
livemarker. 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-upis 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.