@madarco/agentbox 0.18.0 → 0.20.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 (71) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/README.md +4 -3
  3. package/dist/_cloud-attach-THTN4CFZ.js +18 -0
  4. package/dist/{chunk-U7IZS2ZP.js → chunk-3VFY3N4A.js} +1388 -234
  5. package/dist/chunk-3VFY3N4A.js.map +1 -0
  6. package/dist/{chunk-XWBFWUY2.js → chunk-52LKNUY7.js} +6 -3
  7. package/dist/chunk-52LKNUY7.js.map +1 -0
  8. package/dist/{chunk-6QFPYU4Z.js → chunk-7K2A3NLE.js} +8 -5
  9. package/dist/chunk-7K2A3NLE.js.map +1 -0
  10. package/dist/{chunk-5BO6SGMI.js → chunk-7RWFYLF3.js} +194 -34
  11. package/dist/chunk-7RWFYLF3.js.map +1 -0
  12. package/dist/{chunk-IA6YHH52.js → chunk-MODNW54N.js} +6 -3
  13. package/dist/{chunk-IA6YHH52.js.map → chunk-MODNW54N.js.map} +1 -1
  14. package/dist/{chunk-46NXCJ6Z.js → chunk-NXX3KQZ6.js} +2 -2
  15. package/dist/{chunk-3JXSW6PN.js → chunk-P6UT5XGE.js} +2 -2
  16. package/dist/{chunk-OG4KMYOJ.js → chunk-ZX6DTA4X.js} +276 -56
  17. package/dist/chunk-ZX6DTA4X.js.map +1 -0
  18. package/dist/{dist-CFSKUAS5.js → dist-3PLT2EK2.js} +17 -3
  19. package/dist/{dist-T7ESSBCZ.js → dist-3WFNXXPE.js} +20 -6
  20. package/dist/dist-3WFNXXPE.js.map +1 -0
  21. package/dist/{dist-3UYQZOAO.js → dist-7ELDXBAG.js} +19 -6
  22. package/dist/dist-7ELDXBAG.js.map +1 -0
  23. package/dist/{dist-4BHW7DCO.js → dist-C3YRC3PP.js} +10 -5
  24. package/dist/dist-C3YRC3PP.js.map +1 -0
  25. package/dist/{dist-7BS2JS27.js → dist-CZ6CRADC.js} +18 -7
  26. package/dist/dist-CZ6CRADC.js.map +1 -0
  27. package/dist/index.js +1218 -560
  28. package/dist/index.js.map +1 -1
  29. package/dist/{prepared-state-MQHD3M5F-OVABNV66.js → prepared-state-MQHD3M5F-5ZMCNY43.js} +2 -2
  30. package/package.json +4 -4
  31. package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
  32. package/runtime/docker/packages/ctl/dist/bin.cjs +255 -169
  33. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +13 -0
  34. package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +4 -4
  35. package/runtime/e2b/agentbox-dockerd-start +145 -0
  36. package/runtime/e2b/agentbox-setup-skill.md +1 -1
  37. package/runtime/e2b/attach-helper.cjs +23 -2
  38. package/runtime/e2b/claude-managed-settings.json +4 -4
  39. package/runtime/e2b/ctl.cjs +255 -169
  40. package/runtime/e2b/scripts/build-template.sh +22 -5
  41. package/runtime/hetzner/agentbox-dockerd-start +13 -0
  42. package/runtime/hetzner/agentbox-setup-skill.md +1 -1
  43. package/runtime/hetzner/claude-managed-settings.json +4 -4
  44. package/runtime/hetzner/ctl.cjs +255 -169
  45. package/runtime/relay/bin.cjs +267 -63
  46. package/runtime/vercel/agentbox-dockerd-start +145 -0
  47. package/runtime/vercel/agentbox-setup-skill.md +1 -1
  48. package/runtime/vercel/claude-managed-settings.json +4 -4
  49. package/runtime/vercel/ctl.cjs +255 -169
  50. package/runtime/vercel/custom-system-CLAUDE.md +5 -4
  51. package/runtime/vercel/scripts/provision.sh +20 -5
  52. package/share/agentbox-setup/SKILL.md +1 -1
  53. package/share/host-skills/agentbox/SKILL.md +4 -4
  54. package/share/host-skills/agentbox-info/SKILL.md +6 -6
  55. package/share/host-skills/codex/agentbox.md +12 -4
  56. package/share/host-skills/opencode/agentbox.md +2 -2
  57. package/dist/_cloud-attach-3UC3IL62.js +0 -16
  58. package/dist/chunk-5BO6SGMI.js.map +0 -1
  59. package/dist/chunk-6QFPYU4Z.js.map +0 -1
  60. package/dist/chunk-OG4KMYOJ.js.map +0 -1
  61. package/dist/chunk-U7IZS2ZP.js.map +0 -1
  62. package/dist/chunk-XWBFWUY2.js.map +0 -1
  63. package/dist/dist-3UYQZOAO.js.map +0 -1
  64. package/dist/dist-4BHW7DCO.js.map +0 -1
  65. package/dist/dist-7BS2JS27.js.map +0 -1
  66. package/dist/dist-T7ESSBCZ.js.map +0 -1
  67. /package/dist/{_cloud-attach-3UC3IL62.js.map → _cloud-attach-THTN4CFZ.js.map} +0 -0
  68. /package/dist/{chunk-46NXCJ6Z.js.map → chunk-NXX3KQZ6.js.map} +0 -0
  69. /package/dist/{chunk-3JXSW6PN.js.map → chunk-P6UT5XGE.js.map} +0 -0
  70. /package/dist/{dist-CFSKUAS5.js.map → dist-3PLT2EK2.js.map} +0 -0
  71. /package/dist/{prepared-state-MQHD3M5F-OVABNV66.js.map → prepared-state-MQHD3M5F-5ZMCNY43.js.map} +0 -0
package/dist/index.js CHANGED
@@ -4,6 +4,9 @@ import {
4
4
  ALERT_BAND_ROWS,
5
5
  NEW_BOX_ID,
6
6
  NEW_BOX_LABEL,
7
+ agentResumeArgs,
8
+ applyClaudeSkipPermissions,
9
+ applyCodexSkipPermissions,
7
10
  buildCloudAttachInnerCommand,
8
11
  clipboardCaptureAvailable,
9
12
  cloudAgentAttach,
@@ -26,6 +29,7 @@ import {
26
29
  pushTerminalTitle,
27
30
  renderAlertBand,
28
31
  renderFooter,
32
+ restoreAgentSessions,
29
33
  runWrappedAttach,
30
34
  setTerminalTitle,
31
35
  sidebarLines,
@@ -34,7 +38,7 @@ import {
34
38
  stripTitleGlyph,
35
39
  subscribePrompts,
36
40
  uploadImageFileToBox
37
- } from "./chunk-5BO6SGMI.js";
41
+ } from "./chunk-7RWFYLF3.js";
38
42
  import {
39
43
  daytonaBackend,
40
44
  ensureDaytonaCredentials,
@@ -42,7 +46,7 @@ import {
42
46
  readDaytonaCredStatus,
43
47
  readPreparedDaytonaState,
44
48
  secretsPath
45
- } from "./chunk-46NXCJ6Z.js";
49
+ } from "./chunk-NXX3KQZ6.js";
46
50
  import {
47
51
  detectEgressIp,
48
52
  ensureHetznerCredentials,
@@ -53,7 +57,7 @@ import {
53
57
  readPreparedState,
54
58
  secretsPath as secretsPath2,
55
59
  syncFirewallSource
56
- } from "./chunk-3JXSW6PN.js";
60
+ } from "./chunk-P6UT5XGE.js";
57
61
  import {
58
62
  detectSbx,
59
63
  ensureVercelCredentials,
@@ -62,14 +66,14 @@ import {
62
66
  readPreparedState as readPreparedState2,
63
67
  readVercelCredStatus,
64
68
  secretsPath as secretsPath3
65
- } from "./chunk-IA6YHH52.js";
69
+ } from "./chunk-MODNW54N.js";
66
70
  import {
67
71
  ensureE2bCredentials,
68
72
  maskKey as maskKey4,
69
73
  readE2bCredStatus,
70
74
  readPreparedState as readPreparedState3,
71
75
  secretsPath as secretsPath4
72
- } from "./chunk-XWBFWUY2.js";
76
+ } from "./chunk-52LKNUY7.js";
73
77
  import {
74
78
  agentSpecsForCloud,
75
79
  currentCloudBaseFingerprint,
@@ -79,7 +83,7 @@ import {
79
83
  probeCloudCheckpoint,
80
84
  resolveCloudCheckpoint,
81
85
  seedAgentVolumesIfFresh
82
- } from "./chunk-OG4KMYOJ.js";
86
+ } from "./chunk-ZX6DTA4X.js";
83
87
  import {
84
88
  ALL_CONNECTORS,
85
89
  BOX_STATUS_EVENT,
@@ -229,13 +233,14 @@ import {
229
233
  unpauseBox,
230
234
  unsetConfigValue,
231
235
  uploadToBox,
236
+ volumeClaudeCredentials,
232
237
  volumeExists,
233
238
  volumeHasCodexAuth,
234
239
  volumeHasOpencodeAuth,
235
240
  waitForTmuxPaneContent,
236
241
  warmUpClaudeCredentials,
237
242
  writeJob
238
- } from "./chunk-U7IZS2ZP.js";
243
+ } from "./chunk-3VFY3N4A.js";
239
244
  import {
240
245
  AmbiguousBoxError,
241
246
  BoxNotFoundError,
@@ -253,7 +258,7 @@ import {
253
258
  resolveAgentLauncher,
254
259
  resolveBoxRef,
255
260
  resolveRuleRefs
256
- } from "./chunk-6QFPYU4Z.js";
261
+ } from "./chunk-7K2A3NLE.js";
257
262
  import "./chunk-G3H2L3O2.js";
258
263
  import {
259
264
  __export,
@@ -261,11 +266,11 @@ import {
261
266
  } from "./chunk-WJFZJZIM.js";
262
267
 
263
268
  // src/version.ts
264
- var AGENTBOX_VERSION = true ? "0.18.0" : "0.0.0-dev";
265
- var AGENTBOX_COMMIT = true ? "49139851d" : "dev";
269
+ var AGENTBOX_VERSION = true ? "0.20.0" : "0.0.0-dev";
270
+ var AGENTBOX_COMMIT = true ? "cb4cdf97e" : "dev";
266
271
 
267
272
  // src/index.ts
268
- import { Command as Command51 } from "commander";
273
+ import { Command as Command52 } from "commander";
269
274
 
270
275
  // src/engine-override.ts
271
276
  async function applyEngineOverrideAtStartup() {
@@ -1018,7 +1023,7 @@ function parsePositiveInt(raw, label) {
1018
1023
  }
1019
1024
 
1020
1025
  // src/commands/attach.ts
1021
- import { intro as intro5, isCancel as isCancel2, log as log13, outro as outro4, select as select2 } from "@clack/prompts";
1026
+ import { intro as intro5, isCancel as isCancel2, log as log14, outro as outro4, select as select2 } from "@clack/prompts";
1022
1027
  import { Command as Command6 } from "commander";
1023
1028
  import { execa as execa2 } from "execa";
1024
1029
 
@@ -1124,6 +1129,21 @@ async function readAuthFile(path = AUTH_FILE) {
1124
1129
  }
1125
1130
  }
1126
1131
 
1132
+ // src/lib/cloud-sizing.ts
1133
+ function cloudSizingProviderOptions(providerName, cfg) {
1134
+ if (providerName === "vercel") {
1135
+ return {
1136
+ vcpus: cfg.box.vercelVcpus,
1137
+ timeoutMs: cfg.box.vercelTimeoutMs,
1138
+ networkPolicy: cfg.box.vercelNetworkPolicy
1139
+ };
1140
+ }
1141
+ if (providerName === "e2b") {
1142
+ return { timeoutMs: cfg.box.e2bTimeoutMs };
1143
+ }
1144
+ return {};
1145
+ }
1146
+
1127
1147
  // src/lib/queue/assert-creds.ts
1128
1148
  import { stat } from "fs/promises";
1129
1149
  import { homedir } from "os";
@@ -1136,10 +1156,12 @@ async function fileExists(p) {
1136
1156
  return false;
1137
1157
  }
1138
1158
  }
