@madarco/agentbox 0.7.0 → 0.9.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.
Files changed (77) hide show
  1. package/dist/_cloud-attach-ZXBCNWJX.js +13 -0
  2. package/dist/{chunk-NW5NYTQM.js → chunk-BXQMIEHC.js} +459 -110
  3. package/dist/chunk-BXQMIEHC.js.map +1 -0
  4. package/dist/{chunk-UK72UQ5U.js → chunk-G3H2L3O2.js} +55 -4
  5. package/dist/chunk-G3H2L3O2.js.map +1 -0
  6. package/dist/{chunk-7KOEFGN2.js → chunk-GU5LW4B5.js} +385 -31
  7. package/dist/chunk-GU5LW4B5.js.map +1 -0
  8. package/dist/chunk-KL36BRN4.js +455 -0
  9. package/dist/chunk-KL36BRN4.js.map +1 -0
  10. package/dist/{chunk-V5KZGB5V.js → chunk-LEV3KICD.js} +18 -2
  11. package/dist/chunk-LEV3KICD.js.map +1 -0
  12. package/dist/chunk-MTVI44DW.js +662 -0
  13. package/dist/chunk-MTVI44DW.js.map +1 -0
  14. package/dist/{chunk-NAVL4R34.js → chunk-NCJP5MTN.js} +1281 -556
  15. package/dist/chunk-NCJP5MTN.js.map +1 -0
  16. package/dist/{cloud-poller-ZIWSADJB-JXFRJUEM.js → cloud-poller-SUNA6ZQC-2RG5WPRN.js} +2 -2
  17. package/dist/{dist-ETCFRVPA.js → dist-32EZBYG4.js} +50 -20
  18. package/dist/{dist-R67WMLCF.js → dist-CX5CGVEB.js} +120 -10
  19. package/dist/dist-CX5CGVEB.js.map +1 -0
  20. package/dist/{dist-QZGJIBT5.js → dist-GDHP34ZK.js} +141 -75
  21. package/dist/dist-GDHP34ZK.js.map +1 -0
  22. package/dist/dist-XML54CNB.js +849 -0
  23. package/dist/dist-XML54CNB.js.map +1 -0
  24. package/dist/index.js +3881 -867
  25. package/dist/index.js.map +1 -1
  26. package/dist/prepared-state-CL4CWXQA-H5THETIM.js +18 -0
  27. package/dist/prepared-state-CL4CWXQA-H5THETIM.js.map +1 -0
  28. package/package.json +7 -5
  29. package/runtime/daytona/custom-system-CLAUDE.md +39 -0
  30. package/runtime/docker/Dockerfile.box +22 -0
  31. package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
  32. package/runtime/docker/packages/ctl/dist/bin.cjs +1214 -98
  33. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +66 -35
  34. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +15 -1
  35. package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +62 -1
  36. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +15 -4
  37. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +263 -0
  38. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +131 -0
  39. package/runtime/docker/packages/sandbox-docker/scripts/opencode-agentbox-plugin.js +76 -0
  40. package/runtime/hetzner/agentbox-codex-hooks.json +66 -35
  41. package/runtime/hetzner/agentbox-setup-skill.md +1 -1
  42. package/runtime/hetzner/agentbox-vnc-start +15 -1
  43. package/runtime/hetzner/claude-managed-settings.json +62 -1
  44. package/runtime/hetzner/ctl.cjs +1214 -98
  45. package/runtime/hetzner/custom-system-CLAUDE.md +26 -14
  46. package/runtime/hetzner/gh-shim +263 -0
  47. package/runtime/hetzner/git-shim +131 -0
  48. package/runtime/hetzner/opencode-agentbox-plugin.js +76 -0
  49. package/runtime/hetzner/scripts/install-box.sh +11 -2
  50. package/runtime/relay/bin.cjs +1146 -63
  51. package/runtime/vercel/agentbox-checkpoint-cleanup +52 -0
  52. package/runtime/vercel/agentbox-codex-hooks.json +68 -0
  53. package/runtime/vercel/agentbox-open +28 -0
  54. package/runtime/vercel/agentbox-setup-skill.md +196 -0
  55. package/runtime/vercel/agentbox-vnc-start +91 -0
  56. package/runtime/vercel/claude-managed-settings.json +115 -0
  57. package/runtime/vercel/ctl.cjs +23466 -0
  58. package/runtime/vercel/custom-system-CLAUDE.md +50 -0
  59. package/runtime/vercel/gh-shim +263 -0
  60. package/runtime/vercel/git-shim +131 -0
  61. package/runtime/vercel/scripts/provision.sh +274 -0
  62. package/share/agentbox-setup/SKILL.md +1 -1
  63. package/share/host-skills/agentbox/SKILL.md +29 -0
  64. package/share/host-skills/agentbox-info/SKILL.md +211 -0
  65. package/share/host-skills/codex/agentbox.md +35 -0
  66. package/share/host-skills/opencode/agentbox.md +26 -0
  67. package/dist/_cloud-attach-DMVH6GWO.js +0 -12
  68. package/dist/chunk-7KOEFGN2.js.map +0 -1
  69. package/dist/chunk-NAVL4R34.js.map +0 -1
  70. package/dist/chunk-NW5NYTQM.js.map +0 -1
  71. package/dist/chunk-UK72UQ5U.js.map +0 -1
  72. package/dist/chunk-V5KZGB5V.js.map +0 -1
  73. package/dist/dist-QZGJIBT5.js.map +0 -1
  74. package/dist/dist-R67WMLCF.js.map +0 -1
  75. /package/dist/{_cloud-attach-DMVH6GWO.js.map → _cloud-attach-ZXBCNWJX.js.map} +0 -0
  76. /package/dist/{cloud-poller-ZIWSADJB-JXFRJUEM.js.map → cloud-poller-SUNA6ZQC-2RG5WPRN.js.map} +0 -0
  77. /package/dist/{dist-ETCFRVPA.js.map → dist-32EZBYG4.js.map} +0 -0
