@madarco/agentbox 0.23.5 → 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.
Files changed (180) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -2
  4. package/dist/{_cloud-attach-D4OQO5AJ.js → _cloud-attach-T6GPR6LJ.js} +5 -5
  5. package/dist/{chunk-KY32JO6J.js → chunk-5KHEH47T.js} +91 -79
  6. package/dist/chunk-5KHEH47T.js.map +1 -0
  7. package/dist/{chunk-YRTM3KNT.js → chunk-6U2S6QWD.js} +219 -18
  8. package/dist/chunk-6U2S6QWD.js.map +1 -0
  9. package/dist/{chunk-JYEZ6Q5M.js → chunk-DEDTPG2D.js} +874 -146
  10. package/dist/chunk-DEDTPG2D.js.map +1 -0
  11. package/dist/chunk-G3H2L3O2.js +0 -0
  12. package/dist/{chunk-JNY5GPIM.js → chunk-I654PBHA.js} +290 -330
  13. package/dist/chunk-I654PBHA.js.map +1 -0
  14. package/dist/{chunk-6KOQRSHH.js → chunk-K2EDQGZP.js} +18 -4
  15. package/dist/chunk-K2EDQGZP.js.map +1 -0
  16. package/dist/{chunk-KZWJMNLP.js → chunk-LC4E2EIZ.js} +3 -3
  17. package/dist/{chunk-KZWJMNLP.js.map → chunk-LC4E2EIZ.js.map} +1 -1
  18. package/dist/{chunk-DADOEMXP.js → chunk-NACA6AM7.js} +183 -49
  19. package/dist/chunk-NACA6AM7.js.map +1 -0
  20. package/dist/{chunk-FX32NZD4.js → chunk-RYQLFKCP.js} +20 -10
  21. package/dist/chunk-RYQLFKCP.js.map +1 -0
  22. package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
  23. package/dist/chunk-UIRBYL4G.js.map +1 -0
  24. package/dist/chunk-WJFZJZIM.js +0 -0
  25. package/dist/chunk-WLHJZPFJ.js +845 -0
  26. package/dist/chunk-WLHJZPFJ.js.map +1 -0
  27. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  28. package/dist/dist-3KIJ2KQ2.js +1437 -0
  29. package/dist/dist-3KIJ2KQ2.js.map +1 -0
  30. package/dist/{dist-564EDHFF.js → dist-7OUOHQPA.js} +196 -151
  31. package/dist/dist-7OUOHQPA.js.map +1 -0
  32. package/dist/{dist-CAT2TN75.js → dist-B7TNWGVG.js} +8 -4
  33. package/dist/{dist-UDQMBWYW.js → dist-KYV3LEHG.js} +10 -6
  34. package/dist/{dist-EAR4BLL2.js → dist-PHYCFYKH.js} +37 -17
  35. package/dist/dist-PHYCFYKH.js.map +1 -0
  36. package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
  37. package/dist/{dist-O5Y4X4C5.js → dist-Z7KEPQC7.js} +6 -6
  38. package/dist/index.js +2560 -1108
  39. package/dist/index.js.map +1 -1
  40. package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
  41. package/package.json +28 -28
  42. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  43. package/runtime/_shared/agentbox-codex-hooks.json +1 -1
  44. package/runtime/_shared/agentbox-dockerd-start +0 -0
  45. package/runtime/_shared/agentbox-open +0 -0
  46. package/runtime/_shared/agentbox-portless-trust +0 -0
  47. package/runtime/_shared/agentbox-vnc-start +0 -0
  48. package/runtime/_shared/ctl.cjs +468 -97
  49. package/runtime/_shared/gh-shim +0 -0
  50. package/runtime/_shared/git-shim +53 -3
  51. package/runtime/_shared/linear-shim +0 -0
  52. package/runtime/_shared/ntn-shim +0 -0
  53. package/runtime/daytona/custom-system-CLAUDE.md +1 -1
  54. package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
  55. package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
  56. package/runtime/digitalocean/agentbox-dockerd-start +145 -0
  57. package/runtime/digitalocean/agentbox-open +28 -0
  58. package/runtime/digitalocean/agentbox-portless-trust +82 -0
  59. package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
  60. package/runtime/digitalocean/agentbox-vnc-start +102 -0
  61. package/runtime/digitalocean/claude-managed-settings.json +116 -0
  62. package/runtime/digitalocean/ctl.cjs +27852 -0
  63. package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
  64. package/runtime/digitalocean/gh-shim +344 -0
  65. package/runtime/digitalocean/git-shim +181 -0
  66. package/runtime/digitalocean/linear-shim +181 -0
  67. package/runtime/digitalocean/ntn-shim +95 -0
  68. package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
  69. package/runtime/digitalocean/scripts/install-box.sh +462 -0
  70. package/runtime/docker/Dockerfile.box +5 -0
  71. package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
  72. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  73. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
  74. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  75. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  76. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  77. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
  78. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  79. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  80. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
  81. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  82. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
  83. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  84. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  85. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  86. package/runtime/e2b/agentbox-codex-hooks.json +1 -1
  87. package/runtime/e2b/agentbox-dockerd-start +0 -0
  88. package/runtime/e2b/agentbox-open +0 -0
  89. package/runtime/e2b/agentbox-vnc-start +0 -0
  90. package/runtime/e2b/ctl.cjs +468 -97
  91. package/runtime/e2b/custom-system-CLAUDE.md +6 -3
  92. package/runtime/e2b/gh-shim +0 -0
  93. package/runtime/e2b/git-shim +53 -3
  94. package/runtime/e2b/linear-shim +0 -0
  95. package/runtime/e2b/ntn-shim +0 -0
  96. package/runtime/e2b/scripts/build-template.sh +16 -0
  97. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  98. package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
  99. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  100. package/runtime/hetzner/agentbox-open +0 -0
  101. package/runtime/hetzner/agentbox-portless-trust +0 -0
  102. package/runtime/hetzner/agentbox-vnc-start +0 -0
  103. package/runtime/hetzner/ctl.cjs +468 -97
  104. package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
  105. package/runtime/hetzner/gh-shim +0 -0
  106. package/runtime/hetzner/git-shim +53 -3
  107. package/runtime/hetzner/linear-shim +0 -0
  108. package/runtime/hetzner/ntn-shim +0 -0
  109. package/runtime/hetzner/scripts/install-box.sh +5 -0
  110. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  111. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  113. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  115. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  117. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  119. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  120. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
  121. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  122. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
  124. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
  125. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  126. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
  127. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  128. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  129. package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
  130. package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
  131. package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
  132. package/runtime/hub/apps/hub/{chunk-FSEPYTQ6.js → chunk-3VE7AYVK.js} +594 -145
  133. package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
  134. package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
  135. package/runtime/hub/apps/hub/{chunk-7M6FXZIO.js → chunk-FGBXEXUV.js} +350 -292
  136. package/runtime/hub/apps/hub/{chunk-Z7ZAL24C.js → chunk-YVELHPNY.js} +218 -17
  137. package/runtime/hub/apps/hub/{dist-EKQHCXWE.js → dist-33ZNVTC6.js} +183 -49
  138. package/runtime/hub/apps/hub/{dist-V4TJ44MT.js → dist-4SXAJBOC.js} +195 -150
  139. package/runtime/hub/apps/hub/{dist-QIXUPGPP.js → dist-EPJFN2J3.js} +116 -86
  140. package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
  141. package/runtime/hub/apps/hub/{dist-JGZ55OIJ.js → dist-UJVIROA4.js} +19 -5
  142. package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
  143. package/runtime/hub/apps/hub/{dist-GGWYKXJE.js → dist-YM5J25H6.js} +7 -3
  144. package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
  145. package/runtime/hub/apps/hub/package.json +1 -0
  146. package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-UICXTY25.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
  147. package/runtime/hub/apps/hub/server.js +17 -15
  148. package/runtime/relay/bin.cjs +275 -59
  149. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  150. package/runtime/vercel/agentbox-codex-hooks.json +1 -1
  151. package/runtime/vercel/agentbox-dockerd-start +0 -0
  152. package/runtime/vercel/agentbox-open +0 -0
  153. package/runtime/vercel/agentbox-vnc-start +0 -0
  154. package/runtime/vercel/ctl.cjs +468 -97
  155. package/runtime/vercel/custom-system-CLAUDE.md +3 -2
  156. package/runtime/vercel/gh-shim +0 -0
  157. package/runtime/vercel/git-shim +53 -3
  158. package/runtime/vercel/linear-shim +0 -0
  159. package/runtime/vercel/ntn-shim +0 -0
  160. package/runtime/vercel/scripts/provision.sh +16 -0
  161. package/dist/chunk-6KOQRSHH.js.map +0 -1
  162. package/dist/chunk-DADOEMXP.js.map +0 -1
  163. package/dist/chunk-FX32NZD4.js.map +0 -1
  164. package/dist/chunk-JNY5GPIM.js.map +0 -1
  165. package/dist/chunk-JYEZ6Q5M.js.map +0 -1
  166. package/dist/chunk-KY32JO6J.js.map +0 -1
  167. package/dist/chunk-QT3SHMLY.js.map +0 -1
  168. package/dist/chunk-YRTM3KNT.js.map +0 -1
  169. package/dist/dist-564EDHFF.js.map +0 -1
  170. package/dist/dist-EAR4BLL2.js.map +0 -1
  171. package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
  172. /package/dist/{_cloud-attach-D4OQO5AJ.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
  173. /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
  174. /package/dist/{dist-CAT2TN75.js.map → dist-KYV3LEHG.js.map} +0 -0
  175. /package/dist/{dist-O5Y4X4C5.js.map → dist-T5MXBZGP.js.map} +0 -0
  176. /package/dist/{dist-UDQMBWYW.js.map → dist-Z7KEPQC7.js.map} +0 -0
  177. /package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
  178. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
  179. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
  180. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
File without changes
@@ -7,6 +7,19 @@
7
7
  #
8
8
  # Strict per-op flag whitelist — better safe than compatible. Adding a flag
9
9
  # is a deliberate decision, not a default.
10
+ #
11
+ # INVARIANT: every push/pull/fetch flag on a whitelist must be VALUE-LESS.
12
+ # A flag that takes a value can't be expressed anyway — the glued form
13
+ # (`--depth=1`) fails strict_flags' exact-match regex and the split form
14
+ # (`--depth 1`) has its value caught by refuse_positionals — which is what
15
+ # keeps `--upload-pack=`, `--receive-pack=`, `--exec=` and `-o` out for free.
16
+ # Allowing one would break that. (`clone` is the exception: it parses values
17
+ # explicitly, below.)
18
+ #
19
+ # Deliberately still refused, don't "helpfully" add them: `--delete`/`-d` and
20
+ # `--mirror` (destructive on the remote), `push --prune` (deletes remote refs),
21
+ # `push --force` (use `--force-with-lease`), and `--all` — the relay always
22
+ # passes a positional remote+branch, which `git fetch --all` rejects outright.
10
23
 
11
24
  set -euo pipefail
12
25
 
@@ -16,6 +29,10 @@ set -euo pipefail
16
29
  CTL="${AGENTBOX_CTL_PATH:-/usr/local/bin/agentbox-ctl}"
17
30
  REAL_GIT="${AGENTBOX_REAL_GIT_PATH:-/usr/bin/git}"
18
31
 
32
+ # Output-verbosity flags: value-less, no side effects, accepted by all three
33
+ # network ops. Scripts run under `set -e` reach for these first.
34
+ COMMON_QUIET="--quiet|-q|--verbose|-v|--progress|--no-progress"
35
+
19
36
  die() {
20
37
  printf 'agentbox git shim: %s\n' "$*" >&2
21
38
  exit 2
@@ -66,24 +83,57 @@ fi
66
83
  case "$1" in
67
84
  push)
68
85
  shift
69
- strict_flags "git push" "--force-with-lease" "$@"
86
+ strict_flags "git push" "--force-with-lease|--tags|--dry-run|$COMMON_QUIET" "$@"
70
87
  refuse_positionals "git push" "$@"
71
88
  exec "$CTL" git push -- "$@"
72
89
  ;;
73
90
  pull)
