Skip to content

Commit a2afd1b

Browse files
authored
feat(sandbox): add pi sandbox image (#77)
1 parent 0ceacfd commit a2afd1b

4 files changed

Lines changed: 251 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This repo is the community ecosystem around OpenShell -- a hub for contributed s
2626
| `sandboxes/gemini/` | Gemini CLI workflows |
2727
| `sandboxes/nvidia-gpu/` | GPU-enabled VM sandbox image with NVIDIA userspace tooling |
2828
| `sandboxes/ollama/` | Ollama for local and cloud LLMs with Claude Code, Codex, OpenCode pre-installed |
29+
| `sandboxes/pi/` | [Pi](https://pi.dev) pre-installed |
2930
| `sandboxes/sdg/` | Synthetic data generation workflows |
3031

3132
## Getting Started

sandboxes/pi/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# syntax=docker/dockerfile:1.4
2+
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Pi Coding Agent sandbox image for OpenShell
7+
#
8+
# Builds on the community base sandbox and adds pi.
9+
# Build: docker build -t openshell-pi --build-arg BASE_IMAGE=openshell-base .
10+
# Run: openshell sandbox create --from pi
11+
12+
ARG BASE_IMAGE=ghcr.io/nvidia/openshell-community/sandboxes/base:latest
13+
FROM ${BASE_IMAGE}
14+
15+
USER root
16+
17+
# Install pi
18+
RUN npm install -g @earendil-works/pi-coding-agent
19+
20+
# Copy sandbox policy
21+
COPY policy.yaml /etc/openshell/policy.yaml
22+
23+
USER sandbox
24+
25+
ENTRYPOINT ["/bin/bash"]

sandboxes/pi/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Pi Sandbox
2+
3+
OpenShell sandbox image pre-configured with [pi](https://github.com/earendil-works/pi) — a minimal terminal coding harness.
4+
5+
## What's Included
6+
7+
- **pi**
8+
- Everything from the [base sandbox](../base/README.md)
9+
10+
## Build
11+
12+
```bash
13+
docker build -t openshell-pi .
14+
```
15+
16+
To build against a specific base image:
17+
18+
```bash
19+
docker build -t openshell-pi --build-arg BASE_IMAGE=ghcr.io/nvidia/openshell-community/sandboxes/base:latest .
20+
```
21+
22+
## Usage
23+
24+
### Create a sandbox
25+
26+
```bash
27+
openshell sandbox create --from pi
28+
```
29+
30+
### Start pi directly
31+
32+
```bash
33+
openshell sandbox create --from pi -- pi
34+
```

sandboxes/pi/policy.yaml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
version: 1
5+
6+
# --- Sandbox setup configuration (queried once at startup) ---
7+
8+
filesystem_policy:
9+
include_workdir: true
10+
read_only:
11+
- /usr
12+
- /lib
13+
- /proc
14+
- /dev/urandom
15+
- /app
16+
- /etc
17+
- /var/log
18+
read_write:
19+
- /sandbox
20+
- /tmp
21+
- /dev/null
22+
23+
landlock:
24+
compatibility: best_effort
25+
26+
process:
27+
run_as_user: sandbox
28+
run_as_group: sandbox
29+
30+
# --- Network policies (queried per-CONNECT request) ---
31+
#
32+
# Each named policy maps a set of allowed (binary, endpoint) pairs.
33+
# Binary identity is resolved via /proc/net/tcp inode lookup + /proc/{pid}/exe.
34+
# Ancestors (/proc/{pid}/status PPid walk) and cmdline paths are also matched.
35+
# SHA256 integrity is enforced in Rust via trust-on-first-use, not here.
36+
37+
network_policies:
38+
pi:
39+
name: pi
40+
endpoints:
41+
# API-key providers
42+
- { host: api.anthropic.com, port: 443 }
43+
- { host: api.openai.com, port: 443 }
44+
- { host: api.deepseek.com, port: 443 }
45+
- { host: generativelanguage.googleapis.com, port: 443 }
46+
- { host: api.mistral.ai, port: 443 }
47+
- { host: api.groq.com, port: 443 }
48+
- { host: api.cerebras.ai, port: 443 }
49+
- { host: api.x.ai, port: 443 }
50+
- { host: openrouter.ai, port: 443 }
51+
- { host: ai-gateway.vercel.sh, port: 443 }
52+
- { host: router.huggingface.co, port: 443 }
53+
- { host: api.fireworks.ai, port: 443 }
54+
- { host: api.together.ai, port: 443 }
55+
- { host: api.kimi.com, port: 443 }
56+
- { host: api.moonshot.ai, port: 443 }
57+
- { host: api.moonshot.cn, port: 443 }
58+
- { host: api.minimax.io, port: 443 }
59+
- { host: api.minimaxi.com, port: 443 }
60+
- { host: api.xiaomimimo.com, port: 443 }
61+
- { host: token-plan-cn.xiaomimimo.com, port: 443 }
62+
- { host: token-plan-ams.xiaomimimo.com, port: 443 }
63+
- { host: token-plan-sgp.xiaomimimo.com, port: 443 }
64+
- { host: api.z.ai, port: 443 }
65+
- { host: opencode.ai, port: 443 }
66+
# Cloud providers
67+
- { host: bedrock-runtime.us-east-1.amazonaws.com, port: 443 }
68+
- { host: bedrock-runtime.eu-central-1.amazonaws.com, port: 443 }
69+
- { host: api.cloudflare.com, port: 443 }
70+
- { host: gateway.ai.cloudflare.com, port: 443 }
71+
# Add region-specific Vertex AI hosts here if needed, e.g.:
72+
# - { host: us-central1-aiplatform.googleapis.com, port: 443 }
73+
# Subscription login / token refresh endpoints
74+
- { host: claude.ai, port: 443 }
75+
- { host: platform.claude.com, port: 443 }
76+
- { host: auth.openai.com, port: 443 }
77+
- { host: chatgpt.com, port: 443 }
78+
- { host: github.com, port: 443 }
79+
- { host: api.github.com, port: 443 }
80+
# pi downloads managed fd/ripgrep binaries from GitHub release assets.
81+
- { host: release-assets.githubusercontent.com, port: 443 }
82+
- { host: api.githubcopilot.com, port: 443 }
83+
- { host: api.individual.githubcopilot.com, port: 443 }
84+
- { host: api.business.githubcopilot.com, port: 443 }
85+
- { host: api.enterprise.githubcopilot.com, port: 443 }
86+
- { host: copilot-proxy.githubusercontent.com, port: 443 }
87+
- { host: default.exp-tas.com, port: 443 }
88+
binaries:
89+
- { path: /usr/bin/pi }
90+
- { path: /usr/local/bin/pi }
91+
- { path: /usr/lib/node_modules/@earendil-works/pi-coding-agent/dist/cli.js }
92+
- { path: /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/dist/cli.js }
93+
- { path: /usr/bin/node }
94+
- { path: /usr/local/bin/node }
95+
96+
github_ssh_over_https:
97+
name: github-ssh-over-https
98+
endpoints:
99+
- host: github.com
100+
port: 443
101+
protocol: rest
102+
tls: terminate
103+
enforcement: enforce
104+
rules:
105+
# Git Smart HTTP read-only: allow clone, fetch, pull
106+
# Discovery (query string is included in path matching)
107+
- allow:
108+
method: GET
109+
path: "/**/info/refs*"
110+
# Data transfer for reads (all repos)
111+
- allow:
112+
method: POST
113+
path: "/**/git-upload-pack"
114+
# Data transfer for writes
115+
# - allow:
116+
# method: POST
117+
# path: "/**/git-receive-pack"
118+
binaries:
119+
- { path: /usr/bin/git }
120+
121+
nvidia_inference:
122+
name: nvidia-inference
123+
endpoints:
124+
- { host: integrate.api.nvidia.com, port: 443 }
125+
binaries:
126+
- { path: /usr/bin/curl }
127+
- { path: /bin/bash }
128+
129+
# --- GitHub REST API (read-only) ---
130+
github_rest_api:
131+
name: github-rest-api
132+
endpoints:
133+
- host: api.github.com
134+
port: 443
135+
protocol: rest
136+
tls: terminate
137+
enforcement: enforce
138+
access: read-only
139+
binaries:
140+
- { path: /usr/bin/gh }
141+
142+
pypi:
143+
name: pypi
144+
endpoints:
145+
- { host: pypi.org, port: 443 }
146+
- { host: files.pythonhosted.org, port: 443 }
147+
# uv python install downloads from python-build-standalone on GitHub
148+
- { host: github.com, port: 443 }
149+
- { host: objects.githubusercontent.com, port: 443 }
150+
# uv resolves python-build-standalone release metadata via the GitHub API
151+
- { host: api.github.com, port: 443 }
152+
- { host: downloads.python.org, port: 443 }
153+
binaries:
154+
- { path: /sandbox/.venv/bin/python }
155+
- { path: /sandbox/.venv/bin/python3 }
156+
- { path: /sandbox/.venv/bin/pip }
157+
- { path: /app/.venv/bin/python }
158+
- { path: /app/.venv/bin/python3 }
159+
- { path: /app/.venv/bin/pip }
160+
- { path: /usr/local/bin/uv }
161+
# Managed Python installations from uv python install
162+
- { path: "/sandbox/.uv/python/**" }
163+
164+
vscode:
165+
name: vscode
166+
endpoints:
167+
- { host: update.code.visualstudio.com, port: 443 }
168+
# NOTE: OPA host matching uses exact equality, not glob — list hosts explicitly.
169+
- { host: az764295.vo.msecnd.net, port: 443 }
170+
- { host: vscode.download.prss.microsoft.com, port: 443 }
171+
- { host: marketplace.visualstudio.com, port: 443 }
172+
- { host: gallerycdn.vsassets.io, port: 443 }
173+
binaries:
174+
- { path: /usr/bin/curl }
175+
- { path: /usr/bin/wget }
176+
- { path: "/sandbox/.vscode-server/**" }
177+
- { path: "/sandbox/.vscode-remote-containers/**" }
178+
179+
cursor:
180+
name: cursor
181+
endpoints:
182+
- { host: cursor.blob.core.windows.net, port: 443 }
183+
# NOTE: OPA host matching uses exact equality, not glob — list hosts explicitly.
184+
- { host: api2.cursor.sh, port: 443 }
185+
- { host: repo.cursor.sh, port: 443 }
186+
- { host: download.cursor.sh, port: 443 }
187+
- { host: cursor.download.prss.microsoft.com, port: 443 }
188+
binaries:
189+
- { path: /usr/bin/curl }
190+
- { path: /usr/bin/wget }
191+
- { path: "/sandbox/.cursor-server/**" }

0 commit comments

Comments
 (0)