@madarco/agentbox 0.20.1 → 0.21.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 (62) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/{_cloud-attach-MH7NKIZY.js → _cloud-attach-U3QJO7IF.js} +4 -4
  3. package/dist/{chunk-52LKNUY7.js → chunk-6JJIKCMY.js} +2 -2
  4. package/dist/{chunk-P6UT5XGE.js → chunk-DBMLOY3T.js} +11 -3
  5. package/dist/{chunk-P6UT5XGE.js.map → chunk-DBMLOY3T.js.map} +1 -1
  6. package/dist/{chunk-NXX3KQZ6.js → chunk-IXQTUXWV.js} +2 -2
  7. package/dist/{chunk-MODNW54N.js → chunk-KTEDFUKM.js} +2 -2
  8. package/dist/{chunk-4ATVA3RM.js → chunk-PX7G4PSI.js} +78 -23
  9. package/dist/chunk-PX7G4PSI.js.map +1 -0
  10. package/dist/{chunk-3465NDRZ.js → chunk-QKL7PCXQ.js} +127 -11
  11. package/dist/chunk-QKL7PCXQ.js.map +1 -0
  12. package/dist/{chunk-7K2A3NLE.js → chunk-X2DWS4KS.js} +14 -6
  13. package/dist/chunk-X2DWS4KS.js.map +1 -0
  14. package/dist/{chunk-5N7GA2X7.js → chunk-YZVFGFYQ.js} +263 -881
  15. package/dist/chunk-YZVFGFYQ.js.map +1 -0
  16. package/dist/{dist-G5PDFWKH.js → dist-FMA5Y25B.js} +5 -5
  17. package/dist/{dist-T3JIYHCA.js → dist-NWKOEWUJ.js} +120 -26
  18. package/dist/dist-NWKOEWUJ.js.map +1 -0
  19. package/dist/{dist-AJWL4WLW.js → dist-SAS4PIHA.js} +13 -3
  20. package/dist/{dist-CTTTHG6U.js → dist-U76JL6HI.js} +5 -5
  21. package/dist/{dist-LUEH7MER.js → dist-UVQJ2BZJ.js} +5 -5
  22. package/dist/index.js +1236 -561
  23. package/dist/index.js.map +1 -1
  24. package/dist/{prepared-state-MQHD3M5F-5ZMCNY43.js → prepared-state-MQHD3M5F-YYVVMTNJ.js} +2 -2
  25. package/package.json +6 -5
  26. package/runtime/daytona/custom-system-CLAUDE.md +13 -3
  27. package/runtime/docker/Dockerfile.box +44 -10
  28. package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +6 -5
  29. package/runtime/docker/packages/ctl/dist/bin.cjs +324 -109
  30. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +82 -0
  31. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +12 -3
  32. package/runtime/e2b/agentbox-setup-skill.md +6 -5
  33. package/runtime/e2b/ctl.cjs +324 -109
  34. package/runtime/e2b/custom-system-CLAUDE.md +12 -3
  35. package/runtime/e2b/scripts/build-template.sh +44 -2
  36. package/runtime/hetzner/agentbox-portless-trust +82 -0
  37. package/runtime/hetzner/agentbox-setup-skill.md +6 -5
  38. package/runtime/hetzner/ctl.cjs +324 -109
  39. package/runtime/hetzner/custom-system-CLAUDE.md +12 -3
  40. package/runtime/hetzner/scripts/install-box.sh +51 -7
  41. package/runtime/relay/bin.cjs +187 -43
  42. package/runtime/vercel/agentbox-setup-skill.md +6 -5
  43. package/runtime/vercel/ctl.cjs +324 -109
  44. package/runtime/vercel/custom-system-CLAUDE.md +12 -3
  45. package/runtime/vercel/scripts/provision.sh +44 -2
  46. package/share/agentbox-setup/SKILL.md +6 -5
  47. package/share/host-skills/agentbox/SKILL.md +14 -0
  48. package/share/host-skills/agentbox-info/SKILL.md +30 -1
  49. package/dist/chunk-3465NDRZ.js.map +0 -1
  50. package/dist/chunk-4ATVA3RM.js.map +0 -1
  51. package/dist/chunk-5N7GA2X7.js.map +0 -1
  52. package/dist/chunk-7K2A3NLE.js.map +0 -1
  53. package/dist/dist-T3JIYHCA.js.map +0 -1
  54. /package/dist/{_cloud-attach-MH7NKIZY.js.map → _cloud-attach-U3QJO7IF.js.map} +0 -0
  55. /package/dist/{chunk-52LKNUY7.js.map → chunk-6JJIKCMY.js.map} +0 -0
  56. /package/dist/{chunk-NXX3KQZ6.js.map → chunk-IXQTUXWV.js.map} +0 -0
  57. /package/dist/{chunk-MODNW54N.js.map → chunk-KTEDFUKM.js.map} +0 -0
  58. /package/dist/{dist-G5PDFWKH.js.map → dist-FMA5Y25B.js.map} +0 -0
  59. /package/dist/{dist-AJWL4WLW.js.map → dist-SAS4PIHA.js.map} +0 -0
  60. /package/dist/{dist-CTTTHG6U.js.map → dist-U76JL6HI.js.map} +0 -0
  61. /package/dist/{dist-LUEH7MER.js.map → dist-UVQJ2BZJ.js.map} +0 -0
  62. /package/dist/{prepared-state-MQHD3M5F-5ZMCNY43.js.map → prepared-state-MQHD3M5F-YYVVMTNJ.js.map} +0 -0