1139
- async function claudeAuthAvailable(env) {
1159
+ async function claudeCredStatus(env, isCloud) {
1140
1160
  const resolved = await resolveClaudeAuth(env);
1141
- if (resolved.source !== "none") return true;
1142
- return hostBackupHasCredentials();
1161
+ if (resolved.source !== "none") return "ok";
1162
+ if (!await hostBackupHasCredentials()) return "missing";
1163
+ if (isCloud && await hostClaudeBackupExpired()) return "expired";
1164
+ return "ok";
1143
1165
  }
1144
1166
  async function codexAuthAvailable(image, env = process.env) {
1145
1167
  if ((env["OPENAI_API_KEY"] ?? "").length > 0) return true;
@@ -1154,10 +1176,11 @@ async function opencodeAuthAvailable(image, env = process.env) {
1154
1176
  return volumeHasOpencodeAuth(SHARED_OPENCODE_VOLUME, image);
1155
1177
  }
1156
1178
  var MESSAGES = {
1157
- "claude-code": "-i / --initial-prompt: no Claude credentials on host. Run `agentbox claude login` first (or `agentbox claude` interactively) to seed them, then retry.",
1158
- codex: "-i / --initial-prompt: no Codex credentials on host. Run `agentbox codex login` first (or set OPENAI_API_KEY) to seed them, then retry.",
1159
- opencode: "-i / --initial-prompt: no OpenCode credentials on host. Run `agentbox opencode login` first to seed them, then retry."
1179
+ "claude-code": "No Claude credentials on host. Run `agentbox claude login` first (or `agentbox claude` interactively) to seed them, then retry.",
1180
+ codex: "No Codex credentials on host. Run `agentbox codex login` first (or set OPENAI_API_KEY) to seed them, then retry.",
1181
+ opencode: "No OpenCode credentials on host. Run `agentbox opencode login` first to seed them, then retry."
1160
1182
  };
1183
+ var CLAUDE_EXPIRED_MESSAGE = "Your saved Claude login looks expired. Refresh it with `agentbox claude login`, then retry.";
1161
1184
  var MissingAgentCredsError = class extends Error {
1162
1185
  agent;
1163
1186
  constructor(agent, message) {
@@ -1166,16 +1189,22 @@ var MissingAgentCredsError = class extends Error {
1166
1189
  this.agent = agent;
1167
1190
  }
1168
1191
  };
1192
+ var ExpiredAgentCredsError = class extends MissingAgentCredsError {
1193
+ constructor(agent, message) {
1194
+ super(agent, message);
1195
+ this.name = "ExpiredAgentCredsError";
1196
+ }
1197
+ };
1169
1198
  async function assertAgentCredsAvailable(input) {
1170
1199
  const env = input.env ?? process.env;
1171
- let ok = false;
1172
1200
  if (input.agent === "claude-code") {
1173
- ok = await claudeAuthAvailable(env);
1174
- } else if (input.agent === "codex") {
1175
- ok = await codexAuthAvailable(input.image, env);
1176
- } else {
1177
- ok = await opencodeAuthAvailable(input.image, env);
1201
+ const isCloud = input.providerName !== void 0 && input.providerName !== "docker";
1202
+ const status = await claudeCredStatus(env, isCloud);
1203
+ if (status === "missing") throw new MissingAgentCredsError(input.agent, MESSAGES[input.agent]);
1204
+ if (status === "expired") throw new ExpiredAgentCredsError(input.agent, CLAUDE_EXPIRED_MESSAGE);
1205
+ return;
1178
1206
  }
1207
+ const ok = input.agent === "codex" ? await codexAuthAvailable(input.image, env) : await opencodeAuthAvailable(input.image, env);
1179
1208
  if (!ok) throw new MissingAgentCredsError(input.agent, MESSAGES[input.agent]);
1180
1209
  }
1181
1210
 
@@ -1526,7 +1555,7 @@ async function dirSizeCapped(dir, cap, exclude = []) {
1526
1555
 
1527
1556
  // src/lib/carry-resync.ts
1528
1557
  async function resyncCarryFiles(args) {
1529
- const log50 = args.onLog ?? (() => {
1558
+ const log51 = args.onLog ?? (() => {
1530
1559
  });
1531
1560
  const prior = args.box.carry?.entries ?? [];
1532
1561
  if (prior.length === 0) return { recopied: 0, skippedNew: 0 };
@@ -1538,7 +1567,7 @@ async function resyncCarryFiles(args) {
1538
1567
  maxBytes: cfg.effective.box.cpMaxBytes
1539
1568
  });
1540
1569
  if (resolved.errors.length > 0) {
1541
- log50(`carry: resync skipped (resolve errors: ${resolved.errors.length})`);
1570
+ log51(`carry: resync skipped (resolve errors: ${resolved.errors.length})`);
1542
1571
  return { recopied: 0, skippedNew: 0 };
1543
1572
  }
1544
1573
  const priorByDest = new Map(prior.map((e) => [e.dest, e]));
@@ -1555,7 +1584,7 @@ async function resyncCarryFiles(args) {
1555
1584
  if (hash === void 0 || hash !== existing.hash) changed.push(entry);
1556
1585
  }
1557
1586
  if (skippedNew > 0) {
1558
- log50(
1587
+ log51(
1559
1588
  `carry: ${String(skippedNew)} new entry/entries not applied on resync \u2014 recreate the box to approve`
1560
1589
  );
1561
1590
  }
@@ -1563,9 +1592,9 @@ async function resyncCarryFiles(args) {
1563
1592
  const result = await copyCarryPathsToBox({
1564
1593
  container: args.box.container,
1565
1594
  entries: changed,
1566
- onLog: log50
1595
+ onLog: log51
1567
1596
  });
1568
- for (const err of result.errors) log50(`carry: ${err}`);
1597
+ for (const err of result.errors) log51(`carry: ${err}`);
1569
1598
  const updatedByDest = new Map(result.applied.map((e) => [e.dest, e]));
1570
1599
  const mergedEntries = prior.map((e) => updatedByDest.get(e.dest) ?? e);
1571
1600
  await recordBox({
@@ -1573,7 +1602,7 @@ async function resyncCarryFiles(args) {
1573
1602
  carry: { count: mergedEntries.length, entries: mergedEntries }
1574
1603
  });
1575
1604
  if (result.applied.length > 0) {
1576
- log50(`carry: re-copied ${String(result.applied.length)} changed file(s)`);
1605
+ log51(`carry: re-copied ${String(result.applied.length)} changed file(s)`);
1577
1606
  }
1578
1607
  return { recopied: result.applied.length, skippedNew };
1579
1608
  }
@@ -1612,36 +1641,6 @@ async function maybeResyncWorkspace(args) {
1612
1641
  return buildResyncWarning(result);
1613
1642
  }
1614
1643
 
1615
- // src/lib/skip-permissions.ts
1616
- var CLAUDE_SKIP_PERMISSIONS_FLAG = "--dangerously-skip-permissions";
1617
- var CODEX_SKIP_PERMISSIONS_FLAG = "--dangerously-bypass-approvals-and-sandbox";
1618
- var CLAUDE_CONFLICTING = /* @__PURE__ */ new Set([CLAUDE_SKIP_PERMISSIONS_FLAG, "--permission-mode"]);
1619
- var CODEX_CONFLICTING = /* @__PURE__ */ new Set([
1620
- CODEX_SKIP_PERMISSIONS_FLAG,
1621
- "--yolo",
1622
- "--full-auto",
1623
- "-a",
1624
- "--ask-for-approval",
1625
- "-s",
1626
- "--sandbox"
1627
- ]);
1628
- function inject(args, flag, conflicting) {
1629
- const hasConflict = args.some((a) => {
1630
- const eq = a.indexOf("=");
1631
- return conflicting.has(eq === -1 ? a : a.slice(0, eq));
1632
- });
1633
- if (hasConflict) return args;
1634
- return [flag, ...args];
1635
- }
1636
- function applyClaudeSkipPermissions(args, cfg) {
1637
- if (!cfg.claude.dangerouslySkipPermissions) return args;
1638
- return inject(args, CLAUDE_SKIP_PERMISSIONS_FLAG, CLAUDE_CONFLICTING);
1639
- }
1640
- function applyCodexSkipPermissions(args, cfg) {
1641
- if (!cfg.codex.dangerouslySkipPermissions) return args;
1642
- return inject(args, CODEX_SKIP_PERMISSIONS_FLAG, CODEX_CONFLICTING);
1643
- }
1644
-
1645
1644
  // src/lib/queue/parse-max-option.ts
1646
1645
  function parseMaxOption(flag, raw) {
1647
1646
  if (raw === void 0) return void 0;
@@ -1821,6 +1820,9 @@ function resolveAttachInOption(opts) {
1821
1820
  return void 0;
1822
1821
  }
1823
1822
 
1823
+ // src/commands/_cloud-agent-create.ts
1824
+ import { log as log4 } from "@clack/prompts";
1825
+
1824
1826
  // src/lib/progress.ts
1825
1827
  import { spinner } from "@clack/prompts";
1826
1828
 
@@ -1996,6 +1998,9 @@ ${instruction}`));
1996
1998
  }
1997
1999
 
1998
2000
  // src/commands/_cloud-agent-create.ts
2001
+ function agentKindFor(mode) {
2002
+ return mode === "claude" ? "claude-code" : mode;
2003
+ }
1999
2004
  async function cloudAgentCreate(args) {
2000
2005
  const s = makeProgressReporter(args.verbose === true);
2001
2006
  s.start("creating cloud box");
@@ -2013,6 +2018,11 @@ async function cloudAgentCreate(args) {
2013
2018
  extraArgs = [...hook.agentArgsPrefix, ...extraArgs ?? []];
2014
2019
  }
2015
2020
  }
2021
+ const resyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
2022
+ if (resyncWarning) {
2023
+ if (args.hasSeedPrompt) log4.warn(resyncWarning);
2024
+ else extraArgs = buildPromptArgs(agentKindFor(args.mode), resyncWarning, extraArgs ?? []);
2025
+ }
2016
2026
  await printLaunchRecap({
2017
2027
  record: result.record,
2018
2028
  mode: args.mode,
@@ -2043,7 +2053,7 @@ async function cloudAgentCreate(args) {
2043
2053
  // src/lib/carry-gate.ts
2044
2054
  import { readFile as readFile2 } from "fs/promises";
2045
2055
  import { join as join6 } from "path";
2046
- import { log as log5 } from "@clack/prompts";
2056
+ import { log as log6 } from "@clack/prompts";
2047
2057
 
2048
2058
  // src/fmt.ts
2049
2059
  function fmtBytes2(n) {
@@ -2184,13 +2194,13 @@ async function runQueuedCarryGate(args) {
2184
2194
  onLog: args.onLog
2185
2195
  });
2186
2196
  if (gate.decision === "cancel") {
2187
- log5.warn("carry: cancelled \u2014 not queuing the job");
2197
+ log6.warn("carry: cancelled \u2014 not queuing the job");
2188
2198
  args.onClose?.();
2189
2199
  process.exit(0);
2190
2200
  }
2191
2201
  return gate.decision === "approve" ? gate.entries : [];
2192
2202
  } catch (err) {
2193
- log5.error(err instanceof Error ? err.message : String(err));
2203
+ log6.error(err instanceof Error ? err.message : String(err));
2194
2204
  args.onClose?.();
2195
2205
  process.exit(1);
2196
2206
  }
@@ -2446,6 +2456,22 @@ async function peekCodexCwd(file) {
2446
2456
  }
2447
2457
  return null;
2448
2458
  }
2459
+ var CWD_REWRITE_TYPES = /* @__PURE__ */ new Set(["session_meta", "turn_context"]);
2460
+ function rewriteHostPath(s, hostCwd) {
2461
+ if (s === hostCwd) return BOX_WORKSPACE;
2462
+ if (s.startsWith(hostCwd + "/")) return BOX_WORKSPACE + s.slice(hostCwd.length);
2463
+ return s;
2464
+ }
2465
+ function deepRewriteHostPaths(value, hostCwd) {
2466
+ if (typeof value === "string") return rewriteHostPath(value, hostCwd);
2467
+ if (Array.isArray(value)) return value.map((v) => deepRewriteHostPaths(v, hostCwd));
2468
+ if (value && typeof value === "object") {
2469
+ const o = value;
2470
+ for (const k of Object.keys(o)) o[k] = deepRewriteHostPaths(o[k], hostCwd);
2471
+ return o;
2472
+ }
2473
+ return value;
2474
+ }
2449
2475
  async function rewriteCodexSession(src, dst, hostCwd) {
2450
2476
  const raw = await readFile4(src, "utf8");
2451
2477
  const lines = raw.split("\n");
@@ -2464,13 +2490,10 @@ async function rewriteCodexSession(src, dst, hostCwd) {
2464
2490
  }
2465
2491
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
2466
2492
  const obj = parsed;
2467
- if (obj.type === "session_meta" && obj.payload && typeof obj.payload === "object" && !Array.isArray(obj.payload)) {
2468
- const payload = obj.payload;
2469
- if (payload.cwd === hostCwd) {
2470
- payload.cwd = BOX_WORKSPACE;
2471
- out.push(JSON.stringify(obj));
2472
- continue;
2473
- }
2493
+ if (typeof obj.type === "string" && CWD_REWRITE_TYPES.has(obj.type) && obj.payload && typeof obj.payload === "object" && !Array.isArray(obj.payload)) {
2494
+ obj.payload = deepRewriteHostPaths(obj.payload, hostCwd);
2495
+ out.push(JSON.stringify(obj));
2496
+ continue;
2474
2497
  }
2475
2498
  }
2476
2499
  out.push(line);
@@ -2554,7 +2577,7 @@ async function resolvePlanTeleport(opts) {
2554
2577
  }
2555
2578
 
2556
2579
  // src/lib/install-hint.ts
2557
- import { log as log6 } from "@clack/prompts";
2580
+ import { log as log7 } from "@clack/prompts";
2558
2581
  import { existsSync as existsSync4, mkdirSync, writeFileSync } from "fs";
2559
2582
  import { homedir as homedir7 } from "os";
2560
2583
  import { join as join10 } from "path";
@@ -2566,7 +2589,7 @@ function maybeShowInstallHint() {
2566
2589
  if (existsSync4(marker)) return;
2567
2590
  mkdirSync(join10(homedir7(), ".agentbox"), { recursive: true });
2568
2591
  writeFileSync(marker, "");
2569
- log6.info("tip: run 'agentbox install' to enable the /agentbox fork command in host Claude");
2592
+ log7.info("tip: run 'agentbox install' to enable the /agentbox fork command in host Claude");
2570
2593
  } catch {
2571
2594
  }
2572
2595
  }
@@ -2756,13 +2779,13 @@ import { basename as basename2 } from "path";
2756
2779
  async function cloudBackendForProvider(provider) {
2757
2780
  switch (provider) {
2758
2781
  case "daytona":
2759
- return (await import("./dist-7BS2JS27.js")).daytonaBackend;
2782
+ return (await import("./dist-CZ6CRADC.js")).daytonaBackend;
2760
2783
  case "hetzner":
2761
- return (await import("./dist-4BHW7DCO.js")).hetznerBackend;
2784
+ return (await import("./dist-C3YRC3PP.js")).hetznerBackend;
2762
2785
  case "vercel":
2763
- return (await import("./dist-T7ESSBCZ.js")).vercelBackend;
2786
+ return (await import("./dist-3WFNXXPE.js")).vercelBackend;
2764
2787
  case "e2b":
2765
- return (await import("./dist-3UYQZOAO.js")).e2bBackend;
2788
+ return (await import("./dist-7ELDXBAG.js")).e2bBackend;
2766
2789
  default:
2767
2790
  return null;
2768
2791
  }
@@ -2770,13 +2793,13 @@ async function cloudBackendForProvider(provider) {
2770
2793
  async function currentCloudBaseFingerprintLive(provider) {
2771
2794
  switch (provider) {
2772
2795
  case "daytona":
2773
- return (await import("./dist-7BS2JS27.js")).currentDaytonaBaseFingerprintLive();
2796
+ return (await import("./dist-CZ6CRADC.js")).currentDaytonaBaseFingerprintLive();
2774
2797
  case "hetzner":
2775
- return (await import("./dist-4BHW7DCO.js")).currentHetznerBaseFingerprintLive();
2798
+ return (await import("./dist-C3YRC3PP.js")).currentHetznerBaseFingerprintLive();
2776
2799
  case "vercel":
2777
- return (await import("./dist-T7ESSBCZ.js")).currentVercelBaseFingerprintLive();
2800
+ return (await import("./dist-3WFNXXPE.js")).currentVercelBaseFingerprintLive();
2778
2801
  case "e2b":
2779
- return (await import("./dist-3UYQZOAO.js")).currentE2bBaseFingerprintLive();
2802
+ return (await import("./dist-7ELDXBAG.js")).currentE2bBaseFingerprintLive();
2780
2803
  default:
2781
2804
  return void 0;
2782
2805
  }
@@ -3052,7 +3075,7 @@ function passthroughFlags(opts) {
3052
3075
  }
3053
3076
 
3054
3077
  // src/commands/prepare.ts
3055
- import { intro, log as log9, spinner as spinner3 } from "@clack/prompts";
3078
+ import { intro, log as log10, spinner as spinner3 } from "@clack/prompts";
3056
3079
  import { Command as Command2 } from "commander";
3057
3080
  async function dockerStatus() {
3058
3081
  let img;
@@ -3115,7 +3138,7 @@ async function renderDocker(status) {
3115
3138
  }
3116
3139
  async function daytonaStatus() {
3117
3140
  try {
3118
- const mod = await import("./dist-7BS2JS27.js");
3141
+ const mod = await import("./dist-CZ6CRADC.js");
3119
3142
  return await mod.getDaytonaStatus();
3120
3143
  } catch (err) {
3121
3144
  return {
@@ -3126,7 +3149,7 @@ async function daytonaStatus() {
3126
3149
  }
3127
3150
  async function e2bStatus() {
3128
3151
  try {
3129
- const mod = await import("./dist-3UYQZOAO.js");
3152
+ const mod = await import("./dist-7ELDXBAG.js");
3130
3153
  const cred = mod.readE2bCredStatus();
3131
3154
  if (cred.auth === "none") {
3132
3155
  return { configured: false, reason: "not configured \u2014 run `agentbox e2b login`" };
@@ -3236,7 +3259,7 @@ async function runPrepare(providerName, opts = {}) {
3236
3259
  }
3237
3260
  const provider = await getProvider(providerName);
3238
3261
  if (typeof provider.prepare !== "function") {
3239
- log9.error(`provider '${providerName}' does not implement prepare`);
3262
+ log10.error(`provider '${providerName}' does not implement prepare`);
3240
3263
  process.exit(1);
3241
3264
  }
3242
3265
  const cwd = opts.cwd ?? process.cwd();
@@ -3257,10 +3280,10 @@ async function runPrepare(providerName, opts = {}) {
3257
3280
  const configKey = boxImageConfigKey(providerName);
3258
3281
  try {
3259
3282
  const written = await setConfigValue("project", configKey, result.snapshotName, cwd);
3260
- log9.success(`${configKey} = ${result.snapshotName} (written to ${written.path})`);
3283
+ log10.success(`${configKey} = ${result.snapshotName} (written to ${written.path})`);
3261
3284
  } catch (err) {
3262
3285
  const msg = err instanceof Error ? err.message : String(err);
3263
- log9.warn(
3286
+ log10.warn(
3264
3287
  `prepared snapshot '${result.snapshotName}', but failed to pin it into the project config: ${msg}
3265
3288
  Run \`agentbox config set --project ${configKey} ${result.snapshotName}\` manually.`
3266
3289
  );
@@ -3274,24 +3297,19 @@ Run \`agentbox config set --project ${configKey} ${result.snapshotName}\` manual
3274
3297
  if (typeof projectImage === "string" && projectImage.length > 0 && projectImage !== DEFAULT_BOX_IMAGE) {
3275
3298
  const cleared = await unsetConfigValue("project", "box.image", cwd);
3276
3299
  if (cleared.existed) {
3277
- log9.warn(
3300
+ log10.warn(
3278
3301
  `migrated stale \`box.image\` from a previous prepare (was \`${projectImage}\`); re-set manually if you actually meant it: \`agentbox config set --project box.image <ref>\``
3279
3302
  );
3280
3303
  }
3281
3304
  }
3282
3305
  } catch (err) {
3283
3306
  const msg = err instanceof Error ? err.message : String(err);
3284
- log9.warn(`could not migrate stale box.image (continuing): ${msg}`);
3307
+ log10.warn(`could not migrate stale box.image (continuing): ${msg}`);
3285
3308
  }
3286
3309
  if (!opts.suppressStatus) {
3287
3310
  process.stdout.write("\n");
3288
3311
  await showStatus({ onlyProvider: providerName });
3289
3312
  }
3290
- if (!opts.suppressTip) {
3291
- log9.info(
3292
- "tip: install the agentbox host skill so Claude Code on this machine can drive AgentBox for you:\n npx skills add https://github.com/madarco/agentbox --skill agentbox"
3293
- );
3294
- }
3295
3313
  } catch (err) {
3296
3314
  sp.stop(`prepare failed: ${describeError(err)}`);
3297
3315
  throw err;
@@ -3340,6 +3358,159 @@ function describeError(err) {
3340
3358
  return parts.join(" \u2014 ");
3341
3359
  }
3342
3360
 
3361
+ // src/commands/claude.ts
3362
+ import { spawn } from "child_process";
3363
+ import { existsSync as existsSync5 } from "fs";
3364
+ import { randomUUID } from "crypto";
3365
+ import { setTimeout as sleep3 } from "timers/promises";
3366
+
3367
+ // src/lib/claude-login-session.ts
3368
+ import {
3369
+ mkdirSync as mkdirSync3,
3370
+ readdirSync,
3371
+ readFileSync,
3372
+ renameSync as renameSync2,
3373
+ rmSync,
3374
+ unlinkSync as unlinkSync2,
3375
+ writeFileSync as writeFileSync3
3376
+ } from "fs";
3377
+ import { homedir as homedir9 } from "os";
3378
+ import { join as join12 } from "path";
3379
+ function selectLoginMode(o) {
3380
+ if (o.code) return "code";
3381
+ if (o.headless || !o.isTTY) return "headless";
3382
+ return "interactive";
3383
+ }
3384
+ function stateDir2() {
3385
+ return process.env.AGENTBOX_HOME ?? join12(homedir9(), ".agentbox");
3386
+ }
3387
+ function loginRootDir() {
3388
+ return join12(stateDir2(), "claude-login");
3389
+ }
3390
+ function loginSessionDir(id) {
3391
+ return join12(loginRootDir(), id);
3392
+ }
3393
+ function atomicWrite(path, data) {
3394
+ const tmp = `${path}.tmp.${String(process.pid)}.${String(Date.now())}`;
3395
+ writeFileSync3(tmp, data, { mode: 384 });
3396
+ renameSync2(tmp, path);
3397
+ }
3398
+ function readJsonWithRetry(path) {
3399
+ for (let attempt = 0; attempt < 2; attempt++) {
3400
+ try {
3401
+ return JSON.parse(readFileSync(path, "utf8"));
3402
+ } catch {
3403
+ }
3404
+ }
3405
+ return null;
3406
+ }
3407
+ function writeLoginRequest(id, req) {
3408
+ mkdirSync3(loginSessionDir(id), { recursive: true });
3409
+ atomicWrite(join12(loginSessionDir(id), "request.json"), JSON.stringify(req));
3410
+ }
3411
+ function readLoginRequest(id) {
3412
+ return readJsonWithRetry(join12(loginSessionDir(id), "request.json"));
3413
+ }
3414
+ function writeLoginState(id, state) {
3415
+ mkdirSync3(loginSessionDir(id), { recursive: true });
3416
+ const full = { ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
3417
+ atomicWrite(join12(loginSessionDir(id), "state.json"), JSON.stringify(full));
3418
+ }
3419
+ function readLoginState(id) {
3420
+ return readJsonWithRetry(join12(loginSessionDir(id), "state.json"));
3421
+ }
3422
+ function writeLoginCode(id, code) {
3423
+ mkdirSync3(loginSessionDir(id), { recursive: true });
3424
+ atomicWrite(join12(loginSessionDir(id), "code"), code.trim());
3425
+ }
3426
+ function takeLoginCode(id) {
3427
+ const path = join12(loginSessionDir(id), "code");
3428
+ try {
3429
+ const code = readFileSync(path, "utf8").trim();
3430
+ try {
3431
+ unlinkSync2(path);
3432
+ } catch {
3433
+ }
3434
+ return code.length > 0 ? code : null;
3435
+ } catch {
3436
+ return null;
3437
+ }
3438
+ }
3439
+ function pidAlive(pid) {
3440
+ if (!Number.isInteger(pid) || pid <= 0) return false;
3441
+ try {
3442
+ process.kill(pid, 0);
3443
+ return true;
3444
+ } catch (err) {
3445
+ return err.code === "EPERM";
3446
+ }
3447
+ }
3448
+ function listSessions2() {
3449
+ try {
3450
+ return readdirSync(loginRootDir(), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
3451
+ } catch {
3452
+ return [];
3453
+ }
3454
+ }
3455
+ function findPendingSession() {
3456
+ for (const id of listSessions2()) {
3457
+ const state = readLoginState(id);
3458
+ if (state && state.phase === "awaiting-code" && pidAlive(state.pid)) {
3459
+ return { id, state };
3460
+ }
3461
+ }
3462
+ return null;
3463
+ }
3464
+ function findLiveSession() {
3465
+ for (const id of listSessions2()) {
3466
+ const state = readLoginState(id);
3467
+ if (state && state.phase !== "done" && state.phase !== "error" && pidAlive(state.pid)) {
3468
+ return { id, state };
3469
+ }
3470
+ }
3471
+ return null;
3472
+ }
3473
+ function cleanupStaleSessions(now = Date.now()) {
3474
+ const TERMINAL_MAX_AGE = 5 * 6e4;
3475
+ const STUCK_MAX_AGE = 15 * 6e4;
3476
+ for (const id of listSessions2()) {
3477
+ const dir = loginSessionDir(id);
3478
+ const state = readLoginState(id);
3479
+ let stale = false;
3480
+ if (!state) {
3481
+ stale = true;
3482
+ } else {
3483
+ const age = now - Date.parse(state.updatedAt);
3484
+ const terminal = state.phase === "done" || state.phase === "error";
3485
+ if (terminal) {
3486
+ stale = age > TERMINAL_MAX_AGE;
3487
+ } else if (!pidAlive(state.pid)) {
3488
+ stale = true;
3489
+ } else {
3490
+ stale = age > STUCK_MAX_AGE;
3491
+ }
3492
+ }
3493
+ if (stale) {
3494
+ try {
3495
+ rmSync(dir, { recursive: true, force: true });
3496
+ } catch {
3497
+ }
3498
+ }
3499
+ }
3500
+ }
3501
+ var CSI = new RegExp("\\u001b\\[[0-9;?]*[ -\\/]*[@-~]", "g");
3502
+ var URL_BODY = "[^\\s'\"`<>)\\]\\u0000-\\u001f]";
3503
+ var OAUTH_URL = new RegExp(
3504
+ `https?://(?:claude\\.com|claude\\.ai|console\\.anthropic\\.com)/${URL_BODY}*oauth${URL_BODY}*`,
3505
+ "i"
3506
+ );
3507
+ function extractOAuthUrl(text2) {
3508
+ const clean = text2.replace(CSI, "");
3509
+ const m = clean.match(OAUTH_URL);
3510
+ if (!m) return null;
3511
+ return m[0].replace(/["'`)\]>]+$/, "").replace(/[.,;]+$/, "");
3512
+ }
3513
+
3343
3514
  // src/commands/claude.ts
3344
3515
  function pickCreateOpts(opts) {
3345
3516
  return {
@@ -3427,8 +3598,11 @@ async function runClaudeLoginContainer(image, extraArgs) {
3427
3598
  async function maybeRunClaudeLogin(args) {
3428
3599
  if (!process.stdin.isTTY || args.yes) return;
3429
3600
  if (args.authSource === "host-env") return;
3430
- if (await hostBackupHasCredentials()) return;
3431
- const message = args.authSource === "auth-file" ? "You're on a legacy API token (shows as 'Claude API'). Sign in with your Claude subscription instead?" : "Sign in with your Claude subscription? (saved and reused by every box)";
3601
+ const vol = await imageExists(args.image) ? await volumeClaudeCredentials(SHARED_CLAUDE_VOLUME, args.image) : { present: false, hasRefreshToken: false };
3602
+ if (vol.hasRefreshToken) return;
3603
+ const blanked = vol.present && !vol.hasRefreshToken;
3604
+ if (!vol.present && await hostBackupHasCredentials()) return;
3605
+ const message = blanked ? "Your saved Claude login looks expired. Sign in again? (saved and reused by every box)" : args.authSource === "auth-file" ? "You're on a legacy API token (shows as 'Claude API'). Sign in with your Claude subscription instead?" : "Sign in with your Claude subscription? (saved and reused by every box)";
3432
3606
  const answer = await confirm({ message, initialValue: true });
3433
3607
  if (!answer) {
3434
3608
  prompt_exports.log.info("Skipped sign-in \u2014 claude will prompt you to /login inside the box.");
@@ -3612,7 +3786,8 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3612
3786
  try {
3613
3787
  await assertAgentCredsAvailable({
3614
3788
  agent: "claude-code",
3615
- image: cfg.effective.box.image
3789
+ image: cfg.effective.box.image,
3790
+ providerName
3616
3791
  });
3617
3792
  } catch (err) {
3618
3793
  if (err instanceof MissingAgentCredsError) {
@@ -3650,6 +3825,22 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3650
3825
  const providerDefault = resolveDefaultCheckpoint(cfg.effective, providerName);
3651
3826
  const checkpointRef = opts.snapshot && opts.snapshot.length > 0 ? opts.snapshot : providerDefault.length > 0 ? providerDefault : void 0;
3652
3827
  const resolved = await resolveClaudeAuth(process.env);
3828
+ if (!process.stdin.isTTY && resolved.source !== "host-env") {
3829
+ try {
3830
+ await assertAgentCredsAvailable({
3831
+ agent: "claude-code",
3832
+ image: cfg.effective.box.image,
3833
+ providerName
3834
+ });
3835
+ } catch (err) {
3836
+ if (err instanceof MissingAgentCredsError) {
3837
+ prompt_exports.log.error(err.message);
3838
+ cmdLog.close();
3839
+ process.exit(2);
3840
+ }
3841
+ throw err;
3842
+ }
3843
+ }
3653
3844
  if (!isCloud) {
3654
3845
  await maybeRunClaudeLogin({
3655
3846
  image: cfg.effective.box.image,
@@ -3707,7 +3898,6 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3707
3898
  await runPrepare(providerName, {
3708
3899
  force: true,
3709
3900
  cwd: opts.workspace,
3710
- suppressTip: true,
3711
3901
  suppressStatus: true
3712
3902
  });
3713
3903
  }
@@ -3763,9 +3953,14 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3763
3953
  limits: resolveLimits(cfg.effective.box, opts),
3764
3954
  fromBranch,
3765
3955
  useBranch,
3766
- projectRoot
3956
+ resyncOnStart: opts.resync,
3957
+ projectRoot,
3958
+ // Per-provider session-lifetime (e2b/vercel timeout) so the keepalive
3959
+ // seeds correctly; mirrors `agentbox create`.
3960
+ providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective)
3767
3961
  },
3768
3962
  binary: "claude",
3963
+ hasSeedPrompt: Boolean(planPrepared) || wiz.action === "launch-with-prompt" && Boolean(wiz.initialPrompt) || Boolean(resumePrepared),
3769
3964
  sessionName: cfg.effective.claude.sessionName,
3770
3965
  mode: "claude",
3771
3966
  extraArgs: effectiveClaudeArgs,
@@ -4053,6 +4248,15 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4053
4248
  onProgress: (line) => s.message(clampSpinnerLine(line))
4054
4249
  });
4055
4250
  let effectiveArgs = applyClaudeSkipPermissions(claudeArgs, cfg.effective);
4251
+ let attachResumed = false;
4252
+ if (opts.attachResume && claudeArgs.length === 0 && !resumePrepared) {
4253
+ const provider = await providerForBox(box);
4254
+ const resume = await agentResumeArgs(provider, box, "claude");
4255
+ if (resume) {
4256
+ effectiveArgs = [...effectiveArgs, ...resume];
4257
+ attachResumed = true;
4258
+ }
4259
+ }
4056
4260
  if (resumePrepared) {
4057
4261
  s.message("uploading claude session into box");
4058
4262
  try {
@@ -4073,7 +4277,7 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4073
4277
  throw err;
4074
4278
  }
4075
4279
  }
4076
- if (resyncWarning && !resumePrepared) {
4280
+ if (resyncWarning && !resumePrepared && !attachResumed) {
4077
4281
  effectiveArgs = buildPromptArgs("claude-code", resyncWarning, effectiveArgs);
4078
4282
  }
4079
4283
  s.message("starting claude session");
@@ -4084,7 +4288,7 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4084
4288
  boxName: box.name
4085
4289
  });
4086
4290
  s.stop(`box ${box.container} ready`);
4087
- if (resyncWarning && resumePrepared) prompt_exports.log.warn(resyncWarning);
4291
+ if (resyncWarning && (resumePrepared || attachResumed)) prompt_exports.log.warn(resyncWarning);
4088
4292
  logPrune(rebuild);
4089
4293
  for (const f of rebuild.failed) {
4090
4294
  prompt_exports.log.warn(
@@ -4125,7 +4329,7 @@ var claudeAttachCommand = new Command3("attach").description(
4125
4329
  });
4126
4330
  return;
4127
4331
  }
4128
- await startOrAttachClaude(box, [], { ...opts, syncConfig: false });
4332
+ await startOrAttachClaude(box, [], { ...opts, syncConfig: false, attachResume: true });
4129
4333
  } catch (err) {
4130
4334
  if (err instanceof ClaudeSessionError) {
4131
4335
  prompt_exports.log.error(err.message);
@@ -4227,18 +4431,146 @@ var claudeStartCommand = new Command3("start").description(
4227
4431
  handleLifecycleError(err);
4228
4432
  }
4229
4433
  });
4434
+ function printAwaitingCode(st) {
4435
+ const url = st.url ?? "";
4436
+ prompt_exports.log.info("To finish signing in, open this URL in a browser and approve access:");
4437
+ process.stdout.write(`
4438
+ ${url}
4439
+
4440
+ `);
4441
+ prompt_exports.log.info("Then run: agentbox claude login --code <CODE>");
4442
+ process.stdout.write(`AGENTBOX_LOGIN_URL=${url}
4443
+ `);
4444
+ }
4445
+ async function startHeadlessLogin(args) {
4446
+ if (!await loadPtyBackend()) {
4447
+ prompt_exports.log.error(
4448
+ "Headless login needs the node-pty prebuild, which is not installed. Run `agentbox claude login` from an interactive terminal instead."
4449
+ );
4450
+ process.exit(1);
4451
+ }
4452
+ cleanupStaleSessions();
4453
+ const existing = findLiveSession();
4454
+ if (existing) {
4455
+ if (existing.state.phase === "awaiting-code" && existing.state.url) {
4456
+ prompt_exports.log.info("A login is already pending; finish it (or wait for it to expire):");
4457
+ printAwaitingCode(existing.state);
4458
+ } else {
4459
+ prompt_exports.log.info(
4460
+ "A login is already in progress; wait for it to print its URL, then finish with `agentbox claude login --code <CODE>`."
4461
+ );
4462
+ }
4463
+ return;
4464
+ }
4465
+ const cfg = await loadEffectiveConfig(process.cwd());
4466
+ const image = cfg.effective.box.image;
4467
+ const s = (0, prompt_exports.spinner)();
4468
+ s.start("preparing sandbox image");
4469
+ await ensureImage(image, { onProgress: (line) => s.message(clampSpinnerLine(line)) });
4470
+ s.stop("image ready");
4471
+ const id = randomUUID().slice(0, 8);
4472
+ writeLoginRequest(id, {
4473
+ image,
4474
+ extraArgs: args,
4475
+ cwd: process.cwd(),
4476
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
4477
+ });
4478
+ const entry = process.env.AGENTBOX_CLI_ENTRY ?? process.argv[1];
4479
+ if (!entry || !existsSync5(entry)) {
4480
+ prompt_exports.log.error("could not resolve the agentbox CLI entry to spawn the login worker");
4481
+ process.exit(1);
4482
+ }
4483
+ const child = spawn(process.execPath, [entry, "_claude-login-worker", id], {
4484
+ detached: true,
4485
+ stdio: "ignore",
4486
+ env: process.env
4487
+ });
4488
+ child.unref();
4489
+ if (typeof child.pid === "number") {
4490
+ writeLoginState(id, { phase: "starting", pid: child.pid, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
4491
+ }
4492
+ const deadline = Date.now() + 65e3;
4493
+ for (; ; ) {
4494
+ const st = readLoginState(id);
4495
+ if (st?.phase === "awaiting-code" && st.url) {
4496
+ printAwaitingCode(st);
4497
+ return;
4498
+ }
4499
+ if (st?.phase === "error") {
4500
+ prompt_exports.log.error(`login could not start: ${st.error ?? "unknown error"}`);
4501
+ process.exit(1);
4502
+ }
4503
+ if (Date.now() > deadline) {
4504
+ prompt_exports.log.error(`timed out waiting for the login URL \u2014 see ~/.agentbox/logs/claude-login-${id}.log`);
4505
+ process.exit(1);
4506
+ }
4507
+ await sleep3(400);
4508
+ }
4509
+ }
4510
+ async function deliverLoginCode(code) {
4511
+ cleanupStaleSessions();
4512
+ const pending = findPendingSession();
4513
+ if (!pending) {
4514
+ prompt_exports.log.error(
4515
+ "No pending login is waiting for a code. Start one first with `agentbox claude login` (or --headless)."
4516
+ );
4517
+ process.exit(1);
4518
+ }
4519
+ const { id } = pending;
4520
+ const submittedAt = Date.now();
4521
+ writeLoginCode(id, code);
4522
+ const s = (0, prompt_exports.spinner)();
4523
+ s.start("completing sign-in");
4524
+ const deadline = Date.now() + 12e4;
4525
+ for (; ; ) {
4526
+ const st = readLoginState(id);
4527
+ if (st?.phase === "done") {
4528
+ s.stop(st.warmed ? "credentials ready" : "signed in (credential check incomplete)");
4529
+ (0, prompt_exports.outro)("signed in \u2014 credentials saved for future boxes");
4530
+ return;
4531
+ }
4532
+ if (st?.phase === "error") {
4533
+ s.stop("sign-in failed");
4534
+ prompt_exports.log.error(st.error ?? "login failed");
4535
+ process.exit(1);
4536
+ }
4537
+ if (st?.phase === "awaiting-code" && st.lastError && Date.parse(st.updatedAt) >= submittedAt) {
4538
+ s.stop("code rejected");
4539
+ prompt_exports.log.error(`${st.lastError}. Run \`agentbox claude login --code <CODE>\` again with a fresh code.`);
4540
+ process.exit(1);
4541
+ }
4542
+ if (Date.now() > deadline) {
4543
+ s.stop("sign-in timed out");
4544
+ prompt_exports.log.error("timed out completing sign-in \u2014 see the login worker log under ~/.agentbox/logs/");
4545
+ process.exit(1);
4546
+ }
4547
+ await sleep3(500);
4548
+ }
4549
+ }
4230
4550
  var claudeLoginCommand = new Command3("login").description(
4231
- "Sign in to Claude for use in sandboxes (forwards args to `claude auth login`, e.g. --sso, --console). Runs in a throwaway container against the shared claude-config volume \u2014 usable before the first `agentbox claude`."
4551
+ "Sign in to Claude for use in sandboxes (forwards args to `claude auth login`, e.g. --sso, --console). Runs in a throwaway container against the shared claude-config volume \u2014 usable before the first `agentbox claude`. Non-interactive (no TTY) or `--headless`: prints the auth URL, then finish with `--code <CODE>`."
4232
4552
  ).argument(
4233
4553
  "[args...]",
4234
4554
  "extra args forwarded to `claude auth login`; place after `--`, e.g. `agentbox claude login -- --sso`"
4235
- ).action(async (args) => {
4236
- (0, prompt_exports.intro)("Signing in to Claude...");
4237
- if (!process.stdin.isTTY) {
4238
- prompt_exports.log.error("`agentbox claude login` needs an interactive terminal.");
4239
- process.exit(1);
4240
- }
4555
+ ).option(
4556
+ "--headless",
4557
+ "drive login without a terminal: print the auth URL, then finish with `--code` (auto-selected when stdin is not a TTY)"
4558
+ ).option("--code <code>", "deliver the OAuth code to a pending headless login session").action(async (args, opts) => {
4559
+ const mode = selectLoginMode({
4560
+ isTTY: !!process.stdin.isTTY,
4561
+ headless: !!opts.headless,
4562
+ code: typeof opts.code === "string"
4563
+ });
4241
4564
  try {
4565
+ if (mode === "code") {
4566
+ await deliverLoginCode(opts.code);
4567
+ return;
4568
+ }
4569
+ if (mode === "headless") {
4570
+ await startHeadlessLogin(args);
4571
+ return;
4572
+ }
4573
+ (0, prompt_exports.intro)("Signing in to Claude...");
4242
4574
  const cfg = await loadEffectiveConfig(process.cwd());
4243
4575
  const image = cfg.effective.box.image;
4244
4576
  const s = (0, prompt_exports.spinner)();
@@ -4261,8 +4593,8 @@ claudeCommand.addCommand(claudeLoginCommand);
4261
4593
 
4262
4594
  // src/commands/codex.ts
4263
4595
  import { access } from "fs/promises";
4264
- import { homedir as homedir9 } from "os";
4265
- import { join as join12 } from "path";
4596
+ import { homedir as homedir10 } from "os";
4597
+ import { join as join13 } from "path";
4266
4598
  import { Command as Command4 } from "commander";
4267
4599
  function pickCodexCreateOpts(opts) {
4268
4600
  return {
@@ -4344,7 +4676,10 @@ async function maybeRunCodexLogin(args) {
4344
4676
  s.start("preparing sandbox image");
4345
4677
  await ensureImage(args.image, { onProgress: (line) => s.message(clampSpinnerLine(line)) });
4346
4678
  s.message("preparing codex config");
4347
- await ensureCodexVolume({ volume: SHARED_CODEX_VOLUME }, { syncFromHost: true, image: args.image });
4679
+ await ensureCodexVolume(
4680
+ { volume: SHARED_CODEX_VOLUME },
4681
+ { syncFromHost: true, image: args.image }
4682
+ );
4348
4683
  s.stop("image ready");
4349
4684
  const exitCode = await runCodexLoginContainer(args.image, []);
4350
4685
  if (exitCode !== 0) {
@@ -4355,7 +4690,7 @@ async function maybeRunCodexLogin(args) {
4355
4690
  }
4356
4691
  async function cloudCodexCredAvailable(env = process.env) {
4357
4692
  if ((env["OPENAI_API_KEY"] ?? "").length > 0) return true;
4358
- for (const p of [CODEX_CREDENTIALS_BACKUP_FILE, join12(homedir9(), ".codex", "auth.json")]) {
4693
+ for (const p of [CODEX_CREDENTIALS_BACKUP_FILE, join13(homedir10(), ".codex", "auth.json")]) {
4359
4694
  try {
4360
4695
  await access(p);
4361
4696
  return true;
@@ -4379,7 +4714,10 @@ async function maybeRunCloudCodexLogin(args) {
4379
4714
  s.start("preparing sandbox image");
4380
4715
  await ensureImage(args.image, { onProgress: (line) => s.message(clampSpinnerLine(line)) });
4381
4716
  s.message("preparing codex config");
4382
- await ensureCodexVolume({ volume: SHARED_CODEX_VOLUME }, { syncFromHost: true, image: args.image });
4717
+ await ensureCodexVolume(
4718
+ { volume: SHARED_CODEX_VOLUME },
4719
+ { syncFromHost: true, image: args.image }
4720
+ );
4383
4721
  s.stop("image ready");
4384
4722
  const exitCode = await runCodexLoginContainer(args.image, []);
4385
4723
  if (exitCode !== 0) {
@@ -4388,9 +4726,15 @@ async function maybeRunCloudCodexLogin(args) {
4388
4726
  }
4389
4727
  const { copied } = await extractCodexCredentials(SHARED_CODEX_VOLUME, args.image);
4390
4728
  if (copied) prompt_exports.log.success("Signed in to Codex \u2014 saved for future boxes.");
4391
- else prompt_exports.log.warn("Codex login finished but no auth.json was captured \u2014 sign in inside the box if needed.");
4729
+ else
4730
+ prompt_exports.log.warn(
4731
+ "Codex login finished but no auth.json was captured \u2014 sign in inside the box if needed."
4732
+ );
4392
4733
  }
4393
- var codexCommand = new Command4("codex").description("Create a sandboxed box and launch OpenAI Codex in a detachable tmux session").option("-w, --workspace <path>", "host workspace to mount", process.cwd()).option("-n, --name <name>", "friendly box name (default: <workspace-basename>-<id>)").option("--host-snapshot", "APFS-clone the host workspace into a per-box scratch dir before seeding /workspace (stabilizes the tar-pipe source)").option("--no-host-snapshot", "tar-pipe directly from the live host workspace at create time").option(
4734
+ var codexCommand = new Command4("codex").description("Create a sandboxed box and launch OpenAI Codex in a detachable tmux session").option("-w, --workspace <path>", "host workspace to mount", process.cwd()).option("-n, --name <name>", "friendly box name (default: <workspace-basename>-<id>)").option(
4735
+ "--host-snapshot",
4736
+ "APFS-clone the host workspace into a per-box scratch dir before seeding /workspace (stabilizes the tar-pipe source)"
4737
+ ).option("--no-host-snapshot", "tar-pipe directly from the live host workspace at create time").option(
4394
4738
  "--snapshot <ref>",
4395
4739
  "start from a project checkpoint (see `agentbox checkpoint`); overrides box.defaultCheckpoint"
4396
4740
  ).option("--image <ref>", "override the box image").option("-y, --yes", "skip prompts, accept defaults").option(
@@ -4421,10 +4765,7 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
4421
4765
  ).option(
4422
4766
  "--portless",
4423
4767
  "map the box web app to https://<name>.localhost via the Portless proxy (Docker Desktop)"
4424
- ).option("--no-portless", "do not register a Portless alias for this box").option("--session-name <name>", "tmux session name (default from config; built-in: codex)").option("--memory <size>", "memory ceiling (e.g. 512m, 2g); unset = unlimited").option("--cpus <n>", "CPU count cap (fractional ok, e.g. 1.5); unset = unlimited").option("--pids-limit <n>", "max process count (PIDs cgroup); unset = unlimited").option("--disk <size>", "best-effort writable-layer size (e.g. 10g); no-op on overlay2/macOS").option(
4425
- "--provider <name>",
4426
- "sandbox backend: 'docker' (default) or 'daytona' for a cloud box"
4427
- ).option(
4768
+ ).option("--no-portless", "do not register a Portless alias for this box").option("--session-name <name>", "tmux session name (default from config; built-in: codex)").option("--memory <size>", "memory ceiling (e.g. 512m, 2g); unset = unlimited").option("--cpus <n>", "CPU count cap (fractional ok, e.g. 1.5); unset = unlimited").option("--pids-limit <n>", "max process count (PIDs cgroup); unset = unlimited").option("--disk <size>", "best-effort writable-layer size (e.g. 10g); no-op on overlay2/macOS").option("--provider <name>", "sandbox backend: 'docker' (default) or 'daytona' for a cloud box").option(
4428
4769
  "--from-branch <ref>",
4429
4770
  "base the box's per-box branch on this ref (branch / tag / SHA) instead of HEAD. Branch/tag names are fetched from origin first."
4430
4771
  ).option(
@@ -4497,7 +4838,8 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
4497
4838
  try {
4498
4839
  await assertAgentCredsAvailable({
4499
4840
  agent: "codex",
4500
- image: cfg.effective.box.image
4841
+ image: cfg.effective.box.image,
4842
+ providerName
4501
4843
  });
4502
4844
  } catch (err) {
4503
4845
  if (err instanceof MissingAgentCredsError) {
@@ -4589,11 +4931,15 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
4589
4931
  limits: resolveLimits(cfg.effective.box, opts),
4590
4932
  fromBranch,
4591
4933
  useBranch,
4592
- projectRoot
4934
+ resyncOnStart: opts.resync,
4935
+ projectRoot,
4936
+ // Per-provider session-lifetime (e2b/vercel timeout); mirrors create.
4937
+ providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective)
4593
4938
  },
4594
4939
  binary: "codex",
4595
4940
  sessionName: cfg.effective.codex.sessionName,
4596
4941
  mode: "codex",
4942
+ hasSeedPrompt: Boolean(resumePrepared),
4597
4943
  extraArgs: applyCodexSkipPermissions(codexArgs, cfg.effective),
4598
4944
  verbose: opts.verbose === true,
4599
4945
  openIn: hostAwareOpenIn(cfg),
@@ -4815,6 +5161,15 @@ async function startOrAttachCodex(box, codexArgs, opts, resumePrepared) {
4815
5161
  onProgress: (line) => s.message(clampSpinnerLine(line))
4816
5162
  });
4817
5163
  let effectiveArgs = applyCodexSkipPermissions(codexArgs, cfg.effective);
5164
+ let attachResumed = false;
5165
+ if (opts.attachResume && codexArgs.length === 0 && !resumePrepared) {
5166
+ const provider = await providerForBox(box);
5167
+ const resume = await agentResumeArgs(provider, box, "codex");
5168
+ if (resume) {
5169
+ effectiveArgs = [...effectiveArgs, ...resume];
5170
+ attachResumed = true;
5171
+ }
5172
+ }
4818
5173
  if (resumePrepared) {
4819
5174
  s.message("uploading codex session into box");
4820
5175
  try {
@@ -4835,13 +5190,13 @@ async function startOrAttachCodex(box, codexArgs, opts, resumePrepared) {
4835
5190
  throw err;
4836
5191
  }
4837
5192
  }
4838
- if (resyncWarning && !resumePrepared) {
5193
+ if (resyncWarning && !resumePrepared && !attachResumed) {
4839
5194
  effectiveArgs = buildPromptArgs("codex", resyncWarning, effectiveArgs);
4840
5195
  }
4841
5196
  s.message("starting codex session");
4842
5197
  await startCodexSession({ container: box.container, codexArgs: effectiveArgs, sessionName });
4843
5198
  s.stop(`box ${box.container} ready`);
4844
- if (resyncWarning && resumePrepared) prompt_exports.log.warn(resyncWarning);
5199
+ if (resyncWarning && (resumePrepared || attachResumed)) prompt_exports.log.warn(resyncWarning);
4845
5200
  if (!wantAttach) {
4846
5201
  (0, prompt_exports.outro)(
4847
5202
  `session "${sessionName}" started \u2014 attach with: agentbox codex attach ${reattachRef(box)}`
@@ -4875,7 +5230,7 @@ var codexAttachCommand = new Command4("attach").description(
4875
5230
  });
4876
5231
  return;
4877
5232
  }
4878
- await startOrAttachCodex(box, [], { ...opts, syncConfig: false });
5233
+ await startOrAttachCodex(box, [], { ...opts, syncConfig: false, attachResume: true });
4879
5234
  } catch (err) {
4880
5235
  if (err instanceof CodexSessionError) {
4881
5236
  prompt_exports.log.error(err.message);
@@ -4895,10 +5250,7 @@ var codexStartCommand = new Command4("start").description(
4895
5250
  ).option("--attach-in <mode>", ATTACH_IN_HELP).option("-i, --inline", INLINE_HELP).option("-d, --no-attach", NO_ATTACH_HELP).option(
4896
5251
  "-c, --continue",
4897
5252
  "teleport the most recent host Codex session for this cwd into the box and resume"
4898
- ).option(
4899
- "--resume <id>",
4900
- "teleport the specified host Codex session uuid into the box and resume"
4901
- ).argument(
5253
+ ).option("--resume <id>", "teleport the specified host Codex session uuid into the box and resume").argument(
4902
5254
  "[codex-args...]",
4903
5255
  "extra args passed to codex when starting a new session; ignored if a session is already running. Place after `--`, e.g. `agentbox codex start 1 -- -m gpt-5.4`"
4904
5256
  ).action(async function(idOrName, codexArgs) {
@@ -5013,8 +5365,8 @@ codexCommand.addCommand(codexLoginCommand);
5013
5365
 
5014
5366
  // src/commands/opencode.ts
5015
5367
  import { access as access2 } from "fs/promises";
5016
- import { homedir as homedir10 } from "os";
5017
- import { join as join13 } from "path";
5368
+ import { homedir as homedir11 } from "os";
5369
+ import { join as join14 } from "path";
5018
5370
  import { Command as Command5 } from "commander";
5019
5371
  function pickOpencodeCreateOpts(opts) {
5020
5372
  return {
@@ -5109,7 +5461,7 @@ async function cloudOpencodeCredAvailable(env = process.env) {
5109
5461
  for (const k of OPENCODE_FORWARDED_ENV_KEYS) {
5110
5462
  if ((env[k] ?? "").length > 0) return true;
5111
5463
  }
5112
- for (const p of [OPENCODE_CREDENTIALS_BACKUP_FILE, join13(homedir10(), ".local", "share", "opencode", "auth.json")]) {
5464
+ for (const p of [OPENCODE_CREDENTIALS_BACKUP_FILE, join14(homedir11(), ".local", "share", "opencode", "auth.json")]) {
5113
5465
  try {
5114
5466
  await access2(p);
5115
5467
  return true;
@@ -5233,7 +5585,8 @@ var opencodeCommand = new Command5("opencode").description("Create a sandboxed b
5233
5585
  try {
5234
5586
  await assertAgentCredsAvailable({
5235
5587
  agent: "opencode",
5236
- image: cfg.effective.box.image
5588
+ image: cfg.effective.box.image,
5589
+ providerName
5237
5590
  });
5238
5591
  } catch (err) {
5239
5592
  if (err instanceof MissingAgentCredsError) {
@@ -5325,11 +5678,17 @@ var opencodeCommand = new Command5("opencode").description("Create a sandboxed b
5325
5678
  limits: resolveLimits(cfg.effective.box, opts),
5326
5679
  fromBranch,
5327
5680
  useBranch,
5328
- projectRoot
5681
+ resyncOnStart: opts.resync,
5682
+ projectRoot,
5683
+ // Per-provider session-lifetime (e2b/vercel timeout); mirrors create.
5684
+ providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective)
5329
5685
  },
5330
5686
  binary: "opencode",
5331
5687
  sessionName: cfg.effective.opencode.sessionName,
5332
5688
  mode: "opencode",
5689
+ // opencode surfaces the resync warning on stderr (matches its docker
5690
+ // path, which never injects it as an opening turn).
5691
+ hasSeedPrompt: true,
5333
5692
  extraArgs: opencodeArgs,
5334
5693
  verbose: opts.verbose === true,
5335
5694
  openIn: hostAwareOpenIn(cfg),
@@ -5759,7 +6118,7 @@ var attachCommand = new Command6("attach").description(
5759
6118
  const isCloud = (box.provider ?? "docker") !== "docker";
5760
6119
  const sessions = isCloud ? await probeCloudAgentSessions(box, opts.sessionName) : await probeDockerAgentSessions(box.container, opts.sessionName);
5761
6120
  if (sessions.length === 0) {
5762
- log13.warn(`no agent session running in ${box.name}`);
6121
+ log14.warn(`no agent session running in ${box.name}`);
5763
6122
  process.exit(1);
5764
6123
  }
5765
6124
  const winner = await pickSession(box.name, sessions);
@@ -5795,13 +6154,13 @@ var CLOUD_BACKENDS = ["daytona", "hetzner", "vercel", "e2b"];
5795
6154
  async function cloudProviderFor(backend) {
5796
6155
  switch (backend) {
5797
6156
  case "daytona":
5798
- return (await import("./dist-7BS2JS27.js")).daytonaProvider;
6157
+ return (await import("./dist-CZ6CRADC.js")).daytonaProvider;
5799
6158
  case "hetzner":
5800
- return (await import("./dist-4BHW7DCO.js")).hetznerProvider;
6159
+ return (await import("./dist-C3YRC3PP.js")).hetznerProvider;
5801
6160
  case "vercel":
5802
- return (await import("./dist-T7ESSBCZ.js")).vercelProvider;
6161
+ return (await import("./dist-3WFNXXPE.js")).vercelProvider;
5803
6162
  case "e2b":
5804
- return (await import("./dist-3UYQZOAO.js")).e2bProvider;
6163
+ return (await import("./dist-7ELDXBAG.js")).e2bProvider;
5805
6164
  }
5806
6165
  }
5807
6166
  var CHECKPOINT_NOTICE = "Checkpoint in progress \u2014 the box will be unresponsive for a moment";
@@ -6164,16 +6523,16 @@ async function runCloudCheckpointCreate(box, opts) {
6164
6523
  var checkpointCommand = new Command7("checkpoint").alias("checkpoints").description("List and manage project checkpoints (warm box state new boxes can start from)").addCommand(createSub).addCommand(lsSub, { isDefault: true }).addCommand(setDefaultSub).addCommand(rmSub);
6165
6524
 
6166
6525
  // src/commands/code.ts
6167
- import { spawn } from "child_process";
6168
- import { log as log15 } from "@clack/prompts";
6526
+ import { spawn as spawn2 } from "child_process";
6527
+ import { log as log16 } from "@clack/prompts";
6169
6528
  import { Command as Command8, InvalidArgumentError } from "commander";
6170
6529
 
6171
6530
  // src/ssh-config.ts
6172
6531
  import { promises as fs } from "fs";
6173
- import { homedir as homedir11 } from "os";
6174
- import { join as join14 } from "path";
6532
+ import { homedir as homedir12 } from "os";
6533
+ import { join as join15 } from "path";
6175
6534
  function sshConfigPath() {
6176
- return join14(homedir11(), ".ssh", "config");
6535
+ return join15(homedir12(), ".ssh", "config");
6177
6536
  }
6178
6537
  function beginMarker(alias) {
6179
6538
  return `# BEGIN agentbox cloud box ${alias}`;
@@ -6224,7 +6583,7 @@ function buildBlock(opts) {
6224
6583
  }
6225
6584
  async function writeAgentboxSshAlias(opts) {
6226
6585
  const path = sshConfigPath();
6227
- await fs.mkdir(join14(homedir11(), ".ssh"), { recursive: true, mode: 448 });
6586
+ await fs.mkdir(join15(homedir12(), ".ssh"), { recursive: true, mode: 448 });
6228
6587
  const existing = await readConfig();
6229
6588
  const stripped = stripBlock(existing, opts.alias);
6230
6589
  const separator = stripped.length === 0 || stripped.endsWith("\n") ? "" : "\n";
@@ -6306,11 +6665,11 @@ var codeCommand = new Command8("code").description("Open a box in VS Code or Cur
6306
6665
  }
6307
6666
  const exit = await launchIde(folderUri, forcedIde);
6308
6667
  if (exit.code !== 0) {
6309
- log15.error(`failed to launch ${exit.flavor ? ideProfile(exit.flavor).displayName : "IDE"} via ${exit.via} (exit ${String(exit.code)})`);
6668
+ log16.error(`failed to launch ${exit.flavor ? ideProfile(exit.flavor).displayName : "IDE"} via ${exit.via} (exit ${String(exit.code)})`);
6310
6669
  process.stdout.write(folderUri + "\n");
6311
6670
  process.exit(1);
6312
6671
  }
6313
- log15.success(
6672
+ log16.success(
6314
6673
  `opening ${box.name} in ${ideProfile(exit.flavor).displayName} (${exit.via})`
6315
6674
  );
6316
6675
  } catch (err) {
@@ -6320,10 +6679,10 @@ var codeCommand = new Command8("code").description("Open a box in VS Code or Cur
6320
6679
  async function prepareDockerAttach(box, opts) {
6321
6680
  const insp = await inspectBox(box.id);
6322
6681
  if (insp.state === "paused") {
6323
- log15.info(`box is paused; unpausing`);
6682
+ log16.info(`box is paused; unpausing`);
6324
6683
  await unpauseBox(box.id);
6325
6684
  } else if (insp.state === "stopped") {
6326
- log15.info(`box is stopped; starting`);
6685
+ log16.info(`box is stopped; starting`);
6327
6686
  await startBox(box.id);
6328
6687
  } else if (insp.state === "missing") {
6329
6688
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -6334,9 +6693,9 @@ async function prepareDockerAttach(box, opts) {
6334
6693
  const lines = [];
6335
6694
  if (reply.timedOut.length > 0) lines.push(`timed out: ${reply.timedOut.join(", ")}`);
6336
6695
  if (reply.failed.length > 0) lines.push(`failed: ${reply.failed.join(", ")}`);
6337
- log15.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6696
+ log16.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6338
6697
  } else {
6339
- log15.success("all units ready");
6698
+ log16.success("all units ready");
6340
6699
  }
6341
6700
  }
6342
6701
  if (opts.autoTerminals) {
@@ -6346,14 +6705,14 @@ async function prepareDockerAttach(box, opts) {
6346
6705
  regen: opts.regenTasks
6347
6706
  });
6348
6707
  if (r.status === "wrote") {
6349
- log15.info(`wrote /workspace/.vscode/tasks.json (${String(services.length)} service(s))`);
6708
+ log16.info(`wrote /workspace/.vscode/tasks.json (${String(services.length)} service(s))`);
6350
6709
  } else if (r.status === "skipped-user-owned") {
6351
- log15.warn(
6710
+ log16.warn(
6352
6711
  "user-owned .vscode/tasks.json detected; skipping auto-terminals (pass --regen-tasks to overwrite)"
6353
6712
  );
6354
6713
  }
6355
6714
  } catch (err) {
6356
- log15.warn(
6715
+ log16.warn(
6357
6716
  `auto-terminals failed: ${err instanceof Error ? err.message : String(err)}`
6358
6717
  );
6359
6718
  }
@@ -6365,10 +6724,10 @@ async function prepareCloudAttach(box, opts) {
6365
6724
  const p = await providerForBox(box);
6366
6725
  const state = await p.probeState(box);
6367
6726
  if (state === "paused") {
6368
- log15.info("box is paused; resuming");
6727
+ log16.info("box is paused; resuming");
6369
6728
  await p.resume(box);
6370
6729
  } else if (state === "stopped") {
6371
- log15.info("box is stopped; starting");
6730
+ log16.info("box is stopped; starting");
6372
6731
  await p.start(box);
6373
6732
  } else if (state === "missing") {
6374
6733
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -6381,12 +6740,12 @@ async function prepareCloudAttach(box, opts) {
6381
6740
  const lines = [];
6382
6741
  if (reply.timedOut.length > 0) lines.push(`timed out: ${reply.timedOut.join(", ")}`);
6383
6742
  if (reply.failed.length > 0) lines.push(`failed: ${reply.failed.join(", ")}`);
6384
- log15.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6743
+ log16.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
6385
6744
  } else {
6386
- log15.success("all units ready");
6745
+ log16.success("all units ready");
6387
6746
  }
6388
6747
  } catch (err) {
6389
- log15.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
6748
+ log16.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
6390
6749
  }
6391
6750
  }
6392
6751
  if (!p.buildAttach) {
@@ -6408,7 +6767,7 @@ async function prepareCloudAttach(box, opts) {
6408
6767
  user: target.user,
6409
6768
  identityFile: target.identityFile
6410
6769
  });
6411
- log15.info(`updated ~/.ssh/config alias ${alias}`);
6770
+ log16.info(`updated ~/.ssh/config alias ${alias}`);
6412
6771
  return `vscode-remote://ssh-remote+${alias}/workspace`;
6413
6772
  }
6414
6773
  async function runWaitReadyDocker(container, timeoutMs) {
@@ -6433,7 +6792,7 @@ async function launchIde(folderUri, forced) {
6433
6792
  if (code !== null) return code;
6434
6793
  const cursor = await tryCli("cursor", folderUri);
6435
6794
  if (cursor !== null) return cursor;
6436
- log15.warn("neither `code` nor `cursor` found in PATH; falling back to `open vscode://...`");
6795
+ log16.warn("neither `code` nor `cursor` found in PATH; falling back to `open vscode://...`");
6437
6796
  return launchOne("vscode", folderUri);
6438
6797
  }
6439
6798
  async function tryCli(flavor, folderUri) {
@@ -6446,7 +6805,7 @@ async function launchOne(flavor, folderUri) {
6446
6805
  const profile = ideProfile(flavor);
6447
6806
  const cliCode = await spawnCommand(profile.cli, ["--folder-uri", folderUri]);
6448
6807
  if (cliCode !== 127) return { code: cliCode, flavor, via: "cli" };
6449
- log15.warn(
6808
+ log16.warn(
6450
6809
  `\`${profile.cli}\` not found in PATH; falling back to \`${hostOpenCommand()} ${profile.protocolScheme}://...\` (the %2B URL-encoding bug may break attach)`
6451
6810
  );
6452
6811
  const url = `${profile.protocolScheme}://${folderUri.replace(/^vscode-remote:\/\//, "vscode-remote/")}`;
@@ -6455,7 +6814,7 @@ async function launchOne(flavor, folderUri) {
6455
6814
  }
6456
6815
  function spawnCommand(cmd, args) {
6457
6816
  return new Promise((resolve5) => {
6458
- const child = spawn(cmd, args, { stdio: "ignore" });
6817
+ const child = spawn2(cmd, args, { stdio: "ignore" });
6459
6818
  child.once("error", () => resolve5(127));
6460
6819
  child.once("exit", (code) => resolve5(code ?? -1));
6461
6820
  });
@@ -6750,7 +7109,7 @@ var configCommand = new Command9("config").description("Read / write layered con
6750
7109
 
6751
7110
  // src/commands/cp.ts
6752
7111
  import { resolve as resolve3 } from "path";
6753
- import { log as log16 } from "@clack/prompts";
7112
+ import { log as log17 } from "@clack/prompts";
6754
7113
  import { Command as Command10 } from "commander";
6755
7114
  function collectExclude(val, acc) {
6756
7115
  acc.push(val);
@@ -6886,10 +7245,10 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
6886
7245
  }
6887
7246
  const insp = await inspectBox(box.id);
6888
7247
  if (insp.state === "paused") {
6889
- log16.info("box is paused; unpausing");
7248
+ log17.info("box is paused; unpausing");
6890
7249
  await unpauseBox(box.id);
6891
7250
  } else if (insp.state === "stopped") {
6892
- log16.info("box is stopped; starting");
7251
+ log17.info("box is stopped; starting");
6893
7252
  await startBox(box.id);
6894
7253
  } else if (insp.state === "missing") {
6895
7254
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -6897,7 +7256,7 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
6897
7256
  if (parsed.direction === "upload") {
6898
7257
  const result = await uploadToBox(box, parsed.hostPath, parsed.boxPath, tarPatterns);
6899
7258
  if (result.warn) {
6900
- log16.warn(`copied to ${box.name}:${result.finalPath}, but ${result.warn}`);
7259
+ log17.warn(`copied to ${box.name}:${result.finalPath}, but ${result.warn}`);
6901
7260
  } else {
6902
7261
  process.stdout.write(`copied to ${box.name}:${result.finalPath}
6903
7262
  `);
@@ -6918,7 +7277,7 @@ var cpCommand = new Command10("cp").description("Copy files between host and box
6918
7277
  });
6919
7278
 
6920
7279
  // src/commands/create.ts
6921
- import { intro as intro6, log as log17, outro as outro5 } from "@clack/prompts";
7280
+ import { intro as intro6, log as log18, outro as outro5 } from "@clack/prompts";
6922
7281
  import { Command as Command11 } from "commander";
6923
7282
  import { execSync, spawnSync as spawnSync2 } from "child_process";
6924
7283
  function buildCliOverrides(opts) {
@@ -7066,13 +7425,13 @@ var createCommand = new Command11("create").description(
7066
7425
  onLog: (line) => cmdLog.write(line)
7067
7426
  });
7068
7427
  if (gate.decision === "cancel") {
7069
- log17.warn("carry: cancelled \u2014 not creating the box");
7428
+ log18.warn("carry: cancelled \u2014 not creating the box");
7070
7429
  cmdLog.close();
7071
7430
  process.exit(0);
7072
7431
  }
7073
7432
  if (gate.decision === "approve") carryEntries = gate.entries;
7074
7433
  } catch (err) {
7075
- log17.error(err instanceof Error ? err.message : String(err));
7434
+ log18.error(err instanceof Error ? err.message : String(err));
7076
7435
  cmdLog.close();
7077
7436
  process.exit(1);
7078
7437
  }
@@ -7088,11 +7447,10 @@ var createCommand = new Command11("create").description(
7088
7447
  baseStatus
7089
7448
  });
7090
7449
  if (wiz.rebuildBase) {
7091
- log17.warn(`${providerName} base image is outdated; rebuilding before create\u2026`);
7450
+ log18.warn(`${providerName} base image is outdated; rebuilding before create\u2026`);
7092
7451
  await runPrepare(providerName, {
7093
7452
  force: true,
7094
7453
  cwd: opts.workspace,
7095
- suppressTip: true,
7096
7454
  suppressStatus: true
7097
7455
  });
7098
7456
  }
@@ -7135,7 +7493,7 @@ var createCommand = new Command11("create").description(
7135
7493
  } catch (err) {
7136
7494
  if (err instanceof FromBranchError || err instanceof UseBranchError) {
7137
7495
  s.stop("aborting: invalid branch selection");
7138
- log17.error(err.message);
7496
+ log18.error(err.message);
7139
7497
  cmdLog.close();
7140
7498
  process.exit(2);
7141
7499
  }
@@ -7169,29 +7527,26 @@ var createCommand = new Command11("create").description(
7169
7527
  portless: portlessEnabled,
7170
7528
  portlessStateDir: cfg.effective.portless.stateDir || void 0,
7171
7529
  ...effectiveSize ? { size: effectiveSize } : {},
7172
- // Vercel-only sizing (box.vercelVcpus / vercelTimeoutMs). The cloud
7173
- // scaffold reads these as overrides; other providers ignore them.
7174
- ...provider.name === "vercel" ? {
7175
- vcpus: cfg.effective.box.vercelVcpus,
7176
- timeoutMs: cfg.effective.box.vercelTimeoutMs,
7177
- networkPolicy: cfg.effective.box.vercelNetworkPolicy
7178
- } : {}
7530
+ // Per-provider sizing / session-lifetime overrides (vercel vcpus /
7531
+ // timeout / network policy, e2b timeout). The cloud scaffold reads
7532
+ // them; other providers ignore them.
7533
+ ...cloudSizingProviderOptions(provider.name, cfg.effective)
7179
7534
  }
7180
7535
  });
7181
7536
  s.stop(`box ${result.record.container} ready`);
7182
7537
  const createResyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
7183
- if (createResyncWarning) log17.warn(createResyncWarning);
7184
- log17.info(`id: ${result.record.id}`);
7538
+ if (createResyncWarning) log18.warn(createResyncWarning);
7539
+ log18.info(`id: ${result.record.id}`);
7185
7540
  if (typeof result.record.projectIndex === "number") {
7186
- log17.info(`n: ${String(result.record.projectIndex)} (in ${projectRoot})`);
7541
+ log18.info(`n: ${String(result.record.projectIndex)} (in ${projectRoot})`);
7187
7542
  }
7188
- log17.info(`container: ${result.record.container}`);
7189
- log17.info(`image: ${result.record.image}${result.imageBuilt ? " (built just now)" : ""}`);
7543
+ log18.info(`container: ${result.record.container}`);
7544
+ log18.info(`image: ${result.record.image}${result.imageBuilt ? " (built just now)" : ""}`);
7190
7545
  if (result.record.snapshotDir) {
7191
- log17.info(`snapshot: ${result.record.snapshotDir}`);
7546
+ log18.info(`snapshot: ${result.record.snapshotDir}`);
7192
7547
  }
7193
7548
  if (result.record.checkpointSource) {
7194
- log17.info(
7549
+ log18.info(
7195
7550
  `checkpoint: ${result.record.checkpointSource.ref} (${result.record.checkpointSource.type}) \u2192 ${result.record.checkpointImage ?? "(missing)"}`
7196
7551
  );
7197
7552
  }
@@ -7203,7 +7558,7 @@ var createCommand = new Command11("create").description(
7203
7558
  ` agentbox claude attach ${result.record.name}`,
7204
7559
  ` agentbox url ${result.record.name}`
7205
7560
  ];
7206
- log17.message(
7561
+ log18.message(
7207
7562
  [
7208
7563
  "",
7209
7564
  "Try it:",
@@ -7222,7 +7577,7 @@ var createCommand = new Command11("create").description(
7222
7577
  const protectedPaths = boxes.map((b) => b.projectRoot).filter((p) => typeof p === "string");
7223
7578
  const res = await pruneOrphanProjectConfigs({ protectedPaths });
7224
7579
  if (res.removed.length > 0) {
7225
- log17.info(
7580
+ log18.info(
7226
7581
  `cleaned ${String(res.removed.length)} orphan project config dir(s): ` + res.removed.map((r) => r.originalPath).join(", ")
7227
7582
  );
7228
7583
  }
@@ -7232,7 +7587,7 @@ var createCommand = new Command11("create").description(
7232
7587
  }
7233
7588
  outro5("done");
7234
7589
  if (attachClaudeAfter) {
7235
- const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-3UC3IL62.js");
7590
+ const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-THTN4CFZ.js");
7236
7591
  await cloudAgentAttach2({
7237
7592
  box: result.record,
7238
7593
  binary: "claude",
@@ -7248,14 +7603,14 @@ var createCommand = new Command11("create").description(
7248
7603
  s.stop("failed");
7249
7604
  const msg = err instanceof Error ? err.message : String(err);
7250
7605
  cmdLog.write(`FAIL: ${err instanceof Error ? err.stack ?? err.message : String(err)}`);
7251
- log17.error(msg);
7606
+ log18.error(msg);
7252
7607
  try {
7253
7608
  const running = execSync('docker ps --format "{{.Names}}"', {
7254
7609
  stdio: ["ignore", "pipe", "ignore"]
7255
7610
  }).toString().split("\n").filter((n) => n.startsWith("agentbox-"));
7256
7611
  if (running.length > 0) {
7257
- log17.warn(`leftover containers: ${running.join(", ")}`);
7258
- log17.warn(`remove with: docker rm -f ${running.join(" ")}`);
7612
+ log18.warn(`leftover containers: ${running.join(", ")}`);
7613
+ log18.warn(`remove with: docker rm -f ${running.join(" ")}`);
7259
7614
  }
7260
7615
  } catch {
7261
7616
  }
@@ -7267,8 +7622,8 @@ var createCommand = new Command11("create").description(
7267
7622
  });
7268
7623
 
7269
7624
  // src/commands/dashboard.ts
7270
- import { spawn as spawn2 } from "child_process";
7271
- import { log as log18 } from "@clack/prompts";
7625
+ import { spawn as spawn3 } from "child_process";
7626
+ import { log as log19 } from "@clack/prompts";
7272
7627
  import { Command as Command12 } from "commander";
7273
7628
 
7274
7629
  // src/dashboard/layout.ts
@@ -7610,7 +7965,7 @@ var PtySession = class {
7610
7965
  // Reused per cell read — valid only until the next cell() call (the renderer
7611
7966
  // consumes it synchronously within composeRow).
7612
7967
  out = { ...BLANK };
7613
- constructor(spawn5, TerminalClass, boxId, keepAlive, mode, command, args, cols, rows, onRenderable, onExit, cleanup) {
7968
+ constructor(spawn6, TerminalClass, boxId, keepAlive, mode, command, args, cols, rows, onRenderable, onExit, cleanup, env) {
7614
7969
  this.boxId = boxId;
7615
7970
  this.keepAlive = keepAlive;
7616
7971
  this.mode = mode;
@@ -7622,11 +7977,14 @@ var PtySession = class {
7622
7977
  convertEol: false
7623
7978
  });
7624
7979
  this.cleanup = cleanup;
7625
- this.pty = spawn5(command, args, {
7980
+ this.pty = spawn6(command, args, {
7626
7981
  name: "xterm-256color",
7627
7982
  cols,
7628
7983
  rows,
7629
- env: process.env
7984
+ // Merge provider-supplied env over the host env. e2b's attach helper
7985
+ // reads the inner tmux command + API key from here (passed via env, not
7986
+ // argv); without the merge the helper exits before attaching.
7987
+ env: env ? { ...process.env, ...env } : process.env
7630
7988
  });
7631
7989
  this.pty.onData((d) => {
7632
7990
  this.term.write(d, () => {
@@ -8120,7 +8478,8 @@ var Compositor = class {
8120
8478
  Math.max(1, this.layout.right.h),
8121
8479
  () => this.scheduleRender(),
8122
8480
  (id) => this.onSessionExit(id),
8123
- target.cleanup
8481
+ target.cleanup,
8482
+ target.env
8124
8483
  );
8125
8484
  if (keepAlive) {
8126
8485
  const prev = this.liveSessions.get(boxId);
@@ -8791,7 +9150,7 @@ function toSidebar(b) {
8791
9150
  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) => {
8792
9151
  try {
8793
9152
  if (!process.stdout.isTTY || !process.stdin.isTTY) {
8794
- log18.error("agentbox dashboard needs an interactive terminal");
9153
+ log19.error("agentbox dashboard needs an interactive terminal");
8795
9154
  process.exit(2);
8796
9155
  }
8797
9156
  const backend = await loadPtyBackend();
@@ -8801,10 +9160,10 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
8801
9160
  ptySpawn = backend.ptySpawn;
8802
9161
  termCtor = backend.termCtor;
8803
9162
  } else {
8804
- log18.error(
9163
+ log19.error(
8805
9164
  "agentbox dashboard is unavailable here (native terminal backend failed to load)"
8806
9165
  );
8807
- log18.info("use `agentbox claude` / `agentbox attach` instead");
9166
+ log19.info("use `agentbox claude` / `agentbox attach` instead");
8808
9167
  process.exit(2);
8809
9168
  }
8810
9169
  const project = await findProjectRoot(process.cwd());
@@ -8907,6 +9266,7 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
8907
9266
  kind: "attach",
8908
9267
  command: spec.argv[0],
8909
9268
  args: spec.argv.slice(1),
9269
+ ...spec.env ? { env: spec.env } : {},
8910
9270
  ...spec.cleanup ? { cleanup: spec.cleanup } : {},
8911
9271
  mode: which,
8912
9272
  ...providerSupportsKeepAlive(record.provider) ? { keepAlive: true } : {}
@@ -8916,12 +9276,7 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
8916
9276
  const probeCloudSessions = async (record) => {
8917
9277
  try {
8918
9278
  const provider = await providerForBox(record);
8919
- const r = await provider.exec(record, [
8920
- "tmux",
8921
- "list-sessions",
8922
- "-F",
8923
- "#{session_name}"
8924
- ]);
9279
+ const r = await provider.exec(record, ["tmux", "list-sessions", "-F", "#{session_name}"]);
8925
9280
  if (r.exitCode !== 0) return /* @__PURE__ */ new Set();
8926
9281
  return new Set(
8927
9282
  r.stdout.split("\n").map((s) => s.trim()).filter((s) => s.length > 0)
@@ -9086,7 +9441,7 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9086
9441
  };
9087
9442
  };
9088
9443
  const detach = (cmd, args) => {
9089
- spawn2(cmd, args, { detached: true, stdio: "ignore" }).unref();
9444
+ spawn3(cmd, args, { detached: true, stdio: "ignore" }).unref();
9090
9445
  };
9091
9446
  const findEndpointUrl = async (boxId, kind) => {
9092
9447
  const box = (await listBoxes()).find((b) => b.id === boxId);
@@ -9140,14 +9495,20 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9140
9495
  const box = (await listBoxes()).find((b) => b.id === boxId);
9141
9496
  if (!box) throw new Error("box not found");
9142
9497
  if (isCloudBox(box)) {
9143
- const record = await loadBoxRecord(boxId);
9144
- const provider = await providerForBox(record);
9145
- if (box.state === "paused") await provider.resume(record);
9146
- else await provider.start(record);
9498
+ const record2 = await loadBoxRecord(boxId);
9499
+ const provider = await providerForBox(record2);
9500
+ if (box.state === "paused") await provider.resume(record2);
9501
+ else await provider.start(record2);
9502
+ await restoreAgentSessions(record2, provider);
9503
+ return;
9504
+ }
9505
+ if (box.state === "paused") {
9506
+ await unpauseBox(box.id);
9147
9507
  return;
9148
9508
  }
9149
- if (box.state === "paused") await unpauseBox(box.id);
9150
- else await startBox(box.id);
9509
+ await startBox(box.id);
9510
+ const record = await loadBoxRecord(boxId);
9511
+ await restoreAgentSessions(record, await providerForBox(record));
9151
9512
  };
9152
9513
  const pauseBoxAction = async (boxId) => {
9153
9514
  const record = await loadBoxRecord(boxId);
@@ -9209,11 +9570,11 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9209
9570
  });
9210
9571
 
9211
9572
  // ../../packages/sandbox-daytona/dist/cli.js
9212
- import { log as log19, spinner as spinner7 } from "@clack/prompts";
9573
+ import { log as log20, spinner as spinner7 } from "@clack/prompts";
9213
9574
  import { Command as Command13 } from "commander";
9214
9575
  function reportError(err) {
9215
9576
  const message = err instanceof Error ? err.message : String(err);
9216
- log19.error(message);
9577
+ log20.error(message);
9217
9578
  process.exitCode = 1;
9218
9579
  }
9219
9580
  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) => {
@@ -9231,7 +9592,7 @@ var loginSub = new Command13("login").description("Set up (or rotate) Daytona cr
9231
9592
  }
9232
9593
  await ensureDaytonaCredentials({ force: true });
9233
9594
  if (readPreparedDaytonaState()?.base === void 0) {
9234
- log19.info(
9595
+ log20.info(
9235
9596
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider daytona` (or `agentbox install`) to bake it."
9236
9597
  );
9237
9598
  }
@@ -9277,7 +9638,7 @@ var resyncSub = new Command13("resync").description(
9277
9638
  const sb = spinner7();
9278
9639
  sb.start(`provisioning throwaway sandbox to refresh: ${agents.join(", ")}`);
9279
9640
  const ensured = await ensureAgentVolumesForCloud(daytonaBackend, {
9280
- onLog: (line) => log19.info(line)
9641
+ onLog: (line) => log20.info(line)
9281
9642
  });
9282
9643
  if (ensured.agents.length === 0) {
9283
9644
  sb.stop("no agent volumes available \u2014 the daytona backend has no volume primitive");
@@ -9317,7 +9678,7 @@ var resyncSub = new Command13("resync").description(
9317
9678
  }
9318
9679
  sb3.stop("throwaway sandbox destroyed");
9319
9680
  }
9320
- log19.success(
9681
+ log20.success(
9321
9682
  `Daytona agent volumes refreshed: ${agents.join(", ")}. Next \`agentbox create --provider daytona\` will use the updated credentials.`
9322
9683
  );
9323
9684
  } catch (err) {
@@ -9337,11 +9698,11 @@ var dockerCommand = new Command14("docker").description(
9337
9698
  });
9338
9699
 
9339
9700
  // ../../packages/sandbox-hetzner/dist/cli.js
9340
- import { log as log20 } from "@clack/prompts";
9701
+ import { log as log21 } from "@clack/prompts";
9341
9702
  import { Command as Command15 } from "commander";
9342
9703
  function reportError2(err) {
9343
9704
  const message = err instanceof Error ? err.message : String(err);
9344
- log20.error(message);
9705
+ log21.error(message);
9345
9706
  process.exitCode = 1;
9346
9707
  }
9347
9708
  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) => {
@@ -9359,7 +9720,7 @@ var loginSub2 = new Command15("login").description("Set up (or rotate) Hetzner C
9359
9720
  }
9360
9721
  await ensureHetznerCredentials({ force: true });
9361
9722
  if (readPreparedState().base === void 0) {
9362
- log20.info(
9723
+ log21.info(
9363
9724
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider hetzner` (or `agentbox install`) to bake it."
9364
9725
  );
9365
9726
  }
@@ -9490,11 +9851,11 @@ var hetznerCommand = new Command15("hetzner").description(
9490
9851
  ).addCommand(loginSub2, { isDefault: true }).addCommand(firewallSub);
9491
9852
 
9492
9853
  // ../../packages/sandbox-vercel/dist/cli.js
9493
- import { log as log21 } from "@clack/prompts";
9854
+ import { log as log22 } from "@clack/prompts";
9494
9855
  import { Command as Command16 } from "commander";
9495
9856
  function reportError3(err) {
9496
9857
  const message = err instanceof Error ? err.message : String(err);
9497
- log21.error(message);
9858
+ log22.error(message);
9498
9859
  process.exitCode = 1;
9499
9860
  }
9500
9861
  function relativeExpiry(expiresAt) {
@@ -9557,7 +9918,7 @@ var loginSub3 = new Command16("login").description("Set up (or rotate) Vercel cr
9557
9918
  }
9558
9919
  await ensureVercelCredentials({ force: true });
9559
9920
  if (readPreparedState2().base === void 0) {
9560
- log21.info(
9921
+ log22.info(
9561
9922
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider vercel` (or `agentbox install`) to bake it."
9562
9923
  );
9563
9924
  }
@@ -9570,11 +9931,11 @@ var vercelCommand = new Command16("vercel").description(
9570
9931
  ).addCommand(loginSub3, { isDefault: true });
9571
9932
 
9572
9933
  // ../../packages/sandbox-e2b/dist/cli.js
9573
- import { log as log22 } from "@clack/prompts";
9934
+ import { log as log23 } from "@clack/prompts";
9574
9935
  import { Command as Command17 } from "commander";
9575
9936
  function reportError4(err) {
9576
9937
  const message = err instanceof Error ? err.message : String(err);
9577
- log22.error(message);
9938
+ log23.error(message);
9578
9939
  process.exitCode = 1;
9579
9940
  }
9580
9941
  function printStatus4() {
@@ -9606,7 +9967,7 @@ var loginSub4 = new Command17("login").description("Set up (or rotate) E2B crede
9606
9967
  }
9607
9968
  await ensureE2bCredentials({ force: true });
9608
9969
  if (readPreparedState3().base === void 0) {
9609
- log22.info(
9970
+ log23.info(
9610
9971
  "Base template not built yet \u2014 run `agentbox prepare --provider e2b` (or `agentbox install`) to bake it."
9611
9972
  );
9612
9973
  }
@@ -10160,7 +10521,7 @@ downloadCommand.addCommand(downloadOpencodeCommand);
10160
10521
  downloadCommand.addCommand(downloadConfigCommand);
10161
10522
 
10162
10523
  // src/commands/drive.ts
10163
- import { log as log30 } from "@clack/prompts";
10524
+ import { log as log31 } from "@clack/prompts";
10164
10525
  import { Command as Command25 } from "commander";
10165
10526
 
10166
10527
  // src/lib/drive/keys.ts
@@ -10304,7 +10665,7 @@ var drivePromptCommand = new Command25("prompt").description('Type text into the
10304
10665
  const session = await resolveDriveSession(provider, box, opts.session);
10305
10666
  const delay = opts.delay !== void 0 ? parsePositiveInt2(opts.delay, "--delay") : PROMPT_ENTER_DELAY_MS;
10306
10667
  await sendLiteral(provider, box, session.name, text2);
10307
- if (delay > 0) await sleep3(delay);
10668
+ if (delay > 0) await sleep4(delay);
10308
10669
  await sendKey(provider, box, session.name, "Enter");
10309
10670
  } catch (err) {
10310
10671
  handleDriveError(err);
@@ -10330,7 +10691,7 @@ var driveWaitCommand = new Command25("wait").description("Block until --text app
10330
10691
  }
10331
10692
  return;
10332
10693
  }
10333
- await sleep3(POLL_INTERVAL_MS2);
10694
+ await sleep4(POLL_INTERVAL_MS2);
10334
10695
  }
10335
10696
  const elapsedMs = Date.now() - start;
10336
10697
  if (opts.json === true) {
@@ -10343,7 +10704,7 @@ var driveWaitCommand = new Command25("wait").description("Block until --text app
10343
10704
  }) + "\n"
10344
10705
  );
10345
10706
  } else {
10346
- log30.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
10707
+ log31.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
10347
10708
  }
10348
10709
  process.exit(1);
10349
10710
  } catch (err) {
@@ -10370,8 +10731,8 @@ driveCommand.addCommand(driveWaitCommand);
10370
10731
  driveCommand.addCommand(driveResizeCommand);
10371
10732
  function handleDriveError(err) {
10372
10733
  if (err instanceof SessionNotFoundError) {
10373
- log30.error(err.message);
10374
- log30.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
10734
+ log31.error(err.message);
10735
+ log31.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
10375
10736
  process.exit(2);
10376
10737
  }
10377
10738
  handleLifecycleError(err);
@@ -10390,17 +10751,37 @@ function parsePositiveInt2(raw, label) {
10390
10751
  }
10391
10752
  return n;
10392
10753
  }
10393
- function sleep3(ms) {
10754
+ function sleep4(ms) {
10394
10755
  return new Promise((r) => setTimeout(r, ms));
10395
10756
  }
10396
10757
 
10397
10758
  // src/commands/fork.ts
10398
- import { log as log31 } from "@clack/prompts";
10759
+ import { log as log32 } from "@clack/prompts";
10399
10760
  import { Command as Command26 } from "commander";
10400
- import { existsSync as existsSync5, readdirSync, statSync } from "fs";
10401
- import { homedir as homedir12 } from "os";
10402
- import { join as join15 } from "path";
10761
+ import { existsSync as existsSync6, readdirSync as readdirSync2, statSync } from "fs";
10762
+ import { homedir as homedir13 } from "os";
10763
+ import { join as join16 } from "path";
10403
10764
  var FORK_AGENTS = ["claude", "codex", "opencode"];
10765
+ var FORK_PROVIDERS = ["docker", "daytona", "hetzner", "vercel", "e2b"];
10766
+ function resolveForkProvider(positional, flag) {
10767
+ const pos = positional?.trim();
10768
+ const fl = flag?.trim();
10769
+ if (pos && fl && pos !== fl) {
10770
+ throw new Error(`provider given twice: "${pos}" (positional) and --provider "${fl}" \u2014 pass it once.`);
10771
+ }
10772
+ const provider = fl || pos;
10773
+ if (provider && !FORK_PROVIDERS.includes(provider)) {
10774
+ throw new Error(`provider: expected one of ${FORK_PROVIDERS.join(", ")}, got "${provider}"`);
10775
+ }
10776
+ return provider || void 0;
10777
+ }
10778
+ function detectAgentFromEnv(env = process.env) {
10779
+ if (env.CLAUDECODE === "1" || (env.CLAUDE_CODE_SESSION_ID ?? "").trim().length > 0) {
10780
+ return "claude";
10781
+ }
10782
+ if ((env.CODEX_THREAD_ID ?? "").trim().length > 0) return "codex";
10783
+ return void 0;
10784
+ }
10404
10785
  var AGENT_COMMAND = {
10405
10786
  claude: claudeCommand,
10406
10787
  codex: codexCommand,
@@ -10419,12 +10800,12 @@ function resolveSessionArgs(agent, opts) {
10419
10800
  }
10420
10801
  if (opts.session) return ["--resume", opts.session];
10421
10802
  if (agent === "codex") return ["--continue"];
10422
- const dir = join15(homedir12(), ".claude", "projects", encodeClaudeProjectsDir(opts.workspace));
10423
- if (!existsSync5(dir)) return ["--continue"];
10803
+ const dir = join16(homedir13(), ".claude", "projects", encodeClaudeProjectsDir(opts.workspace));
10804
+ if (!existsSync6(dir)) return ["--continue"];
10424
10805
  const now = Date.now();
10425
- const recent = readdirSync(dir).filter((f) => f.endsWith(".jsonl")).map((f) => {
10806
+ const recent = readdirSync2(dir).filter((f) => f.endsWith(".jsonl")).map((f) => {
10426
10807
  try {
10427
- return statSync(join15(dir, f)).mtimeMs;
10808
+ return statSync(join16(dir, f)).mtimeMs;
10428
10809
  } catch {
10429
10810
  return 0;
10430
10811
  }
@@ -10449,16 +10830,19 @@ function resolveAttachArgs(attachIn) {
10449
10830
  return detectHostTerminal() === "unknown" ? ["--no-attach"] : ["--attach-in", attachIn];
10450
10831
  }
10451
10832
  var forkCommand = new Command26("fork").description(
10452
- "Fork the current host agent session into a new box and resume it there. Opens the box in a new terminal tab under iTerm/tmux; otherwise starts it in the background."
10833
+ "Fork the current host agent session into a new box and resume it there. Autodetects the agent (Claude / Codex) and the current session from the launching agent's env, so a bare `agentbox fork` forks whatever you ran it from. Opens the box in a new terminal tab under iTerm/tmux; otherwise starts it in the background."
10834
+ ).argument(
10835
+ "[provider]",
10836
+ "sandbox backend as a positional shorthand for --provider (e.g. `agentbox fork hetzner`): 'docker' (default), 'daytona', 'hetzner', 'vercel', or 'e2b'"
10453
10837
  ).option("-w, --workspace <path>", "host workspace to mount", process.cwd()).option(
10454
10838
  "--agent <name>",
10455
- "which agent to fork: claude (default), codex, or opencode. OpenCode starts a fresh box (session resume not supported yet)."
10839
+ "which agent to fork: claude, codex, or opencode. Autodetected from env (CLAUDECODE / CODEX_THREAD_ID) when omitted, defaulting to claude. OpenCode starts a fresh box (session resume not supported yet)."
10456
10840
  ).option(
10457
10841
  "--session <id>",
10458
- "host agent session id to resume (default: the newest session for this cwd; claude refuses if several were used recently). Ignored for --agent opencode."
10842
+ "host agent session id to resume. Autodetected from the launching agent's env (CLAUDE_CODE_SESSION_ID / CODEX_THREAD_ID) when omitted; else the newest session for this cwd (claude refuses if several were used recently). Ignored for --agent opencode."
10459
10843
  ).option(
10460
10844
  "--provider <name>",
10461
- "sandbox backend: 'docker' (default), 'daytona', 'hetzner', 'vercel', or 'e2b'"
10845
+ "sandbox backend: 'docker' (default), 'daytona', 'hetzner', 'vercel', or 'e2b'. Can also be passed positionally: `agentbox fork hetzner`."
10462
10846
  ).option("-n, --name <name>", "box name (default: fork-<HHMMSS>)").option(
10463
10847
  "--attach-in <mode>",
10464
10848
  "where to open the forked session: window | tab | split | background | same (default: tab). Falls back to background outside tmux/iTerm."
@@ -10469,39 +10853,62 @@ var forkCommand = new Command26("fork").description(
10469
10853
  ).option(
10470
10854
  "--plan <path>",
10471
10855
  '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.'
10472
- ).action(async (opts) => {
10856
+ ).action(async (providerArg, opts) => {
10473
10857
  if ((process.env.AGENTBOX_RELAY_URL ?? "").trim().length > 0) {
10474
- log31.error(
10858
+ log32.error(
10475
10859
  "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."
10476
10860
  );
10477
10861
  process.exit(2);
10478
10862
  }
10479
- const agent = opts.agent?.trim() || "claude";
10863
+ const agent = opts.agent?.trim() || detectAgentFromEnv() || "claude";
10480
10864
  if (!FORK_AGENTS.includes(agent)) {
10481
- log31.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
10865
+ log32.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
10482
10866
  process.exit(2);
10483
10867
  }
10484
10868
  const attachIn = opts.attachIn ?? "tab";
10485
10869
  if (!FORK_ATTACH_VALUES.includes(attachIn)) {
10486
- log31.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
10870
+ log32.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
10487
10871
  process.exit(2);
10488
10872
  }
10489
10873
  const plan = opts.plan?.trim();
10490
10874
  if (plan && agent !== "claude") {
10491
- log31.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
10875
+ log32.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
10492
10876
  process.exit(2);
10493
10877
  }
10494
10878
  const carryMode = opts.carry ?? "send";
10495
10879
  if (carryMode !== "send" && carryMode !== "skip") {
10496
- log31.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
10880
+ log32.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
10497
10881
  process.exit(2);
10498
10882
  }
10499
- const provider = opts.provider?.trim();
10883
+ let provider;
10884
+ try {
10885
+ provider = resolveForkProvider(providerArg, opts.provider);
10886
+ } catch (err) {
10887
+ log32.error(err instanceof Error ? err.message : String(err));
10888
+ process.exit(2);
10889
+ }
10890
+ if (!opts.session?.trim()) {
10891
+ if (agent === "claude") {
10892
+ const envId = (process.env.CLAUDE_CODE_SESSION_ID ?? process.env.CLAUDE_SESSION_ID ?? "").trim();
10893
+ if (envId) {
10894
+ const dir = join16(
10895
+ homedir13(),
10896
+ ".claude",
10897
+ "projects",
10898
+ encodeClaudeProjectsDir(opts.workspace)
10899
+ );
10900
+ if (existsSync6(join16(dir, `${envId}.jsonl`))) opts.session = envId;
10901
+ }
10902
+ } else if (agent === "codex") {
10903
+ const envId = (process.env.CODEX_THREAD_ID ?? "").trim();
10904
+ if (envId) opts.session = envId;
10905
+ }
10906
+ }
10500
10907
  let sessionArgs;
10501
10908
  try {
10502
10909
  sessionArgs = resolveSessionArgs(agent, opts);
10503
10910
  } catch (err) {
10504
- log31.error(err instanceof Error ? err.message : String(err));
10911
+ log32.error(err instanceof Error ? err.message : String(err));
10505
10912
  process.exit(2);
10506
10913
  }
10507
10914
  const subArgv = [
@@ -10524,23 +10931,24 @@ var forkCommand = new Command26("fork").description(
10524
10931
 
10525
10932
  // src/commands/install.ts
10526
10933
  import { Command as Command29 } from "commander";
10934
+ import { execa as execa5 } from "execa";
10527
10935
  import {
10528
- existsSync as existsSync10,
10936
+ existsSync as existsSync11,
10529
10937
  lstatSync,
10530
- mkdirSync as mkdirSync8,
10531
- readFileSync as readFileSync4,
10532
- rmSync,
10938
+ mkdirSync as mkdirSync9,
10939
+ readFileSync as readFileSync5,
10940
+ rmSync as rmSync2,
10533
10941
  symlinkSync as symlinkSync2,
10534
- writeFileSync as writeFileSync7
10942
+ writeFileSync as writeFileSync8
10535
10943
  } from "fs";
10536
- import { homedir as homedir18 } from "os";
10537
- import { dirname as dirname5, join as join21, resolve as resolve4, sep } from "path";
10944
+ import { homedir as homedir19 } from "os";
10945
+ import { dirname as dirname5, join as join22, resolve as resolve4, sep } from "path";
10538
10946
  import { fileURLToPath } from "url";
10539
10947
 
10540
10948
  // src/lib/doctor-checks.ts
10541
- import { accessSync, constants as fsConstants, mkdirSync as mkdirSync3 } from "fs";
10542
- import { homedir as homedir13 } from "os";
10543
- import { join as join16 } from "path";
10949
+ import { accessSync, constants as fsConstants, mkdirSync as mkdirSync4 } from "fs";
10950
+ import { homedir as homedir14 } from "os";
10951
+ import { join as join17 } from "path";
10544
10952
  import { execa as execa4 } from "execa";
10545
10953
  var ALL_PROVIDERS = ["docker", "daytona", "hetzner", "vercel", "e2b"];
10546
10954
  var NODE_MIN_MAJOR = 20;
@@ -10588,9 +10996,9 @@ function checkPlatform() {
10588
10996
  };
10589
10997
  }
10590
10998
  function checkAgentboxHome() {
10591
- const dir = join16(homedir13(), ".agentbox");
10999
+ const dir = join17(homedir14(), ".agentbox");
10592
11000
  try {
10593
- mkdirSync3(dir, { recursive: true });
11001
+ mkdirSync4(dir, { recursive: true });
10594
11002
  accessSync(dir, fsConstants.W_OK);
10595
11003
  return { label: "~/.agentbox", status: "ok", detail: dir };
10596
11004
  } catch (err) {
@@ -10660,7 +11068,7 @@ async function dockerChecks() {
10660
11068
  ];
10661
11069
  }
10662
11070
  const daemonRes = { label: "docker daemon", status: "ok", detail: "reachable" };
10663
- const mod = await import("./dist-CFSKUAS5.js");
11071
+ const mod = await import("./dist-3PLT2EK2.js");
10664
11072
  let imgRes;
10665
11073
  try {
10666
11074
  const img = await mod.imageInfo(mod.DEFAULT_BOX_IMAGE);
@@ -10691,7 +11099,7 @@ async function dockerChecks() {
10691
11099
  }
10692
11100
  async function daytonaChecks() {
10693
11101
  try {
10694
- const mod = await import("./dist-7BS2JS27.js");
11102
+ const mod = await import("./dist-CZ6CRADC.js");
10695
11103
  const status = await mod.getDaytonaStatus();
10696
11104
  if (!status.configured) {
10697
11105
  return [
@@ -10727,7 +11135,7 @@ async function daytonaChecks() {
10727
11135
  }
10728
11136
  async function hetznerChecks() {
10729
11137
  try {
10730
- const mod = await import("./dist-4BHW7DCO.js");
11138
+ const mod = await import("./dist-C3YRC3PP.js");
10731
11139
  const cred = mod.readHetznerCredStatus();
10732
11140
  const credRes = cred.source === "none" ? {
10733
11141
  label: "credentials",
@@ -10759,7 +11167,7 @@ async function hetznerChecks() {
10759
11167
  }
10760
11168
  async function vercelChecks() {
10761
11169
  try {
10762
- const mod = await import("./dist-T7ESSBCZ.js");
11170
+ const mod = await import("./dist-3WFNXXPE.js");
10763
11171
  const cred = mod.readVercelCredStatus();
10764
11172
  const credRes = cred.auth === "none" ? {
10765
11173
  label: "credentials",
@@ -10795,7 +11203,7 @@ async function vercelChecks() {
10795
11203
  }
10796
11204
  async function e2bChecks() {
10797
11205
  try {
10798
- const mod = await import("./dist-3UYQZOAO.js");
11206
+ const mod = await import("./dist-7ELDXBAG.js");
10799
11207
  const cred = mod.readE2bCredStatus();
10800
11208
  const credRes = cred.auth === "none" ? {
10801
11209
  label: "credentials",
@@ -11030,44 +11438,44 @@ function formatDetailed(groups) {
11030
11438
  }
11031
11439
 
11032
11440
  // src/lib/first-run.ts
11033
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "fs";
11034
- import { homedir as homedir14 } from "os";
11035
- import { dirname, join as join17 } from "path";
11441
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, writeFileSync as writeFileSync4 } from "fs";
11442
+ import { homedir as homedir15 } from "os";
11443
+ import { dirname, join as join18 } from "path";
11036
11444
  var MARKER_VERSION = 1;
11037
11445
  function setupMarkerPath() {
11038
- return join17(homedir14(), ".agentbox", "setup-complete.json");
11446
+ return join18(homedir15(), ".agentbox", "setup-complete.json");
11039
11447
  }
11040
11448
  function isFirstRun() {
11041
- return !existsSync6(setupMarkerPath());
11449
+ return !existsSync7(setupMarkerPath());
11042
11450
  }
11043
11451
  function markSetupComplete(provider) {
11044
11452
  const path = setupMarkerPath();
11045
- mkdirSync4(dirname(path), { recursive: true });
11453
+ mkdirSync5(dirname(path), { recursive: true });
11046
11454
  const body = {
11047
11455
  version: MARKER_VERSION,
11048
11456
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
11049
11457
  provider
11050
11458
  };
11051
- writeFileSync3(path, JSON.stringify(body, null, 2) + "\n");
11459
+ writeFileSync4(path, JSON.stringify(body, null, 2) + "\n");
11052
11460
  }
11053
11461
 
11054
11462
  // src/lib/star-prompt.ts
11055
11463
  import { spawnSync as spawnSync3 } from "child_process";
11056
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync, writeFileSync as writeFileSync4 } from "fs";
11057
- import { homedir as homedir15 } from "os";
11058
- import { dirname as dirname2, join as join18 } from "path";
11464
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync2, writeFileSync as writeFileSync5 } from "fs";
11465
+ import { homedir as homedir16 } from "os";
11466
+ import { dirname as dirname2, join as join19 } from "path";
11059
11467
  var STATE_VERSION = 1;
11060
11468
  var REPO = "madarco/agentbox";
11061
11469
  var REPO_URL = `https://github.com/${REPO}`;
11062
11470
  var DEFAULT_STATE = { version: STATE_VERSION, installCount: 0, starred: false };
11063
11471
  function starStatePath() {
11064
- return join18(homedir15(), ".agentbox", "star-prompt.json");
11472
+ return join19(homedir16(), ".agentbox", "star-prompt.json");
11065
11473
  }
11066
11474
  function readStarState() {
11067
11475
  const path = starStatePath();
11068
- if (!existsSync7(path)) return { ...DEFAULT_STATE };
11476
+ if (!existsSync8(path)) return { ...DEFAULT_STATE };
11069
11477
  try {
11070
- const parsed = JSON.parse(readFileSync(path, "utf8"));
11478
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
11071
11479
  return {
11072
11480
  version: STATE_VERSION,
11073
11481
  installCount: typeof parsed.installCount === "number" ? parsed.installCount : 0,
@@ -11079,8 +11487,8 @@ function readStarState() {
11079
11487
  }
11080
11488
  function writeStarState(state) {
11081
11489
  const path = starStatePath();
11082
- mkdirSync5(dirname2(path), { recursive: true });
11083
- writeFileSync4(path, JSON.stringify(state, null, 2) + "\n");
11490
+ mkdirSync6(dirname2(path), { recursive: true });
11491
+ writeFileSync5(path, JSON.stringify(state, null, 2) + "\n");
11084
11492
  }
11085
11493
  function ghReady() {
11086
11494
  const r = spawnSync3("gh", ["auth", "status"], { stdio: "ignore" });
@@ -11126,16 +11534,16 @@ async function maybePromptStar(opts) {
11126
11534
  }
11127
11535
 
11128
11536
  // src/commands/install-cmux.ts
11129
- import { intro as intro7, log as log33, note as note2, outro as outro6 } from "@clack/prompts";
11537
+ import { intro as intro7, log as log34, note as note2, outro as outro6 } from "@clack/prompts";
11130
11538
  import { Command as Command27 } from "commander";
11131
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync5 } from "fs";
11132
- import { homedir as homedir16 } from "os";
11133
- import { dirname as dirname3, join as join19 } from "path";
11539
+ import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync3, renameSync as renameSync3, writeFileSync as writeFileSync6 } from "fs";
11540
+ import { homedir as homedir17 } from "os";
11541
+ import { dirname as dirname3, join as join20 } from "path";
11134
11542
  var CONTROL_ID = "agentbox";
11135
11543
  function cmuxDockPath(env = process.env) {
11136
11544
  const xdg = env["XDG_CONFIG_HOME"];
11137
- const base = xdg && xdg.length > 0 ? xdg : join19(homedir16(), ".config");
11138
- return join19(base, "cmux", "dock.json");
11545
+ const base = xdg && xdg.length > 0 ? xdg : join20(homedir17(), ".config");
11546
+ return join20(base, "cmux", "dock.json");
11139
11547
  }
11140
11548
  function upsertAgentboxControl(doc, opts) {
11141
11549
  const controls = Array.isArray(doc.controls) ? doc.controls : [];
@@ -11165,22 +11573,22 @@ var installCmuxCommand = new Command27("cmux").description(
11165
11573
  height: parseHeight(opts.height)
11166
11574
  };
11167
11575
  let doc = { controls: [] };
11168
- if (existsSync8(dockPath)) {
11169
- const raw = readFileSync2(dockPath, "utf8");
11576
+ if (existsSync9(dockPath)) {
11577
+ const raw = readFileSync3(dockPath, "utf8");
11170
11578
  try {
11171
11579
  const parsed = JSON.parse(raw);
11172
11580
  if (parsed && typeof parsed === "object") doc = parsed;
11173
11581
  } catch {
11174
11582
  if (!opts.force) {
11175
- log33.error(
11583
+ log34.error(
11176
11584
  `existing dock config is not valid JSON: ${dockPath}
11177
11585
  fix it by hand, or pass --force to back it up and write a fresh one`
11178
11586
  );
11179
11587
  process.exit(1);
11180
11588
  }
11181
11589
  if (!opts.dryRun) {
11182
- renameSync2(dockPath, dockPath + ".bak");
11183
- log33.warn(`backed up unparseable dock config to ${dockPath}.bak`);
11590
+ renameSync3(dockPath, dockPath + ".bak");
11591
+ log34.warn(`backed up unparseable dock config to ${dockPath}.bak`);
11184
11592
  }
11185
11593
  doc = { controls: [] };
11186
11594
  }
@@ -11193,8 +11601,8 @@ fix it by hand, or pass --force to back it up and write a fresh one`
11193
11601
  outro6(`would write ${dockPath}`);
11194
11602
  return;
11195
11603
  }
11196
- mkdirSync6(dirname3(dockPath), { recursive: true });
11197
- writeFileSync5(dockPath, json);
11604
+ mkdirSync7(dirname3(dockPath), { recursive: true });
11605
+ writeFileSync6(dockPath, json);
11198
11606
  intro7("AgentBox cmux dock panel");
11199
11607
  note2(
11200
11608
  `Wrote ${dockPath}
@@ -11209,23 +11617,23 @@ To see it:
11209
11617
  });
11210
11618
 
11211
11619
  // src/commands/install-herdr.ts
11212
- import { intro as intro8, log as log34, note as note3, outro as outro7 } from "@clack/prompts";
11620
+ import { intro as intro8, log as log35, note as note3, outro as outro7 } from "@clack/prompts";
11213
11621
  import { Command as Command28, Option } from "commander";
11214
11622
  import { spawnSync as spawnSync4 } from "child_process";
11215
- import { chmodSync, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync6 } from "fs";
11216
- import { homedir as homedir17 } from "os";
11217
- import { dirname as dirname4, join as join20 } from "path";
11218
- var PLUGIN_VERSION = "0.1.0";
11623
+ import { chmodSync, existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync4, writeFileSync as writeFileSync7 } from "fs";
11624
+ import { homedir as homedir18 } from "os";
11625
+ import { dirname as dirname4, join as join21 } from "path";
11626
+ var PLUGIN_VERSION = "0.2.0";
11219
11627
  function herdrPluginDir(env = process.env) {
11220
- const home = env["AGENTBOX_HOME"] ?? join20(homedir17(), ".agentbox");
11221
- return join20(home, "herdr", "plugin");
11628
+ const home = env["AGENTBOX_HOME"] ?? join21(homedir18(), ".agentbox");
11629
+ return join21(home, "herdr", "plugin");
11222
11630
  }
11223
11631
  function herdrConfigPath(env = process.env) {
11224
11632
  const override = env["HERDR_CONFIG_PATH"];
11225
11633
  if (override && override.length > 0) return override;
11226
11634
  const xdg = env["XDG_CONFIG_HOME"];
11227
- const base = xdg && xdg.length > 0 ? xdg : join20(homedir17(), ".config");
11228
- return join20(base, "herdr", "config.toml");
11635
+ const base = xdg && xdg.length > 0 ? xdg : join21(homedir18(), ".config");
11636
+ return join21(base, "herdr", "config.toml");
11229
11637
  }
11230
11638
  function herdrBinary(env = process.env) {
11231
11639
  const b = env["HERDR_BIN_PATH"];
@@ -11233,7 +11641,7 @@ function herdrBinary(env = process.env) {
11233
11641
  }
11234
11642
  function buildHerdrManifest() {
11235
11643
  return `# AgentBox Herdr plugin (https://herdr.dev/docs/plugins).
11236
- # Install: herdr plugin install madarco/agentbox/herdr-plugin
11644
+ # Install: herdr plugin install madarco/agentbox
11237
11645
  # Or, with the AgentBox CLI already installed: agentbox install herdr
11238
11646
  #
11239
11647
  # agentbox commands route through ./agentbox-shim.sh, written at install time
@@ -11341,15 +11749,15 @@ function escapeRe(s) {
11341
11749
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11342
11750
  }
11343
11751
  function writeShim(dir) {
11344
- const p = join20(dir, "agentbox-shim.sh");
11345
- writeFileSync6(p, herdrShimContent(process.execPath, process.argv[1] ?? "agentbox"));
11752
+ const p = join21(dir, "agentbox-shim.sh");
11753
+ writeFileSync7(p, herdrShimContent(process.execPath, process.argv[1] ?? "agentbox"));
11346
11754
  chmodSync(p, 493);
11347
11755
  }
11348
11756
  function applyKeybindings() {
11349
11757
  const cfg = herdrConfigPath();
11350
- const existing = existsSync9(cfg) ? readFileSync3(cfg, "utf8") : "";
11351
- mkdirSync7(dirname4(cfg), { recursive: true });
11352
- writeFileSync6(cfg, upsertHerdrKeybindings(existing, herdrKeybindingsBlock()));
11758
+ const existing = existsSync10(cfg) ? readFileSync4(cfg, "utf8") : "";
11759
+ mkdirSync8(dirname4(cfg), { recursive: true });
11760
+ writeFileSync7(cfg, upsertHerdrKeybindings(existing, herdrKeybindingsBlock()));
11353
11761
  spawnSync4(herdrBinary(), ["server", "reload-config"], { stdio: "ignore" });
11354
11762
  return cfg;
11355
11763
  }
@@ -11366,18 +11774,18 @@ var installHerdrCommand = new Command28("herdr").description(
11366
11774
  return;
11367
11775
  }
11368
11776
  const dir = herdrPluginDir();
11369
- const file = join20(dir, "herdr-plugin.toml");
11777
+ const file = join21(dir, "herdr-plugin.toml");
11370
11778
  const cfgPath = herdrConfigPath();
11371
11779
  if (opts.dryRun) {
11372
11780
  intro8("agentbox install herdr (dry run)");
11373
11781
  process.stdout.write(`# --- ${file} ---
11374
11782
  ${buildHerdrManifest()}
11375
11783
  `);
11376
- process.stdout.write(`# --- ${join20(dir, "build.sh")} ---
11784
+ process.stdout.write(`# --- ${join21(dir, "build.sh")} ---
11377
11785
  ${herdrBuildScript()}
11378
11786
  `);
11379
11787
  process.stdout.write(
11380
- `# --- ${join20(dir, "agentbox-shim.sh")} ---
11788
+ `# --- ${join21(dir, "agentbox-shim.sh")} ---
11381
11789
  ${herdrShimContent(process.execPath, process.argv[1] ?? "agentbox")}
11382
11790
  `
11383
11791
  );
@@ -11387,10 +11795,10 @@ ${herdrKeybindingsBlock()}
11387
11795
  outro7(`would write ${dir}/*, edit ${cfgPath}, and run \`herdr plugin link ${dir}\``);
11388
11796
  return;
11389
11797
  }
11390
- mkdirSync7(dir, { recursive: true });
11391
- writeFileSync6(file, buildHerdrManifest());
11392
- const buildPath = join20(dir, "build.sh");
11393
- writeFileSync6(buildPath, herdrBuildScript());
11798
+ mkdirSync8(dir, { recursive: true });
11799
+ writeFileSync7(file, buildHerdrManifest());
11800
+ const buildPath = join21(dir, "build.sh");
11801
+ writeFileSync7(buildPath, herdrBuildScript());
11394
11802
  chmodSync(buildPath, 493);
11395
11803
  writeShim(dir);
11396
11804
  const cfg = applyKeybindings();
@@ -11404,7 +11812,7 @@ ${herdrKeybindingsBlock()}
11404
11812
  if (linked.status === 0) {
11405
11813
  spawnSync4(bin, ["server", "reload-config"], { stdio: "ignore" });
11406
11814
  } else {
11407
- log34.warn(
11815
+ log35.warn(
11408
11816
  `could not run \`${bin} plugin link\` (is Herdr installed / running?).
11409
11817
  Run it yourself: herdr plugin link ${dir} && herdr server reload-config`
11410
11818
  );
@@ -11438,7 +11846,7 @@ var SYNC_END2 = "\x1B[?2026l";
11438
11846
  var HIDE_CURSOR = "\x1B[?25l";
11439
11847
  var SHOW_CURSOR = "\x1B[?25h";
11440
11848
  var SPIN = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
11441
- var sleep4 = (ms) => new Promise((r) => setTimeout(r, ms));
11849
+ var sleep5 = (ms) => new Promise((r) => setTimeout(r, ms));
11442
11850
  function shineColor(dist) {
11443
11851
  const d = Math.abs(dist);
11444
11852
  if (d === 0) return 231;
@@ -11488,34 +11896,33 @@ ${HIDE_CURSOR}`);
11488
11896
  statusLine2(spin) + "\x1B[3A\r" + // back up to the logo's first row
11489
11897
  SYNC_END2;
11490
11898
  process.stdout.write(frame);
11491
- await sleep4(frameMs);
11899
+ await sleep5(frameMs);
11492
11900
  }
11493
11901
  process.stdout.write(SYNC_BEGIN2 + `\x1B[38;5;39m${LOGO_L1}
11494
11902
  ${LOGO_L2}\x1B[0m` + SYNC_END2);
11495
- await sleep4(250);
11903
+ await sleep5(250);
11496
11904
  process.stdout.write(SYNC_BEGIN2 + "\n\x1B[2K\n\x1B[2K" + SHOW_CURSOR + SYNC_END2);
11497
11905
  process.removeListener("exit", restoreCursor);
11498
11906
  process.removeListener("SIGINT", onSigint);
11499
11907
  }
11500
11908
  var LEGACY_INFO_MARKER = "Drive AgentBox from the host:";
11501
11909
  function installTargets() {
11502
- const home = homedir18();
11503
- const claudeSkills = join21(home, ".claude", "skills");
11910
+ const home = homedir19();
11911
+ const claudeSkills = join22(home, ".claude", "skills");
11504
11912
  return [
11505
- { src: join21("agentbox", "SKILL.md"), dest: join21(claudeSkills, "agentbox", "SKILL.md") },
11506
11913
  {
11507
- src: join21("agentbox-info", "SKILL.md"),
11508
- dest: join21(claudeSkills, "agentbox-info", "SKILL.md")
11914
+ src: join22("agentbox-info", "SKILL.md"),
11915
+ dest: join22(claudeSkills, "agentbox-info", "SKILL.md")
11509
11916
  },
11510
11917
  {
11511
- src: join21("codex", "agentbox.md"),
11512
- dest: join21(home, ".codex", "prompts", "agentbox.md"),
11513
- gateDir: join21(home, ".codex")
11918
+ src: join22("codex", "agentbox.md"),
11919
+ dest: join22(home, ".codex", "prompts", "agentbox.md"),
11920
+ gateDir: join22(home, ".codex")
11514
11921
  },
11515
11922
  {
11516
- src: join21("opencode", "agentbox.md"),
11517
- dest: join21(home, ".config", "opencode", "commands", "agentbox.md"),
11518
- gateDir: join21(home, ".config", "opencode")
11923
+ src: join22("opencode", "agentbox.md"),
11924
+ dest: join22(home, ".config", "opencode", "commands", "agentbox.md"),
11925
+ gateDir: join22(home, ".config", "opencode")
11519
11926
  }
11520
11927
  ];
11521
11928
  }
@@ -11526,7 +11933,7 @@ function resolveHostSkillsDir() {
11526
11933
  resolve4(here, "..", "..", "share", "host-skills")
11527
11934
  ];
11528
11935
  for (const c of candidates) {
11529
- if (existsSync10(c)) return c;
11936
+ if (existsSync11(c)) return c;
11530
11937
  }
11531
11938
  throw new Error(`could not locate bundled host skills; tried:
11532
11939
  ${candidates.join("\n ")}`);
@@ -11542,11 +11949,11 @@ function isSourceCheckout(srcDir) {
11542
11949
  return !srcDir.split(sep).includes("node_modules");
11543
11950
  }
11544
11951
  function writableReason(target, force) {
11545
- if (!existsSync10(target)) {
11952
+ if (!existsSync11(target)) {
11546
11953
  if (isSymlink(target)) return "managed";
11547
11954
  return "new";
11548
11955
  }
11549
- const existing = readFileSync4(target, "utf8");
11956
+ const existing = readFileSync5(target, "utf8");
11550
11957
  if (existing.includes(MANAGED_SENTINEL) || existing.includes(LEGACY_INFO_MARKER)) {
11551
11958
  return "managed";
11552
11959
  }
@@ -11562,13 +11969,13 @@ function installHostSkills(opts = {}) {
11562
11969
  const blocked = [];
11563
11970
  let skipped = 0;
11564
11971
  for (const t of installTargets()) {
11565
- const src = join21(srcDir, t.src);
11566
- if (!existsSync10(src)) {
11972
+ const src = join22(srcDir, t.src);
11973
+ if (!existsSync11(src)) {
11567
11974
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
11568
11975
  skipped++;
11569
11976
  continue;
11570
11977
  }
11571
- if (t.gateDir && !existsSync10(t.gateDir)) continue;
11978
+ if (t.gateDir && !existsSync11(t.gateDir)) continue;
11572
11979
  const reason = writableReason(t.dest, force);
11573
11980
  if (reason === "skip") {
11574
11981
  if (!quiet) prompt_exports.log.warn(`user-modified file at ${t.dest}, skipping; pass --force to overwrite`);
@@ -11581,18 +11988,77 @@ function installHostSkills(opts = {}) {
11581
11988
  written.push(t.dest);
11582
11989
  continue;
11583
11990
  }
11584
- mkdirSync8(dirname5(t.dest), { recursive: true });
11991
+ mkdirSync9(dirname5(t.dest), { recursive: true });
11585
11992
  if (link) {
11586
- rmSync(t.dest, { force: true });
11993
+ rmSync2(t.dest, { force: true });
11587
11994
  symlinkSync2(resolve4(srcDir, t.src), t.dest);
11588
11995
  } else {
11589
- if (isSymlink(t.dest)) rmSync(t.dest, { force: true });
11590
- writeFileSync7(t.dest, readFileSync4(src, "utf8"));
11996
+ if (isSymlink(t.dest)) rmSync2(t.dest, { force: true });
11997
+ writeFileSync8(t.dest, readFileSync5(src, "utf8"));
11591
11998
  }
11592
11999
  written.push(t.dest);
11593
12000
  }
11594
12001
  return { written, skipped, blocked };
11595
12002
  }
12003
+ var FORK_SKILL_REPO = "https://github.com/madarco/agentbox";
12004
+ async function installForkSkill(opts = {}) {
12005
+ const force = opts.force === true;
12006
+ const dryRun = opts.dryRun === true;
12007
+ const quiet = opts.quiet === true;
12008
+ 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)) {
12012
+ if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
12013
+ return { written: [], skipped: 1, blocked: [], method: "skip" };
12014
+ }
12015
+ const reason = writableReason(dest, force);
12016
+ if (reason === "skip") {
12017
+ if (!quiet) prompt_exports.log.warn(`user-modified file at ${dest}, skipping; pass --force to overwrite`);
12018
+ return { written: [], skipped: 1, blocked: [dest], method: "skip" };
12019
+ }
12020
+ if (dryRun) {
12021
+ const via = isSourceCheckout(srcDir) ? "link" : "npx skills add";
12022
+ if (!quiet) prompt_exports.log.info(`would install ${dest} via ${via} (${reason})`);
12023
+ return { written: [dest], skipped: 0, blocked: [], method: "dry-run" };
12024
+ }
12025
+ if (isSourceCheckout(srcDir)) {
12026
+ mkdirSync9(dirname5(dest), { recursive: true });
12027
+ rmSync2(dest, { force: true });
12028
+ symlinkSync2(src, dest);
12029
+ return { written: [dest], skipped: 0, blocked: [], method: "symlink" };
12030
+ }
12031
+ try {
12032
+ await execa5(
12033
+ "npx",
12034
+ [
12035
+ "-y",
12036
+ "skills",
12037
+ "add",
12038
+ FORK_SKILL_REPO,
12039
+ "--skill",
12040
+ "agentbox",
12041
+ "-a",
12042
+ "claude-code",
12043
+ "-g",
12044
+ "-y",
12045
+ "--copy"
12046
+ ],
12047
+ { timeout: 12e4 }
12048
+ );
12049
+ if (existsSync11(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
12050
+ throw new Error("`skills add` reported success but wrote no skill file");
12051
+ } catch (err) {
12052
+ if (!quiet) {
12053
+ const msg = err instanceof Error ? err.message : String(err);
12054
+ prompt_exports.log.warn(`\`npx skills add\` failed (${msg}); copying the bundled fork skill instead`);
12055
+ }
12056
+ mkdirSync9(dirname5(dest), { recursive: true });
12057
+ if (isSymlink(dest)) rmSync2(dest, { force: true });
12058
+ writeFileSync8(dest, readFileSync5(src, "utf8"));
12059
+ return { written: [dest], skipped: 0, blocked: [], method: "copy" };
12060
+ }
12061
+ }
11596
12062
  var PROVIDER_HINTS = {
11597
12063
  docker: "builds a ~1GB local image; no login needed",
11598
12064
  hetzner: "paste an API token from the Hetzner Console",
@@ -11617,7 +12083,7 @@ function ensureTty() {
11617
12083
  async function runProviderLogin(name) {
11618
12084
  if (name === "docker") return true;
11619
12085
  if (name === "daytona") {
11620
- const mod2 = await import("./dist-7BS2JS27.js");
12086
+ const mod2 = await import("./dist-CZ6CRADC.js");
11621
12087
  const status2 = await mod2.getDaytonaStatus();
11622
12088
  if (status2.configured) {
11623
12089
  prompt_exports.log.info("daytona: already configured");
@@ -11629,7 +12095,7 @@ async function runProviderLogin(name) {
11629
12095
  return true;
11630
12096
  }
11631
12097
  if (name === "hetzner") {
11632
- const mod2 = await import("./dist-4BHW7DCO.js");
12098
+ const mod2 = await import("./dist-C3YRC3PP.js");
11633
12099
  const status2 = mod2.readHetznerCredStatus();
11634
12100
  if (status2.source !== "none") {
11635
12101
  prompt_exports.log.info("hetzner: already configured");
@@ -11641,7 +12107,7 @@ async function runProviderLogin(name) {
11641
12107
  return true;
11642
12108
  }
11643
12109
  if (name === "vercel") {
11644
- const mod2 = await import("./dist-T7ESSBCZ.js");
12110
+ const mod2 = await import("./dist-3WFNXXPE.js");
11645
12111
  const status2 = mod2.readVercelCredStatus();
11646
12112
  if (status2.auth !== "none") {
11647
12113
  prompt_exports.log.info(`vercel: already configured (${status2.auth})`);
@@ -11652,7 +12118,7 @@ async function runProviderLogin(name) {
11652
12118
  await mod2.ensureVercelCredentials();
11653
12119
  return true;
11654
12120
  }
11655
- const mod = await import("./dist-3UYQZOAO.js");
12121
+ const mod = await import("./dist-7ELDXBAG.js");
11656
12122
  const status = mod.readE2bCredStatus();
11657
12123
  if (status.auth !== "none") {
11658
12124
  prompt_exports.log.info(`e2b: already configured (${status.auth})`);
@@ -11727,8 +12193,7 @@ async function runInstallWizard(opts = {}) {
11727
12193
  await runPrepare(providerName, {
11728
12194
  cwd: process.cwd(),
11729
12195
  yes: true,
11730
- suppressStatus: true,
11731
- suppressTip: true
12196
+ suppressStatus: true
11732
12197
  });
11733
12198
  } catch (err) {
11734
12199
  prompt_exports.log.warn(
@@ -11742,17 +12207,20 @@ async function runInstallWizard(opts = {}) {
11742
12207
  }
11743
12208
  const sp = (0, prompt_exports.spinner)();
11744
12209
  sp.start("installing host /agentbox skill\u2026");
11745
- let skillRes;
11746
12210
  try {
11747
- skillRes = installHostSkills({ force: opts.force, dryRun: opts.dryRun, quiet: true });
11748
- if (skillRes.written.length > 0) {
11749
- sp.stop(`Agentbox Skills: Installed in ${String(skillRes.written.length)} locations`);
12211
+ const skillRes = installHostSkills({ force: opts.force, dryRun: opts.dryRun, quiet: true });
12212
+ const forkRes = await installForkSkill({ force: opts.force, dryRun: opts.dryRun, quiet: true });
12213
+ const written = skillRes.written.length + forkRes.written.length;
12214
+ const skipped = skillRes.skipped + forkRes.skipped;
12215
+ if (written > 0) {
12216
+ sp.stop(`Agentbox Skills: Installed in ${String(written)} locations`);
11750
12217
  } else {
11751
- sp.stop(`Agentbox Skills: nothing to write (${String(skillRes.skipped)} skipped)`);
12218
+ sp.stop(`Agentbox Skills: nothing to write (${String(skipped)} skipped)`);
11752
12219
  }
11753
- if (skillRes.blocked.length > 0) {
12220
+ const blocked = [...skillRes.blocked, ...forkRes.blocked];
12221
+ if (blocked.length > 0) {
11754
12222
  prompt_exports.log.warn(
11755
- `user-modified host skill file(s) left in place: ${skillRes.blocked.join(", ")}
12223
+ `user-modified host skill file(s) left in place: ${blocked.join(", ")}
11756
12224
  pass \`agentbox install --skills-only --force\` to overwrite`
11757
12225
  );
11758
12226
  }
@@ -11782,23 +12250,27 @@ var installCommand = new Command29("install").description(
11782
12250
  if (opts.skillsOnly) {
11783
12251
  (0, prompt_exports.intro)("Installing AgentBox host commands...");
11784
12252
  let res;
12253
+ let forkRes;
11785
12254
  try {
11786
12255
  res = installHostSkills({ force: opts.force, dryRun: opts.dryRun });
12256
+ forkRes = await installForkSkill({ force: opts.force, dryRun: opts.dryRun });
11787
12257
  } catch (err) {
11788
12258
  prompt_exports.log.error(err instanceof Error ? err.message : String(err));
11789
12259
  process.exit(1);
11790
12260
  }
12261
+ const written = [...res.written, ...forkRes.written];
12262
+ const skipped = res.skipped + forkRes.skipped;
11791
12263
  if (opts.dryRun) {
11792
12264
  (0, prompt_exports.outro)(
11793
- `dry-run: ${String(res.written.length)} file(s) would be written, ${String(res.skipped)} skipped`
12265
+ `dry-run: ${String(written.length)} file(s) would be written, ${String(skipped)} skipped`
11794
12266
  );
11795
12267
  return;
11796
12268
  }
11797
- if (res.written.length === 0) {
11798
- (0, prompt_exports.outro)(`nothing installed (${String(res.skipped)} skipped)`);
12269
+ if (written.length === 0) {
12270
+ (0, prompt_exports.outro)(`nothing installed (${String(skipped)} skipped)`);
11799
12271
  return;
11800
12272
  }
11801
- (0, prompt_exports.outro)(`installed: ${res.written.join(", ")}`);
12273
+ (0, prompt_exports.outro)(`installed: ${written.join(", ")}`);
11802
12274
  return;
11803
12275
  }
11804
12276
  const ok = await runInstallWizard({
@@ -12021,7 +12493,7 @@ for (const op of GH_PR_OPS) {
12021
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);
12022
12494
 
12023
12495
  // src/commands/list.ts
12024
- import { log as log36 } from "@clack/prompts";
12496
+ import { log as log37 } from "@clack/prompts";
12025
12497
  import { Command as Command32 } from "commander";
12026
12498
  import { pathToFileURL } from "url";
12027
12499
 
@@ -12115,7 +12587,7 @@ async function watchRender(produce, rawInterval, opts = {}) {
12115
12587
  process.once("SIGINT", () => process.exit(0));
12116
12588
  }
12117
12589
  const hint = interactive ? "q or Ctrl-C to exit" : "Ctrl-C to exit";
12118
- const sleep6 = (d) => new Promise((r) => {
12590
+ const sleep7 = (d) => new Promise((r) => {
12119
12591
  const t = setTimeout(() => {
12120
12592
  wake = null;
12121
12593
  r();
@@ -12146,7 +12618,7 @@ async function watchRender(produce, rawInterval, opts = {}) {
12146
12618
  ${trimmed}
12147
12619
  `);
12148
12620
  }
12149
- await sleep6(ms);
12621
+ await sleep7(ms);
12150
12622
  if (exiting) {
12151
12623
  restore();
12152
12624
  process.exit(0);
@@ -12389,7 +12861,7 @@ var listCommand2 = withWatchOptions(
12389
12861
  )
12390
12862
  ).action(async (opts) => {
12391
12863
  if (opts.json && opts.watch) {
12392
- log36.error("cannot combine --json with --watch");
12864
+ log37.error("cannot combine --json with --watch");
12393
12865
  process.exit(2);
12394
12866
  }
12395
12867
  const all = opts.global ?? false;
@@ -12434,9 +12906,9 @@ var listCommand2 = withWatchOptions(
12434
12906
  });
12435
12907
 
12436
12908
  // src/commands/logs.ts
12437
- import { log as log37 } from "@clack/prompts";
12909
+ import { log as log38 } from "@clack/prompts";
12438
12910
  import { Command as Command33 } from "commander";
12439
- import { spawn as spawn3 } from "child_process";
12911
+ import { spawn as spawn4 } from "child_process";
12440
12912
  var DAEMON_LOG_PATH = "/var/log/agentbox/ctl-daemon.log";
12441
12913
  var logsCommand = new Command33("logs").description("Print recent log lines from a box service; -f to stream").argument(
12442
12914
  "[box]",
@@ -12456,9 +12928,9 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12456
12928
  service = boxArg;
12457
12929
  }
12458
12930
  if (!service && !opts.daemon) {
12459
- log37.error("missing <service> argument");
12460
- log37.info("usage: agentbox logs [box] <service> [-n N] [-f]");
12461
- log37.info(" agentbox logs [box] --daemon [-n N] [-f]");
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]");
12462
12934
  process.exit(2);
12463
12935
  }
12464
12936
  const box = await resolveBoxOrExit(idOrName);
@@ -12469,7 +12941,7 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12469
12941
  if (!opts.follow) {
12470
12942
  const proc = await provider.exec(box, args, { user: "vscode" });
12471
12943
  if (proc.exitCode !== 0) {
12472
- log37.error(
12944
+ log38.error(
12473
12945
  `${opts.daemon ? "daemon log" : "agentbox-ctl logs"} failed: ${proc.stderr || proc.stdout}`
12474
12946
  );
12475
12947
  process.exit(1);
@@ -12479,7 +12951,7 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12479
12951
  return;
12480
12952
  }
12481
12953
  if (!isCloud) {
12482
- const child2 = spawn3("docker", ["exec", "--user", "vscode", box.container, ...args], {
12954
+ const child2 = spawn4("docker", ["exec", "--user", "vscode", box.container, ...args], {
12483
12955
  stdio: ["ignore", "inherit", "inherit"]
12484
12956
  });
12485
12957
  child2.on("exit", (code) => process.exit(code ?? 0));
@@ -12503,7 +12975,7 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12503
12975
  });
12504
12976
  const [argv0, ...rest] = spec.argv;
12505
12977
  if (!argv0) throw new Error("provider.buildAttach returned an empty argv");
12506
- const child = spawn3(argv0, rest, {
12978
+ const child = spawn4(argv0, rest, {
12507
12979
  stdio: ["ignore", "inherit", "inherit"],
12508
12980
  env: spec.env ? { ...process.env, ...spec.env } : process.env
12509
12981
  });
@@ -12525,11 +12997,11 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12525
12997
  });
12526
12998
 
12527
12999
  // src/commands/open.ts
12528
- import { log as log38 } from "@clack/prompts";
12529
- import { execa as execa5 } from "execa";
12530
- import { existsSync as existsSync11, mkdirSync as mkdirSync9 } from "fs";
12531
- import { homedir as homedir19 } from "os";
12532
- import { join as join22 } from "path";
13000
+ import { log as log39 } from "@clack/prompts";
13001
+ 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";
12533
13005
  import { Command as Command34 } from "commander";
12534
13006
 
12535
13007
  // src/commands/path.ts
@@ -12591,7 +13063,7 @@ var openCommand = new Command34("open").description("Open a box's /workspace in
12591
13063
  }
12592
13064
  });
12593
13065
  async function runCloudOpen(box, provider, opts) {
12594
- const mountRoot = join22(homedir19(), ".agentbox", "mounts", box.name);
13066
+ const mountRoot = join23(homedir20(), ".agentbox", "mounts", box.name);
12595
13067
  if (opts.unmount) {
12596
13068
  const ok = await tryUnmount(mountRoot);
12597
13069
  if (ok) process.stdout.write(`unmounted ${mountRoot}
@@ -12628,14 +13100,14 @@ async function runCloudOpen(box, provider, opts) {
12628
13100
  user: target.user,
12629
13101
  identityFile: target.identityFile
12630
13102
  });
12631
- if (!existsSync11(mountRoot)) {
12632
- mkdirSync9(mountRoot, { recursive: true, mode: 493 });
13103
+ if (!existsSync12(mountRoot)) {
13104
+ mkdirSync10(mountRoot, { recursive: true, mode: 493 });
12633
13105
  } else if (await isMounted(mountRoot)) {
12634
- log38.info(`re-mounting (stale mount detected at ${mountRoot})`);
13106
+ log39.info(`re-mounting (stale mount detected at ${mountRoot})`);
12635
13107
  await tryUnmount(mountRoot);
12636
13108
  }
12637
- log38.info(`mounting ${alias}:/workspace at ${mountRoot}`);
12638
- const mount = await execa5(
13109
+ log39.info(`mounting ${alias}:/workspace at ${mountRoot}`);
13110
+ const mount = await execa6(
12639
13111
  sshfsBin,
12640
13112
  [
12641
13113
  `${alias}:/workspace`,
@@ -12654,27 +13126,27 @@ async function runCloudOpen(box, provider, opts) {
12654
13126
  if (mount.exitCode !== 0) {
12655
13127
  throw new Error(`sshfs mount failed (exit ${String(mount.exitCode)}): ${mount.stderr || mount.stdout}`);
12656
13128
  }
12657
- await execa5(hostOpenCommand(), [mountRoot], { reject: false });
13129
+ await execa6(hostOpenCommand(), [mountRoot], { reject: false });
12658
13130
  process.stdout.write(`opened ${mountRoot}
12659
13131
  `);
12660
13132
  process.stdout.write(`unmount later with: agentbox open ${box.name} --unmount
12661
13133
  `);
12662
13134
  }
12663
13135
  async function locateBinary(name) {
12664
- const r = await execa5("which", [name], { reject: false });
13136
+ const r = await execa6("which", [name], { reject: false });
12665
13137
  if (r.exitCode !== 0) return null;
12666
13138
  const path = (r.stdout ?? "").trim();
12667
13139
  return path.length > 0 ? path : null;
12668
13140
  }
12669
13141
  async function isMounted(path) {
12670
- const r = await execa5("sh", ["-c", `mount | grep -F " on ${path} "`], { reject: false });
13142
+ const r = await execa6("sh", ["-c", `mount | grep -F " on ${path} "`], { reject: false });
12671
13143
  return r.exitCode === 0;
12672
13144
  }
12673
13145
  async function tryUnmount(path) {
12674
13146
  if (await isMounted(path)) {
12675
- const u = await execa5("umount", [path], { reject: false });
13147
+ const u = await execa6("umount", [path], { reject: false });
12676
13148
  if (u.exitCode === 0) return true;
12677
- const d = await execa5("diskutil", ["unmount", path], { reject: false });
13149
+ const d = await execa6("diskutil", ["unmount", path], { reject: false });
12678
13150
  return d.exitCode === 0;
12679
13151
  }
12680
13152
  return false;
@@ -12865,7 +13337,7 @@ async function pruneCloud(provider, opts) {
12865
13337
 
12866
13338
  // src/commands/queue.ts
12867
13339
  import { readFile as readFile6, stat as stat6 } from "fs/promises";
12868
- import { intro as intro10, log as log40, outro as outro9 } from "@clack/prompts";
13340
+ import { intro as intro10, log as log41, outro as outro9 } from "@clack/prompts";
12869
13341
  import { Command as Command37 } from "commander";
12870
13342
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["done", "failed", "cancelled"]);
12871
13343
  var queueCommand = new Command37("queue").description("Inspect and manage background `agentbox claude|codex|opencode -i` jobs");
@@ -12874,8 +13346,8 @@ var queueListCommand = new Command37("list").description("List queued, running,
12874
13346
  const cfg = await loadQueueConfig();
12875
13347
  const visible = opts.all === true ? jobs : jobs.filter((j) => !TERMINAL_STATUSES.has(j.status));
12876
13348
  if (visible.length === 0) {
12877
- log40.info(opts.all ? "no queued jobs." : "no active queued jobs (--all to see terminal).");
12878
- log40.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
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)})`);
12879
13351
  return;
12880
13352
  }
12881
13353
  const rows = visible.map((j) => ({
@@ -12900,12 +13372,12 @@ var queueListCommand = new Command37("list").description("List queued, running,
12900
13372
  headers.map((h, i) => pad4(String(r[h]), widths[i])).join(" ") + "\n"
12901
13373
  );
12902
13374
  }
12903
- log40.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
13375
+ log41.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
12904
13376
  });
12905
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) => {
12906
13378
  const job = await readJob(id);
12907
13379
  if (!job) {
12908
- log40.error(`no job with id ${id}`);
13380
+ log41.error(`no job with id ${id}`);
12909
13381
  process.exit(1);
12910
13382
  }
12911
13383
  process.stdout.write(JSON.stringify(job, null, 2) + "\n");
@@ -12921,18 +13393,18 @@ var queueShowCommand = new Command37("show").description("Dump a job manifest an
12921
13393
  process.stdout.write(slice.join("\n"));
12922
13394
  if (!slice.join("\n").endsWith("\n")) process.stdout.write("\n");
12923
13395
  } catch {
12924
- log40.info(`(no log at ${job.logPath} yet)`);
13396
+ log41.info(`(no log at ${job.logPath} yet)`);
12925
13397
  }
12926
13398
  });
12927
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) => {
12928
13400
  intro10(`Cancelling queue job ${id}...`);
12929
13401
  const job = await readJob(id);
12930
13402
  if (!job) {
12931
- log40.error(`no job with id ${id}`);
13403
+ log41.error(`no job with id ${id}`);
12932
13404
  process.exit(1);
12933
13405
  }
12934
13406
  if (job.status !== "queued") {
12935
- log40.error(
13407
+ log41.error(
12936
13408
  `job ${id} is ${job.status}; cancel only flips 'queued' \u2192 'cancelled'.` + (job.status === "running" ? ` Use 'agentbox destroy ${job.boxName || id}' to stop the box.` : "")
12937
13409
  );
12938
13410
  process.exit(1);
@@ -12952,7 +13424,7 @@ var queueClearCommand = new Command37("clear").description("Sweep terminal-state
12952
13424
  if (opts.all === true || opts.failed === true) targets.add("failed");
12953
13425
  if (opts.all === true || opts.cancelled === true) targets.add("cancelled");
12954
13426
  if (targets.size === 0) {
12955
- log40.error("pick at least one of: --done, --failed, --cancelled, --all");
13427
+ log41.error("pick at least one of: --done, --failed, --cancelled, --all");
12956
13428
  process.exit(2);
12957
13429
  }
12958
13430
  const jobs = await loadQueue();
@@ -12962,7 +13434,7 @@ var queueClearCommand = new Command37("clear").description("Sweep terminal-state
12962
13434
  await deleteJob(j.id);
12963
13435
  removed += 1;
12964
13436
  }
12965
- log40.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
13437
+ log41.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
12966
13438
  });
12967
13439
  var QUEUE_WAIT_EVENTS = [
12968
13440
  "new-box",
@@ -12979,7 +13451,7 @@ var queueWaitForCommand = new Command37("wait-for").description(
12979
13451
  `Block until a queue / box event fires. <event> one of: ${QUEUE_WAIT_EVENTS.join(" | ")}.`
12980
13452
  ).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) => {
12981
13453
  if (!QUEUE_WAIT_EVENTS.includes(eventRaw)) {
12982
- log40.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
13454
+ log41.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
12983
13455
  process.exit(2);
12984
13456
  }
12985
13457
  const event = eventRaw;
@@ -12999,11 +13471,11 @@ var queueWaitForCommand = new Command37("wait-for").description(
12999
13471
  if (opts.json === true) {
13000
13472
  process.stdout.write(JSON.stringify({ matched: false, event, elapsedMs }) + "\n");
13001
13473
  } else {
13002
- log40.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
13474
+ log41.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
13003
13475
  }
13004
13476
  process.exit(1);
13005
13477
  }
13006
- log40.error(err instanceof Error ? err.message : String(err));
13478
+ log41.error(err instanceof Error ? err.message : String(err));
13007
13479
  process.exit(1);
13008
13480
  }
13009
13481
  });
@@ -13063,11 +13535,11 @@ async function pollUntil(deadline, probe) {
13063
13535
  if (result !== void 0) return result;
13064
13536
  const remaining = deadline - Date.now();
13065
13537
  if (remaining <= 0) break;
13066
- await sleep5(Math.min(QUEUE_POLL_INTERVAL_MS, remaining));
13538
+ await sleep6(Math.min(QUEUE_POLL_INTERVAL_MS, remaining));
13067
13539
  }
13068
13540
  throw new QueueWaitTimeout();
13069
13541
  }
13070
- function sleep5(ms) {
13542
+ function sleep6(ms) {
13071
13543
  return new Promise((r) => setTimeout(r, ms));
13072
13544
  }
13073
13545
  function parsePositiveInt3(raw, label) {
@@ -13100,7 +13572,7 @@ function truncate(s, max) {
13100
13572
  }
13101
13573
 
13102
13574
  // src/commands/relay.ts
13103
- import { log as log41, spinner as spinner9 } from "@clack/prompts";
13575
+ import { log as log42, spinner as spinner9 } from "@clack/prompts";
13104
13576
  import { Command as Command38 } from "commander";
13105
13577
  async function rehydrateFromState() {
13106
13578
  const state = await readState();
@@ -13195,7 +13667,7 @@ var restartSub = new Command38("restart").description("Stop then start the host
13195
13667
  s2.stop(`relay running on ${ep.hostUrl}`);
13196
13668
  } catch (err) {
13197
13669
  s2.stop("relay start failed");
13198
- log41.warn(err instanceof Error ? err.message : String(err));
13670
+ log42.warn(err instanceof Error ? err.message : String(err));
13199
13671
  throw err;
13200
13672
  }
13201
13673
  } catch (err) {
@@ -13207,23 +13679,23 @@ var relayCommand = new Command38("relay").description("Manage the host relay pro
13207
13679
  // src/commands/_run-queued-job.ts
13208
13680
  import { Command as Command39 } from "commander";
13209
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) => {
13210
- const log50 = openCommandLog(`queue-${id}`);
13211
- log50.write(`worker pid=${String(process.pid)} starting for job ${id}`);
13682
+ const log51 = openCommandLog(`queue-${id}`);
13683
+ log51.write(`worker pid=${String(process.pid)} starting for job ${id}`);
13212
13684
  let job = null;
13213
13685
  try {
13214
13686
  job = await readJob(id);
13215
13687
  if (!job) {
13216
- log50.write(`FATAL: no manifest at id=${id}`);
13217
- log50.close();
13688
+ log51.write(`FATAL: no manifest at id=${id}`);
13689
+ log51.close();
13218
13690
  process.exit(64);
13219
13691
  }
13220
13692
  const onBoxCreated = (boxId) => {
13221
13693
  if (job) job = { ...job, boxId };
13222
13694
  };
13223
13695
  if ((job.providerName || "docker") === "docker") {
13224
- await runDockerJob(job, log50, onBoxCreated);
13696
+ await runDockerJob(job, log51, onBoxCreated);
13225
13697
  } else {
13226
- await runCloudJob(job, log50, onBoxCreated);
13698
+ await runCloudJob(job, log51, onBoxCreated);
13227
13699
  }
13228
13700
  const done = {
13229
13701
  ...job,
@@ -13232,12 +13704,12 @@ var runQueuedJobCommand = new Command39("_run-queued-job").description("internal
13232
13704
  exitCode: 0
13233
13705
  };
13234
13706
  await writeJob(done);
13235
- log50.write(`done`);
13236
- log50.close();
13707
+ log51.write(`done`);
13708
+ log51.close();
13237
13709
  process.exit(0);
13238
13710
  } catch (err) {
13239
13711
  const msg = err instanceof Error ? err.stack ?? err.message : String(err);
13240
- log50.write(`FAIL: ${msg}`);
13712
+ log51.write(`FAIL: ${msg}`);
13241
13713
  if (job) {
13242
13714
  try {
13243
13715
  const failed = {
@@ -13251,11 +13723,11 @@ var runQueuedJobCommand = new Command39("_run-queued-job").description("internal
13251
13723
  } catch {
13252
13724
  }
13253
13725
  }
13254
- log50.close();
13726
+ log51.close();
13255
13727
  process.exit(1);
13256
13728
  }
13257
13729
  });
13258
- async function runDockerJob(job, log50, onBoxCreated) {
13730
+ async function runDockerJob(job, log51, onBoxCreated) {
13259
13731
  const opts = job.createOpts;
13260
13732
  const cfg = await loadEffectiveConfig(opts.workspace, {
13261
13733
  cliOverrides: buildOverridesFromJob(job)
@@ -13267,7 +13739,7 @@ async function runDockerJob(job, log50, onBoxCreated) {
13267
13739
  const useSnapshot = opts.hostSnapshot === false ? false : opts.hostSnapshot === true ? true : cfg.effective.box.hostSnapshot ?? false;
13268
13740
  const resolved = job.agent === "claude-code" ? await resolveClaudeAuth(process.env) : null;
13269
13741
  const withPlaywright = cfg.effective.box.withPlaywright || cfg.effective.browser.default !== "agent-browser";
13270
- log50.write(`creating box for agent=${job.agent}`);
13742
+ log51.write(`creating box for agent=${job.agent}`);
13271
13743
  const result = await createBox({
13272
13744
  workspacePath: opts.workspace,
13273
13745
  name: opts.name && opts.name.length > 0 ? opts.name : void 0,
@@ -13293,22 +13765,22 @@ async function runDockerJob(job, log50, onBoxCreated) {
13293
13765
  // at box-create time (the worker runs on the host, so it can read the files).
13294
13766
  carry: opts.carry,
13295
13767
  projectRoot,
13296
- onLog: (line) => log50.write(line)
13768
+ onLog: (line) => log51.write(line)
13297
13769
  });
13298
- log50.write(`box created: ${result.record.container}`);
13770
+ log51.write(`box created: ${result.record.container}`);
13299
13771
  onBoxCreated(result.record.id);
13300
13772
  await writeJob({ ...job, boxId: result.record.id });
13301
13773
  const resyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
13302
- if (resyncWarning) log50.write(resyncWarning);
13774
+ if (resyncWarning) log51.write(resyncWarning);
13303
13775
  const prompt = prependResyncWarning(resyncWarning, job.prompt);
13304
13776
  const promptedArgs = buildPromptArgs(job.agent, prompt, job.agentArgs);
13305
13777
  if (job.agent === "claude-code") {
13306
- log50.write(`checking plugin native deps`);
13778
+ log51.write(`checking plugin native deps`);
13307
13779
  await rebuildPluginNativeDeps(result.record.container, {
13308
13780
  volume: result.record.claudeConfigVolume ?? SHARED_CLAUDE_VOLUME,
13309
- onProgress: (line) => log50.write(line)
13781
+ onProgress: (line) => log51.write(line)
13310
13782
  });
13311
- log50.write(`starting claude session`);
13783
+ log51.write(`starting claude session`);
13312
13784
  await startClaudeSession({
13313
13785
  container: result.record.container,
13314
13786
  claudeArgs: applyClaudeSkipPermissions(promptedArgs, cfg.effective),
@@ -13316,22 +13788,22 @@ async function runDockerJob(job, log50, onBoxCreated) {
13316
13788
  boxName: result.record.name
13317
13789
  });
13318
13790
  } else if (job.agent === "codex") {
13319
- log50.write(`checking codex`);
13791
+ log51.write(`checking codex`);
13320
13792
  await ensureCodexInstalled(result.record.container, {
13321
- onProgress: (line) => log50.write(line)
13793
+ onProgress: (line) => log51.write(line)
13322
13794
  });
13323
- log50.write(`starting codex session`);
13795
+ log51.write(`starting codex session`);
13324
13796
  await startCodexSession({
13325
13797
  container: result.record.container,
13326
13798
  codexArgs: applyCodexSkipPermissions(promptedArgs, cfg.effective),
13327
13799
  sessionName: cfg.effective.codex.sessionName
13328
13800
  });
13329
13801
  } else if (job.agent === "opencode") {
13330
- log50.write(`checking opencode`);
13802
+ log51.write(`checking opencode`);
13331
13803
  await ensureOpencodeInstalled(result.record.container, {
13332
- onProgress: (line) => log50.write(line)
13804
+ onProgress: (line) => log51.write(line)
13333
13805
  });
13334
- log50.write(`starting opencode session`);
13806
+ log51.write(`starting opencode session`);
13335
13807
  await startOpencodeSession({
13336
13808
  container: result.record.container,
13337
13809
  opencodeArgs: promptedArgs,
@@ -13340,17 +13812,17 @@ async function runDockerJob(job, log50, onBoxCreated) {
13340
13812
  } else {
13341
13813
  throw new Error(`unknown agent kind: ${String(job.agent)}`);
13342
13814
  }
13343
- await maybeOpenQueuedTerminal(job, result.record.name, log50);
13815
+ await maybeOpenQueuedTerminal(job, result.record.name, log51);
13344
13816
  }
13345
13817
  function agentBinaryName(agent) {
13346
13818
  return agent === "claude-code" ? "claude" : agent;
13347
13819
  }
13348
- async function maybeOpenQueuedTerminal(job, boxName, log50) {
13820
+ async function maybeOpenQueuedTerminal(job, boxName, log51) {
13349
13821
  const ctx = job.openTerminal;
13350
13822
  if (!ctx) return;
13351
13823
  const cliEntry = process.env["AGENTBOX_CLI_ENTRY"];
13352
13824
  if (!cliEntry) {
13353
- log50.write("queue.openIn: AGENTBOX_CLI_ENTRY unset; cannot open terminal");
13825
+ log51.write("queue.openIn: AGENTBOX_CLI_ENTRY unset; cannot open terminal");
13354
13826
  return;
13355
13827
  }
13356
13828
  const argv2 = [
@@ -13364,14 +13836,14 @@ async function maybeOpenQueuedTerminal(job, boxName, log50) {
13364
13836
  ];
13365
13837
  try {
13366
13838
  const r = await spawnQueuedOpenTerminal(ctx, argv2, boxName);
13367
- log50.write(
13839
+ log51.write(
13368
13840
  r.launched ? `queue.openIn: ${r.note}` : `queue.openIn: open failed: ${r.error ?? ""}`
13369
13841
  );
13370
13842
  } catch (err) {
13371
- log50.write(`queue.openIn: open threw: ${err instanceof Error ? err.message : String(err)}`);
13843
+ log51.write(`queue.openIn: open threw: ${err instanceof Error ? err.message : String(err)}`);
13372
13844
  }
13373
13845
  }
13374
- async function runCloudJob(job, log50, onBoxCreated) {
13846
+ async function runCloudJob(job, log51, onBoxCreated) {
13375
13847
  const opts = job.createOpts;
13376
13848
  const cfg = await loadEffectiveConfig(opts.workspace, {
13377
13849
  cliOverrides: buildOverridesFromJob(job)
@@ -13382,7 +13854,7 @@ async function runCloudJob(job, log50, onBoxCreated) {
13382
13854
  const providerDefault = resolveDefaultCheckpoint(cfg.effective, providerName);
13383
13855
  const checkpointRef = opts.snapshot && opts.snapshot.length > 0 ? opts.snapshot : providerDefault.length > 0 ? providerDefault : void 0;
13384
13856
  const withPlaywright = cfg.effective.box.withPlaywright || cfg.effective.browser.default !== "agent-browser";
13385
- log50.write(`creating cloud box (${providerName}) for agent=${job.agent}`);
13857
+ log51.write(`creating cloud box (${providerName}) for agent=${job.agent}`);
13386
13858
  const result = await provider.create({
13387
13859
  workspacePath: opts.workspace,
13388
13860
  name: opts.name && opts.name.length > 0 ? opts.name : void 0,
@@ -13396,9 +13868,9 @@ async function runCloudJob(job, log50, onBoxCreated) {
13396
13868
  // worker runs on the host too, so it reads the files and uploads them.
13397
13869
  carry: opts.carry,
13398
13870
  projectRoot,
13399
- onLog: (line) => log50.write(line)
13871
+ onLog: (line) => log51.write(line)
13400
13872
  });
13401
- log50.write(`box created: ${result.record.id}`);
13873
+ log51.write(`box created: ${result.record.id}`);
13402
13874
  onBoxCreated(result.record.id);
13403
13875
  await writeJob({ ...job, boxId: result.record.id });
13404
13876
  const promptedArgs = buildPromptArgs(job.agent, job.prompt, job.agentArgs);
@@ -13420,14 +13892,14 @@ async function runCloudJob(job, log50, onBoxCreated) {
13420
13892
  } else {
13421
13893
  throw new Error(`unknown agent kind: ${String(job.agent)}`);
13422
13894
  }
13423
- log50.write(`starting detached ${job.agent} session`);
13895
+ log51.write(`starting detached ${job.agent} session`);
13424
13896
  await cloudAgentStartDetached({
13425
13897
  box: result.record,
13426
13898
  binary,
13427
13899
  sessionName,
13428
13900
  extraArgs
13429
13901
  });
13430
- await maybeOpenQueuedTerminal(job, result.record.name, log50);
13902
+ await maybeOpenQueuedTerminal(job, result.record.name, log51);
13431
13903
  }
13432
13904
  function buildOverridesFromJob(job) {
13433
13905
  const opts = job.createOpts;
@@ -13456,9 +13928,155 @@ function buildOverridesFromJob(job) {
13456
13928
  return out;
13457
13929
  }
13458
13930
 
13931
+ // src/commands/_claude-login-worker.ts
13932
+ import { Command as Command40 } from "commander";
13933
+ var URL_TIMEOUT_MS = 6e4;
13934
+ var CODE_TIMEOUT_MS = 10 * 6e4;
13935
+ var POLL_MS2 = 500;
13936
+ var INVALID_CODE = /invalid|incorrect|not a valid|try again|expired|rejected/i;
13937
+ var BUF_CAP = 64 * 1024;
13938
+ function tailOf(buf) {
13939
+ const clean = buf.replace(new RegExp("\\u001b\\[[0-9;?]*[ -\\/]*[@-~]", "g"), "").replace(/\r/g, "");
13940
+ const lines = clean.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
13941
+ const tail = lines.slice(-2).join(" ");
13942
+ return tail.length > 240 ? tail.slice(-240) : tail;
13943
+ }
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}`);
13947
+ const base = { pid: process.pid, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
13948
+ let cur = { ...base, phase: "starting" };
13949
+ const setState = (patch) => {
13950
+ cur = { ...cur, ...patch };
13951
+ writeLoginState(id, cur);
13952
+ };
13953
+ const req = readLoginRequest(id);
13954
+ if (!req) {
13955
+ log51.write(`FATAL: no request.json for session ${id}`);
13956
+ setState({ phase: "error", error: "internal: missing login request" });
13957
+ log51.close();
13958
+ process.exit(64);
13959
+ }
13960
+ const backend = await loadPtyBackend();
13961
+ if (!backend) {
13962
+ log51.write("FATAL: node-pty backend unavailable");
13963
+ setState({ phase: "error", error: "pty-unavailable: the node-pty prebuild is not installed" });
13964
+ log51.close();
13965
+ process.exit(1);
13966
+ }
13967
+ const methodArgs = req.extraArgs.length > 0 ? req.extraArgs : ["--claudeai"];
13968
+ const dockerArgv = buildClaudeLoginRunArgv({
13969
+ volume: SHARED_CLAUDE_VOLUME,
13970
+ image: req.image,
13971
+ extraArgs: methodArgs
13972
+ });
13973
+ log51.write(`spawning: docker ${dockerArgv.join(" ")}`);
13974
+ let buf = "";
13975
+ let urlPublished = false;
13976
+ let lastError;
13977
+ let finished = false;
13978
+ const disposers = [];
13979
+ const pty = backend.ptySpawn("docker", dockerArgv, {
13980
+ name: "xterm-256color",
13981
+ cols: 200,
13982
+ rows: 50,
13983
+ env: process.env
13984
+ });
13985
+ const cleanExit = (code) => {
13986
+ finished = true;
13987
+ for (const d of disposers) d();
13988
+ try {
13989
+ pty.kill();
13990
+ } catch {
13991
+ }
13992
+ log51.close();
13993
+ process.exit(code);
13994
+ };
13995
+ for (const sig of ["SIGTERM", "SIGINT"]) {
13996
+ process.on(sig, () => {
13997
+ if (finished) return;
13998
+ log51.write(`received ${sig}; aborting`);
13999
+ setState({ phase: "error", error: `login worker terminated (${sig})` });
14000
+ cleanExit(1);
14001
+ });
14002
+ }
14003
+ const codePoll = setInterval(() => {
14004
+ if (finished || cur.phase !== "awaiting-code") return;
14005
+ const code = takeLoginCode(id);
14006
+ if (code) {
14007
+ log51.write("received code; submitting to login");
14008
+ setState({ phase: "exchanging" });
14009
+ pty.write(code + "\r");
14010
+ }
14011
+ }, POLL_MS2);
14012
+ disposers.push(() => clearInterval(codePoll));
14013
+ pty.onData((d) => {
14014
+ buf += d;
14015
+ if (buf.length > BUF_CAP) buf = buf.slice(-BUF_CAP);
14016
+ log51.raw(d);
14017
+ if (!urlPublished) {
14018
+ const url = extractOAuthUrl(buf);
14019
+ if (url) {
14020
+ urlPublished = true;
14021
+ log51.write(`published auth url: ${url}`);
14022
+ setState({ phase: "awaiting-code", url });
14023
+ }
14024
+ return;
14025
+ }
14026
+ if (cur.phase === "exchanging" && INVALID_CODE.test(d)) {
14027
+ lastError = "the code was not accepted \u2014 paste a fresh one";
14028
+ log51.write("code rejected; back to awaiting-code");
14029
+ setState({ phase: "awaiting-code", lastError });
14030
+ }
14031
+ });
14032
+ pty.onExit(({ exitCode }) => {
14033
+ if (finished) return;
14034
+ log51.write(`login process exited code=${String(exitCode)}`);
14035
+ void (async () => {
14036
+ let creds = { present: false, hasRefreshToken: false };
14037
+ try {
14038
+ creds = await volumeClaudeCredentials(SHARED_CLAUDE_VOLUME, req.image);
14039
+ } catch {
14040
+ }
14041
+ if (exitCode === 0 && creds.hasRefreshToken) {
14042
+ const warm = await warmUpClaudeCredentials(SHARED_CLAUDE_VOLUME, req.image, {
14043
+ onProgress: (l) => log51.write(l)
14044
+ });
14045
+ await syncClaudeCredentials(
14046
+ { volume: SHARED_CLAUDE_VOLUME },
14047
+ { image: req.image, isolate: false }
14048
+ );
14049
+ setState({ phase: "done", warmed: warm.warmed });
14050
+ cleanExit(0);
14051
+ return;
14052
+ }
14053
+ const tail = tailOf(buf);
14054
+ let error = exitCode === 0 ? "login exited without writing credentials" : `login exited with code ${String(exitCode)}`;
14055
+ if (lastError) error = lastError;
14056
+ if (tail) error += ` \u2014 ${tail}`;
14057
+ setState({ phase: "error", error, exitCode });
14058
+ cleanExit(1);
14059
+ })();
14060
+ });
14061
+ const urlTimer = setTimeout(() => {
14062
+ if (urlPublished || finished) return;
14063
+ log51.write("no auth URL within timeout");
14064
+ setState({ phase: "error", error: "login never printed an auth URL (see the worker log)" });
14065
+ cleanExit(1);
14066
+ }, URL_TIMEOUT_MS);
14067
+ disposers.push(() => clearTimeout(urlTimer));
14068
+ const codeTimer = setTimeout(() => {
14069
+ if (finished || cur.phase !== "starting" && cur.phase !== "awaiting-code") return;
14070
+ log51.write("no code within timeout; aborting");
14071
+ setState({ phase: "error", error: "timed out waiting for a code (10 min) \u2014 run login again" });
14072
+ cleanExit(1);
14073
+ }, CODE_TIMEOUT_MS);
14074
+ disposers.push(() => clearTimeout(codeTimer));
14075
+ });
14076
+
13459
14077
  // src/commands/herdr.ts
13460
14078
  import { spawnSync as spawnSync5 } from "child_process";
13461
- import { Command as Command40 } from "commander";
14079
+ import { Command as Command41 } from "commander";
13462
14080
  function parseHerdrLink(uri) {
13463
14081
  if (!uri) return null;
13464
14082
  const m = uri.match(/^agentbox:\/\/([^/]+)\/(.+)$/);
@@ -13484,7 +14102,7 @@ function herdrContextCwd(env = process.env) {
13484
14102
  }
13485
14103
  return process.cwd();
13486
14104
  }
13487
- var newCommand = new Command40("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) => {
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) => {
13488
14106
  const agent = opts.agent ?? "claude";
13489
14107
  const cwd = herdrContextCwd();
13490
14108
  const r = await spawnInNewTerminal({
@@ -13497,7 +14115,7 @@ var newCommand = new Command40("new").description("Open a new box session in a f
13497
14115
  if (r.launched) process.stdout.write(r.note + "\n");
13498
14116
  else if (r.error) process.stderr.write(r.error + "\n");
13499
14117
  });
13500
- var linkCommand = new Command40("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) => {
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) => {
13501
14119
  const link = parseHerdrLink(uriArg ?? process.env["HERDR_PLUGIN_CLICKED_URL"]);
13502
14120
  if (!link) return;
13503
14121
  if (link.verb !== "web") return;
@@ -13530,12 +14148,12 @@ var linkCommand = new Command40("link").description("Handle a Ctrl+click on an a
13530
14148
  sound: "request"
13531
14149
  });
13532
14150
  });
13533
- var herdrCommand = new Command40("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
14151
+ var herdrCommand = new Command41("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
13534
14152
 
13535
14153
  // src/commands/screen.ts
13536
14154
  import { spawnSync as spawnSync6 } from "child_process";
13537
- import { log as log42 } from "@clack/prompts";
13538
- import { Command as Command41 } from "commander";
14155
+ import { log as log43 } from "@clack/prompts";
14156
+ import { Command as Command42 } from "commander";
13539
14157
  var SIGNED_URL_TTL_MIN = 1;
13540
14158
  var SIGNED_URL_TTL_MAX = 86400;
13541
14159
  function parseTtlOrExit(raw) {
@@ -13548,7 +14166,7 @@ function parseTtlOrExit(raw) {
13548
14166
  }
13549
14167
  return n;
13550
14168
  }
13551
- var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
14169
+ var screenCommand = new Command42("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
13552
14170
  "[box]",
13553
14171
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
13554
14172
  ).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(
@@ -13565,10 +14183,10 @@ var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC
13565
14183
  if (provider === "docker") {
13566
14184
  const insp = await inspectBox(box.id);
13567
14185
  if (insp.state === "paused") {
13568
- log42.info("box is paused; unpausing");
14186
+ log43.info("box is paused; unpausing");
13569
14187
  await unpauseBox(box.id);
13570
14188
  } else if (insp.state === "stopped") {
13571
- log42.info("box is stopped; starting");
14189
+ log43.info("box is stopped; starting");
13572
14190
  await startBox(box.id);
13573
14191
  } else if (insp.state === "missing") {
13574
14192
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -13578,13 +14196,13 @@ var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC
13578
14196
  const inBoxUrl = exposePort !== void 0 ? box.portlessUrl ?? `http://localhost:${String(exposePort)}` : "about:blank";
13579
14197
  const br = await ensureBoxBrowser(box.container, void 0, inBoxUrl);
13580
14198
  if (br.up && !br.alreadyRunning) {
13581
- log42.info(
14199
+ log43.info(
13582
14200
  exposePort !== void 0 ? `opened ${inBoxUrl} in the in-box browser (visible in the VNC view)` : "started in-box browser"
13583
14201
  );
13584
14202
  } else if (br.alreadyRunning) {
13585
- log42.info("in-box browser already running; left it untouched");
14203
+ log43.info("in-box browser already running; left it untouched");
13586
14204
  } else {
13587
- log42.warn(`could not start in-box browser: ${br.reason ?? "unknown"}`);
14205
+ log43.warn(`could not start in-box browser: ${br.reason ?? "unknown"}`);
13588
14206
  }
13589
14207
  const engine = await detectEngine();
13590
14208
  const urls = buildVncUrls(box, engine);
@@ -13605,10 +14223,10 @@ var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC
13605
14223
  const p = await providerForBox(box);
13606
14224
  const state = await p.probeState(box);
13607
14225
  if (state === "paused") {
13608
- log42.info("box is paused; resuming");
14226
+ log43.info("box is paused; resuming");
13609
14227
  await p.resume(box);
13610
14228
  } else if (state === "stopped") {
13611
- log42.info("box is stopped; starting");
14229
+ log43.info("box is stopped; starting");
13612
14230
  await p.start(box);
13613
14231
  } else if (state === "missing") {
13614
14232
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -13623,14 +14241,14 @@ var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC
13623
14241
  user: "vscode"
13624
14242
  });
13625
14243
  if (br.exitCode === 0) {
13626
- log42.info(`opened ${webUrl} in the in-box browser (visible in the VNC view)`);
14244
+ log43.info(`opened ${webUrl} in the in-box browser (visible in the VNC view)`);
13627
14245
  } else {
13628
- log42.warn(
14246
+ log43.warn(
13629
14247
  `could not open in-box browser (continuing): ${br.stderr.trim() || br.stdout.trim() || `exit ${String(br.exitCode)}`}`
13630
14248
  );
13631
14249
  }
13632
14250
  } catch (err) {
13633
- log42.warn(
14251
+ log43.warn(
13634
14252
  `in-box browser skipped: ${err instanceof Error ? err.message : String(err)}`
13635
14253
  );
13636
14254
  }
@@ -13656,18 +14274,18 @@ var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC
13656
14274
 
13657
14275
  // src/commands/shell.ts
13658
14276
  import { spawnSync as spawnSync7 } from "child_process";
13659
- import { log as log44 } from "@clack/prompts";
13660
- import { Command as Command42 } from "commander";
14277
+ import { log as log45 } from "@clack/prompts";
14278
+ import { Command as Command43 } from "commander";
13661
14279
 
13662
14280
  // src/commands/_provider-guard.ts
13663
- import { log as log43 } from "@clack/prompts";
14281
+ import { log as log44 } from "@clack/prompts";
13664
14282
  function requireDockerProvider(box, commandName) {
13665
14283
  const provider = box.provider ?? "docker";
13666
14284
  if (provider === "docker") return;
13667
- log43.error(
14285
+ log44.error(
13668
14286
  `\`agentbox ${commandName}\` doesn't yet support cloud boxes (this box's provider is '${provider}').`
13669
14287
  );
13670
- log43.info(
14288
+ log44.info(
13671
14289
  "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."
13672
14290
  );
13673
14291
  process.exit(2);
@@ -13709,10 +14327,10 @@ function fmtAgo2(iso) {
13709
14327
  async function ensureBoxRunning(box) {
13710
14328
  const insp = await inspectBox(box.id);
13711
14329
  if (insp.state === "paused") {
13712
- log44.info("box is paused; unpausing");
14330
+ log45.info("box is paused; unpausing");
13713
14331
  await unpauseBox(box.id);
13714
14332
  } else if (insp.state === "stopped") {
13715
- log44.info("box is stopped; starting");
14333
+ log45.info("box is stopped; starting");
13716
14334
  await startBox(box.id);
13717
14335
  } else if (insp.state === "missing") {
13718
14336
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -13751,7 +14369,7 @@ async function startOrAttachShell(box, cfg) {
13751
14369
  const label = shellLabel(cfg.sessionName);
13752
14370
  const info = await shellSessionInfo(box.container, cfg.sessionName, cfg.user);
13753
14371
  if (info.running) {
13754
- log44.info(`reattaching to shell "${label}" \u2014 Control+a d to detach`);
14372
+ log45.info(`reattaching to shell "${label}" \u2014 Control+a d to detach`);
13755
14373
  } else {
13756
14374
  await startShellSession({
13757
14375
  container: box.container,
@@ -13759,7 +14377,7 @@ async function startOrAttachShell(box, cfg) {
13759
14377
  user: cfg.user,
13760
14378
  login: cfg.login
13761
14379
  });
13762
- log44.info(`shell "${label}" \u2014 Control+a d to detach, leaves it running`);
14380
+ log45.info(`shell "${label}" \u2014 Control+a d to detach, leaves it running`);
13763
14381
  }
13764
14382
  const code = await runWrappedAttach({
13765
14383
  container: box.container,
@@ -13774,7 +14392,7 @@ async function startOrAttachShell(box, cfg) {
13774
14392
  });
13775
14393
  process.exit(code);
13776
14394
  }
13777
- var shellCommand = new Command42("shell").description(
14395
+ var shellCommand = new Command43("shell").description(
13778
14396
  "Open an interactive shell in a box, in a detachable tmux session (auto-unpause/start)"
13779
14397
  ).argument(
13780
14398
  "[box]",
@@ -13869,7 +14487,7 @@ var shellCommand = new Command42("shell").description(
13869
14487
  handleLifecycleError(err);
13870
14488
  }
13871
14489
  });
13872
- var shellAttachCommand = new Command42("attach").description(
14490
+ var shellAttachCommand = new Command43("attach").description(
13873
14491
  "Attach to a shell tmux session in a box, starting one if none is running (auto-unpause/start)"
13874
14492
  ).argument(
13875
14493
  "[box]",
@@ -13907,7 +14525,7 @@ function renderShellTable(sessions) {
13907
14525
  for (const r of rows) process.stdout.write(`${fmt(r)}
13908
14526
  `);
13909
14527
  }
13910
- var shellLsCommand = new Command42("ls").description("List the shell tmux sessions running in a box").argument(
14528
+ var shellLsCommand = new Command43("ls").description("List the shell tmux sessions running in a box").argument(
13911
14529
  "[box]",
13912
14530
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
13913
14531
  ).action(async (idOrName) => {
@@ -13916,11 +14534,11 @@ var shellLsCommand = new Command42("ls").description("List the shell tmux sessio
13916
14534
  requireDockerProvider(box, "shell");
13917
14535
  const insp = await inspectBox(box.id);
13918
14536
  if (insp.state !== "running") {
13919
- log44.info(`box ${box.name} is ${insp.state} \u2014 no live shell sessions`);
14537
+ log45.info(`box ${box.name} is ${insp.state} \u2014 no live shell sessions`);
13920
14538
  return;
13921
14539
  }
13922
14540
  if (insp.shellSessions.length === 0) {
13923
- log44.info(
14541
+ log45.info(
13924
14542
  `no shell sessions in ${box.name} \u2014 start one with: agentbox shell ${reattachRef2(box)}`
13925
14543
  );
13926
14544
  return;
@@ -13930,7 +14548,7 @@ var shellLsCommand = new Command42("ls").description("List the shell tmux sessio
13930
14548
  handleLifecycleError(err);
13931
14549
  }
13932
14550
  });
13933
- var shellKillCommand = new Command42("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
14551
+ var shellKillCommand = new Command43("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
13934
14552
  "[box]",
13935
14553
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
13936
14554
  ).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) {
@@ -13940,25 +14558,25 @@ var shellKillCommand = new Command42("kill").description("Kill a shell tmux sess
13940
14558
  requireDockerProvider(box, "shell");
13941
14559
  const insp = await inspectBox(box.id);
13942
14560
  if (insp.state !== "running") {
13943
- log44.info(`box ${box.name} is ${insp.state} \u2014 no shell sessions to kill`);
14561
+ log45.info(`box ${box.name} is ${insp.state} \u2014 no shell sessions to kill`);
13944
14562
  return;
13945
14563
  }
13946
14564
  if (opts.all) {
13947
14565
  if (insp.shellSessions.length === 0) {
13948
- log44.info(`no shell sessions in ${box.name}`);
14566
+ log45.info(`no shell sessions in ${box.name}`);
13949
14567
  return;
13950
14568
  }
13951
14569
  let killed = 0;
13952
14570
  for (const s of insp.shellSessions) {
13953
14571
  if (await killShellSession(box.container, s.sessionName)) killed++;
13954
14572
  }
13955
- log44.success(`killed ${String(killed)} shell session${killed === 1 ? "" : "s"} in ${box.name}`);
14573
+ log45.success(`killed ${String(killed)} shell session${killed === 1 ? "" : "s"} in ${box.name}`);
13956
14574
  return;
13957
14575
  }
13958
14576
  const target = shellSessionName(opts.name);
13959
14577
  const ok = await killShellSession(box.container, target);
13960
- if (ok) log44.success(`killed shell "${shellLabel(target)}" in ${box.name}`);
13961
- else log44.warn(`no shell "${shellLabel(target)}" in ${box.name} (already gone?)`);
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?)`);
13962
14580
  } catch (err) {
13963
14581
  handleLifecycleError(err);
13964
14582
  }
@@ -13968,8 +14586,8 @@ shellCommand.addCommand(shellLsCommand);
13968
14586
  shellCommand.addCommand(shellKillCommand);
13969
14587
 
13970
14588
  // src/commands/start.ts
13971
- import { Command as Command43 } from "commander";
13972
- var startCommand = new Command43("start").description(
14589
+ import { Command as Command44 } from "commander";
14590
+ var startCommand = new Command44("start").description(
13973
14591
  "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)."
13974
14592
  ).argument(
13975
14593
  "[box]",
@@ -13981,10 +14599,19 @@ var startCommand = new Command43("start").description(
13981
14599
  const { record } = await startBox(box.id);
13982
14600
  process.stdout.write(`started ${record.container}
13983
14601
  `);
14602
+ await restoreAgentSessions(record, await providerForBox(record), {
14603
+ onLog: (line) => process.stdout.write(`${line}
14604
+ `)
14605
+ });
13984
14606
  } else {
13985
- await (await providerForBox(box)).start(box);
14607
+ const provider = await providerForBox(box);
14608
+ const record = await provider.start(box);
13986
14609
  process.stdout.write(`started ${box.name}
13987
14610
  `);
14611
+ await restoreAgentSessions(record, provider, {
14612
+ onLog: (line) => process.stdout.write(`${line}
14613
+ `)
14614
+ });
13988
14615
  }
13989
14616
  } catch (err) {
13990
14617
  handleLifecycleError(err);
@@ -13992,8 +14619,8 @@ var startCommand = new Command43("start").description(
13992
14619
  });
13993
14620
 
13994
14621
  // src/commands/status.ts
13995
- import { log as log46 } from "@clack/prompts";
13996
- import { Command as Command44 } from "commander";
14622
+ import { log as log47 } from "@clack/prompts";
14623
+ import { Command as Command45 } from "commander";
13997
14624
 
13998
14625
  // src/endpoints-render.ts
13999
14626
  function renderEndpointLines(endpoints, stream) {
@@ -14022,8 +14649,61 @@ function renderEndpointLines(endpoints, stream) {
14022
14649
  return entries.map((e) => ` ${e.name.padEnd(nameWidth)} ${e.value}`);
14023
14650
  }
14024
14651
 
14652
+ // src/commands/_status-render.ts
14653
+ async function fetchLive(state, container) {
14654
+ if (state !== "running") return null;
14655
+ const proc = await execInBox(container, ["agentbox-ctl", "status", "--json"], {
14656
+ user: "vscode"
14657
+ });
14658
+ if (proc.exitCode !== 0) return null;
14659
+ try {
14660
+ return JSON.parse(proc.stdout);
14661
+ } catch {
14662
+ return null;
14663
+ }
14664
+ }
14665
+ function renderLiveSections(live) {
14666
+ const out = [];
14667
+ if (live.tasks.length > 0) {
14668
+ out.push("TASKS", renderTaskTable(live.tasks), "");
14669
+ }
14670
+ out.push("SERVICES", renderStatusTable(live.services), "");
14671
+ out.push("PORTS", renderPortsTable(live.ports));
14672
+ return out;
14673
+ }
14674
+ function renderPersistedSections(s) {
14675
+ const out = [];
14676
+ if (s.tasks.length > 0) {
14677
+ out.push("TASKS");
14678
+ out.push(...s.tasks.map((t) => ` ${t.name} ${t.state}`));
14679
+ out.push("");
14680
+ }
14681
+ out.push("SERVICES");
14682
+ if (s.services.length === 0) {
14683
+ out.push(" (none)");
14684
+ } else {
14685
+ out.push(
14686
+ ...s.services.map(
14687
+ (svc) => ` ${svc.name} ${svc.state}${svc.port !== null ? ` :${String(svc.port)}` : ""}`
14688
+ )
14689
+ );
14690
+ }
14691
+ out.push("");
14692
+ out.push("PORTS");
14693
+ if (s.ports.length === 0) {
14694
+ out.push(" (none listening)");
14695
+ } else {
14696
+ const other = s.ports.filter((p) => !p.service).map((p) => p.port).sort((a, b) => a - b);
14697
+ out.push(
14698
+ ...s.ports.filter((p) => p.service).map((p) => ` :${String(p.port)} (${p.service})`)
14699
+ );
14700
+ if (other.length > 0) out.push(` other (${other.length}): ${other.join(", ")}`);
14701
+ }
14702
+ return out;
14703
+ }
14704
+
14025
14705
  // src/commands/inspect.ts
14026
- import { log as log45 } from "@clack/prompts";
14706
+ import { log as log46 } from "@clack/prompts";
14027
14707
  function fmtLimit(n, unit) {
14028
14708
  return n && n > 0 ? `${String(n)}${unit}` : "unlimited";
14029
14709
  }
@@ -14065,6 +14745,13 @@ async function renderText(i) {
14065
14745
  `host export ${i.hostPaths.mergedExport} (run \`agentbox open\` to refresh)`,
14066
14746
  `created ${i.record.createdAt}`
14067
14747
  ];
14748
+ const live = await fetchLive(i.state, i.record.container);
14749
+ if (live) {
14750
+ lines.push("", "(live from agentbox-ctl)", "", ...renderLiveSections(live));
14751
+ } else if (i.persistedStatus) {
14752
+ lines.push("", `(persisted snapshot from ${i.persistedStatus.timestamp})`, "");
14753
+ lines.push(...renderPersistedSections(i.persistedStatus));
14754
+ }
14068
14755
  return lines.join("\n");
14069
14756
  }
14070
14757
  function renderCheckpoint(i, sizeBytes) {
@@ -14147,6 +14834,9 @@ async function renderCloudText(box) {
14147
14834
  `persisted ${persisted ? `${persisted.timestamp} (${String(persisted.services.length)} svc, ${String(persisted.tasks.length)} tasks, ${String(persisted.ports.length)} ports)` : "(none)"}`,
14148
14835
  `created ${box.createdAt}`
14149
14836
  ];
14837
+ if (persisted) {
14838
+ lines.push("", ...renderPersistedSections(persisted));
14839
+ }
14150
14840
  return lines.join("\n");
14151
14841
  }
14152
14842
  function webPreviewLine(box) {
@@ -14168,7 +14858,7 @@ function renderCodexActivityCloud(persisted) {
14168
14858
  async function runInspect(box, opts) {
14169
14859
  try {
14170
14860
  if (opts.json && opts.watch) {
14171
- log45.error("cannot combine --json with --watch");
14861
+ log46.error("cannot combine --json with --watch");
14172
14862
  process.exit(2);
14173
14863
  }
14174
14864
  const isCloud = (box.provider ?? "docker") !== "docker";
@@ -14205,14 +14895,14 @@ async function runInspect(box, opts) {
14205
14895
 
14206
14896
  // src/commands/status.ts
14207
14897
  var statusCommand2 = withWatchOptions(
14208
- new Command44("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
14898
+ new Command45("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
14209
14899
  "[box]",
14210
14900
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14211
- ).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) instead of service/task status")
14901
+ ).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) plus service/task status")
14212
14902
  ).action(async (idOrName, opts) => {
14213
14903
  try {
14214
14904
  if (opts.json && opts.watch) {
14215
- log46.error("cannot combine --json with --watch");
14905
+ log47.error("cannot combine --json with --watch");
14216
14906
  process.exit(2);
14217
14907
  }
14218
14908
  const box = await resolveBoxOrExit(idOrName);
@@ -14254,18 +14944,6 @@ var statusCommand2 = withWatchOptions(
14254
14944
  handleLifecycleError(err);
14255
14945
  }
14256
14946
  });
14257
- async function fetchLive(state, container) {
14258
- if (state !== "running") return null;
14259
- const proc = await execInBox(container, ["agentbox-ctl", "status", "--json"], {
14260
- user: "vscode"
14261
- });
14262
- if (proc.exitCode !== 0) return null;
14263
- try {
14264
- return JSON.parse(proc.stdout);
14265
- } catch {
14266
- return null;
14267
- }
14268
- }
14269
14947
  async function buildStatusText(id, container) {
14270
14948
  const inspected = await inspectBox(id);
14271
14949
  const { state, endpoints, persistedStatus } = inspected;
@@ -14279,11 +14957,7 @@ async function buildStatusText(id, container) {
14279
14957
  out.push("CLAUDE", renderClaude(inspected, persistedStatus));
14280
14958
  out.push("", "SHELLS", renderShells2(inspected));
14281
14959
  if (live) {
14282
- if (live.tasks.length > 0) {
14283
- out.push("", "TASKS", renderTaskTable(live.tasks));
14284
- }
14285
- out.push("", "SERVICES", renderStatusTable(live.services));
14286
- out.push("", "PORTS", renderPortsTable(live.ports));
14960
+ out.push("", ...renderLiveSections(live));
14287
14961
  return out.join("\n");
14288
14962
  }
14289
14963
  if (!persistedStatus) {
@@ -14348,39 +15022,16 @@ function renderShells2(i) {
14348
15022
  return i.shellSessions.map((s) => ` ${s.label} ${s.attached ? "attached" : "detached"}`).join("\n");
14349
15023
  }
14350
15024
  function renderPersisted2(s, state) {
14351
- const out = [`(persisted snapshot from ${s.timestamp}; box is ${state})`, ""];
14352
- if (s.tasks.length > 0) {
14353
- out.push("TASKS");
14354
- out.push(...s.tasks.map((t) => ` ${t.name} ${t.state}`));
14355
- out.push("");
14356
- }
14357
- out.push("SERVICES");
14358
- if (s.services.length === 0) {
14359
- out.push(" (none)");
14360
- } else {
14361
- out.push(
14362
- ...s.services.map(
14363
- (svc) => ` ${svc.name} ${svc.state}${svc.port !== null ? ` :${String(svc.port)}` : ""}`
14364
- )
14365
- );
14366
- }
14367
- out.push("");
14368
- out.push("PORTS");
14369
- if (s.ports.length === 0) {
14370
- out.push(" (none listening)");
14371
- } else {
14372
- const other = s.ports.filter((p) => !p.service).map((p) => p.port).sort((a, b) => a - b);
14373
- out.push(
14374
- ...s.ports.filter((p) => p.service).map((p) => ` :${String(p.port)} (${p.service})`)
14375
- );
14376
- if (other.length > 0) out.push(` other (${other.length}): ${other.join(", ")}`);
14377
- }
14378
- return out.join("\n");
15025
+ return [
15026
+ `(persisted snapshot from ${s.timestamp}; box is ${state})`,
15027
+ "",
15028
+ ...renderPersistedSections(s)
15029
+ ].join("\n");
14379
15030
  }
14380
15031
 
14381
15032
  // src/commands/stop.ts
14382
- import { Command as Command45 } from "commander";
14383
- var stopCommand = new Command45("stop").description(
15033
+ import { Command as Command46 } from "commander";
15034
+ var stopCommand = new Command46("stop").description(
14384
15035
  "Stop a box (Docker: docker stop; preserves upper + node_modules volumes. Cloud: backend.stop \u2014 sandbox stays in your account, disk preserved)."
14385
15036
  ).argument(
14386
15037
  "[box]",
@@ -14409,7 +15060,7 @@ restart with: agentbox start ${box.name}
14409
15060
  });
14410
15061
 
14411
15062
  // src/commands/top.ts
14412
- import { Command as Command46 } from "commander";
15063
+ import { Command as Command47 } from "commander";
14413
15064
  var COLS = ["BOX", "STATE", "CPU%", "MEM USAGE / LIMIT", "MEM%", "PIDS", "DISK", "NET I/O"];
14414
15065
  function row(name, state, s) {
14415
15066
  const mem = `${fmtBytes2(s.memUsedBytes)} / ${fmtBytes2(s.memLimitBytes)}`;
@@ -14483,7 +15134,7 @@ async function renderProjectFooters() {
14483
15134
 
14484
15135
  SYSTEM: ${parts.join(" - ")}` : "";
14485
15136
  }
14486
- var topCommand = new Command46("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
15137
+ var topCommand = new Command47("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
14487
15138
  "[box]",
14488
15139
  "box ref (default: every box on the host; --project narrows to the cwd's project)"
14489
15140
  ).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) => {
@@ -14516,8 +15167,8 @@ var topCommand = new Command46("top").description("Live resource monitor (cpu/me
14516
15167
  });
14517
15168
 
14518
15169
  // src/commands/unpause.ts
14519
- import { Command as Command47 } from "commander";
14520
- var unpauseCommand = new Command47("unpause").description(
15170
+ import { Command as Command48 } from "commander";
15171
+ var unpauseCommand = new Command48("unpause").description(
14521
15172
  "Resume a paused box. Docker: `docker unpause` (sub-second). Cloud: backend.resume (re-hydrates from archive \u2014 slower first time)."
14522
15173
  ).argument(
14523
15174
  "[box]",
@@ -14530,9 +15181,14 @@ var unpauseCommand = new Command47("unpause").description(
14530
15181
  process.stdout.write(`unpaused ${record.container}
14531
15182
  `);
14532
15183
  } else {
14533
- await (await providerForBox(box)).resume(box);
15184
+ const provider = await providerForBox(box);
15185
+ await provider.resume(box);
14534
15186
  process.stdout.write(`unpaused ${box.name}
14535
15187
  `);
15188
+ await restoreAgentSessions(box, provider, {
15189
+ onLog: (line) => process.stdout.write(`${line}
15190
+ `)
15191
+ });
14536
15192
  }
14537
15193
  } catch (err) {
14538
15194
  handleLifecycleError(err);
@@ -14540,8 +15196,8 @@ var unpauseCommand = new Command47("unpause").description(
14540
15196
  });
14541
15197
 
14542
15198
  // src/commands/update.ts
14543
- import { spawn as spawn4 } from "child_process";
14544
- import { Command as Command48 } from "commander";
15199
+ import { spawn as spawn5 } from "child_process";
15200
+ import { Command as Command49 } from "commander";
14545
15201
 
14546
15202
  // src/exec-method.ts
14547
15203
  function detectExecutionMethod(input) {
@@ -14580,12 +15236,12 @@ function describeSelfUpdate(method) {
14580
15236
  }
14581
15237
  function runInherit(cmd, args) {
14582
15238
  return new Promise((resolveP, rejectP) => {
14583
- const child = spawn4(cmd, args, { stdio: "inherit" });
15239
+ const child = spawn5(cmd, args, { stdio: "inherit" });
14584
15240
  child.on("error", rejectP);
14585
15241
  child.on("close", (code) => resolveP(code ?? 0));
14586
15242
  });
14587
15243
  }
14588
- var updateCommand = new Command48("self-update").description(
15244
+ var updateCommand = new Command49("self-update").description(
14589
15245
  "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"
14590
15246
  ).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) => {
14591
15247
  try {
@@ -14701,8 +15357,8 @@ var updateCommand = new Command48("self-update").description(
14701
15357
 
14702
15358
  // src/commands/url.ts
14703
15359
  import { spawnSync as spawnSync8 } from "child_process";
14704
- import { log as log48 } from "@clack/prompts";
14705
- import { Command as Command49 } from "commander";
15360
+ import { log as log49 } from "@clack/prompts";
15361
+ import { Command as Command50 } from "commander";
14706
15362
  var SIGNED_URL_TTL_MIN2 = 1;
14707
15363
  var SIGNED_URL_TTL_MAX2 = 86400;
14708
15364
  function parseTtlOrExit2(raw) {
@@ -14715,7 +15371,7 @@ function parseTtlOrExit2(raw) {
14715
15371
  }
14716
15372
  return n;
14717
15373
  }
14718
- var urlCommand = new Command49("url").description(
15374
+ var urlCommand = new Command50("url").description(
14719
15375
  "Open a box's web app URL in the browser, even when no service declares `expose:` (auto-unpause/start)"
14720
15376
  ).argument(
14721
15377
  "[box]",
@@ -14734,10 +15390,10 @@ var urlCommand = new Command49("url").description(
14734
15390
  if (provider === "docker") {
14735
15391
  const insp = await inspectBox(box.id);
14736
15392
  if (insp.state === "paused") {
14737
- log48.info("box is paused; unpausing");
15393
+ log49.info("box is paused; unpausing");
14738
15394
  await unpauseBox(box.id);
14739
15395
  } else if (insp.state === "stopped") {
14740
- log48.info("box is stopped; starting");
15396
+ log49.info("box is stopped; starting");
14741
15397
  await startBox(box.id);
14742
15398
  } else if (insp.state === "missing") {
14743
15399
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -14766,10 +15422,10 @@ var urlCommand = new Command49("url").description(
14766
15422
  const p = await providerForBox(box);
14767
15423
  const state = await p.probeState(box);
14768
15424
  if (state === "paused") {
14769
- log48.info("box is paused; resuming");
15425
+ log49.info("box is paused; resuming");
14770
15426
  await p.resume(box);
14771
15427
  } else if (state === "stopped") {
14772
- log48.info("box is stopped; starting");
15428
+ log49.info("box is stopped; starting");
14773
15429
  await p.start(box);
14774
15430
  } else if (state === "missing") {
14775
15431
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -14793,9 +15449,9 @@ var urlCommand = new Command49("url").description(
14793
15449
  });
14794
15450
 
14795
15451
  // src/commands/wait.ts
14796
- import { log as log49 } from "@clack/prompts";
14797
- import { Command as Command50 } from "commander";
14798
- var waitCommand = new Command50("wait").description("Block until the box reports all autostart units ready").argument(
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(
14799
15455
  "[box]",
14800
15456
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14801
15457
  ).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) => {
@@ -14811,7 +15467,7 @@ var waitCommand = new Command50("wait").description("Block until the box reports
14811
15467
  try {
14812
15468
  parsed = JSON.parse(proc.stdout);
14813
15469
  } catch {
14814
- log49.error(`agentbox-ctl wait-ready failed: ${proc.stderr || proc.stdout}`);
15470
+ log50.error(`agentbox-ctl wait-ready failed: ${proc.stderr || proc.stdout}`);
14815
15471
  process.exit(1);
14816
15472
  }
14817
15473
  if (opts.json) {
@@ -14850,7 +15506,7 @@ function rewriteProviderPrefix(argv2) {
14850
15506
  process.env.DOCKER_CLI_HINTS ??= "false";
14851
15507
  process.env.AGENTBOX_CLI_VERSION = AGENTBOX_VERSION;
14852
15508
  process.env.AGENTBOX_CLI_COMMIT = AGENTBOX_COMMIT;
14853
- var program = new Command51();
15509
+ var program = new Command52();
14854
15510
  program.name("agentbox").description("Launch coding agents in isolated sandboxes").version(AGENTBOX_VERSION);
14855
15511
  program.enablePositionalOptions();
14856
15512
  program.addCommand(createCommand);
@@ -14887,6 +15543,7 @@ program.addCommand(configCommand);
14887
15543
  program.addCommand(queueCommand);
14888
15544
  program.addCommand(relayCommand);
14889
15545
  program.addCommand(runQueuedJobCommand, { hidden: true });
15546
+ program.addCommand(claudeLoginWorkerCommand, { hidden: true });
14890
15547
  program.addCommand(herdrCommand, { hidden: true });
14891
15548
  program.addCommand(daytonaCommand);
14892
15549
  program.addCommand(hetznerCommand);
@@ -14906,6 +15563,7 @@ var FIRST_RUN_EXEMPT = /* @__PURE__ */ new Set([
14906
15563
  "help",
14907
15564
  "relay",
14908
15565
  "_run-queued-job",
15566
+ "_claude-login-worker",
14909
15567
  "drive",
14910
15568
  "screen"
14911
15569
  ]);