74
91
  shift
75
- strict_flags "git pull" "--ff-only" "$@"
92
+ strict_flags "git pull" "--ff-only|--prune|-p|--tags|--no-tags|$COMMON_QUIET" "$@"
76
93
  refuse_positionals "git pull" "$@"
77
94
  exec "$CTL" git pull -- "$@"
78
95
  ;;
79
96
  fetch)
80
97
  shift
81
- strict_flags "git fetch" "--prune" "$@"
98
+ strict_flags "git fetch" "--prune|-p|--prune-tags|--tags|--no-tags|--force|-f|--dry-run|$COMMON_QUIET" "$@"
82
99
  refuse_positionals "git fetch" "$@"
83
100
  exec "$CTL" git fetch -- "$@"
84
101
  ;;
85
102
  clone)
86
103
  shift
104
+ # A clone whose source is a filesystem path or `file://` URL needs no host
105
+ # credentials, and `agentbox-ctl git clone` only speaks github — so relaying
106
+ # it would be wrong, not merely strict. Fall through to the real git before
107
+ # the flag gate. agentbox's own cloud workspace seeding does exactly this
108
+ # (`git clone --no-checkout --quiet file:///workspace <tmp>`), which is how
109
+ # `agentbox create --provider <cloud>` runs from inside a box.
110
+ #
111
+ # Do NOT try to find "the repo positional" by skipping known flag values:
112
+ # options we don't model take a value too (`--reference <path>`,
113
+ # `--separate-git-dir <path>`, `--upload-pack <cmd>`), and that path would
114
+ # then read as the source — handing the real git a REMOTE clone and slipping
115
+ # both the relay and the whitelist. Instead classify EVERY non-flag token
116
+ # (values included) and only fall through when something is unmistakably
117
+ # local and nothing looks remote. Unknown/ambiguous ⇒ no fall-through ⇒ the
118
+ # strict gate below rejects it loudly. Fail-closed by default.
119
+ clone_local=0
120
+ clone_remote=0
121
+ for arg in "$@"; do
122
+ case "$arg" in
123
+ -*) continue ;;
124
+ esac
125
+ case "$arg" in
126
+ # file:// first: it also matches the `*://*` remote pattern below.
127
+ file://*|/*|./*|../*|~/*) clone_local=1 ;;
128
+ # scheme://, scp-style host:path / user@host:path, and the bare
129
+ # `owner/name` github shorthand that `agentbox-ctl git clone` accepts.
130
+ *://*|*:*|*/*) clone_remote=1 ;;
131
+ esac
132
+ done
133
+ if [ "$clone_local" = "1" ] && [ "$clone_remote" = "0" ]; then
134
+ exec "$REAL_GIT" clone "$@"
135
+ fi
136
+
87
137
  strict_flags "git clone" "--branch|--depth" "$@"
