@madarco/agentbox 0.19.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/{_cloud-attach-YM2KOWHO.js → _cloud-attach-MH7NKIZY.js} +7 -5
  3. package/dist/{chunk-SPUUOEW2.js → chunk-3465NDRZ.js} +98 -9
  4. package/dist/chunk-3465NDRZ.js.map +1 -0
  5. package/dist/{chunk-JK5V4OLT.js → chunk-4ATVA3RM.js} +194 -34
  6. package/dist/chunk-4ATVA3RM.js.map +1 -0
  7. package/dist/{chunk-Y6PUCLOE.js → chunk-52LKNUY7.js} +5 -2
  8. package/dist/chunk-52LKNUY7.js.map +1 -0
  9. package/dist/{chunk-A5OFRJDI.js → chunk-5N7GA2X7.js} +133 -97
  10. package/dist/chunk-5N7GA2X7.js.map +1 -0
  11. package/dist/{dist-EKSNZHDY.js → dist-AJWL4WLW.js} +8 -2
  12. package/dist/{dist-VQSZVBT3.js → dist-CTTTHG6U.js} +5 -4
  13. package/dist/{dist-VQSZVBT3.js.map → dist-CTTTHG6U.js.map} +1 -1
  14. package/dist/{dist-U2BHTWG4.js → dist-G5PDFWKH.js} +10 -6
  15. package/dist/dist-G5PDFWKH.js.map +1 -0
  16. package/dist/{dist-FTCDWRAL.js → dist-LUEH7MER.js} +3 -3
  17. package/dist/dist-LUEH7MER.js.map +1 -0
  18. package/dist/{dist-PRDYMXCX.js → dist-T3JIYHCA.js} +3 -3
  19. package/dist/index.js +789 -291
  20. package/dist/index.js.map +1 -1
  21. package/package.json +6 -6
  22. package/runtime/docker/Dockerfile.box +13 -0
  23. package/runtime/docker/packages/ctl/dist/bin.cjs +122 -62
  24. package/runtime/docker/packages/sandbox-docker/scripts/claude-managed-settings.json +4 -4
  25. package/runtime/e2b/agentbox-dockerd-start +145 -0
  26. package/runtime/e2b/attach-helper.cjs +27 -3
  27. package/runtime/e2b/claude-managed-settings.json +4 -4
  28. package/runtime/e2b/ctl.cjs +122 -62
  29. package/runtime/e2b/scripts/build-template.sh +32 -5
  30. package/runtime/hetzner/claude-managed-settings.json +4 -4
  31. package/runtime/hetzner/ctl.cjs +122 -62
  32. package/runtime/hetzner/scripts/install-box.sh +9 -0
  33. package/runtime/relay/bin.cjs +6 -0
  34. package/runtime/vercel/claude-managed-settings.json +4 -4
  35. package/runtime/vercel/ctl.cjs +122 -62
  36. package/runtime/vercel/scripts/provision.sh +20 -0
  37. package/share/host-skills/agentbox/SKILL.md +2 -2
  38. package/share/host-skills/agentbox-info/SKILL.md +6 -6
  39. package/share/host-skills/codex/agentbox.md +2 -2
  40. package/share/host-skills/opencode/agentbox.md +2 -2
  41. package/dist/chunk-A5OFRJDI.js.map +0 -1
  42. package/dist/chunk-JK5V4OLT.js.map +0 -1
  43. package/dist/chunk-SPUUOEW2.js.map +0 -1
  44. package/dist/chunk-Y6PUCLOE.js.map +0 -1
  45. package/dist/dist-FTCDWRAL.js.map +0 -1
  46. package/dist/dist-U2BHTWG4.js.map +0 -1
  47. /package/dist/{_cloud-attach-YM2KOWHO.js.map → _cloud-attach-MH7NKIZY.js.map} +0 -0
  48. /package/dist/{dist-EKSNZHDY.js.map → dist-AJWL4WLW.js.map} +0 -0
  49. /package/dist/{dist-PRDYMXCX.js.map → dist-T3JIYHCA.js.map} +0 -0
