Commit e98cbb0
authored
feat: add projectSetupLayer config and sandbox build command (#110)
## Summary
- Add `projectSetupLayer` config option: a bash script baked into a
cached image layer between base and agent overlay, so projects can cache
expensive system-level setup (apt packages, language runtimes, etc.)
- Add `ox sandbox build` command for explicitly building sandbox layers
with `--no-cache` support
- Add `--project` flag to `ox sandbox hash` for inspecting setup layer
hashes
## Image Stack
```
base → projectSetupLayer (optional) → agent overlay → session
```
The setup script runs as root (Docker: `docker exec --user root`, Cloud:
`sudo`), and its content is hashed with the base image hash for cache
invalidation. When either the base image or the script changes, the
layer rebuilds automatically.
## New Commands
```bash
# Build all layers through agent
ox sandbox build --agent claude
# Build just through project setup layer
ox sandbox build --project
# Force rebuild everything
ox sandbox build --agent claude --no-cache
# Inspect hashes
ox sandbox hash --project
ox sandbox hash --project --cloud
```
## Key Changes
- **Config**: New `projectSetupLayer` string field in `OxConfig`
- **Docker**: `ensureProjectSetupLayer()` builds via run/exec/commit
pattern, streams output to terminal
- **Cloud**: `ensureProjectSetupCloudSnapshot()` builds via
volume/sandbox/snapshot pattern
- **Resource cleanup**: Classifies `oxl-`/`oxlb-` prefixed cloud
resources and `ox-sandbox:md5-*-l-*` Docker images
- **CLI**: `sandbox build` with `--agent`, `--project`, `--cloud`,
`--no-cache` flags; `sandbox hash --project`
- **Force rebuild**: `force` parameter threaded through all ensure
functions and `SandboxProvider.ensureImage()`
## Files Changed
| File | Changes |
|------|---------|
| `src/services/config.ts` | Add `projectSetupLayer` field |
| `src/services/docker.ts` | Hash/tag computation,
`ensureProjectSetupLayer`, `force` param, GHCR pull skip for setup
layers |
| `src/services/sandbox/cloudSnapshot.ts` | Cloud snapshot build,
`force` param, setup hash in agent slugs |
| `src/services/sandbox/cloudProvider.ts` | Chain setup layer into
`ensureImage()` |
| `src/services/sandbox/resources.ts` | Classify setup layer resources
in cleanup |
| `src/services/sandbox/sandboxExec.ts` | Add `stream` option for
real-time output |
| `src/services/sandbox/types.ts` | Add `force` to
`SandboxProvider.ensureImage()` |
| `src/services/sandbox/dockerProvider.ts` | Thread `force` through |
| `src/commands/sandbox.ts` | `build` subcommand, `--project` flag on
`hash`, flag validation |
| Tests | New tests for hash, slug, and resource classification |1 parent cdabdcd commit e98cbb0
File tree
26 files changed
+1920
-155
lines changed- docs
- src
- commands
- components
- services
- sandbox
- stores
26 files changed
+1920
-155
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
144 | 159 | | |
145 | 160 | | |
146 | 161 | | |
| |||
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
156 | 176 | | |
157 | 177 | | |
158 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
17 | 38 | | |
18 | 39 | | |
19 | 40 | | |
| |||
66 | 87 | | |
67 | 88 | | |
68 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
69 | 99 | | |
70 | 100 | | |
71 | 101 | | |
| |||
0 commit comments