@madarco/agentbox 0.23.4 → 0.24.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/CHANGELOG.md +79 -0
- package/LICENSE +21 -0
- package/README.md +3 -2
- package/dist/{_cloud-attach-BQRWX3J2.js → _cloud-attach-T6GPR6LJ.js} +5 -5
- package/dist/{chunk-GGRZ3GZO.js → chunk-5KHEH47T.js} +91 -79
- package/dist/chunk-5KHEH47T.js.map +1 -0
- package/dist/{chunk-I6ZRWTPR.js → chunk-6U2S6QWD.js} +219 -18
- package/dist/chunk-6U2S6QWD.js.map +1 -0
- package/dist/{chunk-LK2JT2OO.js → chunk-DEDTPG2D.js} +880 -146
- package/dist/chunk-DEDTPG2D.js.map +1 -0
- package/dist/chunk-G3H2L3O2.js +0 -0
- package/dist/{chunk-LA4JMS27.js → chunk-I654PBHA.js} +290 -330
- package/dist/chunk-I654PBHA.js.map +1 -0
- package/dist/{chunk-W3FQPFP7.js → chunk-K2EDQGZP.js} +18 -4
- package/dist/chunk-K2EDQGZP.js.map +1 -0
- package/dist/{chunk-LSQXT5WZ.js → chunk-LC4E2EIZ.js} +3 -3
- package/dist/{chunk-LSQXT5WZ.js.map → chunk-LC4E2EIZ.js.map} +1 -1
- package/dist/{chunk-SFA57TGX.js → chunk-NACA6AM7.js} +183 -49
- package/dist/chunk-NACA6AM7.js.map +1 -0
- package/dist/{chunk-QEQFZLYR.js → chunk-RYQLFKCP.js} +20 -10
- package/dist/chunk-RYQLFKCP.js.map +1 -0
- package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
- package/dist/chunk-UIRBYL4G.js.map +1 -0
- package/dist/chunk-WJFZJZIM.js +0 -0
- package/dist/chunk-WLHJZPFJ.js +845 -0
- package/dist/chunk-WLHJZPFJ.js.map +1 -0
- package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
- package/dist/dist-3KIJ2KQ2.js +1437 -0
- package/dist/dist-3KIJ2KQ2.js.map +1 -0
- package/dist/{dist-V235KVEX.js → dist-7OUOHQPA.js} +196 -151
- package/dist/dist-7OUOHQPA.js.map +1 -0
- package/dist/{dist-Z2NEVV55.js → dist-B7TNWGVG.js} +8 -4
- package/dist/{dist-CUKBKS3N.js → dist-KYV3LEHG.js} +10 -6
- package/dist/{dist-FXQFTT75.js → dist-PHYCFYKH.js} +37 -17
- package/dist/dist-PHYCFYKH.js.map +1 -0
- package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
- package/dist/{dist-QO4CTLAX.js → dist-Z7KEPQC7.js} +6 -6
- package/dist/index.js +2560 -1108
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-BUO75YLZ-CDTISC2C.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
- package/package.json +28 -28
- package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
- package/runtime/_shared/agentbox-codex-hooks.json +1 -1
- package/runtime/_shared/agentbox-dockerd-start +0 -0
- package/runtime/_shared/agentbox-open +0 -0
- package/runtime/_shared/agentbox-portless-trust +0 -0
- package/runtime/_shared/agentbox-vnc-start +0 -0
- package/runtime/_shared/ctl.cjs +468 -97
- package/runtime/_shared/gh-shim +0 -0
- package/runtime/_shared/git-shim +53 -3
- package/runtime/_shared/linear-shim +0 -0
- package/runtime/_shared/ntn-shim +0 -0
- package/runtime/daytona/custom-system-CLAUDE.md +1 -1
- package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
- package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
- package/runtime/digitalocean/agentbox-dockerd-start +145 -0
- package/runtime/digitalocean/agentbox-open +28 -0
- package/runtime/digitalocean/agentbox-portless-trust +82 -0
- package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
- package/runtime/digitalocean/agentbox-vnc-start +102 -0
- package/runtime/digitalocean/claude-managed-settings.json +116 -0
- package/runtime/digitalocean/ctl.cjs +27852 -0
- package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
- package/runtime/digitalocean/gh-shim +344 -0
- package/runtime/digitalocean/git-shim +181 -0
- package/runtime/digitalocean/linear-shim +181 -0
- package/runtime/digitalocean/ntn-shim +95 -0
- package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
- package/runtime/digitalocean/scripts/install-box.sh +462 -0
- package/runtime/docker/Dockerfile.box +5 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
- package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
- package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
- package/runtime/e2b/agentbox-codex-hooks.json +1 -1
- package/runtime/e2b/agentbox-dockerd-start +0 -0
- package/runtime/e2b/agentbox-open +0 -0
- package/runtime/e2b/agentbox-vnc-start +0 -0
- package/runtime/e2b/ctl.cjs +468 -97
- package/runtime/e2b/custom-system-CLAUDE.md +6 -3
- package/runtime/e2b/gh-shim +0 -0
- package/runtime/e2b/git-shim +53 -3
- package/runtime/e2b/linear-shim +0 -0
- package/runtime/e2b/ntn-shim +0 -0
- package/runtime/e2b/scripts/build-template.sh +16 -0
- package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
- package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
- package/runtime/hetzner/agentbox-dockerd-start +0 -0
- package/runtime/hetzner/agentbox-open +0 -0
- package/runtime/hetzner/agentbox-portless-trust +0 -0
- package/runtime/hetzner/agentbox-vnc-start +0 -0
- package/runtime/hetzner/ctl.cjs +468 -97
- package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
- package/runtime/hetzner/gh-shim +0 -0
- package/runtime/hetzner/git-shim +53 -3
- package/runtime/hetzner/linear-shim +0 -0
- package/runtime/hetzner/ntn-shim +0 -0
- package/runtime/hetzner/scripts/install-box.sh +5 -0
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/1c5w3kqosumog.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/1o3ot_9-8jgzc.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3uq9hf-roasav.js +1 -0
- package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-H22XP3NY.js → chunk-3VE7AYVK.js} +600 -145
- package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
- package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-2Z74R6ZT.js → chunk-FGBXEXUV.js} +351 -292
- package/runtime/hub/apps/hub/{chunk-AR7CEZ2G.js → chunk-YVELHPNY.js} +218 -17
- package/runtime/hub/apps/hub/{dist-LZNRLUYY.js → dist-33ZNVTC6.js} +183 -49
- package/runtime/hub/apps/hub/{dist-Q6G66Z57.js → dist-4SXAJBOC.js} +195 -150
- package/runtime/hub/apps/hub/{dist-SD4G36EP.js → dist-EPJFN2J3.js} +116 -86
- package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
- package/runtime/hub/apps/hub/{dist-LNHEG5P4.js → dist-UJVIROA4.js} +19 -5
- package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
- package/runtime/hub/apps/hub/{dist-VV6Z2CQX.js → dist-YM5J25H6.js} +7 -3
- package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
- package/runtime/hub/apps/hub/package.json +1 -0
- package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-CAXQS5Y3.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
- package/runtime/hub/apps/hub/server.js +38 -19
- package/runtime/relay/bin.cjs +275 -59
- package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
- package/runtime/vercel/agentbox-codex-hooks.json +1 -1
- package/runtime/vercel/agentbox-dockerd-start +0 -0
- package/runtime/vercel/agentbox-open +0 -0
- package/runtime/vercel/agentbox-vnc-start +0 -0
- package/runtime/vercel/ctl.cjs +468 -97
- package/runtime/vercel/custom-system-CLAUDE.md +3 -2
- package/runtime/vercel/gh-shim +0 -0
- package/runtime/vercel/git-shim +53 -3
- package/runtime/vercel/linear-shim +0 -0
- package/runtime/vercel/ntn-shim +0 -0
- package/runtime/vercel/scripts/provision.sh +16 -0
- package/dist/chunk-GGRZ3GZO.js.map +0 -1
- package/dist/chunk-I6ZRWTPR.js.map +0 -1
- package/dist/chunk-LA4JMS27.js.map +0 -1
- package/dist/chunk-LK2JT2OO.js.map +0 -1
- package/dist/chunk-QEQFZLYR.js.map +0 -1
- package/dist/chunk-QT3SHMLY.js.map +0 -1
- package/dist/chunk-SFA57TGX.js.map +0 -1
- package/dist/chunk-W3FQPFP7.js.map +0 -1
- package/dist/dist-FXQFTT75.js.map +0 -1
- package/dist/dist-V235KVEX.js.map +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/20hq7-0depjid.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/3p86ecqhr_7yy.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/3qof5hg87qf5n.js +0 -1
- /package/dist/{_cloud-attach-BQRWX3J2.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
- /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
- /package/dist/{dist-CUKBKS3N.js.map → dist-KYV3LEHG.js.map} +0 -0
- /package/dist/{dist-QO4CTLAX.js.map → dist-T5MXBZGP.js.map} +0 -0
- /package/dist/{dist-Z2NEVV55.js.map → dist-Z7KEPQC7.js.map} +0 -0
- /package/dist/{prepared-state-BUO75YLZ-CDTISC2C.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,317 @@
|
|
|
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
|
+
## Box layout (what you're configuring against)
|
|
9
|
+
|
|
10
|
+
Your user i `vscode` and you can use `sudo` to run commands as root.
|
|
11
|
+
|
|
12
|
+
`/workspace` is where the user code lives, a per-box git worktree on a fresh `agentbox/<box-name>` branch (or a tar-piped copy of the host workspace for non-git projects).
|
|
13
|
+
Run `agentbox checkpoint --set-default` (similar to `docker commit`) to save any changes make to the system and workspace so that new boxes will start from a warm state. Everything is wiped on `agentbox destroy`.
|
|
14
|
+
|
|
15
|
+
Some special folders:
|
|
16
|
+
|
|
17
|
+
- **Host main repo's `.git/`** — If the box bind-mounted RW at its identical absolute host path. In-box commits land on the host's branch refs (visible to `git log` on the host immediately); the box itself carries no SSH/git creds, so `git push` goes through the host relay (`agentbox-ctl git push`). The host's **working tree is never written to** — only refs/objects under `.git/`. GitHub PR ops (`agentbox-ctl git pr create|view|list|comment|review|merge|close|reopen|checkout`) flow the same way through host `gh`; write ops require host confirmation (deny → exit 10), `merge` and `checkout` have additional opt-in guards.
|
|
18
|
+
- **`~/.claude`** — and similar home folders for coding agents are seeded from the host's `~/.claude` on each create so auth, skills, and plugins persist without leaking the host's home dir.
|
|
19
|
+
- **`agentbox.yaml`** — read by `agentbox-ctl` from `/workspace`. Tasks and services declared here are what the supervisor will run.
|
|
20
|
+
|
|
21
|
+
Exposed ports and services:
|
|
22
|
+
- **portless** - every port with `expose:` setting in agentbox.yaml, will be exposed not only as a local port but also as a special domain name `https://<name>.localhost` (so on https) using `portless` cli and proxy. This will be also mapped to the host where also `portless` proxy is running so users can access the same service on the same looking url.
|
|
23
|
+
- **vnc** - the webVNC server exposed on 6080 will be proxies to the host on a random port.
|
|
24
|
+
- **vscode** - the vscode server is proxied to the host on a random port.
|
|
25
|
+
|
|
26
|
+
## Goal
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
`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.
|
|
31
|
+
|
|
32
|
+
## 1. Discover the project
|
|
33
|
+
|
|
34
|
+
Look at `/workspace`:
|
|
35
|
+
|
|
36
|
+
- Top-level manifests: `package.json`, `pyproject.toml` / `requirements.txt`, `Cargo.toml`, `go.mod`, `Gemfile`, `composer.json`, `mix.exs`, etc. — these tell you the runtime.
|
|
37
|
+
- `docker-compose.yaml` / `docker-compose.yml` — often lists the real services the project expects.
|
|
38
|
+
- `package.json` → `scripts`: look for `dev`, `start`, `build`, `test`, `migrate`, `seed`.
|
|
39
|
+
- `Makefile` / `justfile` / `Taskfile.yaml` — alternative task runners.
|
|
40
|
+
- Listening ports: grep for `listen(`, `PORT=`, framework defaults (3000 for Next.js / Nuxt, 5173 for Vite, 8000 for Django, 8080 for Spring, etc.).
|
|
41
|
+
- Database / cache deps to spin up locally (Postgres, Redis, …) — declare them as services if the project doesn't expect them to be external.
|
|
42
|
+
|
|
43
|
+
## 2. Pick services and tasks
|
|
44
|
+
|
|
45
|
+
- **Services** = long-running. Web servers, watchers, queue workers, databases. `restart: on-failure` by default.
|
|
46
|
+
- **Tasks** = one-shot. `pnpm install`, DB migrations, codegen, fixture loaders, install apt packages. Wire dependent services with `needs:` so they wait for the task to finish successfully.
|
|
47
|
+
- Names: must match `[A-Za-z0-9_-]+`. Task names and service names share a namespace — no collisions.
|
|
48
|
+
- No cycles in `needs:`.
|
|
49
|
+
- **Always generate a dependency-install task** and make it the root of the `needs:` graph (every service that needs deps gets `needs: [install, …]`). Future boxes start from a snapshot of the final filesystem so they won't need this, but updates or moving to a cloud provider might need to rebuild the container from scratch. The filesystem can be then later captured by `agentbox-ctl checkpoint --set-default`. The task must be **idempotent**: `agentbox-ctl` re-runs pending tasks on every box stop/start (the daemon dies with the container and is relaunched), so an unguarded install would reinstall on every start. The clean way is the **`run_once: true`** field — the supervisor stores a marker keyed by a hash of the command and skips warm boots automatically (the marker lives at `/var/lib/agentbox/tasks/<name>`, on the box rootfs, captured by checkpoints, never polluting `/workspace`). Editing the command re-runs it. Detect the package manager from the lockfile — never hardcode `pnpm`. See the worked example below.
|
|
50
|
+
- **Add a comment to the beginning** of the file to explain what you did and what issues you encountered, so that future run might use this information in case the project evolves and you need to update the agentbox.yaml file.
|
|
51
|
+
|
|
52
|
+
### Stateful services: data persistence & re-seeding (read this for databases)
|
|
53
|
+
|
|
54
|
+
**Declare a containerized dependency with the `image:` service form** — AgentBox
|
|
55
|
+
generates the `docker start`-or-`run` shell (no hand-written `docker run … || docker
|
|
56
|
+
start …`). The container runs in the box's dockerd; a published port is reachable
|
|
57
|
+
from other in-box services at `127.0.0.1:<host port>`:
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
services:
|
|
61
|
+
postgres:
|
|
62
|
+
image: # bare string (image: postgres:17-alpine) or a mapping:
|
|
63
|
+
name: postgres:17-alpine
|
|
64
|
+
ports: ["5432:5432"]
|
|
65
|
+
env:
|
|
66
|
+
POSTGRES_PASSWORD: postgres
|
|
67
|
+
POSTGRES_DB: app
|
|
68
|
+
args: "-c max_connections=200" # string or ["-c","max_connections=200"]
|
|
69
|
+
container_name: app_db # optional; default = service name
|
|
70
|
+
ready_when: { port: 5432 }
|
|
71
|
+
restart: always
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The container is reused by name across box stop/start. (Changing `image`/`env`
|
|
75
|
+
reuses the existing container as-is; `docker rm <container_name>` + `agentbox-ctl
|
|
76
|
+
reload` to apply.) Install the DB client the migrate/seed tasks need (e.g.
|
|
77
|
+
`postgresql-client`) in the `install` task and reach the DB over TCP — don't
|
|
78
|
+
`docker exec` the container (nested exec fails with a `setns` error in a box).
|
|
79
|
+
|
|
80
|
+
**A checkpoint does NOT capture docker-in-docker data.** `agentbox checkpoint` is a `docker commit` of the box's writable filesystem (the system + `/workspace`). The in-box `dockerd` keeps its storage in a *separate* per-box volume (`/var/lib/docker`), which is **not** part of that image — it's fresh on every new box and wiped on `agentbox destroy`. So a database or cache you run as a **docker container** (e.g. `docker run … postgres`) starts **empty on every new box** created from a checkpoint (every `agentbox claude` / `agentbox create`), even though `/workspace` and any marker files you wrote were restored. (A DB run as a **native process** with its data dir on the box filesystem — e.g. `postgres -D /var/lib/postgresql/data` — *is* captured by the checkpoint, since it lives in the writable layer.)
|
|
81
|
+
|
|
82
|
+
**Consequence for migrate/seed tasks of a containerized DB: do NOT use `run_once: true` (the marker form).** A command-hash marker is correct for deps (they live in `/workspace`, which the checkpoint captures), but **wrong** for DB data living in a docker volume: the marker is restored from the checkpoint while the DB is empty, so a marker-guarded seed wrongly skips and the app boots against an empty database. Instead use the **`run_once: { check: <cmd> }`** form — the probe runs first and the seed runs unless the probe exits 0, and **no marker is written** (the DB is the source of truth). Gate on the actual data:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
seed:
|
|
86
|
+
# Re-seed when the DB is empty. The postgres data lives in the in-box docker
|
|
87
|
+
# volume, which is NOT captured by `agentbox checkpoint` — so a box started
|
|
88
|
+
# from a checkpoint has the workspace warm but an empty DB. The marker form
|
|
89
|
+
# would be restored while the DB is blank and wrongly skip; the `check` probe
|
|
90
|
+
# gates on the data itself. Exit 0 = already seeded, skip. Fast no-op once
|
|
91
|
+
# the data is present.
|
|
92
|
+
command: pnpm db:seed
|
|
93
|
+
needs: [install, migrate]
|
|
94
|
+
run_once:
|
|
95
|
+
check: |
|
|
96
|
+
export PGPASSWORD=postgres
|
|
97
|
+
psql -h 127.0.0.1 -p 5432 -U postgres -d app -tAc \
|
|
98
|
+
"SELECT EXISTS (SELECT 1 FROM users LIMIT 1)" 2>/dev/null | grep -q t
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Lifecycle nuance (this is why the data check, not a marker, is right):**
|
|
102
|
+
|
|
103
|
+
- **Box stop → start** (`agentbox stop`/`start`): the supervisor daemon dies with the container and is relaunched, so it **re-runs all tasks** from `pending`. The per-box docker volume *does* survive stop/start, so the DB still has data — the data check makes the seed a fast no-op.
|
|
104
|
+
- **New box from a checkpoint** (`agentbox claude`/`create`): tasks run and the DB volume is empty → the check fails → the seed runs. Correct.
|
|
105
|
+
- **Resume after pause** (`agentbox pause`/`unpause`): the daemon is frozen and thawed, **not** restarted, so tasks do **not** re-run at all — nothing to seed, the running DB is untouched.
|
|
106
|
+
|
|
107
|
+
(Migrations are usually safe to re-run as-is: migration tools track applied migrations in their own table, which on a fresh box is empty, so they simply re-apply. Only the *data* seed needs the existence check.) Install the DB client the seed/migrate tasks need (e.g. `postgresql-client`) in the `install` task — don't `docker exec` the DB container for these checks (nested `docker exec` fails inside a box with a `setns` error); reach it over TCP with the client tools instead.
|
|
108
|
+
|
|
109
|
+
## 3. Wire readiness probes (services only)
|
|
110
|
+
|
|
111
|
+
`ready_when:` lets the supervisor decide when a service is "ready" (vs. just "running"). Exactly one of these must be present:
|
|
112
|
+
|
|
113
|
+
- `port: 3000` — TCP connect (default host `127.0.0.1`; override with `host:`).
|
|
114
|
+
- `log_match: "Listening on"` — regex matched against stdout/stderr. First match flips the service to ready.
|
|
115
|
+
- `http: "http://127.0.0.1:3000/health"` — GET probe. Optional `expect_status: 200` (default: any 2xx).
|
|
116
|
+
|
|
117
|
+
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).
|
|
118
|
+
|
|
119
|
+
### Mark the web service with `expose:`
|
|
120
|
+
|
|
121
|
+
The box's primary web app (the dev server / Next.js / API the user opens in a browser) should declare:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
expose:
|
|
125
|
+
port: 3000 # the port this service listens on inside the box
|
|
126
|
+
as: 80 # must be 80 — the container port AgentBox publishes
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
At most **one** service may set `expose:`. AgentBox forwards container `:80` to `127.0.0.1:<port>` and publishes it on the host with `portless` proxy to a <boxname>.localhost url, 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:`).
|
|
130
|
+
|
|
131
|
+
## 4. Restart + backoff
|
|
132
|
+
|
|
133
|
+
Per service:
|
|
134
|
+
|
|
135
|
+
- `restart: always | on-failure | never` (default `on-failure`).
|
|
136
|
+
- `backoff:` — `initial_ms` (default 500), `max_ms` (default 30000; must be `>= initial_ms`), `factor` (default 2).
|
|
137
|
+
|
|
138
|
+
## 5. (Optional) `defaults:` block
|
|
139
|
+
|
|
140
|
+
Sets per-project defaults for `agentbox create`/`claude`/`code`/`shell` — same shape as `~/.agentbox/config.yaml`. CLI flags still override. Common keys:
|
|
141
|
+
|
|
142
|
+
- `box.hostSnapshot` (bool) — APFS-clone the *host* workspace into a per-box scratch dir before seeding `/workspace` (stabilizes the tar-pipe source).
|
|
143
|
+
- `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).
|
|
144
|
+
- `box.withPlaywright` (bool) — install `@playwright/cli` globally inside the box.
|
|
145
|
+
- `box.vnc` (bool) — run Xvnc + noVNC on container port 6080.
|
|
146
|
+
- `box.isolateClaudeConfig` (bool) — per-box `~/.claude` volume instead of the shared one.
|
|
147
|
+
- `code.ide` — `vscode | cursor | auto`.
|
|
148
|
+
- `code.autoTerminals` (bool) — auto-generate `.vscode/tasks.json` with per-service tails.
|
|
149
|
+
- `browser.default` — `agent-browser | playwright | both`.
|
|
150
|
+
|
|
151
|
+
Full key list (run on the host): `agentbox config list --keys`.
|
|
152
|
+
|
|
153
|
+
## 6. Worked example
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
# yaml-language-server: $schema=https://agent-box.sh/schema/agentbox.schema.json
|
|
157
|
+
# This agentbox.yaml setup this Next.js project, and includes:
|
|
158
|
+
# - a postgres database because it's used in the project
|
|
159
|
+
# - an inngest server for queues
|
|
160
|
+
# - a fix to move .turbo/cache folder to the workspace to avoid a permission error during setup
|
|
161
|
+
# - ...
|
|
162
|
+
defaults:
|
|
163
|
+
box:
|
|
164
|
+
withPlaywright: true
|
|
165
|
+
code:
|
|
166
|
+
ide: cursor
|
|
167
|
+
|
|
168
|
+
tasks:
|
|
169
|
+
# Idempotent install. /workspace is the container's writable filesystem, so
|
|
170
|
+
# node_modules persists across pause/stop/start and is captured by
|
|
171
|
+
# `agentbox checkpoint`. The host's node_modules is macOS-native and is
|
|
172
|
+
# never copied in, so the first Linux install runs; `run_once: true` then
|
|
173
|
+
# skips it on every subsequent box start (the supervisor stores a marker
|
|
174
|
+
# keyed by a hash of the command). Adjust the lockfile detection to the
|
|
175
|
+
# project's package manager.
|
|
176
|
+
install:
|
|
177
|
+
command: |
|
|
178
|
+
set -e
|
|
179
|
+
sudo apt-get update && sudo apt-get install -y postgresql-client
|
|
180
|
+
if [ -f pnpm-lock.yaml ]; then
|
|
181
|
+
corepack enable >/dev/null 2>&1 || true
|
|
182
|
+
pnpm install --frozen-lockfile || pnpm install
|
|
183
|
+
fi
|
|
184
|
+
run_once: true
|
|
185
|
+
|
|
186
|
+
migrate:
|
|
187
|
+
command: pnpm db:migrate
|
|
188
|
+
needs: [install]
|
|
189
|
+
|
|
190
|
+
services:
|
|
191
|
+
postgres:
|
|
192
|
+
command: postgres -D /var/lib/postgresql/data
|
|
193
|
+
ready_when:
|
|
194
|
+
port: 5432
|
|
195
|
+
restart: always
|
|
196
|
+
|
|
197
|
+
dev:
|
|
198
|
+
command: pnpm dev
|
|
199
|
+
needs: [install, migrate, postgres]
|
|
200
|
+
ready_when:
|
|
201
|
+
port: 3000
|
|
202
|
+
timeout_ms: 120000
|
|
203
|
+
expose:
|
|
204
|
+
port: 3000
|
|
205
|
+
as: 80
|
|
206
|
+
restart: on-failure
|
|
207
|
+
backoff:
|
|
208
|
+
initial_ms: 500
|
|
209
|
+
max_ms: 5000
|
|
210
|
+
factor: 2
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## 6b. Bringing extra host files/folders into the box
|
|
214
|
+
|
|
215
|
+
Two ways to copy host files in (both COPY — never a live mount, so the box can't
|
|
216
|
+
write back to the host):
|
|
217
|
+
|
|
218
|
+
- **`carry:` block** (declarative, in `agentbox.yaml`) — for files/dirs every box
|
|
219
|
+
should get at create time. Each entry is `{ src, dest }` with optional `mode`,
|
|
220
|
+
`user`, `optional`, and `exclude:` (a list of tar globs / bare dir names to drop
|
|
221
|
+
when copying a directory). Heavy regenerable dirs (`.git`, `node_modules`, `bin`,
|
|
222
|
+
`obj`, `packages`, `dist`, `.next`, `target`) are dropped by default; `exclude:`
|
|
223
|
+
is additive. Each carry entry is capped at `box.cpMaxBytes` (default 100 MiB
|
|
224
|
+
after excludes) — the same limit `agentbox cp` enforces.
|
|
225
|
+
- **`agentbox-ctl cp fromHost <hostPath...> <boxPath>`** (ad-hoc, from inside the box)
|
|
226
|
+
— for a one-off copy. Takes several sources in one call (last path is the dest,
|
|
227
|
+
which must be a directory). Prompts the user on the host to approve.
|
|
228
|
+
|
|
229
|
+
**The per-copy size limit (important for large/legacy folders).** A single copy is
|
|
230
|
+
blocked above `box.cpMaxBytes` (default **100 MB**) *after* default excludes, so it
|
|
231
|
+
fails loud instead of silently hanging. When blocked you get a `du`-style tree of
|
|
232
|
+
the biggest remaining folders/subfolders. To get under the limit, EITHER:
|
|
233
|
+
|
|
234
|
+
- **drop what the box can regenerate** (the default excludes already remove
|
|
235
|
+
`node_modules`/`.git`/build output; add more with `--exclude=<glob-or-name>`), OR
|
|
236
|
+
- **copy the heavy folders one at a time** so each copy is under the limit, OR
|
|
237
|
+
- pass `--yes` to copy the whole thing anyway (only when you really need it all).
|
|
238
|
+
|
|
239
|
+
Example: a 2.4 GB legacy folder is mostly `packages/` (NuGet) + `.git`; those are
|
|
240
|
+
excluded by default, and what's left can be copied in one call by listing the
|
|
241
|
+
sub-folders into a destination directory:
|
|
242
|
+
`agentbox-ctl cp fromHost ../legacy/src ../legacy/Database /workspace/legacy/`.
|
|
243
|
+
|
|
244
|
+
## 7. Validate before handing off
|
|
245
|
+
|
|
246
|
+
- check with `agentbox-ctl reload` and then `agentbox-ctl status` that everything is running as expected.
|
|
247
|
+
- Every name in `needs:` must reference an existing task or service.
|
|
248
|
+
- A service with `restart: never` and an autostart dependency will block the dependent forever after one failed run — usually a mistake.
|
|
249
|
+
- `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.
|
|
250
|
+
|
|
251
|
+
## 8. Hand-off
|
|
252
|
+
|
|
253
|
+
Tell the user (verbatim):
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
█████╗ ██████╗ ███████╗███╗ ██╗████████╗██████╗ ██████╗ ██╗ ██╗
|
|
257
|
+
██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝██╔══██╗██╔═══██╗╚██╗██╔╝
|
|
258
|
+
███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║ ██████╔╝██║ ██║ ╚███╔╝
|
|
259
|
+
██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║ ██╔══██╗██║ ██║ ██╔██╗
|
|
260
|
+
██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║ ██████╔╝╚██████╔╝██╔╝ ██╗
|
|
261
|
+
╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
your box is ready, you can start more sessions with `agentbox claude`
|
|
265
|
+
you can access the web app at https://<boxname>.localhost
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
## 9. Checkpoint the warm state - DON't SKIP THIS STEP
|
|
269
|
+
|
|
270
|
+
Checkpoint (snapshot) this box writable layer: once the box is warmed up (deps installed, services ready), checkpoint it with `agentbox-ctl checkpoint --name setup --replace --set-default` so future boxes start ready.
|
|
271
|
+
Remember the checkpoint captures the writable layer (`/workspace` + system), **not** docker-in-docker volumes — so a containerized DB's data does not carry into new boxes. That's expected; the data-existence-gated seed task from section 2 re-seeds those automatically. (If you need the data itself to persist into new boxes, run the DB as a native process with its data dir on the box filesystem, or bind a `/workspace` path as the container's data volume so it lands in the checkpoint.)
|
|
272
|
+
Run this command exactly once. The `--name setup --replace` makes it idempotent — if it ever needs to run again it overwrites the existing `setup` checkpoint instead of stacking duplicates.
|
|
273
|
+
On all providers except Vercel, this doesn't need to be confirmed by the user. It will pause the container for several seconds so warn the user about it and write Done when it's done.
|
|
274
|
+
On Vercel: this actually STOPS the sandbox, so warn the user about it. Also the system will ask confirmation.
|
|
275
|
+
|
|
276
|
+
## 10. Known issues
|
|
277
|
+
|
|
278
|
+
- For Nextjs/Vite/Tasnstack projects, makes sure to forward also websocket for hot reload.
|
|
279
|
+
|
|
280
|
+
- Service like flask, nextjs, BETTER_AUTH_URL, NEXT_PUBLIC_APP_URL should use the env-init `{{AGENTBOX_BOX_HOST}}` in agentbox.yaml so it will be automatically replaced.
|
|
281
|
+
|
|
282
|
+
- The `install` task above uses `run_once: true`, so it is a no-op on warm boots. Do **not** wrap it in a manual marker check too. To force a one-off rebuild, run `agentbox-ctl run-task install --force` (which bypasses the run_once marker), or edit the command (a changed command invalidates the hash and re-runs).
|
|
283
|
+
|
|
284
|
+
## 11. Pin URLs / render config files (env, secrets)
|
|
285
|
+
|
|
286
|
+
Many apps hard-code a hostname (e.g. `optima.localhost`) or read a gitignored `.env`. Instead of long `sed` commands in a task, use the built-ins:
|
|
287
|
+
|
|
288
|
+
- **`agentbox-ctl render <src>`** — a declarative `sed` for files already in the workspace. `--env` substitutes `{{AGENTBOX_*}}` placeholders; `--rules <name>` applies a named rule-set from the top-level `replacements:` block; `--rule 'from=>to'` / `--rule-regex 'pat=>repl'` are inline. Write to `--out <path>` (or `--in-place`). The whitelist placeholders are `{{AGENTBOX_BOX_NAME}}`, `{{AGENTBOX_BOX_HOST}}` (= `<boxname>.localhost`), `{{AGENTBOX_BOX_ID}}`, `{{AGENTBOX_BOX_KIND}}`, `{{AGENTBOX_HOST_WORKSPACE}}`, `{{AGENTBOX_PROJECT_ROOT}}`.
|
|
289
|
+
|
|
290
|
+
Render a gitignored `.env` from a committed `env.example` on every boot, pinning the URLs to this box:
|
|
291
|
+
|
|
292
|
+
```yaml
|
|
293
|
+
replacements:
|
|
294
|
+
box-host:
|
|
295
|
+
- { from: 'optima\.localhost', to: '{{AGENTBOX_BOX_HOST}}', regex: true } # {{AGENTBOX_BOX_HOST}} = <box>.localhost
|
|
296
|
+
|
|
297
|
+
tasks:
|
|
298
|
+
env:
|
|
299
|
+
# The render is idempotent (the rules re-pin the same lines every boot), so
|
|
300
|
+
# no `run_once:` guard is needed — it self-corrects on a checkpoint-started
|
|
301
|
+
# box that carries a different box's host in .env.
|
|
302
|
+
command: agentbox-ctl render apps/saas/env.example --out apps/saas/.env --env --rules box-host
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Note: an `run_once: { check: <cmd> }` probe runs verbatim via `bash -c` with the box env — use shell vars like `$AGENTBOX_BOX_NAME`, NOT `{{…}}` placeholders (those are only expanded by `render`/carry, never by the supervisor).
|
|
306
|
+
|
|
307
|
+
**Generated secrets:** put `{{AGENTBOX_AUTO_SECRET}}` in the template for a value like `BETTER_AUTH_SECRET` instead of shelling out to `openssl rand`. Unnamed → a fresh 32-byte base64url secret each render (stable when you render the template→`.env` once). `{{AGENTBOX_AUTO_SECRET:better-auth}}` → generated once, persisted at `/var/lib/agentbox/secrets/<name>`, reused on every render (stable even if you render every boot). Example `env.example` line: `BETTER_AUTH_SECRET="{{AGENTBOX_AUTO_SECRET:better-auth}}"`.
|
|
308
|
+
|
|
309
|
+
- **`carry:` + `replaceEnvs`/`replace`/`rules`** — for a host-only file (e.g. a real `.env` with secrets that never lives in the repo), carry it in and render it host-side in one step (file entries only):
|
|
310
|
+
|
|
311
|
+
```yaml
|
|
312
|
+
carry:
|
|
313
|
+
- src: ~/secrets/optima.env
|
|
314
|
+
dest: /workspace/apps/saas/.env
|
|
315
|
+
replaceEnvs: true
|
|
316
|
+
rules: [box-host]
|
|
317
|
+
```
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Start the per-box VNC stack: Xvnc on :1 (loopback inside container) +
|
|
3
|
+
# websockify on 0.0.0.0:6080 serving noVNC's HTML5 client and proxying RFB.
|
|
4
|
+
# Launched by the host via `docker exec -d --user vscode` after the container
|
|
5
|
+
# is up. Idempotent — re-running while the daemons are alive is a no-op, so
|
|
6
|
+
# `agentbox start` can blindly call us again.
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
PASS="${AGENTBOX_VNC_PASSWORD:-}"
|
|
11
|
+
if [[ -z "$PASS" ]]; then
|
|
12
|
+
echo "agentbox-vnc-start: AGENTBOX_VNC_PASSWORD is not set" >&2
|
|
13
|
+
exit 64
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if pgrep -u "$(id -u)" -x Xvnc >/dev/null \
|
|
17
|
+
&& pgrep -u "$(id -u)" -f "websockify.*6080" >/dev/null; then
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
mkdir -p "$HOME/.vnc"
|
|
22
|
+
# vncpasswd's -f mode reads plaintext on stdin, writes the DES blob to stdout.
|
|
23
|
+
# VncAuth truncates >8 chars at compare time, which is fine — the host writes
|
|
24
|
+
# an 8-char password. Write to a temp file + rename so a failure (e.g.,
|
|
25
|
+
# vncpasswd missing) doesn't leave an empty file that Xvnc would then reject.
|
|
26
|
+
#
|
|
27
|
+
# Debian 12 (E2B base) doesn't package vncpasswd at all — tigervnc-tools is
|
|
28
|
+
# Ubuntu-only. When vncpasswd is missing, fall back to `-SecurityTypes None`
|
|
29
|
+
# and rely on the cloud provider's signed preview URL as the access boundary
|
|
30
|
+
# (same effective model: holding the URL = holding the credential). Other
|
|
31
|
+
# providers (docker, hetzner, daytona, vercel) keep VncAuth.
|
|
32
|
+
VNC_SECURITY_ARGS=(-SecurityTypes VncAuth -PasswordFile "$HOME/.vnc/passwd")
|
|
33
|
+
if command -v vncpasswd >/dev/null 2>&1; then
|
|
34
|
+
TMP_PASSWD="$(mktemp "$HOME/.vnc/passwd.XXXXXX")"
|
|
35
|
+
printf '%s\n' "$PASS" | vncpasswd -f > "$TMP_PASSWD"
|
|
36
|
+
chmod 600 "$TMP_PASSWD"
|
|
37
|
+
mv "$TMP_PASSWD" "$HOME/.vnc/passwd"
|
|
38
|
+
else
|
|
39
|
+
echo "agentbox-vnc-start: vncpasswd not installed; starting Xvnc with -SecurityTypes None (preview URL is the access boundary)" >&2
|
|
40
|
+
VNC_SECURITY_ARGS=(-SecurityTypes None)
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
mkdir -p /var/log/agentbox 2>/dev/null || true
|
|
44
|
+
|
|
45
|
+
# Xvnc on display :1, loopback-only (websockify is the only public ingress).
|
|
46
|
+
# 1280x800x24 is a sensible laptop-browser viewport.
|
|
47
|
+
# The clipboard params are on-by-default in TigerVNC 1.13 but pinned here so a
|
|
48
|
+
# base-image bump can't silently break host->box paste, and to document intent:
|
|
49
|
+
# accept cut-text from noVNC, set both the X CLIPBOARD and PRIMARY selections.
|
|
50
|
+
Xvnc :1 \
|
|
51
|
+
-localhost \
|
|
52
|
+
"${VNC_SECURITY_ARGS[@]}" \
|
|
53
|
+
-geometry 1280x800 \
|
|
54
|
+
-depth 24 \
|
|
55
|
+
-AlwaysShared \
|
|
56
|
+
-AcceptCutText=1 \
|
|
57
|
+
-SendCutText=1 \
|
|
58
|
+
-SetPrimary=1 \
|
|
59
|
+
-SendPrimary=1 \
|
|
60
|
+
>/var/log/agentbox/xvnc.log 2>&1 &
|
|
61
|
+
|
|
62
|
+
# Wait for Xvnc's RFB socket (5901). bash's /dev/tcp pseudo-device makes the
|
|
63
|
+
# probe a one-liner without needing netcat in the image.
|
|
64
|
+
for _ in $(seq 1 50); do
|
|
65
|
+
if (echo > /dev/tcp/127.0.0.1/5901) 2>/dev/null; then break; fi
|
|
66
|
+
sleep 0.1
|
|
67
|
+
done
|
|
68
|
+
|
|
69
|
+
# With no window manager, nothing owns the X selections, so Xvnc's RFB cut-text
|
|
70
|
+
# isn't reliably handed to Chromium on Ctrl+V. autocutsel (one daemon per
|
|
71
|
+
# selection) keeps CLIPBOARD and PRIMARY populated and synced. Best-effort: a
|
|
72
|
+
# clipboard failure must never abort VNC, and the pgrep guard keeps a stray
|
|
73
|
+
# re-entry from spawning duplicates (Xvnc is up now, so DISPLAY=:1 resolves).
|
|
74
|
+
if ! pgrep -u "$(id -u)" -x autocutsel >/dev/null; then
|
|
75
|
+
DISPLAY=:1 autocutsel -selection CLIPBOARD -fork >/dev/null 2>&1 || true
|
|
76
|
+
DISPLAY=:1 autocutsel -selection PRIMARY -fork >/dev/null 2>&1 || true
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# noVNC's static assets live at different paths per base image: Debian/Ubuntu
|
|
80
|
+
# (docker, hetzner) ship them at /usr/share/novnc via apt; the AL2023 bake
|
|
81
|
+
# (vercel) git-clones them to /usr/local/share/novnc. websockify runs
|
|
82
|
+
# os.chdir(--web) at startup, so a wrong path makes it FileNotFoundError and
|
|
83
|
+
# never bind 6080 — pick the first dir that exists.
|
|
84
|
+
NOVNC_WEB=""
|
|
85
|
+
for _d in /usr/share/novnc /usr/local/share/novnc; do
|
|
86
|
+
if [[ -d "$_d" ]]; then NOVNC_WEB="$_d"; break; fi
|
|
87
|
+
done
|
|
88
|
+
if [[ -z "$NOVNC_WEB" ]]; then
|
|
89
|
+
echo "agentbox-vnc-start: noVNC assets not found (looked in /usr/share/novnc, /usr/local/share/novnc)" >&2
|
|
90
|
+
exit 65
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
# websockify serves noVNC at /vnc.html (--web) and tunnels WS frames to Xvnc's
|
|
94
|
+
# RFB. Bind 0.0.0.0:6080 so both Docker `-p` mappings and OrbStack's
|
|
95
|
+
# <name>.orb.local routing reach it.
|
|
96
|
+
websockify \
|
|
97
|
+
--web="$NOVNC_WEB" \
|
|
98
|
+
0.0.0.0:6080 \
|
|
99
|
+
127.0.0.1:5901 \
|
|
100
|
+
>/var/log/agentbox/websockify.log 2>&1 &
|
|
101
|
+
|
|
102
|
+
disown -a
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "AgentBox enterprise-managed Claude Code settings, baked into the box image at /etc/claude-code/managed-settings.json. Highest precedence and NOT synced from the host ~/.claude, so claude-hooks-filter.ts never touches it; per Claude Code, hook arrays MERGE across settings sources, so the user's own hooks still run. These hooks report Claude's activity to the box supervisor (agentbox-ctl claude-state -> ctl socket -> relay -> ~/.agentbox/boxes/<id>/status.json) so `agentbox status/list/inspect` can show it even when the box is paused. Each command is exit-0 fast and shell-backgrounded so a hook can never block or fail a Claude turn. The ExitPlanMode / AskUserQuestion entries run SYNCHRONOUSLY (no &) because they consume the hook's stdin payload; the catchall PreToolUse 'working' hook races with them, but the supervisor's sticky-state semantics swallow that race (a 'working' set while in end-plan/question is ignored unless --clear-pending is set, which only the matching PostToolUse hook passes). The SessionStart / Stop entries also run SYNCHRONOUSLY (no &) with --capture-session: they read the hook's stdin session_id and record it to the box's per-box session pointer (~/.local/state/agentbox/claude-session) so a box restart can resume the exact conversation (claude --resume <id>); they fire often enough to track /new and /branch, which mint fresh session ids. (A backgrounded `&` hook would detach stdin, so capture hooks must be synchronous.) skipDangerousModePermissionPrompt pre-accepts the bypass-permissions disclaimer at policy precedence — AgentBox boxes are isolated, and `agentbox claude` defaults to --dangerously-skip-permissions, so the one-time accept gate would just trap every fresh box.",
|
|
3
|
+
"skipDangerousModePermissionPrompt": true,
|
|
4
|
+
"hooks": {
|
|
5
|
+
"UserPromptSubmit": [
|
|
6
|
+
{
|
|
7
|
+
"hooks": [
|
|
8
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
9
|
+
]
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"PreToolUse": [
|
|
13
|
+
{
|
|
14
|
+
"hooks": [
|
|
15
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"matcher": "ExitPlanMode",
|
|
20
|
+
"hooks": [
|
|
21
|
+
{ "type": "command", "command": "agentbox-ctl claude-state end-plan --payload-stdin >/dev/null 2>&1", "timeout": 3 }
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"matcher": "AskUserQuestion",
|
|
26
|
+
"hooks": [
|
|
27
|
+
{ "type": "command", "command": "agentbox-ctl claude-state question --payload-stdin >/dev/null 2>&1", "timeout": 3 }
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"PostToolUse": [
|
|
32
|
+
{
|
|
33
|
+
"matcher": "ExitPlanMode",
|
|
34
|
+
"hooks": [
|
|
35
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working --clear-pending >/dev/null 2>&1 &", "timeout": 3 }
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"matcher": "AskUserQuestion",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working --clear-pending >/dev/null 2>&1 &", "timeout": 3 }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"Stop": [
|
|
46
|
+
{
|
|
47
|
+
"hooks": [
|
|
48
|
+
{ "type": "command", "command": "agentbox-ctl claude-state idle --capture-session >/dev/null 2>&1", "timeout": 3 }
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"StopFailure": [
|
|
53
|
+
{
|
|
54
|
+
"hooks": [
|
|
55
|
+
{ "type": "command", "command": "agentbox-ctl claude-state error >/dev/null 2>&1 &", "timeout": 3 }
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"PreCompact": [
|
|
60
|
+
{
|
|
61
|
+
"hooks": [
|
|
62
|
+
{ "type": "command", "command": "agentbox-ctl claude-state compacting >/dev/null 2>&1 &", "timeout": 3 }
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"PostCompact": [
|
|
67
|
+
{
|
|
68
|
+
"hooks": [
|
|
69
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working --clear-pending >/dev/null 2>&1 &", "timeout": 3 }
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"SubagentStart": [
|
|
74
|
+
{
|
|
75
|
+
"hooks": [
|
|
76
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"SubagentStop": [
|
|
81
|
+
{
|
|
82
|
+
"hooks": [
|
|
83
|
+
{ "type": "command", "command": "agentbox-ctl claude-state working >/dev/null 2>&1 &", "timeout": 3 }
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"Notification": [
|
|
88
|
+
{
|
|
89
|
+
"matcher": "permission_prompt",
|
|
90
|
+
"hooks": [
|
|
91
|
+
{ "type": "command", "command": "agentbox-ctl claude-state waiting >/dev/null 2>&1 &", "timeout": 3 }
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"matcher": "idle_prompt",
|
|
96
|
+
"hooks": [
|
|
97
|
+
{ "type": "command", "command": "agentbox-ctl claude-state idle >/dev/null 2>&1 &", "timeout": 3 }
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"SessionStart": [
|
|
102
|
+
{
|
|
103
|
+
"hooks": [
|
|
104
|
+
{ "type": "command", "command": "agentbox-ctl claude-state idle --capture-session >/dev/null 2>&1", "timeout": 3 }
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"SessionEnd": [
|
|
109
|
+
{
|
|
110
|
+
"hooks": [
|
|
111
|
+
{ "type": "command", "command": "agentbox-ctl claude-state idle --clear-session >/dev/null 2>&1 &", "timeout": 3 }
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|