@madarco/agentbox 0.19.0 → 0.20.1

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 (49) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/{_cloud-attach-YM2KOWHO.js → _cloud-attach-MH7NKIZY.js} +7 -5
  3. package/dist/{chunk-SPUUOEW2.js → chunk-3465NDRZ.js} +98 -9
  4. package/dist/chunk-3465NDRZ.js.map +1 -0
  5. package/dist/{chunk-JK5V4OLT.js → chunk-4ATVA3RM.js} +194 -34
  6. package/dist/chunk-4ATVA3RM.js.map +1 -0
  7. package/dist/{chunk-Y6PUCLOE.js → chunk-52LKNUY7.js} +5 -2
  8. package/dist/chunk-52LKNUY7.js.map +1 -0
  9. package/dist/{chunk-A5OFRJDI.js → chunk-5N7GA2X7.js} +133 -97
  10. package/dist/chunk-5N7GA2X7.js.map +1 -0
  11. package/dist/{dist-EKSNZHDY.js → dist-AJWL4WLW.js} +8 -2
  12. package/dist/{dist-VQSZVBT3.js → dist-CTTTHG6U.js} +5 -4
  13. package/dist/{dist-VQSZVBT3.js.map → dist-CTTTHG6U.js.map} +1 -1
  14. package/dist/{dist-U2BHTWG4.js → dist-G5PDFWKH.js} +10 -6
  15. package/dist/dist-G5PDFWKH.js.map +1 -0
  16. package/dist/{dist-FTCDWRAL.js → dist-LUEH7MER.js} +3 -3
  17. package/dist/dist-LUEH7MER.js.map +1 -0
  18. package/dist/{dist-PRDYMXCX.js → dist-T3JIYHCA.js} +3 -3
  19. package/dist/index.js +789 -291
  20. package/dist/index.js.map +1 -1
  21. package/package.json +6 -6
  22. package/runtime/docker/Dockerfile.box +13 -0
  23. package/runtime/docker/packages/ctl/dist/bin.cjs +122 -62
  24. package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +4 -4
  25. package/runtime/e2b/agentbox-dockerd-start +145 -0
  26. package/runtime/e2b/attach-helper.cjs +27 -3
  27. package/runtime/e2b/claude-managed-settings.json +4 -4
  28. package/runtime/e2b/ctl.cjs +122 -62
  29. package/runtime/e2b/scripts/build-template.sh +32 -5
  30. package/runtime/hetzner/claude-managed-settings.json +4 -4
  31. package/runtime/hetzner/ctl.cjs +122 -62
  32. package/runtime/hetzner/scripts/install-box.sh +9 -0
  33. package/runtime/relay/bin.cjs +6 -0
  34. package/runtime/vercel/claude-managed-settings.json +4 -4
  35. package/runtime/vercel/ctl.cjs +122 -62
  36. package/runtime/vercel/scripts/provision.sh +20 -0
  37. package/share/host-skills/agentbox/SKILL.md +2 -2
  38. package/share/host-skills/agentbox-info/SKILL.md +6 -6
  39. package/share/host-skills/codex/agentbox.md +2 -2
  40. package/share/host-skills/opencode/agentbox.md +2 -2
  41. package/dist/chunk-A5OFRJDI.js.map +0 -1
  42. package/dist/chunk-JK5V4OLT.js.map +0 -1
  43. package/dist/chunk-SPUUOEW2.js.map +0 -1
  44. package/dist/chunk-Y6PUCLOE.js.map +0 -1
  45. package/dist/dist-FTCDWRAL.js.map +0 -1
  46. package/dist/dist-U2BHTWG4.js.map +0 -1
  47. /package/dist/{_cloud-attach-YM2KOWHO.js.map → _cloud-attach-MH7NKIZY.js.map} +0 -0
  48. /package/dist/{dist-EKSNZHDY.js.map → dist-AJWL4WLW.js.map} +0 -0
  49. /package/dist/{dist-PRDYMXCX.js.map → dist-T3JIYHCA.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -9,6 +9,89 @@ Entries are generated from the commit history with `/release-notes` and then
9
9
  hand-reviewed — they describe what changed for someone using the `agentbox`
10
10
  CLI, not the raw commits.
11
11
 
12
+ ## [0.20.1] - 2026-06-25
13
+
14
+ ### Added
15
+
16
+ - **git-lfs repos now check out with real content inside boxes.** LFS-tracked
17
+ files land as their actual content instead of broken pointer files (or a
18
+ failed seed) at both create and checkpoint-restore. Covers every provider —
19
+ docker plus the cloud backends (daytona, hetzner, vercel, e2b). Cloud boxes
20
+ carry only the checked-out ref's objects (no creds/network needed in-box);
21
+ pushing box-created LFS objects back is not yet supported. Cloud providers
22
+ need a re-`prepare` to pick up the in-box git-lfs binary.
23
+
24
+ ### Fixed
25
+
26
+ - **Attaching to a box no longer flashes and exits with an unusual terminal.**
27
+ When your terminal isn't in the box's terminfo database (e.g. Ghostty's
28
+ `xterm-ghostty`), `agentbox claude` / `codex` / `opencode` / `shell` attach
29
+ used to flash-quit with "missing or unsuitable terminal"; it now falls back
30
+ to `xterm-256color`. Terminals the box does recognize keep full fidelity.
31
+ Fixed across docker and all cloud providers.
32
+
33
+ ## [0.20.0] - 2026-06-24
34
+
35
+ ### Added
36
+
37
+ - **Boxes resume your running agent across a restart.** When a box stops (or a
38
+ cloud box idle-pauses and resumes), `agentbox start` — and attaching to a
39
+ down box, and cloud idle-wake — now relaunches the agent resuming the *same*
40
+ conversation (`claude --resume`, `codex resume --last`) instead of opening a
41
+ fresh session, so background/`-i` work isn't lost. Verified on docker,
42
+ vercel, and hetzner. Requires a docker image rebuild / cloud re-`prepare`;
43
+ until then it no-ops.
44
+ - **Headless `agentbox claude login` for non-interactive use.** Sign in without
45
+ a TTY (CI, an orchestrating agent) via a two-call protocol:
46
+ `agentbox claude login --headless` prints the approval URL (and a greppable
47
+ `AGENTBOX_LOGIN_URL=` marker), then `agentbox claude login --code <CODE>`
48
+ completes it. Headless mode is auto-selected when stdin is not a TTY;
49
+ interactive login is unchanged.
50
+ - **E2B now runs docker-in-docker by default.** In-box docker is baked into the
51
+ E2B base template and `dockerd` auto-starts on create/resume — nested
52
+ containers work on E2B (full root + namespaces), matching the other cloud
53
+ providers. Re-`prepare --provider e2b` to pick it up.
54
+ - **Configurable E2B session timeout.** New `box.e2bTimeoutMs` config key
55
+ (default 45m, mirrors `box.vercelTimeoutMs`) records the box's real session
56
+ lifetime so the keepalive holds the box open precisely while the agent is
57
+ working.
58
+
59
+ ### Changed
60
+
61
+ - **Non-interactive runs fail fast on a missing or expired Claude login.** The
62
+ `-i` queue preflight and TTY-less foreground runs now check credential
63
+ validity (expiry is consulted on cloud) and exit early with an
64
+ `agentbox claude login` hint, instead of creating a box whose agent silently
65
+ parks on its `/login` screen.
66
+ - **Herdr plugin is discoverable from the marketplace.** The `herdr-plugin.toml`
67
+ manifest moved to the repo root, so the install shorthand is now
68
+ `herdr plugin install madarco/agentbox`.
69
+
70
+ ### Fixed
71
+
72
+ - **Multi-line `-i` seed prompts survive on cloud.** A multi-paragraph seed
73
+ prompt passed to a detached cloud `-i` run was being split into one argument
74
+ per line, killing the agent at launch; prompts are now encoded so embedded
75
+ newlines are preserved.
76
+ - **`-i` fan-out reliably opens its Herdr terminal.** Concurrent box launches no
77
+ longer trip "herdr gave no pane id" — JSON-RPC replies are now matched by
78
+ request id (ignoring interleaved notifications), and pane ids with letters
79
+ (`:pA`, `:pB`, …) are accepted.
80
+ - **Cloud `-i` start failures surface instead of reporting done.** A detached
81
+ cloud session that fails to launch (transient SDK error, agent crash, stale
82
+ in-box credentials) is now marked failed with an actionable hint, rather than
83
+ silently writing `status: done` with no agent running.
84
+ - **`agentbox create --provider <cloud> -w ../repo`** now resolves a relative
85
+ workspace path to absolute, fixing the git seed that failed with "does not
86
+ appear to be a git repository".
87
+ - **E2B fixes:** the dashboard attach now forwards the provider env so the
88
+ attach helper gets its inner command (right pane no longer blank); the
89
+ create→attach pre-start no longer hangs the CLI on a blank screen.
90
+ - **Docker Claude config sync** no longer aborts (rsync exit 23) on nested
91
+ symlinked skill dirs that point outside the box, and a box whose shared-volume
92
+ login token was blanked by a failed in-box refresh now re-offers sign-in
93
+ before launch instead of booting into a login error.
94
+
12
95
  ## [0.19.0] - 2026-06-23
13
96
 
14
97
  ### Added
@@ -2,15 +2,17 @@
2
2
  import {
3
3
  buildCloudAttachInnerCommand,
4
4
  cloudAgentAttach,
5
- cloudAgentStartDetached
6
- } from "./chunk-JK5V4OLT.js";
7
- import "./chunk-A5OFRJDI.js";
5
+ cloudAgentStartDetached,
6
+ verifyDetachedSession
7
+ } from "./chunk-4ATVA3RM.js";
8
+ import "./chunk-5N7GA2X7.js";
8
9
  import "./chunk-7K2A3NLE.js";