88
138
  # Walk argv: split into (url, dir, flags) so we can hand them to ctl
89
139
  # in commander's expected shape (positionals first, then options).
File without changes
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  You are running inside an AgentBox sandbox: a Daytona Cloud sandbox
4
4
  provisioned just for this box, with docker-in-docker available (run `docker`
5
- directly, no sudo). Your user is `vscode` and you can use passwordless
5
+ and `docker compose` directly, no sudo). Your user is `vscode` and you can use passwordless
6
6
  **sudo** to run commands as root. The whole sandbox is yours — the user's
7
7
  host filesystem is not visible from here and nothing is bind-mounted.
8
8
 
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # Pre-`docker commit` cleanup: strip ephemeral / disposable state so the
3
+ # captured checkpoint image is closer to "warm project state, nothing else".
4
+ #
5
+ # Invoked by the host via `docker exec --user root <container>
6
+ # /usr/local/bin/agentbox-checkpoint-cleanup` right before
7
+ # `docker commit`. Best-effort: every step is allowed to fail (a checkpoint
8
+ # capture should never block on cleanup hiccups).
9
+ #
10
+ # What we DELIBERATELY keep:
11
+ # - /workspace the actual point of the checkpoint
12
+ # - /home/vscode/.npm warm npm cache (next install is fast)
13
+ # - /home/vscode/.cache pnpm/yarn/Cargo/etc. caches
14
+ # - /var/lib/docker in-box dockerd's data root
15
+ # - /home/vscode/.claude the named volume is bind-mounted; image
16
+ # layer never sees it anyway
17
+ set +e
18
+
19
+ # apt: drop downloaded .deb cache and the package index. The index is ~50MB
20
+ # and gets refreshed on the next `apt-get update`; the .deb cache is reusable
21
+ # only if we don't change versions, which we usually do.
22
+ apt-get clean 2>/dev/null
23
+ rm -rf /var/lib/apt/lists/* 2>/dev/null
24
+
25
+ # Throwaway scratch dirs. Preserve /tmp/claude-* — that is the live in-box
26
+ # Claude Code session's working tree (its per-task stdout/stderr files). The
27
+ # agent that triggered this checkpoint *is* that session; deleting its task
28
+ # output mid-run makes its harness see ENOENT, treat the command as failed,
29
+ # and retry the checkpoint (observed: 5 duplicate auto-named checkpoints).
30
+ # Stale claude-* dirs baked into the image are tiny and Claude Code prunes
31
+ # them itself on the next session start.
32
+ find /tmp /var/tmp -mindepth 1 -maxdepth 1 ! -name 'claude-*' -exec rm -rf {} + 2>/dev/null
33
+
34
+ # Logs: truncate (don't delete) so the original file modes / ownerships stay
35
+ # intact for the next run. Targets common rotated archives too. Exclude the
36
+ # `state/` subdir — it holds the idempotent-task marker fallback (used when
37
+ # /var/lib/agentbox isn't writable) and must survive the checkpoint.
38
+ find /var/log -type f \( -name '*.log' -o -name '*.gz' -o -name '*.1' \) \
39
+ -not -path '/var/log/agentbox/state/*' -exec truncate -s0 {} + 2>/dev/null
40
+ find /var/log/agentbox -type f -not -path '/var/log/agentbox/state/*' \
41
+ -exec truncate -s0 {} + 2>/dev/null
42
+
43
+ # Bash history (root + vscode). Re-assert vscode ownership: `: >` run as root
44
+ # (re)creates the file root-owned 0644 when it didn't exist, which the uid-1000
45
+ # vscode user cannot append to, silently dropping all shell history.
46
+ : > /root/.bash_history 2>/dev/null
47
+ : > /home/vscode/.bash_history 2>/dev/null
48
+ chown vscode:vscode /home/vscode/.bash_history 2>/dev/null
49
+ chmod 600 /home/vscode/.bash_history 2>/dev/null
50
+
51
+ # Anthropic's installer writes a transient marker; redundant once the binary
52
+ # is in place. Safe to wipe.
53
+ rm -rf /home/vscode/.claude-installer 2>/dev/null
54
+
55
+ exit 0
@@ -0,0 +1,68 @@
1
+ {
2
+ "description": "AgentBox activity-state hooks (defense-in-depth seed; production state comes from the tmux-pane scraper in packages/ctl/src/codex-scraper.ts). Codex's strict parser allows only `description` and `hooks` at the top level. Loading needs `codex --enable hooks --dangerously-bypass-hook-trust` (both supplied by startCodexSession()).",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "hooks": [
7
+ { "type": "command", "command": "agentbox-ctl codex-state idle >/dev/null 2>&1 &", "timeout": 3 }
8
+ ]
9
+ }
10
+ ],
11
+ "UserPromptSubmit": [
12
+ {
13
+ "hooks": [
14
+ { "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
15
+ ]
16
+ }
17
+ ],
18
+ "PreToolUse": [
19
+ {
20
+ "hooks": [
21
+ { "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
22
+ ]
23
+ }
24
+ ],
25
+ "PermissionRequest": [
26
+ {
27
+ "hooks": [
28
+ { "type": "command", "command": "agentbox-ctl codex-state waiting >/dev/null 2>&1 &", "timeout": 3 }
29
+ ]
30
+ }
31
+ ],
32
+ "PreCompact": [
33
+ {
34
+ "hooks": [
35
+ { "type": "command", "command": "agentbox-ctl codex-state compacting >/dev/null 2>&1 &", "timeout": 3 }
36
+ ]
37
+ }
38
+ ],
39
+ "PostCompact": [
40
+ {
41
+ "hooks": [
42
+ { "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
43
+ ]
44
+ }
45
+ ],
46
+ "SubagentStart": [
47
+ {
48
+ "hooks": [
49
+ { "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
50
+ ]
51
+ }
52
+ ],
53
+ "SubagentStop": [
54
+ {
55
+ "hooks": [
56
+ { "type": "command", "command": "agentbox-ctl codex-state working >/dev/null 2>&1 &", "timeout": 3 }
57
+ ]
58
+ }
59
+ ],
60
+ "Stop": [
61
+ {
62
+ "hooks": [
63
+ { "type": "command", "command": "agentbox-ctl codex-state idle >/dev/null 2>&1 &", "timeout": 3 }
64
+ ]
65
+ }
66
+ ]
67
+ }
68
+ }
@@ -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
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+ # Routes in-box URL opens to `agentbox-ctl open`, which opens the link in the
3
+ # box's own Chromium (agent-browser, visible via `agentbox screen`) and asks
4
+ # the host user — in the footer/dashboard — whether to also open it on the
5
+ # host. This script is installed at /usr/local/bin (earlier in PATH than
6
+ # xdg-utils' /usr/bin/xdg-open, which it is also symlinked over) and is the
7
+ # box's $BROWSER, so `xdg-open`, Claude Code's OAuth flow, `gh`,
8
+ # `git web--browse`, python's webbrowser, etc. all land here.
9
+ #
10
+ # Only http(s) URLs are routed. Anything else (a file path, another scheme)
11
+ # falls through to the real xdg-open, which resolves it locally in the box.
12
+
13
+ set -uo pipefail
14
+
15
+ target="${1:-}"
16
+
17
+ case "$target" in
18
+ http://* | https://*)
19
+ exec agentbox-ctl open "$target"
20
+ ;;
21
+ *)
22
+ if [[ -x /usr/bin/xdg-open ]]; then
23
+ exec /usr/bin/xdg-open "$@"
24
+ fi
25
+ echo "agentbox-open: not an http(s) URL: $target" >&2
26
+ exit 1
27
+ ;;
28
+ esac
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env bash
2
+ # Trust a Portless self-signed CA *inside the box* so every in-box HTTPS client
3
+ # accepts the symmetric `https://<box>.localhost` URL.
4
+ #
5
+ # Why this exists: when the host Portless proxy runs in TLS mode, AgentBox
6
+ # serves the same `https://<box>.localhost` URL inside the box (Hetzner: an
7
+ # in-VPS mirror proxy with its own CA at /root/.portless/ca.pem; Docker: the
8
+ # host CA bind-mounted at /home/vscode/.portless/ca.pem). `portless proxy start`
9
+ # at best trusts the CA in the Linux *system* store — it does NOT populate the
10
+ # per-user NSS database that Chromium / Playwright-Chromium read on Linux, so
11
+ # the VNC browser window and Playwright fail with a cert error. We close that
12
+ # gap here by trusting the CA in BOTH the system store and the box user's NSS db.
13
+ #
14
+ # Usage: agentbox-portless-trust <ca-pem-path> [box-user]
15
+ # box-user defaults to `vscode` (the account that runs the agents / browser).
16
+ # Idempotent and best-effort: prints the installed system CA path on stdout
17
+ # (for NODE_EXTRA_CA_CERTS) and never exits non-zero — a trust failure must not
18
+ # break box create/resume.
19
+
20
+ set -uo pipefail
21
+
22
+ CA_SRC="${1:-}"
23
+ BOX_USER="${2:-vscode}"
24
+ SYS_CA_DST="/usr/local/share/ca-certificates/agentbox-portless-ca.crt"
25
+ NSS_NICK="agentbox-portless-ca"
26
+
27
+ warn() { echo "agentbox-portless-trust: $*" >&2; }
28
+
29
+ if [ -z "$CA_SRC" ] || [ ! -r "$CA_SRC" ]; then
30
+ warn "CA file '$CA_SRC' missing or unreadable — nothing to trust"
31
+ exit 0
32
+ fi
33
+
34
+ # --- System store (curl / wget / system OpenSSL / Node via the bundle) --------
35
+ # Copy to a world-readable path first; the source may be root-only
36
+ # (/root/.portless/ca.pem) and NODE_EXTRA_CA_CERTS / NSS need to read it as the
37
+ # box user.
38
+ if install -m 0644 "$CA_SRC" "$SYS_CA_DST" 2>/dev/null; then
39
+ if command -v update-ca-certificates >/dev/null 2>&1; then
40
+ update-ca-certificates >/dev/null 2>&1 || warn "update-ca-certificates failed (system store may be stale)"
41
+ fi
42
+ else
43
+ warn "could not stage CA to $SYS_CA_DST"
44
+ fi
45
+
46
+ # --- Box user's NSS DB (Chromium / Playwright-Chromium on Linux) --------------
47
+ # Chromium reads sql:\$HOME/.pki/nssdb for the user it runs as. certutil ships in
48
+ # libnss3-tools (baked into the box images).
49
+ if command -v certutil >/dev/null 2>&1; then
50
+ BOX_HOME="$(getent passwd "$BOX_USER" 2>/dev/null | cut -d: -f6)"
51
+ if [ -n "$BOX_HOME" ]; then
52
+ NSSDB="$BOX_HOME/.pki/nssdb"
53
+ # Run the NSS mutations as the box user so the db stays user-owned, even
54
+ # when this script runs as root (the common case: `exec --user root`).
55
+ if [ "$(id -un)" = "$BOX_USER" ]; then
56
+ run_as_user() { bash -c "$1"; }
57
+ else
58
+ run_as_user() { sudo -u "$BOX_USER" -H bash -c "$1"; }
59
+ fi
60
+ run_as_user "mkdir -p '$NSSDB'" 2>/dev/null || warn "could not create $NSSDB"
61
+ # Initialize an empty (password-less) db if none exists yet.
62
+ if [ ! -f "$NSSDB/cert9.db" ]; then
63
+ run_as_user "certutil -d sql:'$NSSDB' -N --empty-password" 2>/dev/null \
64
+ || warn "certutil -N failed"
65
+ fi
66
+ # Delete-then-add keeps re-runs (resume) idempotent.
67
+ run_as_user "certutil -d sql:'$NSSDB' -D -n '$NSS_NICK'" 2>/dev/null || true
68
+ if run_as_user "certutil -d sql:'$NSSDB' -A -t 'C,,' -n '$NSS_NICK' -i '$SYS_CA_DST'" 2>/dev/null; then
69
+ :
70
+ else
71
+ warn "certutil -A failed — in-box Chromium may not trust the CA"
72
+ fi
73
+ else
74
+ warn "user '$BOX_USER' not found — skipping NSS trust"
75
+ fi
76
+ else
77
+ warn "certutil not found (libnss3-tools missing) — skipping NSS trust"
78
+ fi
79
+
80
+ # Emit the system CA path for the caller to wire into NODE_EXTRA_CA_CERTS.
81
+ echo "$SYS_CA_DST"
82
+ exit 0