package/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-JK5V4OLT.js";
41
+ } from "./chunk-4ATVA3RM.js";
38
42
  import {
39
43
  daytonaBackend,
40
44
  ensureDaytonaCredentials,
@@ -69,7 +73,7 @@ import {
69
73
  readE2bCredStatus,
70
74
  readPreparedState as readPreparedState3,
71
75
  secretsPath as secretsPath4
72
- } from "./chunk-Y6PUCLOE.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-SPUUOEW2.js";
86
+ } from "./chunk-3465NDRZ.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-A5OFRJDI.js";
243
+ } from "./chunk-5N7GA2X7.js";
239
244
  import {
240
245
  AmbiguousBoxError,
241
246
  BoxNotFoundError,
@@ -261,11 +266,11 @@ import {
261
266
  } from "./chunk-WJFZJZIM.js";
262
267
 
263
268
  // src/version.ts
264
- var AGENTBOX_VERSION = true ? "0.19.0" : "0.0.0-dev";
265
- var AGENTBOX_COMMIT = true ? "e1a69779a" : "dev";
269
+ var AGENTBOX_VERSION = true ? "0.20.1" : "0.0.0-dev";
270
+ var AGENTBOX_COMMIT = true ? "5c78d7dfd" : "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() {
@@ -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
 
@@ -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;
@@ -2780,13 +2779,13 @@ import { basename as basename2 } from "path";
2780
2779
  async function cloudBackendForProvider(provider) {
2781
2780
  switch (provider) {
2782
2781
  case "daytona":
2783
- return (await import("./dist-FTCDWRAL.js")).daytonaBackend;
2782
+ return (await import("./dist-LUEH7MER.js")).daytonaBackend;
2784
2783
  case "hetzner":
2785
- return (await import("./dist-PRDYMXCX.js")).hetznerBackend;
2784
+ return (await import("./dist-T3JIYHCA.js")).hetznerBackend;
2786
2785
  case "vercel":
2787
- return (await import("./dist-VQSZVBT3.js")).vercelBackend;
2786
+ return (await import("./dist-CTTTHG6U.js")).vercelBackend;
2788
2787
  case "e2b":
2789
- return (await import("./dist-U2BHTWG4.js")).e2bBackend;
2788
+ return (await import("./dist-G5PDFWKH.js")).e2bBackend;
2790
2789
  default:
2791
2790
  return null;
2792
2791
  }
@@ -2794,13 +2793,13 @@ async function cloudBackendForProvider(provider) {
2794
2793
  async function currentCloudBaseFingerprintLive(provider) {
2795
2794
  switch (provider) {
2796
2795
  case "daytona":
2797
- return (await import("./dist-FTCDWRAL.js")).currentDaytonaBaseFingerprintLive();
2796
+ return (await import("./dist-LUEH7MER.js")).currentDaytonaBaseFingerprintLive();
2798
2797
  case "hetzner":
2799
- return (await import("./dist-PRDYMXCX.js")).currentHetznerBaseFingerprintLive();
2798
+ return (await import("./dist-T3JIYHCA.js")).currentHetznerBaseFingerprintLive();
2800
2799
  case "vercel":
2801
- return (await import("./dist-VQSZVBT3.js")).currentVercelBaseFingerprintLive();
2800
+ return (await import("./dist-CTTTHG6U.js")).currentVercelBaseFingerprintLive();
2802
2801
  case "e2b":
2803
- return (await import("./dist-U2BHTWG4.js")).currentE2bBaseFingerprintLive();
2802
+ return (await import("./dist-G5PDFWKH.js")).currentE2bBaseFingerprintLive();
2804
2803
  default:
2805
2804
  return void 0;
2806
2805
  }
@@ -3139,7 +3138,7 @@ async function renderDocker(status) {
3139
3138
  }
3140
3139
  async function daytonaStatus() {
3141
3140
  try {
3142
- const mod = await import("./dist-FTCDWRAL.js");
3141
+ const mod = await import("./dist-LUEH7MER.js");
3143
3142
  return await mod.getDaytonaStatus();
3144
3143
  } catch (err) {
3145
3144
  return {
@@ -3150,7 +3149,7 @@ async function daytonaStatus() {
3150
3149
  }
3151
3150
  async function e2bStatus() {
3152
3151
  try {
3153
- const mod = await import("./dist-U2BHTWG4.js");
3152
+ const mod = await import("./dist-G5PDFWKH.js");
3154
3153
  const cred = mod.readE2bCredStatus();
3155
3154
  if (cred.auth === "none") {
3156
3155
  return { configured: false, reason: "not configured \u2014 run `agentbox e2b login`" };
@@ -3359,6 +3358,159 @@ function describeError(err) {
3359
3358
  return parts.join(" \u2014 ");
3360
3359
  }
3361
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
+
3362
3514
  // src/commands/claude.ts
3363
3515
  function pickCreateOpts(opts) {
3364
3516
  return {
@@ -3446,8 +3598,11 @@ async function runClaudeLoginContainer(image, extraArgs) {
3446
3598
  async function maybeRunClaudeLogin(args) {
3447
3599
  if (!process.stdin.isTTY || args.yes) return;
3448
3600
  if (args.authSource === "host-env") return;
3449
- if (await hostBackupHasCredentials()) return;
3450
- 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)";
3451
3606
  const answer = await confirm({ message, initialValue: true });
3452
3607
  if (!answer) {
3453
3608
  prompt_exports.log.info("Skipped sign-in \u2014 claude will prompt you to /login inside the box.");
@@ -3631,7 +3786,8 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3631
3786
  try {
3632
3787
  await assertAgentCredsAvailable({
3633
3788
  agent: "claude-code",
3634
- image: cfg.effective.box.image
3789
+ image: cfg.effective.box.image,
3790
+ providerName
3635
3791
  });
3636
3792
  } catch (err) {
3637
3793
  if (err instanceof MissingAgentCredsError) {
@@ -3669,6 +3825,22 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3669
3825
  const providerDefault = resolveDefaultCheckpoint(cfg.effective, providerName);
3670
3826
  const checkpointRef = opts.snapshot && opts.snapshot.length > 0 ? opts.snapshot : providerDefault.length > 0 ? providerDefault : void 0;
3671
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
+ }
3672
3844
  if (!isCloud) {
3673
3845
  await maybeRunClaudeLogin({
3674
3846
  image: cfg.effective.box.image,
@@ -3782,7 +3954,10 @@ var claudeCommand = new Command3("claude").description("Create a sandboxed box a
3782
3954
  fromBranch,
3783
3955
  useBranch,
3784
3956
  resyncOnStart: opts.resync,
3785
- projectRoot
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)
3786
3961
  },
3787
3962
  binary: "claude",
3788
3963
  hasSeedPrompt: Boolean(planPrepared) || wiz.action === "launch-with-prompt" && Boolean(wiz.initialPrompt) || Boolean(resumePrepared),
@@ -4073,6 +4248,15 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4073
4248
  onProgress: (line) => s.message(clampSpinnerLine(line))
4074
4249
  });
4075
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
+ }
4076
4260
  if (resumePrepared) {
4077
4261
  s.message("uploading claude session into box");
4078
4262
  try {
@@ -4093,7 +4277,7 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4093
4277
  throw err;
4094
4278
  }
4095
4279
  }
4096
- if (resyncWarning && !resumePrepared) {
4280
+ if (resyncWarning && !resumePrepared && !attachResumed) {
4097
4281
  effectiveArgs = buildPromptArgs("claude-code", resyncWarning, effectiveArgs);
4098
4282
  }
4099
4283
  s.message("starting claude session");
@@ -4104,7 +4288,7 @@ async function startOrAttachClaude(box, claudeArgs, opts, resumePrepared) {
4104
4288
  boxName: box.name
4105
4289
  });
4106
4290
  s.stop(`box ${box.container} ready`);
4107
- if (resyncWarning && resumePrepared) prompt_exports.log.warn(resyncWarning);
4291
+ if (resyncWarning && (resumePrepared || attachResumed)) prompt_exports.log.warn(resyncWarning);
4108
4292
  logPrune(rebuild);
4109
4293
  for (const f of rebuild.failed) {
4110
4294
  prompt_exports.log.warn(
@@ -4145,7 +4329,7 @@ var claudeAttachCommand = new Command3("attach").description(
4145
4329
  });
4146
4330
  return;
4147
4331
  }
4148
- await startOrAttachClaude(box, [], { ...opts, syncConfig: false });
4332
+ await startOrAttachClaude(box, [], { ...opts, syncConfig: false, attachResume: true });
4149
4333
  } catch (err) {
4150
4334
  if (err instanceof ClaudeSessionError) {
4151
4335
  prompt_exports.log.error(err.message);
@@ -4247,18 +4431,146 @@ var claudeStartCommand = new Command3("start").description(
4247
4431
  handleLifecycleError(err);
4248
4432
  }
4249
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
+ }
4250
4550
  var claudeLoginCommand = new Command3("login").description(
4251
- "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>`."
4252
4552
  ).argument(
4253
4553
  "[args...]",
4254
4554
  "extra args forwarded to `claude auth login`; place after `--`, e.g. `agentbox claude login -- --sso`"
4255
- ).action(async (args) => {
4256
- (0, prompt_exports.intro)("Signing in to Claude...");
4257
- if (!process.stdin.isTTY) {
4258
- prompt_exports.log.error("`agentbox claude login` needs an interactive terminal.");
4259
- process.exit(1);
4260
- }
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
+ });
4261
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...");
4262
4574
  const cfg = await loadEffectiveConfig(process.cwd());
4263
4575
  const image = cfg.effective.box.image;
4264
4576
  const s = (0, prompt_exports.spinner)();
@@ -4281,8 +4593,8 @@ claudeCommand.addCommand(claudeLoginCommand);
4281
4593
 
4282
4594
  // src/commands/codex.ts
4283
4595
  import { access } from "fs/promises";
4284
- import { homedir as homedir9 } from "os";
4285
- import { join as join12 } from "path";
4596
+ import { homedir as homedir10 } from "os";
4597
+ import { join as join13 } from "path";
4286
4598
  import { Command as Command4 } from "commander";
4287
4599
  function pickCodexCreateOpts(opts) {
4288
4600
  return {
@@ -4364,7 +4676,10 @@ async function maybeRunCodexLogin(args) {
4364
4676
  s.start("preparing sandbox image");
4365
4677
  await ensureImage(args.image, { onProgress: (line) => s.message(clampSpinnerLine(line)) });
4366
4678
  s.message("preparing codex config");
4367
- 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
+ );
4368
4683
  s.stop("image ready");
4369
4684
  const exitCode = await runCodexLoginContainer(args.image, []);
4370
4685
  if (exitCode !== 0) {
@@ -4375,7 +4690,7 @@ async function maybeRunCodexLogin(args) {
4375
4690
  }
4376
4691
  async function cloudCodexCredAvailable(env = process.env) {
4377
4692
  if ((env["OPENAI_API_KEY"] ?? "").length > 0) return true;
4378
- 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")]) {
4379
4694
  try {
4380
4695
  await access(p);
4381
4696
  return true;
@@ -4399,7 +4714,10 @@ async function maybeRunCloudCodexLogin(args) {
4399
4714
  s.start("preparing sandbox image");
4400
4715
  await ensureImage(args.image, { onProgress: (line) => s.message(clampSpinnerLine(line)) });
4401
4716
  s.message("preparing codex config");
4402
- 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
+ );
4403
4721
  s.stop("image ready");
4404
4722
  const exitCode = await runCodexLoginContainer(args.image, []);
4405
4723
  if (exitCode !== 0) {
@@ -4408,9 +4726,15 @@ async function maybeRunCloudCodexLogin(args) {
4408
4726
  }
4409
4727
  const { copied } = await extractCodexCredentials(SHARED_CODEX_VOLUME, args.image);
4410
4728
  if (copied) prompt_exports.log.success("Signed in to Codex \u2014 saved for future boxes.");
4411
- 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
+ );
4412
4733
  }
4413
- 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(
4414
4738
  "--snapshot <ref>",
4415
4739
  "start from a project checkpoint (see `agentbox checkpoint`); overrides box.defaultCheckpoint"
4416
4740
  ).option("--image <ref>", "override the box image").option("-y, --yes", "skip prompts, accept defaults").option(
@@ -4441,10 +4765,7 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
4441
4765
  ).option(
4442
4766
  "--portless",
4443
4767
  "map the box web app to https://<name>.localhost via the Portless proxy (Docker Desktop)"
4444
- ).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(
4445
- "--provider <name>",
4446
- "sandbox backend: 'docker' (default) or 'daytona' for a cloud box"
4447
- ).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(
4448
4769
  "--from-branch <ref>",
4449
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."
4450
4771
  ).option(
@@ -4517,7 +4838,8 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
4517
4838
  try {
4518
4839
  await assertAgentCredsAvailable({
4519
4840
  agent: "codex",
4520
- image: cfg.effective.box.image
4841
+ image: cfg.effective.box.image,
4842
+ providerName
4521
4843
  });
4522
4844
  } catch (err) {
4523
4845
  if (err instanceof MissingAgentCredsError) {
@@ -4610,7 +4932,9 @@ var codexCommand = new Command4("codex").description("Create a sandboxed box and
4610
4932
  fromBranch,
4611
4933
  useBranch,
4612
4934
  resyncOnStart: opts.resync,
4613
- projectRoot
4935
+ projectRoot,
4936
+ // Per-provider session-lifetime (e2b/vercel timeout); mirrors create.
4937
+ providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective)
4614
4938
  },
4615
4939
  binary: "codex",
4616
4940
  sessionName: cfg.effective.codex.sessionName,
@@ -4837,6 +5161,15 @@ async function startOrAttachCodex(box, codexArgs, opts, resumePrepared) {
4837
5161
  onProgress: (line) => s.message(clampSpinnerLine(line))
4838
5162
  });
4839
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
+ }
4840
5173
  if (resumePrepared) {
4841
5174
  s.message("uploading codex session into box");
4842
5175
  try {
@@ -4857,13 +5190,13 @@ async function startOrAttachCodex(box, codexArgs, opts, resumePrepared) {
4857
5190
  throw err;
4858
5191
  }
4859
5192
  }
4860
- if (resyncWarning && !resumePrepared) {
5193
+ if (resyncWarning && !resumePrepared && !attachResumed) {
4861
5194
  effectiveArgs = buildPromptArgs("codex", resyncWarning, effectiveArgs);
4862
5195
  }
4863
5196
  s.message("starting codex session");
4864
5197
  await startCodexSession({ container: box.container, codexArgs: effectiveArgs, sessionName });
4865
5198
  s.stop(`box ${box.container} ready`);
4866
- if (resyncWarning && resumePrepared) prompt_exports.log.warn(resyncWarning);
5199
+ if (resyncWarning && (resumePrepared || attachResumed)) prompt_exports.log.warn(resyncWarning);
4867
5200
  if (!wantAttach) {
4868
5201
  (0, prompt_exports.outro)(
4869
5202
  `session "${sessionName}" started \u2014 attach with: agentbox codex attach ${reattachRef(box)}`
@@ -4897,7 +5230,7 @@ var codexAttachCommand = new Command4("attach").description(
4897
5230
  });
4898
5231
  return;
4899
5232
  }
4900
- await startOrAttachCodex(box, [], { ...opts, syncConfig: false });
5233
+ await startOrAttachCodex(box, [], { ...opts, syncConfig: false, attachResume: true });
4901
5234
  } catch (err) {
4902
5235
  if (err instanceof CodexSessionError) {
4903
5236
  prompt_exports.log.error(err.message);
@@ -4917,10 +5250,7 @@ var codexStartCommand = new Command4("start").description(
4917
5250
  ).option("--attach-in <mode>", ATTACH_IN_HELP).option("-i, --inline", INLINE_HELP).option("-d, --no-attach", NO_ATTACH_HELP).option(
4918
5251
  "-c, --continue",
4919
5252
  "teleport the most recent host Codex session for this cwd into the box and resume"
4920
- ).option(
4921
- "--resume <id>",
4922
- "teleport the specified host Codex session uuid into the box and resume"
4923
- ).argument(
5253
+ ).option("--resume <id>", "teleport the specified host Codex session uuid into the box and resume").argument(
4924
5254
  "[codex-args...]",
4925
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`"
4926
5256
  ).action(async function(idOrName, codexArgs) {
@@ -5035,8 +5365,8 @@ codexCommand.addCommand(codexLoginCommand);
5035
5365
 
5036
5366
  // src/commands/opencode.ts
5037
5367
  import { access as access2 } from "fs/promises";
5038
- import { homedir as homedir10 } from "os";
5039
- import { join as join13 } from "path";
5368
+ import { homedir as homedir11 } from "os";
5369
+ import { join as join14 } from "path";
5040
5370
  import { Command as Command5 } from "commander";
5041
5371
  function pickOpencodeCreateOpts(opts) {
5042
5372
  return {
@@ -5131,7 +5461,7 @@ async function cloudOpencodeCredAvailable(env = process.env) {
5131
5461
  for (const k of OPENCODE_FORWARDED_ENV_KEYS) {
5132
5462
  if ((env[k] ?? "").length > 0) return true;
5133
5463
  }
5134
- 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")]) {
5135
5465
  try {
5136
5466
  await access2(p);
5137
5467
  return true;
@@ -5255,7 +5585,8 @@ var opencodeCommand = new Command5("opencode").description("Create a sandboxed b
5255
5585
  try {
5256
5586
  await assertAgentCredsAvailable({
5257
5587
  agent: "opencode",
5258
- image: cfg.effective.box.image
5588
+ image: cfg.effective.box.image,
5589
+ providerName
5259
5590
  });
5260
5591
  } catch (err) {
5261
5592
  if (err instanceof MissingAgentCredsError) {
@@ -5348,7 +5679,9 @@ var opencodeCommand = new Command5("opencode").description("Create a sandboxed b
5348
5679
  fromBranch,
5349
5680
  useBranch,
5350
5681
  resyncOnStart: opts.resync,
5351
- projectRoot
5682
+ projectRoot,
5683
+ // Per-provider session-lifetime (e2b/vercel timeout); mirrors create.
5684
+ providerOptions: cloudSizingProviderOptions(provider.name, cfg.effective)
5352
5685
  },
5353
5686
  binary: "opencode",
5354
5687
  sessionName: cfg.effective.opencode.sessionName,
@@ -5821,13 +6154,13 @@ var CLOUD_BACKENDS = ["daytona", "hetzner", "vercel", "e2b"];
5821
6154
  async function cloudProviderFor(backend) {
5822
6155
  switch (backend) {
5823
6156
  case "daytona":
5824
- return (await import("./dist-FTCDWRAL.js")).daytonaProvider;
6157
+ return (await import("./dist-LUEH7MER.js")).daytonaProvider;
5825
6158
  case "hetzner":
5826
- return (await import("./dist-PRDYMXCX.js")).hetznerProvider;
6159
+ return (await import("./dist-T3JIYHCA.js")).hetznerProvider;
5827
6160
  case "vercel":
5828
- return (await import("./dist-VQSZVBT3.js")).vercelProvider;
6161
+ return (await import("./dist-CTTTHG6U.js")).vercelProvider;
5829
6162
  case "e2b":
5830
- return (await import("./dist-U2BHTWG4.js")).e2bProvider;
6163
+ return (await import("./dist-G5PDFWKH.js")).e2bProvider;
5831
6164
  }
5832
6165
  }
5833
6166
  var CHECKPOINT_NOTICE = "Checkpoint in progress \u2014 the box will be unresponsive for a moment";
@@ -6190,16 +6523,16 @@ async function runCloudCheckpointCreate(box, opts) {
6190
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);
6191
6524
 
6192
6525
  // src/commands/code.ts
6193
- import { spawn } from "child_process";
6526
+ import { spawn as spawn2 } from "child_process";
6194
6527
  import { log as log16 } from "@clack/prompts";
6195
6528
  import { Command as Command8, InvalidArgumentError } from "commander";
6196
6529
 
6197
6530
  // src/ssh-config.ts
6198
6531
  import { promises as fs } from "fs";
6199
- import { homedir as homedir11 } from "os";
6200
- import { join as join14 } from "path";
6532
+ import { homedir as homedir12 } from "os";
6533
+ import { join as join15 } from "path";
6201
6534
  function sshConfigPath() {
6202
- return join14(homedir11(), ".ssh", "config");
6535
+ return join15(homedir12(), ".ssh", "config");
6203
6536
  }
6204
6537
  function beginMarker(alias) {
6205
6538
  return `# BEGIN agentbox cloud box ${alias}`;
@@ -6250,7 +6583,7 @@ function buildBlock(opts) {
6250
6583
  }
6251
6584
  async function writeAgentboxSshAlias(opts) {
6252
6585
  const path = sshConfigPath();
6253
- await fs.mkdir(join14(homedir11(), ".ssh"), { recursive: true, mode: 448 });
6586
+ await fs.mkdir(join15(homedir12(), ".ssh"), { recursive: true, mode: 448 });
6254
6587
  const existing = await readConfig();
6255
6588
  const stripped = stripBlock(existing, opts.alias);
6256
6589
  const separator = stripped.length === 0 || stripped.endsWith("\n") ? "" : "\n";
@@ -6481,7 +6814,7 @@ async function launchOne(flavor, folderUri) {
6481
6814
  }
6482
6815
  function spawnCommand(cmd, args) {
6483
6816
  return new Promise((resolve5) => {
6484
- const child = spawn(cmd, args, { stdio: "ignore" });
6817
+ const child = spawn2(cmd, args, { stdio: "ignore" });
6485
6818
  child.once("error", () => resolve5(127));
6486
6819
  child.once("exit", (code) => resolve5(code ?? -1));
6487
6820
  });
@@ -7194,13 +7527,10 @@ var createCommand = new Command11("create").description(
7194
7527
  portless: portlessEnabled,
7195
7528
  portlessStateDir: cfg.effective.portless.stateDir || void 0,
7196
7529
  ...effectiveSize ? { size: effectiveSize } : {},
7197
- // Vercel-only sizing (box.vercelVcpus / vercelTimeoutMs). The cloud
7198
- // scaffold reads these as overrides; other providers ignore them.
7199
- ...provider.name === "vercel" ? {
7200
- vcpus: cfg.effective.box.vercelVcpus,
7201
- timeoutMs: cfg.effective.box.vercelTimeoutMs,
7202
- networkPolicy: cfg.effective.box.vercelNetworkPolicy
7203
- } : {}
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)
7204
7534
  }
7205
7535
  });
7206
7536
  s.stop(`box ${result.record.container} ready`);
@@ -7257,7 +7587,7 @@ var createCommand = new Command11("create").description(
7257
7587
  }
7258
7588
  outro5("done");
7259
7589
  if (attachClaudeAfter) {
7260
- const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-YM2KOWHO.js");
7590
+ const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-MH7NKIZY.js");
7261
7591
  await cloudAgentAttach2({
7262
7592
  box: result.record,
7263
7593
  binary: "claude",
@@ -7292,7 +7622,7 @@ var createCommand = new Command11("create").description(
7292
7622
  });
7293
7623
 
7294
7624
  // src/commands/dashboard.ts
7295
- import { spawn as spawn2 } from "child_process";
7625
+ import { spawn as spawn3 } from "child_process";
7296
7626
  import { log as log19 } from "@clack/prompts";
7297
7627
  import { Command as Command12 } from "commander";
7298
7628
 
@@ -7635,7 +7965,7 @@ var PtySession = class {
7635
7965
  // Reused per cell read — valid only until the next cell() call (the renderer
7636
7966
  // consumes it synchronously within composeRow).
7637
7967
  out = { ...BLANK };
7638
- 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) {
7639
7969
  this.boxId = boxId;
7640
7970
  this.keepAlive = keepAlive;
7641
7971
  this.mode = mode;
@@ -7647,11 +7977,14 @@ var PtySession = class {
7647
7977
  convertEol: false
7648
7978
  });
7649
7979
  this.cleanup = cleanup;
7650
- this.pty = spawn5(command, args, {
7980
+ this.pty = spawn6(command, args, {
7651
7981
  name: "xterm-256color",
7652
7982
  cols,
7653
7983
  rows,
7654
- 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
7655
7988
  });
7656
7989
  this.pty.onData((d) => {
7657
7990
  this.term.write(d, () => {
@@ -8145,7 +8478,8 @@ var Compositor = class {
8145
8478
  Math.max(1, this.layout.right.h),
8146
8479
  () => this.scheduleRender(),
8147
8480
  (id) => this.onSessionExit(id),
8148
- target.cleanup
8481
+ target.cleanup,
8482
+ target.env
8149
8483
  );
8150
8484
  if (keepAlive) {
8151
8485
  const prev = this.liveSessions.get(boxId);
@@ -8932,6 +9266,7 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
8932
9266
  kind: "attach",
8933
9267
  command: spec.argv[0],
8934
9268
  args: spec.argv.slice(1),
9269
+ ...spec.env ? { env: spec.env } : {},
8935
9270
  ...spec.cleanup ? { cleanup: spec.cleanup } : {},
8936
9271
  mode: which,
8937
9272
  ...providerSupportsKeepAlive(record.provider) ? { keepAlive: true } : {}
@@ -8941,12 +9276,7 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
8941
9276
  const probeCloudSessions = async (record) => {
8942
9277
  try {
8943
9278
  const provider = await providerForBox(record);
8944
- const r = await provider.exec(record, [
8945
- "tmux",
8946
- "list-sessions",
8947
- "-F",
8948
- "#{session_name}"
8949
- ]);
9279
+ const r = await provider.exec(record, ["tmux", "list-sessions", "-F", "#{session_name}"]);
8950
9280
  if (r.exitCode !== 0) return /* @__PURE__ */ new Set();
8951
9281
  return new Set(
8952
9282
  r.stdout.split("\n").map((s) => s.trim()).filter((s) => s.length > 0)
@@ -9111,7 +9441,7 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9111
9441
  };
9112
9442
  };
9113
9443
  const detach = (cmd, args) => {
9114
- spawn2(cmd, args, { detached: true, stdio: "ignore" }).unref();
9444
+ spawn3(cmd, args, { detached: true, stdio: "ignore" }).unref();
9115
9445
  };
9116
9446
  const findEndpointUrl = async (boxId, kind) => {
9117
9447
  const box = (await listBoxes()).find((b) => b.id === boxId);
@@ -9165,14 +9495,20 @@ var dashboardCommand = new Command12("dashboard").description("Box list + the se
9165
9495
  const box = (await listBoxes()).find((b) => b.id === boxId);
9166
9496
  if (!box) throw new Error("box not found");
9167
9497
  if (isCloudBox(box)) {
9168
- const record = await loadBoxRecord(boxId);
9169
- const provider = await providerForBox(record);
9170
- if (box.state === "paused") await provider.resume(record);
9171
- 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);
9172
9507
  return;
9173
9508
  }
9174
- if (box.state === "paused") await unpauseBox(box.id);
9175
- else await startBox(box.id);
9509
+ await startBox(box.id);
9510
+ const record = await loadBoxRecord(boxId);
9511
+ await restoreAgentSessions(record, await providerForBox(record));
9176
9512
  };
9177
9513
  const pauseBoxAction = async (boxId) => {
9178
9514
  const record = await loadBoxRecord(boxId);
@@ -10329,7 +10665,7 @@ var drivePromptCommand = new Command25("prompt").description('Type text into the
10329
10665
  const session = await resolveDriveSession(provider, box, opts.session);
10330
10666
  const delay = opts.delay !== void 0 ? parsePositiveInt2(opts.delay, "--delay") : PROMPT_ENTER_DELAY_MS;
10331
10667
  await sendLiteral(provider, box, session.name, text2);
10332
- if (delay > 0) await sleep3(delay);
10668
+ if (delay > 0) await sleep4(delay);
10333
10669
  await sendKey(provider, box, session.name, "Enter");
10334
10670
  } catch (err) {
10335
10671
  handleDriveError(err);
@@ -10355,7 +10691,7 @@ var driveWaitCommand = new Command25("wait").description("Block until --text app
10355
10691
  }
10356
10692
  return;
10357
10693
  }
10358
- await sleep3(POLL_INTERVAL_MS2);
10694
+ await sleep4(POLL_INTERVAL_MS2);
10359
10695
  }
10360
10696
  const elapsedMs = Date.now() - start;
10361
10697
  if (opts.json === true) {
@@ -10415,16 +10751,16 @@ function parsePositiveInt2(raw, label) {
10415
10751
  }
10416
10752
  return n;
10417
10753
  }
10418
- function sleep3(ms) {
10754
+ function sleep4(ms) {
10419
10755
  return new Promise((r) => setTimeout(r, ms));
10420
10756
  }
10421
10757
 
10422
10758
  // src/commands/fork.ts
10423
10759
  import { log as log32 } from "@clack/prompts";
10424
10760
  import { Command as Command26 } from "commander";
10425
- import { existsSync as existsSync5, readdirSync, statSync } from "fs";
10426
- import { homedir as homedir12 } from "os";
10427
- 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";
10428
10764
  var FORK_AGENTS = ["claude", "codex", "opencode"];
10429
10765
  var FORK_PROVIDERS = ["docker", "daytona", "hetzner", "vercel", "e2b"];
10430
10766
  function resolveForkProvider(positional, flag) {
@@ -10464,12 +10800,12 @@ function resolveSessionArgs(agent, opts) {
10464
10800
  }
10465
10801
  if (opts.session) return ["--resume", opts.session];
10466
10802
  if (agent === "codex") return ["--continue"];
10467
- const dir = join15(homedir12(), ".claude", "projects", encodeClaudeProjectsDir(opts.workspace));
10468
- if (!existsSync5(dir)) return ["--continue"];
10803
+ const dir = join16(homedir13(), ".claude", "projects", encodeClaudeProjectsDir(opts.workspace));
10804
+ if (!existsSync6(dir)) return ["--continue"];
10469
10805
  const now = Date.now();
10470
- const recent = readdirSync(dir).filter((f) => f.endsWith(".jsonl")).map((f) => {
10806
+ const recent = readdirSync2(dir).filter((f) => f.endsWith(".jsonl")).map((f) => {
10471
10807
  try {
10472
- return statSync(join15(dir, f)).mtimeMs;
10808
+ return statSync(join16(dir, f)).mtimeMs;
10473
10809
  } catch {
10474
10810
  return 0;
10475
10811
  }
@@ -10555,13 +10891,13 @@ var forkCommand = new Command26("fork").description(
10555
10891
  if (agent === "claude") {
10556
10892
  const envId = (process.env.CLAUDE_CODE_SESSION_ID ?? process.env.CLAUDE_SESSION_ID ?? "").trim();
10557
10893
  if (envId) {
10558
- const dir = join15(
10559
- homedir12(),
10894
+ const dir = join16(
10895
+ homedir13(),
10560
10896
  ".claude",
10561
10897
  "projects",
10562
10898
  encodeClaudeProjectsDir(opts.workspace)
10563
10899
  );
10564
- if (existsSync5(join15(dir, `${envId}.jsonl`))) opts.session = envId;
10900
+ if (existsSync6(join16(dir, `${envId}.jsonl`))) opts.session = envId;
10565
10901
  }
10566
10902
  } else if (agent === "codex") {
10567
10903
  const envId = (process.env.CODEX_THREAD_ID ?? "").trim();
@@ -10597,22 +10933,22 @@ var forkCommand = new Command26("fork").description(
10597
10933
  import { Command as Command29 } from "commander";
10598
10934
  import { execa as execa5 } from "execa";
10599
10935
  import {
10600
- existsSync as existsSync10,
10936
+ existsSync as existsSync11,
10601
10937
  lstatSync,
10602
- mkdirSync as mkdirSync8,
10603
- readFileSync as readFileSync4,
10604
- rmSync,
10938
+ mkdirSync as mkdirSync9,
10939
+ readFileSync as readFileSync5,
10940
+ rmSync as rmSync2,
10605
10941
  symlinkSync as symlinkSync2,
10606
- writeFileSync as writeFileSync7
10942
+ writeFileSync as writeFileSync8
10607
10943
  } from "fs";
10608
- import { homedir as homedir18 } from "os";
10609
- 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";
10610
10946
  import { fileURLToPath } from "url";
10611
10947
 
10612
10948
  // src/lib/doctor-checks.ts
10613
- import { accessSync, constants as fsConstants, mkdirSync as mkdirSync3 } from "fs";
10614
- import { homedir as homedir13 } from "os";
10615
- 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";
10616
10952
  import { execa as execa4 } from "execa";
10617
10953
  var ALL_PROVIDERS = ["docker", "daytona", "hetzner", "vercel", "e2b"];
10618
10954
  var NODE_MIN_MAJOR = 20;
@@ -10660,9 +10996,9 @@ function checkPlatform() {
10660
10996
  };
10661
10997
  }
10662
10998
  function checkAgentboxHome() {
10663
- const dir = join16(homedir13(), ".agentbox");
10999
+ const dir = join17(homedir14(), ".agentbox");
10664
11000
  try {
10665
- mkdirSync3(dir, { recursive: true });
11001
+ mkdirSync4(dir, { recursive: true });
10666
11002
  accessSync(dir, fsConstants.W_OK);
10667
11003
  return { label: "~/.agentbox", status: "ok", detail: dir };
10668
11004
  } catch (err) {
@@ -10732,7 +11068,7 @@ async function dockerChecks() {
10732
11068
  ];
10733
11069
  }
10734
11070
  const daemonRes = { label: "docker daemon", status: "ok", detail: "reachable" };
10735
- const mod = await import("./dist-EKSNZHDY.js");
11071
+ const mod = await import("./dist-AJWL4WLW.js");
10736
11072
  let imgRes;
10737
11073
  try {
10738
11074
  const img = await mod.imageInfo(mod.DEFAULT_BOX_IMAGE);
@@ -10763,7 +11099,7 @@ async function dockerChecks() {
10763
11099
  }
10764
11100
  async function daytonaChecks() {
10765
11101
  try {
10766
- const mod = await import("./dist-FTCDWRAL.js");
11102
+ const mod = await import("./dist-LUEH7MER.js");
10767
11103
  const status = await mod.getDaytonaStatus();
10768
11104
  if (!status.configured) {
10769
11105
  return [
@@ -10799,7 +11135,7 @@ async function daytonaChecks() {
10799
11135
  }
10800
11136
  async function hetznerChecks() {
10801
11137
  try {
10802
- const mod = await import("./dist-PRDYMXCX.js");
11138
+ const mod = await import("./dist-T3JIYHCA.js");
10803
11139
  const cred = mod.readHetznerCredStatus();
10804
11140
  const credRes = cred.source === "none" ? {
10805
11141
  label: "credentials",
@@ -10831,7 +11167,7 @@ async function hetznerChecks() {
10831
11167
  }
10832
11168
  async function vercelChecks() {
10833
11169
  try {
10834
- const mod = await import("./dist-VQSZVBT3.js");
11170
+ const mod = await import("./dist-CTTTHG6U.js");
10835
11171
  const cred = mod.readVercelCredStatus();
10836
11172
  const credRes = cred.auth === "none" ? {
10837
11173
  label: "credentials",
@@ -10867,7 +11203,7 @@ async function vercelChecks() {
10867
11203
  }
10868
11204
  async function e2bChecks() {
10869
11205
  try {
10870
- const mod = await import("./dist-U2BHTWG4.js");
11206
+ const mod = await import("./dist-G5PDFWKH.js");
10871
11207
  const cred = mod.readE2bCredStatus();
10872
11208
  const credRes = cred.auth === "none" ? {
10873
11209
  label: "credentials",
@@ -11102,44 +11438,44 @@ function formatDetailed(groups) {
11102
11438
  }
11103
11439
 
11104
11440
  // src/lib/first-run.ts
11105
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "fs";
11106
- import { homedir as homedir14 } from "os";
11107
- 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";
11108
11444
  var MARKER_VERSION = 1;
11109
11445
  function setupMarkerPath() {
11110
- return join17(homedir14(), ".agentbox", "setup-complete.json");
11446
+ return join18(homedir15(), ".agentbox", "setup-complete.json");
11111
11447
  }
11112
11448
  function isFirstRun() {
11113
- return !existsSync6(setupMarkerPath());
11449
+ return !existsSync7(setupMarkerPath());
11114
11450
  }
11115
11451
  function markSetupComplete(provider) {
11116
11452
  const path = setupMarkerPath();
11117
- mkdirSync4(dirname(path), { recursive: true });
11453
+ mkdirSync5(dirname(path), { recursive: true });
11118
11454
  const body = {
11119
11455
  version: MARKER_VERSION,
11120
11456
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
11121
11457
  provider
11122
11458
  };
11123
- writeFileSync3(path, JSON.stringify(body, null, 2) + "\n");
11459
+ writeFileSync4(path, JSON.stringify(body, null, 2) + "\n");
11124
11460
  }
11125
11461
 
11126
11462
  // src/lib/star-prompt.ts
11127
11463
  import { spawnSync as spawnSync3 } from "child_process";
11128
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync, writeFileSync as writeFileSync4 } from "fs";
11129
- import { homedir as homedir15 } from "os";
11130
- 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";
11131
11467
  var STATE_VERSION = 1;
11132
11468
  var REPO = "madarco/agentbox";
11133
11469
  var REPO_URL = `https://github.com/${REPO}`;
11134
11470
  var DEFAULT_STATE = { version: STATE_VERSION, installCount: 0, starred: false };
11135
11471
  function starStatePath() {
11136
- return join18(homedir15(), ".agentbox", "star-prompt.json");
11472
+ return join19(homedir16(), ".agentbox", "star-prompt.json");
11137
11473
  }
11138
11474
  function readStarState() {
11139
11475
  const path = starStatePath();
11140
- if (!existsSync7(path)) return { ...DEFAULT_STATE };
11476
+ if (!existsSync8(path)) return { ...DEFAULT_STATE };
11141
11477
  try {
11142
- const parsed = JSON.parse(readFileSync(path, "utf8"));
11478
+ const parsed = JSON.parse(readFileSync2(path, "utf8"));
11143
11479
  return {
11144
11480
  version: STATE_VERSION,
11145
11481
  installCount: typeof parsed.installCount === "number" ? parsed.installCount : 0,
@@ -11151,8 +11487,8 @@ function readStarState() {
11151
11487
  }
11152
11488
  function writeStarState(state) {
11153
11489
  const path = starStatePath();
11154
- mkdirSync5(dirname2(path), { recursive: true });
11155
- writeFileSync4(path, JSON.stringify(state, null, 2) + "\n");
11490
+ mkdirSync6(dirname2(path), { recursive: true });
11491
+ writeFileSync5(path, JSON.stringify(state, null, 2) + "\n");
11156
11492
  }
11157
11493
  function ghReady() {
11158
11494
  const r = spawnSync3("gh", ["auth", "status"], { stdio: "ignore" });
@@ -11200,14 +11536,14 @@ async function maybePromptStar(opts) {
11200
11536
  // src/commands/install-cmux.ts
11201
11537
  import { intro as intro7, log as log34, note as note2, outro as outro6 } from "@clack/prompts";
11202
11538
  import { Command as Command27 } from "commander";
11203
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync5 } from "fs";
11204
- import { homedir as homedir16 } from "os";
11205
- 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";
11206
11542
  var CONTROL_ID = "agentbox";
11207
11543
  function cmuxDockPath(env = process.env) {
11208
11544
  const xdg = env["XDG_CONFIG_HOME"];
11209
- const base = xdg && xdg.length > 0 ? xdg : join19(homedir16(), ".config");
11210
- return join19(base, "cmux", "dock.json");
11545
+ const base = xdg && xdg.length > 0 ? xdg : join20(homedir17(), ".config");
11546
+ return join20(base, "cmux", "dock.json");
11211
11547
  }
11212
11548
  function upsertAgentboxControl(doc, opts) {
11213
11549
  const controls = Array.isArray(doc.controls) ? doc.controls : [];
@@ -11237,8 +11573,8 @@ var installCmuxCommand = new Command27("cmux").description(
11237
11573
  height: parseHeight(opts.height)
11238
11574
  };
11239
11575
  let doc = { controls: [] };
11240
- if (existsSync8(dockPath)) {
11241
- const raw = readFileSync2(dockPath, "utf8");
11576
+ if (existsSync9(dockPath)) {
11577
+ const raw = readFileSync3(dockPath, "utf8");
11242
11578
  try {
11243
11579
  const parsed = JSON.parse(raw);
11244
11580
  if (parsed && typeof parsed === "object") doc = parsed;
@@ -11251,7 +11587,7 @@ fix it by hand, or pass --force to back it up and write a fresh one`
11251
11587
  process.exit(1);
11252
11588
  }
11253
11589
  if (!opts.dryRun) {
11254
- renameSync2(dockPath, dockPath + ".bak");
11590
+ renameSync3(dockPath, dockPath + ".bak");
11255
11591
  log34.warn(`backed up unparseable dock config to ${dockPath}.bak`);
11256
11592
  }
11257
11593
  doc = { controls: [] };
@@ -11265,8 +11601,8 @@ fix it by hand, or pass --force to back it up and write a fresh one`
11265
11601
  outro6(`would write ${dockPath}`);
11266
11602
  return;
11267
11603
  }
11268
- mkdirSync6(dirname3(dockPath), { recursive: true });
11269
- writeFileSync5(dockPath, json);
11604
+ mkdirSync7(dirname3(dockPath), { recursive: true });
11605
+ writeFileSync6(dockPath, json);
11270
11606
  intro7("AgentBox cmux dock panel");
11271
11607
  note2(
11272
11608
  `Wrote ${dockPath}
@@ -11284,20 +11620,20 @@ To see it:
11284
11620
  import { intro as intro8, log as log35, note as note3, outro as outro7 } from "@clack/prompts";
11285
11621
  import { Command as Command28, Option } from "commander";
11286
11622
  import { spawnSync as spawnSync4 } from "child_process";
11287
- import { chmodSync, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync6 } from "fs";
11288
- import { homedir as homedir17 } from "os";
11289
- import { dirname as dirname4, join as join20 } from "path";
11290
- 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";
11291
11627
  function herdrPluginDir(env = process.env) {
11292
- const home = env["AGENTBOX_HOME"] ?? join20(homedir17(), ".agentbox");
11293
- return join20(home, "herdr", "plugin");
11628
+ const home = env["AGENTBOX_HOME"] ?? join21(homedir18(), ".agentbox");
11629
+ return join21(home, "herdr", "plugin");
11294
11630
  }
11295
11631
  function herdrConfigPath(env = process.env) {
11296
11632
  const override = env["HERDR_CONFIG_PATH"];
11297
11633
  if (override && override.length > 0) return override;
11298
11634
  const xdg = env["XDG_CONFIG_HOME"];
11299
- const base = xdg && xdg.length > 0 ? xdg : join20(homedir17(), ".config");
11300
- return join20(base, "herdr", "config.toml");
11635
+ const base = xdg && xdg.length > 0 ? xdg : join21(homedir18(), ".config");
11636
+ return join21(base, "herdr", "config.toml");
11301
11637
  }
11302
11638
  function herdrBinary(env = process.env) {
11303
11639
  const b = env["HERDR_BIN_PATH"];
@@ -11305,7 +11641,7 @@ function herdrBinary(env = process.env) {
11305
11641
  }
11306
11642
  function buildHerdrManifest() {
11307
11643
  return `# AgentBox Herdr plugin (https://herdr.dev/docs/plugins).
11308
- # Install: herdr plugin install madarco/agentbox/herdr-plugin
11644
+ # Install: herdr plugin install madarco/agentbox
11309
11645
  # Or, with the AgentBox CLI already installed: agentbox install herdr
11310
11646
  #
11311
11647
  # agentbox commands route through ./agentbox-shim.sh, written at install time
@@ -11413,15 +11749,15 @@ function escapeRe(s) {
11413
11749
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11414
11750
  }
11415
11751
  function writeShim(dir) {
11416
- const p = join20(dir, "agentbox-shim.sh");
11417
- 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"));
11418
11754
  chmodSync(p, 493);
11419
11755
  }
11420
11756
  function applyKeybindings() {
11421
11757
  const cfg = herdrConfigPath();
11422
- const existing = existsSync9(cfg) ? readFileSync3(cfg, "utf8") : "";
11423
- mkdirSync7(dirname4(cfg), { recursive: true });
11424
- 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()));
11425
11761
  spawnSync4(herdrBinary(), ["server", "reload-config"], { stdio: "ignore" });
11426
11762
  return cfg;
11427
11763
  }
@@ -11438,18 +11774,18 @@ var installHerdrCommand = new Command28("herdr").description(
11438
11774
  return;
11439
11775
  }
11440
11776
  const dir = herdrPluginDir();
11441
- const file = join20(dir, "herdr-plugin.toml");
11777
+ const file = join21(dir, "herdr-plugin.toml");
11442
11778
  const cfgPath = herdrConfigPath();
11443
11779
  if (opts.dryRun) {
11444
11780
  intro8("agentbox install herdr (dry run)");
11445
11781
  process.stdout.write(`# --- ${file} ---
11446
11782
  ${buildHerdrManifest()}
11447
11783
  `);
11448
- process.stdout.write(`# --- ${join20(dir, "build.sh")} ---
11784
+ process.stdout.write(`# --- ${join21(dir, "build.sh")} ---
11449
11785
  ${herdrBuildScript()}
11450
11786
  `);
11451
11787
  process.stdout.write(
11452
- `# --- ${join20(dir, "agentbox-shim.sh")} ---
11788
+ `# --- ${join21(dir, "agentbox-shim.sh")} ---
11453
11789
  ${herdrShimContent(process.execPath, process.argv[1] ?? "agentbox")}
11454
11790
  `
11455
11791
  );
@@ -11459,10 +11795,10 @@ ${herdrKeybindingsBlock()}
11459
11795
  outro7(`would write ${dir}/*, edit ${cfgPath}, and run \`herdr plugin link ${dir}\``);
11460
11796
  return;
11461
11797
  }
11462
- mkdirSync7(dir, { recursive: true });
11463
- writeFileSync6(file, buildHerdrManifest());
11464
- const buildPath = join20(dir, "build.sh");
11465
- writeFileSync6(buildPath, herdrBuildScript());
11798
+ mkdirSync8(dir, { recursive: true });
11799
+ writeFileSync7(file, buildHerdrManifest());
11800
+ const buildPath = join21(dir, "build.sh");
11801
+ writeFileSync7(buildPath, herdrBuildScript());
11466
11802
  chmodSync(buildPath, 493);
11467
11803
  writeShim(dir);
11468
11804
  const cfg = applyKeybindings();
@@ -11510,7 +11846,7 @@ var SYNC_END2 = "\x1B[?2026l";
11510
11846
  var HIDE_CURSOR = "\x1B[?25l";
11511
11847
  var SHOW_CURSOR = "\x1B[?25h";
11512
11848
  var SPIN = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
11513
- var sleep4 = (ms) => new Promise((r) => setTimeout(r, ms));
11849
+ var sleep5 = (ms) => new Promise((r) => setTimeout(r, ms));
11514
11850
  function shineColor(dist) {
11515
11851
  const d = Math.abs(dist);
11516
11852
  if (d === 0) return 231;
@@ -11560,33 +11896,33 @@ ${HIDE_CURSOR}`);
11560
11896
  statusLine2(spin) + "\x1B[3A\r" + // back up to the logo's first row
11561
11897
  SYNC_END2;
11562
11898
  process.stdout.write(frame);
11563
- await sleep4(frameMs);
11899
+ await sleep5(frameMs);
11564
11900
  }
11565
11901
  process.stdout.write(SYNC_BEGIN2 + `\x1B[38;5;39m${LOGO_L1}
11566
11902
  ${LOGO_L2}\x1B[0m` + SYNC_END2);
11567
- await sleep4(250);
11903
+ await sleep5(250);
11568
11904
  process.stdout.write(SYNC_BEGIN2 + "\n\x1B[2K\n\x1B[2K" + SHOW_CURSOR + SYNC_END2);
11569
11905
  process.removeListener("exit", restoreCursor);
11570
11906
  process.removeListener("SIGINT", onSigint);
11571
11907
  }
11572
11908
  var LEGACY_INFO_MARKER = "Drive AgentBox from the host:";
11573
11909
  function installTargets() {
11574
- const home = homedir18();
11575
- const claudeSkills = join21(home, ".claude", "skills");
11910
+ const home = homedir19();
11911
+ const claudeSkills = join22(home, ".claude", "skills");
11576
11912
  return [
11577
11913
  {
11578
- src: join21("agentbox-info", "SKILL.md"),
11579
- dest: join21(claudeSkills, "agentbox-info", "SKILL.md")
11914
+ src: join22("agentbox-info", "SKILL.md"),
11915
+ dest: join22(claudeSkills, "agentbox-info", "SKILL.md")
11580
11916
  },
11581
11917
  {
11582
- src: join21("codex", "agentbox.md"),
11583
- dest: join21(home, ".codex", "prompts", "agentbox.md"),
11584
- gateDir: join21(home, ".codex")
11918
+ src: join22("codex", "agentbox.md"),
11919
+ dest: join22(home, ".codex", "prompts", "agentbox.md"),
11920
+ gateDir: join22(home, ".codex")
11585
11921
  },
11586
11922
  {
11587
- src: join21("opencode", "agentbox.md"),
11588
- dest: join21(home, ".config", "opencode", "commands", "agentbox.md"),
11589
- 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")
11590
11926
  }
11591
11927
  ];
11592
11928
  }
@@ -11597,7 +11933,7 @@ function resolveHostSkillsDir() {
11597
11933
  resolve4(here, "..", "..", "share", "host-skills")
11598
11934
  ];
11599
11935
  for (const c of candidates) {
11600
- if (existsSync10(c)) return c;
11936
+ if (existsSync11(c)) return c;
11601
11937
  }
11602
11938
  throw new Error(`could not locate bundled host skills; tried:
11603
11939
  ${candidates.join("\n ")}`);
@@ -11613,11 +11949,11 @@ function isSourceCheckout(srcDir) {
11613
11949
  return !srcDir.split(sep).includes("node_modules");
11614
11950
  }
11615
11951
  function writableReason(target, force) {
11616
- if (!existsSync10(target)) {
11952
+ if (!existsSync11(target)) {
11617
11953
  if (isSymlink(target)) return "managed";
11618
11954
  return "new";
11619
11955
  }
11620
- const existing = readFileSync4(target, "utf8");
11956
+ const existing = readFileSync5(target, "utf8");
11621
11957
  if (existing.includes(MANAGED_SENTINEL) || existing.includes(LEGACY_INFO_MARKER)) {
11622
11958
  return "managed";
11623
11959
  }
@@ -11633,13 +11969,13 @@ function installHostSkills(opts = {}) {
11633
11969
  const blocked = [];
11634
11970
  let skipped = 0;
11635
11971
  for (const t of installTargets()) {
11636
- const src = join21(srcDir, t.src);
11637
- if (!existsSync10(src)) {
11972
+ const src = join22(srcDir, t.src);
11973
+ if (!existsSync11(src)) {
11638
11974
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
11639
11975
  skipped++;
11640
11976
  continue;
11641
11977
  }
11642
- if (t.gateDir && !existsSync10(t.gateDir)) continue;
11978
+ if (t.gateDir && !existsSync11(t.gateDir)) continue;
11643
11979
  const reason = writableReason(t.dest, force);
11644
11980
  if (reason === "skip") {
11645
11981
  if (!quiet) prompt_exports.log.warn(`user-modified file at ${t.dest}, skipping; pass --force to overwrite`);
@@ -11652,13 +11988,13 @@ function installHostSkills(opts = {}) {
11652
11988
  written.push(t.dest);
11653
11989
  continue;
11654
11990
  }
11655
- mkdirSync8(dirname5(t.dest), { recursive: true });
11991
+ mkdirSync9(dirname5(t.dest), { recursive: true });
11656
11992
  if (link) {
11657
- rmSync(t.dest, { force: true });
11993
+ rmSync2(t.dest, { force: true });
11658
11994
  symlinkSync2(resolve4(srcDir, t.src), t.dest);
11659
11995
  } else {
11660
- if (isSymlink(t.dest)) rmSync(t.dest, { force: true });
11661
- writeFileSync7(t.dest, readFileSync4(src, "utf8"));
11996
+ if (isSymlink(t.dest)) rmSync2(t.dest, { force: true });
11997
+ writeFileSync8(t.dest, readFileSync5(src, "utf8"));
11662
11998
  }
11663
11999
  written.push(t.dest);
11664
12000
  }
@@ -11670,9 +12006,9 @@ async function installForkSkill(opts = {}) {
11670
12006
  const dryRun = opts.dryRun === true;
11671
12007
  const quiet = opts.quiet === true;
11672
12008
  const srcDir = resolveHostSkillsDir();
11673
- const src = join21(srcDir, "agentbox", "SKILL.md");
11674
- const dest = join21(homedir18(), ".claude", "skills", "agentbox", "SKILL.md");
11675
- if (!existsSync10(src)) {
12009
+ const src = join22(srcDir, "agentbox", "SKILL.md");
12010
+ const dest = join22(homedir19(), ".claude", "skills", "agentbox", "SKILL.md");
12011
+ if (!existsSync11(src)) {
11676
12012
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
11677
12013
  return { written: [], skipped: 1, blocked: [], method: "skip" };
11678
12014
  }
@@ -11687,8 +12023,8 @@ async function installForkSkill(opts = {}) {
11687
12023
  return { written: [dest], skipped: 0, blocked: [], method: "dry-run" };
11688
12024
  }
11689
12025
  if (isSourceCheckout(srcDir)) {
11690
- mkdirSync8(dirname5(dest), { recursive: true });
11691
- rmSync(dest, { force: true });
12026
+ mkdirSync9(dirname5(dest), { recursive: true });
12027
+ rmSync2(dest, { force: true });
11692
12028
  symlinkSync2(src, dest);
11693
12029
  return { written: [dest], skipped: 0, blocked: [], method: "symlink" };
11694
12030
  }
@@ -11710,16 +12046,16 @@ async function installForkSkill(opts = {}) {
11710
12046
  ],
11711
12047
  { timeout: 12e4 }
11712
12048
  );
11713
- if (existsSync10(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
12049
+ if (existsSync11(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
11714
12050
  throw new Error("`skills add` reported success but wrote no skill file");
11715
12051
  } catch (err) {
11716
12052
  if (!quiet) {
11717
12053
  const msg = err instanceof Error ? err.message : String(err);
11718
12054
  prompt_exports.log.warn(`\`npx skills add\` failed (${msg}); copying the bundled fork skill instead`);
11719
12055
  }
11720
- mkdirSync8(dirname5(dest), { recursive: true });
11721
- if (isSymlink(dest)) rmSync(dest, { force: true });
11722
- writeFileSync7(dest, readFileSync4(src, "utf8"));
12056
+ mkdirSync9(dirname5(dest), { recursive: true });
12057
+ if (isSymlink(dest)) rmSync2(dest, { force: true });
12058
+ writeFileSync8(dest, readFileSync5(src, "utf8"));
11723
12059
  return { written: [dest], skipped: 0, blocked: [], method: "copy" };
11724
12060
  }
11725
12061
  }
@@ -11747,7 +12083,7 @@ function ensureTty() {
11747
12083
  async function runProviderLogin(name) {
11748
12084
  if (name === "docker") return true;
11749
12085
  if (name === "daytona") {
11750
- const mod2 = await import("./dist-FTCDWRAL.js");
12086
+ const mod2 = await import("./dist-LUEH7MER.js");
11751
12087
  const status2 = await mod2.getDaytonaStatus();
11752
12088
  if (status2.configured) {
11753
12089
  prompt_exports.log.info("daytona: already configured");
@@ -11759,7 +12095,7 @@ async function runProviderLogin(name) {
11759
12095
  return true;
11760
12096
  }
11761
12097
  if (name === "hetzner") {
11762
- const mod2 = await import("./dist-PRDYMXCX.js");
12098
+ const mod2 = await import("./dist-T3JIYHCA.js");
11763
12099
  const status2 = mod2.readHetznerCredStatus();
11764
12100
  if (status2.source !== "none") {
11765
12101
  prompt_exports.log.info("hetzner: already configured");
@@ -11771,7 +12107,7 @@ async function runProviderLogin(name) {
11771
12107
  return true;
11772
12108
  }
11773
12109
  if (name === "vercel") {
11774
- const mod2 = await import("./dist-VQSZVBT3.js");
12110
+ const mod2 = await import("./dist-CTTTHG6U.js");
11775
12111
  const status2 = mod2.readVercelCredStatus();
11776
12112
  if (status2.auth !== "none") {
11777
12113
  prompt_exports.log.info(`vercel: already configured (${status2.auth})`);
@@ -11782,7 +12118,7 @@ async function runProviderLogin(name) {
11782
12118
  await mod2.ensureVercelCredentials();
11783
12119
  return true;
11784
12120
  }
11785
- const mod = await import("./dist-U2BHTWG4.js");
12121
+ const mod = await import("./dist-G5PDFWKH.js");
11786
12122
  const status = mod.readE2bCredStatus();
11787
12123
  if (status.auth !== "none") {
11788
12124
  prompt_exports.log.info(`e2b: already configured (${status.auth})`);
@@ -12251,7 +12587,7 @@ async function watchRender(produce, rawInterval, opts = {}) {
12251
12587
  process.once("SIGINT", () => process.exit(0));
12252
12588
  }
12253
12589
  const hint = interactive ? "q or Ctrl-C to exit" : "Ctrl-C to exit";
12254
- const sleep6 = (d) => new Promise((r) => {
12590
+ const sleep7 = (d) => new Promise((r) => {
12255
12591
  const t = setTimeout(() => {
12256
12592
  wake = null;
12257
12593
  r();
@@ -12282,7 +12618,7 @@ async function watchRender(produce, rawInterval, opts = {}) {
12282
12618
  ${trimmed}
12283
12619
  `);
12284
12620
  }
12285
- await sleep6(ms);
12621
+ await sleep7(ms);
12286
12622
  if (exiting) {
12287
12623
  restore();
12288
12624
  process.exit(0);
@@ -12572,7 +12908,7 @@ var listCommand2 = withWatchOptions(
12572
12908
  // src/commands/logs.ts
12573
12909
  import { log as log38 } from "@clack/prompts";
12574
12910
  import { Command as Command33 } from "commander";
12575
- import { spawn as spawn3 } from "child_process";
12911
+ import { spawn as spawn4 } from "child_process";
12576
12912
  var DAEMON_LOG_PATH = "/var/log/agentbox/ctl-daemon.log";
12577
12913
  var logsCommand = new Command33("logs").description("Print recent log lines from a box service; -f to stream").argument(
12578
12914
  "[box]",
@@ -12615,7 +12951,7 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12615
12951
  return;
12616
12952
  }
12617
12953
  if (!isCloud) {
12618
- const child2 = spawn3("docker", ["exec", "--user", "vscode", box.container, ...args], {
12954
+ const child2 = spawn4("docker", ["exec", "--user", "vscode", box.container, ...args], {
12619
12955
  stdio: ["ignore", "inherit", "inherit"]
12620
12956
  });
12621
12957
  child2.on("exit", (code) => process.exit(code ?? 0));
@@ -12639,7 +12975,7 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12639
12975
  });
12640
12976
  const [argv0, ...rest] = spec.argv;
12641
12977
  if (!argv0) throw new Error("provider.buildAttach returned an empty argv");
12642
- const child = spawn3(argv0, rest, {
12978
+ const child = spawn4(argv0, rest, {
12643
12979
  stdio: ["ignore", "inherit", "inherit"],
12644
12980
  env: spec.env ? { ...process.env, ...spec.env } : process.env
12645
12981
  });
@@ -12663,9 +12999,9 @@ var logsCommand = new Command33("logs").description("Print recent log lines from
12663
12999
  // src/commands/open.ts
12664
13000
  import { log as log39 } from "@clack/prompts";
12665
13001
  import { execa as execa6 } from "execa";
12666
- import { existsSync as existsSync11, mkdirSync as mkdirSync9 } from "fs";
12667
- import { homedir as homedir19 } from "os";
12668
- import { join as join22 } from "path";
13002
+ import { existsSync as existsSync12, mkdirSync as mkdirSync10 } from "fs";
13003
+ import { homedir as homedir20 } from "os";
13004
+ import { join as join23 } from "path";
12669
13005
  import { Command as Command34 } from "commander";
12670
13006
 
12671
13007
  // src/commands/path.ts
@@ -12727,7 +13063,7 @@ var openCommand = new Command34("open").description("Open a box's /workspace in
12727
13063
  }
12728
13064
  });
12729
13065
  async function runCloudOpen(box, provider, opts) {
12730
- const mountRoot = join22(homedir19(), ".agentbox", "mounts", box.name);
13066
+ const mountRoot = join23(homedir20(), ".agentbox", "mounts", box.name);
12731
13067
  if (opts.unmount) {
12732
13068
  const ok = await tryUnmount(mountRoot);
12733
13069
  if (ok) process.stdout.write(`unmounted ${mountRoot}
@@ -12764,8 +13100,8 @@ async function runCloudOpen(box, provider, opts) {
12764
13100
  user: target.user,
12765
13101
  identityFile: target.identityFile
12766
13102
  });
12767
- if (!existsSync11(mountRoot)) {
12768
- mkdirSync9(mountRoot, { recursive: true, mode: 493 });
13103
+ if (!existsSync12(mountRoot)) {
13104
+ mkdirSync10(mountRoot, { recursive: true, mode: 493 });
12769
13105
  } else if (await isMounted(mountRoot)) {
12770
13106
  log39.info(`re-mounting (stale mount detected at ${mountRoot})`);
12771
13107
  await tryUnmount(mountRoot);
@@ -13199,11 +13535,11 @@ async function pollUntil(deadline, probe) {
13199
13535
  if (result !== void 0) return result;
13200
13536
  const remaining = deadline - Date.now();
13201
13537
  if (remaining <= 0) break;
13202
- await sleep5(Math.min(QUEUE_POLL_INTERVAL_MS, remaining));
13538
+ await sleep6(Math.min(QUEUE_POLL_INTERVAL_MS, remaining));
13203
13539
  }
13204
13540
  throw new QueueWaitTimeout();
13205
13541
  }
13206
- function sleep5(ms) {
13542
+ function sleep6(ms) {
13207
13543
  return new Promise((r) => setTimeout(r, ms));
13208
13544
  }
13209
13545
  function parsePositiveInt3(raw, label) {
@@ -13592,9 +13928,155 @@ function buildOverridesFromJob(job) {
13592
13928
  return out;
13593
13929
  }
13594
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
+
13595
14077
  // src/commands/herdr.ts
13596
14078
  import { spawnSync as spawnSync5 } from "child_process";
13597
- import { Command as Command40 } from "commander";
14079
+ import { Command as Command41 } from "commander";
13598
14080
  function parseHerdrLink(uri) {
13599
14081
  if (!uri) return null;
13600
14082
  const m = uri.match(/^agentbox:\/\/([^/]+)\/(.+)$/);
@@ -13620,7 +14102,7 @@ function herdrContextCwd(env = process.env) {
13620
14102
  }
13621
14103
  return process.cwd();
13622
14104
  }
13623
- 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) => {
13624
14106
  const agent = opts.agent ?? "claude";
13625
14107
  const cwd = herdrContextCwd();
13626
14108
  const r = await spawnInNewTerminal({
@@ -13633,7 +14115,7 @@ var newCommand = new Command40("new").description("Open a new box session in a f
13633
14115
  if (r.launched) process.stdout.write(r.note + "\n");
13634
14116
  else if (r.error) process.stderr.write(r.error + "\n");
13635
14117
  });
13636
- 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) => {
13637
14119
  const link = parseHerdrLink(uriArg ?? process.env["HERDR_PLUGIN_CLICKED_URL"]);
13638
14120
  if (!link) return;
13639
14121
  if (link.verb !== "web") return;
@@ -13666,12 +14148,12 @@ var linkCommand = new Command40("link").description("Handle a Ctrl+click on an a
13666
14148
  sound: "request"
13667
14149
  });
13668
14150
  });
13669
- 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);
13670
14152
 
13671
14153
  // src/commands/screen.ts
13672
14154
  import { spawnSync as spawnSync6 } from "child_process";
13673
14155
  import { log as log43 } from "@clack/prompts";
13674
- import { Command as Command41 } from "commander";
14156
+ import { Command as Command42 } from "commander";
13675
14157
  var SIGNED_URL_TTL_MIN = 1;
13676
14158
  var SIGNED_URL_TTL_MAX = 86400;
13677
14159
  function parseTtlOrExit(raw) {
@@ -13684,7 +14166,7 @@ function parseTtlOrExit(raw) {
13684
14166
  }
13685
14167
  return n;
13686
14168
  }
13687
- 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(
13688
14170
  "[box]",
13689
14171
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
13690
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(
@@ -13793,7 +14275,7 @@ var screenCommand = new Command41("screen").description("Open a box's VNC (noVNC
13793
14275
  // src/commands/shell.ts
13794
14276
  import { spawnSync as spawnSync7 } from "child_process";
13795
14277
  import { log as log45 } from "@clack/prompts";
13796
- import { Command as Command42 } from "commander";
14278
+ import { Command as Command43 } from "commander";
13797
14279
 
13798
14280
  // src/commands/_provider-guard.ts
13799
14281
  import { log as log44 } from "@clack/prompts";
@@ -13910,7 +14392,7 @@ async function startOrAttachShell(box, cfg) {
13910
14392
  });
13911
14393
  process.exit(code);
13912
14394
  }
13913
- var shellCommand = new Command42("shell").description(
14395
+ var shellCommand = new Command43("shell").description(
13914
14396
  "Open an interactive shell in a box, in a detachable tmux session (auto-unpause/start)"
13915
14397
  ).argument(
13916
14398
  "[box]",
@@ -14005,7 +14487,7 @@ var shellCommand = new Command42("shell").description(
14005
14487
  handleLifecycleError(err);
14006
14488
  }
14007
14489
  });
14008
- var shellAttachCommand = new Command42("attach").description(
14490
+ var shellAttachCommand = new Command43("attach").description(
14009
14491
  "Attach to a shell tmux session in a box, starting one if none is running (auto-unpause/start)"
14010
14492
  ).argument(
14011
14493
  "[box]",
@@ -14043,7 +14525,7 @@ function renderShellTable(sessions) {
14043
14525
  for (const r of rows) process.stdout.write(`${fmt(r)}
14044
14526
  `);
14045
14527
  }
14046
- 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(
14047
14529
  "[box]",
14048
14530
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14049
14531
  ).action(async (idOrName) => {
@@ -14066,7 +14548,7 @@ var shellLsCommand = new Command42("ls").description("List the shell tmux sessio
14066
14548
  handleLifecycleError(err);
14067
14549
  }
14068
14550
  });
14069
- 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(
14070
14552
  "[box]",
14071
14553
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14072
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) {
@@ -14104,8 +14586,8 @@ shellCommand.addCommand(shellLsCommand);
14104
14586
  shellCommand.addCommand(shellKillCommand);
14105
14587
 
14106
14588
  // src/commands/start.ts
14107
- import { Command as Command43 } from "commander";
14108
- var startCommand = new Command43("start").description(
14589
+ import { Command as Command44 } from "commander";
14590
+ var startCommand = new Command44("start").description(
14109
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)."
14110
14592
  ).argument(
14111
14593
  "[box]",
@@ -14117,10 +14599,19 @@ var startCommand = new Command43("start").description(
14117
14599
  const { record } = await startBox(box.id);
14118
14600
  process.stdout.write(`started ${record.container}
14119
14601
  `);
14602
+ await restoreAgentSessions(record, await providerForBox(record), {
14603
+ onLog: (line) => process.stdout.write(`${line}
14604
+ `)
14605
+ });
14120
14606
  } else {
14121
- await (await providerForBox(box)).start(box);
14607
+ const provider = await providerForBox(box);
14608
+ const record = await provider.start(box);
14122
14609
  process.stdout.write(`started ${box.name}
14123
14610
  `);
14611
+ await restoreAgentSessions(record, provider, {
14612
+ onLog: (line) => process.stdout.write(`${line}
14613
+ `)
14614
+ });
14124
14615
  }
14125
14616
  } catch (err) {
14126
14617
  handleLifecycleError(err);
@@ -14129,7 +14620,7 @@ var startCommand = new Command43("start").description(
14129
14620
 
14130
14621
  // src/commands/status.ts
14131
14622
  import { log as log47 } from "@clack/prompts";
14132
- import { Command as Command44 } from "commander";
14623
+ import { Command as Command45 } from "commander";
14133
14624
 
14134
14625
  // src/endpoints-render.ts
14135
14626
  function renderEndpointLines(endpoints, stream) {
@@ -14404,7 +14895,7 @@ async function runInspect(box, opts) {
14404
14895
 
14405
14896
  // src/commands/status.ts
14406
14897
  var statusCommand2 = withWatchOptions(
14407
- 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(
14408
14899
  "[box]",
14409
14900
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14410
14901
  ).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) plus service/task status")
@@ -14539,8 +15030,8 @@ function renderPersisted2(s, state) {
14539
15030
  }
14540
15031
 
14541
15032
  // src/commands/stop.ts
14542
- import { Command as Command45 } from "commander";
14543
- var stopCommand = new Command45("stop").description(
15033
+ import { Command as Command46 } from "commander";
15034
+ var stopCommand = new Command46("stop").description(
14544
15035
  "Stop a box (Docker: docker stop; preserves upper + node_modules volumes. Cloud: backend.stop \u2014 sandbox stays in your account, disk preserved)."
14545
15036
  ).argument(
14546
15037
  "[box]",
@@ -14569,7 +15060,7 @@ restart with: agentbox start ${box.name}
14569
15060
  });
14570
15061
 
14571
15062
  // src/commands/top.ts
14572
- import { Command as Command46 } from "commander";
15063
+ import { Command as Command47 } from "commander";
14573
15064
  var COLS = ["BOX", "STATE", "CPU%", "MEM USAGE / LIMIT", "MEM%", "PIDS", "DISK", "NET I/O"];
14574
15065
  function row(name, state, s) {
14575
15066
  const mem = `${fmtBytes2(s.memUsedBytes)} / ${fmtBytes2(s.memLimitBytes)}`;
@@ -14643,7 +15134,7 @@ async function renderProjectFooters() {
14643
15134
 
14644
15135
  SYSTEM: ${parts.join(" - ")}` : "";
14645
15136
  }
14646
- 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(
14647
15138
  "[box]",
14648
15139
  "box ref (default: every box on the host; --project narrows to the cwd's project)"
14649
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) => {
@@ -14676,8 +15167,8 @@ var topCommand = new Command46("top").description("Live resource monitor (cpu/me
14676
15167
  });
14677
15168
 
14678
15169
  // src/commands/unpause.ts
14679
- import { Command as Command47 } from "commander";
14680
- var unpauseCommand = new Command47("unpause").description(
15170
+ import { Command as Command48 } from "commander";
15171
+ var unpauseCommand = new Command48("unpause").description(
14681
15172
  "Resume a paused box. Docker: `docker unpause` (sub-second). Cloud: backend.resume (re-hydrates from archive \u2014 slower first time)."
14682
15173
  ).argument(
14683
15174
  "[box]",
@@ -14690,9 +15181,14 @@ var unpauseCommand = new Command47("unpause").description(
14690
15181
  process.stdout.write(`unpaused ${record.container}
14691
15182
  `);
14692
15183
  } else {
14693
- await (await providerForBox(box)).resume(box);
15184
+ const provider = await providerForBox(box);
15185
+ await provider.resume(box);
14694
15186
  process.stdout.write(`unpaused ${box.name}
14695
15187
  `);
15188
+ await restoreAgentSessions(box, provider, {
15189
+ onLog: (line) => process.stdout.write(`${line}
15190
+ `)
15191
+ });
14696
15192
  }
14697
15193
  } catch (err) {
14698
15194
  handleLifecycleError(err);
@@ -14700,8 +15196,8 @@ var unpauseCommand = new Command47("unpause").description(
14700
15196
  });
14701
15197
 
14702
15198
  // src/commands/update.ts
14703
- import { spawn as spawn4 } from "child_process";
14704
- import { Command as Command48 } from "commander";
15199
+ import { spawn as spawn5 } from "child_process";
15200
+ import { Command as Command49 } from "commander";
14705
15201
 
14706
15202
  // src/exec-method.ts
14707
15203
  function detectExecutionMethod(input) {
@@ -14740,12 +15236,12 @@ function describeSelfUpdate(method) {
14740
15236
  }
14741
15237
  function runInherit(cmd, args) {
14742
15238
  return new Promise((resolveP, rejectP) => {
14743
- const child = spawn4(cmd, args, { stdio: "inherit" });
15239
+ const child = spawn5(cmd, args, { stdio: "inherit" });
14744
15240
  child.on("error", rejectP);
14745
15241
  child.on("close", (code) => resolveP(code ?? 0));
14746
15242
  });
14747
15243
  }
14748
- var updateCommand = new Command48("self-update").description(
15244
+ var updateCommand = new Command49("self-update").description(
14749
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"
14750
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) => {
14751
15247
  try {
@@ -14862,7 +15358,7 @@ var updateCommand = new Command48("self-update").description(
14862
15358
  // src/commands/url.ts
14863
15359
  import { spawnSync as spawnSync8 } from "child_process";
14864
15360
  import { log as log49 } from "@clack/prompts";
14865
- import { Command as Command49 } from "commander";
15361
+ import { Command as Command50 } from "commander";
14866
15362
  var SIGNED_URL_TTL_MIN2 = 1;
14867
15363
  var SIGNED_URL_TTL_MAX2 = 86400;
14868
15364
  function parseTtlOrExit2(raw) {
@@ -14875,7 +15371,7 @@ function parseTtlOrExit2(raw) {
14875
15371
  }
14876
15372
  return n;
14877
15373
  }
14878
- var urlCommand = new Command49("url").description(
15374
+ var urlCommand = new Command50("url").description(
14879
15375
  "Open a box's web app URL in the browser, even when no service declares `expose:` (auto-unpause/start)"
14880
15376
  ).argument(
14881
15377
  "[box]",
@@ -14954,8 +15450,8 @@ var urlCommand = new Command49("url").description(
14954
15450
 
14955
15451
  // src/commands/wait.ts
14956
15452
  import { log as log50 } from "@clack/prompts";
14957
- import { Command as Command50 } from "commander";
14958
- var waitCommand = new Command50("wait").description("Block until the box reports all autostart units ready").argument(
15453
+ import { Command as Command51 } from "commander";
15454
+ var waitCommand = new Command51("wait").description("Block until the box reports all autostart units ready").argument(
14959
15455
  "[box]",
14960
15456
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14961
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) => {
@@ -15010,7 +15506,7 @@ function rewriteProviderPrefix(argv2) {
15010
15506
  process.env.DOCKER_CLI_HINTS ??= "false";
15011
15507
  process.env.AGENTBOX_CLI_VERSION = AGENTBOX_VERSION;
15012
15508
  process.env.AGENTBOX_CLI_COMMIT = AGENTBOX_COMMIT;
15013
- var program = new Command51();
15509
+ var program = new Command52();
15014
15510
  program.name("agentbox").description("Launch coding agents in isolated sandboxes").version(AGENTBOX_VERSION);
15015
15511
  program.enablePositionalOptions();
15016
15512
  program.addCommand(createCommand);
@@ -15047,6 +15543,7 @@ program.addCommand(configCommand);
15047
15543
  program.addCommand(queueCommand);
15048
15544
  program.addCommand(relayCommand);
15049
15545
  program.addCommand(runQueuedJobCommand, { hidden: true });
15546
+ program.addCommand(claudeLoginWorkerCommand, { hidden: true });
15050
15547
  program.addCommand(herdrCommand, { hidden: true });
15051
15548
  program.addCommand(daytonaCommand);
15052
15549
  program.addCommand(hetznerCommand);
@@ -15066,6 +15563,7 @@ var FIRST_RUN_EXEMPT = /* @__PURE__ */ new Set([
15066
15563
  "help",
15067
15564
  "relay",
15068
15565
  "_run-queued-job",
15566
+ "_claude-login-worker",
15069
15567
  "drive",
15070
15568
  "screen"
15071
15569
  ]);