9
10
  import "./chunk-G3H2L3O2.js";
10
11
  import "./chunk-WJFZJZIM.js";
11
12
  export {
12
13
  buildCloudAttachInnerCommand,
13
14
  cloudAgentAttach,
14
- cloudAgentStartDetached
15
+ cloudAgentStartDetached,
16
+ verifyDetachedSession
15
17
  };
16
- //# sourceMappingURL=_cloud-attach-YM2KOWHO.js.map
18
+ //# sourceMappingURL=_cloud-attach-MH7NKIZY.js.map
@@ -12,6 +12,7 @@ import {
12
12
  SHARED_CLAUDE_VOLUME,
13
13
  SHARED_CODEX_VOLUME,
14
14
  SHARED_OPENCODE_VOLUME,
15
+ TERM_FALLBACK_SNIPPET,
15
16
  buildHostEnvFindArgs,
16
17
  buildHostSyncManifest,
17
18
  buildTmuxConfigShellSnippet,
@@ -42,7 +43,7 @@ import {
42
43
  stageOpencodeStateForUpload,
43
44
  stageOpencodeStaticForUpload,
44
45
  syncClaudeCredentials
45
- } from "./chunk-A5OFRJDI.js";
46
+ } from "./chunk-5N7GA2X7.js";
46
47
  import {
47
48
  DEFAULT_BOX_IMAGE,
48
49
  allocateProjectIndex,
@@ -57,7 +58,7 @@ import {
57
58
  } from "./chunk-7K2A3NLE.js";
58
59
 
59
60
  // ../../packages/sandbox-cloud/dist/index.js
60
- import { basename as basename2 } from "path";
61
+ import { basename as basename2, resolve } from "path";
61
62
  import { chmod, mkdir, writeFile } from "fs/promises";
62
63
  import { dirname } from "path";
63
64
  import { mkdtemp, rm, writeFile as writeFile2 } from "fs/promises";
@@ -90,9 +91,9 @@ import {
90
91
  } from "path";
91
92
  import { posix } from "path";
92
93
  import { execa as execa5 } from "execa";
93
- import { mkdtemp as mkdtemp5, rm as rm6, stat } from "fs/promises";
94
+ import { copyFile, mkdir as mkdir3, mkdtemp as mkdtemp5, rm as rm6, stat } from "fs/promises";
94
95
  import { tmpdir as tmpdir5 } from "os";
95
- import { join as join6 } from "path";
96
+ import { dirname as dirname3, join as join6 } from "path";
96
97
  var CREDENTIALS_VOLUME = "agentbox-credentials";
97
98
  var AGENT_SPECS = [
98
99
  {
@@ -1117,7 +1118,9 @@ async function seedFromGitClone(args) {
1117
1118
  adaptive ? `clone: depth=${String(DEFAULT_BUNDLE_DEPTH)} (default, adaptive)` : initialDepth === null ? "clone: depth=full (configured)" : `clone: depth=${String(initialDepth)} (configured)`
1118
1119
  );
1119
1120
  const cloneBranch = args.useBranch ?? args.fromBranch;
1121
+ const lfsRef = cloneBranch ?? "HEAD";
1120
1122
  await runShallowClone(args.hostRepo, cloneDir, initialDepth, stashRefCreated, cloneBranch);
1123
+ await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
1121
1124
  await tarCloneDir(cloneDir, tarPath);
1122
1125
  if (adaptive && initialDepth !== null) {
1123
1126
  const size = await safeFileSize(tarPath);
@@ -1129,6 +1132,7 @@ async function seedFromGitClone(args) {
1129
1132
  await rm6(cloneDir, { recursive: true, force: true });
1130
1133
  await rm6(tarPath, { force: true });
1131
1134
  await runShallowClone(args.hostRepo, cloneDir, LARGE_BUNDLE_DEPTH, stashRefCreated, cloneBranch);
1135
+ await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
1132
1136
  await tarCloneDir(cloneDir, tarPath);
1133
1137
  }
1134
1138
  }
@@ -1200,6 +1204,7 @@ async function seedFromGitClone(args) {
1200
1204
  }
1201
1205
  var DELTA_TARGET_REF = "refs/agentbox-delta/target";
1202
1206
  var REMOTE_DELTA_BUNDLE = "/tmp/agentbox-delta.bundle";
1207
+ var REMOTE_DELTA_LFS = "/tmp/agentbox-delta-lfs.tar.gz";
1203
1208
  var SHA_RE = /^[0-9a-f]{40}$/;
1204
1209
  async function tryReseedRepoDelta(args) {
1205
1210
  const log = args.onLog ?? (() => {
@@ -1232,6 +1237,7 @@ async function tryReseedRepoDelta(args) {
1232
1237
  const stage = await mkdtemp5(join6(tmpdir5(), "agentbox-delta-"));
1233
1238
  const bundlePath = join6(stage, "delta.bundle");
1234
1239
  const untrackedTarPath = join6(stage, "untracked.tar.gz");
1240
+ const deltaLfsTarPath = join6(stage, "delta-lfs.tar.gz");
1235
1241
  const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
1236
1242
  const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
1237
1243
  let stashRefCreated = false;
@@ -1267,6 +1273,18 @@ async function tryReseedRepoDelta(args) {
1267
1273
  if (untrackedSize > 0) {
1268
1274
  await args.backend.uploadFile(args.handle, untrackedTarPath, REMOTE_UNTRACKED_TAR);
1269
1275
  }
1276
+ const deltaLfsSize = await maybeBuildDeltaLfsTar(
1277
+ args.hostRepo,
1278
+ target,
1279
+ checkpointTip,
1280
+ deltaLfsTarPath
1281
+ );
1282
+ if (deltaLfsSize > 0) {
1283
+ await args.backend.uploadFile(args.handle, deltaLfsTarPath, REMOTE_DELTA_LFS);
1284
+ log(
1285
+ `checkpoint restore: ${args.workspaceDir}: ${String(deltaLfsSize)} B of new git-lfs objects`
1286
+ );
1287
+ }
1270
1288
  log(
1271
1289
  needTarget ? `checkpoint restore: ${args.workspaceDir}: delta bundle (${checkpointTip.slice(0, 8)}..${target.slice(0, 8)})` : `checkpoint restore: ${args.workspaceDir}: no new host commits; re-branch + carry-over only`
1272
1290
  );
@@ -1284,18 +1302,20 @@ async function tryReseedRepoDelta(args) {
1284
1302
  hasUntracked: untrackedSize > 0,
1285
1303
  detectConflicts: true
1286
1304
  });
1305
+ const lfsStep = deltaLfsSize > 0 ? `tar -C ${quoteShellArgv([`${args.workspaceDir}/.git`])} -xzf ${quoteShellArgv([REMOTE_DELTA_LFS])}` : ": # no delta lfs objects";
1287
1306
  const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
1288
1307
  const script = [
1289
1308
  `set -euo pipefail`,
1290
1309
  `cd /tmp`,
1291
1310
  SUDO,
1292
1311
  fetchStep,
1312
+ lfsStep,
1293
1313
  checkoutStep,
1294
1314
  `git -C ${wd} reset --hard ${quoteShellArgv([target])}`,
1295
1315
  setOrigin,
1296
1316
  ...carryOverSteps,
1297
1317
  `git -C ${wd} update-ref -d ${quoteShellArgv([DELTA_TARGET_REF])} || true`,
1298
- `rm -f ${quoteShellArgv([REMOTE_DELTA_BUNDLE])}`
1318
+ `rm -f ${quoteShellArgv([REMOTE_DELTA_BUNDLE])} ${quoteShellArgv([REMOTE_DELTA_LFS])}`
1299
1319
  ].join("\n");
1300
1320
  const r = await args.backend.exec(args.handle, bashScript(script));
1301
1321
  if (r.exitCode !== 0) {
@@ -1336,6 +1356,69 @@ async function tarCloneDir(cloneDir, outPath) {
1336
1356
  env: { ...process.env, COPYFILE_DISABLE: "1" }
1337
1357
  });
1338
1358
  }
1359
+ var LFS_OID_RE = /^[0-9a-f]{64}$/;
1360
+ function lfsObjectRelPath(oid) {
1361
+ return join6("lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid);
1362
+ }
1363
+ async function lfsOidsForRef(hostRepo, ref) {
1364
+ const listed = await execa5("git", ["-C", hostRepo, "lfs", "ls-files", "--long", ref], {
1365
+ reject: false
1366
+ });
1367
+ if (listed.exitCode !== 0) return [];
1368
+ const oids = listed.stdout.split("\n").map((l) => l.trim().split(/\s+/)[0] ?? "").filter((o) => LFS_OID_RE.test(o));
1369
+ return [...new Set(oids)];
1370
+ }
1371
+ async function seedCloneLfsObjects(hostRepo, cloneDir, ref, log) {
1372
+ const tracked = await execa5("git", ["-C", hostRepo, "lfs", "ls-files", "-n", ref], {
1373
+ reject: false
1374
+ });
1375
+ if (tracked.exitCode !== 0 || tracked.stdout.trim().length === 0) return;
1376
+ const fetched = await execa5("git", ["-C", hostRepo, "lfs", "fetch", "origin", ref], {
1377
+ reject: false
1378
+ });
1379
+ if (fetched.exitCode !== 0) {
1380
+ const msg = (fetched.stderr || fetched.stdout || `exit ${String(fetched.exitCode ?? "?")}`).trim().split("\n")[0];
1381
+ log(`git-lfs prefetch for ${ref} skipped (best-effort, continuing): ${msg}`);
1382
+ }
1383
+ const oids = await lfsOidsForRef(hostRepo, ref);
1384
+ let copied = 0;
1385
+ for (const oid of oids) {
1386
+ const rel = lfsObjectRelPath(oid);
1387
+ const dst = join6(cloneDir, ".git", rel);
1388
+ try {
1389
+ await mkdir3(dirname3(dst), { recursive: true });
1390
+ await copyFile(join6(hostRepo, ".git", rel), dst);
1391
+ copied++;
1392
+ } catch {
1393
+ }
1394
+ }
1395
+ if (copied > 0) log(`seeded ${String(copied)} git-lfs object(s) for ${ref} into clone`);
1396
+ }
1397
+ async function maybeBuildDeltaLfsTar(hostRepo, target, checkpointTip, outPath) {
1398
+ const targetOids = await lfsOidsForRef(hostRepo, target);
1399
+ if (targetOids.length === 0) return 0;
1400
+ const have = new Set(await lfsOidsForRef(hostRepo, checkpointTip));
1401
+ const deltaOids = targetOids.filter((o) => !have.has(o));
1402
+ if (deltaOids.length === 0) return 0;
1403
+ await execa5("git", ["-C", hostRepo, "lfs", "fetch", "origin", target], { reject: false });
1404
+ const gitDir = join6(hostRepo, ".git");
1405
+ const relPaths = [];
1406
+ for (const oid of deltaOids) {
1407
+ const rel = lfsObjectRelPath(oid);
1408
+ try {
1409
+ await stat(join6(gitDir, rel));
1410
+ relPaths.push(rel);
1411
+ } catch {
1412
+ }
1413
+ }
1414
+ if (relPaths.length === 0) return 0;
1415
+ const tar = await execa5("tar", ["-C", gitDir, "-czf", outPath, ...relPaths], {
1416
+ env: { ...process.env, COPYFILE_DISABLE: "1" },
1417
+ reject: false
1418
+ });
1419
+ if (tar.exitCode !== 0) return 0;
1420
+ return safeFileSize(outPath);
1421
+ }
1339
1422
  async function safeFileSize(path) {
1340
1423
  try {
1341
1424
  return (await stat(path)).size;
@@ -1658,7 +1741,8 @@ function createCloudProvider(backend, opts = {}) {
1658
1741
  }
1659
1742
  return {
1660
1743
  name: providerName,
1661
- async create(req) {
1744
+ async create(reqRaw) {
1745
+ const req = reqRaw.workspacePath ? { ...reqRaw, workspacePath: resolve(reqRaw.workspacePath) } : reqRaw;
1662
1746
  const log = req.onLog ?? (() => {
1663
1747
  });
1664
1748
  const { id, name, branch } = mintBox(req);
@@ -2230,6 +2314,10 @@ function makeCloudCheckpoint(backend) {
2230
2314
  }
2231
2315
  };
2232
2316
  }
2317
+ function hostTermForCloud() {
2318
+ const t = process.env["TERM"];
2319
+ return t && /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(t) ? t : "xterm-256color";
2320
+ }
2233
2321
  function renderInnerCommand(kind, opts) {
2234
2322
  const sessionName = opts?.sessionName ?? defaultSessionName(kind);
2235
2323
  const fallback = opts?.command ?? defaultCommand(kind, opts);
@@ -2248,8 +2336,8 @@ function renderInnerCommand(kind, opts) {
2248
2336
  `tmux has-session -t ${sessionQ} 2>/dev/null || tmux new-session -d -c ${cwdQ} -s ${sessionQ} ${fallbackQ}`,
2249
2337
  configSnippet
2250
2338
  ];
2251
- if (opts?.detached) return lines.join("; ");
2252
- return [...lines, `exec tmux attach -t ${sessionQ}`].join("; ");
2339
+ if (opts?.detached) return TERM_FALLBACK_SNIPPET + lines.join("; ");
2340
+ return TERM_FALLBACK_SNIPPET + [...lines, `exec tmux attach -t ${sessionQ}`].join("; ");
2253
2341
  }
2254
2342
  function defaultSessionName(kind) {
2255
2343
  switch (kind) {
@@ -2294,6 +2382,7 @@ export {
2294
2382
  removeCloudCheckpointDir,
2295
2383
  probeCloudCheckpoint,
2296
2384
  createCloudProvider,
2385
+ hostTermForCloud,
2297
2386
  renderInnerCommand
2298
2387
  };
2299
- //# sourceMappingURL=chunk-SPUUOEW2.js.map
2388
+ //# sourceMappingURL=chunk-3465NDRZ.js.map