@@ -0,0 +1,274 @@
1
+ #!/usr/bin/env bash
2
+ # AgentBox Vercel base-snapshot installer.
3
+ #
4
+ # Idempotent installer run once on a fresh Vercel Sandbox (Amazon Linux 2023,
5
+ # node24 runtime) during `agentbox prepare --provider vercel`. After it
6
+ # completes we `sandbox.snapshot()` the microVM — that snapshot is what every
7
+ # per-box create boots from.
8
+ #
9
+ # Differences from the hetzner installer (packages/sandbox-hetzner/scripts/
10
+ # install-box.sh), which this mirrors:
11
+ # - dnf, not apt (Amazon Linux 2023).
12
+ # - NO docker / dockerd / iptables — Vercel Sandbox blocks the namespace
13
+ # syscalls a container runtime needs, so DinD is impossible here.
14
+ # - The `vscode` user is created without forcing uid 1000 (the Vercel default
15
+ # user may already hold it; there are no bind mounts so the exact uid is
16
+ # irrelevant — only ownership of /workspace + /home/vscode matters).
17
+ #
18
+ # Required inputs (uploaded to /tmp before this runs):
19
+ # /tmp/agentbox-ctl -- prebuilt @agentbox/ctl bundle (cjs)
20
+ # /tmp/agentbox-vnc-start -- VNC startup helper
21
+ # /tmp/agentbox-checkpoint-cleanup -- pre-snapshot cleanup helper
22
+ # /tmp/agentbox-open -- in-box xdg-open shim
23
+ # /tmp/agentbox-gh-shim -- in-box `gh` shim (routes to host gh)
24
+ # /tmp/agentbox-git-shim -- in-box `git` shim (routes via relay)
25
+ # /tmp/agentbox-custom-CLAUDE.md -- /etc/claude-code/CLAUDE.md content
26
+ # /tmp/agentbox-managed-settings.json -- /etc/claude-code/managed-settings.json
27
+ # /tmp/agentbox-codex-hooks.json -- /usr/local/share/agentbox/codex-hooks.json
28
+ # /tmp/agentbox-setup-skill.md -- /usr/local/share/agentbox/setup-guide.md
29
+ #
30
+ # Output: noisy progress to stdout (streamed into ~/.agentbox/logs/prepare.log).
31
+ # Each major step prints `>>> BEGIN <step>` / `<<< END <step>`.
32
+
33
+ set -euo pipefail
34
+
35
+ step() { printf '\n>>> BEGIN %s\n' "$1"; }
36
+ done_() { printf '<<< END %s\n' "$1"; }
37
+
38
+ if [ "$(id -u)" -ne 0 ]; then
39
+ echo "provision.sh: must run as root (got uid $(id -u))" >&2
40
+ exit 64
41
+ fi
42
+
43
+ step "dnf base packages"
44
+ # NOTE: do NOT request `curl` — AL2023 ships `curl-minimal` which provides the
45
+ # `curl` binary, and asking for full `curl` conflicts with it and aborts the
46
+ # whole (atomic) dnf transaction. `--allowerasing` lets dnf resolve any other
47
+ # such conflict by swapping rather than failing. No `| tail || true` here: that
48
+ # masks dnf's real exit code and lets the script march on with nothing
49
+ # installed (the bug that broke the first bake).
50
+ dnf install -y -q --allowerasing \
51
+ ca-certificates \
52
+ git \
53
+ tar \
54
+ gzip \
55
+ which \
56
+ shadow-utils \
57
+ sudo \
58
+ python3 \
59
+ python3-pip \
60
+ tmux \
61
+ vim \
62
+ libcap \
63
+ rsync
64
+ done_ "dnf base packages"
65
+
66
+ step "node 24 sanity"
67
+ # Vercel's node24 runtime already ships node; just confirm it's on PATH.
68
+ if ! command -v node >/dev/null 2>&1; then
69
+ echo "provision.sh: node not found on the node24 runtime — unexpected" >&2
70
+ exit 65
71
+ fi
72
+ node --version
73
+ done_ "node 24 sanity"
74
+
75
+ step "vscode user + sudoers"
76
+ # No forced uid: the Vercel default user (`vercel-sandbox`) may already hold
77
+ # 1000, and there are no bind mounts so uid-parity with the docker provider
78
+ # doesn't matter. Ownership + passwordless sudo is what counts.
79
+ if ! id vscode >/dev/null 2>&1; then
80
+ useradd -m -s /bin/bash vscode
81
+ fi
82
+ install -d -m 0755 -o vscode -g vscode /home/vscode
83
+ echo 'vscode ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/90-agentbox-vscode
84
+ chmod 0440 /etc/sudoers.d/90-agentbox-vscode
85
+ # Vercel's AL2023 base ships /etc/sudoers WITHOUT an includedir for
86
+ # /etc/sudoers.d (and with non-0440 perms), so the drop-in above is silently
87
+ # ignored and `sudo -n` as vscode fails with "a password is required" — which
88
+ # breaks the workspace seed, ctl-launch, and carry (all run as vscode and lean
89
+ # on passwordless sudo). Wire the include in and normalise perms so the rule
90
+ # actually loads, then fail loud if the result doesn't parse.
91
+ if ! grep -qE '^[[:space:]]*[@#]includedir[[:space:]]+/etc/sudoers\.d' /etc/sudoers; then
92
+ printf '\n@includedir /etc/sudoers.d\n' >> /etc/sudoers
93
+ fi
94
+ chmod 0440 /etc/sudoers
95
+ visudo -cf /etc/sudoers >/dev/null
96
+ done_ "vscode user + sudoers"
97
+
98
+ step "agentbox base dirs + /workspace ownership"
99
+ mkdir -p /workspace /run/agentbox /var/log/agentbox /etc/agentbox /etc/claude-code \
100
+ /usr/local/share/agentbox
101
+ chmod 755 /workspace
102
+ chown vscode:vscode /workspace /run/agentbox /var/log/agentbox
103
+ done_ "agentbox base dirs + /workspace ownership"
104
+
105
+ step "node setcap (bind <1024 without root)"
106
+ # The cloud WebProxy binds port 80; grant node the capability so it needn't run
107
+ # as root. Best-effort — if setcap is unavailable the WebProxy can still be
108
+ # launched via sudo.
109
+ NODE_BIN="$(readlink -f "$(command -v node)")"
110
+ setcap cap_net_bind_service=+ep "$NODE_BIN" || echo "provision.sh: setcap failed (continuing)"
111
+ done_ "node setcap (bind <1024 without root)"
112
+
113
+ step "corepack (pnpm + yarn shims)"
114
+ npm install -g corepack@latest 2>&1 | tail -2 || true
115
+ corepack enable pnpm yarn 2>/dev/null || true
116
+ sudo -u vscode -H mkdir -p /home/vscode/.cache/node/corepack
117
+ done_ "corepack (pnpm + yarn shims)"
118
+
119
+ step "git system-wide safe.directory"
120
+ # The Vercel node24 runtime's git is built with prefix /opt/git, so its system
121
+ # config is /opt/git/etc/gitconfig and the parent dir may not exist — without
122
+ # it `git config --system` fails with "could not lock config file" (exit 255).
123
+ # Create the dir, then set it system-wide AND for the vscode user so workspace
124
+ # git ops never trip "dubious ownership". All best-effort — a git-config quirk
125
+ # must never abort the bake.
126
+ mkdir -p /opt/git/etc 2>/dev/null || true
127
+ git config --system --add safe.directory '*' 2>/dev/null || true
128
+ sudo -u vscode -H git config --global --add safe.directory '*' 2>/dev/null || true
129
+ done_ "git system-wide safe.directory"
130
+
131
+ step "agentbox-ctl install"
132
+ install -m 0755 /tmp/agentbox-ctl /usr/local/bin/agentbox-ctl
133
+ done_ "agentbox-ctl install"
134
+
135
+ step "baked helper scripts (vnc / cleanup / xdg-open)"
136
+ install -m 0755 /tmp/agentbox-vnc-start /usr/local/bin/agentbox-vnc-start
137
+ install -m 0755 /tmp/agentbox-checkpoint-cleanup /usr/local/bin/agentbox-checkpoint-cleanup
138
+ install -m 0755 /tmp/agentbox-open /usr/local/bin/agentbox-open
139
+ ln -sf /usr/local/bin/agentbox-open /usr/local/bin/xdg-open
140
+ # NOTE: the gh + git shims are installed LAST (see "relay shims" near the end).
141
+ # Installing them here would put the relay-routing `git` on PATH ahead of
142
+ # /usr/bin/git and route provision.sh's own noVNC `git clone` through a relay
143
+ # that doesn't exist during the bake.
144
+ done_ "baked helper scripts (vnc / cleanup / xdg-open)"
145
+
146
+ step "baked config files (claude / codex / setup guide / tmux.conf)"
147
+ install -m 0644 /tmp/agentbox-custom-CLAUDE.md /etc/claude-code/CLAUDE.md
148
+ install -m 0644 /tmp/agentbox-managed-settings.json /etc/claude-code/managed-settings.json
149
+ install -m 0644 /tmp/agentbox-codex-hooks.json /usr/local/share/agentbox/codex-hooks.json
150
+ install -m 0644 /tmp/agentbox-setup-skill.md /usr/local/share/agentbox/setup-guide.md
151
+
152
+ cat > /etc/tmux.conf <<'TMUX'
153
+ set -g default-terminal "tmux-256color"
154
+ set -as terminal-overrides ",*:Tc"
155
+ set -as terminal-overrides ",*:RGB"
156
+ set -as terminal-features ",*:hyperlinks"
157
+ set -as terminal-features ",*:RGB"
158
+ set -g allow-passthrough on
159
+ set -g set-clipboard on
160
+ set -g extended-keys on
161
+ set -as terminal-features ",*:extkeys"
162
+ set -g mouse on
163
+ bind -T copy-mode WheelUpPane send -N2 -X scroll-up
164
+ bind -T copy-mode WheelDownPane send -N2 -X scroll-down
165
+ bind -T copy-mode-vi WheelUpPane send -N2 -X scroll-up
166
+ bind -T copy-mode-vi WheelDownPane send -N2 -X scroll-down
167
+ set -g history-limit 50000
168
+ set -g escape-time 0
169
+ TMUX
170
+ done_ "baked config files (claude / codex / setup guide / tmux.conf)"
171
+
172
+ step "credential pivot symlinks (vscode home)"
173
+ sudo -u vscode -H mkdir -p \
174
+ /home/vscode/.claude \
175
+ /home/vscode/.claude/skills/agentbox-setup \
176
+ /home/vscode/.codex \
177
+ /home/vscode/.local/share/opencode \
178
+ /home/vscode/.agentbox-creds/claude \
179
+ /home/vscode/.agentbox-creds/codex \
180
+ /home/vscode/.agentbox-creds/opencode
181
+ sudo -u vscode -H ln -sf /home/vscode/.agentbox-creds/claude/.credentials.json \
182
+ /home/vscode/.claude/.credentials.json
183
+ sudo -u vscode -H ln -sf /home/vscode/.agentbox-creds/codex/auth.json \
184
+ /home/vscode/.codex/auth.json
185
+ sudo -u vscode -H ln -sf /home/vscode/.agentbox-creds/opencode/auth.json \
186
+ /home/vscode/.local/share/opencode/auth.json
187
+ sudo -u vscode -H ln -sf /home/vscode/.claude/_claude.json /home/vscode/.claude.json
188
+ sudo -u vscode -H cp /usr/local/share/agentbox/setup-guide.md \
189
+ /home/vscode/.claude/skills/agentbox-setup/SKILL.md
190
+ done_ "credential pivot symlinks (vscode home)"
191
+
192
+ step "login-shell shim (/etc/profile.d/agentbox.sh)"
193
+ cat > /etc/profile.d/agentbox.sh <<'PROFILE'
194
+ # Auto-loaded by login shells; box.env is written at create time.
195
+ if [ -r /etc/agentbox/box.env ]; then
196
+ set -a
197
+ . /etc/agentbox/box.env
198
+ set +a
199
+ fi
200
+ case ":$PATH:" in
201
+ *:/home/vscode/.local/bin:*) : ;;
202
+ *) PATH=/home/vscode/.local/bin:$PATH ;;
203
+ esac
204
+ # Force /usr/local/bin to win PATH. Vercel's AL2023 base prepends /opt/git/bin
205
+ # AHEAD of /usr/local/bin, so the relay-routing shims at /usr/local/bin/{git,gh}
206
+ # are otherwise shadowed by the real binaries and agent-typed `git push` /
207
+ # `gh ...` bypass the host relay (backlog #19). A plain `case` prepend doesn't
208
+ # help — /usr/local/bin is already on PATH, just not first — so strip any
209
+ # existing occurrence and re-prepend.
210
+ PATH=/usr/local/bin:$(printf '%s' "$PATH" | sed -e 's#:/usr/local/bin:#:#g' -e 's#^/usr/local/bin:##' -e 's#:/usr/local/bin$##' -e 's#^/usr/local/bin$##')
211
+ export PATH
212
+ export COLORTERM=${COLORTERM:-truecolor}
213
+ export DISABLE_AUTOUPDATER=${DISABLE_AUTOUPDATER:-1}
214
+ export DISPLAY=${DISPLAY:-:1}
215
+ export AGENT_BROWSER_EXECUTABLE_PATH=${AGENT_BROWSER_EXECUTABLE_PATH:-/usr/local/bin/chromium}
216
+ export BROWSER=${BROWSER:-/usr/local/bin/agentbox-open}
217
+ PROFILE
218
+ chmod 0644 /etc/profile.d/agentbox.sh
219
+ done_ "login-shell shim (/etc/profile.d/agentbox.sh)"
220
+
221
+ step "VNC stack (TigerVNC + websockify + noVNC)"
222
+ # Best-effort: VNC is a convenience (agentbox screen). A package that isn't in
223
+ # the AL2023 repos shouldn't fail the whole bake — the VNC daemon launch is
224
+ # already best-effort on the create path.
225
+ dnf install -y -q --allowerasing tigervnc-server xterm 2>&1 | tail -3 || \
226
+ echo "provision.sh: tigervnc-server install failed (VNC may be unavailable)"
227
+ pip3 install --quiet websockify 2>&1 | tail -2 || \
228
+ echo "provision.sh: websockify install failed (VNC may be unavailable)"
229
+ # noVNC static assets — clone shallow into a stable path the vnc-start script
230
+ # can serve.
231
+ if [ ! -d /usr/local/share/novnc ]; then
232
+ git clone --depth 1 https://github.com/novnc/noVNC /usr/local/share/novnc 2>&1 | tail -2 || \
233
+ echo "provision.sh: noVNC clone failed (VNC may be unavailable)"
234
+ fi
235
+ sudo -u vscode -H mkdir -p /home/vscode/.vnc
236
+ done_ "VNC stack (TigerVNC + websockify + noVNC)"
237
+
238
+ step "agent CLIs (codex + opencode + agent-browser, global npm)"
239
+ npm install -g @openai/codex opencode-ai agent-browser 2>&1 | tail -3 || \
240
+ echo "provision.sh: one or more agent npm installs failed (continuing)"
241
+ done_ "agent CLIs (codex + opencode + agent-browser, global npm)"
242
+
243
+ step "Claude Code (native installer, run as vscode)"
244
+ # Anthropic's canonical installer drops `claude` at /home/vscode/.local/bin/.
245
+ sudo -u vscode -H bash -lc 'curl -fsSL https://claude.ai/install.sh | bash -s stable'
246
+ done_ "Claude Code (native installer, run as vscode)"
247
+
248
+ step "dnf cleanup"
249
+ dnf clean all 2>/dev/null || true
250
+ done_ "dnf cleanup"
251
+
252
+ # Relay-routing shims, installed LAST — after every git/gh use in this script
253
+ # (the noVNC `git clone` and any npm/installer step). At RUNTIME agent calls to
254
+ # `gh ...` / `git push|pull|fetch|clone` must route through the host relay; the
255
+ # login-shell shim above forces /usr/local/bin ahead of Vercel's /opt/git/bin so
256
+ # these win (a plain install location is NOT enough on AL2023 — see #19). During
257
+ # the bake there is no relay, so they must not shadow the real binaries until
258
+ # provisioning is done. Installed from /tmp just before the trim step removes the
259
+ # sources.
260
+ step "relay shims (gh + git)"
261
+ install -m 0755 /tmp/agentbox-gh-shim /usr/local/bin/gh
262
+ install -m 0755 /tmp/agentbox-git-shim /usr/local/bin/git
263
+ done_ "relay shims (gh + git)"
264
+
265
+ step "trim /tmp/agentbox-*"
266
+ rm -f /tmp/agentbox-ctl /tmp/agentbox-vnc-start \
267
+ /tmp/agentbox-checkpoint-cleanup /tmp/agentbox-open \
268
+ /tmp/agentbox-gh-shim /tmp/agentbox-git-shim \
269
+ /tmp/agentbox-custom-CLAUDE.md /tmp/agentbox-managed-settings.json \
270
+ /tmp/agentbox-codex-hooks.json /tmp/agentbox-setup-skill.md
271
+ mv /tmp/agentbox-provision.sh /var/log/agentbox/provision.sh 2>/dev/null || true
272
+ done_ "trim /tmp/agentbox-*"
273
+
274
+ printf '\n*** provision.sh: complete — microVM ready for snapshot.\n'
@@ -14,7 +14,7 @@ Run `agentbox checkpoint --set-default` (similar to `docker commit`) to save any
14
14
 
