@madarco/agentbox 0.8.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 (46) hide show
  1. package/dist/{_cloud-attach-T727ZPRV.js → _cloud-attach-ZXBCNWJX.js} +4 -4
  2. package/dist/{chunk-67N47KUS.js → chunk-BXQMIEHC.js} +106 -31
  3. package/dist/chunk-BXQMIEHC.js.map +1 -0
  4. package/dist/{chunk-FODMEHD3.js → chunk-GU5LW4B5.js} +341 -25
  5. package/dist/chunk-GU5LW4B5.js.map +1 -0
  6. package/dist/{chunk-BGK32PZE.js → chunk-KL36BRN4.js} +2 -2
  7. package/dist/chunk-KL36BRN4.js.map +1 -0
  8. package/dist/chunk-MTVI44DW.js +662 -0
  9. package/dist/chunk-MTVI44DW.js.map +1 -0
  10. package/dist/{chunk-6OZDFNBF.js → chunk-NCJP5MTN.js} +201 -44
  11. package/dist/chunk-NCJP5MTN.js.map +1 -0
  12. package/dist/{dist-LOZBWMBF.js → dist-32EZBYG4.js} +9 -3
  13. package/dist/{dist-L4LCG5SJ.js → dist-CX5CGVEB.js} +4 -4
  14. package/dist/{dist-ZODPD2I6.js → dist-GDHP34ZK.js} +8 -10
  15. package/dist/dist-GDHP34ZK.js.map +1 -0
  16. package/dist/dist-XML54CNB.js +849 -0
  17. package/dist/dist-XML54CNB.js.map +1 -0
  18. package/dist/index.js +636 -340
  19. package/dist/index.js.map +1 -1
  20. package/dist/{prepared-state-CL4CWXQA-ME4HSKDE.js → prepared-state-CL4CWXQA-H5THETIM.js} +2 -2
  21. package/package.json +7 -5
  22. package/runtime/docker/packages/ctl/dist/bin.cjs +98 -29
  23. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +15 -1
  24. package/runtime/hetzner/agentbox-vnc-start +15 -1
  25. package/runtime/hetzner/ctl.cjs +98 -29
  26. package/runtime/relay/bin.cjs +229 -37
  27. package/runtime/vercel/agentbox-checkpoint-cleanup +52 -0
  28. package/runtime/vercel/agentbox-codex-hooks.json +68 -0
  29. package/runtime/vercel/agentbox-open +28 -0
  30. package/runtime/vercel/agentbox-setup-skill.md +196 -0
  31. package/runtime/vercel/agentbox-vnc-start +91 -0
  32. package/runtime/vercel/claude-managed-settings.json +115 -0
  33. package/runtime/vercel/ctl.cjs +23466 -0
  34. package/runtime/vercel/custom-system-CLAUDE.md +50 -0
  35. package/runtime/vercel/gh-shim +263 -0
  36. package/runtime/vercel/git-shim +131 -0
  37. package/runtime/vercel/scripts/provision.sh +274 -0
  38. package/dist/chunk-67N47KUS.js.map +0 -1
  39. package/dist/chunk-6OZDFNBF.js.map +0 -1
  40. package/dist/chunk-BGK32PZE.js.map +0 -1
  41. package/dist/chunk-FODMEHD3.js.map +0 -1
  42. package/dist/dist-ZODPD2I6.js.map +0 -1
  43. /package/dist/{_cloud-attach-T727ZPRV.js.map → _cloud-attach-ZXBCNWJX.js.map} +0 -0
  44. /package/dist/{dist-LOZBWMBF.js.map → dist-32EZBYG4.js.map} +0 -0
  45. /package/dist/{dist-L4LCG5SJ.js.map → dist-CX5CGVEB.js.map} +0 -0
  46. /package/dist/{prepared-state-CL4CWXQA-ME4HSKDE.js.map → prepared-state-CL4CWXQA-H5THETIM.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'