@madarco/agentbox 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/chunk-IDR4HVIC.js +106 -0
- package/dist/chunk-IDR4HVIC.js.map +1 -0
- package/dist/chunk-J35IH7W5.js +200 -0
- package/dist/chunk-J35IH7W5.js.map +1 -0
- package/dist/chunk-O5HS3QHW.js +2164 -0
- package/dist/chunk-O5HS3QHW.js.map +1 -0
- package/dist/chunk-OOOKFFR5.js +496 -0
- package/dist/chunk-OOOKFFR5.js.map +1 -0
- package/dist/chunk-RWJE6AER.js +515 -0
- package/dist/chunk-RWJE6AER.js.map +1 -0
- package/dist/chunk-SOMIKEN2.js +1651 -0
- package/dist/chunk-SOMIKEN2.js.map +1 -0
- package/dist/create-LSSO7H4I-GWNALUMF.js +15 -0
- package/dist/create-LSSO7H4I-GWNALUMF.js.map +1 -0
- package/dist/index.js +4067 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle-P4FSKGR2-3466P54Y.js +38 -0
- package/dist/lifecycle-P4FSKGR2-3466P54Y.js.map +1 -0
- package/dist/state-ZSP3ORXW-WI6KOIG3.js +26 -0
- package/dist/state-ZSP3ORXW-WI6KOIG3.js.map +1 -0
- package/dist/stats-GZFLPYTU-DBJ2DVBJ.js +19 -0
- package/dist/stats-GZFLPYTU-DBJ2DVBJ.js.map +1 -0
- package/package.json +73 -0
- package/runtime/docker/Dockerfile.box +316 -0
- package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +188 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +12770 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +52 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +77 -0
- package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +54 -0
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +21 -0
- package/runtime/relay/bin.cjs +11467 -0
- package/share/agentbox-setup/SKILL.md +188 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentbox-setup
|
|
3
|
+
description: Generate an agentbox.yaml for the current AgentBox workspace. Invoke when the user opens a sandbox without an agentbox.yaml or asks to (re)configure one.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /agentbox-setup
|
|
7
|
+
|
|
8
|
+
Goal: produce a `/workspace/agentbox.yaml` that captures this project's services, tasks, and box defaults so the in-box supervisor (`agentbox-ctl`) can boot the workspace deterministically.
|
|
9
|
+
|
|
10
|
+
`agentbox.yaml` is **declarative**. The supervisor reads it on box start, but you don't have to restart the box: after you write the file, `agentbox-ctl reload` (run from inside the box) makes the already-running supervisor re-read it and immediately run the declared tasks and autostart the services. See step 8.
|
|
11
|
+
|
|
12
|
+
## 1. Discover the project
|
|
13
|
+
|
|
14
|
+
Look at `/workspace`:
|
|
15
|
+
|
|
16
|
+
- Top-level manifests: `package.json`, `pyproject.toml` / `requirements.txt`, `Cargo.toml`, `go.mod`, `Gemfile`, `composer.json`, `mix.exs`, etc. — these tell you the runtime.
|
|
17
|
+
- `docker-compose.yaml` / `docker-compose.yml` — often lists the real services the project expects.
|
|
18
|
+
- `package.json` → `scripts`: look for `dev`, `start`, `build`, `test`, `migrate`, `seed`.
|
|
19
|
+
- `Makefile` / `justfile` / `Taskfile.yaml` — alternative task runners.
|
|
20
|
+
- Listening ports: grep for `listen(`, `PORT=`, framework defaults (3000 for Next.js / Nuxt, 5173 for Vite, 8000 for Django, 8080 for Spring, etc.).
|
|
21
|
+
- Database / cache deps to spin up locally (Postgres, Redis, …) — declare them as services if the project doesn't expect them to be external.
|
|
22
|
+
|
|
23
|
+
## 2. Pick services and tasks
|
|
24
|
+
|
|
25
|
+
- **Services** = long-running. Web servers, watchers, queue workers, databases. `restart: on-failure` by default.
|
|
26
|
+
- **Tasks** = one-shot. `pnpm install`, DB migrations, codegen, fixture loaders. Wire dependent services with `needs:` so they wait for the task to finish successfully.
|
|
27
|
+
- Names: must match `[A-Za-z0-9_-]+`. Task names and service names share a namespace — no collisions.
|
|
28
|
+
- No cycles in `needs:`.
|
|
29
|
+
- **Always generate a dependency-install task** and make it the root of the `needs:` graph (every service that needs deps gets `needs: [install, …]`). The box runs on Linux; the host's `node_modules` (and `.next`, `target`, `.venv`) are macOS-native and now live in the box's writable upper layer, so they must be rebuilt **inside** the box. The task must be **idempotent and self-healing**: `agentbox-ctl` re-runs pending tasks on every box stop/start (the daemon dies with the container and is relaunched), so a plain `rm -rf node_modules && install` would wipe + reinstall on every start. Guard the rebuild with a marker file *inside* `node_modules` (the `.agentbox-installed` convention AgentBox uses internally): rebuild only when the marker is absent (fresh box, or a stale host-leaked `node_modules`), and be a fast no-op once it exists. Detect the package manager from the lockfile — never hardcode `pnpm`. See the worked example below.
|
|
30
|
+
|
|
31
|
+
## 3. Wire readiness probes (services only)
|
|
32
|
+
|
|
33
|
+
`ready_when:` lets the supervisor decide when a service is "ready" (vs. just "running"). Exactly one of these must be present:
|
|
34
|
+
|
|
35
|
+
- `port: 3000` — TCP connect (default host `127.0.0.1`; override with `host:`).
|
|
36
|
+
- `log_match: "Listening on"` — regex matched against stdout/stderr. First match flips the service to ready.
|
|
37
|
+
- `http: "http://127.0.0.1:3000/health"` — GET probe. Optional `expect_status: 200` (default: any 2xx).
|
|
38
|
+
|
|
39
|
+
Tunables: `interval_ms` (default 500), `initial_delay_ms` (default 0), `timeout_ms` (default 60000), `on_timeout: kill | mark_unhealthy` (default `kill` — re-enters the restart policy).
|
|
40
|
+
|
|
41
|
+
### Mark the web service with `expose:`
|
|
42
|
+
|
|
43
|
+
The box's primary web app (the dev server / Next.js / API the user opens in a browser) should declare:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
expose:
|
|
47
|
+
port: 3000 # the port this service listens on inside the box
|
|
48
|
+
as: 80 # must be 80 — the container port AgentBox publishes
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
At most **one** service may set `expose:`. AgentBox forwards container `:80` to `127.0.0.1:<port>` and publishes it on the host, so `agentbox list`/`status` show it as the box's main URL on every engine (no OrbStack dependency). Set this on the same service whose `ready_when:` you just wrote (a DB or worker should **not** get `expose:`).
|
|
52
|
+
|
|
53
|
+
## 4. Restart + backoff
|
|
54
|
+
|
|
55
|
+
Per service:
|
|
56
|
+
|
|
57
|
+
- `restart: always | on-failure | never` (default `on-failure`).
|
|
58
|
+
- `backoff:` — `initial_ms` (default 500), `max_ms` (default 30000; must be `>= initial_ms`), `factor` (default 2).
|
|
59
|
+
|
|
60
|
+
## 5. (Optional) `defaults:` block
|
|
61
|
+
|
|
62
|
+
Sets per-project defaults for `agentbox create`/`claude`/`code`/`shell` — same shape as `~/.agentbox/config.yaml`. CLI flags still override. Common keys:
|
|
63
|
+
|
|
64
|
+
- `box.hostSnapshot` (bool) — frozen APFS clone of the *host* workspace as overlay lower (renamed from `box.snapshot`).
|
|
65
|
+
- `box.defaultCheckpoint` (string) — checkpoint new boxes start from (normally you set this via `agentbox-ctl checkpoint --set-default` at the end of setup — see section 9, not by hand).
|
|
66
|
+
- `box.withPlaywright` (bool) — install `@playwright/cli` globally inside the box.
|
|
67
|
+
- `box.vnc` (bool) — run Xvnc + noVNC on container port 6080.
|
|
68
|
+
- `box.isolateClaudeConfig` (bool) — per-box `~/.claude` volume instead of the shared one.
|
|
69
|
+
- `code.ide` — `vscode | cursor | auto`.
|
|
70
|
+
- `code.autoTerminals` (bool) — auto-generate `.vscode/tasks.json` with per-service tails.
|
|
71
|
+
- `browser.default` — `agent-browser | playwright | both`.
|
|
72
|
+
|
|
73
|
+
Full key list (run on the host): `agentbox config list --keys`.
|
|
74
|
+
|
|
75
|
+
## 6. Worked example
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
# yaml-language-server: $schema=https://agentbox.dev/schema/agentbox.schema.json
|
|
79
|
+
defaults:
|
|
80
|
+
box:
|
|
81
|
+
withPlaywright: true
|
|
82
|
+
code:
|
|
83
|
+
ide: cursor
|
|
84
|
+
|
|
85
|
+
tasks:
|
|
86
|
+
# Idempotent install. node_modules lives in the box's writable upper layer
|
|
87
|
+
# (per-box, isolated, captured by `agentbox open --upper`). The host's
|
|
88
|
+
# node_modules is macOS-native, so force a clean Linux build the first time
|
|
89
|
+
# and self-heal a stale one — but skip on every subsequent box start
|
|
90
|
+
# (agentbox-ctl re-runs pending tasks after stop/start). Adjust the
|
|
91
|
+
# lockfile detection to the project's package manager.
|
|
92
|
+
install:
|
|
93
|
+
command: |
|
|
94
|
+
set -e
|
|
95
|
+
MARKER=node_modules/.agentbox-installed
|
|
96
|
+
[ -f "$MARKER" ] && { echo "deps installed (marker present) — skip"; exit 0; }
|
|
97
|
+
rm -rf node_modules
|
|
98
|
+
if [ -f pnpm-lock.yaml ]; then
|
|
99
|
+
corepack enable >/dev/null 2>&1 || true
|
|
100
|
+
pnpm install --frozen-lockfile || pnpm install
|
|
101
|
+
elif [ -f yarn.lock ]; then
|
|
102
|
+
corepack enable >/dev/null 2>&1 || true
|
|
103
|
+
yarn install --frozen-lockfile || yarn install
|
|
104
|
+
elif [ -f bun.lockb ] || [ -f bun.lock ]; then
|
|
105
|
+
bun install
|
|
106
|
+
elif [ -f package-lock.json ]; then
|
|
107
|
+
npm ci || npm install
|
|
108
|
+
else
|
|
109
|
+
npm install
|
|
110
|
+
fi
|
|
111
|
+
touch "$MARKER"
|
|
112
|
+
|
|
113
|
+
migrate:
|
|
114
|
+
command: pnpm db:migrate
|
|
115
|
+
needs: [install]
|
|
116
|
+
|
|
117
|
+
services:
|
|
118
|
+
postgres:
|
|
119
|
+
command: postgres -D /var/lib/postgresql/data
|
|
120
|
+
ready_when:
|
|
121
|
+
port: 5432
|
|
122
|
+
restart: always
|
|
123
|
+
|
|
124
|
+
dev:
|
|
125
|
+
command: pnpm dev
|
|
126
|
+
needs: [install, migrate, postgres]
|
|
127
|
+
ready_when:
|
|
128
|
+
port: 3000
|
|
129
|
+
timeout_ms: 120000
|
|
130
|
+
expose:
|
|
131
|
+
port: 3000
|
|
132
|
+
as: 80
|
|
133
|
+
restart: on-failure
|
|
134
|
+
backoff:
|
|
135
|
+
initial_ms: 500
|
|
136
|
+
max_ms: 5000
|
|
137
|
+
factor: 2
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 7. Validate before handing off
|
|
141
|
+
|
|
142
|
+
- check with `agentbox-ctl reload` and then `agentbox-ctl status` that everything is running as expected.
|
|
143
|
+
- Every name in `needs:` must reference an existing task or service.
|
|
144
|
+
- A service with `restart: never` and an autostart dependency will block the dependent forever after one failed run — usually a mistake.
|
|
145
|
+
- `command:` is either a shell string (run via `bash -c`) or an argv array. Use the argv form if you need to avoid shell quoting.
|
|
146
|
+
|
|
147
|
+
## 8. Hand-off
|
|
148
|
+
|
|
149
|
+
1. Write the file to `/workspace/agentbox.yaml`.
|
|
150
|
+
2. **Apply it live**: from inside the box run `agentbox-ctl reload`. The already-running supervisor re-reads the config and immediately runs the declared tasks and autostarts the services — no box restart needed. It prints the `added` / `removed` / `changed` diff. If it errors because the daemon isn't running, the config is still valid: the next `agentbox start` (or `agentbox create` in this workspace) picks it up automatically.
|
|
151
|
+
3. Confirm with `agentbox-ctl status`: tasks should be `running` or `done`, autostart services `starting` or `ready`. If something failed, tail it with `agentbox-ctl logs <service>` and fix the config, then `agentbox-ctl reload` again.
|
|
152
|
+
4. Tell the user:
|
|
153
|
+
|
|
154
|
+
> I wrote `/workspace/agentbox.yaml` and ran `agentbox-ctl reload` so the supervisor is already running the declared tasks/services. To land the file on the host:
|
|
155
|
+
> - commit it inside the box (`git add agentbox.yaml && git commit -m 'add agentbox config'`) — the box's `.git/` is bind-mounted, so the commit shows up on the host immediately; or
|
|
156
|
+
> - on the host, tell the user to run `agentbox pull config` to update their original host workspace. `agentbox pull env` if you also create env files.
|
|
157
|
+
|
|
158
|
+
5. **Then do section 9** — once the box is warmed up (deps installed, services ready), checkpoint it so future boxes start ready. This is the real final step; don't stop at hand-off.
|
|
159
|
+
|
|
160
|
+
## 9. Checkpoint the warm state (do this at the very end)
|
|
161
|
+
|
|
162
|
+
Once `agentbox-ctl status` shows the install task `done` and services `ready` — i.e. the box is fully warmed up — capture a **checkpoint** so future boxes in this project start from this exact state instead of cold.
|
|
163
|
+
|
|
164
|
+
A checkpoint snapshots the box's writable layer, which includes everything you just did:
|
|
165
|
+
|
|
166
|
+
- `node_modules` (and `.next`, `target`, `.venv`, build caches) — the expensive Linux-native install,
|
|
167
|
+
- `.env` / `.env.*` / `secrets.toml` and any other gitignored config files present in `/workspace`,
|
|
168
|
+
- any other files written during setup.
|
|
169
|
+
|
|
170
|
+
A new box created from the checkpoint reuses all of it (the install task's marker is already present, so it no-ops), while git-tracked code still comes fresh from the host's current HEAD. Result: new boxes are ready in seconds with no reinstall and no missing env vars.
|
|
171
|
+
|
|
172
|
+
**Run this from inside the box, as the final step:**
|
|
173
|
+
|
|
174
|
+
```sh
|
|
175
|
+
agentbox-ctl checkpoint --set-default
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
This routes through the host relay (no host shell needed), captures `<box-name>-<n>`, and writes `box.defaultCheckpoint` into the project's config so **every future `agentbox create` / `claude` in this project starts warm automatically**. Pass `--name <name>` for a stable name, or omit `--set-default` to capture without changing the default. Re-run it whenever the warm state meaningfully changes (e.g. after a dependency bump you want every new box to inherit).
|
|
179
|
+
|
|
180
|
+
Then tell the user, e.g.:
|
|
181
|
+
|
|
182
|
+
> I checkpointed the warm box state (node_modules, env files, build caches) and set it as this project's default — `agentbox create` will now spin up new boxes from it in seconds, no reinstall.
|
|
183
|
+
|
|
184
|
+
## 10. Known issues
|
|
185
|
+
|
|
186
|
+
- For Nextjs/Vite/Tasnstack projects, makes sure to forward also websocket for hot reload.
|
|
187
|
+
- **Turbo/Nx/Jest and other git-worktree-aware tools may try to write their cache to a read-only host path.** The box runs `/workspace` as a git worktree with the host repo's `.git/` bind-mounted at its absolute host path; tools that derive paths from git (Turbo's cache root = the worktree's git *common dir*) resolve outside `/workspace` and hit `EROFS` on the Mac path. Pin the cache into the writable overlay via the task/service `env:`, e.g. `TURBO_CACHE_DIR: /workspace/.turbo/cache` (or pass `--cache-dir`).
|
|
188
|
+
- The `install` task is intentionally a no-op once `node_modules/.agentbox-installed` exists. Do **not** remove the marker guard to "force a fresh install" — that reinstalls on every box start. To force a one-off rebuild, delete `node_modules` (or just the marker) then run `agentbox-ctl reload`.
|