@madarco/agentbox 0.18.0 → 0.19.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 (59) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +4 -3
  3. package/dist/{_cloud-attach-3UC3IL62.js → _cloud-attach-YM2KOWHO.js} +4 -4
  4. package/dist/{chunk-6QFPYU4Z.js → chunk-7K2A3NLE.js} +8 -5
  5. package/dist/chunk-7K2A3NLE.js.map +1 -0
  6. package/dist/{chunk-U7IZS2ZP.js → chunk-A5OFRJDI.js} +1313 -213
  7. package/dist/chunk-A5OFRJDI.js.map +1 -0
  8. package/dist/{chunk-5BO6SGMI.js → chunk-JK5V4OLT.js} +7 -7
  9. package/dist/{chunk-IA6YHH52.js → chunk-MODNW54N.js} +6 -3
  10. package/dist/{chunk-IA6YHH52.js.map → chunk-MODNW54N.js.map} +1 -1
  11. package/dist/{chunk-46NXCJ6Z.js → chunk-NXX3KQZ6.js} +2 -2
  12. package/dist/{chunk-3JXSW6PN.js → chunk-P6UT5XGE.js} +2 -2
  13. package/dist/{chunk-OG4KMYOJ.js → chunk-SPUUOEW2.js} +273 -54
  14. package/dist/chunk-SPUUOEW2.js.map +1 -0
  15. package/dist/{chunk-XWBFWUY2.js → chunk-Y6PUCLOE.js} +2 -2
  16. package/dist/{dist-CFSKUAS5.js → dist-EKSNZHDY.js} +13 -3
  17. package/dist/{dist-7BS2JS27.js → dist-FTCDWRAL.js} +18 -7
  18. package/dist/dist-FTCDWRAL.js.map +1 -0
  19. package/dist/{dist-4BHW7DCO.js → dist-PRDYMXCX.js} +10 -5
  20. package/dist/dist-PRDYMXCX.js.map +1 -0
  21. package/dist/{dist-3UYQZOAO.js → dist-U2BHTWG4.js} +17 -5
  22. package/dist/dist-U2BHTWG4.js.map +1 -0
  23. package/dist/{dist-T7ESSBCZ.js → dist-VQSZVBT3.js} +20 -6
  24. package/dist/dist-VQSZVBT3.js.map +1 -0
  25. package/dist/index.js +471 -311
  26. package/dist/index.js.map +1 -1
  27. package/dist/{prepared-state-MQHD3M5F-OVABNV66.js → prepared-state-MQHD3M5F-5ZMCNY43.js} +2 -2
  28. package/package.json +5 -5
  29. package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
  30. package/runtime/docker/packages/ctl/dist/bin.cjs +133 -107
  31. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +13 -0
  32. package/runtime/e2b/agentbox-setup-skill.md +1 -1
  33. package/runtime/e2b/ctl.cjs +133 -107
  34. package/runtime/hetzner/agentbox-dockerd-start +13 -0
  35. package/runtime/hetzner/agentbox-setup-skill.md +1 -1
  36. package/runtime/hetzner/ctl.cjs +133 -107
  37. package/runtime/relay/bin.cjs +261 -63
  38. package/runtime/vercel/agentbox-dockerd-start +145 -0
  39. package/runtime/vercel/agentbox-setup-skill.md +1 -1
  40. package/runtime/vercel/ctl.cjs +133 -107
  41. package/runtime/vercel/custom-system-CLAUDE.md +5 -4
  42. package/runtime/vercel/scripts/provision.sh +20 -5
  43. package/share/agentbox-setup/SKILL.md +1 -1
  44. package/share/host-skills/agentbox/SKILL.md +2 -2
  45. package/share/host-skills/codex/agentbox.md +10 -2
  46. package/dist/chunk-6QFPYU4Z.js.map +0 -1
  47. package/dist/chunk-OG4KMYOJ.js.map +0 -1
  48. package/dist/chunk-U7IZS2ZP.js.map +0 -1
  49. package/dist/dist-3UYQZOAO.js.map +0 -1
  50. package/dist/dist-4BHW7DCO.js.map +0 -1
  51. package/dist/dist-7BS2JS27.js.map +0 -1
  52. package/dist/dist-T7ESSBCZ.js.map +0 -1
  53. /package/dist/{_cloud-attach-3UC3IL62.js.map → _cloud-attach-YM2KOWHO.js.map} +0 -0
  54. /package/dist/{chunk-5BO6SGMI.js.map → chunk-JK5V4OLT.js.map} +0 -0
  55. /package/dist/{chunk-46NXCJ6Z.js.map → chunk-NXX3KQZ6.js.map} +0 -0
  56. /package/dist/{chunk-3JXSW6PN.js.map → chunk-P6UT5XGE.js.map} +0 -0
  57. /package/dist/{chunk-XWBFWUY2.js.map → chunk-Y6PUCLOE.js.map} +0 -0
  58. /package/dist/{dist-CFSKUAS5.js.map → dist-EKSNZHDY.js.map} +0 -0
  59. /package/dist/{prepared-state-MQHD3M5F-OVABNV66.js.map → prepared-state-MQHD3M5F-5ZMCNY43.js.map} +0 -0
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env bash
2
+ # Start the in-box dockerd. Launched by the host via
3
+ # `docker exec -d --user root`. Idempotent — safe to call again on
4
+ # `agentbox start`. The storage driver is selected at runtime (see
5
+ # select_storage_driver below): the kernel-native `overlay2` when a probe
6
+ # proves it works on the data-root filesystem, otherwise `fuse-overlayfs`.
7
+ # The chosen driver is written to /etc/docker/daemon.json before launch.
8
+
9
+ set -euo pipefail
10
+
11
+ if pgrep -x dockerd >/dev/null; then
12
+ # dockerd already up — but a prior run may have died after the daemon became
13
+ # ready yet before it widened the socket, leaving it 0660 and unreachable by
14
+ # the unprivileged box user. Re-assert the chmod (see the note on the
15
+ # fresh-start path below) before the idempotent early exit.
16
+ chmod 666 /var/run/docker.sock 2>/dev/null || true
17
+ exit 0
18
+ fi
19
+
20
+ mkdir -p /var/lib/docker /var/run /var/log/agentbox
21
+
22
+ # /var/run lives in the container's writable layer (not a volume), so files
23
+ # written by the previous dockerd run survive `docker stop`/`start`. dockerd
24
+ # refuses to start if `/var/run/docker.pid` exists with a PID in /proc — and
25
+ # after restart, that PID number has been reassigned to (probably) the new
26
+ # `sleep infinity`. Wipe both the pidfile and the stale socket here; pgrep
27
+ # above already confirmed no real dockerd is running.
28
+ rm -f /var/run/docker.pid /var/run/docker.sock
29
+
30
+ # Cgroup v2 + unprivileged DinD on OrbStack/Docker Desktop: the outer
31
+ # container has /sys/fs/cgroup and /proc/sys bind-mounted RO from the host
32
+ # (Docker's standard hardening). We need both writable for dockerd to:
33
+ # * mkdir /sys/fs/cgroup/docker (its own cgroup slice for child containers)
34
+ # * write /proc/sys/net/ipv6/conf/<veth>/disable_ipv6 (default bridge setup)
35
+ # Without these, `docker run` fails with EROFS or "failed to disable IPv6".
36
+ # SYS_ADMIN + the private cgroup namespace let us remount these RW; the
37
+ # writes only affect the box's own namespaces (not the host). Failure is
38
+ # tolerable — some hosts already mount these RW.
39
+ mount -o remount,rw /sys/fs/cgroup 2>/dev/null || true
40
+ mount -o remount,rw /proc/sys 2>/dev/null || true
41
+
42
+ # --- Storage-driver selection -------------------------------------------------
43
+ # The inner dockerd's data root (/var/lib/docker, a Docker named volume) used
44
+ # to be pinned to fuse-overlayfs. fuse-overlayfs is broken on recent kernels
45
+ # (e.g. Docker Desktop's 6.x linuxkit kernel): inner `docker run` fails at
46
+ # execve() with "exec ...: invalid argument". The kernel-native overlay2
47
+ # driver works when the data-root filesystem can carry an overlay mount, which
48
+ # the ext4 named volume can. We pick overlay2 when a probe proves it works,
49
+ # else fall back to fuse-overlayfs.
50
+ #
51
+ # dockerd refuses to switch drivers once its data root is populated, so if the
52
+ # data root is already initialized under one driver we reuse that driver and
53
+ # skip the probe — a box created under one driver never switches.
54
+ DOCKER_DATA_ROOT=/var/lib/docker
55
+ DAEMON_JSON=/etc/docker/daemon.json
56
+
57
+ probe_overlay2() {
58
+ # The kernel overlay filesystem has to exist at all.
59
+ grep -qw overlay /proc/filesystems 2>/dev/null || return 1
60
+
61
+ local probe lower upper work merged ok=1
62
+ # The probe dir MUST live inside the data root so the test overlay is mounted
63
+ # on the SAME filesystem the real graph will use. A probe under /tmp would
64
+ # test the container's overlayfs writable layer — the wrong filesystem.
65
+ probe="$(mktemp -d "$DOCKER_DATA_ROOT/.overlay2-probe.XXXXXX" 2>/dev/null)" || return 1
66
+ lower="$probe/lower"; upper="$probe/upper"; work="$probe/work"; merged="$probe/merged"
67
+ mkdir -p "$lower" "$upper" "$work" "$merged" || { rm -rf "$probe"; return 1; }
68
+
69
+ # Stage a known-good executable so the merged view exposes it.
70
+ cp /bin/true "$lower/probe-bin" 2>/dev/null || { rm -rf "$probe"; return 1; }
71
+ chmod 0755 "$lower/probe-bin" 2>/dev/null || true
72
+
73
+ if mount -t overlay overlay \
74
+ -o "lowerdir=$lower,upperdir=$upper,workdir=$work" "$merged" 2>/dev/null; then
75
+ # The actual fuse-overlayfs failure mode: execve from the merged dir. A
76
+ # successful mount is not enough — fuse-overlayfs mounts fine and only
77
+ # fails here.
78
+ "$merged/probe-bin" >/dev/null 2>&1 || ok=0
79
+ umount "$merged" 2>/dev/null || umount -l "$merged" 2>/dev/null || true
80
+ else
81
+ ok=0
82
+ fi
83
+ rm -rf "$probe"
84
+ [ "$ok" = 1 ]
85
+ }
86
+
87
+ select_storage_driver() {
88
+ # 1. Reuse an already-initialized data root's driver — dockerd cannot switch
89
+ # a populated data root, and this script reruns on every `agentbox start`.
90
+ local has_overlay2=0 has_fuse=0
91
+ [ -d "$DOCKER_DATA_ROOT/overlay2" ] \
92
+ && [ -n "$(ls -A "$DOCKER_DATA_ROOT/overlay2" 2>/dev/null)" ] && has_overlay2=1
93
+ [ -d "$DOCKER_DATA_ROOT/fuse-overlayfs" ] \
94
+ && [ -n "$(ls -A "$DOCKER_DATA_ROOT/fuse-overlayfs" 2>/dev/null)" ] && has_fuse=1
95
+ if [ "$has_overlay2" = 1 ]; then echo "overlay2"; return 0; fi
96
+ if [ "$has_fuse" = 1 ]; then echo "fuse-overlayfs"; return 0; fi
97
+
98
+ # 2. Fresh data root: probe overlay2 against the data-root filesystem.
99
+ if probe_overlay2; then echo "overlay2"; return 0; fi
100
+ echo "fuse-overlayfs"
101
+ }
102
+
103
+ # Sweep any leaked probe dir from a hard-killed previous run (cosmetic; the
104
+ # driver subdir checks above ignore it, and dockerd ignores non-driver dirs).
105
+ rm -rf "$DOCKER_DATA_ROOT"/.overlay2-probe.* 2>/dev/null || true
106
+
107
+ STORAGE_DRIVER="$(select_storage_driver)"
108
+
109
+ # Write daemon.json with the resolved driver. `iptables: true` stays for inner
110
+ # bridge networking. Rewritten every start, but the driver is stable (step 1
111
+ # above), so this never causes a mid-life driver switch.
112
+ mkdir -p /etc/docker
113
+ printf '%s\n' \
114
+ "{ \"storage-driver\": \"$STORAGE_DRIVER\", \"iptables\": true }" \
115
+ > "$DAEMON_JSON"
116
+ # Truncate dockerd.log fresh for this start, marker line first; dockerd appends.
117
+ echo "agentbox-dockerd-start: storage-driver=$STORAGE_DRIVER" \
118
+ > /var/log/agentbox/dockerd.log
119
+ # --- end storage-driver selection --------------------------------------------
120
+
121
+ # nohup + & + disown lets us survive the `docker exec -d` returning. dockerd
122
+ # reads /etc/docker/daemon.json on its own; no flags here keeps the start path
123
+ # debuggable from inside the container (just edit the file and restart).
124
+ nohup dockerd >>/var/log/agentbox/dockerd.log 2>&1 &
125
+
126
+ # Wait for the socket to become accept()-able. Bound by ~30s — first start has
127
+ # to initialize iptables chains and the storage graphdriver (fuse-overlayfs is
128
+ # noticeably slower to initialize than overlay2).
129
+ for _ in $(seq 1 300); do
130
+ if [ -S /var/run/docker.sock ] \
131
+ && docker -H unix:///var/run/docker.sock info >/dev/null 2>&1; then
132
+ break
133
+ fi
134
+ sleep 0.1
135
+ done
136
+
137
+ # Open the socket to the unprivileged box user. dockerd creates it root:docker
138
+ # 0660; the in-box agent and the ctl supervisor's `image:` services run as the
139
+ # box user, whose already-running session may not carry the docker group, so
140
+ # widen to 0666. Single-tenant box, so this is safe; correctly timed here (run
141
+ # as root, right after the socket is ready) so the cloud launcher's poll — which
142
+ # runs `docker info` as the box user — can succeed.
143
+ chmod 666 /var/run/docker.sock 2>/dev/null || true
144
+
145
+ disown -a
@@ -276,7 +276,7 @@ On Vercel: this actually STOPS the sandbox, so warn the user about it. Also the
276
276
 
277
277
  - For Nextjs/Vite/Tasnstack projects, makes sure to forward also websocket for hot reload.
278
278
 
279
- - Service like flask, nextjs, BETTER_AUTH_URL, NEXT_PUBLIC_APP_URL should use the `<boxname>.localhost` url for the local development so that on the host it will use the same url as the box. Render this automatically instead of hand-writing `sed` — see section 6c.
279
+ - 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.
280
280
 
281
281
  - 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).
282
282