package/dist/index.js CHANGED
@@ -37,8 +37,9 @@ import {
37
37
  statusLine,
38
38
  stripTitleGlyph,
39
39
  subscribePrompts,
40
- uploadImageFileToBox
41
- } from "./chunk-4ATVA3RM.js";
40
+ uploadImageFileToBox,
41
+ withFirewallRepair
42
+ } from "./chunk-PX7G4PSI.js";
42
43
  import {
43
44
  daytonaBackend,
44
45
  ensureDaytonaCredentials,
@@ -46,7 +47,7 @@ import {
46
47
  readDaytonaCredStatus,
47
48
  readPreparedDaytonaState,
48
49
  secretsPath
49
- } from "./chunk-NXX3KQZ6.js";
50
+ } from "./chunk-IXQTUXWV.js";
50
51
  import {
51
52
  detectEgressIp,
52
53
  ensureHetznerCredentials,
@@ -57,7 +58,7 @@ import {
57
58
  readPreparedState,
58
59
  secretsPath as secretsPath2,
59
60
  syncFirewallSource
60
- } from "./chunk-P6UT5XGE.js";
61
+ } from "./chunk-DBMLOY3T.js";
61
62
  import {
62
63
  detectSbx,
63
64
  ensureVercelCredentials,
@@ -66,14 +67,14 @@ import {
66
67
  readPreparedState as readPreparedState2,
67
68
  readVercelCredStatus,
68
69
  secretsPath as secretsPath3
69
- } from "./chunk-MODNW54N.js";
70
+ } from "./chunk-KTEDFUKM.js";
70
71
  import {
71
72
  ensureE2bCredentials,
72
73
  maskKey as maskKey4,
73
74
  readE2bCredStatus,
74
75
  readPreparedState as readPreparedState3,
75
76
  secretsPath as secretsPath4
76
- } from "./chunk-52LKNUY7.js";
77
+ } from "./chunk-6JJIKCMY.js";
77
78
  import {
78
79
  agentSpecsForCloud,
79
80
  currentCloudBaseFingerprint,
@@ -83,7 +84,7 @@ import {
83
84
  probeCloudCheckpoint,
84
85
  resolveCloudCheckpoint,
85
86
  seedAgentVolumesIfFresh
86
- } from "./chunk-3465NDRZ.js";
87
+ } from "./chunk-QKL7PCXQ.js";
87
88
  import {
88
89
  ALL_CONNECTORS,
89
90
  BOX_STATUS_EVENT,
@@ -150,6 +151,7 @@ import {
150
151
  extractOpencodeCredentials,
151
152
  findProjectRoot,
152
153
  formatDetachNotice,
154
+ generateRelayToken,
153
155
  getBoxHostPaths,
154
156
  getDockerContext,
155
157
  getRelayStatus,
@@ -240,7 +242,7 @@ import {
240
242
  waitForTmuxPaneContent,
241
243
  warmUpClaudeCredentials,
242
244
  writeJob
243
- } from "./chunk-5N7GA2X7.js";
245
+ } from "./chunk-YZVFGFYQ.js";
244
246
  import {
245
247
  AmbiguousBoxError,
246
248
  BoxNotFoundError,
@@ -249,16 +251,18 @@ import {
249
251
  UserFacingError,
250
252
  computeDockerContextFingerprint,
251
253
  ensureImage,
254
+ generateBoxId,
252
255
  hostOpenCommand,
253
256
  imageExists,
254
257
  imageInfo,
255
258
  readPreparedDockerState,
256
259
  readState,
257
260
  recordBox,
261
+ recordLastAgent,
258
262
  resolveAgentLauncher,
259
263
  resolveBoxRef,
260
264
  resolveRuleRefs
261
- } from "./chunk-7K2A3NLE.js";
265
+ } from "./chunk-X2DWS4KS.js";
262
266
  import "./chunk-G3H2L3O2.js";
263
267
  import {
264
268
  __export,
@@ -266,11 +270,11 @@ import {
266
270
  } from "./chunk-WJFZJZIM.js";
267
271
 
268
272
  // src/version.ts
269
- var AGENTBOX_VERSION = true ? "0.20.1" : "0.0.0-dev";
270
- var AGENTBOX_COMMIT = true ? "5c78d7dfd" : "dev";
273
+ var AGENTBOX_VERSION = true ? "0.21.0" : "0.0.0-dev";
274
+ var AGENTBOX_COMMIT = true ? "f44445706" : "dev";
271
275
 
272
276
  // src/index.ts
273
- import { Command as Command52 } from "commander";
277
+ import { Command as Command54 } from "commander";
274
278
 
275
279
  // src/engine-override.ts
276
280
  async function applyEngineOverrideAtStartup() {
@@ -1555,7 +1559,7 @@ async function dirSizeCapped(dir, cap, exclude = []) {
1555
1559
 
1556
1560
  // src/lib/carry-resync.ts
1557
1561
  async function resyncCarryFiles(args) {
1558
- const log51 = args.onLog ?? (() => {
1562
+ const log54 = args.onLog ?? (() => {
1559
1563
  });
1560
1564
  const prior = args.box.carry?.entries ?? [];
1561
1565
  if (prior.length === 0) return { recopied: 0, skippedNew: 0 };
@@ -1567,7 +1571,7 @@ async function resyncCarryFiles(args) {
1567
1571
  maxBytes: cfg.effective.box.cpMaxBytes
1568
1572
  });
1569
1573
  if (resolved.errors.length > 0) {
1570
- log51(`carry: resync skipped (resolve errors: ${resolved.errors.length})`);
1574
+ log54(`carry: resync skipped (resolve errors: ${resolved.errors.length})`);
1571
1575
  return { recopied: 0, skippedNew: 0 };
1572
1576
  }
1573
1577
  const priorByDest = new Map(prior.map((e) => [e.dest, e]));
@@ -1584,7 +1588,7 @@ async function resyncCarryFiles(args) {
1584
1588
  if (hash === void 0 || hash !== existing.hash) changed.push(entry);
1585
1589
  }
1586
1590
  if (skippedNew > 0) {
1587
- log51(
1591
+ log54(
1588
1592
  `carry: ${String(skippedNew)} new entry/entries not applied on resync \u2014 recreate the box to approve`
1589
1593
  );
1590
1594
  }
@@ -1592,9 +1596,9 @@ async function resyncCarryFiles(args) {
1592
1596
  const result = await copyCarryPathsToBox({
1593
1597
  container: args.box.container,
1594
1598
  entries: changed,
1595
- onLog: log51
1599
+ onLog: log54
1596
1600
  });
1597
- for (const err of result.errors) log51(`carry: ${err}`);
1601
+ for (const err of result.errors) log54(`carry: ${err}`);
1598
1602
  const updatedByDest = new Map(result.applied.map((e) => [e.dest, e]));
1599
1603
  const mergedEntries = prior.map((e) => updatedByDest.get(e.dest) ?? e);
1600
1604
  await recordBox({
@@ -1602,7 +1606,7 @@ async function resyncCarryFiles(args) {
1602
1606
  carry: { count: mergedEntries.length, entries: mergedEntries }
1603
1607
  });
1604
1608
  if (result.applied.length > 0) {
1605
- log51(`carry: re-copied ${String(result.applied.length)} changed file(s)`);
1609
+ log54(`carry: re-copied ${String(result.applied.length)} changed file(s)`);
1606
1610
  }
1607
1611
  return { recopied: result.applied.length, skippedNew };
1608
1612
  }
@@ -2011,6 +2015,8 @@ async function cloudAgentCreate(args) {
2011
2015
  });
2012
2016
  const nSuffix = typeof result.record.projectIndex === "number" ? ` \xB7 n ${String(result.record.projectIndex)}` : "";
2013
2017
  s.stop(`box ready${nSuffix}`);
2018
+ await recordLastAgent(result.record.id, args.mode).catch(() => {
2019
+ });
2014
2020
  let extraArgs = args.extraArgs;
2015
2021
  if (args.beforeStart) {
2016
2022
  const hook = await args.beforeStart(result.record);
@@ -2034,6 +2040,12 @@ async function cloudAgentCreate(args) {
2034
2040
  attaching: args.attach !== false
2035
2041
  });
2036
2042
  if (args.attach === false) {
2043
+ await cloudAgentStartDetached({
2044
+ box: result.record,
2045
+ binary: args.binary,
2046
+ sessionName: args.sessionName,
2047
+ extraArgs
2048
+ });
2037
2049
  return;
2038
2050
  }
2039
2051
  await cloudAgentAttach({
@@ -2533,7 +2545,7 @@ async function uploadTeleport(input) {
2533
2545
  `provider '${input.provider.name}' does not support file upload; session teleport is unavailable on this backend.`
2534
2546
  );
2535
2547
  }
2536
- await input.provider.uploadPath(input.box, input.resolved.hostFile, `${input.resolved.boxParentDir}/`);
2548
+ await input.provider.uploadPath(input.box, [input.resolved.hostFile], `${input.resolved.boxParentDir}/`);
2537
2549
  input.log?.(
2538
2550
  `teleport: uploaded ${input.resolved.sessionId} into ${input.resolved.boxParentDir}/`
2539
2551
  );
@@ -2779,13 +2791,13 @@ import { basename as basename2 } from "path";
2779
2791
  async function cloudBackendForProvider(provider) {
2780
2792
  switch (provider) {
2781
2793
  case "daytona":
2782
- return (await import("./dist-LUEH7MER.js")).daytonaBackend;
2794
+ return (await import("./dist-UVQJ2BZJ.js")).daytonaBackend;
2783
2795
  case "hetzner":
2784
- return (await import("./dist-T3JIYHCA.js")).hetznerBackend;
2796
+ return (await import("./dist-NWKOEWUJ.js")).hetznerBackend;
2785
2797
  case "vercel":
2786
- return (await import("./dist-CTTTHG6U.js")).vercelBackend;
2798
+ return (await import("./dist-U76JL6HI.js")).vercelBackend;
2787
2799
  case "e2b":
2788
- return (await import("./dist-G5PDFWKH.js")).e2bBackend;
2800
+ return (await import("./dist-FMA5Y25B.js")).e2bBackend;
2789
2801
  default:
2790
2802
  return null;
2791
2803
  }
@@ -2793,13 +2805,13 @@ async function cloudBackendForProvider(provider) {
2793
2805
  async function currentCloudBaseFingerprintLive(provider) {
2794
2806
  switch (provider) {
2795
2807
  case "daytona":
2796
- return (await import("./dist-LUEH7MER.js")).currentDaytonaBaseFingerprintLive();
2808
+ return (await import("./dist-UVQJ2BZJ.js")).currentDaytonaBaseFingerprintLive();
2797
2809
  case "hetzner":
2798
- return (await import("./dist-T3JIYHCA.js")).currentHetznerBaseFingerprintLive();
2810
+ return (await import("./dist-NWKOEWUJ.js")).currentHetznerBaseFingerprintLive();
2799
2811
  case "vercel":
2800
- return (await import("./dist-CTTTHG6U.js")).currentVercelBaseFingerprintLive();
2812
+ return (await import("./dist-U76JL6HI.js")).currentVercelBaseFingerprintLive();
2801
2813
  case "e2b":
2802
- return (await import("./dist-G5PDFWKH.js")).currentE2bBaseFingerprintLive();
2814
+ return (await import("./dist-FMA5Y25B.js")).currentE2bBaseFingerprintLive();
2803
2815
  default:
2804
2816
  return void 0;
2805
2817
  }
@@ -3138,7 +3150,7 @@ async function renderDocker(status) {
3138
3150
  }
3139
3151
  async function daytonaStatus() {
3140
3152
  try {
3141
- const mod = await import("./dist-LUEH7MER.js");
3153
+ const mod = await import("./dist-UVQJ2BZJ.js");
3142
3154
  return await mod.getDaytonaStatus();
3143
3155
  } catch (err) {
3144
3156
  return {
@@ -3149,7 +3161,7 @@ async function daytonaStatus() {
3149
3161
  }
3150
3162
  async function e2bStatus() {
3151
3163
  try {
3152
- const mod = await import("./dist-G5PDFWKH.js");
3164
+ const mod = await import("./dist-FMA5Y25B.js");
3153
3165
  const cred = mod.readE2bCredStatus();
3154
3166
  if (cred.auth === "none") {
3155
3167
  return { configured: false, reason: "not configured \u2014 run `agentbox e2b login`" };
@@ -4115,6 +4127,8 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
4115
4127
  sessionName,
4116
4128
  boxName: result.record.name
4117
4129
  });
4130
+ await recordLastAgent(result.record.id, "claude").catch(() => {
4131
+ });
4118
4132
  if (pendingCreateResyncWarn) prompt_exports.log.warn(pendingCreateResyncWarn);
4119
4133
  const nSuffix = typeof result.record.projectIndex === "number" ? ` \xB7 n ${String(result.record.projectIndex)}` : "";
4120
4134
  s.stop(`box ready${nSuffix}`);
@@ -4184,6 +4198,8 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4184
4198
  if (insp.state === "missing") {
4185
4199
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
4186
4200
  }
4201
+ await recordLastAgent(box.id, "claude").catch(() => {
4202
+ });
4187
4203
  const existing = await claudeSessionInfo(box.container, sessionName);
4188
4204
  if (existing.running) {
4189
4205
  if (resumePrepared) {
@@ -4386,12 +4402,6 @@ var claudeStartCommand = new Command3("start").description(
4386
4402
  }
4387
4403
  }
4388
4404
  if ((box.provider ?? "docker") !== "docker") {
4389
- if (opts.attach === false) {
4390
- (0, prompt_exports.outro)(
4391
- `--no-attach: cloud agent sessions are started lazily on attach. Run: agentbox claude attach ${reattachRef(box)}`
4392
- );
4393
- return;
4394
- }
4395
4405
  const cfg = await loadEffectiveConfig(box.workspacePath, {
4396
4406
  cliOverrides: {
4397
4407
  ...attachIn ? { attach: { openIn: attachIn } } : {},
@@ -4412,10 +4422,21 @@ var claudeStartCommand = new Command3("start").description(
4412
4422
  throw err;
4413
4423
  }
4414
4424
  }
4425
+ const sessionName = opts.sessionName ?? "claude";
4426
+ if (opts.attach === false) {
4427
+ await cloudAgentStartDetached({
4428
+ box,
4429
+ binary: "claude",
4430
+ sessionName,
4431
+ extraArgs: effectiveClaudeArgs
4432
+ });
4433
+ (0, prompt_exports.outro)(`--no-attach: claude started in background. Attach: agentbox claude attach ${reattachRef(box)}`);
4434
+ return;
4435
+ }
4415
4436
  await cloudAgentAttach({
4416
4437
  box,
4417
4438
  binary: "claude",
4418
- sessionName: opts.sessionName ?? "claude",
4439
+ sessionName,
4419
4440
  mode: "claude",
4420
4441
  extraArgs: effectiveClaudeArgs,
4421
4442
  openIn: hostAwareOpenIn(cfg)
@@ -5051,6 +5072,8 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
5051
5072
  codexArgs: effectiveCodexArgs,
5052
5073
  sessionName
5053
5074
  });
5075
+ await recordLastAgent(result.record.id, "codex").catch(() => {
5076
+ });
5054
5077
  const nSuffix = typeof result.record.projectIndex === "number" ? ` \xB7 n ${String(result.record.projectIndex)}` : "";
5055
5078
  s.stop(`box ready${nSuffix}`);
5056
5079
  if (createResyncWarning && resumePrepared) prompt_exports.log.warn(createResyncWarning);
@@ -5111,6 +5134,8 @@ async function startOrAttachCodex(box, codexArgs, opts, resumePrepared) {
5111
5134
  if (insp.state === "missing") {
5112
5135
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
5113
5136
  }
5137
+ await recordLastAgent(box.id, "codex").catch(() => {
5138
+ });
5114
5139
  const existing = await codexSessionInfo(box.container, sessionName);
5115
5140
  if (existing.running) {
5116
5141
  if (resumePrepared) {
@@ -5284,12 +5309,6 @@ var codexStartCommand = new Command4("start").description(
5284
5309
  }
5285
5310
  }
5286
5311
  if ((box.provider ?? "docker") !== "docker") {
5287
- if (opts.attach === false) {
5288
- (0, prompt_exports.outro)(
5289
- `--no-attach: cloud agent sessions are started lazily on attach. Run: agentbox codex attach ${reattachRef(box)}`
5290
- );
5291
- return;
5292
- }
5293
5312
  const cfg = await loadEffectiveConfig(box.workspacePath, {
5294
5313
  cliOverrides: {
5295
5314
  ...attachIn ? { attach: { openIn: attachIn } } : {},
@@ -5310,10 +5329,21 @@ var codexStartCommand = new Command4("start").description(
5310
5329
  throw err;
5311
5330
  }
5312
5331
  }
5332
+ const sessionName = opts.sessionName ?? "codex";
5333
+ if (opts.attach === false) {
5334
+ await cloudAgentStartDetached({
5335
+ box,
5336
+ binary: "codex",
5337
+ sessionName,
5338
+ extraArgs: effectiveCodexArgs
5339
+ });
5340
+ (0, prompt_exports.outro)(`--no-attach: codex started in background. Attach: agentbox codex attach ${reattachRef(box)}`);
5341
+ return;
5342
+ }
5313
5343
  await cloudAgentAttach({
5314
5344
  box,
5315
5345
  binary: "codex",
5316
- sessionName: opts.sessionName ?? "codex",
5346
+ sessionName,
5317
5347
  mode: "codex",
5318
5348
  extraArgs: effectiveCodexArgs,
5319
5349
  openIn: hostAwareOpenIn(cfg)
@@ -5749,6 +5779,8 @@ var opencodeCommand = new Command5("opencode").description("Create a sandboxed b
5749
5779
  opencodeArgs,
5750
5780
  sessionName
5751
5781
  });
5782
+ await recordLastAgent(result.record.id, "opencode").catch(() => {
5783
+ });
5752
5784
  const createResyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
5753
5785
  const nSuffix = typeof result.record.projectIndex === "number" ? ` \xB7 n ${String(result.record.projectIndex)}` : "";
5754
5786
  s.stop(`box ready${nSuffix}`);
@@ -5804,6 +5836,8 @@ async function startOrAttachOpencode(box, opencodeArgs, opts) {
5804
5836
  if (insp.state === "missing") {
5805
5837
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
5806
5838
  }
5839
+ await recordLastAgent(box.id, "opencode").catch(() => {
5840
+ });
5807
5841
  const existing = await opencodeSessionInfo(box.container, sessionName);
5808
5842
  if (existing.running) {
5809
5843
  if (!wantAttach) {
@@ -5931,19 +5965,26 @@ var opencodeStartCommand = new Command5("start").description(
5931
5965
  }
5932
5966
  }
5933
5967
  if ((box.provider ?? "docker") !== "docker") {
5968
+ const cfg = await loadEffectiveConfig(box.workspacePath, {
5969
+ cliOverrides: attachIn ? { attach: { openIn: attachIn } } : {}
5970
+ });
5971
+ const sessionName = opts.sessionName ?? "opencode";
5934
5972
  if (opts.attach === false) {
5973
+ await cloudAgentStartDetached({
5974
+ box,
5975
+ binary: "opencode",
5976
+ sessionName,
5977
+ extraArgs: effectiveOpencodeArgs
5978
+ });
5935
5979
  (0, prompt_exports.outro)(
5936
- `--no-attach: cloud agent sessions are started lazily on attach. Run: agentbox opencode attach ${reattachRef(box)}`
5980
+ `--no-attach: opencode started in background. Attach: agentbox opencode attach ${reattachRef(box)}`
5937
5981
  );
5938
5982
  return;
5939
5983
  }
5940
- const cfg = await loadEffectiveConfig(box.workspacePath, {
5941
- cliOverrides: attachIn ? { attach: { openIn: attachIn } } : {}
5942
- });
5943
5984
  await cloudAgentAttach({
5944
5985
  box,
5945
5986
  binary: "opencode",
5946
- sessionName: opts.sessionName ?? "opencode",
5987
+ sessionName,
5947
5988
  mode: "opencode",
5948
5989
  extraArgs: effectiveOpencodeArgs,
5949
5990
  openIn: hostAwareOpenIn(cfg)
@@ -6102,6 +6143,32 @@ async function dispatchDocker(box, winner, openIn) {
6102
6143
  return;
6103
6144
  }
6104
6145
  }
6146
+ async function attachToRunningAgent(box, opts) {
6147
+ const isCloud = (box.provider ?? "docker") !== "docker";
6148
+ const sessions = isCloud ? await probeCloudAgentSessions(box, opts.sessionName) : await probeDockerAgentSessions(box.container, opts.sessionName);
6149
+ if (sessions.length === 0) return "none";
6150
+ const winner = await pickSession(box.name, sessions);
6151
+ if (winner === null) return "cancelled";
6152
+ if (isCloud) {
6153
+ const attachIn2 = resolveAttachInOption(opts);
6154
+ const cfg2 = await loadEffectiveConfig(box.workspacePath, {
6155
+ cliOverrides: attachIn2 ? { attach: { openIn: attachIn2 } } : {}
6156
+ });
6157
+ await cloudAgentAttach({
6158
+ box,
6159
+ binary: winner.kind,
6160
+ sessionName: winner.sessionName,
6161
+ mode: winner.kind,
6162
+ openIn: hostAwareOpenIn(cfg2)
6163
+ });
6164
+ return;
6165
+ }
6166
+ const attachIn = resolveAttachInOption(opts);
6167
+ const cfg = await loadEffectiveConfig(box.workspacePath, {
6168
+ cliOverrides: attachIn ? { attach: { openIn: attachIn } } : {}
6169
+ });
6170
+ await dispatchDocker(box, winner, hostAwareOpenIn(cfg));
6171
+ }
6105
6172
  var attachCommand = new Command6("attach").description(
6106
6173
  "Attach to the running agent tmux session in a box (claude / codex / opencode). Does not auto-start: if no session is running, exits non-zero with a bare warning. With multiple live sessions, prompts on a TTY and picks the most recently started otherwise."
6107
6174
  ).argument(
@@ -6115,33 +6182,11 @@ var attachCommand = new Command6("attach").description(
6115
6182
  intro5("Attaching to agent session...");
6116
6183
  try {
6117
6184
  const box = await resolveBoxOrExit(idOrName);
6118
- const isCloud = (box.provider ?? "docker") !== "docker";
6119
- const sessions = isCloud ? await probeCloudAgentSessions(box, opts.sessionName) : await probeDockerAgentSessions(box.container, opts.sessionName);
6120
- if (sessions.length === 0) {
6185
+ const result = await attachToRunningAgent(box, opts);
6186
+ if (result === "none") {
6121
6187
  log14.warn(`no agent session running in ${box.name}`);
6122
6188
  process.exit(1);
6123
6189
  }
6124
- const winner = await pickSession(box.name, sessions);
6125
- if (winner === null) return;
6126
- if (isCloud) {
6127
- const attachIn2 = resolveAttachInOption(opts);
6128
- const cfg2 = await loadEffectiveConfig(box.workspacePath, {
6129
- cliOverrides: attachIn2 ? { attach: { openIn: attachIn2 } } : {}
6130
- });
6131
- await cloudAgentAttach({
6132
- box,
6133
- binary: winner.kind,
6134
- sessionName: winner.sessionName,
6135
- mode: winner.kind,
6136
- openIn: hostAwareOpenIn(cfg2)
6137
- });
6138
- return;
6139
- }
6140
- const attachIn = resolveAttachInOption(opts);
6141
- const cfg = await loadEffectiveConfig(box.workspacePath, {
6142
- cliOverrides: attachIn ? { attach: { openIn: attachIn } } : {}
6143
- });
6144
- await dispatchDocker(box, winner, hostAwareOpenIn(cfg));
6145
6190
  } catch (err) {
6146
6191
  handleLifecycleError(err);
6147
6192
  }
@@ -6154,13 +6199,13 @@ var CLOUD_BACKENDS = ["daytona", "hetzner", "vercel", "e2b"];
6154
6199
  async function cloudProviderFor(backend) {
6155
6200
  switch (backend) {
6156
6201
  case "daytona":
6157
- return (await import("./dist-LUEH7MER.js")).daytonaProvider;
6202
+ return (await import("./dist-UVQJ2BZJ.js")).daytonaProvider;
6158
6203
  case "hetzner":
6159
- return (await import("./dist-T3JIYHCA.js")).hetznerProvider;
6204
+ return (await import("./dist-NWKOEWUJ.js")).hetznerProvider;
6160
6205
  case "vercel":
6161
- return (await import("./dist-CTTTHG6U.js")).vercelProvider;
6206
+ return (await import("./dist-U76JL6HI.js")).vercelProvider;
6162
6207
  case "e2b":
6163
- return (await import("./dist-G5PDFWKH.js")).e2bProvider;
6208
+ return (await import("./dist-FMA5Y25B.js")).e2bProvider;
6164
6209
  }
6165
6210
  }
6166
6211
  var CHECKPOINT_NOTICE = "Checkpoint in progress \u2014 the box will be unresponsive for a moment";
@@ -6524,9 +6569,12 @@ var checkpointCommand = new Command7("checkpoint").alias("checkpoints").descript
6524
6569
 
6525
6570
  // src/commands/code.ts
6526
6571
  import { spawn as spawn2 } from "child_process";
6527
- import { log as log16 } from "@clack/prompts";
6572
+ import { log as log17 } from "@clack/prompts";
6528
6573
  import { Command as Command8, InvalidArgumentError } from "commander";
6529
6574
 
6575
+ // src/cloud-ssh.ts
6576
+ import { log as log16 } from "@clack/prompts";
6577
+
6530
6578
  // src/ssh-config.ts
6531
6579
  import { promises as fs } from "fs";
6532
6580
  import { homedir as homedir12 } from "os";
@@ -6541,7 +6589,7 @@ function endMarker(alias) {
6541
6589
  return `# END agentbox cloud box ${alias}`;
6542
6590
  }
6543
6591
  function agentboxAliasFor(boxName) {
6544
- return `agentbox-cloud-${boxName}`;
6592
+ return boxName;
6545
6593
  }
6546
6594
  async function readConfig() {
6547
6595
  try {
@@ -6581,16 +6629,29 @@ function buildBlock(opts) {
6581
6629
  );
6582
6630
  return lines.join("\n");
6583
6631
  }
6632
+ function legacyAliasFor(alias) {
6633
+ return `agentbox-cloud-${alias}`;
6634
+ }
6584
6635
  async function writeAgentboxSshAlias(opts) {
6585
6636
  const path = sshConfigPath();
6586
6637
  await fs.mkdir(join15(homedir12(), ".ssh"), { recursive: true, mode: 448 });
6587
6638
  const existing = await readConfig();
6588
- const stripped = stripBlock(existing, opts.alias);
6639
+ const stripped = stripBlock(stripBlock(existing, opts.alias), legacyAliasFor(opts.alias));
6589
6640
  const separator = stripped.length === 0 || stripped.endsWith("\n") ? "" : "\n";
6590
6641
  const next = `${stripped}${separator}${buildBlock(opts)}`;
6591
6642
  await fs.writeFile(path, next, { mode: 384 });
6592
6643
  await fs.chmod(path, 384);
6593
6644
  }
6645
+ async function hasUnmanagedHostConflict(alias) {
6646
+ const contents = await readConfig();
6647
+ if (contents === "") return false;
6648
+ const foreign = stripBlock(contents, alias);
6649
+ return foreign.split("\n").some((line) => {
6650
+ const m = /^\s*Host\s+(.+?)\s*$/.exec(line);
6651
+ if (!m) return false;
6652
+ return m[1].split(/\s+/).includes(alias);
6653
+ });
6654
+ }
6594
6655
  function parseSshTarget(argv2) {
6595
6656
  let target;
6596
6657
  for (let i = argv2.length - 1; i >= 0; i--) {
@@ -6611,15 +6672,64 @@ function parseSshTarget(argv2) {
6611
6672
  }
6612
6673
  return { ...target, identityFile };
6613
6674
  }
6675
+ async function readAgentboxSshAlias(alias) {
6676
+ const contents = await readConfig();
6677
+ if (contents === "") return void 0;
6678
+ const begin = beginMarker(alias);
6679
+ const end = endMarker(alias);
6680
+ const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6681
+ const match = new RegExp(`^${escape(begin)}\\n([\\s\\S]*?)${escape(end)}`, "m").exec(contents);
6682
+ if (!match) return void 0;
6683
+ const body = match[1] ?? "";
6684
+ const field = (name) => new RegExp(`^\\s*${name}\\s+(.+)$`, "m").exec(body)?.[1]?.trim();
6685
+ return { hostName: field("HostName"), identityFile: field("IdentityFile") };
6686
+ }
6614
6687
  async function removeAgentboxSshAlias(alias) {
6615
6688
  const path = sshConfigPath();
6616
6689
  const existing = await readConfig();
6617
6690
  if (existing === "") return;
6618
- const next = stripBlock(existing, alias);
6691
+ const next = stripBlock(stripBlock(existing, alias), legacyAliasFor(alias));
6619
6692
  if (next === existing) return;
6620
6693
  await fs.writeFile(path, next, { mode: 384 });
6621
6694
  }
6622
6695
 
6696
+ // src/cloud-ssh.ts
6697
+ async function resolveCloudSshTarget(box, opts = {}) {
6698
+ const p = await providerForBox(box);
6699
+ if (!p.buildAttach) {
6700
+ throw new Error(`cloud provider '${p.name}' does not support SSH attach`);
6701
+ }
6702
+ if (opts.bringOnline ?? true) {
6703
+ const state = await p.probeState(box);
6704
+ if (state === "paused") {
6705
+ log16.info("box is paused; resuming");
6706
+ await p.resume(box);
6707
+ } else if (state === "stopped") {
6708
+ log16.info("box is stopped; starting");
6709
+ await p.start(box);
6710
+ } else if (state === "missing") {
6711
+ throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
6712
+ }
6713
+ }
6714
+ const spec = await p.buildAttach(box, "shell", { noTmux: true });
6715
+ const target = parseSshTarget(spec.argv);
6716
+ if (!target) {
6717
+ throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
6718
+ }
6719
+ const alias = agentboxAliasFor(box.name);
6720
+ return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
6721
+ }
6722
+ async function ensureCloudSshAlias(box, opts = {}) {
6723
+ const conn = await resolveCloudSshTarget(box, opts);
6724
+ await writeAgentboxSshAlias({
6725
+ alias: conn.alias,
6726
+ hostname: conn.host,
6727
+ user: conn.user,
6728
+ identityFile: conn.identityFile
6729
+ });
6730
+ return conn;
6731
+ }
6732
+
6623
6733
  // src/commands/code.ts
6624
6734
  function buildCodeCliOverrides(opts) {
6625
6735
  const code = {};
@@ -6665,11 +6775,11 @@ var codeCommand = new Command8("code").description("Open a box in VS Code or Cur
6665
6775
  }
6666
6776
  const exit = await launchIde(folderUri, forcedIde);
6667
6777
  if (exit.code !== 0) {
6668
- log16.error(`failed to launch ${exit.flavor ? ideProfile(exit.flavor).displayName : "IDE"} via ${exit.via} (exit ${String(exit.code)})`);
6778
+ log17.error(`failed to launch ${exit.flavor ? ideProfile(exit.flavor).displayName : "IDE"} via ${exit.via} (exit ${String(exit.code)})`);
6669
6779
  process.stdout.write(folderUri + "\n");
6670
6780
  process.exit(1);
6671
6781
  }
6672
- log16.success(
6782
+ log17.success(
6673
6783
  `opening ${box.name} in ${ideProfile(exit.flavor).displayName} (${exit.via})`
6674
6784
  );
6675
6785
  } catch (err) {
@@ -6679,10 +6789,10 @@ var codeCommand = new Command8("code").description("Open a box in VS Code or Cur
6679
6789
  async function prepareDockerAttach(box, opts) {
6680
6790
  const insp = await inspectBox(box.id);
6681
6791
  if (insp.state === "paused") {
6682
- log16.info(`box is paused; unpausing`);
6792
+ log17.info(`box is paused; unpausing`);
6683
6793
  await unpauseBox(box.id);
6684
6794
  } else if (insp.state === "stopped") {
6685
- log16.info(`box is stopped; starting`);
6795
+ log17.info(`box is stopped; starting`);
6686
6796
  await startBox(box.id);
6687
6797
  } else if (insp.state === "missing") {
6688
6798
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -6693,9 +6803,9 @@ async function prepareDockerAttach(box, opts) {
6693
6803
  const lines = [];
6694
6804
  if (reply.timedOut.length > 0) lines.push(`timed out: ${reply.timedOut.join(", ")}`);
6695
6805
  if (reply.failed.length > 0) lines.push(`failed: ${reply.failed.join(", ")}`);
6696
- log16.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6806
+ log17.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6697
6807
  } else {
6698
- log16.success("all units ready");
6808
+ log17.success("all units ready");
6699
6809
  }
6700
6810
  }
6701
6811
  if (opts.autoTerminals) {
@@ -6705,14 +6815,14 @@ async function prepareDockerAttach(box, opts) {
6705
6815
  regen: opts.regenTasks
6706
6816
  });
6707
6817
  if (r.status === "wrote") {
6708
- log16.info(`wrote /workspace/.vscode/tasks.json (${String(services.length)} service(s))`);
6818
+ log17.info(`wrote /workspace/.vscode/tasks.json (${String(services.length)} service(s))`);
6709
6819
  } else if (r.status === "skipped-user-owned") {
6710
- log16.warn(
6820
+ log17.warn(
6711
6821
  "user-owned .vscode/tasks.json detected; skipping auto-terminals (pass --regen-tasks to overwrite)"
6712
6822
  );
6713
6823
  }
6714
6824
  } catch (err) {
6715
- log16.warn(
6825
+ log17.warn(
6716
6826
  `auto-terminals failed: ${err instanceof Error ? err.message : String(err)}`
6717
6827
  );
6718
6828
  }
@@ -6724,10 +6834,10 @@ async function prepareCloudAttach(box, opts) {
6724
6834
  const p = await providerForBox(box);
6725
6835
  const state = await p.probeState(box);
6726
6836
  if (state === "paused") {
6727
- log16.info("box is paused; resuming");
6837
+ log17.info("box is paused; resuming");
6728
6838
  await p.resume(box);
6729
6839
  } else if (state === "stopped") {
6730
- log16.info("box is stopped; starting");
6840
+ log17.info("box is stopped; starting");
6731
6841
  await p.start(box);
6732
6842
  } else if (state === "missing") {
6733
6843
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -6740,34 +6850,16 @@ async function prepareCloudAttach(box, opts) {
6740
6850
  const lines = [];
6741
6851
  if (reply.timedOut.length > 0) lines.push(`timed out: ${reply.timedOut.join(", ")}`);
6742
6852
  if (reply.failed.length > 0) lines.push(`failed: ${reply.failed.join(", ")}`);
6743
- log16.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6853
+ log17.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6744
6854
  } else {
6745
- log16.success("all units ready");
6855
+ log17.success("all units ready");
6746
6856
  }
6747
6857
  } catch (err) {
6748
- log16.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
6858
+ log17.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
6749
6859
  }
6750
6860
  }
6751
- if (!p.buildAttach) {
6752
- throw new Error(
6753
- `cloud provider '${p.name}' does not support SSH attach \u2014 \`agentbox code\` requires it`
6754
- );
6755
- }
6756
- const spec = await p.buildAttach(box, "shell", { noTmux: true });
6757
- const target = parseSshTarget(spec.argv);
6758
- if (!target) {
6759
- throw new Error(
6760
- `could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`
6761
- );
6762
- }
6763
- const alias = agentboxAliasFor(box.name);
6764
- await writeAgentboxSshAlias({
6765
- alias,
6766
- hostname: target.host,
6767
- user: target.user,
6768
- identityFile: target.identityFile
6769
- });
6770
- log16.info(`updated ~/.ssh/config alias ${alias}`);
6861
+ const { alias } = await ensureCloudSshAlias(box, { bringOnline: false });
6862
+ log17.info(`updated ~/.ssh/config alias ${alias}`);
6771
6863
  return `vscode-remote://ssh-remote+${alias}/workspace`;
6772
6864
  }
6773
6865
  async function runWaitReadyDocker(container, timeoutMs) {
@@ -6792,7 +6884,7 @@ async function launchIde(folderUri, forced) {
6792
6884
  if (code !== null) return code;
6793
6885
  const cursor = await tryCli("cursor", folderUri);
6794
6886
  if (cursor !== null) return cursor;
6795
- log16.warn("neither `code` nor `cursor` found in PATH; falling back to `open vscode://...`");
6887
+ log17.warn("neither `code` nor `cursor` found in PATH; falling back to `open vscode://...`");
6796
6888
  return launchOne("vscode", folderUri);
6797
6889
  }
6798
6890
  async function tryCli(flavor, folderUri) {
@@ -6805,7 +6897,7 @@ async function launchOne(flavor, folderUri) {
6805
6897
  const profile = ideProfile(flavor);
6806
6898
  const cliCode = await spawnCommand(profile.cli, ["--folder-uri", folderUri]);
6807
6899
  if (cliCode !== 127) return { code: cliCode, flavor, via: "cli" };
6808
- log16.warn(
6900
+ log17.warn(
6809
6901
  `\`${profile.cli}\` not found in PATH; falling back to \`${hostOpenCommand()} ${profile.protocolScheme}://...\` (the %2B URL-encoding bug may break attach)`
6810
6902
  );
6811
6903
  const url = `${profile.protocolScheme}://${folderUri.replace(/^vscode-remote:\/\//, "vscode-remote/")}`;
@@ -6813,10 +6905,10 @@ async function launchOne(flavor, folderUri) {
6813
6905
  return { code: fallback, flavor, via: "open" };
6814
6906
  }
6815
6907
  function spawnCommand(cmd, args) {
6816
- return new Promise((resolve5) => {
6908
+ return new Promise((resolve6) => {
6817
6909
  const child = spawn2(cmd, args, { stdio: "ignore" });
6818
- child.once("error", () => resolve5(127));
6819
- child.once("exit", (code) => resolve5(code ?? -1));
6910
+ child.once("error", () => resolve6(127));
6911
+ child.once("exit", (code) => resolve6(code ?? -1));
6820
6912
  });
6821
6913
  }
6822
6914
  async function fetchServiceNamesDocker(container) {
@@ -7109,49 +7201,51 @@ var configCommand = new Command9("config").description("Read / write layered con
7109
7201
 
7110
7202
  // src/commands/cp.ts
7111
7203
  import { resolve as resolve3 } from "path";
7112
- import { log as log17 } from "@clack/prompts";
7204
+ import { log as log18 } from "@clack/prompts";
7113
7205
  import { Command as Command10 } from "commander";
7114
7206
  function collectExclude(val, acc) {
7115
7207
  acc.push(val);
7116
7208
  return acc;
7117
7209
  }
7118
- async function guardUploadSize(hostSrc, boxDst, opts) {
7210
+ async function guardUploadSizes(hostSrcs, boxDst, opts) {
7119
7211
  const tokens = effectiveExcludes(opts.exclude, opts.defaultExcludes);
7120
7212
  const tarPatterns = toTarExcludes(tokens);
7213
+ if (opts.yes) return tarPatterns;
7121
7214
  const cfg = await loadEffectiveConfig(process.cwd());
7122
7215
  const maxBytes = cfg.effective.box.cpMaxBytes;
7123
- const absSrc = resolve3(hostSrc);
7124
- const measured = await measureCopy(absSrc, tokens);
7125
- if (opts.yes || measured.totalBytes <= maxBytes) {
7126
- return tarPatterns;
7127
- }
7128
- const dropped = measured.isDir && opts.defaultExcludes ? ` after default excludes (${effectiveExcludes([], true).join(", ")})` : "";
7129
- const lines = [
7130
- `${hostSrc} is ${fmtBytes(measured.totalBytes)}${dropped}, over the ${fmtBytes(maxBytes)} per-copy limit.`
7131
- ];
7132
- if (measured.isDir) {
7133
- lines.push(
7134
- "Biggest remaining folders/subfolders:",
7135
- ...measured.treeLines,
7136
- "Each copy must be under the limit. To proceed, EITHER:",
7137
- " - copy the heavy folders one at a time, e.g.:"
7138
- );
7139
- for (const child of measured.topChildren.slice(0, 3)) {
7140
- lines.push(` agentbox cp ${hostSrc}/${child.path} ${boxDst}`);
7216
+ for (const hostSrc of hostSrcs) {
7217
+ const absSrc = resolve3(hostSrc);
7218
+ const measured = await measureCopy(absSrc, tokens);
7219
+ if (measured.totalBytes <= maxBytes) continue;
7220
+ const dropped = measured.isDir && opts.defaultExcludes ? ` after default excludes (${effectiveExcludes([], true).join(", ")})` : "";
7221
+ const lines = [
7222
+ `${hostSrc} is ${fmtBytes(measured.totalBytes)}${dropped}, over the ${fmtBytes(maxBytes)} per-copy limit.`
7223
+ ];
7224
+ if (measured.isDir) {
7225
+ lines.push(
7226
+ "Biggest remaining folders/subfolders:",
7227
+ ...measured.treeLines,
7228
+ "Each copy must be under the limit. To proceed, EITHER:",
7229
+ " - copy the heavy folders one at a time, e.g.:"
7230
+ );
7231
+ for (const child of measured.topChildren.slice(0, 3)) {
7232
+ lines.push(` agentbox cp ${hostSrc}/${child.path} ${boxDst}`);
7233
+ }
7234
+ lines.push(
7235
+ " - or drop what you do not need:",
7236
+ ` agentbox cp ${hostSrc} ${boxDst} --exclude=<dir>`,
7237
+ " - or copy the whole thing anyway:",
7238
+ ` agentbox cp ${hostSrc} ${boxDst} --yes`
7239
+ );
7240
+ } else {
7241
+ lines.push(
7242
+ "A single file cannot be split or trimmed. To copy it anyway:",
7243
+ ` agentbox cp ${hostSrc} ${boxDst} --yes`
7244
+ );
7141
7245
  }
7142
- lines.push(
7143
- " - or drop what you do not need:",
7144
- ` agentbox cp ${hostSrc} ${boxDst} --exclude=<dir>`,
7145
- " - or copy the whole thing anyway:",
7146
- ` agentbox cp ${hostSrc} ${boxDst} --yes`
7147
- );
7148
- } else {
7149
- lines.push(
7150
- "A single file cannot be split or trimmed. To copy it anyway:",
7151
- ` agentbox cp ${hostSrc} ${boxDst} --yes`
7152
- );
7246
+ throw new Error(lines.join("\n"));
7153
7247
  }
7154
- throw new Error(lines.join("\n"));
7248
+ return tarPatterns;
7155
7249
  }
7156
7250
  function parseBoxArg(arg) {
7157
7251
  const idx = arg.indexOf(":");
@@ -7163,25 +7257,43 @@ function parseBoxArg(arg) {
7163
7257
  if (p.length === 0) return null;
7164
7258
  return { boxRef: prefix, path: p };
7165
7259
  }
7166
- function parseArgs(src, dst) {
7167
- const srcBox = parseBoxArg(src);
7260
+ function parseArgs(paths) {
7261
+ if (paths.length === 0) {
7262
+ throw new Error("cp requires at least one path.");
7263
+ }
7264
+ const sources = paths.length === 1 ? paths : paths.slice(0, -1);
7265
+ const dst = paths.length === 1 ? void 0 : paths[paths.length - 1];
7266
+ const srcBoxes = sources.map((s) => ({ raw: s, box: parseBoxArg(s) }));
7168
7267
  const dstBox = dst === void 0 ? null : parseBoxArg(dst);
7169
- if (srcBox && dstBox) {
7268
+ const allSrcBox = srcBoxes.every((s) => s.box);
7269
+ const anySrcBox = srcBoxes.some((s) => s.box);
7270
+ if (anySrcBox && !allSrcBox) {
7170
7271
  throw new Error(
7171
- "box-to-box copy is not supported; both arguments look like box paths (`name:/path`)."
7272
+ "all sources must be on the same side; mixing box paths (`name:/path`) and host paths is not supported."
7172
7273
  );
7173
7274
  }
7174
- if (!srcBox && !dstBox) {
7275
+ if (allSrcBox && dstBox) {
7175
7276
  throw new Error(
7176
- "one argument must be a box path of the form `<box>:/path` (e.g. `mybox:/workspace/foo`)."
7277
+ "box-to-box copy is not supported; both sides look like box paths (`name:/path`)."
7177
7278
  );
7178
7279
  }
7179
- if (srcBox) {
7280
+ if (!allSrcBox && !dstBox) {
7281
+ throw new Error(
7282
+ "one side must be a box path of the form `<box>:/path` (e.g. `mybox:/workspace/foo`)."
7283
+ );
7284
+ }
7285
+ if (allSrcBox) {
7286
+ const boxRefs = new Set(srcBoxes.map((s) => s.box.boxRef));
7287
+ if (boxRefs.size > 1) {
7288
+ throw new Error(
7289
+ `all box sources must name the same box; got ${[...boxRefs].join(", ")}.`
7290
+ );
7291
+ }
7180
7292
  return {
7181
7293
  direction: "download",
7182
- boxRef: srcBox.boxRef,
7183
- boxPath: srcBox.path,
7184
- hostPath: dst
7294
+ boxRef: srcBoxes[0].box.boxRef,
7295
+ boxSrcs: srcBoxes.map((s) => s.box.path),
7296
+ hostDst: dst
7185
7297
  };
7186
7298
  }
7187
7299
  if (dst === void 0) {
@@ -7190,13 +7302,13 @@ function parseArgs(src, dst) {
7190
7302
  return {
7191
7303
  direction: "upload",
7192
7304
  boxRef: dstBox.boxRef,
7193
- boxPath: dstBox.path,
7194
- hostPath: src
7305
+ hostSrcs: sources,
7306
+ boxDst: dstBox.path
7195
7307
  };
7196
7308
  }
7197
- var cpCommand = new Command10("cp").description("Copy files between host and box (like `docker cp`; direction picked by `name:` prefix)").argument("<src>", "`box:/path` (download) or host path (upload)").argument(
7198
- "[dst]",
7199
- "`box:/path` (upload) or host path (download); defaults to cwd when downloading"
7309
+ var cpCommand = new Command10("cp").description("Copy files between host and box (like `docker cp`; direction picked by `name:` prefix)").argument(
7310
+ "<paths...>",
7311
+ "source path(s) then destination; `box:/path` marks the box side. With one arg, downloads into cwd. With >=2 sources the destination must be a directory."
7200
7312
  ).option(
7201
7313
  "--exclude <pattern>",
7202
7314
  'exclude paths matching <pattern> (repeatable; tar glob like "*/foo" or a bare dir name)',
@@ -7205,7 +7317,7 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
7205
7317
  ).option(
7206
7318
  "--no-default-excludes",
7207
7319
  `keep the heavy dirs cp drops by default (${effectiveExcludes([], true).join(", ")})`
7208
- ).option("-y, --yes", "copy even if the source is over the box.cpMaxBytes size limit").addHelpText(
7320
+ ).option("-y, --yes", "copy even if a source is over the box.cpMaxBytes size limit").addHelpText(
7209
7321
  "after",
7210
7322
  [
7211
7323
  "",
@@ -7214,28 +7326,30 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
7214
7326
  " agentbox cp mybox:/workspace/.env # download into cwd",
7215
7327
  " agentbox cp ./local.txt mybox:/workspace/ # upload (host path required)",
7216
7328
  " agentbox cp ./dir mybox:/workspace/ # upload directory (recursive)",
7329
+ " agentbox cp a.txt b.txt src/ mybox:/workspace/dest/ # many sources into a dir",
7330
+ " agentbox cp ./*.log mybox:/workspace/logs/ # shell-expanded wildcard",
7217
7331
  ' agentbox cp ./dir mybox:/workspace/ --exclude=.git --exclude="*/cache"'
7218
7332
  ].join("\n")
7219
- ).action(async (src, dst, opts) => {
7333
+ ).action(async (paths, opts) => {
7220
7334
  try {
7221
- const parsed = parseArgs(src, dst);
7335
+ const parsed = parseArgs(paths);
7222
7336
  const box = await resolveBoxOrExit(parsed.boxRef);
7223
7337
  const isCloud = (box.provider ?? "docker") !== "docker";
7224
- const tarPatterns = parsed.direction === "upload" ? await guardUploadSize(parsed.hostPath, `${parsed.boxRef}:${parsed.boxPath}`, opts) : toTarExcludes(effectiveExcludes(opts.exclude, opts.defaultExcludes));
7338
+ const tarPatterns = parsed.direction === "upload" ? await guardUploadSizes(parsed.hostSrcs, `${parsed.boxRef}:${parsed.boxDst}`, opts) : toTarExcludes(effectiveExcludes(opts.exclude, opts.defaultExcludes));
7225
7339
  if (isCloud) {
7226
7340
  const provider = await providerForBox(box);
7227
7341
  if (!provider.uploadPath || !provider.downloadPath) {
7228
7342
  throw new Error(`provider '${provider.name}' does not support cp`);
7229
7343
  }
7230
7344
  if (parsed.direction === "upload") {
7231
- const result = await provider.uploadPath(box, parsed.hostPath, parsed.boxPath, tarPatterns);
7345
+ const result = await provider.uploadPath(box, parsed.hostSrcs, parsed.boxDst, tarPatterns);
7232
7346
  process.stdout.write(`copied to ${box.name}:${result.finalPath}
7233
7347
  `);
7234
7348
  } else {
7235
7349
  const result = await provider.downloadPath(
7236
7350
  box,
7237
- parsed.boxPath,
7238
- parsed.hostPath ?? process.cwd(),
7351
+ parsed.boxSrcs,
7352
+ parsed.hostDst ?? process.cwd(),
7239
7353
  tarPatterns
7240
7354
  );
7241
7355
  process.stdout.write(`copied to ${result.finalPath}
@@ -7245,18 +7359,18 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
7245
7359
  }
7246
7360
  const insp = await inspectBox(box.id);
7247
7361
  if (insp.state === "paused") {
7248
- log17.info("box is paused; unpausing");
7362
+ log18.info("box is paused; unpausing");
7249
7363
  await unpauseBox(box.id);
7250
7364
  } else if (insp.state === "stopped") {
7251
- log17.info("box is stopped; starting");
7365
+ log18.info("box is stopped; starting");
7252
7366
  await startBox(box.id);
7253
7367
  } else if (insp.state === "missing") {
7254
7368
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
7255
7369
  }
7256
7370
  if (parsed.direction === "upload") {
7257
- const result = await uploadToBox(box, parsed.hostPath, parsed.boxPath, tarPatterns);
7371
+ const result = await uploadToBox(box, parsed.hostSrcs, parsed.boxDst, tarPatterns);
7258
7372
  if (result.warn) {
7259
- log17.warn(`copied to ${box.name}:${result.finalPath}, but ${result.warn}`);
7373
+ log18.warn(`copied to ${box.name}:${result.finalPath}, but ${result.warn}`);
7260
7374
  } else {
7261
7375
  process.stdout.write(`copied to ${box.name}:${result.finalPath}
7262
7376
  `);
@@ -7264,8 +7378,8 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
7264
7378
  } else {
7265
7379
  const result = await downloadFromBox(
7266
7380
  box,
7267
- parsed.boxPath,
7268
- parsed.hostPath ?? process.cwd(),
7381
+ parsed.boxSrcs,
7382
+ parsed.hostDst ?? process.cwd(),
7269
7383
  tarPatterns
7270
7384
  );
7271
7385
  process.stdout.write(`copied to ${result.finalPath}
@@ -7277,7 +7391,7 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
7277
7391
  });
7278
7392
 
7279
7393
  // src/commands/create.ts
7280
- import { intro as intro6, log as log18, outro as outro5 } from "@clack/prompts";
7394
+ import { intro as intro6, log as log19, outro as outro5 } from "@clack/prompts";
7281
7395
  import { Command as Command11 } from "commander";
7282
7396
  import { execSync, spawnSync as spawnSync2 } from "child_process";
7283
7397
  function buildCliOverrides(opts) {
@@ -7425,13 +7539,13 @@ var createCommand = new Command11("create").description(
7425
7539
  onLog: (line) => cmdLog.write(line)
7426
7540
  });
7427
7541
  if (gate.decision === "cancel") {
7428
- log18.warn("carry: cancelled \u2014 not creating the box");
7542
+ log19.warn("carry: cancelled \u2014 not creating the box");
7429
7543
  cmdLog.close();
7430
7544
  process.exit(0);
7431
7545
  }
7432
7546
  if (gate.decision === "approve") carryEntries = gate.entries;
7433
7547
  } catch (err) {
7434
- log18.error(err instanceof Error ? err.message : String(err));
7548
+ log19.error(err instanceof Error ? err.message : String(err));
7435
7549
  cmdLog.close();
7436
7550
  process.exit(1);
7437
7551
  }
@@ -7447,7 +7561,7 @@ var createCommand = new Command11("create").description(
7447
7561
  baseStatus
7448
7562
  });
7449
7563
  if (wiz.rebuildBase) {
7450
- log18.warn(`${providerName} base image is outdated; rebuilding before create\u2026`);
7564
+ log19.warn(`${providerName} base image is outdated; rebuilding before create\u2026`);
7451
7565
  await runPrepare(providerName, {
7452
7566
  force: true,
7453
7567
  cwd: opts.workspace,
@@ -7493,7 +7607,7 @@ var createCommand = new Command11("create").description(
7493
7607
  } catch (err) {
7494
7608
  if (err instanceof FromBranchError || err instanceof UseBranchError) {
7495
7609
  s.stop("aborting: invalid branch selection");
7496
- log18.error(err.message);
7610
+ log19.error(err.message);
7497
7611
  cmdLog.close();
7498
7612
  process.exit(2);
7499
7613
  }
@@ -7535,18 +7649,18 @@ var createCommand = new Command11("create").description(
7535
7649
  });
7536
7650
  s.stop(`box ${result.record.container} ready`);
7537
7651
  const createResyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
7538
- if (createResyncWarning) log18.warn(createResyncWarning);
7539
- log18.info(`id: ${result.record.id}`);
7652
+ if (createResyncWarning) log19.warn(createResyncWarning);
7653
+ log19.info(`id: ${result.record.id}`);
7540
7654
  if (typeof result.record.projectIndex === "number") {
7541
- log18.info(`n: ${String(result.record.projectIndex)} (in ${projectRoot})`);
7655
+ log19.info(`n: ${String(result.record.projectIndex)} (in ${projectRoot})`);
7542
7656
  }
7543
- log18.info(`container: ${result.record.container}`);
7544
- log18.info(`image: ${result.record.image}${result.imageBuilt ? " (built just now)" : ""}`);
7657
+ log19.info(`container: ${result.record.container}`);
7658
+ log19.info(`image: ${result.record.image}${result.imageBuilt ? " (built just now)" : ""}`);
7545
7659
  if (result.record.snapshotDir) {
7546
- log18.info(`snapshot: ${result.record.snapshotDir}`);
7660
+ log19.info(`snapshot: ${result.record.snapshotDir}`);
7547
7661
  }
7548
7662
  if (result.record.checkpointSource) {
7549
- log18.info(
7663
+ log19.info(
7550
7664
  `checkpoint: ${result.record.checkpointSource.ref} (${result.record.checkpointSource.type}) \u2192 ${result.record.checkpointImage ?? "(missing)"}`
7551
7665
  );
7552
7666
  }
@@ -7558,7 +7672,7 @@ var createCommand = new Command11("create").description(
7558
7672
  ` agentbox claude attach ${result.record.name}`,
7559
7673
  ` agentbox url ${result.record.name}`
7560
7674
  ];
7561
- log18.message(
7675
+ log19.message(
7562
7676
  [
7563
7677
  "",
7564
7678
  "Try it:",
@@ -7577,7 +7691,7 @@ var createCommand = new Command11("create").description(
7577
7691
  const protectedPaths = boxes.map((b) => b.projectRoot).filter((p) => typeof p === "string");
7578
7692
  const res = await pruneOrphanProjectConfigs({ protectedPaths });
7579
7693
  if (res.removed.length > 0) {
7580
- log18.info(
7694
+ log19.info(
7581
7695
  `cleaned ${String(res.removed.length)} orphan project config dir(s): ` + res.removed.map((r) => r.originalPath).join(", ")
7582
7696
  );
7583
7697
  }
@@ -7587,7 +7701,7 @@ var createCommand = new Command11("create").description(
7587
7701
  }
7588
7702
  outro5("done");
7589
7703
  if (attachClaudeAfter) {
7590
- const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-MH7NKIZY.js");
7704
+ const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-U3QJO7IF.js");
7591
7705
  await cloudAgentAttach2({
7592
7706
  box: result.record,
7593
7707
  binary: "claude",
@@ -7603,14 +7717,14 @@ var createCommand = new Command11("create").description(
7603
7717
  s.stop("failed");
7604
7718
  const msg = err instanceof Error ? err.message : String(err);
7605
7719
  cmdLog.write(`FAIL: ${err instanceof Error ? err.stack ?? err.message : String(err)}`);
7606
- log18.error(msg);
7720
+ log19.error(msg);
7607
7721
  try {
7608
7722
  const running = execSync('docker ps --format "{{.Names}}"', {
7609
7723
  stdio: ["ignore", "pipe", "ignore"]
7610
7724
  }).toString().split("\n").filter((n) => n.startsWith("agentbox-"));
7611
7725
  if (running.length > 0) {
7612
- log18.warn(`leftover containers: ${running.join(", ")}`);
7613
- log18.warn(`remove with: docker rm -f ${running.join(" ")}`);
7726
+ log19.warn(`leftover containers: ${running.join(", ")}`);
7727
+ log19.warn(`remove with: docker rm -f ${running.join(" ")}`);
7614
7728
  }
7615
7729
  } catch {
7616
7730
  }
@@ -7623,7 +7737,7 @@ var createCommand = new Command11("create").description(
7623
7737
 
7624
7738
  // src/commands/dashboard.ts
7625
7739
  import { spawn as spawn3 } from "child_process";
7626
- import { log as log19 } from "@clack/prompts";
7740
+ import { log as log20 } from "@clack/prompts";
7627
7741
  import { Command as Command12 } from "commander";
7628
7742
 
7629
7743
  // src/dashboard/layout.ts
@@ -8223,8 +8337,8 @@ var Compositor = class {
8223
8337
  this.drawChrome();
8224
8338
  this.scheduleRender();
8225
8339
  this.pollTimer = setInterval(() => void this.poll(), POLL_MS);
8226
- await new Promise((resolve5) => {
8227
- this.resolveDone = resolve5;
8340
+ await new Promise((resolve6) => {
8341
+ this.resolveDone = resolve6;
8228
8342
  });
8229
8343
  }
8230
8344
  async refreshBoxes() {
@@ -9150,7 +9264,7 @@ function toSidebar(b) {
9150
9264
  var dashboardCommand = new Command12("dashboard").description("Box list + the selected box live Agent session").argument("[box]", "initial box (default: first running box; -p restricts to the cwd project)").option("-p, --project", "only this project's boxes (default: all boxes globally)").action(async (idOrName, opts) => {
9151
9265
  try {
9152
9266
  if (!process.stdout.isTTY || !process.stdin.isTTY) {
9153
- log19.error("agentbox dashboard needs an interactive terminal");
9267
+ log20.error("agentbox dashboard needs an interactive terminal");
9154
9268
  process.exit(2);
9155
9269
  }
9156
9270
  const backend = await loadPtyBackend();
@@ -9160,10 +9274,10 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9160
9274
  ptySpawn = backend.ptySpawn;
9161
9275
  termCtor = backend.termCtor;
9162
9276
  } else {
9163
- log19.error(
9277
+ log20.error(
9164
9278
  "agentbox dashboard is unavailable here (native terminal backend failed to load)"
9165
9279
  );
9166
- log19.info("use `agentbox claude` / `agentbox attach` instead");
9280
+ log20.info("use `agentbox claude` / `agentbox attach` instead");
9167
9281
  process.exit(2);
9168
9282
  }
9169
9283
  const project = await findProjectRoot(process.cwd());
@@ -9570,11 +9684,11 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9570
9684
  });
9571
9685
 
9572
9686
  // ../../packages/sandbox-daytona/dist/cli.js
9573
- import { log as log20, spinner as spinner7 } from "@clack/prompts";
9687
+ import { log as log21, spinner as spinner7 } from "@clack/prompts";
9574
9688
  import { Command as Command13 } from "commander";
9575
9689
  function reportError(err) {
9576
9690
  const message = err instanceof Error ? err.message : String(err);
9577
- log20.error(message);
9691
+ log21.error(message);
9578
9692
  process.exitCode = 1;
9579
9693
  }
9580
9694
  var loginSub = new Command13("login").description("Set up (or rotate) Daytona credentials for cloud boxes").option("--status", "show what is currently configured (masked) and exit").action(async (opts) => {
@@ -9592,7 +9706,7 @@ var loginSub = new Command13("login").description("Set up (or rotate) Daytona cr
9592
9706
  }
9593
9707
  await ensureDaytonaCredentials({ force: true });
9594
9708
  if (readPreparedDaytonaState()?.base === void 0) {
9595
- log20.info(
9709
+ log21.info(
9596
9710
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider daytona` (or `agentbox install`) to bake it."
9597
9711
  );
9598
9712
  }
@@ -9638,7 +9752,7 @@ var resyncSub = new Command13("resync").description(
9638
9752
  const sb = spinner7();
9639
9753
  sb.start(`provisioning throwaway sandbox to refresh: ${agents.join(", ")}`);
9640
9754
  const ensured = await ensureAgentVolumesForCloud(daytonaBackend, {
9641
- onLog: (line) => log20.info(line)
9755
+ onLog: (line) => log21.info(line)
9642
9756
  });
9643
9757
  if (ensured.agents.length === 0) {
9644
9758
  sb.stop("no agent volumes available \u2014 the daytona backend has no volume primitive");
@@ -9678,7 +9792,7 @@ var resyncSub = new Command13("resync").description(
9678
9792
  }
9679
9793
  sb3.stop("throwaway sandbox destroyed");
9680
9794
  }
9681
- log20.success(
9795
+ log21.success(
9682
9796
  `Daytona agent volumes refreshed: ${agents.join(", ")}. Next \`agentbox create --provider daytona\` will use the updated credentials.`
9683
9797
  );
9684
9798
  } catch (err) {
@@ -9698,11 +9812,11 @@ var dockerCommand = new Command14("docker").description(
9698
9812
  });
9699
9813
 
9700
9814
  // ../../packages/sandbox-hetzner/dist/cli.js
9701
- import { log as log21 } from "@clack/prompts";
9815
+ import { log as log22 } from "@clack/prompts";
9702
9816
  import { Command as Command15 } from "commander";
9703
9817
  function reportError2(err) {
9704
9818
  const message = err instanceof Error ? err.message : String(err);
9705
- log21.error(message);
9819
+ log22.error(message);
9706
9820
  process.exitCode = 1;
9707
9821
  }
9708
9822
  var loginSub2 = new Command15("login").description("Set up (or rotate) Hetzner Cloud credentials for VPS boxes").option("--status", "show what is currently configured (masked) and exit").action(async (opts) => {
@@ -9720,7 +9834,7 @@ var loginSub2 = new Command15("login").description("Set up (or rotate) Hetzner C
9720
9834
  }
9721
9835
  await ensureHetznerCredentials({ force: true });
9722
9836
  if (readPreparedState().base === void 0) {
9723
- log21.info(
9837
+ log22.info(
9724
9838
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider hetzner` (or `agentbox install`) to bake it."
9725
9839
  );
9726
9840
  }
@@ -9851,11 +9965,11 @@ var hetznerCommand = new Command15("hetzner").description(
9851
9965
  ).addCommand(loginSub2, { isDefault: true }).addCommand(firewallSub);
9852
9966
 
9853
9967
  // ../../packages/sandbox-vercel/dist/cli.js
9854
- import { log as log22 } from "@clack/prompts";
9968
+ import { log as log23 } from "@clack/prompts";
9855
9969
  import { Command as Command16 } from "commander";
9856
9970
  function reportError3(err) {
9857
9971
  const message = err instanceof Error ? err.message : String(err);
9858
- log22.error(message);
9972
+ log23.error(message);
9859
9973
  process.exitCode = 1;
9860
9974
  }
9861
9975
  function relativeExpiry(expiresAt) {
@@ -9918,7 +10032,7 @@ var loginSub3 = new Command16("login").description("Set up (or rotate) Vercel cr
9918
10032
  }
9919
10033
  await ensureVercelCredentials({ force: true });
9920
10034
  if (readPreparedState2().base === void 0) {
9921
- log22.info(
10035
+ log23.info(
9922
10036
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider vercel` (or `agentbox install`) to bake it."
9923
10037
  );
9924
10038
  }
@@ -9931,11 +10045,11 @@ var vercelCommand = new Command16("vercel").description(
9931
10045
  ).addCommand(loginSub3, { isDefault: true });
9932
10046
 
9933
10047
  // ../../packages/sandbox-e2b/dist/cli.js
9934
- import { log as log23 } from "@clack/prompts";
10048
+ import { log as log24 } from "@clack/prompts";
9935
10049
  import { Command as Command17 } from "commander";
9936
10050
  function reportError4(err) {
9937
10051
  const message = err instanceof Error ? err.message : String(err);
9938
- log23.error(message);
10052
+ log24.error(message);
9939
10053
  process.exitCode = 1;
9940
10054
  }
9941
10055
  function printStatus4() {
@@ -9967,7 +10081,7 @@ var loginSub4 = new Command17("login").description("Set up (or rotate) E2B crede
9967
10081
  }
9968
10082
  await ensureE2bCredentials({ force: true });
9969
10083
  if (readPreparedState3().base === void 0) {
9970
- log23.info(
10084
+ log24.info(
9971
10085
  "Base template not built yet \u2014 run `agentbox prepare --provider e2b` (or `agentbox install`) to bake it."
9972
10086
  );
9973
10087
  }
@@ -10521,7 +10635,7 @@ downloadCommand.addCommand(downloadOpencodeCommand);
10521
10635
  downloadCommand.addCommand(downloadConfigCommand);
10522
10636
 
10523
10637
  // src/commands/drive.ts
10524
- import { log as log31 } from "@clack/prompts";
10638
+ import { log as log32 } from "@clack/prompts";
10525
10639
  import { Command as Command25 } from "commander";
10526
10640
 
10527
10641
  // src/lib/drive/keys.ts
@@ -10704,7 +10818,7 @@ var driveWaitCommand = new Command25("wait").description("Block until --text app
10704
10818
  }) + "\n"
10705
10819
  );
10706
10820
  } else {
10707
- log31.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
10821
+ log32.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
10708
10822
  }
10709
10823
  process.exit(1);
10710
10824
  } catch (err) {
@@ -10731,8 +10845,8 @@ driveCommand.addCommand(driveWaitCommand);
10731
10845
  driveCommand.addCommand(driveResizeCommand);
10732
10846
  function handleDriveError(err) {
10733
10847
  if (err instanceof SessionNotFoundError) {
10734
- log31.error(err.message);
10735
- log31.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
10848
+ log32.error(err.message);
10849
+ log32.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
10736
10850
  process.exit(2);
10737
10851
  }
10738
10852
  handleLifecycleError(err);
@@ -10756,7 +10870,7 @@ function sleep4(ms) {
10756
10870
  }
10757
10871
 
10758
10872
  // src/commands/fork.ts
10759
- import { log as log32 } from "@clack/prompts";
10873
+ import { log as log33 } from "@clack/prompts";
10760
10874
  import { Command as Command26 } from "commander";
10761
10875
  import { existsSync as existsSync6, readdirSync as readdirSync2, statSync } from "fs";
10762
10876
  import { homedir as homedir13 } from "os";
@@ -10855,36 +10969,36 @@ var forkCommand = new Command26("fork").description(
10855
10969
  'copy a Claude Code plan file (e.g. ~/.claude/plans/<slug>.md) into the box, start claude in plan mode, and seed a "resume the plan" prompt. Claude only.'
10856
10970
  ).action(async (providerArg, opts) => {
10857
10971
  if ((process.env.AGENTBOX_RELAY_URL ?? "").trim().length > 0) {
10858
- log32.error(
10972
+ log33.error(
10859
10973
  "agentbox fork runs on the host only: it teleports a host agent session into a new box. You appear to be inside a box (AGENTBOX_RELAY_URL is set) \u2014 box\u2192box fork is not supported yet."
10860
10974
  );
10861
10975
  process.exit(2);
10862
10976
  }
10863
10977
  const agent = opts.agent?.trim() || detectAgentFromEnv() || "claude";
10864
10978
  if (!FORK_AGENTS.includes(agent)) {
10865
- log32.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
10979
+ log33.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
10866
10980
  process.exit(2);
10867
10981
  }
10868
10982
  const attachIn = opts.attachIn ?? "tab";
10869
10983
  if (!FORK_ATTACH_VALUES.includes(attachIn)) {
10870
- log32.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
10984
+ log33.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
10871
10985
  process.exit(2);
10872
10986
  }
10873
10987
  const plan = opts.plan?.trim();
10874
10988
  if (plan && agent !== "claude") {
10875
- log32.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
10989
+ log33.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
10876
10990
  process.exit(2);
10877
10991
  }
10878
10992
  const carryMode = opts.carry ?? "send";
10879
10993
  if (carryMode !== "send" && carryMode !== "skip") {
10880
- log32.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
10994
+ log33.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
10881
10995
  process.exit(2);
10882
10996
  }
10883
10997
  let provider;
10884
10998
  try {
10885
10999
  provider = resolveForkProvider(providerArg, opts.provider);
10886
11000
  } catch (err) {
10887
- log32.error(err instanceof Error ? err.message : String(err));
11001
+ log33.error(err instanceof Error ? err.message : String(err));
10888
11002
  process.exit(2);
10889
11003
  }
10890
11004
  if (!opts.session?.trim()) {
@@ -10908,7 +11022,7 @@ var forkCommand = new Command26("fork").description(
10908
11022
  try {
10909
11023
  sessionArgs = resolveSessionArgs(agent, opts);
10910
11024
  } catch (err) {
10911
- log32.error(err instanceof Error ? err.message : String(err));
11025
+ log33.error(err instanceof Error ? err.message : String(err));
10912
11026
  process.exit(2);
10913
11027
  }
10914
11028
  const subArgv = [
@@ -10930,25 +11044,57 @@ var forkCommand = new Command26("fork").description(
10930
11044
  });
10931
11045
 
10932
11046
  // src/commands/install.ts
10933
- import { Command as Command29 } from "commander";
11047
+ import { Command as Command30 } from "commander";
10934
11048
  import { execa as execa5 } from "execa";
10935
11049
  import {
10936
- existsSync as existsSync11,
11050
+ existsSync as existsSync13,
10937
11051
  lstatSync,
10938
- mkdirSync as mkdirSync9,
10939
- readFileSync as readFileSync5,
10940
- rmSync as rmSync2,
10941
- symlinkSync as symlinkSync2,
10942
- writeFileSync as writeFileSync8
11052
+ mkdirSync as mkdirSync10,
11053
+ readFileSync as readFileSync6,
11054
+ rmSync as rmSync3,
11055
+ symlinkSync as symlinkSync3,
11056
+ writeFileSync as writeFileSync9
10943
11057
  } from "fs";
10944
- import { homedir as homedir19 } from "os";
10945
- import { dirname as dirname5, join as join22, resolve as resolve4, sep } from "path";
11058
+ import { homedir as homedir20 } from "os";
11059
+ import { dirname as dirname7, join as join24, resolve as resolve5 } from "path";
11060
+
11061
+ // src/lib/source-checkout.ts
11062
+ import { existsSync as existsSync7 } from "fs";
11063
+ import { dirname, join as join17, resolve as resolve4, sep } from "path";
10946
11064
  import { fileURLToPath } from "url";
11065
+ function resolveHostSkillsDir() {
11066
+ const here = dirname(fileURLToPath(import.meta.url));
11067
+ const candidates = [
11068
+ resolve4(here, "..", "share", "host-skills"),
11069
+ resolve4(here, "..", "..", "share", "host-skills")
11070
+ ];
11071
+ for (const c of candidates) {
11072
+ if (existsSync7(c)) return c;
11073
+ }
11074
+ throw new Error(`could not locate bundled host skills; tried:
11075
+ ${candidates.join("\n ")}`);
11076
+ }
11077
+ function isSourceCheckout(srcDir) {
11078
+ return !srcDir.split(sep).includes("node_modules");
11079
+ }
11080
+ function resolveDevRepoRoot() {
11081
+ let hostSkillsDir;
11082
+ try {
11083
+ hostSkillsDir = resolveHostSkillsDir();
11084
+ } catch {
11085
+ return null;
11086
+ }
11087
+ if (!isSourceCheckout(hostSkillsDir)) return null;
11088
+ const root = resolve4(hostSkillsDir, "..", "..", "..", "..");
11089
+ const hasMarketplace = existsSync7(join17(root, ".agents", "plugins", "marketplace.json"));
11090
+ const hasPlugin = existsSync7(join17(root, "plugins", "agentbox"));
11091
+ return hasMarketplace && hasPlugin ? root : null;
11092
+ }
10947
11093
 
10948
11094
  // src/lib/doctor-checks.ts
10949
11095
  import { accessSync, constants as fsConstants, mkdirSync as mkdirSync4 } from "fs";
10950
11096
  import { homedir as homedir14 } from "os";
10951
- import { join as join17 } from "path";
11097
+ import { join as join18 } from "path";
10952
11098
  import { execa as execa4 } from "execa";
10953
11099
  var ALL_PROVIDERS = ["docker", "daytona", "hetzner", "vercel", "e2b"];
10954
11100
  var NODE_MIN_MAJOR = 20;
@@ -10996,7 +11142,7 @@ function checkPlatform() {
10996
11142
  };
10997
11143
  }
10998
11144
  function checkAgentboxHome() {
10999
- const dir = join17(homedir14(), ".agentbox");
11145
+ const dir = join18(homedir14(), ".agentbox");
11000
11146
  try {
11001
11147
  mkdirSync4(dir, { recursive: true });
11002
11148
  accessSync(dir, fsConstants.W_OK);
@@ -11068,7 +11214,7 @@ async function dockerChecks() {
11068
11214
  ];
11069
11215
  }
11070
11216
  const daemonRes = { label: "docker daemon", status: "ok", detail: "reachable" };
11071
- const mod = await import("./dist-AJWL4WLW.js");
11217
+ const mod = await import("./dist-SAS4PIHA.js");
11072
11218
  let imgRes;
11073
11219
  try {
11074
11220
  const img = await mod.imageInfo(mod.DEFAULT_BOX_IMAGE);
@@ -11099,7 +11245,7 @@ async function dockerChecks() {
11099
11245
  }
11100
11246
  async function daytonaChecks() {
11101
11247
  try {
11102
- const mod = await import("./dist-LUEH7MER.js");
11248
+ const mod = await import("./dist-UVQJ2BZJ.js");
11103
11249
  const status = await mod.getDaytonaStatus();
11104
11250
  if (!status.configured) {
11105
11251
  return [
@@ -11135,7 +11281,7 @@ async function daytonaChecks() {
11135
11281
  }
11136
11282
  async function hetznerChecks() {
11137
11283
  try {
11138
- const mod = await import("./dist-T3JIYHCA.js");
11284
+ const mod = await import("./dist-NWKOEWUJ.js");
11139
11285
  const cred = mod.readHetznerCredStatus();
11140
11286
  const credRes = cred.source === "none" ? {
11141
11287
  label: "credentials",
@@ -11167,7 +11313,7 @@ async function hetznerChecks() {
11167
11313
  }
11168
11314
  async function vercelChecks() {
11169
11315
  try {
11170
- const mod = await import("./dist-CTTTHG6U.js");
11316
+ const mod = await import("./dist-U76JL6HI.js");
11171
11317
  const cred = mod.readVercelCredStatus();
11172
11318
  const credRes = cred.auth === "none" ? {
11173
11319
  label: "credentials",
@@ -11203,7 +11349,7 @@ async function vercelChecks() {
11203
11349
  }
11204
11350
  async function e2bChecks() {
11205
11351
  try {
11206
- const mod = await import("./dist-G5PDFWKH.js");
11352
+ const mod = await import("./dist-FMA5Y25B.js");
11207
11353
  const cred = mod.readE2bCredStatus();
11208
11354
  const credRes = cred.auth === "none" ? {
11209
11355
  label: "credentials",
@@ -11438,19 +11584,19 @@ function formatDetailed(groups) {
11438
11584
  }
11439
11585
 
11440
11586
  // src/lib/first-run.ts
11441
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, writeFileSync as writeFileSync4 } from "fs";
11587
+ import { existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as writeFileSync4 } from "fs";
11442
11588
  import { homedir as homedir15 } from "os";
11443
- import { dirname, join as join18 } from "path";
11589
+ import { dirname as dirname2, join as join19 } from "path";
11444
11590
  var MARKER_VERSION = 1;
11445
11591
  function setupMarkerPath() {
11446
- return join18(homedir15(), ".agentbox", "setup-complete.json");
11592
+ return join19(homedir15(), ".agentbox", "setup-complete.json");
11447
11593
  }
11448
11594
  function isFirstRun() {
11449
- return !existsSync7(setupMarkerPath());
11595
+ return !existsSync8(setupMarkerPath());
11450
11596
  }
11451
11597
  function markSetupComplete(provider) {
11452
11598
  const path = setupMarkerPath();
11453
- mkdirSync5(dirname(path), { recursive: true });
11599
+ mkdirSync5(dirname2(path), { recursive: true });
11454
11600
  const body = {
11455
11601
  version: MARKER_VERSION,
11456
11602
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -11461,19 +11607,19 @@ function markSetupComplete(provider) {
11461
11607
 
11462
11608
  // src/lib/star-prompt.ts
11463
11609
  import { spawnSync as spawnSync3 } from "child_process";
11464
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync2, writeFileSync as writeFileSync5 } from "fs";
11610
+ import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync2, writeFileSync as writeFileSync5 } from "fs";
11465
11611
  import { homedir as homedir16 } from "os";
11466
- import { dirname as dirname2, join as join19 } from "path";
11612
+ import { dirname as dirname3, join as join20 } from "path";
11467
11613
  var STATE_VERSION = 1;
11468
11614
  var REPO = "madarco/agentbox";
11469
11615
  var REPO_URL = `https://github.com/${REPO}`;
11470
11616
  var DEFAULT_STATE = { version: STATE_VERSION, installCount: 0, starred: false };
11471
11617
  function starStatePath() {
11472
- return join19(homedir16(), ".agentbox", "star-prompt.json");
11618
+ return join20(homedir16(), ".agentbox", "star-prompt.json");
11473
11619
  }
11474
11620
  function readStarState() {
11475
11621
  const path = starStatePath();
11476
- if (!existsSync8(path)) return { ...DEFAULT_STATE };
11622
+ if (!existsSync9(path)) return { ...DEFAULT_STATE };
11477
11623
  try {
11478
11624
  const parsed = JSON.parse(readFileSync2(path, "utf8"));
11479
11625
  return {
@@ -11487,7 +11633,7 @@ function readStarState() {
11487
11633
  }
11488
11634
  function writeStarState(state) {
11489
11635
  const path = starStatePath();
11490
- mkdirSync6(dirname2(path), { recursive: true });
11636
+ mkdirSync6(dirname3(path), { recursive: true });
11491
11637
  writeFileSync5(path, JSON.stringify(state, null, 2) + "\n");
11492
11638
  }
11493
11639
  function ghReady() {
@@ -11534,16 +11680,16 @@ async function maybePromptStar(opts) {
11534
11680
  }
11535
11681
 
11536
11682
  // src/commands/install-cmux.ts
11537
- import { intro as intro7, log as log34, note as note2, outro as outro6 } from "@clack/prompts";
11683
+ import { intro as intro7, log as log35, note as note2, outro as outro6 } from "@clack/prompts";
11538
11684
  import { Command as Command27 } from "commander";
11539
- import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync3, renameSync as renameSync3, writeFileSync as writeFileSync6 } from "fs";
11685
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync3, renameSync as renameSync3, writeFileSync as writeFileSync6 } from "fs";
11540
11686
  import { homedir as homedir17 } from "os";
11541
- import { dirname as dirname3, join as join20 } from "path";
11687
+ import { dirname as dirname4, join as join21 } from "path";
11542
11688
  var CONTROL_ID = "agentbox";
11543
11689
  function cmuxDockPath(env = process.env) {
11544
11690
  const xdg = env["XDG_CONFIG_HOME"];
11545
- const base = xdg && xdg.length > 0 ? xdg : join20(homedir17(), ".config");
11546
- return join20(base, "cmux", "dock.json");
11691
+ const base = xdg && xdg.length > 0 ? xdg : join21(homedir17(), ".config");
11692
+ return join21(base, "cmux", "dock.json");
11547
11693
  }
11548
11694
  function upsertAgentboxControl(doc, opts) {
11549
11695
  const controls = Array.isArray(doc.controls) ? doc.controls : [];
@@ -11573,14 +11719,14 @@ var installCmuxCommand = new Command27("cmux").description(
11573
11719
  height: parseHeight(opts.height)
11574
11720
  };
11575
11721
  let doc = { controls: [] };
11576
- if (existsSync9(dockPath)) {
11722
+ if (existsSync10(dockPath)) {
11577
11723
  const raw = readFileSync3(dockPath, "utf8");
11578
11724
  try {
11579
11725
  const parsed = JSON.parse(raw);
11580
11726
  if (parsed && typeof parsed === "object") doc = parsed;
11581
11727
  } catch {
11582
11728
  if (!opts.force) {
11583
- log34.error(
11729
+ log35.error(
11584
11730
  `existing dock config is not valid JSON: ${dockPath}
11585
11731
  fix it by hand, or pass --force to back it up and write a fresh one`
11586
11732
  );
@@ -11588,7 +11734,7 @@ fix it by hand, or pass --force to back it up and write a fresh one`
11588
11734
  }
11589
11735
  if (!opts.dryRun) {
11590
11736
  renameSync3(dockPath, dockPath + ".bak");
11591
- log34.warn(`backed up unparseable dock config to ${dockPath}.bak`);
11737
+ log35.warn(`backed up unparseable dock config to ${dockPath}.bak`);
11592
11738
  }
11593
11739
  doc = { controls: [] };
11594
11740
  }
@@ -11601,7 +11747,7 @@ fix it by hand, or pass --force to back it up and write a fresh one`
11601
11747
  outro6(`would write ${dockPath}`);
11602
11748
  return;
11603
11749
  }
11604
- mkdirSync7(dirname3(dockPath), { recursive: true });
11750
+ mkdirSync7(dirname4(dockPath), { recursive: true });
11605
11751
  writeFileSync6(dockPath, json);
11606
11752
  intro7("AgentBox cmux dock panel");
11607
11753
  note2(
@@ -11617,23 +11763,23 @@ To see it:
11617
11763
  });
11618
11764
 
11619
11765
  // src/commands/install-herdr.ts
11620
- import { intro as intro8, log as log35, note as note3, outro as outro7 } from "@clack/prompts";
11766
+ import { intro as intro8, log as log36, note as note3, outro as outro7 } from "@clack/prompts";
11621
11767
  import { Command as Command28, Option } from "commander";
11622
11768
  import { spawnSync as spawnSync4 } from "child_process";
11623
- import { chmodSync, existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync4, writeFileSync as writeFileSync7 } from "fs";
11769
+ import { chmodSync, existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync4, writeFileSync as writeFileSync7 } from "fs";
11624
11770
  import { homedir as homedir18 } from "os";
11625
- import { dirname as dirname4, join as join21 } from "path";
11771
+ import { dirname as dirname5, join as join22 } from "path";
11626
11772
  var PLUGIN_VERSION = "0.2.0";
11627
11773
  function herdrPluginDir(env = process.env) {
11628
- const home = env["AGENTBOX_HOME"] ?? join21(homedir18(), ".agentbox");
11629
- return join21(home, "herdr", "plugin");
11774
+ const home = env["AGENTBOX_HOME"] ?? join22(homedir18(), ".agentbox");
11775
+ return join22(home, "herdr", "plugin");
11630
11776
  }
11631
11777
  function herdrConfigPath(env = process.env) {
11632
11778
  const override = env["HERDR_CONFIG_PATH"];
11633
11779
  if (override && override.length > 0) return override;
11634
11780
  const xdg = env["XDG_CONFIG_HOME"];
11635
- const base = xdg && xdg.length > 0 ? xdg : join21(homedir18(), ".config");
11636
- return join21(base, "herdr", "config.toml");
11781
+ const base = xdg && xdg.length > 0 ? xdg : join22(homedir18(), ".config");
11782
+ return join22(base, "herdr", "config.toml");
11637
11783
  }
11638
11784
  function herdrBinary(env = process.env) {
11639
11785
  const b = env["HERDR_BIN_PATH"];
@@ -11749,14 +11895,14 @@ function escapeRe(s) {
11749
11895
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11750
11896
  }
11751
11897
  function writeShim(dir) {
11752
- const p = join21(dir, "agentbox-shim.sh");
11898
+ const p = join22(dir, "agentbox-shim.sh");
11753
11899
  writeFileSync7(p, herdrShimContent(process.execPath, process.argv[1] ?? "agentbox"));
11754
11900
  chmodSync(p, 493);
11755
11901
  }
11756
11902
  function applyKeybindings() {
11757
11903
  const cfg = herdrConfigPath();
11758
- const existing = existsSync10(cfg) ? readFileSync4(cfg, "utf8") : "";
11759
- mkdirSync8(dirname4(cfg), { recursive: true });
11904
+ const existing = existsSync11(cfg) ? readFileSync4(cfg, "utf8") : "";
11905
+ mkdirSync8(dirname5(cfg), { recursive: true });
11760
11906
  writeFileSync7(cfg, upsertHerdrKeybindings(existing, herdrKeybindingsBlock()));
11761
11907
  spawnSync4(herdrBinary(), ["server", "reload-config"], { stdio: "ignore" });
11762
11908
  return cfg;
@@ -11774,18 +11920,18 @@ var installHerdrCommand = new Command28("herdr").description(
11774
11920
  return;
11775
11921
  }
11776
11922
  const dir = herdrPluginDir();
11777
- const file = join21(dir, "herdr-plugin.toml");
11923
+ const file = join22(dir, "herdr-plugin.toml");
11778
11924
  const cfgPath = herdrConfigPath();
11779
11925
  if (opts.dryRun) {
11780
11926
  intro8("agentbox install herdr (dry run)");
11781
11927
  process.stdout.write(`# --- ${file} ---
11782
11928
  ${buildHerdrManifest()}
11783
11929
  `);
11784
- process.stdout.write(`# --- ${join21(dir, "build.sh")} ---
11930
+ process.stdout.write(`# --- ${join22(dir, "build.sh")} ---
11785
11931
  ${herdrBuildScript()}
11786
11932
  `);
11787
11933
  process.stdout.write(
11788
- `# --- ${join21(dir, "agentbox-shim.sh")} ---
11934
+ `# --- ${join22(dir, "agentbox-shim.sh")} ---
11789
11935
  ${herdrShimContent(process.execPath, process.argv[1] ?? "agentbox")}
11790
11936
  `
11791
11937
  );
@@ -11797,7 +11943,7 @@ ${herdrKeybindingsBlock()}
11797
11943
  }
11798
11944
  mkdirSync8(dir, { recursive: true });
11799
11945
  writeFileSync7(file, buildHerdrManifest());
11800
- const buildPath = join21(dir, "build.sh");
11946
+ const buildPath = join22(dir, "build.sh");
11801
11947
  writeFileSync7(buildPath, herdrBuildScript());
11802
11948
  chmodSync(buildPath, 493);
11803
11949
  writeShim(dir);
@@ -11812,7 +11958,7 @@ ${herdrKeybindingsBlock()}
11812
11958
  if (linked.status === 0) {
11813
11959
  spawnSync4(bin, ["server", "reload-config"], { stdio: "ignore" });
11814
11960
  } else {
11815
- log35.warn(
11961
+ log36.warn(
11816
11962
  `could not run \`${bin} plugin link\` (is Herdr installed / running?).
11817
11963
  Run it yourself: herdr plugin link ${dir} && herdr server reload-config`
11818
11964
  );
@@ -11827,6 +11973,254 @@ Added shortcuts to ${cfg}
11827
11973
  outro7("done");
11828
11974
  });
11829
11975
 
11976
+ // src/commands/install-codex.ts
11977
+ import { Command as Command29 } from "commander";
11978
+ import { spawnSync as spawnSync5 } from "child_process";
11979
+ import {
11980
+ existsSync as existsSync12,
11981
+ mkdirSync as mkdirSync9,
11982
+ readFileSync as readFileSync5,
11983
+ readdirSync as readdirSync3,
11984
+ rmSync as rmSync2,
11985
+ symlinkSync as symlinkSync2,
11986
+ writeFileSync as writeFileSync8
11987
+ } from "fs";
11988
+ import { homedir as homedir19 } from "os";
11989
+ import { dirname as dirname6, join as join23 } from "path";
11990
+ import { parse as parseToml } from "smol-toml";
11991
+ var MARKETPLACE_SOURCE = "madarco/agentbox";
11992
+ var MARKETPLACE_NAME = "agentbox";
11993
+ var PLUGIN_NAME = "agentbox";
11994
+ var PLUGIN_ID = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
11995
+ var PLUGIN_BUNDLE_REL = join23("plugins", "agentbox");
11996
+ function marketplaceSource(opts = {}) {
11997
+ const devRoot = opts.noDev ? null : resolveDevRepoRoot();
11998
+ return { source: devRoot ?? MARKETPLACE_SOURCE, devRoot };
11999
+ }
12000
+ function symlinkStagedSkills(devRoot, env = process.env) {
12001
+ try {
12002
+ const pluginRoot = join23(codexHomeDir(env), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME);
12003
+ const bundle = join23(devRoot, PLUGIN_BUNDLE_REL);
12004
+ let versionDir;
12005
+ try {
12006
+ const manifest = JSON.parse(
12007
+ readFileSync5(join23(bundle, ".codex-plugin", "plugin.json"), "utf8")
12008
+ );
12009
+ if (manifest.version) versionDir = join23(pluginRoot, manifest.version);
12010
+ } catch {
12011
+ }
12012
+ if (!versionDir || !existsSync12(versionDir)) {
12013
+ const children = existsSync12(pluginRoot) ? readdirSync3(pluginRoot) : [];
12014
+ versionDir = children.length === 1 ? join23(pluginRoot, children[0]) : void 0;
12015
+ }
12016
+ if (!versionDir || !existsSync12(versionDir)) {
12017
+ return { linked: 0, error: "staged plugin dir not found" };
12018
+ }
12019
+ const skillsDir = join23(bundle, "skills");
12020
+ if (!existsSync12(skillsDir)) return { linked: 0 };
12021
+ let linked = 0;
12022
+ for (const name of readdirSync3(skillsDir)) {
12023
+ const repoSkill = join23(skillsDir, name, "SKILL.md");
12024
+ if (!existsSync12(repoSkill)) continue;
12025
+ const stagedSkill = join23(versionDir, "skills", name, "SKILL.md");
12026
+ mkdirSync9(dirname6(stagedSkill), { recursive: true });
12027
+ rmSync2(stagedSkill, { force: true });
12028
+ symlinkSync2(repoSkill, stagedSkill);
12029
+ linked++;
12030
+ }
12031
+ return { linked };
12032
+ } catch (e) {
12033
+ return { linked: 0, error: e.message };
12034
+ }
12035
+ }
12036
+ function syncBundleSkill(devRoot) {
12037
+ spawnSync5("node", [join23(devRoot, "scripts", "check-plugin-skill-sync.mjs"), "--fix"], {
12038
+ cwd: devRoot,
12039
+ stdio: "ignore"
12040
+ });
12041
+ }
12042
+ function codexHomeDir(env = process.env) {
12043
+ const override = env["CODEX_HOME"];
12044
+ return override && override.length > 0 ? override : join23(homedir19(), ".codex");
12045
+ }
12046
+ function currentMarketplaceType(env = process.env) {
12047
+ try {
12048
+ const cfg = readFileSync5(codexConfigPath(env), "utf8");
12049
+ const parsed = parseToml(cfg);
12050
+ const t = parsed.marketplaces?.[MARKETPLACE_NAME]?.source_type;
12051
+ return typeof t === "string" ? t : null;
12052
+ } catch {
12053
+ return null;
12054
+ }
12055
+ }
12056
+ function codexConfigPath(env = process.env) {
12057
+ return join23(codexHomeDir(env), "config.toml");
12058
+ }
12059
+ function codexBinary(env = process.env) {
12060
+ const b = env["CODEX_BIN_PATH"];
12061
+ return b && b.length > 0 ? b : "codex";
12062
+ }
12063
+ function codexCliAvailable(env = process.env) {
12064
+ const r = spawnSync5(codexBinary(env), ["--version"], { stdio: "ignore" });
12065
+ return r.status === 0;
12066
+ }
12067
+ function codexPluginInstalled(bin) {
12068
+ try {
12069
+ const r = spawnSync5(bin, ["plugin", "list", "--json"], { encoding: "utf8" });
12070
+ if (r.status !== 0 || !r.stdout) return false;
12071
+ const parsed = JSON.parse(r.stdout);
12072
+ return (parsed.installed ?? []).some((p) => p.pluginId === PLUGIN_ID);
12073
+ } catch {
12074
+ return false;
12075
+ }
12076
+ }
12077
+ function codexPluginEnableTable() {
12078
+ return `# AgentBox plugin (added by \`agentbox install codex\`). Set enabled = false to disable.
12079
+ [plugins."${PLUGIN_ID}"]
12080
+ enabled = true`;
12081
+ }
12082
+ function upsertCodexPluginEnable(existing, opts = {}) {
12083
+ let entry;
12084
+ try {
12085
+ const parsed = parseToml(existing);
12086
+ entry = parsed.plugins?.[PLUGIN_ID];
12087
+ } catch {
12088
+ return { text: existing, status: "parse-error" };
12089
+ }
12090
+ if (entry === void 0) {
12091
+ const head = existing.replace(/\s+$/, "");
12092
+ const text2 = (head.length > 0 ? `${head}
12093
+
12094
+ ` : "") + codexPluginEnableTable() + "\n";
12095
+ return { text: text2, status: "added" };
12096
+ }
12097
+ if (entry.enabled !== false) return { text: existing, status: "user-enabled" };
12098
+ if (!opts.force) return { text: existing, status: "user-disabled" };
12099
+ return { text: forceEnableInPlace(existing), status: "forced-enabled" };
12100
+ }
12101
+ function forceEnableInPlace(existing) {
12102
+ const lines = existing.split("\n");
12103
+ const header = `[plugins."${PLUGIN_ID}"]`;
12104
+ const start = lines.findIndex((l) => l.trim() === header);
12105
+ if (start === -1) return existing;
12106
+ let end = lines.length;
12107
+ for (let i = start + 1; i < lines.length; i++) {
12108
+ if (/^\s*\[/.test(lines[i] ?? "")) {
12109
+ end = i;
12110
+ break;
12111
+ }
12112
+ }
12113
+ for (let i = start + 1; i < end; i++) {
12114
+ if (/^\s*enabled\s*=/.test(lines[i] ?? "")) {
12115
+ lines[i] = "enabled = true";
12116
+ return lines.join("\n");
12117
+ }
12118
+ }
12119
+ lines.splice(start + 1, 0, "enabled = true");
12120
+ return lines.join("\n");
12121
+ }
12122
+ async function installCodexPlugin(opts = {}) {
12123
+ const env = process.env;
12124
+ const cfgPath = codexConfigPath(env);
12125
+ const { source, devRoot } = marketplaceSource({ noDev: opts.noDev });
12126
+ const result = {
12127
+ ran: false,
12128
+ marketplaceAdded: false,
12129
+ pluginInstalled: false,
12130
+ configPath: cfgPath,
12131
+ dev: devRoot !== null
12132
+ };
12133
+ if (!existsSync12(codexHomeDir(env)) || !codexCliAvailable(env)) {
12134
+ return result;
12135
+ }
12136
+ result.ran = true;
12137
+ const bin = codexBinary(env);
12138
+ if (opts.dryRun) {
12139
+ if (!opts.quiet) {
12140
+ process.stdout.write(
12141
+ `# would run: ${bin} plugin marketplace add ${source}
12142
+ # would run: ${bin} plugin add ${PLUGIN_ID}
12143
+ ` + (devRoot ? `# would symlink the staged skills/*/SKILL.md -> ${join23(devRoot, PLUGIN_BUNDLE_REL, "skills")}/*
12144
+ ` : "") + `# --- appended to ${cfgPath} (only if not already configured) ---
12145
+ ${codexPluginEnableTable()}
12146
+ `
12147
+ );
12148
+ }
12149
+ return result;
12150
+ }
12151
+ if (devRoot) syncBundleSkill(devRoot);
12152
+ const desiredType = devRoot ? "local" : "git";
12153
+ const sourceConflict = currentMarketplaceType(env) !== null && currentMarketplaceType(env) !== desiredType;
12154
+ const alreadyInstalled = !opts.force && !devRoot && !sourceConflict && codexPluginInstalled(bin);
12155
+ if (alreadyInstalled) {
12156
+ result.marketplaceAdded = true;
12157
+ result.pluginInstalled = true;
12158
+ } else {
12159
+ if (devRoot || sourceConflict) {
12160
+ spawnSync5(bin, ["plugin", "marketplace", "remove", MARKETPLACE_NAME], { stdio: "ignore" });
12161
+ }
12162
+ const mkt = spawnSync5(bin, ["plugin", "marketplace", "add", source], {
12163
+ stdio: "ignore"
12164
+ });
12165
+ result.marketplaceAdded = mkt.status === 0;
12166
+ const add = spawnSync5(bin, ["plugin", "add", PLUGIN_ID], { encoding: "utf8" });
12167
+ result.pluginInstalled = add.status === 0;
12168
+ if (add.status !== 0 && !opts.quiet) {
12169
+ const detail = (add.stderr || add.stdout || "").trim();
12170
+ prompt_exports.log.info(
12171
+ `codex plugin add ${PLUGIN_ID} returned non-zero (continuing \u2014 likely already installed)` + (detail ? `: ${detail.split("\n")[0]}` : "")
12172
+ );
12173
+ }
12174
+ if (devRoot) {
12175
+ const sym = symlinkStagedSkills(devRoot, env);
12176
+ result.skillsSymlinked = sym.linked > 0;
12177
+ if (sym.linked === 0 && !opts.quiet) {
12178
+ prompt_exports.log.info(
12179
+ `could not symlink the staged Codex skill to the repo (using the local copy instead)` + (sym.error ? `: ${sym.error}` : "")
12180
+ );
12181
+ }
12182
+ }
12183
+ }
12184
+ const existing = existsSync12(cfgPath) ? readFileSync5(cfgPath, "utf8") : "";
12185
+ const { text: text2, status } = upsertCodexPluginEnable(existing, { force: opts.force });
12186
+ result.enableStatus = status;
12187
+ if (text2 !== existing) {
12188
+ mkdirSync9(dirname6(cfgPath), { recursive: true });
12189
+ writeFileSync8(cfgPath, text2);
12190
+ } else if (status === "user-disabled" && !opts.quiet) {
12191
+ prompt_exports.log.info(
12192
+ `AgentBox Codex plugin is present but disabled in ${cfgPath} \u2014 leaving it off. Re-run with --force (or set enabled = true) to use it.`
12193
+ );
12194
+ }
12195
+ return result;
12196
+ }
12197
+ var installCodexCommand = new Command29("codex").description(
12198
+ "Install + enable the AgentBox Codex plugin (marketplace add, plugin add, and enable it by default in ~/.codex/config.toml)."
12199
+ ).option("--dry-run", "print the commands and config block without changing anything").option("--force", "re-install and re-enable even if the plugin was disabled").option("--no-dev", "use the published GitHub marketplace even inside a source checkout").action(async (opts) => {
12200
+ (0, prompt_exports.intro)("AgentBox Codex plugin");
12201
+ const res = await installCodexPlugin({
12202
+ force: opts.force,
12203
+ dryRun: opts.dryRun,
12204
+ noDev: opts.dev === false
12205
+ });
12206
+ if (!res.ran) {
12207
+ (0, prompt_exports.outro)("Codex not detected on this host (no ~/.codex or `codex` CLI) \u2014 skipped.");
12208
+ return;
12209
+ }
12210
+ if (opts.dryRun) {
12211
+ (0, prompt_exports.outro)("dry-run: nothing written");
12212
+ return;
12213
+ }
12214
+ (0, prompt_exports.note)(
12215
+ `Source: ${res.dev ? `local repo (dev)${res.skillsSymlinked ? ", skill symlinked \u2014 edits live on restart" : ""}` : "madarco/agentbox (GitHub)"}
12216
+ Marketplace: ${res.marketplaceAdded ? "registered" : "see warning above"}
12217
+ Plugin: ${res.pluginInstalled ? "installed" : "add attempted (may already exist)"}
12218
+ Enabled: ${res.enableStatus === "added" ? `yes (wrote ${res.configPath})` : res.enableStatus === "forced-enabled" ? `re-enabled (wrote ${res.configPath})` : res.enableStatus === "user-enabled" ? "already enabled" : res.enableStatus === "user-disabled" ? "left disabled (your choice \u2014 re-run with --force to enable)" : `could not edit ${res.configPath}`}`,
12219
+ "Installed"
12220
+ );
12221
+ (0, prompt_exports.outro)("done \u2014 restart Codex if it was running");
12222
+ });
12223
+
11830
12224
  // src/commands/install.ts
11831
12225
  var MANAGED_SENTINEL = "<!-- agentbox-managed:v1 -->";
11832
12226
  var LOGO_L1 = "\u2584\u2580\u2588 \u2588\u2580\u2580 \u2588\u2580\u2580 \u2588\u2584\u2591\u2588 \u2580\u2588\u2580 \u2588\u2584\u2584 \u2588\u2580\u2588 \u2580\u2584\u2580";
@@ -11907,37 +12301,25 @@ ${LOGO_L2}\x1B[0m` + SYNC_END2);
11907
12301
  }
11908
12302
  var LEGACY_INFO_MARKER = "Drive AgentBox from the host:";
11909
12303
  function installTargets() {
11910
- const home = homedir19();
11911
- const claudeSkills = join22(home, ".claude", "skills");
12304
+ const home = homedir20();
12305
+ const claudeSkills = join24(home, ".claude", "skills");
11912
12306
  return [
11913
12307
  {
11914
- src: join22("agentbox-info", "SKILL.md"),
11915
- dest: join22(claudeSkills, "agentbox-info", "SKILL.md")
12308
+ src: join24("agentbox-info", "SKILL.md"),
12309
+ dest: join24(claudeSkills, "agentbox-info", "SKILL.md")
11916
12310
  },
11917
12311
  {
11918
- src: join22("codex", "agentbox.md"),
11919
- dest: join22(home, ".codex", "prompts", "agentbox.md"),
11920
- gateDir: join22(home, ".codex")
12312
+ src: join24("codex", "agentbox.md"),
12313
+ dest: join24(home, ".codex", "prompts", "agentbox.md"),
12314
+ gateDir: join24(home, ".codex")
11921
12315
  },
11922
12316
  {
11923
- src: join22("opencode", "agentbox.md"),
11924
- dest: join22(home, ".config", "opencode", "commands", "agentbox.md"),
11925
- gateDir: join22(home, ".config", "opencode")
12317
+ src: join24("opencode", "agentbox.md"),
12318
+ dest: join24(home, ".config", "opencode", "commands", "agentbox.md"),
12319
+ gateDir: join24(home, ".config", "opencode")
11926
12320
  }
11927
12321
  ];
11928
12322
  }
11929
- function resolveHostSkillsDir() {
11930
- const here = dirname5(fileURLToPath(import.meta.url));
11931
- const candidates = [
11932
- resolve4(here, "..", "share", "host-skills"),
11933
- resolve4(here, "..", "..", "share", "host-skills")
11934
- ];
11935
- for (const c of candidates) {
11936
- if (existsSync11(c)) return c;
11937
- }
11938
- throw new Error(`could not locate bundled host skills; tried:
11939
- ${candidates.join("\n ")}`);
11940
- }
11941
12323
  function isSymlink(target) {
11942
12324
  try {
11943
12325
  return lstatSync(target).isSymbolicLink();
@@ -11945,15 +12327,12 @@ function isSymlink(target) {
11945
12327
  return false;
11946
12328
  }
11947
12329
  }
11948
- function isSourceCheckout(srcDir) {
11949
- return !srcDir.split(sep).includes("node_modules");
11950
- }
11951
12330
  function writableReason(target, force) {
11952
- if (!existsSync11(target)) {
12331
+ if (!existsSync13(target)) {
11953
12332
  if (isSymlink(target)) return "managed";
11954
12333
  return "new";
11955
12334
  }
11956
- const existing = readFileSync5(target, "utf8");
12335
+ const existing = readFileSync6(target, "utf8");
11957
12336
  if (existing.includes(MANAGED_SENTINEL) || existing.includes(LEGACY_INFO_MARKER)) {
11958
12337
  return "managed";
11959
12338
  }
@@ -11969,13 +12348,13 @@ function installHostSkills(opts = {}) {
11969
12348
  const blocked = [];
11970
12349
  let skipped = 0;
11971
12350
  for (const t of installTargets()) {
11972
- const src = join22(srcDir, t.src);
11973
- if (!existsSync11(src)) {
12351
+ const src = join24(srcDir, t.src);
12352
+ if (!existsSync13(src)) {
11974
12353
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
11975
12354
  skipped++;
11976
12355
  continue;
11977
12356
  }
11978
- if (t.gateDir && !existsSync11(t.gateDir)) continue;
12357
+ if (t.gateDir && !existsSync13(t.gateDir)) continue;
11979
12358
  const reason = writableReason(t.dest, force);
11980
12359
  if (reason === "skip") {
11981
12360
  if (!quiet) prompt_exports.log.warn(`user-modified file at ${t.dest}, skipping; pass --force to overwrite`);
@@ -11988,13 +12367,13 @@ function installHostSkills(opts = {}) {
11988
12367
  written.push(t.dest);
11989
12368
  continue;
11990
12369
  }
11991
- mkdirSync9(dirname5(t.dest), { recursive: true });
12370
+ mkdirSync10(dirname7(t.dest), { recursive: true });
11992
12371
  if (link) {
11993
- rmSync2(t.dest, { force: true });
11994
- symlinkSync2(resolve4(srcDir, t.src), t.dest);
12372
+ rmSync3(t.dest, { force: true });
12373
+ symlinkSync3(resolve5(srcDir, t.src), t.dest);
11995
12374
  } else {
11996
- if (isSymlink(t.dest)) rmSync2(t.dest, { force: true });
11997
- writeFileSync8(t.dest, readFileSync5(src, "utf8"));
12375
+ if (isSymlink(t.dest)) rmSync3(t.dest, { force: true });
12376
+ writeFileSync9(t.dest, readFileSync6(src, "utf8"));
11998
12377
  }
11999
12378
  written.push(t.dest);
12000
12379
  }
@@ -12006,9 +12385,9 @@ async function installForkSkill(opts = {}) {
12006
12385
  const dryRun = opts.dryRun === true;
12007
12386
  const quiet = opts.quiet === true;
12008
12387
  const srcDir = resolveHostSkillsDir();
12009
- const src = join22(srcDir, "agentbox", "SKILL.md");
12010
- const dest = join22(homedir19(), ".claude", "skills", "agentbox", "SKILL.md");
12011
- if (!existsSync11(src)) {
12388
+ const src = join24(srcDir, "agentbox", "SKILL.md");
12389
+ const dest = join24(homedir20(), ".claude", "skills", "agentbox", "SKILL.md");
12390
+ if (!existsSync13(src)) {
12012
12391
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
12013
12392
  return { written: [], skipped: 1, blocked: [], method: "skip" };
12014
12393
  }
@@ -12023,9 +12402,9 @@ async function installForkSkill(opts = {}) {
12023
12402
  return { written: [dest], skipped: 0, blocked: [], method: "dry-run" };
12024
12403
  }
12025
12404
  if (isSourceCheckout(srcDir)) {
12026
- mkdirSync9(dirname5(dest), { recursive: true });
12027
- rmSync2(dest, { force: true });
12028
- symlinkSync2(src, dest);
12405
+ mkdirSync10(dirname7(dest), { recursive: true });
12406
+ rmSync3(dest, { force: true });
12407
+ symlinkSync3(src, dest);
12029
12408
  return { written: [dest], skipped: 0, blocked: [], method: "symlink" };
12030
12409
  }
12031
12410
  try {
@@ -12046,16 +12425,16 @@ async function installForkSkill(opts = {}) {
12046
12425
  ],
12047
12426
  { timeout: 12e4 }
12048
12427
  );
12049
- if (existsSync11(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
12428
+ if (existsSync13(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
12050
12429
  throw new Error("`skills add` reported success but wrote no skill file");
12051
12430
  } catch (err) {
12052
12431
  if (!quiet) {
12053
12432
  const msg = err instanceof Error ? err.message : String(err);
12054
12433
  prompt_exports.log.warn(`\`npx skills add\` failed (${msg}); copying the bundled fork skill instead`);
12055
12434
  }
12056
- mkdirSync9(dirname5(dest), { recursive: true });
12057
- if (isSymlink(dest)) rmSync2(dest, { force: true });
12058
- writeFileSync8(dest, readFileSync5(src, "utf8"));
12435
+ mkdirSync10(dirname7(dest), { recursive: true });
12436
+ if (isSymlink(dest)) rmSync3(dest, { force: true });
12437
+ writeFileSync9(dest, readFileSync6(src, "utf8"));
12059
12438
  return { written: [dest], skipped: 0, blocked: [], method: "copy" };
12060
12439
  }
12061
12440
  }
@@ -12083,7 +12462,7 @@ function ensureTty() {
12083
12462
  async function runProviderLogin(name) {
12084
12463
  if (name === "docker") return true;
12085
12464
  if (name === "daytona") {
12086
- const mod2 = await import("./dist-LUEH7MER.js");
12465
+ const mod2 = await import("./dist-UVQJ2BZJ.js");
12087
12466
  const status2 = await mod2.getDaytonaStatus();
12088
12467
  if (status2.configured) {
12089
12468
  prompt_exports.log.info("daytona: already configured");
@@ -12095,7 +12474,7 @@ async function runProviderLogin(name) {
12095
12474
  return true;
12096
12475
  }
12097
12476
  if (name === "hetzner") {
12098
- const mod2 = await import("./dist-T3JIYHCA.js");
12477
+ const mod2 = await import("./dist-NWKOEWUJ.js");
12099
12478
  const status2 = mod2.readHetznerCredStatus();
12100
12479
  if (status2.source !== "none") {
12101
12480
  prompt_exports.log.info("hetzner: already configured");
@@ -12107,7 +12486,7 @@ async function runProviderLogin(name) {
12107
12486
  return true;
12108
12487
  }
12109
12488
  if (name === "vercel") {
12110
- const mod2 = await import("./dist-CTTTHG6U.js");
12489
+ const mod2 = await import("./dist-U76JL6HI.js");
12111
12490
  const status2 = mod2.readVercelCredStatus();
12112
12491
  if (status2.auth !== "none") {
12113
12492
  prompt_exports.log.info(`vercel: already configured (${status2.auth})`);
@@ -12118,7 +12497,7 @@ async function runProviderLogin(name) {
12118
12497
  await mod2.ensureVercelCredentials();
12119
12498
  return true;
12120
12499
  }
12121
- const mod = await import("./dist-G5PDFWKH.js");
12500
+ const mod = await import("./dist-FMA5Y25B.js");
12122
12501
  const status = mod.readE2bCredStatus();
12123
12502
  if (status.auth !== "none") {
12124
12503
  prompt_exports.log.info(`e2b: already configured (${status.auth})`);
@@ -12228,6 +12607,20 @@ pass \`agentbox install --skills-only --force\` to overwrite`
12228
12607
  sp.stop("Agentbox Skills: failed");
12229
12608
  prompt_exports.log.warn(err instanceof Error ? err.message : String(err));
12230
12609
  }
12610
+ try {
12611
+ const codexRes = await installCodexPlugin({
12612
+ force: opts.force,
12613
+ dryRun: opts.dryRun,
12614
+ quiet: true
12615
+ });
12616
+ if (codexRes.ran) {
12617
+ prompt_exports.log.info(
12618
+ codexRes.enableStatus === "added" ? "Codex plugin: installed and enabled by default" : codexRes.enableStatus === "user-enabled" ? "Codex plugin: already enabled" : codexRes.enableStatus === "user-disabled" ? "Codex plugin: installed (left disabled per your config)" : "Codex plugin: installed (could not edit ~/.codex/config.toml)"
12619
+ );
12620
+ }
12621
+ } catch (err) {
12622
+ prompt_exports.log.warn(`Codex plugin setup skipped: ${err instanceof Error ? err.message : String(err)}`);
12623
+ }
12231
12624
  markSetupComplete(providerName);
12232
12625
  const providerGroup = await runProviderChecks(providerName);
12233
12626
  process.stdout.write(" " + formatCompact([sysGroup, providerGroup]) + "\n");
@@ -12238,7 +12631,7 @@ pass \`agentbox install --skills-only --force\` to overwrite`
12238
12631
  await maybePromptStar({ trigger: "install" });
12239
12632
  return true;
12240
12633
  }
12241
- var installCommand = new Command29("install").description(
12634
+ var installCommand = new Command30("install").description(
12242
12635
  "Interactive setup wizard: system check, pick a provider, log in, prepare its base image/snapshot, and install the host /agentbox skill. `--skills-only` runs just the skill install."
12243
12636
  ).option(
12244
12637
  "--skills-only",
@@ -12284,10 +12677,11 @@ var installCommand = new Command29("install").description(
12284
12677
  installCommand.enablePositionalOptions();
12285
12678
  installCommand.addCommand(installCmuxCommand);
12286
12679
  installCommand.addCommand(installHerdrCommand);
12680
+ installCommand.addCommand(installCodexCommand);
12287
12681
 
12288
12682
  // src/commands/doctor.ts
12289
- import { Command as Command30 } from "commander";
12290
- var doctorCommand = new Command30("doctor").description(
12683
+ import { Command as Command31 } from "commander";
12684
+ var doctorCommand = new Command31("doctor").description(
12291
12685
  "Diagnose system compatibility and provider readiness (Node, git, ssh, Docker daemon, provider credentials, prepared snapshots)."
12292
12686
  ).option(
12293
12687
  "-p, --provider <name>",
@@ -12353,7 +12747,7 @@ function formatUnknown(err) {
12353
12747
  }
12354
12748
 
12355
12749
  // src/commands/git.ts
12356
- import { Command as Command31 } from "commander";
12750
+ import { Command as Command32 } from "commander";
12357
12751
  var WORKSPACE = "/workspace";
12358
12752
  var TOKEN_TTL_MS = 12e4;
12359
12753
  async function runInBox(box, argv2) {
@@ -12385,20 +12779,35 @@ function buildPredictedGhPrParams(ghArgs) {
12385
12779
  async function exitWith(code) {
12386
12780
  process.exit(code);
12387
12781
  }
12388
- var pushCommand = new Command31("push").description("Push the box's branch via the host relay (host creds, no prompt)").argument("<box>", "box ref: project index, id, id prefix, name, or container").argument("[args...]", "extra flags forwarded to `agentbox-ctl git push` (e.g. --force-with-lease, --tags)").option("--remote <name>", "remote name (default: origin)").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args, opts) => {
12389
- try {
12390
- const box = await resolveBoxOrExit(boxRef);
12391
- const predicted = buildPredictedGitParams(opts.remote, args);
12392
- const tokenArgs = await hostInitiatedArgs(box.id, "git.push", predicted);
12393
- const argv2 = ["agentbox-ctl", "git", "push", ...tokenArgs];
12394
- if (opts.remote) argv2.push("--remote", opts.remote);
12395
- argv2.push(...args);
12396
- await exitWith(await runAndStream(box, argv2));
12397
- } catch (err) {
12398
- handleLifecycleError(err);
12782
+ var pushCommand = new Command32("push").description("Push the box's branch via the host relay (host creds, no prompt)").argument("<box>", "box ref: project index, id, id prefix, name, or container").argument("[args...]", "extra flags forwarded to `agentbox-ctl git push` (e.g. --force-with-lease, --tags)").option("--remote <name>", "remote name (default: origin)").option("--host-only", "land the branch in the host's local repo only; do NOT push to the remote (nothing is published online)").option("--as <branch>", "with --host-only: destination branch name in the host repo (default: the box's branch name)").option("--force", "with --host-only: allow a non-fast-forward overwrite of the destination branch").allowExcessArguments(true).allowUnknownOption(true).action(
12783
+ async (boxRef, args, opts) => {
12784
+ try {
12785
+ if (opts.hostOnly && opts.remote) {
12786
+ process.stderr.write("agentbox git push: --host-only does not use a remote; drop --remote\n");
12787
+ await exitWith(64);
12788
+ }
12789
+ const box = await resolveBoxOrExit(boxRef);
12790
+ if (opts.hostOnly) {
12791
+ const argv3 = ["agentbox-ctl", "git", "push", "--host-only"];
12792
+ if (opts.as) argv3.push("--as", opts.as);
12793
+ if (opts.force) argv3.push("--force");
12794
+ argv3.push(...args);
12795
+ await exitWith(await runAndStream(box, argv3));
12796
+ return;
12797
+ }
12798
+ const extraArgs = opts.force ? [...args, "--force"] : args;
12799
+ const predicted = buildPredictedGitParams(opts.remote, extraArgs);
12800
+ const tokenArgs = await hostInitiatedArgs(box.id, "git.push", predicted);
12801
+ const argv2 = ["agentbox-ctl", "git", "push", ...tokenArgs];
12802
+ if (opts.remote) argv2.push("--remote", opts.remote);
12803
+ argv2.push(...extraArgs);
12804
+ await exitWith(await runAndStream(box, argv2));
12805
+ } catch (err) {
12806
+ handleLifecycleError(err);
12807
+ }
12399
12808
  }
12400
- });
12401
- var fetchCommand = new Command31("fetch").description("Fetch via the host relay (refs land in the shared .git)").argument("<box>", "box ref").argument("[args...]", "extra flags forwarded to `agentbox-ctl git fetch` (e.g. --prune)").option("--remote <name>", "remote name (default: origin)").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args, opts) => {
12809
+ );
12810
+ var fetchCommand = new Command32("fetch").description("Fetch via the host relay (refs land in the shared .git)").argument("<box>", "box ref").argument("[args...]", "extra flags forwarded to `agentbox-ctl git fetch` (e.g. --prune)").option("--remote <name>", "remote name (default: origin)").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args, opts) => {
12402
12811
  try {
12403
12812
  const box = await resolveBoxOrExit(boxRef);
12404
12813
  const predicted = buildPredictedGitParams(opts.remote, args);
@@ -12411,7 +12820,7 @@ var fetchCommand = new Command31("fetch").description("Fetch via the host relay
12411
12820
  handleLifecycleError(err);
12412
12821
  }
12413
12822
  });
12414
- var pullCommand = new Command31("pull").description(
12823
+ var pullCommand = new Command32("pull").description(
12415
12824
  "Fetch via the relay then merge in /workspace. With <branch>: first `git checkout <branch>` so the box switches base branch and pulls latest \u2014 useful for reusing a box on a new task."
12416
12825
  ).argument("<box>", "box ref").argument("[branch]", "optional branch to switch to before pulling (e.g. main)").argument("[args...]", "extra flags forwarded to `agentbox-ctl git pull`").option("--remote <name>", "remote name (default: origin)").option("--ff-only", "pass --ff-only to the in-box merge").allowExcessArguments(true).allowUnknownOption(true).action(
12417
12826
  async (boxRef, branch, args, opts) => {
@@ -12433,7 +12842,7 @@ var pullCommand = new Command31("pull").description(
12433
12842
  }
12434
12843
  }
12435
12844
  );
12436
- var checkoutCommand = new Command31("checkout").description("Change the box's working branch (runs `git checkout <branch>` in /workspace)").argument("<box>", "box ref").argument("<branch>", "branch to check out inside the box").argument("[args...]", "extra flags forwarded to `git checkout`").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, branch, args) => {
12845
+ var checkoutCommand = new Command32("checkout").description("Change the box's working branch (runs `git checkout <branch>` in /workspace)").argument("<box>", "box ref").argument("<branch>", "branch to check out inside the box").argument("[args...]", "extra flags forwarded to `git checkout`").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, branch, args) => {
12437
12846
  try {
12438
12847
  const box = await resolveBoxOrExit(boxRef);
12439
12848
  await exitWith(await runAndStream(box, ["git", "checkout", branch, ...args]));
@@ -12441,7 +12850,7 @@ var checkoutCommand = new Command31("checkout").description("Change the box's wo
12441
12850
  handleLifecycleError(err);
12442
12851
  }
12443
12852
  });
12444
- var statusCommand = new Command31("status").description("Run `git status` in the box's /workspace (read-only, no relay)").argument("<box>", "box ref").argument("[args...]", "extra flags forwarded to `git status`").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args) => {
12853
+ var statusCommand = new Command32("status").description("Run `git status` in the box's /workspace (read-only, no relay)").argument("<box>", "box ref").argument("[args...]", "extra flags forwarded to `git status`").allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args) => {
12445
12854
  try {
12446
12855
  const box = await resolveBoxOrExit(boxRef);
12447
12856
  await exitWith(await runAndStream(box, ["git", "status", ...args]));
@@ -12467,7 +12876,7 @@ function injectPrCreateHead2(op, box, args) {
12467
12876
  return injectPrCreateHead(op, rootWt?.branch, args);
12468
12877
  }
12469
12878
  function buildPrSubcommand(op) {
12470
- return new Command31(op).description(PR_OP_DESCRIPTIONS[op]).argument("<box>", "box ref").argument(
12879
+ return new Command32(op).description(PR_OP_DESCRIPTIONS[op]).argument("<box>", "box ref").argument(
12471
12880
  "[args...]",
12472
12881
  "extra flags forwarded to `gh pr <op>` (e.g. --title, --body, --label, --draft, --json)"
12473
12882
  ).allowExcessArguments(true).allowUnknownOption(true).action(async (boxRef, args) => {
@@ -12483,18 +12892,18 @@ function buildPrSubcommand(op) {
12483
12892
  }
12484
12893
  });
12485
12894
  }
12486
- var prCommand = new Command31("pr").description(
12895
+ var prCommand = new Command32("pr").description(
12487
12896
  "PR operations against a box's branch via the host `gh` CLI"
12488
12897
  );
12489
12898
  for (const op of GH_PR_OPS) {
12490
12899
  const sub = buildPrSubcommand(op);
12491
12900
  prCommand.addCommand(sub, op === "create" ? { isDefault: true } : void 0);
12492
12901
  }
12493
- var gitCommand = new Command31("git").description("Run git / gh pr operations against a box from the host").addCommand(pushCommand).addCommand(fetchCommand).addCommand(pullCommand).addCommand(checkoutCommand).addCommand(statusCommand).addCommand(prCommand);
12902
+ var gitCommand = new Command32("git").description("Run git / gh pr operations against a box from the host").addCommand(pushCommand).addCommand(fetchCommand).addCommand(pullCommand).addCommand(checkoutCommand).addCommand(statusCommand).addCommand(prCommand);
12494
12903
 
12495
12904
  // src/commands/list.ts
12496
- import { log as log37 } from "@clack/prompts";
12497
- import { Command as Command32 } from "commander";
12905
+ import { log as log39 } from "@clack/prompts";
12906
+ import { Command as Command33 } from "commander";
12498
12907
  import { pathToFileURL } from "url";
12499
12908
 
12500
12909
  // src/hyperlink.ts
@@ -12523,17 +12932,17 @@ async function applyLiveCloudStates(boxes) {
12523
12932
  );
12524
12933
  }
12525
12934
  function withTimeout(p, ms) {
12526
- return new Promise((resolve5) => {
12527
- const t = setTimeout(() => resolve5(null), ms);
12935
+ return new Promise((resolve6) => {
12936
+ const t = setTimeout(() => resolve6(null), ms);
12528
12937
  if (typeof t.unref === "function") t.unref();
12529
12938
  p.then(
12530
12939
  (v) => {
12531
12940
  clearTimeout(t);
12532
- resolve5(v);
12941
+ resolve6(v);
12533
12942
  },
12534
12943
  () => {
12535
12944
  clearTimeout(t);
12536
- resolve5(null);
12945
+ resolve6(null);
12537
12946
  }
12538
12947
  );
12539
12948
  });
@@ -12852,7 +13261,7 @@ async function buildListText(all, live) {
12852
13261
  ${table}`;
12853
13262
  }
12854
13263
  var listCommand2 = withWatchOptions(
12855
- new Command32("list").alias("ls").description("List agent boxes in the current project (-g for all)").option("-j, --json", "machine-readable JSON output").option("-g, --global", "include boxes from all projects").option(
13264
+ new Command33("list").alias("ls").description("List agent boxes in the current project (-g for all)").option("-j, --json", "machine-readable JSON output").option("-g, --global", "include boxes from all projects").option(
12856
13265
  "--live",
12857
13266
  "probe live cloud state via the provider SDK (slower; default: last host-known state)"
12858
13267
  ).option("--cmux", "compact output for the cmux dock sidebar (narrow, 2 lines per box)").option(
@@ -12861,7 +13270,7 @@ var listCommand2 = withWatchOptions(
12861
13270
  )
12862
13271
  ).action(async (opts) => {
12863
13272
  if (opts.json && opts.watch) {
12864
- log37.error("cannot combine --json with --watch");
13273
+ log39.error("cannot combine --json with --watch");
12865
13274
  process.exit(2);
12866
13275
  }
12867
13276
  const all = opts.global ?? false;
@@ -12906,11 +13315,11 @@ var listCommand2 = withWatchOptions(
12906
13315
  });
12907
13316
 
12908
13317
  // src/commands/logs.ts
12909
- import { log as log38 } from "@clack/prompts";
12910
- import { Command as Command33 } from "commander";
13318
+ import { log as log40 } from "@clack/prompts";
13319
+ import { Command as Command34 } from "commander";
12911
13320
  import { spawn as spawn4 } from "child_process";
12912
13321
  var DAEMON_LOG_PATH = "/var/log/agentbox/ctl-daemon.log";
12913
- var logsCommand = new Command33("logs").description("Print recent log lines from a box service; -f to stream").argument(
13322
+ var logsCommand = new Command34("logs").description("Print recent log lines from a box service; -f to stream").argument(
12914
13323
  "[box]",
12915
13324
  "box ref (optional when cwd has exactly 1 box): project index, id, id prefix, name, or container"
12916
13325
  ).argument("[service]", "service name from agentbox.yaml").option("-n, --tail <n>", "how many recent lines to print first", "200").option("-f, --follow", "keep the connection open and stream new lines").option(
@@ -12928,9 +13337,9 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12928
13337
  service = boxArg;
12929
13338
  }
12930
13339
  if (!service && !opts.daemon) {
12931
- log38.error("missing <service> argument");
12932
- log38.info("usage: agentbox logs [box] <service> [-n N] [-f]");
12933
- log38.info(" agentbox logs [box] --daemon [-n N] [-f]");
13340
+ log40.error("missing <service> argument");
13341
+ log40.info("usage: agentbox logs [box] <service> [-n N] [-f]");
13342
+ log40.info(" agentbox logs [box] --daemon [-n N] [-f]");
12934
13343
  process.exit(2);
12935
13344
  }
12936
13345
  const box = await resolveBoxOrExit(idOrName);
@@ -12941,7 +13350,7 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12941
13350
  if (!opts.follow) {
12942
13351
  const proc = await provider.exec(box, args, { user: "vscode" });
12943
13352
  if (proc.exitCode !== 0) {
12944
- log38.error(
13353
+ log40.error(
12945
13354
  `${opts.daemon ? "daemon log" : "agentbox-ctl logs"} failed: ${proc.stderr || proc.stdout}`
12946
13355
  );
12947
13356
  process.exit(1);
@@ -12997,12 +13406,12 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12997
13406
  });
12998
13407
 
12999
13408
  // src/commands/open.ts
13000
- import { log as log39 } from "@clack/prompts";
13409
+ import { log as log41 } from "@clack/prompts";
13001
13410
  import { execa as execa6 } from "execa";
13002
- import { existsSync as existsSync12, mkdirSync as mkdirSync10 } from "fs";
13003
- import { homedir as homedir20 } from "os";
13004
- import { join as join23 } from "path";
13005
- import { Command as Command34 } from "commander";
13411
+ import { existsSync as existsSync14, mkdirSync as mkdirSync11 } from "fs";
13412
+ import { homedir as homedir21 } from "os";
13413
+ import { join as join25 } from "path";
13414
+ import { Command as Command35 } from "commander";
13006
13415
 
13007
13416
  // src/commands/path.ts
13008
13417
  async function runPath(box, opts) {
@@ -13024,7 +13433,7 @@ async function runPath(box, opts) {
13024
13433
  }
13025
13434
 
13026
13435
  // src/commands/open.ts
13027
- var openCommand = new Command34("open").description("Open a box's /workspace in Finder (docker: rsync'd snapshot; cloud: sshfs mount)").argument(
13436
+ var openCommand = new Command35("open").description("Open a box's /workspace in Finder (docker: rsync'd snapshot; cloud: sshfs mount)").argument(
13028
13437
  "[box]",
13029
13438
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
13030
13439
  ).option("--no-refresh", "skip the rsync; open whatever's already on disk (docker only)").option(
@@ -13036,10 +13445,9 @@ var openCommand = new Command34("open").description("Open a box's /workspace in
13036
13445
  ).action(async (idOrName, opts) => {
13037
13446
  try {
13038
13447
  const box = await resolveBoxOrExit(idOrName);
13039
- const provider = await providerForBox(box);
13040
13448
  const isCloud = (box.provider ?? "docker") !== "docker";
13041
13449
  if (isCloud) {
13042
- await runCloudOpen(box, provider, opts);
13450
+ await runCloudOpen(box, opts);
13043
13451
  return;
13044
13452
  }
13045
13453
  if (opts.path || opts.print) {
@@ -13062,8 +13470,8 @@ var openCommand = new Command34("open").description("Open a box's /workspace in
13062
13470
  handleLifecycleError(err);
13063
13471
  }
13064
13472
  });
13065
- async function runCloudOpen(box, provider, opts) {
13066
- const mountRoot = join23(homedir20(), ".agentbox", "mounts", box.name);
13473
+ async function runCloudOpen(box, opts) {
13474
+ const mountRoot = join25(homedir21(), ".agentbox", "mounts", box.name);
13067
13475
  if (opts.unmount) {
13068
13476
  const ok = await tryUnmount(mountRoot);
13069
13477
  if (ok) process.stdout.write(`unmounted ${mountRoot}
@@ -13083,30 +13491,14 @@ async function runCloudOpen(box, provider, opts) {
13083
13491
  "sshfs not found on PATH. Install with `brew install macfuse sshfs` (macOS) or your distro's package manager, then retry. Cloud `agentbox open` mounts the sandbox /workspace via sshfs."
13084
13492
  );
13085
13493
  }
13086
- if (!provider.buildAttach) {
13087
- throw new Error(
13088
- `cloud provider '${provider.name}' does not support SSH attach \u2014 \`agentbox open\` requires it for cloud boxes`
13089
- );
13090
- }
13091
- const spec = await provider.buildAttach(box, "shell", { noTmux: true });
13092
- const target = parseSshTarget(spec.argv);
13093
- if (!target) {
13094
- throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
13095
- }
13096
- const alias = agentboxAliasFor(box.name);
13097
- await writeAgentboxSshAlias({
13098
- alias,
13099
- hostname: target.host,
13100
- user: target.user,
13101
- identityFile: target.identityFile
13102
- });
13103
- if (!existsSync12(mountRoot)) {
13104
- mkdirSync10(mountRoot, { recursive: true, mode: 493 });
13494
+ const { alias } = await ensureCloudSshAlias(box);
13495
+ if (!existsSync14(mountRoot)) {
13496
+ mkdirSync11(mountRoot, { recursive: true, mode: 493 });
13105
13497
  } else if (await isMounted(mountRoot)) {
13106
- log39.info(`re-mounting (stale mount detected at ${mountRoot})`);
13498
+ log41.info(`re-mounting (stale mount detected at ${mountRoot})`);
13107
13499
  await tryUnmount(mountRoot);
13108
13500
  }
13109
- log39.info(`mounting ${alias}:/workspace at ${mountRoot}`);
13501
+ log41.info(`mounting ${alias}:/workspace at ${mountRoot}`);
13110
13502
  const mount = await execa6(
13111
13503
  sshfsBin,
13112
13504
  [
@@ -13153,8 +13545,8 @@ async function tryUnmount(path) {
13153
13545
  }
13154
13546
 
13155
13547
  // src/commands/pause.ts
13156
- import { Command as Command35 } from "commander";
13157
- var pauseCommand = new Command35("pause").description(
13548
+ import { Command as Command36 } from "commander";
13549
+ var pauseCommand = new Command36("pause").description(
13158
13550
  "Pause a box. Docker: `docker pause` (cgroup freeze \u2014 sub-second resume). Cloud: backend.pause (Daytona archive \u2014 cold storage; resume is slower but uses no quota while archived)."
13159
13551
  ).argument(
13160
13552
  "[box]",
@@ -13177,7 +13569,7 @@ var pauseCommand = new Command35("pause").description(
13177
13569
  });
13178
13570
 
13179
13571
  // src/commands/prune.ts
13180
- import { Command as Command36 } from "commander";
13572
+ import { Command as Command37 } from "commander";
13181
13573
  function totalRemovals(r, projectConfigs) {
13182
13574
  return r.removedRecords.length + r.removedContainers.length + r.removedVolumes.length + r.removedSnapshotDirs.length + r.removedBoxDirs.length + projectConfigs.length;
13183
13575
  }
@@ -13223,7 +13615,7 @@ async function liveProjectRoots() {
13223
13615
  return [];
13224
13616
  }
13225
13617
  }
13226
- var pruneCommand = new Command36("prune").description("Clean up orphan state.json records (and with --all, orphan docker resources)").option("--dry-run", "show what would be removed, don't change anything").option(
13618
+ var pruneCommand = new Command37("prune").description("Clean up orphan state.json records (and with --all, orphan docker resources)").option("--dry-run", "show what would be removed, don't change anything").option(
13227
13619
  "--all",
13228
13620
  "also remove orphan agentbox-* containers, volumes, snapshot dirs, and orphan per-project config dirs"
13229
13621
  ).option("-y, --yes", "skip the confirmation prompt").option(
@@ -13337,17 +13729,17 @@ async function pruneCloud(provider, opts) {
13337
13729
 
13338
13730
  // src/commands/queue.ts
13339
13731
  import { readFile as readFile6, stat as stat6 } from "fs/promises";
13340
- import { intro as intro10, log as log41, outro as outro9 } from "@clack/prompts";
13341
- import { Command as Command37 } from "commander";
13732
+ import { intro as intro11, log as log43, outro as outro10 } from "@clack/prompts";
13733
+ import { Command as Command38 } from "commander";
13342
13734
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["done", "failed", "cancelled"]);
13343
- var queueCommand = new Command37("queue").description("Inspect and manage background `agentbox claude|codex|opencode -i` jobs");
13344
- var queueListCommand = new Command37("list").description("List queued, running, and (with --all) terminal background jobs").option("--all", "include done/failed/cancelled jobs (default: hide terminal)").action(async (opts) => {
13735
+ var queueCommand = new Command38("queue").description("Inspect and manage background `agentbox claude|codex|opencode -i` jobs");
13736
+ var queueListCommand = new Command38("list").description("List queued, running, and (with --all) terminal background jobs").option("--all", "include done/failed/cancelled jobs (default: hide terminal)").action(async (opts) => {
13345
13737
  const jobs = await loadQueue();
13346
13738
  const cfg = await loadQueueConfig();
13347
13739
  const visible = opts.all === true ? jobs : jobs.filter((j) => !TERMINAL_STATUSES.has(j.status));
13348
13740
  if (visible.length === 0) {
13349
- log41.info(opts.all ? "no queued jobs." : "no active queued jobs (--all to see terminal).");
13350
- log41.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
13741
+ log43.info(opts.all ? "no queued jobs." : "no active queued jobs (--all to see terminal).");
13742
+ log43.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
13351
13743
  return;
13352
13744
  }
13353
13745
  const rows = visible.map((j) => ({
@@ -13372,12 +13764,12 @@ var queueListCommand = new Command37("list").description("List queued, running,
13372
13764
  headers.map((h, i) => pad4(String(r[h]), widths[i])).join(" ") + "\n"
13373
13765
  );
13374
13766
  }
13375
- log41.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
13767
+ log43.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
13376
13768
  });
13377
- var queueShowCommand = new Command37("show").description("Dump a job manifest and tail its log").argument("<id>", "queue job id (from `agentbox queue list`)").option("--tail <n>", "lines of log to print (default: 50)", "50").action(async (id, opts) => {
13769
+ var queueShowCommand = new Command38("show").description("Dump a job manifest and tail its log").argument("<id>", "queue job id (from `agentbox queue list`)").option("--tail <n>", "lines of log to print (default: 50)", "50").action(async (id, opts) => {
13378
13770
  const job = await readJob(id);
13379
13771
  if (!job) {
13380
- log41.error(`no job with id ${id}`);
13772
+ log43.error(`no job with id ${id}`);
13381
13773
  process.exit(1);
13382
13774
  }
13383
13775
  process.stdout.write(JSON.stringify(job, null, 2) + "\n");
@@ -13393,18 +13785,18 @@ var queueShowCommand = new Command37("show").description("Dump a job manifest an
13393
13785
  process.stdout.write(slice.join("\n"));
13394
13786
  if (!slice.join("\n").endsWith("\n")) process.stdout.write("\n");
13395
13787
  } catch {
13396
- log41.info(`(no log at ${job.logPath} yet)`);
13788
+ log43.info(`(no log at ${job.logPath} yet)`);
13397
13789
  }
13398
13790
  });
13399
- var queueCancelCommand = new Command37("cancel").description("Cancel a queued job; running jobs are NOT killed \u2014 use `agentbox destroy` instead").argument("<id>", "queue job id (from `agentbox queue list`)").action(async (id) => {
13400
- intro10(`Cancelling queue job ${id}...`);
13791
+ var queueCancelCommand = new Command38("cancel").description("Cancel a queued job; running jobs are NOT killed \u2014 use `agentbox destroy` instead").argument("<id>", "queue job id (from `agentbox queue list`)").action(async (id) => {
13792
+ intro11(`Cancelling queue job ${id}...`);
13401
13793
  const job = await readJob(id);
13402
13794
  if (!job) {
13403
- log41.error(`no job with id ${id}`);
13795
+ log43.error(`no job with id ${id}`);
13404
13796
  process.exit(1);
13405
13797
  }
13406
13798
  if (job.status !== "queued") {
13407
- log41.error(
13799
+ log43.error(
13408
13800
  `job ${id} is ${job.status}; cancel only flips 'queued' \u2192 'cancelled'.` + (job.status === "running" ? ` Use 'agentbox destroy ${job.boxName || id}' to stop the box.` : "")
13409
13801
  );
13410
13802
  process.exit(1);
@@ -13416,15 +13808,15 @@ var queueCancelCommand = new Command37("cancel").description("Cancel a queued jo
13416
13808
  reason: "cancelled by user"
13417
13809
  };
13418
13810
  await writeJob(cancelled);
13419
- outro9(`job ${id} cancelled`);
13811
+ outro10(`job ${id} cancelled`);
13420
13812
  });
13421
- var queueClearCommand = new Command37("clear").description("Sweep terminal-state manifests from ~/.agentbox/queue/").option("--done", "remove done jobs").option("--failed", "remove failed jobs").option("--cancelled", "remove cancelled jobs").option("--all", "remove every terminal-state job (done + failed + cancelled)").action(async (opts) => {
13813
+ var queueClearCommand = new Command38("clear").description("Sweep terminal-state manifests from ~/.agentbox/queue/").option("--done", "remove done jobs").option("--failed", "remove failed jobs").option("--cancelled", "remove cancelled jobs").option("--all", "remove every terminal-state job (done + failed + cancelled)").action(async (opts) => {
13422
13814
  const targets = /* @__PURE__ */ new Set();
13423
13815
  if (opts.all === true || opts.done === true) targets.add("done");
13424
13816
  if (opts.all === true || opts.failed === true) targets.add("failed");
13425
13817
  if (opts.all === true || opts.cancelled === true) targets.add("cancelled");
13426
13818
  if (targets.size === 0) {
13427
- log41.error("pick at least one of: --done, --failed, --cancelled, --all");
13819
+ log43.error("pick at least one of: --done, --failed, --cancelled, --all");
13428
13820
  process.exit(2);
13429
13821
  }
13430
13822
  const jobs = await loadQueue();
@@ -13434,7 +13826,7 @@ var queueClearCommand = new Command37("clear").description("Sweep terminal-state
13434
13826
  await deleteJob(j.id);
13435
13827
  removed += 1;
13436
13828
  }
13437
- log41.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
13829
+ log43.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
13438
13830
  });
13439
13831
  var QUEUE_WAIT_EVENTS = [
13440
13832
  "new-box",
@@ -13447,11 +13839,11 @@ var QUEUE_WAIT_EVENTS = [
13447
13839
  var ACTIVE_JOB_STATUSES = /* @__PURE__ */ new Set(["queued", "running"]);
13448
13840
  var DEFAULT_QUEUE_WAIT_TIMEOUT_MS = 10 * 60 * 1e3;
13449
13841
  var QUEUE_POLL_INTERVAL_MS = 500;
13450
- var queueWaitForCommand = new Command37("wait-for").description(
13842
+ var queueWaitForCommand = new Command38("wait-for").description(
13451
13843
  `Block until a queue / box event fires. <event> one of: ${QUEUE_WAIT_EVENTS.join(" | ")}.`
13452
13844
  ).argument("<event>", `target event: ${QUEUE_WAIT_EVENTS.join(" | ")}`).option("--box <ref>", "box ref (required for box-paused / box-running / box-stopped)").option("--job <id>", "queue job id (required for job-done)").option("--timeout <ms>", `wall-clock cap (default: ${String(DEFAULT_QUEUE_WAIT_TIMEOUT_MS)})`).option("--json", "emit a JSON envelope { matched, elapsedMs, ... }").action(async (eventRaw, opts) => {
13453
13845
  if (!QUEUE_WAIT_EVENTS.includes(eventRaw)) {
13454
- log41.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
13846
+ log43.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
13455
13847
  process.exit(2);
13456
13848
  }
13457
13849
  const event = eventRaw;
@@ -13471,11 +13863,11 @@ var queueWaitForCommand = new Command37("wait-for").description(
13471
13863
  if (opts.json === true) {
13472
13864
  process.stdout.write(JSON.stringify({ matched: false, event, elapsedMs }) + "\n");
13473
13865
  } else {
13474
- log41.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
13866
+ log43.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
13475
13867
  }
13476
13868
  process.exit(1);
13477
13869
  }
13478
- log41.error(err instanceof Error ? err.message : String(err));
13870
+ log43.error(err instanceof Error ? err.message : String(err));
13479
13871
  process.exit(1);
13480
13872
  }
13481
13873
  });
@@ -13572,8 +13964,8 @@ function truncate(s, max) {
13572
13964
  }
13573
13965
 
13574
13966
  // src/commands/relay.ts
13575
- import { log as log42, spinner as spinner9 } from "@clack/prompts";
13576
- import { Command as Command38 } from "commander";
13967
+ import { log as log44, spinner as spinner9 } from "@clack/prompts";
13968
+ import { Command as Command39 } from "commander";
13577
13969
  async function rehydrateFromState() {
13578
13970
  const state = await readState();
13579
13971
  await rehydrateRelayRegistry(
@@ -13616,7 +14008,7 @@ function renderStatus(s) {
13616
14008
  }
13617
14009
  return ["relay: not running", ` log: ${s.logFile}`].join("\n");
13618
14010
  }
13619
- var statusSub = new Command38("status").description("Show whether the host relay is running, with pid / port / box count").option("--json", "emit RelayStatus as JSON").action(async (opts) => {
14011
+ var statusSub = new Command39("status").description("Show whether the host relay is running, with pid / port / box count").option("--json", "emit RelayStatus as JSON").action(async (opts) => {
13620
14012
  try {
13621
14013
  const s = await getRelayStatus();
13622
14014
  if (opts.json) {
@@ -13628,7 +14020,7 @@ var statusSub = new Command38("status").description("Show whether the host relay
13628
14020
  handleLifecycleError(err);
13629
14021
  }
13630
14022
  });
13631
- var stopSub = new Command38("stop").description("Stop the host relay process (idempotent)").action(async () => {
14023
+ var stopSub = new Command39("stop").description("Stop the host relay process (idempotent)").action(async () => {
13632
14024
  try {
13633
14025
  const s = spinner9();
13634
14026
  s.start("stopping relay");
@@ -13640,7 +14032,7 @@ var stopSub = new Command38("stop").description("Stop the host relay process (id
13640
14032
  handleLifecycleError(err);
13641
14033
  }
13642
14034
  });
13643
- var startSub = new Command38("start").description("Start the host relay if not already running (idempotent)").action(async () => {
14035
+ var startSub = new Command39("start").description("Start the host relay if not already running (idempotent)").action(async () => {
13644
14036
  try {
13645
14037
  const s = spinner9();
13646
14038
  s.start("starting relay");
@@ -13651,7 +14043,7 @@ var startSub = new Command38("start").description("Start the host relay if not a
13651
14043
  handleLifecycleError(err);
13652
14044
  }
13653
14045
  });
13654
- var restartSub = new Command38("restart").description("Stop then start the host relay").action(async () => {
14046
+ var restartSub = new Command39("restart").description("Stop then start the host relay").action(async () => {
13655
14047
  try {
13656
14048
  const s = spinner9();
13657
14049
  s.start("stopping relay");
@@ -13667,35 +14059,35 @@ var restartSub = new Command38("restart").description("Stop then start the host
13667
14059
  s2.stop(`relay running on ${ep.hostUrl}`);
13668
14060
  } catch (err) {
13669
14061
  s2.stop("relay start failed");
13670
- log42.warn(err instanceof Error ? err.message : String(err));
14062
+ log44.warn(err instanceof Error ? err.message : String(err));
13671
14063
  throw err;
13672
14064
  }
13673
14065
  } catch (err) {
13674
14066
  handleLifecycleError(err);
13675
14067
  }
13676
14068
  });
13677
- var relayCommand = new Command38("relay").description("Manage the host relay process (status / stop / start / restart)").addCommand(statusSub, { isDefault: true }).addCommand(stopSub).addCommand(startSub).addCommand(restartSub);
14069
+ var relayCommand = new Command39("relay").description("Manage the host relay process (status / stop / start / restart)").addCommand(statusSub, { isDefault: true }).addCommand(stopSub).addCommand(startSub).addCommand(restartSub);
13678
14070
 
13679
14071
  // src/commands/_run-queued-job.ts
13680
- import { Command as Command39 } from "commander";
13681
- var runQueuedJobCommand = new Command39("_run-queued-job").description("internal: run a queued background agent job (do not invoke directly)").argument("<id>", "queue job id (from ~/.agentbox/queue/<id>.json)").action(async (id) => {
13682
- const log51 = openCommandLog(`queue-${id}`);
13683
- log51.write(`worker pid=${String(process.pid)} starting for job ${id}`);
14072
+ import { Command as Command40 } from "commander";
14073
+ var runQueuedJobCommand = new Command40("_run-queued-job").description("internal: run a queued background agent job (do not invoke directly)").argument("<id>", "queue job id (from ~/.agentbox/queue/<id>.json)").action(async (id) => {
14074
+ const log54 = openCommandLog(`queue-${id}`);
14075
+ log54.write(`worker pid=${String(process.pid)} starting for job ${id}`);
13684
14076
  let job = null;
13685
14077
  try {
13686
14078
  job = await readJob(id);
13687
14079
  if (!job) {
13688
- log51.write(`FATAL: no manifest at id=${id}`);
13689
- log51.close();
14080
+ log54.write(`FATAL: no manifest at id=${id}`);
14081
+ log54.close();
13690
14082
  process.exit(64);
13691
14083
  }
13692
14084
  const onBoxCreated = (boxId) => {
13693
14085
  if (job) job = { ...job, boxId };
13694
14086
  };
13695
14087
  if ((job.providerName || "docker") === "docker") {
13696
- await runDockerJob(job, log51, onBoxCreated);
14088
+ await runDockerJob(job, log54, onBoxCreated);
13697
14089
  } else {
13698
- await runCloudJob(job, log51, onBoxCreated);
14090
+ await runCloudJob(job, log54, onBoxCreated);
13699
14091
  }
13700
14092
  const done = {
13701
14093
  ...job,
@@ -13704,12 +14096,12 @@ var runQueuedJobCommand = new Command39("_run-queued-job").description("internal
13704
14096
  exitCode: 0
13705
14097
  };
13706
14098
  await writeJob(done);
13707
- log51.write(`done`);
13708
- log51.close();
14099
+ log54.write(`done`);
14100
+ log54.close();
13709
14101
  process.exit(0);
13710
14102
  } catch (err) {
13711
14103
  const msg = err instanceof Error ? err.stack ?? err.message : String(err);
13712
- log51.write(`FAIL: ${msg}`);
14104
+ log54.write(`FAIL: ${msg}`);
13713
14105
  if (job) {
13714
14106
  try {
13715
14107
  const failed = {
@@ -13723,11 +14115,11 @@ var runQueuedJobCommand = new Command39("_run-queued-job").description("internal
13723
14115
  } catch {
13724
14116
  }
13725
14117
  }
13726
- log51.close();
14118
+ log54.close();
13727
14119
  process.exit(1);
13728
14120
  }
13729
14121
  });
13730
- async function runDockerJob(job, log51, onBoxCreated) {
14122
+ async function runDockerJob(job, log54, onBoxCreated) {
13731
14123
  const opts = job.createOpts;
13732
14124
  const cfg = await loadEffectiveConfig(opts.workspace, {
13733
14125
  cliOverrides: buildOverridesFromJob(job)
@@ -13739,7 +14131,7 @@ async function runDockerJob(job, log51, onBoxCreated) {
13739
14131
  const useSnapshot = opts.hostSnapshot === false ? false : opts.hostSnapshot === true ? true : cfg.effective.box.hostSnapshot ?? false;
13740
14132
  const resolved = job.agent === "claude-code" ? await resolveClaudeAuth(process.env) : null;
13741
14133
  const withPlaywright = cfg.effective.box.withPlaywright || cfg.effective.browser.default !== "agent-browser";
13742
- log51.write(`creating box for agent=${job.agent}`);
14134
+ log54.write(`creating box for agent=${job.agent}`);
13743
14135
  const result = await createBox({
13744
14136
  workspacePath: opts.workspace,
13745
14137
  name: opts.name && opts.name.length > 0 ? opts.name : void 0,
@@ -13765,22 +14157,24 @@ async function runDockerJob(job, log51, onBoxCreated) {
13765
14157
  // at box-create time (the worker runs on the host, so it can read the files).
13766
14158
  carry: opts.carry,
13767
14159
  projectRoot,
13768
- onLog: (line) => log51.write(line)
14160
+ onLog: (line) => log54.write(line)
13769
14161
  });
13770
- log51.write(`box created: ${result.record.container}`);
14162
+ log54.write(`box created: ${result.record.container}`);
13771
14163
  onBoxCreated(result.record.id);
14164
+ await recordLastAgent(result.record.id, agentBinaryName(job.agent)).catch(() => {
14165
+ });
13772
14166
  await writeJob({ ...job, boxId: result.record.id });
13773
14167
  const resyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
13774
- if (resyncWarning) log51.write(resyncWarning);
14168
+ if (resyncWarning) log54.write(resyncWarning);
13775
14169
  const prompt = prependResyncWarning(resyncWarning, job.prompt);
13776
14170
  const promptedArgs = buildPromptArgs(job.agent, prompt, job.agentArgs);
13777
14171
  if (job.agent === "claude-code") {
13778
- log51.write(`checking plugin native deps`);
14172
+ log54.write(`checking plugin native deps`);
13779
14173
  await rebuildPluginNativeDeps(result.record.container, {
13780
14174
  volume: result.record.claudeConfigVolume ?? SHARED_CLAUDE_VOLUME,
13781
- onProgress: (line) => log51.write(line)
14175
+ onProgress: (line) => log54.write(line)
13782
14176
  });
13783
- log51.write(`starting claude session`);
14177
+ log54.write(`starting claude session`);
13784
14178
  await startClaudeSession({
13785
14179
  container: result.record.container,
13786
14180
  claudeArgs: applyClaudeSkipPermissions(promptedArgs, cfg.effective),
@@ -13788,22 +14182,22 @@ async function runDockerJob(job, log51, onBoxCreated) {
13788
14182
  boxName: result.record.name
13789
14183
  });
13790
14184
  } else if (job.agent === "codex") {
13791
- log51.write(`checking codex`);
14185
+ log54.write(`checking codex`);
13792
14186
  await ensureCodexInstalled(result.record.container, {
13793
- onProgress: (line) => log51.write(line)
14187
+ onProgress: (line) => log54.write(line)
13794
14188
  });
13795
- log51.write(`starting codex session`);
14189
+ log54.write(`starting codex session`);
13796
14190
  await startCodexSession({
13797
14191
  container: result.record.container,
13798
14192
  codexArgs: applyCodexSkipPermissions(promptedArgs, cfg.effective),
13799
14193
  sessionName: cfg.effective.codex.sessionName
13800
14194
  });
13801
14195
  } else if (job.agent === "opencode") {
13802
- log51.write(`checking opencode`);
14196
+ log54.write(`checking opencode`);
13803
14197
  await ensureOpencodeInstalled(result.record.container, {
13804
- onProgress: (line) => log51.write(line)
14198
+ onProgress: (line) => log54.write(line)
13805
14199
  });
13806
- log51.write(`starting opencode session`);
14200
+ log54.write(`starting opencode session`);
13807
14201
  await startOpencodeSession({
13808
14202
  container: result.record.container,
13809
14203
  opencodeArgs: promptedArgs,
@@ -13812,17 +14206,17 @@ async function runDockerJob(job, log51, onBoxCreated) {
13812
14206
  } else {
13813
14207
  throw new Error(`unknown agent kind: ${String(job.agent)}`);
13814
14208
  }
13815
- await maybeOpenQueuedTerminal(job, result.record.name, log51);
14209
+ await maybeOpenQueuedTerminal(job, result.record.name, log54);
13816
14210
  }
13817
14211
  function agentBinaryName(agent) {
13818
14212
  return agent === "claude-code" ? "claude" : agent;
13819
14213
  }
13820
- async function maybeOpenQueuedTerminal(job, boxName, log51) {
14214
+ async function maybeOpenQueuedTerminal(job, boxName, log54) {
13821
14215
  const ctx = job.openTerminal;
13822
14216
  if (!ctx) return;
13823
14217
  const cliEntry = process.env["AGENTBOX_CLI_ENTRY"];
13824
14218
  if (!cliEntry) {
13825
- log51.write("queue.openIn: AGENTBOX_CLI_ENTRY unset; cannot open terminal");
14219
+ log54.write("queue.openIn: AGENTBOX_CLI_ENTRY unset; cannot open terminal");
13826
14220
  return;
13827
14221
  }
13828
14222
  const argv2 = [
@@ -13836,14 +14230,14 @@ async function maybeOpenQueuedTerminal(job, boxName, log51) {
13836
14230
  ];
13837
14231
  try {
13838
14232
  const r = await spawnQueuedOpenTerminal(ctx, argv2, boxName);
13839
- log51.write(
14233
+ log54.write(
13840
14234
  r.launched ? `queue.openIn: ${r.note}` : `queue.openIn: open failed: ${r.error ?? ""}`
13841
14235
  );
13842
14236
  } catch (err) {
13843
- log51.write(`queue.openIn: open threw: ${err instanceof Error ? err.message : String(err)}`);
14237
+ log54.write(`queue.openIn: open threw: ${err instanceof Error ? err.message : String(err)}`);
13844
14238
  }
13845
14239
  }
13846
- async function runCloudJob(job, log51, onBoxCreated) {
14240
+ async function runCloudJob(job, log54, onBoxCreated) {
13847
14241
  const opts = job.createOpts;
13848
14242
  const cfg = await loadEffectiveConfig(opts.workspace, {
13849
14243
  cliOverrides: buildOverridesFromJob(job)
@@ -13854,7 +14248,7 @@ async function runCloudJob(job, log51, onBoxCreated) {
13854
14248
  const providerDefault = resolveDefaultCheckpoint(cfg.effective, providerName);
13855
14249
  const checkpointRef = opts.snapshot && opts.snapshot.length > 0 ? opts.snapshot : providerDefault.length > 0 ? providerDefault : void 0;
13856
14250
  const withPlaywright = cfg.effective.box.withPlaywright || cfg.effective.browser.default !== "agent-browser";
13857
- log51.write(`creating cloud box (${providerName}) for agent=${job.agent}`);
14251
+ log54.write(`creating cloud box (${providerName}) for agent=${job.agent}`);
13858
14252
  const result = await provider.create({
13859
14253
  workspacePath: opts.workspace,
13860
14254
  name: opts.name && opts.name.length > 0 ? opts.name : void 0,
@@ -13868,10 +14262,12 @@ async function runCloudJob(job, log51, onBoxCreated) {
13868
14262
  // worker runs on the host too, so it reads the files and uploads them.
13869
14263
  carry: opts.carry,
13870
14264
  projectRoot,
13871
- onLog: (line) => log51.write(line)
14265
+ onLog: (line) => log54.write(line)
13872
14266
  });
13873
- log51.write(`box created: ${result.record.id}`);
14267
+ log54.write(`box created: ${result.record.id}`);
13874
14268
  onBoxCreated(result.record.id);
14269
+ await recordLastAgent(result.record.id, agentBinaryName(job.agent)).catch(() => {
14270
+ });
13875
14271
  await writeJob({ ...job, boxId: result.record.id });
13876
14272
  const promptedArgs = buildPromptArgs(job.agent, job.prompt, job.agentArgs);
13877
14273
  let binary;
@@ -13892,14 +14288,14 @@ async function runCloudJob(job, log51, onBoxCreated) {
13892
14288
  } else {
13893
14289
  throw new Error(`unknown agent kind: ${String(job.agent)}`);
13894
14290
  }
13895
- log51.write(`starting detached ${job.agent} session`);
14291
+ log54.write(`starting detached ${job.agent} session`);
13896
14292
  await cloudAgentStartDetached({
13897
14293
  box: result.record,
13898
14294
  binary,
13899
14295
  sessionName,
13900
14296
  extraArgs
13901
14297
  });
13902
- await maybeOpenQueuedTerminal(job, result.record.name, log51);
14298
+ await maybeOpenQueuedTerminal(job, result.record.name, log54);
13903
14299
  }
13904
14300
  function buildOverridesFromJob(job) {
13905
14301
  const opts = job.createOpts;
@@ -13929,7 +14325,7 @@ function buildOverridesFromJob(job) {
13929
14325
  }
13930
14326
 
13931
14327
  // src/commands/_claude-login-worker.ts
13932
- import { Command as Command40 } from "commander";
14328
+ import { Command as Command41 } from "commander";
13933
14329
  var URL_TIMEOUT_MS = 6e4;
13934
14330
  var CODE_TIMEOUT_MS = 10 * 6e4;
13935
14331
  var POLL_MS2 = 500;
@@ -13941,9 +14337,9 @@ function tailOf(buf) {
13941
14337
  const tail = lines.slice(-2).join(" ");
13942
14338
  return tail.length > 240 ? tail.slice(-240) : tail;
13943
14339
  }
13944
- var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description("internal: drive `claude auth login` under a pty for headless login (do not invoke directly)").argument("<id>", "login session id (~/.agentbox/claude-login/<id>/)").action(async (id) => {
13945
- const log51 = openCommandLog(`claude-login-${id}`);
13946
- log51.write(`worker pid=${String(process.pid)} starting for session ${id}`);
14340
+ var claudeLoginWorkerCommand = new Command41("_claude-login-worker").description("internal: drive `claude auth login` under a pty for headless login (do not invoke directly)").argument("<id>", "login session id (~/.agentbox/claude-login/<id>/)").action(async (id) => {
14341
+ const log54 = openCommandLog(`claude-login-${id}`);
14342
+ log54.write(`worker pid=${String(process.pid)} starting for session ${id}`);
13947
14343
  const base = { pid: process.pid, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
13948
14344
  let cur = { ...base, phase: "starting" };
13949
14345
  const setState = (patch) => {
@@ -13952,16 +14348,16 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
13952
14348
  };
13953
14349
  const req = readLoginRequest(id);
13954
14350
  if (!req) {
13955
- log51.write(`FATAL: no request.json for session ${id}`);
14351
+ log54.write(`FATAL: no request.json for session ${id}`);
13956
14352
  setState({ phase: "error", error: "internal: missing login request" });
13957
- log51.close();
14353
+ log54.close();
13958
14354
  process.exit(64);
13959
14355
  }
13960
14356
  const backend = await loadPtyBackend();
13961
14357
  if (!backend) {
13962
- log51.write("FATAL: node-pty backend unavailable");
14358
+ log54.write("FATAL: node-pty backend unavailable");
13963
14359
  setState({ phase: "error", error: "pty-unavailable: the node-pty prebuild is not installed" });
13964
- log51.close();
14360
+ log54.close();
13965
14361
  process.exit(1);
13966
14362
  }
13967
14363
  const methodArgs = req.extraArgs.length > 0 ? req.extraArgs : ["--claudeai"];
@@ -13970,7 +14366,7 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
13970
14366
  image: req.image,
13971
14367
  extraArgs: methodArgs
13972
14368
  });
13973
- log51.write(`spawning: docker ${dockerArgv.join(" ")}`);
14369
+ log54.write(`spawning: docker ${dockerArgv.join(" ")}`);
13974
14370
  let buf = "";
13975
14371
  let urlPublished = false;
13976
14372
  let lastError;
@@ -13989,13 +14385,13 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
13989
14385
  pty.kill();
13990
14386
  } catch {
13991
14387
  }
13992
- log51.close();
14388
+ log54.close();
13993
14389
  process.exit(code);
13994
14390
  };
13995
14391
  for (const sig of ["SIGTERM", "SIGINT"]) {
13996
14392
  process.on(sig, () => {
13997
14393
  if (finished) return;
13998
- log51.write(`received ${sig}; aborting`);
14394
+ log54.write(`received ${sig}; aborting`);
13999
14395
  setState({ phase: "error", error: `login worker terminated (${sig})` });
14000
14396
  cleanExit(1);
14001
14397
  });
@@ -14004,7 +14400,7 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
14004
14400
  if (finished || cur.phase !== "awaiting-code") return;
14005
14401
  const code = takeLoginCode(id);
14006
14402
  if (code) {
14007
- log51.write("received code; submitting to login");
14403
+ log54.write("received code; submitting to login");
14008
14404
  setState({ phase: "exchanging" });
14009
14405
  pty.write(code + "\r");
14010
14406
  }
@@ -14013,25 +14409,25 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
14013
14409
  pty.onData((d) => {
14014
14410
  buf += d;
14015
14411
  if (buf.length > BUF_CAP) buf = buf.slice(-BUF_CAP);
14016
- log51.raw(d);
14412
+ log54.raw(d);
14017
14413
  if (!urlPublished) {
14018
14414
  const url = extractOAuthUrl(buf);
14019
14415
  if (url) {
14020
14416
  urlPublished = true;
14021
- log51.write(`published auth url: ${url}`);
14417
+ log54.write(`published auth url: ${url}`);
14022
14418
  setState({ phase: "awaiting-code", url });
14023
14419
  }
14024
14420
  return;
14025
14421
  }
14026
14422
  if (cur.phase === "exchanging" && INVALID_CODE.test(d)) {
14027
14423
  lastError = "the code was not accepted \u2014 paste a fresh one";
14028
- log51.write("code rejected; back to awaiting-code");
14424
+ log54.write("code rejected; back to awaiting-code");
14029
14425
  setState({ phase: "awaiting-code", lastError });
14030
14426
  }
14031
14427
  });
14032
14428
  pty.onExit(({ exitCode }) => {
14033
14429
  if (finished) return;
14034
- log51.write(`login process exited code=${String(exitCode)}`);
14430
+ log54.write(`login process exited code=${String(exitCode)}`);
14035
14431
  void (async () => {
14036
14432
  let creds = { present: false, hasRefreshToken: false };
14037
14433
  try {
@@ -14040,7 +14436,7 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
14040
14436
  }
14041
14437
  if (exitCode === 0 && creds.hasRefreshToken) {
14042
14438
  const warm = await warmUpClaudeCredentials(SHARED_CLAUDE_VOLUME, req.image, {
14043
- onProgress: (l) => log51.write(l)
14439
+ onProgress: (l) => log54.write(l)
14044
14440
  });
14045
14441
  await syncClaudeCredentials(
14046
14442
  { volume: SHARED_CLAUDE_VOLUME },
@@ -14060,14 +14456,14 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
14060
14456
  });
14061
14457
  const urlTimer = setTimeout(() => {
14062
14458
  if (urlPublished || finished) return;
14063
- log51.write("no auth URL within timeout");
14459
+ log54.write("no auth URL within timeout");
14064
14460
  setState({ phase: "error", error: "login never printed an auth URL (see the worker log)" });
14065
14461
  cleanExit(1);
14066
14462
  }, URL_TIMEOUT_MS);
14067
14463
  disposers.push(() => clearTimeout(urlTimer));
14068
14464
  const codeTimer = setTimeout(() => {
14069
14465
  if (finished || cur.phase !== "starting" && cur.phase !== "awaiting-code") return;
14070
- log51.write("no code within timeout; aborting");
14466
+ log54.write("no code within timeout; aborting");
14071
14467
  setState({ phase: "error", error: "timed out waiting for a code (10 min) \u2014 run login again" });
14072
14468
  cleanExit(1);
14073
14469
  }, CODE_TIMEOUT_MS);
@@ -14075,8 +14471,8 @@ var claudeLoginWorkerCommand = new Command40("_claude-login-worker").description
14075
14471
  });
14076
14472
 
14077
14473
  // src/commands/herdr.ts
14078
- import { spawnSync as spawnSync5 } from "child_process";
14079
- import { Command as Command41 } from "commander";
14474
+ import { spawnSync as spawnSync6 } from "child_process";
14475
+ import { Command as Command42 } from "commander";
14080
14476
  function parseHerdrLink(uri) {
14081
14477
  if (!uri) return null;
14082
14478
  const m = uri.match(/^agentbox:\/\/([^/]+)\/(.+)$/);
@@ -14102,7 +14498,7 @@ function herdrContextCwd(env = process.env) {
14102
14498
  }
14103
14499
  return process.cwd();
14104
14500
  }
14105
- var newCommand = new Command41("new").description("Open a new box session in a fresh Herdr tab (used by the plugin shortcut)").option("--agent <agent>", "agent to launch (claude|codex|opencode)", "claude").action(async (opts) => {
14501
+ var newCommand = new Command42("new").description("Open a new box session in a fresh Herdr tab (used by the plugin shortcut)").option("--agent <agent>", "agent to launch (claude|codex|opencode)", "claude").action(async (opts) => {
14106
14502
  const agent = opts.agent ?? "claude";
14107
14503
  const cwd = herdrContextCwd();
14108
14504
  const r = await spawnInNewTerminal({
@@ -14115,7 +14511,7 @@ var newCommand = new Command41("new").description("Open a new box session in a f
14115
14511
  if (r.launched) process.stdout.write(r.note + "\n");
14116
14512
  else if (r.error) process.stderr.write(r.error + "\n");
14117
14513
  });
14118
- var linkCommand = new Command41("link").description("Handle a Ctrl+click on an agentbox:// link (used by the plugin link handler)").argument("[uri]", "the clicked URI; defaults to $HERDR_PLUGIN_CLICKED_URL").action(async (uriArg) => {
14514
+ var linkCommand = new Command42("link").description("Handle a Ctrl+click on an agentbox:// link (used by the plugin link handler)").argument("[uri]", "the clicked URI; defaults to $HERDR_PLUGIN_CLICKED_URL").action(async (uriArg) => {
14119
14515
  const link = parseHerdrLink(uriArg ?? process.env["HERDR_PLUGIN_CLICKED_URL"]);
14120
14516
  if (!link) return;
14121
14517
  if (link.verb !== "web") return;
@@ -14131,7 +14527,7 @@ var linkCommand = new Command41("link").description("Handle a Ctrl+click on an a
14131
14527
  }
14132
14528
  const webUrl = box.endpoints.endpoints.find((e) => e.kind === "web" && e.url)?.url;
14133
14529
  if (webUrl) {
14134
- spawnSync5(hostOpenCommand(), [webUrl], { stdio: "ignore" });
14530
+ spawnSync6(hostOpenCommand(), [webUrl], { stdio: "ignore" });
14135
14531
  return;
14136
14532
  }
14137
14533
  if (box.state !== "running") {
@@ -14148,12 +14544,227 @@ var linkCommand = new Command41("link").description("Handle a Ctrl+click on an a
14148
14544
  sound: "request"
14149
14545
  });
14150
14546
  });
14151
- var herdrCommand = new Command41("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
14547
+ var herdrCommand = new Command42("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
14548
+
14549
+ // src/commands/recover.ts
14550
+ import { homedir as homedir22 } from "os";
14551
+ import { join as join26 } from "path";
14552
+ import { access as access3 } from "fs/promises";
14553
+ import { isCancel as isCancel3, log as log45, select as select3 } from "@clack/prompts";
14554
+ import { Command as Command43 } from "commander";
14555
+ function hetznerKeyPath(sandboxId) {
14556
+ return join26(homedir22(), ".agentbox", "boxes", sandboxId, "ssh", "id_ed25519");
14557
+ }
14558
+ async function fileExists2(path) {
14559
+ try {
14560
+ await access3(path);
14561
+ return true;
14562
+ } catch {
14563
+ return false;
14564
+ }
14565
+ }
14566
+ async function hetznerKeyMissing(box) {
14567
+ if ((box.provider ?? "docker") !== "hetzner") return false;
14568
+ const sandboxId = box.cloud?.sandboxId;
14569
+ if (!sandboxId) return false;
14570
+ return !await fileExists2(hetznerKeyPath(sandboxId));
14571
+ }
14572
+ async function readBoxBranch(box) {
14573
+ try {
14574
+ const provider = await providerForBox(box);
14575
+ const r = await provider.exec(box, ["git", "-C", "/workspace", "branch", "--show-current"], {
14576
+ user: "vscode"
14577
+ });
14578
+ const branch = r.exitCode === 0 ? r.stdout.trim() : "";
14579
+ return branch.length > 0 ? branch : void 0;
14580
+ } catch {
14581
+ return void 0;
14582
+ }
14583
+ }
14584
+ async function recoverKnownBox(box, opts) {
14585
+ if (await hetznerKeyMissing(box)) {
14586
+ log45.warn(
14587
+ `${box.name}: per-box SSH key not found at ${hetznerKeyPath(box.cloud?.sandboxId ?? box.id)} \u2014 this box was created on another host and can't be controlled from here. Skipping.`
14588
+ );
14589
+ return false;
14590
+ }
14591
+ const provider = await providerForBox(box);
14592
+ const record = await withFirewallRepair(
14593
+ provider,
14594
+ box,
14595
+ { enabled: opts.firewallSync, onLog: (line) => log45.success(line) },
14596
+ () => provider.reconnect(box)
14597
+ );
14598
+ log45.success(`reconnected ${record.name}`);
14599
+ await restoreAgentSessions(record, provider, {
14600
+ restoreOnly: record.lastAgent,
14601
+ onLog: (line) => log45.info(line)
14602
+ });
14603
+ if (opts.attach) {
14604
+ const result = await attachToRunningAgent(record, {});
14605
+ if (result === "none") {
14606
+ log45.warn(
14607
+ `${record.name} reconnected but no agent session came up${record.lastAgent ? ` (last agent: ${record.lastAgent})` : ""}. Start one with: agentbox ${record.lastAgent ?? "claude"} ${record.name}`
14608
+ );
14609
+ }
14610
+ }
14611
+ return true;
14612
+ }
14613
+ async function adoptUnknownBox(provider, ref) {
14614
+ const backend = await cloudBackendForProvider(provider);
14615
+ if (!backend) {
14616
+ log45.error(`--adopt is cloud-only; '${provider}' has no remote sandbox list`);
14617
+ process.exit(2);
14618
+ }
14619
+ if (!backend.list) {
14620
+ log45.error(`${provider} backend doesn't expose list(); cannot enumerate sandboxes to adopt`);
14621
+ process.exit(2);
14622
+ }
14623
+ const [remote, state] = await Promise.all([backend.list(), readState()]);
14624
+ const knownIds = /* @__PURE__ */ new Set();
14625
+ for (const b of state.boxes) {
14626
+ if ((b.provider ?? "docker") === provider && b.cloud?.sandboxId)
14627
+ knownIds.add(b.cloud.sandboxId);
14628
+ }
14629
+ const candidates = remote.filter(
14630
+ (sb2) => !knownIds.has(sb2.sandboxId) && (sb2.name ?? "").length > 0
14631
+ );
14632
+ if (candidates.length === 0) {
14633
+ log45.info(`no un-tracked ${provider} sandboxes to adopt`);
14634
+ return null;
14635
+ }
14636
+ let chosen;
14637
+ if (ref) {
14638
+ chosen = candidates.find((sb2) => sb2.sandboxId === ref || sb2.name === ref);
14639
+ if (!chosen) {
14640
+ log45.error(`no adoptable ${provider} sandbox matches '${ref}'`);
14641
+ process.exit(1);
14642
+ }
14643
+ } else if (candidates.length === 1) {
14644
+ chosen = candidates[0];
14645
+ } else {
14646
+ const picked = await select3({
14647
+ message: `Which ${provider} sandbox to adopt?`,
14648
+ options: candidates.map((sb2) => ({
14649
+ value: sb2,
14650
+ label: sb2.name ?? sb2.sandboxId,
14651
+ hint: [sb2.sandboxId, sb2.state, sb2.createdAt].filter(Boolean).join(" ")
14652
+ }))
14653
+ });
14654
+ if (isCancel3(picked)) {
14655
+ log45.info("cancelled");
14656
+ return null;
14657
+ }
14658
+ chosen = picked;
14659
+ }
14660
+ const sb = chosen;
14661
+ if (!sb) return null;
14662
+ const record = {
14663
+ id: generateBoxId(),
14664
+ name: sb.name ?? sb.sandboxId,
14665
+ provider,
14666
+ container: `cloud:${sb.sandboxId}`,
14667
+ image: "",
14668
+ workspacePath: "/workspace",
14669
+ relayToken: generateRelayToken(),
14670
+ createdAt: sb.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
14671
+ cloud: {
14672
+ backend: provider,
14673
+ sandboxId: sb.sandboxId,
14674
+ bridgeToken: generateRelayToken(),
14675
+ webPort: backend.webProxyPort
14676
+ }
14677
+ };
14678
+ if (await hetznerKeyMissing(record)) {
14679
+ log45.error(
14680
+ `cannot adopt ${record.name}: per-box SSH key not found at ${hetznerKeyPath(sb.sandboxId)} \u2014 Hetzner boxes can only be controlled from the host that created them (the private key never leaves that host).`
14681
+ );
14682
+ process.exit(1);
14683
+ }
14684
+ const branch = await readBoxBranch(record);
14685
+ if (branch) {
14686
+ record.gitWorktrees = [
14687
+ {
14688
+ kind: "root",
14689
+ branch,
14690
+ containerPath: "/workspace",
14691
+ hostMainRepo: "",
14692
+ gitWorktreePath: "",
14693
+ relPathFromWorkspace: ""
14694
+ }
14695
+ ];
14696
+ }
14697
+ await recordBox(record);
14698
+ log45.success(`adopted ${record.name} (${provider} sandbox ${sb.sandboxId})`);
14699
+ log45.warn(
14700
+ "host-side project linkage (project index, git worktree host paths) could not be reconstructed from the box."
14701
+ );
14702
+ return record;
14703
+ }
14704
+ var recoverCommand = new Command43("recover").description(
14705
+ "Reconnect to an already-running box without power-cycling it: ensure the relay is up, re-open the host transport (Hetzner SSH tunnel) + portless aliases, re-register with the relay, relaunch the agent it was running, and attach. With --all, recover every box in state. With --provider <p> --adopt [ref], first rebuild local state for a box created elsewhere."
14706
+ ).argument(
14707
+ "[box]",
14708
+ "box ref: project index, id, id prefix, name, or container (default: the only box in this project). With --adopt: the sandbox id or name to adopt."
14709
+ ).option("--all", "recover every box in local state (skips attach)").option("--no-attach", "restore only; do not attach to the agent").option(
14710
+ "--no-firewall-sync",
14711
+ "don't auto-sync a Hetzner box's firewall to your current egress IP on a connect failure"
14712
+ ).option("--provider <name>", "cloud provider for --adopt (daytona|hetzner|vercel|e2b)").option("--adopt", "rebuild local state from a live sandbox that is missing from this host").action(async function(idOrName) {
14713
+ const opts = this.optsWithGlobals();
14714
+ try {
14715
+ await ensureRelay();
14716
+ await rehydrateFromState();
14717
+ if (opts.adopt) {
14718
+ const provider = opts.provider;
14719
+ if (!provider || !isKnownProvider(provider) || provider === "docker") {
14720
+ log45.error("--adopt requires --provider <daytona|hetzner|vercel|e2b>");
14721
+ process.exit(2);
14722
+ }
14723
+ const adopted = await adoptUnknownBox(provider, idOrName);
14724
+ if (!adopted) return;
14725
+ await recoverKnownBox(adopted, {
14726
+ attach: opts.attach !== false,
14727
+ firewallSync: opts.firewallSync !== false
14728
+ });
14729
+ return;
14730
+ }
14731
+ if (opts.all) {
14732
+ const state = await readState();
14733
+ if (state.boxes.length === 0) {
14734
+ log45.info("no boxes in local state to recover");
14735
+ return;
14736
+ }
14737
+ let ok = 0;
14738
+ for (const box2 of state.boxes) {
14739
+ try {
14740
+ if (await recoverKnownBox(box2, {
14741
+ attach: false,
14742
+ firewallSync: opts.firewallSync !== false
14743
+ }))
14744
+ ok++;
14745
+ } catch (err) {
14746
+ log45.warn(
14747
+ `${box2.name}: recover failed: ${err instanceof Error ? err.message : String(err)}`
14748
+ );
14749
+ }
14750
+ }
14751
+ log45.success(`recovered ${String(ok)}/${String(state.boxes.length)} box(es)`);
14752
+ return;
14753
+ }
14754
+ const box = await resolveBoxOrExit(idOrName);
14755
+ await recoverKnownBox(box, {
14756
+ attach: opts.attach !== false,
14757
+ firewallSync: opts.firewallSync !== false
14758
+ });
14759
+ } catch (err) {
14760
+ handleLifecycleError(err);
14761
+ }
14762
+ });
14152
14763
 
14153
14764
  // src/commands/screen.ts
14154
- import { spawnSync as spawnSync6 } from "child_process";
14155
- import { log as log43 } from "@clack/prompts";
14156
- import { Command as Command42 } from "commander";
14765
+ import { spawnSync as spawnSync7 } from "child_process";
14766
+ import { log as log46 } from "@clack/prompts";
14767
+ import { Command as Command44 } from "commander";
14157
14768
  var SIGNED_URL_TTL_MIN = 1;
14158
14769
  var SIGNED_URL_TTL_MAX = 86400;
14159
14770
  function parseTtlOrExit(raw) {
@@ -14166,7 +14777,7 @@ function parseTtlOrExit(raw) {
14166
14777
  }
14167
14778
  return n;
14168
14779
  }
14169
- var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
14780
+ var screenCommand = new Command44("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
14170
14781
  "[box]",
14171
14782
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14172
14783
  ).option("--print", "print the URL to stdout instead of launching the browser").option("--loopback", "docker only: use the 127.0.0.1 URL instead of the OrbStack .orb.local URL").option(
@@ -14183,10 +14794,10 @@ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC
14183
14794
  if (provider === "docker") {
14184
14795
  const insp = await inspectBox(box.id);
14185
14796
  if (insp.state === "paused") {
14186
- log43.info("box is paused; unpausing");
14797
+ log46.info("box is paused; unpausing");
14187
14798
  await unpauseBox(box.id);
14188
14799
  } else if (insp.state === "stopped") {
14189
- log43.info("box is stopped; starting");
14800
+ log46.info("box is stopped; starting");
14190
14801
  await startBox(box.id);
14191
14802
  } else if (insp.state === "missing") {
14192
14803
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -14196,13 +14807,13 @@ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC
14196
14807
  const inBoxUrl = exposePort !== void 0 ? box.portlessUrl ?? `http://localhost:${String(exposePort)}` : "about:blank";
14197
14808
  const br = await ensureBoxBrowser(box.container, void 0, inBoxUrl);
14198
14809
  if (br.up && !br.alreadyRunning) {
14199
- log43.info(
14810
+ log46.info(
14200
14811
  exposePort !== void 0 ? `opened ${inBoxUrl} in the in-box browser (visible in the VNC view)` : "started in-box browser"
14201
14812
  );
14202
14813
  } else if (br.alreadyRunning) {
14203
- log43.info("in-box browser already running; left it untouched");
14814
+ log46.info("in-box browser already running; left it untouched");
14204
14815
  } else {
14205
- log43.warn(`could not start in-box browser: ${br.reason ?? "unknown"}`);
14816
+ log46.warn(`could not start in-box browser: ${br.reason ?? "unknown"}`);
14206
14817
  }
14207
14818
  const engine = await detectEngine();
14208
14819
  const urls = buildVncUrls(box, engine);
@@ -14223,10 +14834,10 @@ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC
14223
14834
  const p = await providerForBox(box);
14224
14835
  const state = await p.probeState(box);
14225
14836
  if (state === "paused") {
14226
- log43.info("box is paused; resuming");
14837
+ log46.info("box is paused; resuming");
14227
14838
  await p.resume(box);
14228
14839
  } else if (state === "stopped") {
14229
- log43.info("box is stopped; starting");
14840
+ log46.info("box is stopped; starting");
14230
14841
  await p.start(box);
14231
14842
  } else if (state === "missing") {
14232
14843
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -14241,14 +14852,14 @@ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC
14241
14852
  user: "vscode"
14242
14853
  });
14243
14854
  if (br.exitCode === 0) {
14244
- log43.info(`opened ${webUrl} in the in-box browser (visible in the VNC view)`);
14855
+ log46.info(`opened ${webUrl} in the in-box browser (visible in the VNC view)`);
14245
14856
  } else {
14246
- log43.warn(
14857
+ log46.warn(
14247
14858
  `could not open in-box browser (continuing): ${br.stderr.trim() || br.stdout.trim() || `exit ${String(br.exitCode)}`}`
14248
14859
  );
14249
14860
  }
14250
14861
  } catch (err) {
14251
- log43.warn(
14862
+ log46.warn(
14252
14863
  `in-box browser skipped: ${err instanceof Error ? err.message : String(err)}`
14253
14864
  );
14254
14865
  }
@@ -14261,7 +14872,7 @@ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC
14261
14872
  `);
14262
14873
  return;
14263
14874
  }
14264
- const opened = spawnSync6(hostOpenCommand(), [url], { stdio: "inherit" });
14875
+ const opened = spawnSync7(hostOpenCommand(), [url], { stdio: "inherit" });
14265
14876
  if (opened.status !== 0) {
14266
14877
  throw new Error(`open ${url} failed (exit ${String(opened.status ?? "n/a")})`);
14267
14878
  }
@@ -14273,19 +14884,19 @@ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC
14273
14884
  });
14274
14885
 
14275
14886
  // src/commands/shell.ts
14276
- import { spawnSync as spawnSync7 } from "child_process";
14277
- import { log as log45 } from "@clack/prompts";
14278
- import { Command as Command43 } from "commander";
14887
+ import { spawnSync as spawnSync8 } from "child_process";
14888
+ import { log as log48 } from "@clack/prompts";
14889
+ import { Command as Command45 } from "commander";
14279
14890
 
14280
14891
  // src/commands/_provider-guard.ts
14281
- import { log as log44 } from "@clack/prompts";
14892
+ import { log as log47 } from "@clack/prompts";
14282
14893
  function requireDockerProvider(box, commandName) {
14283
14894
  const provider = box.provider ?? "docker";
14284
14895
  if (provider === "docker") return;
14285
- log44.error(
14896
+ log47.error(
14286
14897
  `\`agentbox ${commandName}\` doesn't yet support cloud boxes (this box's provider is '${provider}').`
14287
14898
  );
14288
- log44.info(
14899
+ log47.info(
14289
14900
  "Cloud-provider routing for this command is on the Phase 3 backlog. For now: use `agentbox url` for web access, `agentbox-ctl git push` from inside the sandbox via SSH/web terminal, or fall back to the cloud provider's own console."
14290
14901
  );
14291
14902
  process.exit(2);
@@ -14327,10 +14938,10 @@ function fmtAgo2(iso) {
14327
14938
  async function ensureBoxRunning(box) {
14328
14939
  const insp = await inspectBox(box.id);
14329
14940
  if (insp.state === "paused") {
14330
- log45.info("box is paused; unpausing");
14941
+ log48.info("box is paused; unpausing");
14331
14942
  await unpauseBox(box.id);
14332
14943
  } else if (insp.state === "stopped") {
14333
- log45.info("box is stopped; starting");
14944
+ log48.info("box is stopped; starting");
14334
14945
  await startBox(box.id);
14335
14946
  } else if (insp.state === "missing") {
14336
14947
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -14369,7 +14980,7 @@ async function startOrAttachShell(box, cfg) {
14369
14980
  const label = shellLabel(cfg.sessionName);
14370
14981
  const info = await shellSessionInfo(box.container, cfg.sessionName, cfg.user);
14371
14982
  if (info.running) {
14372
- log45.info(`reattaching to shell "${label}" \u2014 Control+a d to detach`);
14983
+ log48.info(`reattaching to shell "${label}" \u2014 Control+a d to detach`);
14373
14984
  } else {
14374
14985
  await startShellSession({
14375
14986
  container: box.container,
@@ -14377,7 +14988,7 @@ async function startOrAttachShell(box, cfg) {
14377
14988
  user: cfg.user,
14378
14989
  login: cfg.login
14379
14990
  });
14380
- log45.info(`shell "${label}" \u2014 Control+a d to detach, leaves it running`);
14991
+ log48.info(`shell "${label}" \u2014 Control+a d to detach, leaves it running`);
14381
14992
  }
14382
14993
  const code = await runWrappedAttach({
14383
14994
  container: box.container,
@@ -14392,7 +15003,59 @@ async function startOrAttachShell(box, cfg) {
14392
15003
  });
14393
15004
  process.exit(code);
14394
15005
  }
14395
- var shellCommand = new Command43("shell").description(
15006
+ async function runSshConfig(box, opts) {
15007
+ const conn = await resolveCloudSshTarget(box);
15008
+ if (!conn.identityFile) {
15009
+ throw new Error(
15010
+ `box '${box.name}' (provider '${box.provider ?? "docker"}') has no persistent SSH key, so it can't be added to Codex / Claude desktop over SSH. Only Hetzner cloud boxes are supported \u2014 Docker boxes aren't reachable over SSH, and Daytona uses a 60-min token that expires.`
15011
+ );
15012
+ }
15013
+ if (await hasUnmanagedHostConflict(conn.alias)) {
15014
+ log48.warn(
15015
+ `~/.ssh/config already has a non-agentbox \`Host ${conn.alias}\` entry. SSH uses the first value per keyword, so it may override agentbox's HostName/IdentityFile \u2014 remove it (or rename the box) if \`ssh ${conn.alias}\` doesn't reach the box.`
15016
+ );
15017
+ }
15018
+ await writeAgentboxSshAlias({
15019
+ alias: conn.alias,
15020
+ hostname: conn.host,
15021
+ user: conn.user,
15022
+ identityFile: conn.identityFile
15023
+ });
15024
+ const codexUrl = `codex://settings/connections/ssh/add?name=${encodeURIComponent(conn.alias)}`;
15025
+ if (opts.json) {
15026
+ process.stdout.write(
15027
+ JSON.stringify(
15028
+ {
15029
+ alias: conn.alias,
15030
+ host: conn.host,
15031
+ user: conn.user,
15032
+ identityFile: conn.identityFile,
15033
+ sshCommand: `ssh ${conn.alias}`,
15034
+ codexAddUrl: codexUrl
15035
+ },
15036
+ null,
15037
+ 2
15038
+ ) + "\n"
15039
+ );
15040
+ return;
15041
+ }
15042
+ const codexLink = hyperlink(`Add ${conn.alias} to Codex SSH`, codexUrl, process.stdout);
15043
+ const lines = [
15044
+ `wrote ~/.ssh/config alias "${conn.alias}"`,
15045
+ ``,
15046
+ `ssh alias: ${conn.alias}`,
15047
+ `host: ${conn.host}`,
15048
+ `user: ${conn.user}`,
15049
+ `identity: ${conn.identityFile}`,
15050
+ `connect: ssh ${conn.alias}`,
15051
+ ``,
15052
+ `Codex: ${codexLink}`,
15053
+ ` ${codexUrl}`,
15054
+ `Claude desktop: add an SSH connection to host "${conn.alias}" (already in ~/.ssh/config)`
15055
+ ];
15056
+ process.stdout.write(lines.join("\n") + "\n");
15057
+ }
15058
+ var shellCommand = new Command45("shell").description(
14396
15059
  "Open an interactive shell in a box, in a detachable tmux session (auto-unpause/start)"
14397
15060
  ).argument(
14398
15061
  "[box]",
@@ -14400,10 +15063,17 @@ var shellCommand = new Command43("shell").description(
14400
15063
  ).argument(
14401
15064
  "[cmd...]",
14402
15065
  "optional one-shot command to run instead of an interactive shell; place after `--`, e.g. `agentbox shell smoke -- ls /workspace`"
14403
- ).option("--user <name>", "user inside the container (default from config; built-in: vscode)").option("--no-login", "invoke `bash` instead of `bash -l` (skip login profile)").option("--no-tmux", "run a plain docker exec shell instead of a detachable tmux session").option("-n, --name <label>", "open/attach a named shell session (a box can hold several)").option("--new", "open a fresh, auto-numbered shell session (shell-2, shell-3, ...)").action(async (idOrName, cmd, opts) => {
15066
+ ).option("--user <name>", "user inside the container (default from config; built-in: vscode)").option("--no-login", "invoke `bash` instead of `bash -l` (skip login profile)").option("--no-tmux", "run a plain docker exec shell instead of a detachable tmux session").option("-n, --name <label>", "open/attach a named shell session (a box can hold several)").option("--new", "open a fresh, auto-numbered shell session (shell-2, shell-3, ...)").option(
15067
+ "--ssh-config",
15068
+ "write a ~/.ssh/config alias for this box (Hetzner cloud boxes) and print connection details for Codex / Claude desktop, instead of opening a shell"
15069
+ ).option("--json", "with --ssh-config: emit the connection details as JSON").action(async (idOrName, cmd, opts) => {
14404
15070
  try {
14405
15071
  const { box, shifted } = await resolveBoxOrShift(idOrName);
14406
15072
  const effectiveCmd = shifted && idOrName ? [idOrName, ...cmd] : cmd;
15073
+ if (opts.sshConfig) {
15074
+ await runSshConfig(box, opts);
15075
+ return;
15076
+ }
14407
15077
  const cfg = await loadEffectiveConfig(box.workspacePath, {
14408
15078
  cliOverrides: buildShellCliOverrides(opts)
14409
15079
  });
@@ -14466,7 +15136,7 @@ var shellCommand = new Command43("shell").description(
14466
15136
  ...bashInvocation
14467
15137
  ];
14468
15138
  if (!isInteractive || effectiveCmd.length > 0) {
14469
- const child = spawnSync7("docker", plainArgv, { stdio: "inherit" });
15139
+ const child = spawnSync8("docker", plainArgv, { stdio: "inherit" });
14470
15140
  process.exit(child.status ?? 0);
14471
15141
  }
14472
15142
  if (tmux) {
@@ -14487,7 +15157,7 @@ var shellCommand = new Command43("shell").description(
14487
15157
  handleLifecycleError(err);
14488
15158
  }
14489
15159
  });
14490
- var shellAttachCommand = new Command43("attach").description(
15160
+ var shellAttachCommand = new Command45("attach").description(
14491
15161
  "Attach to a shell tmux session in a box, starting one if none is running (auto-unpause/start)"
14492
15162
  ).argument(
14493
15163
  "[box]",
@@ -14525,7 +15195,7 @@ function renderShellTable(sessions) {
14525
15195
  for (const r of rows) process.stdout.write(`${fmt(r)}
14526
15196
  `);
14527
15197
  }
14528
- var shellLsCommand = new Command43("ls").description("List the shell tmux sessions running in a box").argument(
15198
+ var shellLsCommand = new Command45("ls").description("List the shell tmux sessions running in a box").argument(
14529
15199
  "[box]",
14530
15200
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14531
15201
  ).action(async (idOrName) => {
@@ -14534,11 +15204,11 @@ var shellLsCommand = new Command43("ls").description("List the shell tmux sessio
14534
15204
  requireDockerProvider(box, "shell");
14535
15205
  const insp = await inspectBox(box.id);
14536
15206
  if (insp.state !== "running") {
14537
- log45.info(`box ${box.name} is ${insp.state} \u2014 no live shell sessions`);
15207
+ log48.info(`box ${box.name} is ${insp.state} \u2014 no live shell sessions`);
14538
15208
  return;
14539
15209
  }
14540
15210
  if (insp.shellSessions.length === 0) {
14541
- log45.info(
15211
+ log48.info(
14542
15212
  `no shell sessions in ${box.name} \u2014 start one with: agentbox shell ${reattachRef2(box)}`
14543
15213
  );
14544
15214
  return;
@@ -14548,7 +15218,7 @@ var shellLsCommand = new Command43("ls").description("List the shell tmux sessio
14548
15218
  handleLifecycleError(err);
14549
15219
  }
14550
15220
  });
14551
- var shellKillCommand = new Command43("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
15221
+ var shellKillCommand = new Command45("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
14552
15222
  "[box]",
14553
15223
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14554
15224
  ).option("-n, --name <label>", "shell label to kill (default: the box default shell)").option("--all", "kill every shell session in the box").action(async function(idOrName) {
@@ -14558,25 +15228,25 @@ var shellKillCommand = new Command43("kill").description("Kill a shell tmux sess
14558
15228
  requireDockerProvider(box, "shell");
14559
15229
  const insp = await inspectBox(box.id);
14560
15230
  if (insp.state !== "running") {
14561
- log45.info(`box ${box.name} is ${insp.state} \u2014 no shell sessions to kill`);
15231
+ log48.info(`box ${box.name} is ${insp.state} \u2014 no shell sessions to kill`);
14562
15232
  return;
14563
15233
  }
14564
15234
  if (opts.all) {
14565
15235
  if (insp.shellSessions.length === 0) {
14566
- log45.info(`no shell sessions in ${box.name}`);
15236
+ log48.info(`no shell sessions in ${box.name}`);
14567
15237
  return;
14568
15238
  }
14569
15239
  let killed = 0;
14570
15240
  for (const s of insp.shellSessions) {
14571
15241
  if (await killShellSession(box.container, s.sessionName)) killed++;
14572
15242
  }
14573
- log45.success(`killed ${String(killed)} shell session${killed === 1 ? "" : "s"} in ${box.name}`);
15243
+ log48.success(`killed ${String(killed)} shell session${killed === 1 ? "" : "s"} in ${box.name}`);
14574
15244
  return;
14575
15245
  }
14576
15246
  const target = shellSessionName(opts.name);
14577
15247
  const ok = await killShellSession(box.container, target);
14578
- if (ok) log45.success(`killed shell "${shellLabel(target)}" in ${box.name}`);
14579
- else log45.warn(`no shell "${shellLabel(target)}" in ${box.name} (already gone?)`);
15248
+ if (ok) log48.success(`killed shell "${shellLabel(target)}" in ${box.name}`);
15249
+ else log48.warn(`no shell "${shellLabel(target)}" in ${box.name} (already gone?)`);
14580
15250
  } catch (err) {
14581
15251
  handleLifecycleError(err);
14582
15252
  }
@@ -14586,8 +15256,8 @@ shellCommand.addCommand(shellLsCommand);
14586
15256
  shellCommand.addCommand(shellKillCommand);
14587
15257
 
14588
15258
  // src/commands/start.ts
14589
- import { Command as Command44 } from "commander";
14590
- var startCommand = new Command44("start").description(
15259
+ import { Command as Command46 } from "commander";
15260
+ var startCommand = new Command46("start").description(
14591
15261
  "Start a stopped box. Docker: docker start + relaunch ctl/dockerd/vnc daemons. Cloud: backend.start, then re-resolve preview URLs/tokens, re-launch in-sandbox ctl/dockerd daemons, and re-register with the host relay (so the CloudBoxPoller resumes)."
14592
15262
  ).argument(
14593
15263
  "[box]",
@@ -14619,8 +15289,8 @@ var startCommand = new Command44("start").description(
14619
15289
  });
14620
15290
 
14621
15291
  // src/commands/status.ts
14622
- import { log as log47 } from "@clack/prompts";
14623
- import { Command as Command45 } from "commander";
15292
+ import { log as log50 } from "@clack/prompts";
15293
+ import { Command as Command47 } from "commander";
14624
15294
 
14625
15295
  // src/endpoints-render.ts
14626
15296
  function renderEndpointLines(endpoints, stream) {
@@ -14703,7 +15373,7 @@ function renderPersistedSections(s) {
14703
15373
  }
14704
15374
 
14705
15375
  // src/commands/inspect.ts
14706
- import { log as log46 } from "@clack/prompts";
15376
+ import { log as log49 } from "@clack/prompts";
14707
15377
  function fmtLimit(n, unit) {
14708
15378
  return n && n > 0 ? `${String(n)}${unit}` : "unlimited";
14709
15379
  }
@@ -14809,6 +15479,8 @@ async function renderCloudText(box) {
14809
15479
  const provider = await providerForBox(box);
14810
15480
  const state = await provider.probeState(box);
14811
15481
  const persisted = await readBoxStatus(box);
15482
+ const alias = agentboxAliasFor(box.name);
15483
+ const sshAlias = await readAgentboxSshAlias(alias);
14812
15484
  const lim = box.resourceLimits;
14813
15485
  const lines = [
14814
15486
  `id ${box.id}`,
@@ -14826,6 +15498,8 @@ async function renderCloudText(box) {
14826
15498
  `web preview ${webPreviewLine(box)}`,
14827
15499
  `relay preview ${box.cloud?.relayPreviewUrl ?? "(unresolved)"}`,
14828
15500
  `bridge token ${box.cloud?.bridgeToken ? "(set)" : "(unset)"}`,
15501
+ `ssh alias ${alias}${sshAlias ? "" : ` (run \`agentbox shell ${box.name} --ssh-config\` to write it)`}`,
15502
+ `ssh identity ${sshAlias?.identityFile ?? "(none \u2014 write the alias first)"}`,
14829
15503
  `playwright ${box.withPlaywright ? "yes" : "no"}`,
14830
15504
  `env files ${box.withEnv ? "yes" : "no"}`,
14831
15505
  `mem limit ${lim?.memoryBytes ? fmtBytes2(lim.memoryBytes) : "unlimited"}`,
@@ -14858,7 +15532,7 @@ function renderCodexActivityCloud(persisted) {
14858
15532
  async function runInspect(box, opts) {
14859
15533
  try {
14860
15534
  if (opts.json && opts.watch) {
14861
- log46.error("cannot combine --json with --watch");
15535
+ log49.error("cannot combine --json with --watch");
14862
15536
  process.exit(2);
14863
15537
  }
14864
15538
  const isCloud = (box.provider ?? "docker") !== "docker";
@@ -14895,14 +15569,14 @@ async function runInspect(box, opts) {
14895
15569
 
14896
15570
  // src/commands/status.ts
14897
15571
  var statusCommand2 = withWatchOptions(
14898
- new Command45("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
15572
+ new Command47("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
14899
15573
  "[box]",
14900
15574
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14901
15575
  ).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) plus service/task status")
14902
15576
  ).action(async (idOrName, opts) => {
14903
15577
  try {
14904
15578
  if (opts.json && opts.watch) {
14905
- log47.error("cannot combine --json with --watch");
15579
+ log50.error("cannot combine --json with --watch");
14906
15580
  process.exit(2);
14907
15581
  }
14908
15582
  const box = await resolveBoxOrExit(idOrName);
@@ -15030,8 +15704,8 @@ function renderPersisted2(s, state) {
15030
15704
  }
15031
15705
 
15032
15706
  // src/commands/stop.ts
15033
- import { Command as Command46 } from "commander";
15034
- var stopCommand = new Command46("stop").description(
15707
+ import { Command as Command48 } from "commander";
15708
+ var stopCommand = new Command48("stop").description(
15035
15709
  "Stop a box (Docker: docker stop; preserves upper + node_modules volumes. Cloud: backend.stop \u2014 sandbox stays in your account, disk preserved)."
15036
15710
  ).argument(
15037
15711
  "[box]",
@@ -15060,7 +15734,7 @@ restart with: agentbox start ${box.name}
15060
15734
  });
15061
15735
 
15062
15736
  // src/commands/top.ts
15063
- import { Command as Command47 } from "commander";
15737
+ import { Command as Command49 } from "commander";
15064
15738
  var COLS = ["BOX", "STATE", "CPU%", "MEM USAGE / LIMIT", "MEM%", "PIDS", "DISK", "NET I/O"];
15065
15739
  function row(name, state, s) {
15066
15740
  const mem = `${fmtBytes2(s.memUsedBytes)} / ${fmtBytes2(s.memLimitBytes)}`;
@@ -15134,7 +15808,7 @@ async function renderProjectFooters() {
15134
15808
 
15135
15809
  SYSTEM: ${parts.join(" - ")}` : "";
15136
15810
  }
15137
- var topCommand = new Command47("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
15811
+ var topCommand = new Command49("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
15138
15812
  "[box]",
15139
15813
  "box ref (default: every box on the host; --project narrows to the cwd's project)"
15140
15814
  ).option("-p, --project", "show only boxes in the cwd's project").option("--once", "print a single snapshot instead of watching").option("-j, --json", "machine-readable JSON (implies --once)").option("--interval <seconds>", "refresh interval", "2").option("--live", "probe live cloud state via the provider SDK (slower; default: last host-known)").action(async (idOrName, opts) => {
@@ -15167,8 +15841,8 @@ var topCommand = new Command47("top").description("Live resource monitor (cpu/me
15167
15841
  });
15168
15842
 
15169
15843
  // src/commands/unpause.ts
15170
- import { Command as Command48 } from "commander";
15171
- var unpauseCommand = new Command48("unpause").description(
15844
+ import { Command as Command50 } from "commander";
15845
+ var unpauseCommand = new Command50("unpause").description(
15172
15846
  "Resume a paused box. Docker: `docker unpause` (sub-second). Cloud: backend.resume (re-hydrates from archive \u2014 slower first time)."
15173
15847
  ).argument(
15174
15848
  "[box]",
@@ -15197,7 +15871,7 @@ var unpauseCommand = new Command48("unpause").description(
15197
15871
 
15198
15872
  // src/commands/update.ts
15199
15873
  import { spawn as spawn5 } from "child_process";
15200
- import { Command as Command49 } from "commander";
15874
+ import { Command as Command51 } from "commander";
15201
15875
 
15202
15876
  // src/exec-method.ts
15203
15877
  function detectExecutionMethod(input) {
@@ -15241,7 +15915,7 @@ function runInherit(cmd, args) {
15241
15915
  child.on("close", (code) => resolveP(code ?? 0));
15242
15916
  });
15243
15917
  }
15244
- var updateCommand = new Command49("self-update").description(
15918
+ var updateCommand = new Command51("self-update").description(
15245
15919
  "Update agentbox: self-update via npm/pnpm (unless run via npx), refresh the host skills, wipe the box image so it rebuilds, and reload the relay"
15246
15920
  ).option("-y, --yes", "skip the confirmation prompt").option("--dry-run", "show what would happen, don't change anything").option("--skip-self", "skip the package self-update; only refresh the skills + image + relay").option("--skip-skills", "skip refreshing the host skill files in ~/.claude, ~/.codex, ~/.config/opencode").action(async (opts) => {
15247
15921
  try {
@@ -15356,9 +16030,9 @@ var updateCommand = new Command49("self-update").description(
15356
16030
  });
15357
16031
 
15358
16032
  // src/commands/url.ts
15359
- import { spawnSync as spawnSync8 } from "child_process";
15360
- import { log as log49 } from "@clack/prompts";
15361
- import { Command as Command50 } from "commander";
16033
+ import { spawnSync as spawnSync9 } from "child_process";
16034
+ import { log as log52 } from "@clack/prompts";
16035
+ import { Command as Command52 } from "commander";
15362
16036
  var SIGNED_URL_TTL_MIN2 = 1;
15363
16037
  var SIGNED_URL_TTL_MAX2 = 86400;
15364
16038
  function parseTtlOrExit2(raw) {
@@ -15371,7 +16045,7 @@ function parseTtlOrExit2(raw) {
15371
16045
  }
15372
16046
  return n;
15373
16047
  }
15374
- var urlCommand = new Command50("url").description(
16048
+ var urlCommand = new Command52("url").description(
15375
16049
  "Open a box's web app URL in the browser, even when no service declares `expose:` (auto-unpause/start)"
15376
16050
  ).argument(
15377
16051
  "[box]",
@@ -15390,10 +16064,10 @@ var urlCommand = new Command50("url").description(
15390
16064
  if (provider === "docker") {
15391
16065
  const insp = await inspectBox(box.id);
15392
16066
  if (insp.state === "paused") {
15393
- log49.info("box is paused; unpausing");
16067
+ log52.info("box is paused; unpausing");
15394
16068
  await unpauseBox(box.id);
15395
16069
  } else if (insp.state === "stopped") {
15396
- log49.info("box is stopped; starting");
16070
+ log52.info("box is stopped; starting");
15397
16071
  await startBox(box.id);
15398
16072
  } else if (insp.state === "missing") {
15399
16073
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -15422,10 +16096,10 @@ var urlCommand = new Command50("url").description(
15422
16096
  const p = await providerForBox(box);
15423
16097
  const state = await p.probeState(box);
15424
16098
  if (state === "paused") {
15425
- log49.info("box is paused; resuming");
16099
+ log52.info("box is paused; resuming");
15426
16100
  await p.resume(box);
15427
16101
  } else if (state === "stopped") {
15428
- log49.info("box is stopped; starting");
16102
+ log52.info("box is stopped; starting");
15429
16103
  await p.start(box);
15430
16104
  } else if (state === "missing") {
15431
16105
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -15437,7 +16111,7 @@ var urlCommand = new Command50("url").description(
15437
16111
  `);
15438
16112
  return;
15439
16113
  }
15440
- const opened = spawnSync8(hostOpenCommand(), [url], { stdio: "inherit" });
16114
+ const opened = spawnSync9(hostOpenCommand(), [url], { stdio: "inherit" });
15441
16115
  if (opened.status !== 0) {
15442
16116
  throw new Error(`open ${url} failed (exit ${String(opened.status ?? "n/a")})`);
15443
16117
  }
@@ -15449,9 +16123,9 @@ var urlCommand = new Command50("url").description(
15449
16123
  });
15450
16124
 
15451
16125
  // src/commands/wait.ts
15452
- import { log as log50 } from "@clack/prompts";
15453
- import { Command as Command51 } from "commander";
15454
- var waitCommand = new Command51("wait").description("Block until the box reports all autostart units ready").argument(
16126
+ import { log as log53 } from "@clack/prompts";
16127
+ import { Command as Command53 } from "commander";
16128
+ var waitCommand = new Command53("wait").description("Block until the box reports all autostart units ready").argument(
15455
16129
  "[box]",
15456
16130
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
15457
16131
  ).option("--timeout <ms>", "overall timeout in milliseconds", "120000").option("--units <names...>", "restrict to the named units").option("-j, --json", "machine-readable JSON output").action(async (idOrName, opts) => {
@@ -15467,7 +16141,7 @@ var waitCommand = new Command51("wait").description("Block until the box reports
15467
16141
  try {
15468
16142
  parsed = JSON.parse(proc.stdout);
15469
16143
  } catch {
15470
- log50.error(`agentbox-ctl wait-ready failed: ${proc.stderr || proc.stdout}`);
16144
+ log53.error(`agentbox-ctl wait-ready failed: ${proc.stderr || proc.stdout}`);
15471
16145
  process.exit(1);
15472
16146
  }
15473
16147
  if (opts.json) {
@@ -15506,7 +16180,7 @@ function rewriteProviderPrefix(argv2) {
15506
16180
  process.env.DOCKER_CLI_HINTS ??= "false";
15507
16181
  process.env.AGENTBOX_CLI_VERSION = AGENTBOX_VERSION;
15508
16182
  process.env.AGENTBOX_CLI_COMMIT = AGENTBOX_COMMIT;
15509
- var program = new Command52();
16183
+ var program = new Command54();
15510
16184
  program.name("agentbox").description("Launch coding agents in isolated sandboxes").version(AGENTBOX_VERSION);
15511
16185
  program.enablePositionalOptions();
15512
16186
  program.addCommand(createCommand);
@@ -15535,6 +16209,7 @@ program.addCommand(pauseCommand);
15535
16209
  program.addCommand(unpauseCommand);
15536
16210
  program.addCommand(stopCommand);
15537
16211
  program.addCommand(startCommand);
16212
+ program.addCommand(recoverCommand);
15538
16213
  program.addCommand(destroyCommand);
15539
16214
  program.addCommand(prepareCommand);
15540
16215
  program.addCommand(pruneCommand);