15
15
  Some special folders:
16
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/`.
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
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
19
  - **`agentbox.yaml`** — read by `agentbox-ctl` from `/workspace`. Tasks and services declared here are what the supervisor will run.
20
20
 
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: agentbox
3
+ description: "Fork the current agent session into a new VM or local Docker container with all the project files, agent settings and session teleported into."
4
+ disable-model-invocation: true
5
+ context: fork
6
+ agent: general-purpose
7
+ allowed-tools: Bash
8
+ ---
9
+ <!-- agentbox-managed:v1 -->
10
+
11
+ Fork the current Claude Code session into a fresh AgentBox box.
12
+
13
+ 1. **Resolve the provider flag from `$ARGUMENTS`:**
14
+ - empty → no flag (uses the default docker provider)
15
+ - `docker` | `daytona` | `hetzner` → pass `--provider $ARGUMENTS`
16
+ - anything else → stop and tell the user the valid values are `docker`, `daytona`, `hetzner`
17
+
18
+ 2. **Fork.** Run, via the Bash tool, exactly one command:
19
+
20
+ ```
21
+ agentbox fork --session ${CLAUDE_SESSION_ID} [--provider $ARGUMENTS]
22
+ ```
23
+
24
+ 3. **Report.** In one line, give the user the new box name (parse it from the command output) and confirm their host session is unaffected. Do not summarize the conversation — the fork already carries it.
25
+
26
+ ## Troubleshooting
27
+
28
+ - If agentbox command fails, tell the user to install AgentBox by writing `! npm -g install @madarco/agentbox` in the chat.
29
+ - If `AGENTBOX_RELAY_URL` is set in the environment, you are running *inside* a box. This command is host-only in v1; tell the user box→box fork is not supported yet.
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: agentbox-info
3
+ description: "Spin up isolated sandboxes (\"boxes\") for coding agents, run them in parallel, queue background runs with -i, and push commits safely through the host relay. Use when the user wants to run Claude Code / Codex / OpenCode in a sandbox, start more boxes, attach to a running box, or otherwise operate the `agentbox` CLI on their laptop."
4
+ user-invocable: false
5
+ ---
6
+ <!-- agentbox-managed:v1 -->
7
+
8
+ # AgentBox (host-side)
9
+
10
+ You are operating on the **user's host machine** (laptop / dev workstation), not inside a box. Use the `agentbox` CLI to provision isolated sandboxes for coding agents and to attach to them.
11
+
12
+ If you find yourself *inside* a box (`/workspace` exists and `AGENTBOX_RELAY_URL` is set in the env), this is the wrong skill — use the in-box `/agentbox-setup` skill instead.
13
+
14
+ ## What AgentBox is, in one paragraph
15
+
16
+ AgentBox spins up one isolated sandbox per agent run — a local Docker container (default), a Daytona cloud sandbox (`--provider daytona`), or a Hetzner VPS (`--provider hetzner`). Each box has its own `/workspace`, but the host's `.git/` is shared, so commits made inside the box land on the host immediately. The agent inside the box has **no host credentials** — `git push`, opening URLs in the host browser, capturing checkpoints, and all other host-side operations flow through a small host process called the **relay** that runs alongside the CLI.
17
+
18
+ ## The two starting commands
19
+
20
+ ### `agentbox create`
21
+
22
+ Provision a box and stop. The box exists and is ready, but nothing is launched inside it.
23
+
24
+ ```sh
25
+ agentbox create # docker, auto-named after the workspace
26
+ agentbox create -n review # docker, friendly name
27
+ agentbox create --provider hetzner # cloud VPS (requires `agentbox prepare --provider hetzner` once)
28
+ agentbox create --attach # drop into a shell inside the box after create
29
+ ```
30
+
31
+ Useful flags: `-n <name>` (friendly box name), `--provider docker|daytona|hetzner`, `--attach`, `-w <path>` (workspace to mount; defaults to `cwd`), `--snapshot <ref>` (start from a checkpoint).
32
+
33
+ Non-docker providers require a one-time `agentbox prepare --provider <name>` to bake the base image / snapshot.
34
+
35
+ ### `agentbox claude`
36
+
37
+ Provision (same as `create`) and launch **Claude Code** inside the box, in a detachable tmux session. This is the main entry point most users want.
38
+
39
+ ```sh
40
+ agentbox claude # docker, attaches your terminal
41
+ agentbox claude -n review # second box, named
42
+ agentbox claude --provider hetzner # cloud
43
+ agentbox claude -- --model sonnet # extra args after `--` go to claude itself
44
+ ```
45
+
46
+ While attached: **`Ctrl+a d`** detaches without killing claude. The box keeps running. Reattach with `agentbox claude attach <name|n>`.
47
+
48
+ Variants with the same shape for other agents: **`agentbox codex`**, **`agentbox opencode`**.
49
+
50
+ ## `-i` / `--initial-prompt`: background queue
51
+
52
+ With `-i "<prompt>"`, `agentbox claude` (and `codex` / `opencode`) does **not** attach. It writes a job manifest to `~/.agentbox/queue/<id>.json` and exits immediately, printing the job id and log path. The host relay's queue loop drains these manifests respecting `queue.maxConcurrent` (global config; override per invocation with `--max-running <n>`).
53
+
54
+ Use this to fan out parallel agent runs:
55
+
56
+ ```sh
57
+ agentbox claude -i "fix the failing test in src/auth and open a PR"
58
+ agentbox claude -i "draft a CHANGELOG entry from the last 20 commits"
59
+ agentbox claude -i "audit our dependencies for known CVEs"
60
+ ```
61
+
62
+ Each call returns instantly. The queue drains them concurrently up to `queue.maxConcurrent`. Inspect / attach later:
63
+
64
+ ```sh
65
+ agentbox dashboard # TUI with status + leader-key actions
66
+ agentbox claude attach <name|n> # reattach to a specific box
67
+ ```
68
+
69
+ Caveats: `-i` is currently **docker-only** (cloud sessions only start on attach, so background-mode has no place to seed the prompt). The host must have valid Claude Code credentials.
70
+
71
+ ## Forking the current session into a box
72
+
73
+ From host Claude, run the **`/agentbox`** slash command (optional arg: `docker` | `daytona` | `hetzner`) to snapshot the *current* Claude Code session into a brand-new box that resumes it. With tmux or iTerm it opens in a new terminal tab; otherwise it starts in the background. The host session is unaffected — you get two parallel timelines. The underlying CLI is `agentbox fork` (`agentbox fork --help`); `/agentbox` requires `agentbox install` to have been run once. This is distinct from `-i`, which seeds a *new* prompt rather than resuming the live conversation.
74
+
75
+ ## Driving one agent from another (`drive`, `agent`, `queue wait-for`)
76
+
77
+ When *you* are the host-side agent and want to orchestrate other agents running inside boxes — read what they're doing, send them a prompt, wait until they're done or need input — use these three command families. Everything is stateless / one-shot, and the human-text default switches to machine-friendly JSON with `--json`.
78
+
79
+ ### `agentbox drive <box>` — terminal driving
80
+
81
+ Targets the running tmux session inside a box (auto-picks the agent session: `claude` → `codex` → `opencode` → the only running session; override with `--session <name>`). Provider-uniform — works the same on docker / daytona / hetzner.
82
+
83
+ ```sh
84
+ agentbox drive snapshot 1 # print rendered TUI as plain text
85
+ agentbox drive snapshot 1 --with-cursor # JSON envelope: { session, cols, rows, cursor, screen }
86
+ agentbox drive snapshot 1 --ansi --rows -200:-1 # include color, walk into scrollback
87
+ agentbox drive keypress 1 "<C-c>" # DSL: <Enter>, <C-x>, <Tab>, <F5>, <Up>, etc.
88
+ agentbox drive send-text 1 "hello" # literal text, no DSL parsing, no trailing Enter
89
+ agentbox drive prompt 1 "summarize /workspace/README" # type + Enter (the convenience action)
90
+ agentbox drive wait 1 --text "✓" --timeout 60000 # block until <text> appears on screen
91
+ agentbox drive resize 1 200 60
92
+ ```
93
+
94
+ `keypress` uses a small DSL: `<Enter>`, `<Tab>`, `<Esc>`, `<Space>`, `<BS>`, `<Del>`, `<Up>/<Down>/<Left>/<Right>`, `<Home>/<End>/<PageUp>/<PageDown>`, `<F1>`–`<F12>`, `<C-a>`..`<C-z>`. Use `<<` for a literal `<`. Multiple args concatenate with no spaces (`"ls" "<Enter>"` → `ls\r`).
95
+
96
+ ### `agentbox agent <box>` — agent state introspection (Claude / Codex / OpenCode)
97
+
98
+ Sub-second latency. State source by agent:
99
+
100
+ - **Claude Code**: lifecycle hooks (`UserPromptSubmit`, `PreToolUse`, `Stop`, `Notification`, `ExitPlanMode`, `AskUserQuestion`, `PreCompact`/`PostCompact`, `StopFailure`, `SubagentStart`/`SubagentStop`).
101
+ - **Codex**: tmux-pane scraper inside the box (codex 0.134.0's own hook firing is unreliable; staged hooks remain for the day that's fixed upstream).
102
+ - **OpenCode**: a plugin (`agentbox-state.js`) seeded into the OpenCode config volume, subscribing to OpenCode's event bus.
103
+
104
+ All three feed the same status pipeline; `agent state` / `agent wait-for` work the same regardless of which agent runs inside the box. Reports come from `~/.agentbox/boxes/<id>/status.json` and the relay event stream.
105
+
106
+ ```sh
107
+ agentbox agent state 1 # → working | idle | waiting | end-plan | question | prompt | compacting | error
108
+ agentbox agent state 1 --json # full BoxStatusClaude (state, updatedAt, sessionTitle, plan?, question?)
109
+
110
+ agentbox agent wait-for prompt 1 --timeout 600000 # block until Claude is at the input box, no pending plan/question
111
+ agentbox agent wait-for end-plan 1 # Claude just called ExitPlanMode; user has to approve
112
+ agentbox agent wait-for question 1 # AskUserQuestion picker is up
113
+ agentbox agent wait-for idle 1 # Stop hook fired (turn complete)
114
+ agentbox agent wait-for compacting 1 # Claude is summarizing context (PreCompact fired)
115
+ agentbox agent wait-for error 1 # Claude's turn ended with a failure (StopFailure)
116
+
117
+ agentbox agent get-plan-question 1 # print the plan body OR question + options (human)
118
+ agentbox agent get-plan-question 1 --json # structured payload
119
+ ```
120
+
121
+ The `prompt` state is derived: `idle` AND tmux session alive AND no pending plan/question — i.e. "ready for the next user message". Use it as the natural sync point after sending a new prompt.
122
+
123
+ The `end-plan` and `question` matchers tolerate the race where Claude's `Notification:permission_prompt` hook flips the raw state to `waiting` immediately after the matcher hook fires — both states still match while the plan/question payload is pending, and only the matching `PostToolUse` (handled internally with `--clear-pending`) resets them.
124
+
125
+ ### `agentbox queue wait-for <event>` — queue + box lifecycle
126
+
127
+ ```sh
128
+ agentbox queue wait-for new-box # any new box gets registered
129
+ agentbox queue wait-for empty-queue --timeout 1800000 # all queued/running jobs settled
130
+ agentbox queue wait-for box-running --box review
131
+ agentbox queue wait-for box-paused --box 2
132
+ agentbox queue wait-for box-stopped --box 2
133
+ agentbox queue wait-for job-done --job b45f1603841bd2b5 # terminal status (done/failed/cancelled)
134
+ ```
135
+
136
+ All wait-for commands exit 0 on match, exit 1 on timeout, and accept `--json` for parseable output.
137
+
138
+ ### Recipe: queue a plan, then act per turn
139
+
140
+ This is the canonical "drive a Claude Code from another Claude Code" loop. You queue an initial planning prompt, wait for the plan to land, capture it, decide, send the next message, repeat.
141
+
142
+ ```sh
143
+ # 1. Kick off a box with a planning prompt.
144
+ agentbox claude -n design -i "Plan how to add an OAuth login flow to apps/web, then enter plan mode. Don't start coding."
145
+
146
+ # 2. Wait until Claude is at the ExitPlanMode approval prompt.
147
+ agentbox agent wait-for end-plan design --timeout 600000
148
+
149
+ # 3. Read the plan back as text (or JSON) and decide.
150
+ PLAN=$(agentbox agent get-plan-question design)
151
+ echo "$PLAN"
152
+
153
+ # 4. Approve via tmux — option 1 ("Yes, and use auto mode") is already highlighted.
154
+ agentbox drive keypress design "<Enter>"
155
+
156
+ # 5. Wait for the turn to finish.
157
+ agentbox agent wait-for prompt design --timeout 1200000
158
+
159
+ # 6. Fan out follow-up work to a fresh box, in background, while reviewing this one.
160
+ agentbox claude -i "Write the OAuth provider unit tests in apps/web/test/auth/"
161
+
162
+ # 7. Block until everything settles before reporting back.
163
+ agentbox queue wait-for empty-queue --timeout 3600000
164
+ ```
165
+
166
+ The same shape covers `agent wait-for question` + `agent get-plan-question` (read the choices, send the answer index via `drive keypress 1 "<Down><Enter>"`, then `wait-for prompt`).
167
+
168
+ ### Quick mental model
169
+
170
+ - `drive` = "send keystrokes / read screen" — provider-uniform tmux capture-pane / send-keys.
171
+ - `agent` = "what is the Claude TUI currently doing" — hook-driven, race-free, machine-readable.
172
+ - `queue wait-for` = "block on queue or box lifecycle transitions" — poll-based, no new endpoint.
173
+ - All three commands are **stateless** — safe to invoke from any script, any agent, in parallel.
174
+ - `--json` everywhere. Default human text is for the operator; an agent should pass `--json`.
175
+
176
+ ## Git through the host relay
177
+
178
+ **The box has no SSH keys, GPG keys, or git remote credentials.** Don't ask the user to add any. When an in-box agent (or a script you run inside the box) does `git push` or `git pull`, the AgentBox-provided `agentbox-ctl git` wrapper POSTs a JSON-RPC call to the host relay (`POST /rpc`, bearer-auth, loopback-only). The relay runs the **real** `git push origin …` on the host, using the user's `SSH_AUTH_SOCK`, `~/.gitconfig`, and identity — and streams stdout/stderr back into the box's terminal. The box's exit code matches the host's.
179
+
180
+ Implications for you, the host-side agent:
181
+
182
+ - Inside the box you can `git commit … && git push` exactly as normal. No setup needed.
183
+ - Pushes are gated host-side: the relay can require a confirm prompt for destructive operations (the user sees it in the dashboard footer, ~25 s TTL). If a push appears to hang, tell the user to check the dashboard.
184
+ - The relay process is started lazily by the first `agentbox create` / `agentbox claude` and persists across runs (PID at `~/.agentbox/relay.pid`, log at `~/.agentbox/relay.log`). You normally don't need to manage it.
185
+
186
+ ## Other commands worth knowing
187
+
188
+ | Command | What it does |
189
+ | --- | --- |
190
+ | `agentbox dashboard` | TUI status + switcher across all boxes. The leader is **`Ctrl+a`** (e.g. `Ctrl+a u` opens the box's web URL; `Ctrl+a s` opens the in-box browser; `Ctrl+a q` quits). |
191
+ | `agentbox shell [n\|name]` | Interactive `bash -l` inside the box (also wrapped in tmux by default — detach with `Ctrl+a d`). |
192
+ | `agentbox url [n\|name]` | Open the box's web app URL (`<box-name>.localhost` via Portless) in the host browser. |
193
+ | `agentbox screen [n\|name]` | Open the box's **own** Chromium via VNC — useful for OAuth flows the agent inside the box initiates. |
194
+ | `agentbox code [n\|name]` | Open VS Code / Cursor pointed at the box. |
195
+ | `agentbox prepare --provider <name>` | One-time base image / snapshot build for `daytona` or `hetzner`. With no `--provider`, prints status across all providers. |
196
+ | `agentbox prune --provider <name>` | Clean up orphan boxes / images / snapshots for a provider (docker + daytona supported; hetzner pending). |
197
+
198
+ Per-project numeric index (`1`, `2`, …) and friendly name (`review`, `smoke`) both work wherever `<box>` is accepted. Index `1` is the first box created in the current workspace.
199
+
200
+ ## Operating principles
201
+
202
+ 1. **Never assume the host needs SSH keys forwarded into a box** — git is handled by the relay, by design.
203
+ 2. **Use `-i` whenever the user asks for parallel agent work** rather than spawning multiple foreground sessions. Then point them at `agentbox dashboard` to watch progress.
204
+ 3. **Pick the provider deliberately.** `docker` is the fast default. `--provider hetzner` gives a real VPS (heavier, isolated, requires `agentbox prepare --provider hetzner` once). `--provider daytona` is the managed cloud option.
205
+ 4. **Cross-check before recommending a command.** If a flag isn't listed here, run `agentbox <command> --help` (it's safe and read-only) before suggesting it to the user.
206
+ 5. **`/agentbox-setup` is a different skill.** It runs *inside* a box to generate `/workspace/agentbox.yaml`. Don't conflate it with `/agentbox` (host-side fork) or this reference skill.
207
+
208
+ ## Reference
209
+
210
+ - Full docs live in the repo at `docs/` — start with `docs/architecture.md` and `docs/create-and-checkpoints.md` for the model, `docs/host-relay.md` for the relay, `docs/cloud-providers.md` for the cloud paths.
211
+ - npm package: `@madarco/agentbox` — `npm -g install @madarco/agentbox` (or `npx @madarco/agentbox <command>`).
@@ -0,0 +1,35 @@
1
+ ---
2
+ description: Fork the current Codex session into a new AgentBox box and resume it there (opens in a new terminal tab).
3
+ argument-hint: [provider]
4
+ ---
5
+ <!-- agentbox-managed:v1 -->
6
+
7
+ Fork the current Codex session into a fresh AgentBox box running Codex.
8
+
9
+ Optional provider argument: `$ARGUMENTS` (docker | daytona | hetzner; default docker).
10
+
11
+ ## Steps
12
+
13
+ 1. **Pre-flight (stop on either):**
14
+ - If `AGENTBOX_RELAY_URL` is set in the environment, you are running *inside* a box — box→box fork is not supported yet; stop and tell the user.
15
+ - If `which agentbox` fails, tell the user to install AgentBox (`npm -g install @madarco/agentbox`) and stop.
16
+
17
+ 2. **Find the current Codex session id.** Codex exposes no session-id variable, so resolve it from the most recently written rollout file (that is the live session). Run via your shell tool:
18
+
19
+ ```
20
+ ls -t "$HOME"/.codex/sessions/*/*/*/rollout-*.jsonl 2>/dev/null | head -1 \
21
+ | xargs -I{} basename {} .jsonl \
22
+ | grep -oE '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
23
+ ```
24
+
25
+ That prints the session `<uuid>`. If it prints nothing, stop and tell the user no Codex session was found for this machine.
26
+
27
+ 3. **Resolve the provider flag from `$ARGUMENTS`:** empty → none; `docker` | `daytona` | `hetzner` → `--provider $ARGUMENTS`; anything else → stop and report the valid values.
28
+
29
+ 4. **Fork.** Run, via your shell tool:
30
+
31
+ ```
32
+ agentbox fork --agent codex --session <uuid> [--provider <from step 3>]
33
+ ```
34
+
35
+ 5. **Report** the new box name from the command output. Your current Codex session is unaffected — you now have two parallel timelines.
@@ -0,0 +1,26 @@
1
+ ---
2
+ description: Spawn a parallel AgentBox box running OpenCode for this project (opens in a new terminal tab). Note - the current OpenCode session is not resumed yet; this starts a fresh session.
3
+ ---
4
+ <!-- agentbox-managed:v1 -->
5
+
6
+ Spawn a new AgentBox box running OpenCode for the current project, in a new terminal tab.
7
+
8
+ Optional provider argument: `$ARGUMENTS` (docker | daytona | hetzner; default docker).
9
+
10
+ **Note:** resuming an OpenCode session into a box isn't supported yet (sessions live in a shared SQLite DB), so this starts a **fresh** OpenCode session in the box — it does not carry the current conversation.
11
+
12
+ ## Steps
13
+
14
+ 1. **Pre-flight (stop on either):**
15
+ - If `AGENTBOX_RELAY_URL` is set in the environment, you are running *inside* a box — not supported; stop and tell the user.
16
+ - If `which agentbox` fails, tell the user to install AgentBox (`npm -g install @madarco/agentbox`) and stop.
17
+
18
+ 2. **Resolve the provider flag from `$ARGUMENTS`:** empty → none; `docker` | `daytona` | `hetzner` → `--provider $ARGUMENTS`; anything else → stop and report the valid values.
19
+
20
+ 3. **Fork.** Run, via your shell tool:
21
+
22
+ ```
23
+ agentbox fork --agent opencode [--provider <from step 2>]
24
+ ```
25
+
26
+ 4. **Report** the new box name from the command output.
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- buildCloudAttachInnerCommand,
4
- cloudAgentAttach
5
- } from "./chunk-7KOEFGN2.js";
6
- import "./chunk-NAVL4R34.js";
7
- import "./chunk-UK72UQ5U.js";
8
- export {
9
- buildCloudAttachInnerCommand,
10
- cloudAgentAttach
11
- };
12
- //# sourceMappingURL=_cloud-attach-DMVH6GWO.js.map