@madarco/agentbox 0.22.1 → 0.22.2

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 (122) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/{_cloud-attach-YH2SU75S.js → _cloud-attach-Y5WZ7F53.js} +5 -5
  3. package/dist/{chunk-KBVD2UUQ.js → chunk-3KAWXDQ4.js} +3 -3
  4. package/dist/{chunk-YZXXBHWG.js → chunk-5DZTXHLQ.js} +3 -3
  5. package/dist/{chunk-O2NDZQHN.js → chunk-7HAGPF4X.js} +2 -2
  6. package/dist/{chunk-O67ZESNL.js → chunk-AYNGC4Z5.js} +4 -4
  7. package/dist/{chunk-GGWVTWJM.js → chunk-BMCT3LBE.js} +16 -13
  8. package/dist/chunk-BMCT3LBE.js.map +1 -0
  9. package/dist/{chunk-ALEYDWAO.js → chunk-ES2DDCAC.js} +303 -87
  10. package/dist/chunk-ES2DDCAC.js.map +1 -0
  11. package/dist/{chunk-VBSRJG53.js → chunk-QT3SHMLY.js} +9 -1
  12. package/dist/chunk-QT3SHMLY.js.map +1 -0
  13. package/dist/{chunk-CDEJ2GQK.js → chunk-S4OWE3UD.js} +4 -4
  14. package/dist/{chunk-W2FLHB54.js → chunk-V2NCCC2B.js} +2 -2
  15. package/dist/{dist-QBXEP4VY.js → dist-2BTJQUJS.js} +2 -2
  16. package/dist/{dist-LJHS4PTC.js → dist-AN5NUXA5.js} +6 -6
  17. package/dist/{dist-EJXUKIR7.js → dist-FNAGMTUI.js} +4 -4
  18. package/dist/{dist-YECTRVGD.js → dist-K5GASNBV.js} +6 -6
  19. package/dist/{dist-UR2DB2HT.js → dist-SJRMFVRV.js} +6 -6
  20. package/dist/{dist-QNV4H6NN.js → dist-VOVN64Y2.js} +6 -6
  21. package/dist/index.js +1108 -727
  22. package/dist/index.js.map +1 -1
  23. package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js → prepared-state-5FIGV4BE-WPHOEDA6.js} +2 -2
  24. package/package.json +5 -5
  25. package/runtime/_shared/ctl.cjs +10 -0
  26. package/runtime/docker/packages/ctl/dist/bin.cjs +10 -0
  27. package/runtime/e2b/ctl.cjs +10 -0
  28. package/runtime/hetzner/ctl.cjs +10 -0
  29. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  30. package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +1 -0
  31. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  32. package/runtime/hub/apps/hub/.next/routes-manifest.json +8 -0
  33. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/app-paths-manifest.json +3 -0
  34. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/build-manifest.json +9 -0
  35. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route/server-reference-manifest.json +4 -0
  36. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js +9 -0
  37. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.map +5 -0
  38. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route.js.nft.json +1 -0
  39. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/boxes/[id]/rename/route_client-reference-manifest.js +3 -0
  40. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
  41. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/server-reference-manifest.json +12 -0
  42. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  43. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/server-reference-manifest.json +12 -0
  44. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  45. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/server-reference-manifest.json +12 -0
  46. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  47. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  48. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  49. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  50. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  51. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  52. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  53. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  54. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  55. package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +1 -0
  56. package/runtime/hub/apps/hub/.next/server/chunks/0m4a_kysely_dist_095p8vu._.js +1 -1
  57. package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_boxes_[id]_rename_route_actions_0mf3a9p.js +3 -0
  58. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +1 -1
  59. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  60. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +3 -0
  61. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +14 -14
  62. package/runtime/hub/apps/hub/.next/server/chunks/_0lgs9kd._.js +3 -0
  63. package/runtime/hub/apps/hub/.next/server/chunks/ssr/044u_hub__next-internal_server_app_(dashboard)_projects_[id]_page_actions_15f56np.js +1 -1
  64. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
  65. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ozyjt1._.js +1 -1
  66. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  67. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
  68. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
  69. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_boxes_[id]_page_actions_0k7kgn2.js +1 -1
  70. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_page_actions_1t3u0xy.js +1 -1
  71. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_components_1z1p98f._.js +1 -1
  72. package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +1 -0
  73. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  74. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  75. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.js +1 -1
  76. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.json +24 -0
  77. package/runtime/hub/apps/hub/.next/static/chunks/2xc1sm79a6tsb.js +1 -0
  78. package/runtime/hub/apps/hub/.next/static/chunks/332lo0ac7l2wv.js +1 -0
  79. package/runtime/hub/apps/hub/.next/static/chunks/3gdqmzzl34ilu.js +1 -0
  80. package/runtime/hub/apps/hub/.next/static/chunks/44exu5uemf-ev.js +1 -0
  81. package/runtime/hub/apps/hub/{auth-YBXDRLHG.js → auth-675P3LQS.js} +2 -2
  82. package/runtime/hub/apps/hub/{auth-config-LJGI76HI.js → auth-config-AOBEKRZQ.js} +2 -2
  83. package/runtime/hub/apps/hub/{chunk-OBKLTPIR.js → chunk-56YQBVN2.js} +1 -1
  84. package/runtime/hub/apps/hub/{chunk-LJG4CEGS.js → chunk-5XQ3T3W2.js} +274 -84
  85. package/runtime/hub/apps/hub/{chunk-JDA7BPPN.js → chunk-673QOHSR.js} +3 -3
  86. package/runtime/hub/apps/hub/{chunk-V5KGFHCF.js → chunk-7J6ZFTT4.js} +2 -2
  87. package/runtime/hub/apps/hub/{chunk-AKLBSCSZ.js → chunk-EXQCBM5Q.js} +8 -0
  88. package/runtime/hub/apps/hub/{dist-GGM4BUKM.js → dist-EI54M5DP.js} +4 -4
  89. package/runtime/hub/apps/hub/{dist-ELOY2IUE.js → dist-GCALYJN7.js} +3 -3
  90. package/runtime/hub/apps/hub/{dist-FDBOJ74K.js → dist-K7WHNDZB.js} +4 -4
  91. package/runtime/hub/apps/hub/{dist-CM4YAQLI.js → dist-LYTWBTUL.js} +4 -4
  92. package/runtime/hub/apps/hub/{dist-BF54UNHK.js → dist-MOCUH2OC.js} +4 -4
  93. package/runtime/hub/apps/hub/{dist-IENF7YOD.js → dist-STQK5XM6.js} +1 -1
  94. package/runtime/hub/apps/hub/{hub-token-EW32VDIU.js → hub-token-2BZFBBW3.js} +2 -2
  95. package/runtime/hub/apps/hub/{prepared-state-5FIGV4BE-FIXKBF5A.js → prepared-state-5FIGV4BE-D2HJEY2L.js} +1 -1
  96. package/runtime/hub/apps/hub/server.js +57 -16
  97. package/runtime/relay/bin.cjs +10 -0
  98. package/runtime/vercel/ctl.cjs +10 -0
  99. package/dist/chunk-ALEYDWAO.js.map +0 -1
  100. package/dist/chunk-GGWVTWJM.js.map +0 -1
  101. package/dist/chunk-VBSRJG53.js.map +0 -1
  102. package/runtime/hub/apps/hub/.next/static/chunks/0lq354ziiwxxl.js +0 -1
  103. package/runtime/hub/apps/hub/.next/static/chunks/11vmjdy3390ik.js +0 -1
  104. package/runtime/hub/apps/hub/.next/static/chunks/1svigjdfotduh.js +0 -1
  105. package/runtime/hub/apps/hub/.next/static/chunks/2d5e6t-5j4etp.js +0 -1
  106. /package/dist/{_cloud-attach-YH2SU75S.js.map → _cloud-attach-Y5WZ7F53.js.map} +0 -0
  107. /package/dist/{chunk-KBVD2UUQ.js.map → chunk-3KAWXDQ4.js.map} +0 -0
  108. /package/dist/{chunk-YZXXBHWG.js.map → chunk-5DZTXHLQ.js.map} +0 -0
  109. /package/dist/{chunk-O2NDZQHN.js.map → chunk-7HAGPF4X.js.map} +0 -0
  110. /package/dist/{chunk-O67ZESNL.js.map → chunk-AYNGC4Z5.js.map} +0 -0
  111. /package/dist/{chunk-CDEJ2GQK.js.map → chunk-S4OWE3UD.js.map} +0 -0
  112. /package/dist/{chunk-W2FLHB54.js.map → chunk-V2NCCC2B.js.map} +0 -0
  113. /package/dist/{dist-EJXUKIR7.js.map → dist-2BTJQUJS.js.map} +0 -0
  114. /package/dist/{dist-LJHS4PTC.js.map → dist-AN5NUXA5.js.map} +0 -0
  115. /package/dist/{dist-QBXEP4VY.js.map → dist-FNAGMTUI.js.map} +0 -0
  116. /package/dist/{dist-QNV4H6NN.js.map → dist-K5GASNBV.js.map} +0 -0
  117. /package/dist/{dist-UR2DB2HT.js.map → dist-SJRMFVRV.js.map} +0 -0
  118. /package/dist/{dist-YECTRVGD.js.map → dist-VOVN64Y2.js.map} +0 -0
  119. /package/dist/{prepared-state-5FIGV4BE-BMUK63FD.js.map → prepared-state-5FIGV4BE-WPHOEDA6.js.map} +0 -0
  120. /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → zT1paOSXMJpAPsZ1dFK2V}/_buildManifest.js +0 -0
  121. /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → zT1paOSXMJpAPsZ1dFK2V}/_clientMiddlewareManifest.js +0 -0
  122. /package/runtime/hub/apps/hub/.next/static/{TpPTWVdZDxqrPlONtJcR5 → zT1paOSXMJpAPsZ1dFK2V}/_ssgManifest.js +0 -0
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  readE2bCredStatus,
6
6
  readPreparedState as readPreparedState3,
7
7
  secretsPath as secretsPath4
8
- } from "./chunk-W2FLHB54.js";
8
+ } from "./chunk-V2NCCC2B.js";
9
9
  import {
10
10
  ADVANCED_HINT_GROUPS,
11
11
  ALERT_BAND_ROWS,
@@ -49,7 +49,7 @@ import {
49
49
  subscribePrompts,
50
50
  uploadImageFileToBox,
51
51
  withFirewallRepair
52
- } from "./chunk-GGWVTWJM.js";
52
+ } from "./chunk-BMCT3LBE.js";
53
53
  import {
54
54
  daytonaBackend,
55
55
  ensureDaytonaCredentials,
@@ -57,7 +57,7 @@ import {
57
57
  readDaytonaCredStatus,
58
58
  readPreparedDaytonaState,
59
59
  secretsPath
60
- } from "./chunk-O2NDZQHN.js";
60
+ } from "./chunk-7HAGPF4X.js";
61
61
  import {
62
62
  deployControlPlaneToHetzner,
63
63
  detectEgressIp,
@@ -69,7 +69,7 @@ import {
69
69
  readPreparedState,
70
70
  secretsPath as secretsPath2,
71
71
  syncFirewallSource
72
- } from "./chunk-O67ZESNL.js";
72
+ } from "./chunk-AYNGC4Z5.js";
73
73
  import {
74
74
  createGitDeployment,
75
75
  createGitProject,
@@ -88,7 +88,7 @@ import {
88
88
  resolveVercelApiAuth,
89
89
  secretsPath as secretsPath3,
90
90
  upsertProjectEnv
91
- } from "./chunk-KBVD2UUQ.js";
91
+ } from "./chunk-3KAWXDQ4.js";
92
92
  import {
93
93
  agentSpecsForCloud,
94
94
  baseFreshnessFromFingerprints,
@@ -100,7 +100,7 @@ import {
100
100
  probeCloudCheckpoint,
101
101
  resolveCloudCheckpoint,
102
102
  seedAgentVolumesIfFresh
103
- } from "./chunk-CDEJ2GQK.js";
103
+ } from "./chunk-S4OWE3UD.js";
104
104
  import {
105
105
  ALL_CONNECTORS,
106
106
  BOX_STATUS_EVENT,
@@ -247,10 +247,11 @@ import {
247
247
  waitForTmuxPaneContent,
248
248
  warmUpClaudeCredentials,
249
249
  writeJob
250
- } from "./chunk-YZXXBHWG.js";
250
+ } from "./chunk-5DZTXHLQ.js";
251
251
  import {
252
252
  BUILT_IN_DEFAULTS,
253
253
  CLOUD_PROVIDER_NAMES,
254
+ GLOBAL_CONFIG_FILE,
254
255
  KEY_REGISTRY,
255
256
  PROVIDER_NAMES,
256
257
  UserConfigError,
@@ -263,6 +264,7 @@ import {
263
264
  listProjectsConfigured,
264
265
  loadEffectiveConfig,
265
266
  lookupKey,
267
+ parseUserConfig,
266
268
  providerMeta,
267
269
  pruneOrphanProjectConfigs,
268
270
  registerProject,
@@ -271,7 +273,7 @@ import {
271
273
  resolveDefaultCheckpoint,
272
274
  setConfigValue,
273
275
  unsetConfigValue
274
- } from "./chunk-VBSRJG53.js";
276
+ } from "./chunk-QT3SHMLY.js";
275
277
  import {
276
278
  AmbiguousBoxError,
277
279
  BoxNotFoundError,
@@ -281,6 +283,9 @@ import {
281
283
  SUPPORTED_SDK_API_VERSIONS,
282
284
  UserFacingError,
283
285
  addPluginRecord,
286
+ agentboxAliasFor,
287
+ agentboxSshConfigPath,
288
+ autoWriteSshConfig,
284
289
  boxGitCheckout,
285
290
  boxGitNewBranch,
286
291
  boxGitPull,
@@ -290,10 +295,12 @@ import {
290
295
  boxRestartServices,
291
296
  boxServicesStatusRaw,
292
297
  computeDockerContextFingerprint,
298
+ ensureCloudSshAlias,
293
299
  ensureImage,
294
300
  errSummary,
295
301
  firstLine,
296
302
  generateBoxId,
303
+ hasUnmanagedHostConflict,
297
304
  hostBackupHasCredentials,
298
305
  hostClaudeBackupExpired,
299
306
  hostOpenCommand,
@@ -303,6 +310,7 @@ import {
303
310
  isSupportedApiVersion,
304
311
  mutateState,
305
312
  normalizeLastAgent,
313
+ readAgentboxSshAlias,
306
314
  readPluginRegistrySync,
307
315
  readPreparedDockerState,
308
316
  readState,
@@ -313,12 +321,15 @@ import {
313
321
  removePluginRecord,
314
322
  resolveAgentLauncher,
315
323
  resolveBoxRef,
324
+ resolveCloudSshTarget,
316
325
  resolveRuleRefs,
317
326
  scanHostEnvFiles,
318
327
  scratchBranchName,
328
+ setBoxDisplayName,
329
+ syncAgentboxSshConfig,
319
330
  toQueueKind,
320
331
  toSyncKind
321
- } from "./chunk-ALEYDWAO.js";
332
+ } from "./chunk-ES2DDCAC.js";
322
333
  import "./chunk-G3H2L3O2.js";
323
334
  import {
324
335
  __export,
@@ -326,14 +337,14 @@ import {
326
337
  } from "./chunk-WJFZJZIM.js";
327
338
 
328
339
  // src/version.ts
329
- var AGENTBOX_VERSION = true ? "0.22.1" : "0.0.0-dev";
330
- var AGENTBOX_COMMIT = true ? "109ca1238" : "dev";
340
+ var AGENTBOX_VERSION = true ? "0.22.2" : "0.0.0-dev";
341
+ var AGENTBOX_COMMIT = true ? "ae2c7503b" : "dev";
331
342
 
332
343
  // src/index.ts
333
344
  import { existsSync as _existsSync } from "fs";
334
345
  import { dirname as _dirname, resolve as _resolve } from "path";
335
346
  import { fileURLToPath as _fileURLToPath } from "url";
336
- import { Command as Command61 } from "commander";
347
+ import { Command as Command62 } from "commander";
337
348
 
338
349
  // src/engine-override.ts
339
350
  async function applyEngineOverrideAtStartup() {
@@ -1091,9 +1102,9 @@ import { intro as intro2, log as log5, outro as outro2, spinner } from "@clack/p
1091
1102
  import { Command as Command3 } from "commander";
1092
1103
  import { execa as execa2 } from "execa";
1093
1104
  import { spawn } from "child_process";
1094
- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync, writeFileSync } from "fs";
1095
- import { homedir } from "os";
1096
- import { join as join2 } from "path";
1105
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3, statSync, writeFileSync as writeFileSync2 } from "fs";
1106
+ import { homedir as homedir2 } from "os";
1107
+ import { join as join3 } from "path";
1097
1108
  import { setTimeout as delay2 } from "timers/promises";
1098
1109
 
1099
1110
  // src/commands/install-tray.ts
@@ -1101,10 +1112,60 @@ import { intro, log as log4, outro } from "@clack/prompts";
1101
1112
  import { Command as Command2 } from "commander";
1102
1113
  import { execa } from "execa";
1103
1114
  import { createHash as createHash2 } from "crypto";
1104
- import { existsSync, mkdtempSync, readFileSync, rmSync } from "fs";
1115
+ import { existsSync as existsSync2, mkdtempSync, readFileSync as readFileSync2, rmSync } from "fs";
1105
1116
  import { tmpdir } from "os";
1106
- import { join } from "path";
1117
+ import { join as join2 } from "path";
1107
1118
  import { setTimeout as delay } from "timers/promises";
1119
+
1120
+ // src/lib/update-state.ts
1121
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
1122
+ import { homedir } from "os";
1123
+ import { dirname, join } from "path";
1124
+ var STATE_VERSION = 1;
1125
+ function updateStatePath() {
1126
+ return join(homedir(), ".agentbox", "update-state.json");
1127
+ }
1128
+ function readUpdateState() {
1129
+ const path = updateStatePath();
1130
+ if (!existsSync(path)) return { version: STATE_VERSION };
1131
+ try {
1132
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
1133
+ const state = { version: STATE_VERSION };
1134
+ if (typeof parsed.lastRunVersion === "string") state.lastRunVersion = parsed.lastRunVersion;
1135
+ if (typeof parsed.traySha === "string") state.traySha = parsed.traySha;
1136
+ if (parsed.remoteCheck !== void 0 && typeof parsed.remoteCheck === "object" && typeof parsed.remoteCheck.checkedAt === "string") {
1137
+ state.remoteCheck = {
1138
+ checkedAt: parsed.remoteCheck.checkedAt,
1139
+ ...typeof parsed.remoteCheck.npmLatest === "string" ? { npmLatest: parsed.remoteCheck.npmLatest } : {},
1140
+ ...typeof parsed.remoteCheck.trayLatestSha === "string" ? { trayLatestSha: parsed.remoteCheck.trayLatestSha } : {}
1141
+ };
1142
+ }
1143
+ return state;
1144
+ } catch {
1145
+ return { version: STATE_VERSION };
1146
+ }
1147
+ }
1148
+ function writeUpdateState(patch) {
1149
+ const state = readUpdateState();
1150
+ const merged = { ...state, ...patch, version: STATE_VERSION };
1151
+ for (const key of Object.keys(merged)) {
1152
+ if (merged[key] === void 0) delete merged[key];
1153
+ }
1154
+ const path = updateStatePath();
1155
+ mkdirSync(dirname(path), { recursive: true });
1156
+ writeFileSync(path, JSON.stringify(merged, null, 2) + "\n");
1157
+ return merged;
1158
+ }
1159
+ var DAY_MS = 24 * 60 * 60 * 1e3;
1160
+ function remoteCheckFresh(state, now = /* @__PURE__ */ new Date()) {
1161
+ const at = state.remoteCheck?.checkedAt;
1162
+ if (at === void 0) return false;
1163
+ const t = Date.parse(at);
1164
+ if (Number.isNaN(t)) return false;
1165
+ return now.getTime() - t < DAY_MS && t - now.getTime() < DAY_MS;
1166
+ }
1167
+
1168
+ // src/commands/install-tray.ts
1108
1169
  var APP_NAME = "AgentBox";
1109
1170
  var APP_PATH = `/Applications/${APP_NAME}.app`;
1110
1171
  var APP_BUNDLE_ID = "com.madarco.agentbox-tray";
@@ -1123,23 +1184,26 @@ async function installTray(opts = {}) {
1123
1184
  await execa("pkill", ["-x", APP_NAME]).catch(() => void 0);
1124
1185
  await execa("pkill", ["-x", LEGACY_APP_NAME]).catch(() => void 0);
1125
1186
  if (opts.uninstall) {
1126
- if (existsSync(APP_PATH)) rmSync(APP_PATH, { recursive: true, force: true });
1127
- if (existsSync(LEGACY_APP_PATH)) rmSync(LEGACY_APP_PATH, { recursive: true, force: true });
1187
+ if (existsSync2(APP_PATH)) rmSync(APP_PATH, { recursive: true, force: true });
1188
+ if (existsSync2(LEGACY_APP_PATH)) rmSync(LEGACY_APP_PATH, { recursive: true, force: true });
1189
+ writeUpdateState({ traySha: void 0 });
1128
1190
  say(`Removed ${APP_PATH}. (Launch-at-login is unregistered by the app itself.)`);
1129
1191
  return { ran: true };
1130
1192
  }
1131
1193
  let zip;
1194
+ let sha;
1132
1195
  let scratch = null;
1133
1196
  if (opts.zip) {
1134
- if (!existsSync(opts.zip)) {
1197
+ if (!existsSync2(opts.zip)) {
1135
1198
  say(`No zip at ${opts.zip}.`);
1136
1199
  return { ran: false, reason: "zip-missing" };
1137
1200
  }
1138
1201
  zip = opts.zip;
1202
+ sha = createHash2("sha256").update(readFileSync2(zip)).digest("hex");
1139
1203
  } else {
1140
- scratch = mkdtempSync(join(tmpdir(), "agentbox-tray-"));
1204
+ scratch = mkdtempSync(join2(tmpdir(), "agentbox-tray-"));
1141
1205
  try {
1142
- zip = await downloadAndVerify(opts.tag ?? DEFAULT_TAG, scratch, say);
1206
+ ({ zipPath: zip, sha } = await downloadAndVerify(opts.tag ?? DEFAULT_TAG, scratch, say));
1143
1207
  } catch (err) {
1144
1208
  rmSync(scratch, { recursive: true, force: true });
1145
1209
  say(`Download failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -1147,10 +1211,11 @@ async function installTray(opts = {}) {
1147
1211
  }
1148
1212
  }
1149
1213
  try {
1150
- if (existsSync(APP_PATH)) rmSync(APP_PATH, { recursive: true, force: true });
1214
+ if (existsSync2(APP_PATH)) rmSync(APP_PATH, { recursive: true, force: true });
1151
1215
  await execa("ditto", ["-x", "-k", zip, "/Applications"]);
1152
- if (existsSync(LEGACY_APP_PATH)) rmSync(LEGACY_APP_PATH, { recursive: true, force: true });
1216
+ if (existsSync2(LEGACY_APP_PATH)) rmSync(LEGACY_APP_PATH, { recursive: true, force: true });
1153
1217
  await execa("xattr", ["-dr", "com.apple.quarantine", APP_PATH]).catch(() => void 0);
1218
+ writeUpdateState({ traySha: sha });
1154
1219
  await launchTray(say);
1155
1220
  } finally {
1156
1221
  if (scratch) rmSync(scratch, { recursive: true, force: true });
@@ -1158,6 +1223,33 @@ async function installTray(opts = {}) {
1158
1223
  say(`Installed ${APP_PATH} and launched it (look for the box icon in the menu bar).`);
1159
1224
  return { ran: true };
1160
1225
  }
1226
+ function trayInstalled() {
1227
+ return process.platform === "darwin" && existsSync2(APP_PATH);
1228
+ }
1229
+ async function fetchTraySidecarSha(tag2 = DEFAULT_TAG) {
1230
+ try {
1231
+ const { stdout } = await execa("curl", [
1232
+ "-fsSL",
1233
+ "--max-time",
1234
+ "5",
1235
+ `${RELEASE_BASE}/${tag2}/${APP_NAME}.zip.sha256`
1236
+ ]);
1237
+ return parseSidecarSha(stdout);
1238
+ } catch {
1239
+ return void 0;
1240
+ }
1241
+ }
1242
+ function parseSidecarSha(body) {
1243
+ const first = body.trim().split(/\s+/)[0]?.toLowerCase();
1244
+ return first && /^[0-9a-f]{64}$/.test(first) ? first : void 0;
1245
+ }
1246
+ function decideTrayUpdate(input) {
1247
+ if (!input.installed) return { update: false, reason: "not-installed" };
1248
+ if (input.latestSha === void 0) return { update: false, reason: "no-latest-sha" };
1249
+ if (input.stampedSha === void 0) return { update: true, reason: "no-stamp" };
1250
+ if (input.stampedSha !== input.latestSha) return { update: true, reason: "mismatch" };
1251
+ return { update: false, reason: "up-to-date" };
1252
+ }
1161
1253
  async function trayRunning() {
1162
1254
  return await execa("pgrep", ["-x", APP_NAME]).catch(() => null) !== null;
1163
1255
  }
@@ -1174,17 +1266,17 @@ async function launchTray(say) {
1174
1266
  }
1175
1267
  async function downloadAndVerify(tag2, dir, say) {
1176
1268
  const base = `${RELEASE_BASE}/${tag2}`;
1177
- const zipPath = join(dir, `${APP_NAME}.zip`);
1178
- const shaPath = join(dir, `${APP_NAME}.zip.sha256`);
1269
+ const zipPath = join2(dir, `${APP_NAME}.zip`);
1270
+ const shaPath = join2(dir, `${APP_NAME}.zip.sha256`);
1179
1271
  say(`Downloading ${APP_NAME} (${tag2})\u2026`);
1180
1272
  await execa("curl", ["-fSL", "-o", zipPath, `${base}/${APP_NAME}.zip`]);
1181
1273
  await execa("curl", ["-fSL", "-o", shaPath, `${base}/${APP_NAME}.zip.sha256`]);
1182
- const expected = readFileSync(shaPath, "utf8").trim().split(/\s+/)[0]?.toLowerCase();
1183
- const actual = createHash2("sha256").update(readFileSync(zipPath)).digest("hex");
1274
+ const expected = parseSidecarSha(readFileSync2(shaPath, "utf8"));
1275
+ const actual = createHash2("sha256").update(readFileSync2(zipPath)).digest("hex");
1184
1276
  if (!expected || expected !== actual) {
1185
1277
  throw new Error(`checksum mismatch (expected ${expected ?? "none"}, got ${actual})`);
1186
1278
  }
1187
- return zipPath;
1279
+ return { zipPath, sha: actual };
1188
1280
  }
1189
1281
  var installTrayCommand = new Command2("tray").description("Download and install the AgentBox Tray macOS menu-bar app into /Applications").option("--uninstall", "quit and remove the menu-bar app").option("--tag <tag>", "release tag to install from (default: tray-latest)").option("--zip <path>", "install a local AgentBox.zip instead of downloading").action(async (opts) => {
1190
1282
  intro(opts.uninstall ? "Removing AgentBox Tray\u2026" : "Installing AgentBox Tray\u2026");
@@ -1194,7 +1286,7 @@ var installTrayCommand = new Command2("tray").description("Download and install
1194
1286
  });
1195
1287
 
1196
1288
  // src/commands/app.ts
1197
- var DIAGNOSTIC_REPORTS_DIR = join2(homedir(), "Library/Logs/DiagnosticReports");
1289
+ var DIAGNOSTIC_REPORTS_DIR = join3(homedir2(), "Library/Logs/DiagnosticReports");
1198
1290
  var LOG_PREDICATE = `subsystem == "${APP_BUNDLE_ID}"`;
1199
1291
  function ensureMac() {
1200
1292
  if (process.platform === "darwin") return true;
@@ -1221,14 +1313,14 @@ async function stopTray() {
1221
1313
  await execa2("pkill", ["-x", LEGACY_APP_NAME]).catch(() => void 0);
1222
1314
  }
1223
1315
  function ensureInstalled() {
1224
- if (existsSync2(APP_PATH)) return true;
1316
+ if (existsSync3(APP_PATH)) return true;
1225
1317
  log5.error(`${APP_PATH} is not installed. Run \`agentbox install tray\` first.`);
1226
1318
  process.exitCode = 1;
1227
1319
  return false;
1228
1320
  }
1229
1321
  var IPS_NAME = new RegExp(`^${APP_NAME}[-_].*\\.ips$`, "i");
1230
1322
  function listCrashReports() {
1231
- const dirs = [DIAGNOSTIC_REPORTS_DIR, join2(DIAGNOSTIC_REPORTS_DIR, "Retired")];
1323
+ const dirs = [DIAGNOSTIC_REPORTS_DIR, join3(DIAGNOSTIC_REPORTS_DIR, "Retired")];
1232
1324
  const reports = [];
1233
1325
  for (const dir of dirs) {
1234
1326
  let names;
@@ -1239,7 +1331,7 @@ function listCrashReports() {
1239
1331
  }
1240
1332
  for (const n of names) {
1241
1333
  if (!IPS_NAME.test(n)) continue;
1242
- const path = join2(dir, n);
1334
+ const path = join3(dir, n);
1243
1335
  try {
1244
1336
  reports.push({ name: n, path, mtimeMs: statSync(path).mtimeMs });
1245
1337
  } catch {
@@ -1279,7 +1371,7 @@ function printCrashReports(reports, limit = 5) {
1279
1371
  var statusSub = new Command3("status").description("Show whether the AgentBox app is running, with pid(s)").option("--json", "emit { running, pids, installed, appPath } as JSON").action(async (opts) => {
1280
1372
  const mac = process.platform === "darwin";
1281
1373
  const pids = mac ? await trayPids() : [];
1282
- const installed = mac && existsSync2(APP_PATH);
1374
+ const installed = mac && existsSync3(APP_PATH);
1283
1375
  if (opts.json) {
1284
1376
  process.stdout.write(
1285
1377
  JSON.stringify({ running: pids.length > 0, pids, installed, appPath: APP_PATH }, null, 2) + "\n"
@@ -1389,14 +1481,14 @@ async function writeBugReportBundle(outPath, last) {
1389
1481
  const cliVersion = AGENTBOX_VERSION;
1390
1482
  const macVersion = (await execa2("sw_vers", ["-productVersion"], { reject: false }).catch(() => null))?.stdout ?? "unknown";
1391
1483
  const pids = await trayPids();
1392
- const installed = existsSync2(APP_PATH);
1484
+ const installed = existsSync3(APP_PATH);
1393
1485
  const { text: logText, failureNote } = await trayUnifiedLog(last);
1394
1486
  const reports = listCrashReports();
1395
1487
  const newest = reports[0];
1396
1488
  let newestBody = "";
1397
1489
  if (newest) {
1398
1490
  try {
1399
- newestBody = readFileSync2(newest.path, "utf8");
1491
+ newestBody = readFileSync3(newest.path, "utf8");
1400
1492
  } catch (err) {
1401
1493
  newestBody = `(failed to read ${newest.path}: ${err instanceof Error ? err.message : String(err)})`;
1402
1494
  }
@@ -1422,7 +1514,7 @@ async function writeBugReportBundle(outPath, last) {
1422
1514
  newestBody.trimEnd(),
1423
1515
  ""
1424
1516
  ].join("\n");
1425
- writeFileSync(outPath, bundle);
1517
+ writeFileSync2(outPath, bundle);
1426
1518
  s.stop("Diagnostics collected");
1427
1519
  log5.info(`Wrote bug-report bundle to ${outPath}`);
1428
1520
  }
@@ -1500,14 +1592,14 @@ async function password(opts) {
1500
1592
  // src/control-plane/ensure-repo-installed.ts
1501
1593
  import { confirm as confirm2, isCancel as isCancel2, log as clog, note } from "@clack/prompts";
1502
1594
  import { spawn as spawn2 } from "child_process";
1503
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
1504
- import { homedir as homedir2 } from "os";
1505
- import { join as join3 } from "path";
1595
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
1596
+ import { homedir as homedir3 } from "os";
1597
+ import { join as join4 } from "path";
1506
1598
  import { execa as execa3 } from "execa";
1507
- var CP_DIR = join3(homedir2(), ".agentbox", "control-plane");
1508
- var ENV_PATH = join3(CP_DIR, "control-plane.env");
1509
- var META_PATH = join3(CP_DIR, "control-plane.json");
1510
- var REPOS_STATE = join3(CP_DIR, "repos.json");
1599
+ var CP_DIR = join4(homedir3(), ".agentbox", "control-plane");
1600
+ var ENV_PATH = join4(CP_DIR, "control-plane.env");
1601
+ var META_PATH = join4(CP_DIR, "control-plane.json");
1602
+ var REPOS_STATE = join4(CP_DIR, "repos.json");
1511
1603
  function openInBrowser(url) {
1512
1604
  try {
1513
1605
  const child = spawn2(hostOpenCommand(), [url], { detached: true, stdio: "ignore" });
@@ -1517,14 +1609,14 @@ function openInBrowser(url) {
1517
1609
  }
1518
1610
  function loadControlPlaneMeta() {
1519
1611
  try {
1520
- return JSON.parse(readFileSync3(META_PATH, "utf8"));
1612
+ return JSON.parse(readFileSync4(META_PATH, "utf8"));
1521
1613
  } catch {
1522
1614
  return null;
1523
1615
  }
1524
1616
  }
1525
1617
  function loadLocalControlPlaneEnv() {
1526
- if (!existsSync3(ENV_PATH)) return;
1527
- for (const line of readFileSync3(ENV_PATH, "utf8").split("\n")) {
1618
+ if (!existsSync4(ENV_PATH)) return;
1619
+ for (const line of readFileSync4(ENV_PATH, "utf8").split("\n")) {
1528
1620
  const m = /^([A-Z_]+)=(.*)$/.exec(line.trim());
1529
1621
  if (m && !process.env[m[1]]) process.env[m[1]] = m[2];
1530
1622
  }
@@ -1570,15 +1662,15 @@ function addRepoUrl(meta) {
1570
1662
  }
1571
1663
  function readReposState() {
1572
1664
  try {
1573
- return JSON.parse(readFileSync3(REPOS_STATE, "utf8"));
1665
+ return JSON.parse(readFileSync4(REPOS_STATE, "utf8"));
1574
1666
  } catch {
1575
1667
  return {};
1576
1668
  }
1577
1669
  }
1578
1670
  function writeReposState(state) {
1579
1671
  try {
1580
- mkdirSync(CP_DIR, { recursive: true });
1581
- writeFileSync2(REPOS_STATE, JSON.stringify(state, null, 2) + "\n", { mode: 384 });
1672
+ mkdirSync2(CP_DIR, { recursive: true });
1673
+ writeFileSync3(REPOS_STATE, JSON.stringify(state, null, 2) + "\n", { mode: 384 });
1582
1674
  } catch {
1583
1675
  }
1584
1676
  }
@@ -1641,8 +1733,8 @@ import { Command as Command5 } from "commander";
1641
1733
 
1642
1734
  // src/auth.ts
1643
1735
  import { readFile } from "fs/promises";
1644
- import { join as join4 } from "path";
1645
- var AUTH_FILE = join4(STATE_DIR, "auth.json");
1736
+ import { join as join5 } from "path";
1737
+ var AUTH_FILE = join5(STATE_DIR, "auth.json");
1646
1738
  async function resolveClaudeAuth(processEnv, opts = {}) {
1647
1739
  const env = {};
1648
1740
  const envApiKey = processEnv["ANTHROPIC_API_KEY"];
@@ -1691,8 +1783,8 @@ function cloudSizingProviderOptions(providerName, cfg) {
1691
1783
 
1692
1784
  // src/lib/queue/assert-creds.ts
1693
1785
  import { stat } from "fs/promises";
1694
- import { homedir as homedir3 } from "os";
1695
- import { join as join5 } from "path";
1786
+ import { homedir as homedir4 } from "os";
1787
+ import { join as join6 } from "path";
1696
1788
  async function fileExists(p) {
1697
1789
  try {
1698
1790
  await stat(p);
@@ -1710,14 +1802,14 @@ async function claudeCredStatus(env, isCloud) {
1710
1802
  }
1711
1803
  async function codexAuthAvailable(image, env = process.env) {
1712
1804
  if ((env["OPENAI_API_KEY"] ?? "").length > 0) return true;
1713
- if (await fileExists(join5(homedir3(), ".codex", "auth.json"))) return true;
1805
+ if (await fileExists(join6(homedir4(), ".codex", "auth.json"))) return true;
1714
1806
  return volumeHasCodexAuth(SHARED_CODEX_VOLUME, image);
1715
1807
  }
1716
1808
  async function opencodeAuthAvailable(image, env = process.env) {
1717
1809
  for (const k of OPENCODE_FORWARDED_ENV_KEYS) {
1718
1810
  if ((env[k] ?? "").length > 0) return true;
1719
1811
  }
1720
- if (await fileExists(join5(homedir3(), ".local", "share", "opencode", "auth.json"))) return true;
1812
+ if (await fileExists(join6(homedir4(), ".local", "share", "opencode", "auth.json"))) return true;
1721
1813
  return volumeHasOpencodeAuth(SHARED_OPENCODE_VOLUME, image);
1722
1814
  }
1723
1815
  var MESSAGES = {
@@ -1759,16 +1851,16 @@ function buildPromptArgs(agentKind, prompt, userArgs) {
1759
1851
  }
1760
1852
 
1761
1853
  // src/lib/carry-resync.ts
1762
- import { join as join8 } from "path";
1854
+ import { join as join9 } from "path";
1763
1855
 
1764
1856
  // src/lib/carry-resolve.ts
1765
1857
  import { realpath, stat as stat3 } from "fs/promises";
1766
- import { homedir as homedir4 } from "os";
1767
- import { isAbsolute, join as join7, normalize, relative, resolve } from "path";
1858
+ import { homedir as homedir5 } from "os";
1859
+ import { isAbsolute, join as join8, normalize, relative, resolve } from "path";
1768
1860
 
1769
1861
  // src/lib/dir-breakdown.ts
1770
1862
  import { readdir, stat as stat2 } from "fs/promises";
1771
- import { join as join6 } from "path";
1863
+ import { join as join7 } from "path";
1772
1864
  var DEFAULT_CP_EXCLUDES = [
1773
1865
  ".git",
1774
1866
  "node_modules",
@@ -1833,7 +1925,7 @@ async function buildNode(abs, rel, tokens, seen) {
1833
1925
  for (const name of entries) {
1834
1926
  const childRel = rel ? `${rel}/${name}` : name;
1835
1927
  if (isPathExcluded(childRel, tokens)) continue;
1836
- const full = join6(abs, name);
1928
+ const full = join7(abs, name);
1837
1929
  let st;
1838
1930
  try {
1839
1931
  st = await stat2(full);
@@ -1892,7 +1984,7 @@ function fmtBytes(n) {
1892
1984
  var DENYLIST_DEST_PREFIXES = ["/proc", "/sys", "/dev"];
1893
1985
  var DENYLIST_DEST_EXACT = /* @__PURE__ */ new Set(["/etc/passwd", "/etc/shadow"]);
1894
1986
  async function resolveCarry(items, opts) {
1895
- const home = opts.homeDir ?? homedir4();
1987
+ const home = opts.homeDir ?? homedir5();
1896
1988
  const cap = opts.maxBytes ?? BUILT_IN_DEFAULTS.box.cpMaxBytes;
1897
1989
  const projectRoot = opts.projectRoot;
1898
1990
  const replacements = opts.replacements ?? {};
@@ -2061,7 +2153,7 @@ async function dirSizeCapped(dir, cap, exclude = []) {
2061
2153
  }
2062
2154
  for (const name of names) {
2063
2155
  if (total > cap) return;
2064
- const full = join7(d, name);
2156
+ const full = join8(d, name);
2065
2157
  const rel = relative(dir, full).split(/[\\/]/).join("/");
2066
2158
  if (exclude.length > 0 && isPathExcluded(rel, exclude)) continue;
2067
2159
  let st;
@@ -2091,7 +2183,7 @@ async function resyncCarryFiles(args) {
2091
2183
  });
2092
2184
  const prior = args.box.carry?.entries ?? [];
2093
2185
  if (prior.length === 0) return { recopied: 0, skippedNew: 0 };
2094
- const items = await loadCarrySection(join8(args.projectRoot, "agentbox.yaml"));
2186
+ const items = await loadCarrySection(join9(args.projectRoot, "agentbox.yaml"));
2095
2187
  if (items.length === 0) return { recopied: 0, skippedNew: 0 };
2096
2188
  const cfg = await loadEffectiveConfig(args.projectRoot);
2097
2189
  const resolved = await resolveCarry(items, {
@@ -2372,7 +2464,7 @@ function makeProgressReporter(verbose) {
2372
2464
  }
2373
2465
 
2374
2466
  // src/lib/launch-recap.ts
2375
- import { homedir as homedir5 } from "os";
2467
+ import { homedir as homedir6 } from "os";
2376
2468
  import { note as note2 } from "@clack/prompts";
2377
2469
 
2378
2470
  // src/lib/from-branch.ts
@@ -2469,7 +2561,7 @@ async function resolveBranchSelection(opts) {
2469
2561
 
2470
2562
  // src/lib/launch-recap.ts
2471
2563
  function homeShorten(p) {
2472
- const home = homedir5();
2564
+ const home = homedir6();
2473
2565
  return p === home || p.startsWith(home + "/") ? "~" + p.slice(home.length) : p;
2474
2566
  }
2475
2567
  function whiten(text3) {
@@ -2563,7 +2655,7 @@ async function cloudAgentCreate(args) {
2563
2655
 
2564
2656
  // src/lib/carry-gate.ts
2565
2657
  import { readFile as readFile2 } from "fs/promises";
2566
- import { join as join9 } from "path";
2658
+ import { join as join10 } from "path";
2567
2659
  import { log as log8 } from "@clack/prompts";
2568
2660
 
2569
2661
  // src/fmt.ts
@@ -2658,7 +2750,7 @@ function pad(s, w) {
2658
2750
  async function runCarryGate(args) {
2659
2751
  const emit = args.onLog ?? (() => {
2660
2752
  });
2661
- const yamlPath = join9(args.projectRoot, "agentbox.yaml");
2753
+ const yamlPath = join10(args.projectRoot, "agentbox.yaml");
2662
2754
  let yamlText = "";
2663
2755
  try {
2664
2756
  yamlText = await readFile2(yamlPath, "utf8");
@@ -2719,9 +2811,9 @@ async function runQueuedCarryGate(args) {
2719
2811
 
2720
2812
  // src/session-teleport/claude.ts
2721
2813
  import { mkdir, mkdtemp, readdir as readdir2, readFile as readFile3, stat as stat4, writeFile } from "fs/promises";
2722
- import { existsSync as existsSync4 } from "fs";
2723
- import { homedir as homedir6, tmpdir as tmpdir2 } from "os";
2724
- import { join as join10 } from "path";
2814
+ import { existsSync as existsSync5 } from "fs";
2815
+ import { homedir as homedir7, tmpdir as tmpdir2 } from "os";
2816
+ import { join as join11 } from "path";
2725
2817
 
2726
2818
  // src/session-teleport/cwd-encoding.ts
2727
2819
  function encodeClaudeProjectsDir(absPath) {
@@ -2741,22 +2833,22 @@ var TeleportError = class extends Error {
2741
2833
  // src/session-teleport/claude.ts
2742
2834
  var BOX_CLAUDE_PROJECTS_DIR = `/home/vscode/.claude/projects/${BOX_WORKSPACE_ENCODED}`;
2743
2835
  async function resolveClaudeTeleport(opts) {
2744
- const hostHome = opts.hostHome ?? homedir6();
2745
- const projectDir = join10(
2836
+ const hostHome = opts.hostHome ?? homedir7();
2837
+ const projectDir = join11(
2746
2838
  hostHome,
2747
2839
  ".claude",
2748
2840
  "projects",
2749
2841
  encodeClaudeProjectsDir(opts.hostCwd)
2750
2842
  );
2751
- if (!existsSync4(projectDir)) {
2843
+ if (!existsSync5(projectDir)) {
2752
2844
  throw new TeleportError(
2753
2845
  `no Claude session history found on the host for ${opts.hostCwd} (expected at ${projectDir}). Run \`claude\` here at least once before using -c / --resume.`
2754
2846
  );
2755
2847
  }
2756
2848
  const sessionPath = await pickSessionFile(projectDir, opts.mode);
2757
2849
  const sessionId = sessionPath.replace(/\.jsonl$/u, "").split("/").pop() ?? "";
2758
- const stage = await mkdtemp(join10(tmpdir2(), "agentbox-teleport-claude-"));
2759
- const stagedFile = join10(stage, `${sessionId}.jsonl`);
2850
+ const stage = await mkdtemp(join11(tmpdir2(), "agentbox-teleport-claude-"));
2851
+ const stagedFile = join11(stage, `${sessionId}.jsonl`);
2760
2852
  await rewriteSessionFile(sessionPath, stagedFile, opts.hostCwd);
2761
2853
  opts.log?.(`teleport: claude session ${sessionId} staged for upload`);
2762
2854
  return {
@@ -2770,8 +2862,8 @@ async function resolveClaudeTeleport(opts) {
2770
2862
  }
2771
2863
  async function pickSessionFile(projectDir, mode) {
2772
2864
  if (mode.kind === "resume") {
2773
- const target = join10(projectDir, `${mode.id}.jsonl`);
2774
- if (!existsSync4(target)) {
2865
+ const target = join11(projectDir, `${mode.id}.jsonl`);
2866
+ if (!existsSync5(target)) {
2775
2867
  throw new TeleportError(
2776
2868
  `Claude session "${mode.id}" not found in ${projectDir}. List available sessions with: ls "${projectDir}"`
2777
2869
  );
@@ -2787,7 +2879,7 @@ async function pickSessionFile(projectDir, mode) {
2787
2879
  }
2788
2880
  const stats = await Promise.all(
2789
2881
  jsonl.map(async (name) => {
2790
- const full = join10(projectDir, name);
2882
+ const full = join11(projectDir, name);
2791
2883
  const s = await stat4(full);
2792
2884
  return { full, mtimeMs: s.mtimeMs };
2793
2885
  })
@@ -2821,19 +2913,19 @@ async function rewriteSessionFile(src, dst, hostCwd) {
2821
2913
  }
2822
2914
  out.push(line);
2823
2915
  }
2824
- await mkdir(join10(dst, ".."), { recursive: true });
2916
+ await mkdir(join11(dst, ".."), { recursive: true });
2825
2917
  await writeFile(dst, out.join("\n"), "utf8");
2826
2918
  }
2827
2919
 
2828
2920
  // src/session-teleport/codex.ts
2829
2921
  import { mkdtemp as mkdtemp2, readdir as readdir3, readFile as readFile4, stat as stat5, writeFile as writeFile2 } from "fs/promises";
2830
- import { existsSync as existsSync5 } from "fs";
2831
- import { homedir as homedir7, tmpdir as tmpdir3 } from "os";
2832
- import { join as join11 } from "path";
2922
+ import { existsSync as existsSync6 } from "fs";
2923
+ import { homedir as homedir8, tmpdir as tmpdir3 } from "os";
2924
+ import { join as join12 } from "path";
2833
2925
  async function resolveCodexTeleport(opts) {
2834
- const hostHome = opts.hostHome ?? homedir7();
2835
- const sessionsRoot = join11(hostHome, ".codex", "sessions");
2836
- if (!existsSync5(sessionsRoot)) {
2926
+ const hostHome = opts.hostHome ?? homedir8();
2927
+ const sessionsRoot = join12(hostHome, ".codex", "sessions");
2928
+ if (!existsSync6(sessionsRoot)) {
2837
2929
  throw new TeleportError(
2838
2930
  `no Codex session history found on the host (expected at ${sessionsRoot}). Run \`codex\` at least once before using -c / --resume.`
2839
2931
  );
@@ -2874,8 +2966,8 @@ async function resolveCodexTeleport(opts) {
2874
2966
  matching.sort((a, b) => b.mtimeMs - a.mtimeMs);
2875
2967
  picked = matching[0];
2876
2968
  }
2877
- const stage = await mkdtemp2(join11(tmpdir3(), "agentbox-teleport-codex-"));
2878
- const stagedFile = join11(stage, posixBasename(picked.relPath));
2969
+ const stage = await mkdtemp2(join12(tmpdir3(), "agentbox-teleport-codex-"));
2970
+ const stagedFile = join12(stage, posixBasename(picked.relPath));
2879
2971
  await rewriteCodexSession(picked.hostPath, stagedFile, opts.hostCwd);
2880
2972
  opts.log?.(`teleport: codex session ${picked.uuid} staged for upload`);
2881
2973
  const boxParentDir = `/home/vscode/.codex/sessions/${posixDirname(picked.relPath)}`;
@@ -2901,21 +2993,21 @@ async function listCodexSessions(sessionsRoot) {
2901
2993
  const years = await safeReaddir(sessionsRoot);
2902
2994
  for (const y of years) {
2903
2995
  if (!/^\d{4}$/u.test(y)) continue;
2904
- const yDir = join11(sessionsRoot, y);
2996
+ const yDir = join12(sessionsRoot, y);
2905
2997
  const months = await safeReaddir(yDir);
2906
2998
  for (const m of months) {
2907
2999
  if (!/^\d{2}$/u.test(m)) continue;
2908
- const mDir = join11(yDir, m);
3000
+ const mDir = join12(yDir, m);
2909
3001
  const days = await safeReaddir(mDir);
2910
3002
  for (const d of days) {
2911
3003
  if (!/^\d{2}$/u.test(d)) continue;
2912
- const dDir = join11(mDir, d);
3004
+ const dDir = join12(mDir, d);
2913
3005
  const files = await safeReaddir(dDir);
2914
3006
  for (const name of files) {
2915
3007
  if (!name.startsWith("rollout-") || !name.endsWith(".jsonl")) continue;
2916
3008
  const uuid = extractCodexUuid(name);
2917
3009
  if (uuid === null) continue;
2918
- const hostPath = join11(dDir, name);
3010
+ const hostPath = join12(dDir, name);
2919
3011
  let mtimeMs = 0;
2920
3012
  try {
2921
3013
  mtimeMs = (await stat5(hostPath)).mtimeMs;
@@ -3052,26 +3144,26 @@ async function uploadTeleport(input) {
3052
3144
 
3053
3145
  // src/session-teleport/plan.ts
3054
3146
  import { mkdtemp as mkdtemp3, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
3055
- import { existsSync as existsSync6 } from "fs";
3056
- import { homedir as homedir8, tmpdir as tmpdir4 } from "os";
3057
- import { basename, isAbsolute as isAbsolute2, join as join12, resolve as resolve2 } from "path";
3147
+ import { existsSync as existsSync7 } from "fs";
3148
+ import { homedir as homedir9, tmpdir as tmpdir4 } from "os";
3149
+ import { basename, isAbsolute as isAbsolute2, join as join13, resolve as resolve2 } from "path";
3058
3150
  var BOX_CLAUDE_PLANS_DIR = "/home/vscode/.claude/plans";
3059
3151
  function expandHome(p, hostHome) {
3060
3152
  if (p === "~") return hostHome;
3061
- if (p.startsWith("~/")) return join12(hostHome, p.slice(2));
3153
+ if (p.startsWith("~/")) return join13(hostHome, p.slice(2));
3062
3154
  return isAbsolute2(p) ? p : resolve2(p);
3063
3155
  }
3064
3156
  async function resolvePlanTeleport(opts) {
3065
- const hostHome = opts.hostHome ?? homedir8();
3157
+ const hostHome = opts.hostHome ?? homedir9();
3066
3158
  const planFile = expandHome(opts.planPath, hostHome);
3067
- if (!existsSync6(planFile)) {
3159
+ if (!existsSync7(planFile)) {
3068
3160
  throw new TeleportError(
3069
3161
  `plan file not found on the host: ${planFile}. Pass --plan with the path to a Claude Code plan (e.g. ~/.claude/plans/<slug>.md).`
3070
3162
  );
3071
3163
  }
3072
3164
  const name = basename(planFile);
3073
- const stage = await mkdtemp3(join12(tmpdir4(), "agentbox-teleport-plan-"));
3074
- const stagedFile = join12(stage, name);
3165
+ const stage = await mkdtemp3(join13(tmpdir4(), "agentbox-teleport-plan-"));
3166
+ const stagedFile = join13(stage, name);
3075
3167
  const raw = await readFile5(planFile, "utf8");
3076
3168
  const absCwd = opts.hostCwd ? resolve2(expandHome(opts.hostCwd, hostHome)) : "";
3077
3169
  const rewritten = absCwd ? raw.split(absCwd).join(BOX_WORKSPACE) : raw;
@@ -3089,37 +3181,37 @@ async function resolvePlanTeleport(opts) {
3089
3181
 
3090
3182
  // src/lib/install-hint.ts
3091
3183
  import { log as log9 } from "@clack/prompts";
3092
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
3093
- import { homedir as homedir9 } from "os";
3094
- import { join as join13 } from "path";
3184
+ import { existsSync as existsSync8, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
3185
+ import { homedir as homedir10 } from "os";
3186
+ import { join as join14 } from "path";
3095
3187
  function maybeShowInstallHint() {
3096
3188
  try {
3097
- const skill = join13(homedir9(), ".claude", "skills", "agentbox", "SKILL.md");
3098
- if (existsSync7(skill)) return;
3099
- const marker = join13(homedir9(), ".agentbox", "install-hint-shown");
3100
- if (existsSync7(marker)) return;
3101
- mkdirSync2(join13(homedir9(), ".agentbox"), { recursive: true });
3102
- writeFileSync3(marker, "");
3189
+ const skill = join14(homedir10(), ".claude", "skills", "agentbox", "SKILL.md");
3190
+ if (existsSync8(skill)) return;
3191
+ const marker = join14(homedir10(), ".agentbox", "install-hint-shown");
3192
+ if (existsSync8(marker)) return;
3193
+ mkdirSync3(join14(homedir10(), ".agentbox"), { recursive: true });
3194
+ writeFileSync4(marker, "");
3103
3195
  log9.info("tip: run 'agentbox install' to enable the /agentbox fork command in host Claude");
3104
3196
  } catch {
3105
3197
  }
3106
3198
  }
3107
3199
 
3108
3200
  // src/lib/log-file.ts
3109
- import { closeSync, mkdirSync as mkdirSync3, openSync, renameSync, symlinkSync, unlinkSync, writeFileSync as writeFileSync4, writeSync } from "fs";
3110
- import { homedir as homedir10 } from "os";
3111
- import { join as join14 } from "path";
3201
+ import { closeSync, mkdirSync as mkdirSync4, openSync, renameSync, symlinkSync, unlinkSync, writeFileSync as writeFileSync5, writeSync } from "fs";
3202
+ import { homedir as homedir11 } from "os";
3203
+ import { join as join15 } from "path";
3112
3204
  function stateDir() {
3113
- return process.env.AGENTBOX_HOME ?? join14(homedir10(), ".agentbox");
3205
+ return process.env.AGENTBOX_HOME ?? join15(homedir11(), ".agentbox");
3114
3206
  }
3115
3207
  function logsDir() {
3116
- return join14(stateDir(), "logs");
3208
+ return join15(stateDir(), "logs");
3117
3209
  }
3118
3210
  function openCommandLog(command) {
3119
3211
  const dir = logsDir();
3120
- mkdirSync3(dir, { recursive: true });
3121
- const path = join14(dir, `${command}.log`);
3122
- const prev = join14(dir, `${command}.log.prev`);
3212
+ mkdirSync4(dir, { recursive: true });
3213
+ const path = join15(dir, `${command}.log`);
3214
+ const prev = join15(dir, `${command}.log.prev`);
3123
3215
  try {
3124
3216
  renameSync(path, prev);
3125
3217
  } catch {
@@ -3179,7 +3271,7 @@ function openCommandLog(command) {
3179
3271
  };
3180
3272
  }
3181
3273
  function updateLatestSymlink(dir, target) {
3182
- const link = join14(dir, "latest.log");
3274
+ const link = join15(dir, "latest.log");
3183
3275
  try {
3184
3276
  unlinkSync(link);
3185
3277
  } catch {
@@ -3188,7 +3280,7 @@ function updateLatestSymlink(dir, target) {
3188
3280
  symlinkSync(target, link);
3189
3281
  } catch {
3190
3282
  try {
3191
- writeFileSync4(link, target + "\n");
3283
+ writeFileSync5(link, target + "\n");
3192
3284
  } catch {
3193
3285
  }
3194
3286
  }
@@ -3283,7 +3375,7 @@ async function setupPortlessHost(opts = {}) {
3283
3375
  async function maybePromptPortless(args) {
3284
3376
  if (args.enabled !== void 0) return args.enabled;
3285
3377
  if (args.engine === "orbstack") return false;
3286
- if (!process.stdin.isTTY || args.yes) return false;
3378
+ if (!process.stdin.isTTY || args.yes) return resolvePortlessNonInteractive(args);
3287
3379
  const answer = await confirm({
3288
3380
  message: "Use Portless to give box web apps a friendly local URL? (installs the portless CLI and starts a local proxy if needed)",
3289
3381
  initialValue: true
@@ -3298,6 +3390,18 @@ async function maybePromptPortless(args) {
3298
3390
  if (answer) await setupPortlessHost();
3299
3391
  return answer;
3300
3392
  }
3393
+ async function resolvePortlessNonInteractive(args) {
3394
+ if (args.enabled !== void 0) return args.enabled;
3395
+ if (args.engine === "orbstack") return false;
3396
+ const state = await detectPortless();
3397
+ if (state.proxyRunning) {
3398
+ try {
3399
+ await setConfigValue("global", "portless.enabled", true, args.cwd, { raw: false });
3400
+ } catch {
3401
+ }
3402
+ }
3403
+ return state.proxyRunning;
3404
+ }
3301
3405
 
3302
3406
  // src/wizard.ts
3303
3407
  import { basename as basename2 } from "path";
@@ -3628,7 +3732,7 @@ async function renderDocker(status) {
3628
3732
  }
3629
3733
  async function daytonaStatus() {
3630
3734
  try {
3631
- const mod = await import("./dist-LJHS4PTC.js");
3735
+ const mod = await import("./dist-AN5NUXA5.js");
3632
3736
  return await mod.getDaytonaStatus();
3633
3737
  } catch (err) {
3634
3738
  return {
@@ -3639,7 +3743,7 @@ async function daytonaStatus() {
3639
3743
  }
3640
3744
  async function e2bStatus() {
3641
3745
  try {
3642
- const mod = await import("./dist-UR2DB2HT.js");
3746
+ const mod = await import("./dist-SJRMFVRV.js");
3643
3747
  const cred = mod.readE2bCredStatus();
3644
3748
  if (cred.auth === "none") {
3645
3749
  return { configured: false, reason: "not configured \u2014 run `agentbox e2b login`" };
@@ -3872,73 +3976,73 @@ function describeError(err) {
3872
3976
 
3873
3977
  // src/commands/claude.ts
3874
3978
  import { spawn as spawn3 } from "child_process";
3875
- import { existsSync as existsSync8 } from "fs";
3979
+ import { existsSync as existsSync9 } from "fs";
3876
3980
  import { randomUUID } from "crypto";
3877
3981
  import { setTimeout as sleep3 } from "timers/promises";
3878
3982
 
3879
3983
  // src/lib/claude-login-session.ts
3880
3984
  import {
3881
- mkdirSync as mkdirSync4,
3985
+ mkdirSync as mkdirSync5,
3882
3986
  readdirSync as readdirSync2,
3883
- readFileSync as readFileSync4,
3987
+ readFileSync as readFileSync5,
3884
3988
  renameSync as renameSync2,
3885
3989
  rmSync as rmSync2,
3886
3990
  unlinkSync as unlinkSync2,
3887
- writeFileSync as writeFileSync5
3991
+ writeFileSync as writeFileSync6
3888
3992
  } from "fs";
3889
- import { homedir as homedir11 } from "os";
3890
- import { join as join15 } from "path";
3993
+ import { homedir as homedir12 } from "os";
3994
+ import { join as join16 } from "path";
3891
3995
  function selectLoginMode(o) {
3892
3996
  if (o.code) return "code";
3893
3997
  if (o.headless || !o.isTTY) return "headless";
3894
3998
  return "interactive";
3895
3999
  }
3896
4000
  function stateDir2() {
3897
- return process.env.AGENTBOX_HOME ?? join15(homedir11(), ".agentbox");
4001
+ return process.env.AGENTBOX_HOME ?? join16(homedir12(), ".agentbox");
3898
4002
  }
3899
4003
  function loginRootDir() {
3900
- return join15(stateDir2(), "claude-login");
4004
+ return join16(stateDir2(), "claude-login");
3901
4005
  }
3902
4006
  function loginSessionDir(id) {
3903
- return join15(loginRootDir(), id);
4007
+ return join16(loginRootDir(), id);
3904
4008
  }
3905
4009
  function atomicWrite(path, data) {
3906
4010
  const tmp = `${path}.tmp.${String(process.pid)}.${String(Date.now())}`;
3907
- writeFileSync5(tmp, data, { mode: 384 });
4011
+ writeFileSync6(tmp, data, { mode: 384 });
3908
4012
  renameSync2(tmp, path);
3909
4013
  }
3910
4014
  function readJsonWithRetry(path) {
3911
4015
  for (let attempt = 0; attempt < 2; attempt++) {
3912
4016
  try {
3913
- return JSON.parse(readFileSync4(path, "utf8"));
4017
+ return JSON.parse(readFileSync5(path, "utf8"));
3914
4018
  } catch {
3915
4019
  }
3916
4020
  }
3917
4021
  return null;
3918
4022
  }
3919
4023
  function writeLoginRequest(id, req) {
3920
- mkdirSync4(loginSessionDir(id), { recursive: true });
3921
- atomicWrite(join15(loginSessionDir(id), "request.json"), JSON.stringify(req));
4024
+ mkdirSync5(loginSessionDir(id), { recursive: true });
4025
+ atomicWrite(join16(loginSessionDir(id), "request.json"), JSON.stringify(req));
3922
4026
  }
3923
4027
  function readLoginRequest(id) {
3924
- return readJsonWithRetry(join15(loginSessionDir(id), "request.json"));
4028
+ return readJsonWithRetry(join16(loginSessionDir(id), "request.json"));
3925
4029
  }
3926
4030
  function writeLoginState(id, state) {
3927
- mkdirSync4(loginSessionDir(id), { recursive: true });
4031
+ mkdirSync5(loginSessionDir(id), { recursive: true });
3928
4032
  const full = { ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
3929
- atomicWrite(join15(loginSessionDir(id), "state.json"), JSON.stringify(full));
4033
+ atomicWrite(join16(loginSessionDir(id), "state.json"), JSON.stringify(full));
3930
4034
  }
3931
4035
  function readLoginState(id) {
3932
- return readJsonWithRetry(join15(loginSessionDir(id), "state.json"));
4036
+ return readJsonWithRetry(join16(loginSessionDir(id), "state.json"));
3933
4037
  }
3934
4038
  function writeLoginCode(id, code) {
3935
- mkdirSync4(loginSessionDir(id), { recursive: true });
3936
- atomicWrite(join15(loginSessionDir(id), "code"), code.trim());
4039
+ mkdirSync5(loginSessionDir(id), { recursive: true });
4040
+ atomicWrite(join16(loginSessionDir(id), "code"), code.trim());
3937
4041
  }
3938
4042
  function takeLoginCode(id) {
3939
- const path = join15(loginSessionDir(id), "code");
4043
+ const path = join16(loginSessionDir(id), "code");
3940
4044
  try {
3941
- const code = readFileSync4(path, "utf8").trim();
4045
+ const code = readFileSync5(path, "utf8").trim();
3942
4046
  try {
3943
4047
  unlinkSync2(path);
3944
4048
  } catch {
@@ -5010,7 +5114,7 @@ async function startHeadlessLogin(args) {
5010
5114
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
5011
5115
  });
5012
5116
  const entry = process.env.AGENTBOX_CLI_ENTRY ?? process.argv[1];
5013
- if (!entry || !existsSync8(entry)) {
5117
+ if (!entry || !existsSync9(entry)) {
5014
5118
  prompt_exports.log.error("could not resolve the agentbox CLI entry to spawn the login worker");
5015
5119
  process.exit(1);
5016
5120
  }
@@ -5127,8 +5231,8 @@ claudeCommand.addCommand(claudeLoginCommand);
5127
5231
 
5128
5232
  // src/commands/codex.ts
5129
5233
  import { access } from "fs/promises";
5130
- import { homedir as homedir12 } from "os";
5131
- import { join as join16 } from "path";
5234
+ import { homedir as homedir13 } from "os";
5235
+ import { join as join17 } from "path";
5132
5236
  import { Command as Command6 } from "commander";
5133
5237
  function pickCodexCreateOpts(opts) {
5134
5238
  return {
@@ -5224,7 +5328,7 @@ async function maybeRunCodexLogin(args) {
5224
5328
  }
5225
5329
  async function cloudCodexCredAvailable(env = process.env) {
5226
5330
  if ((env["OPENAI_API_KEY"] ?? "").length > 0) return true;
5227
- for (const p of [CODEX_CREDENTIALS_BACKUP_FILE, join16(homedir12(), ".codex", "auth.json")]) {
5331
+ for (const p of [CODEX_CREDENTIALS_BACKUP_FILE, join17(homedir13(), ".codex", "auth.json")]) {
5228
5332
  try {
5229
5333
  await access(p);
5230
5334
  return true;
@@ -5918,8 +6022,8 @@ codexCommand.addCommand(codexLoginCommand);
5918
6022
 
5919
6023
  // src/commands/opencode.ts
5920
6024
  import { access as access2 } from "fs/promises";
5921
- import { homedir as homedir13 } from "os";
5922
- import { join as join17 } from "path";
6025
+ import { homedir as homedir14 } from "os";
6026
+ import { join as join18 } from "path";
5923
6027
  import { Command as Command7 } from "commander";
5924
6028
  function pickOpencodeCreateOpts(opts) {
5925
6029
  return {
@@ -6014,7 +6118,7 @@ async function cloudOpencodeCredAvailable(env = process.env) {
6014
6118
  for (const k of OPENCODE_FORWARDED_ENV_KEYS) {
6015
6119
  if ((env[k] ?? "").length > 0) return true;
6016
6120
  }
6017
- for (const p of [OPENCODE_CREDENTIALS_BACKUP_FILE, join17(homedir13(), ".local", "share", "opencode", "auth.json")]) {
6121
+ for (const p of [OPENCODE_CREDENTIALS_BACKUP_FILE, join18(homedir14(), ".local", "share", "opencode", "auth.json")]) {
6018
6122
  try {
6019
6123
  await access2(p);
6020
6124
  return true;
@@ -7103,203 +7207,8 @@ var checkpointCommand = new Command9("checkpoint").alias("checkpoints").descript
7103
7207
 
7104
7208
  // src/commands/code.ts
7105
7209
  import { spawn as spawn4 } from "child_process";
7106
- import { log as log19 } from "@clack/prompts";
7107
- import { Command as Command10, InvalidArgumentError } from "commander";
7108
-
7109
- // src/cloud-ssh.ts
7110
7210
  import { log as log18 } from "@clack/prompts";
7111
-
7112
- // src/ssh-config.ts
7113
- import { promises as fs } from "fs";
7114
- import { homedir as homedir14 } from "os";
7115
- import { dirname, join as join18 } from "path";
7116
- function sshConfigPath() {
7117
- return join18(homedir14(), ".ssh", "config");
7118
- }
7119
- function agentboxSshConfigPath() {
7120
- return join18(homedir14(), ".agentbox", "ssh", "config");
7121
- }
7122
- function stateFilePath() {
7123
- return join18(homedir14(), ".agentbox", "state.json");
7124
- }
7125
- var INCLUDE_BEGIN = "# BEGIN agentbox ssh include";
7126
- var INCLUDE_END = "# END agentbox ssh include";
7127
- function beginMarker(alias) {
7128
- return `# BEGIN agentbox cloud box ${alias}`;
7129
- }
7130
- function endMarker(alias) {
7131
- return `# END agentbox cloud box ${alias}`;
7132
- }
7133
- function agentboxAliasFor(boxName) {
7134
- return boxName;
7135
- }
7136
- async function readFileOrEmpty(path) {
7137
- try {
7138
- return await fs.readFile(path, "utf8");
7139
- } catch (err) {
7140
- if (err.code === "ENOENT") return "";
7141
- throw err;
7142
- }
7143
- }
7144
- function buildBlock(opts) {
7145
- const lines = [
7146
- beginMarker(opts.alias),
7147
- `Host ${opts.alias}`,
7148
- ` HostName ${opts.hostname}`,
7149
- ` User ${opts.user}`
7150
- ];
7151
- if (opts.identityFile) {
7152
- lines.push(` IdentityFile ${opts.identityFile}`);
7153
- lines.push(` IdentitiesOnly yes`);
7154
- }
7155
- lines.push(
7156
- ` StrictHostKeyChecking accept-new`,
7157
- ` UserKnownHostsFile /dev/null`,
7158
- ` LogLevel ERROR`,
7159
- endMarker(opts.alias),
7160
- ""
7161
- );
7162
- return lines.join("\n");
7163
- }
7164
- function stripLegacyInlineBlocks(contents) {
7165
- const pattern = /^# BEGIN agentbox cloud box .*\n[\s\S]*?^# END agentbox cloud box .*\n?/gm;
7166
- return contents.replace(pattern, "");
7167
- }
7168
- function hasIncludeBlock(contents) {
7169
- return contents.includes(INCLUDE_BEGIN) || contents.includes(`Include ${agentboxSshConfigPath()}`);
7170
- }
7171
- async function ensureSshInclude() {
7172
- const path = sshConfigPath();
7173
- await fs.mkdir(join18(homedir14(), ".ssh"), { recursive: true, mode: 448 });
7174
- const existing = stripLegacyInlineBlocks(await readFileOrEmpty(path));
7175
- let next = existing;
7176
- if (!hasIncludeBlock(existing)) {
7177
- const block = `${INCLUDE_BEGIN}
7178
- Include ${agentboxSshConfigPath()}
7179
- ${INCLUDE_END}
7180
- `;
7181
- next = existing.length === 0 ? block : `${block}
7182
- ${existing}`;
7183
- }
7184
- await fs.writeFile(path, next, { mode: 384 });
7185
- await fs.chmod(path, 384);
7186
- }
7187
- async function syncAgentboxSshConfig(statePath = stateFilePath()) {
7188
- const state = await readState(statePath);
7189
- const blocks = [];
7190
- for (const box of state.boxes) {
7191
- const ssh = box.cloud?.ssh;
7192
- if (!ssh) continue;
7193
- blocks.push(
7194
- buildBlock({
7195
- alias: agentboxAliasFor(box.name),
7196
- hostname: ssh.host,
7197
- user: ssh.user,
7198
- identityFile: ssh.identityFile
7199
- })
7200
- );
7201
- }
7202
- const header = "# Managed by agentbox \u2014 regenerated on box create/start/destroy.\n# Do not edit; changes are overwritten. Disable with `agentbox config set ssh.autoConfig false`.\n\n";
7203
- const path = agentboxSshConfigPath();
7204
- await fs.mkdir(dirname(path), { recursive: true, mode: 448 });
7205
- await fs.writeFile(path, header + blocks.join("\n"), { mode: 384 });
7206
- await fs.chmod(path, 384);
7207
- await ensureSshInclude();
7208
- }
7209
- async function hasUnmanagedHostConflict(alias) {
7210
- const contents = stripLegacyInlineBlocks(await readFileOrEmpty(sshConfigPath()));
7211
- if (contents === "") return false;
7212
- return contents.split("\n").some((line) => {
7213
- const m = /^\s*Host\s+(.+?)\s*$/.exec(line);
7214
- if (!m) return false;
7215
- return m[1].split(/\s+/).includes(alias);
7216
- });
7217
- }
7218
- function parseSshTarget(argv2) {
7219
- let target;
7220
- for (let i = argv2.length - 1; i >= 0; i--) {
7221
- const v = argv2[i];
7222
- if (!v || v.startsWith("-")) continue;
7223
- const at = v.indexOf("@");
7224
- if (at <= 0) continue;
7225
- target = { user: v.slice(0, at), host: v.slice(at + 1) };
7226
- break;
7227
- }
7228
- if (!target) return void 0;
7229
- let identityFile;
7230
- for (let i = 0; i < argv2.length - 1; i++) {
7231
- if (argv2[i] === "-i") {
7232
- identityFile = argv2[i + 1];
7233
- break;
7234
- }
7235
- }
7236
- return { ...target, identityFile };
7237
- }
7238
- async function readAgentboxSshAlias(alias) {
7239
- const contents = await readFileOrEmpty(agentboxSshConfigPath());
7240
- if (contents === "") return void 0;
7241
- const begin = beginMarker(alias);
7242
- const end = endMarker(alias);
7243
- const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7244
- const match = new RegExp(`^${escape(begin)}\\n([\\s\\S]*?)${escape(end)}`, "m").exec(contents);
7245
- if (!match) return void 0;
7246
- const body = match[1] ?? "";
7247
- const field = (name) => new RegExp(`^\\s*${name}\\s+(.+)$`, "m").exec(body)?.[1]?.trim();
7248
- return { hostName: field("HostName"), identityFile: field("IdentityFile") };
7249
- }
7250
-
7251
- // src/cloud-ssh.ts
7252
- async function resolveCloudSshTarget(box, opts = {}) {
7253
- const p = await providerForBox(box);
7254
- if (!p.buildAttach) {
7255
- throw new Error(`cloud provider '${p.name}' does not support SSH attach`);
7256
- }
7257
- if (opts.bringOnline ?? true) {
7258
- const state = await p.probeState(box);
7259
- if (state === "paused") {
7260
- log18.info("box is paused; resuming");
7261
- await p.resume(box);
7262
- } else if (state === "stopped") {
7263
- log18.info("box is stopped; starting");
7264
- await p.start(box);
7265
- } else if (state === "missing") {
7266
- throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
7267
- }
7268
- }
7269
- const spec = await p.buildAttach(box, "shell", { noTmux: true });
7270
- const target = parseSshTarget(spec.argv);
7271
- if (!target) {
7272
- throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
7273
- }
7274
- const alias = agentboxAliasFor(box.name);
7275
- return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
7276
- }
7277
- async function ensureCloudSshAlias(box, opts = {}) {
7278
- const conn = await resolveCloudSshTarget(box, opts);
7279
- await recordBoxSsh(box.id, {
7280
- host: conn.host,
7281
- user: conn.user,
7282
- identityFile: conn.identityFile
7283
- });
7284
- await syncAgentboxSshConfig();
7285
- return conn;
7286
- }
7287
- async function autoWriteSshConfig(box, enabled) {
7288
- if (!enabled) return;
7289
- try {
7290
- const conn = await resolveCloudSshTarget(box, { bringOnline: false });
7291
- if (!conn.identityFile) return;
7292
- await recordBoxSsh(box.id, {
7293
- host: conn.host,
7294
- user: conn.user,
7295
- identityFile: conn.identityFile
7296
- });
7297
- await syncAgentboxSshConfig();
7298
- } catch {
7299
- }
7300
- }
7301
-
7302
- // src/commands/code.ts
7211
+ import { Command as Command10, InvalidArgumentError } from "commander";
7303
7212
  function buildCodeCliOverrides(opts) {
7304
7213
  const code = {};
7305
7214
  if (opts.ide !== void 0) code.ide = opts.ide;
@@ -7328,40 +7237,43 @@ var codeCommand = new Command10("code").description("Open a box in VS Code or Cu
7328
7237
  ).action(async (idOrName, opts) => {
7329
7238
  try {
7330
7239
  const box = await resolveBoxOrExit(idOrName);
7331
- const cfg = await loadEffectiveConfig(box.workspacePath, {
7332
- cliOverrides: buildCodeCliOverrides(opts)
7333
- });
7334
- const wait = cfg.effective.code.wait;
7335
- const autoTerminals = cfg.effective.code.autoTerminals;
7336
- const timeoutMs = String(cfg.effective.code.timeoutMs);
7337
- const ide = cfg.effective.code.ide;
7338
- const forcedIde = ide === "auto" ? void 0 : ide;
7339
- const provider = box.provider ?? "docker";
7340
- const folderUri = provider === "docker" ? await prepareDockerAttach(box, { wait, autoTerminals, timeoutMs, regenTasks: opts.regenTasks }) : await prepareCloudAttach(box, { wait, timeoutMs });
7341
- if (opts.print) {
7342
- process.stdout.write(folderUri + "\n");
7343
- return;
7344
- }
7345
- const exit = await launchIde(folderUri, forcedIde);
7346
- if (exit.code !== 0) {
7347
- log19.error(`failed to launch ${exit.flavor ? ideProfile(exit.flavor).displayName : "IDE"} via ${exit.via} (exit ${String(exit.code)})`);
7348
- process.stdout.write(folderUri + "\n");
7349
- process.exit(1);
7350
- }
7351
- log19.success(
7352
- `opening ${box.name} in ${ideProfile(exit.flavor).displayName} (${exit.via})`
7353
- );
7240
+ await runCodeOpen(box, opts);
7354
7241
  } catch (err) {
7355
7242
  handleLifecycleError(err);
7356
7243
  }
7357
7244
  });
7245
+ async function runCodeOpen(box, opts) {
7246
+ const cfg = await loadEffectiveConfig(box.workspacePath, {
7247
+ cliOverrides: buildCodeCliOverrides(opts)
7248
+ });
7249
+ const wait = cfg.effective.code.wait;
7250
+ const autoTerminals = cfg.effective.code.autoTerminals;
7251
+ const timeoutMs = String(cfg.effective.code.timeoutMs);
7252
+ const ide = cfg.effective.code.ide;
7253
+ const forcedIde = ide === "auto" ? void 0 : ide;
7254
+ const provider = box.provider ?? "docker";
7255
+ const folderUri = provider === "docker" ? await prepareDockerAttach(box, { wait, autoTerminals, timeoutMs, regenTasks: opts.regenTasks }) : await prepareCloudAttach(box, { wait, timeoutMs });
7256
+ if (opts.print) {
7257
+ process.stdout.write(folderUri + "\n");
7258
+ return;
7259
+ }
7260
+ const exit = await launchIde(folderUri, forcedIde);
7261
+ if (exit.code !== 0) {
7262
+ log18.error(`failed to launch ${exit.flavor ? ideProfile(exit.flavor).displayName : "IDE"} via ${exit.via} (exit ${String(exit.code)})`);
7263
+ process.stdout.write(folderUri + "\n");
7264
+ process.exit(1);
7265
+ }
7266
+ log18.success(
7267
+ `opening ${box.name} in ${ideProfile(exit.flavor).displayName} (${exit.via})`
7268
+ );
7269
+ }
7358
7270
  async function prepareDockerAttach(box, opts) {
7359
7271
  const insp = await inspectBox(box.id);
7360
7272
  if (insp.state === "paused") {
7361
- log19.info(`box is paused; unpausing`);
7273
+ log18.info(`box is paused; unpausing`);
7362
7274
  await unpauseBox(box.id);
7363
7275
  } else if (insp.state === "stopped") {
7364
- log19.info(`box is stopped; starting`);
7276
+ log18.info(`box is stopped; starting`);
7365
7277
  await startBox(box.id);
7366
7278
  } else if (insp.state === "missing") {
7367
7279
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -7372,9 +7284,9 @@ async function prepareDockerAttach(box, opts) {
7372
7284
  const lines = [];
7373
7285
  if (reply.timedOut.length > 0) lines.push(`timed out: ${reply.timedOut.join(", ")}`);
7374
7286
  if (reply.failed.length > 0) lines.push(`failed: ${reply.failed.join(", ")}`);
7375
- log19.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
7287
+ log18.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
7376
7288
  } else {
7377
- log19.success("all units ready");
7289
+ log18.success("all units ready");
7378
7290
  }
7379
7291
  }
7380
7292
  if (opts.autoTerminals) {
@@ -7384,14 +7296,14 @@ async function prepareDockerAttach(box, opts) {
7384
7296
  regen: opts.regenTasks
7385
7297
  });
7386
7298
  if (r.status === "wrote") {
7387
- log19.info(`wrote /workspace/.vscode/tasks.json (${String(services.length)} service(s))`);
7299
+ log18.info(`wrote /workspace/.vscode/tasks.json (${String(services.length)} service(s))`);
7388
7300
  } else if (r.status === "skipped-user-owned") {
7389
- log19.warn(
7301
+ log18.warn(
7390
7302
  "user-owned .vscode/tasks.json detected; skipping auto-terminals (pass --regen-tasks to overwrite)"
7391
7303
  );
7392
7304
  }
7393
7305
  } catch (err) {
7394
- log19.warn(
7306
+ log18.warn(
7395
7307
  `auto-terminals failed: ${err instanceof Error ? err.message : String(err)}`
7396
7308
  );
7397
7309
  }
@@ -7403,10 +7315,10 @@ async function prepareCloudAttach(box, opts) {
7403
7315
  const p = await providerForBox(box);
7404
7316
  const state = await p.probeState(box);
7405
7317
  if (state === "paused") {
7406
- log19.info("box is paused; resuming");
7318
+ log18.info("box is paused; resuming");
7407
7319
  await p.resume(box);
7408
7320
  } else if (state === "stopped") {
7409
- log19.info("box is stopped; starting");
7321
+ log18.info("box is stopped; starting");
7410
7322
  await p.start(box);
7411
7323
  } else if (state === "missing") {
7412
7324
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
@@ -7419,16 +7331,16 @@ async function prepareCloudAttach(box, opts) {
7419
7331
  const lines = [];
7420
7332
  if (reply.timedOut.length > 0) lines.push(`timed out: ${reply.timedOut.join(", ")}`);
7421
7333
  if (reply.failed.length > 0) lines.push(`failed: ${reply.failed.join(", ")}`);
7422
- log19.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
7334
+ log18.warn(`box not fully ready (${lines.join("; ")}). Opening anyway.`);
7423
7335
  } else {
7424
- log19.success("all units ready");
7336
+ log18.success("all units ready");
7425
7337
  }
7426
7338
  } catch (err) {
7427
- log19.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
7339
+ log18.warn(`wait-ready failed (continuing): ${err instanceof Error ? err.message : String(err)}`);
7428
7340
  }
7429
7341
  }
7430
- const { alias } = await ensureCloudSshAlias(box, { bringOnline: false });
7431
- log19.info(`updated ~/.ssh/config alias ${alias}`);
7342
+ const { alias } = await ensureCloudSshAlias(box, p, { bringOnline: false });
7343
+ log18.info(`updated ~/.ssh/config alias ${alias}`);
7432
7344
  return `vscode-remote://ssh-remote+${alias}/workspace`;
7433
7345
  }
7434
7346
  async function runWaitReadyDocker(container, timeoutMs) {
@@ -7453,7 +7365,7 @@ async function launchIde(folderUri, forced) {
7453
7365
  if (code !== null) return code;
7454
7366
  const cursor = await tryCli("cursor", folderUri);
7455
7367
  if (cursor !== null) return cursor;
7456
- log19.warn("neither `code` nor `cursor` found in PATH; falling back to `open vscode://...`");
7368
+ log18.warn("neither `code` nor `cursor` found in PATH; falling back to `open vscode://...`");
7457
7369
  return launchOne("vscode", folderUri);
7458
7370
  }
7459
7371
  async function tryCli(flavor, folderUri) {
@@ -7466,7 +7378,7 @@ async function launchOne(flavor, folderUri) {
7466
7378
  const profile = ideProfile(flavor);
7467
7379
  const cliCode = await spawnCommand(profile.cli, ["--folder-uri", folderUri]);
7468
7380
  if (cliCode !== 127) return { code: cliCode, flavor, via: "cli" };
7469
- log19.warn(
7381
+ log18.warn(
7470
7382
  `\`${profile.cli}\` not found in PATH; falling back to \`${hostOpenCommand()} ${profile.protocolScheme}://...\` (the %2B URL-encoding bug may break attach)`
7471
7383
  );
7472
7384
  const url = `${profile.protocolScheme}://${folderUri.replace(/^vscode-remote:\/\//, "vscode-remote/")}`;
@@ -7770,7 +7682,7 @@ var configCommand = new Command11("config").description("Read / write layered co
7770
7682
 
7771
7683
  // src/commands/cp.ts
7772
7684
  import { resolve as resolve3 } from "path";
7773
- import { log as log20 } from "@clack/prompts";
7685
+ import { log as log19 } from "@clack/prompts";
7774
7686
  import { Command as Command12 } from "commander";
7775
7687
  function collectExclude(val, acc) {
7776
7688
  acc.push(val);
@@ -7928,10 +7840,10 @@ var cpCommand = new Command12("cp").description("Copy files between host and box
7928
7840
  }
7929
7841
  const insp = await inspectBox(box.id);
7930
7842
  if (insp.state === "paused") {
7931
- log20.info("box is paused; unpausing");
7843
+ log19.info("box is paused; unpausing");
7932
7844
  await unpauseBox(box.id);
7933
7845
  } else if (insp.state === "stopped") {
7934
- log20.info("box is stopped; starting");
7846
+ log19.info("box is stopped; starting");
7935
7847
  await startBox(box.id);
7936
7848
  } else if (insp.state === "missing") {
7937
7849
  throw new Error(`box ${box.name} has no container; was it destroyed?`);
@@ -7939,7 +7851,7 @@ var cpCommand = new Command12("cp").description("Copy files between host and box
7939
7851
  if (parsed.direction === "upload") {
7940
7852
  const result = await uploadToBox(box, parsed.hostSrcs, parsed.boxDst, tarPatterns);
7941
7853
  if (result.warn) {
7942
- log20.warn(`copied to ${box.name}:${result.finalPath}, but ${result.warn}`);
7854
+ log19.warn(`copied to ${box.name}:${result.finalPath}, but ${result.warn}`);
7943
7855
  } else {
7944
7856
  process.stdout.write(`copied to ${box.name}:${result.finalPath}
7945
7857
  `);
@@ -7960,7 +7872,7 @@ var cpCommand = new Command12("cp").description("Copy files between host and box
7960
7872
  });
7961
7873
 
7962
7874
  // src/commands/create.ts
7963
- import { intro as intro8, log as log21, outro as outro7 } from "@clack/prompts";
7875
+ import { intro as intro8, log as log20, outro as outro7 } from "@clack/prompts";
7964
7876
  import { Command as Command13 } from "commander";
7965
7877
  import { execSync, spawnSync as spawnSync2 } from "child_process";
7966
7878
  function buildCliOverrides(opts) {
@@ -8113,13 +8025,13 @@ var createCommand = new Command13("create").description(
8113
8025
  onLog: (line) => cmdLog.write(line)
8114
8026
  });
8115
8027
  if (gate.decision === "cancel") {
8116
- log21.warn("carry: cancelled \u2014 not creating the box");
8028
+ log20.warn("carry: cancelled \u2014 not creating the box");
8117
8029
  cmdLog.close();
8118
8030
  process.exit(0);
8119
8031
  }
8120
8032
  if (gate.decision === "approve") carryEntries = gate.entries;
8121
8033
  } catch (err) {
8122
- log21.error(err instanceof Error ? err.message : String(err));
8034
+ log20.error(err instanceof Error ? err.message : String(err));
8123
8035
  cmdLog.close();
8124
8036
  process.exit(1);
8125
8037
  }
@@ -8138,7 +8050,7 @@ var createCommand = new Command13("create").description(
8138
8050
  baseStatus
8139
8051
  });
8140
8052
  if (wiz.rebuildBase) {
8141
- log21.warn(`${providerName} base image is outdated; rebuilding before create\u2026`);
8053
+ log20.warn(`${providerName} base image is outdated; rebuilding before create\u2026`);
8142
8054
  await runPrepare(providerName, {
8143
8055
  force: true,
8144
8056
  cwd: opts.workspace,
@@ -8184,7 +8096,7 @@ var createCommand = new Command13("create").description(
8184
8096
  } catch (err) {
8185
8097
  if (err instanceof FromBranchError || err instanceof UseBranchError) {
8186
8098
  s.stop("aborting: invalid branch selection");
8187
- log21.error(err.message);
8099
+ log20.error(err.message);
8188
8100
  cmdLog.close();
8189
8101
  process.exit(2);
8190
8102
  }
@@ -8232,21 +8144,26 @@ var createCommand = new Command13("create").description(
8232
8144
  });
8233
8145
  s.stop(`box ${result.record.container} ready`);
8234
8146
  const createResyncWarning = result.resync ? buildResyncWarning(result.resync) : null;
8235
- if (createResyncWarning) log21.warn(createResyncWarning);
8147
+ if (createResyncWarning) log20.warn(createResyncWarning);
8236
8148
  if (!isDocker) {
8237
- await autoWriteSshConfig(result.record, cfg.effective.ssh.autoConfig);
8149
+ await autoWriteSshConfig(
8150
+ result.record,
8151
+ provider,
8152
+ cfg.effective.ssh.autoConfig,
8153
+ (m2) => log20.warn(m2)
8154
+ );
8238
8155
  }
8239
- log21.info(`id: ${result.record.id}`);
8156
+ log20.info(`id: ${result.record.id}`);
8240
8157
  if (typeof result.record.projectIndex === "number") {
8241
- log21.info(`n: ${String(result.record.projectIndex)} (in ${projectRoot})`);
8158
+ log20.info(`n: ${String(result.record.projectIndex)} (in ${projectRoot})`);
8242
8159
  }
8243
- log21.info(`container: ${result.record.container}`);
8244
- log21.info(`image: ${result.record.image}${result.imageBuilt ? " (built just now)" : ""}`);
8160
+ log20.info(`container: ${result.record.container}`);
8161
+ log20.info(`image: ${result.record.image}${result.imageBuilt ? " (built just now)" : ""}`);
8245
8162
  if (result.record.snapshotDir) {
8246
- log21.info(`snapshot: ${result.record.snapshotDir}`);
8163
+ log20.info(`snapshot: ${result.record.snapshotDir}`);
8247
8164
  }
8248
8165
  if (result.record.checkpointSource) {
8249
- log21.info(
8166
+ log20.info(
8250
8167
  `checkpoint: ${result.record.checkpointSource.ref} (${result.record.checkpointSource.type}) \u2192 ${result.record.checkpointImage ?? "(missing)"}`
8251
8168
  );
8252
8169
  }
@@ -8258,7 +8175,7 @@ var createCommand = new Command13("create").description(
8258
8175
  ` agentbox claude attach ${result.record.name}`,
8259
8176
  ` agentbox url ${result.record.name}`
8260
8177
  ];
8261
- log21.message(
8178
+ log20.message(
8262
8179
  [
8263
8180
  "",
8264
8181
  "Try it:",
@@ -8277,7 +8194,7 @@ var createCommand = new Command13("create").description(
8277
8194
  const protectedPaths = boxes.map((b) => b.projectRoot).filter((p) => typeof p === "string");
8278
8195
  const res = await pruneOrphanProjectConfigs({ protectedPaths });
8279
8196
  if (res.removed.length > 0) {
8280
- log21.info(
8197
+ log20.info(
8281
8198
  `cleaned ${String(res.removed.length)} orphan project config dir(s): ` + res.removed.map((r) => r.originalPath).join(", ")
8282
8199
  );
8283
8200
  }
@@ -8287,7 +8204,7 @@ var createCommand = new Command13("create").description(
8287
8204
  }
8288
8205
  outro7("done");
8289
8206
  if (attachClaudeAfter) {
8290
- const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-YH2SU75S.js");
8207
+ const { cloudAgentAttach: cloudAgentAttach2 } = await import("./_cloud-attach-Y5WZ7F53.js");
8291
8208
  await cloudAgentAttach2({
8292
8209
  box: result.record,
8293
8210
  binary: "claude",
@@ -8303,14 +8220,14 @@ var createCommand = new Command13("create").description(
8303
8220
  s.stop("failed");
8304
8221
  const msg = err instanceof Error ? err.message : String(err);
8305
8222
  cmdLog.write(`FAIL: ${err instanceof Error ? err.stack ?? err.message : String(err)}`);
8306
- log21.error(msg);
8223
+ log20.error(msg);
8307
8224
  try {
8308
8225
  const running = execSync('docker ps --format "{{.Names}}"', {
8309
8226
  stdio: ["ignore", "pipe", "ignore"]
8310
8227
  }).toString().split("\n").filter((n) => n.startsWith("agentbox-"));
8311
8228
  if (running.length > 0) {
8312
- log21.warn(`leftover containers: ${running.join(", ")}`);
8313
- log21.warn(`remove with: docker rm -f ${running.join(" ")}`);
8229
+ log20.warn(`leftover containers: ${running.join(", ")}`);
8230
+ log20.warn(`remove with: docker rm -f ${running.join(" ")}`);
8314
8231
  }
8315
8232
  } catch {
8316
8233
  }
@@ -8323,7 +8240,7 @@ var createCommand = new Command13("create").description(
8323
8240
 
8324
8241
  // src/commands/dashboard.ts
8325
8242
  import { spawn as spawn5 } from "child_process";
8326
- import { log as log22 } from "@clack/prompts";
8243
+ import { log as log21 } from "@clack/prompts";
8327
8244
  import { Command as Command14 } from "commander";
8328
8245
 
8329
8246
  // src/dashboard/layout.ts
@@ -9850,7 +9767,7 @@ function toSidebar(b) {
9850
9767
  var dashboardCommand = new Command14("dashboard").description("Box list + the selected box live Agent session").argument("[box]", "initial box (default: first running box; -p restricts to the cwd project)").option("-p, --project", "only this project's boxes (default: all boxes globally)").action(async (idOrName, opts) => {
9851
9768
  try {
9852
9769
  if (!process.stdout.isTTY || !process.stdin.isTTY) {
9853
- log22.error("agentbox dashboard needs an interactive terminal");
9770
+ log21.error("agentbox dashboard needs an interactive terminal");
9854
9771
  process.exit(2);
9855
9772
  }
9856
9773
  const backend = await loadPtyBackend();
@@ -9860,10 +9777,10 @@ var dashboardCommand = new Command14("dashboard").description("Box list + the se
9860
9777
  ptySpawn = backend.ptySpawn;
9861
9778
  termCtor = backend.termCtor;
9862
9779
  } else {
9863
- log22.error(
9780
+ log21.error(
9864
9781
  "agentbox dashboard is unavailable here (native terminal backend failed to load)"
9865
9782
  );
9866
- log22.info("use `agentbox claude` / `agentbox attach` instead");
9783
+ log21.info("use `agentbox claude` / `agentbox attach` instead");
9867
9784
  process.exit(2);
9868
9785
  }
9869
9786
  const project = await findProjectRoot(process.cwd());
@@ -10270,11 +10187,11 @@ var dashboardCommand = new Command14("dashboard").description("Box list + the se
10270
10187
  });
10271
10188
 
10272
10189
  // ../../packages/sandbox-daytona/dist/cli.js
10273
- import { log as log23, spinner as spinner8 } from "@clack/prompts";
10190
+ import { log as log22, spinner as spinner8 } from "@clack/prompts";
10274
10191
  import { Command as Command15 } from "commander";
10275
10192
  function reportError(err) {
10276
10193
  const message = err instanceof Error ? err.message : String(err);
10277
- log23.error(message);
10194
+ log22.error(message);
10278
10195
  process.exitCode = 1;
10279
10196
  }
10280
10197
  var loginSub = new Command15("login").description("Set up (or rotate) Daytona credentials for cloud boxes").option("--status", "show what is currently configured (masked) and exit").action(async (opts) => {
@@ -10292,7 +10209,7 @@ var loginSub = new Command15("login").description("Set up (or rotate) Daytona cr
10292
10209
  }
10293
10210
  await ensureDaytonaCredentials({ force: true });
10294
10211
  if (readPreparedDaytonaState()?.base === void 0) {
10295
- log23.info(
10212
+ log22.info(
10296
10213
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider daytona` (or `agentbox install`) to bake it."
10297
10214
  );
10298
10215
  }
@@ -10338,7 +10255,7 @@ var resyncSub = new Command15("resync").description(
10338
10255
  const sb = spinner8();
10339
10256
  sb.start(`provisioning throwaway sandbox to refresh: ${agents.join(", ")}`);
10340
10257
  const ensured = await ensureAgentVolumesForCloud(daytonaBackend, {
10341
- onLog: (line) => log23.info(line)
10258
+ onLog: (line) => log22.info(line)
10342
10259
  });
10343
10260
  if (ensured.agents.length === 0) {
10344
10261
  sb.stop("no agent volumes available \u2014 the daytona backend has no volume primitive");
@@ -10378,7 +10295,7 @@ var resyncSub = new Command15("resync").description(
10378
10295
  }
10379
10296
  sb3.stop("throwaway sandbox destroyed");
10380
10297
  }
10381
- log23.success(
10298
+ log22.success(
10382
10299
  `Daytona agent volumes refreshed: ${agents.join(", ")}. Next \`agentbox create --provider daytona\` will use the updated credentials.`
10383
10300
  );
10384
10301
  } catch (err) {
@@ -10398,11 +10315,11 @@ var dockerCommand = new Command16("docker").description(
10398
10315
  });
10399
10316
 
10400
10317
  // ../../packages/sandbox-hetzner/dist/cli.js
10401
- import { log as log24 } from "@clack/prompts";
10318
+ import { log as log23 } from "@clack/prompts";
10402
10319
  import { Command as Command17 } from "commander";
10403
10320
  function reportError2(err) {
10404
10321
  const message = err instanceof Error ? err.message : String(err);
10405
- log24.error(message);
10322
+ log23.error(message);
10406
10323
  process.exitCode = 1;
10407
10324
  }
10408
10325
  var loginSub2 = new Command17("login").description("Set up (or rotate) Hetzner Cloud credentials for VPS boxes").option("--status", "show what is currently configured (masked) and exit").action(async (opts) => {
@@ -10420,7 +10337,7 @@ var loginSub2 = new Command17("login").description("Set up (or rotate) Hetzner C
10420
10337
  }
10421
10338
  await ensureHetznerCredentials({ force: true });
10422
10339
  if (readPreparedState().base === void 0) {
10423
- log24.info(
10340
+ log23.info(
10424
10341
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider hetzner` (or `agentbox install`) to bake it."
10425
10342
  );
10426
10343
  }
@@ -10551,11 +10468,11 @@ var hetznerCommand = new Command17("hetzner").description(
10551
10468
  ).addCommand(loginSub2, { isDefault: true }).addCommand(firewallSub);
10552
10469
 
10553
10470
  // ../../packages/sandbox-vercel/dist/cli.js
10554
- import { log as log25 } from "@clack/prompts";
10471
+ import { log as log24 } from "@clack/prompts";
10555
10472
  import { Command as Command18 } from "commander";
10556
10473
  function reportError3(err) {
10557
10474
  const message = err instanceof Error ? err.message : String(err);
10558
- log25.error(message);
10475
+ log24.error(message);
10559
10476
  process.exitCode = 1;
10560
10477
  }
10561
10478
  function relativeExpiry(expiresAt) {
@@ -10618,7 +10535,7 @@ var loginSub3 = new Command18("login").description("Set up (or rotate) Vercel cr
10618
10535
  }
10619
10536
  await ensureVercelCredentials({ force: true });
10620
10537
  if (readPreparedState2().base === void 0) {
10621
- log25.info(
10538
+ log24.info(
10622
10539
  "Base snapshot not built yet \u2014 run `agentbox prepare --provider vercel` (or `agentbox install`) to bake it."
10623
10540
  );
10624
10541
  }
@@ -10631,11 +10548,11 @@ var vercelCommand = new Command18("vercel").description(
10631
10548
  ).addCommand(loginSub3, { isDefault: true });
10632
10549
 
10633
10550
  // ../../packages/sandbox-e2b/dist/cli.js
10634
- import { log as log26 } from "@clack/prompts";
10551
+ import { log as log25 } from "@clack/prompts";
10635
10552
  import { Command as Command19 } from "commander";
10636
10553
  function reportError4(err) {
10637
10554
  const message = err instanceof Error ? err.message : String(err);
10638
- log26.error(message);
10555
+ log25.error(message);
10639
10556
  process.exitCode = 1;
10640
10557
  }
10641
10558
  function printStatus4() {
@@ -10667,7 +10584,7 @@ var loginSub4 = new Command19("login").description("Set up (or rotate) E2B crede
10667
10584
  }
10668
10585
  await ensureE2bCredentials({ force: true });
10669
10586
  if (readPreparedState3().base === void 0) {
10670
- log26.info(
10587
+ log25.info(
10671
10588
  "Base template not built yet \u2014 run `agentbox prepare --provider e2b` (or `agentbox install`) to bake it."
10672
10589
  );
10673
10590
  }
@@ -11221,7 +11138,7 @@ downloadCommand.addCommand(downloadOpencodeCommand);
11221
11138
  downloadCommand.addCommand(downloadConfigCommand);
11222
11139
 
11223
11140
  // src/commands/drive.ts
11224
- import { log as log34 } from "@clack/prompts";
11141
+ import { log as log33 } from "@clack/prompts";
11225
11142
  import { Command as Command27 } from "commander";
11226
11143
 
11227
11144
  // src/lib/drive/keys.ts
@@ -11404,7 +11321,7 @@ var driveWaitCommand = new Command27("wait").description("Block until --text app
11404
11321
  }) + "\n"
11405
11322
  );
11406
11323
  } else {
11407
- log34.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
11324
+ log33.error(`text not found within ${String(timeoutMs)}ms: ${opts.text}`);
11408
11325
  }
11409
11326
  process.exit(1);
11410
11327
  } catch (err) {
@@ -11431,8 +11348,8 @@ driveCommand.addCommand(driveWaitCommand);
11431
11348
  driveCommand.addCommand(driveResizeCommand);
11432
11349
  function handleDriveError(err) {
11433
11350
  if (err instanceof SessionNotFoundError) {
11434
- log34.error(err.message);
11435
- log34.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
11351
+ log33.error(err.message);
11352
+ log33.info("start an agent first (e.g. `agentbox claude <box>`) or pass --session.");
11436
11353
  process.exit(2);
11437
11354
  }
11438
11355
  handleLifecycleError(err);
@@ -11456,9 +11373,9 @@ function sleep4(ms) {
11456
11373
  }
11457
11374
 
11458
11375
  // src/commands/fork.ts
11459
- import { log as log35 } from "@clack/prompts";
11376
+ import { log as log34 } from "@clack/prompts";
11460
11377
  import { Command as Command28 } from "commander";
11461
- import { existsSync as existsSync9, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
11378
+ import { existsSync as existsSync10, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
11462
11379
  import { homedir as homedir15 } from "os";
11463
11380
  import { join as join19 } from "path";
11464
11381
  var FORK_AGENTS = ["claude", "codex", "opencode"];
@@ -11501,7 +11418,7 @@ function resolveSessionArgs(agent, opts) {
11501
11418
  if (opts.session) return ["--resume", opts.session];
11502
11419
  if (agent === "codex") return ["--continue"];
11503
11420
  const dir = join19(homedir15(), ".claude", "projects", encodeClaudeProjectsDir(opts.workspace));
11504
- if (!existsSync9(dir)) return ["--continue"];
11421
+ if (!existsSync10(dir)) return ["--continue"];
11505
11422
  const now = Date.now();
11506
11423
  const recent = readdirSync3(dir).filter((f) => f.endsWith(".jsonl")).map((f) => {
11507
11424
  try {
@@ -11555,36 +11472,36 @@ var forkCommand = new Command28("fork").description(
11555
11472
  'copy a Claude Code plan file (e.g. ~/.claude/plans/<slug>.md) into the box, start claude in plan mode, and seed a "resume the plan" prompt. Claude only.'
11556
11473
  ).action(async (providerArg, opts) => {
11557
11474
  if ((process.env.AGENTBOX_RELAY_URL ?? "").trim().length > 0) {
11558
- log35.error(
11475
+ log34.error(
11559
11476
  "agentbox fork runs on the host only: it teleports a host agent session into a new box. You appear to be inside a box (AGENTBOX_RELAY_URL is set) \u2014 box\u2192box fork is not supported yet."
11560
11477
  );
11561
11478
  process.exit(2);
11562
11479
  }
11563
11480
  const agent = opts.agent?.trim() || detectAgentFromEnv() || "claude";
11564
11481
  if (!FORK_AGENTS.includes(agent)) {
11565
- log35.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
11482
+ log34.error(`--agent: expected one of ${FORK_AGENTS.join(", ")}, got "${opts.agent ?? ""}"`);
11566
11483
  process.exit(2);
11567
11484
  }
11568
11485
  const attachIn = opts.attachIn ?? "tab";
11569
11486
  if (!FORK_ATTACH_VALUES.includes(attachIn)) {
11570
- log35.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
11487
+ log34.error(`--attach-in: expected one of ${FORK_ATTACH_VALUES.join(", ")}, got "${attachIn}"`);
11571
11488
  process.exit(2);
11572
11489
  }
11573
11490
  const plan = opts.plan?.trim();
11574
11491
  if (plan && agent !== "claude") {
11575
- log35.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
11492
+ log34.error("--plan is only supported with --agent claude (plan mode is Claude-specific).");
11576
11493
  process.exit(2);
11577
11494
  }
11578
11495
  const carryMode = opts.carry ?? "send";
11579
11496
  if (carryMode !== "send" && carryMode !== "skip") {
11580
- log35.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
11497
+ log34.error(`--carry: expected 'send' or 'skip', got "${opts.carry ?? ""}"`);
11581
11498
  process.exit(2);
11582
11499
  }
11583
11500
  let provider;
11584
11501
  try {
11585
11502
  provider = resolveForkProvider(providerArg, opts.provider);
11586
11503
  } catch (err) {
11587
- log35.error(err instanceof Error ? err.message : String(err));
11504
+ log34.error(err instanceof Error ? err.message : String(err));
11588
11505
  process.exit(2);
11589
11506
  }
11590
11507
  if (!opts.session?.trim()) {
@@ -11597,7 +11514,7 @@ var forkCommand = new Command28("fork").description(
11597
11514
  "projects",
11598
11515
  encodeClaudeProjectsDir(opts.workspace)
11599
11516
  );
11600
- if (existsSync9(join19(dir, `${envId}.jsonl`))) opts.session = envId;
11517
+ if (existsSync10(join19(dir, `${envId}.jsonl`))) opts.session = envId;
11601
11518
  }
11602
11519
  } else if (agent === "codex") {
11603
11520
  const envId = (process.env.CODEX_THREAD_ID ?? "").trim();
@@ -11608,7 +11525,7 @@ var forkCommand = new Command28("fork").description(
11608
11525
  try {
11609
11526
  sessionArgs = resolveSessionArgs(agent, opts);
11610
11527
  } catch (err) {
11611
- log35.error(err instanceof Error ? err.message : String(err));
11528
+ log34.error(err instanceof Error ? err.message : String(err));
11612
11529
  process.exit(2);
11613
11530
  }
11614
11531
  const subArgv = [
@@ -11633,19 +11550,19 @@ var forkCommand = new Command28("fork").description(
11633
11550
  import { Command as Command32 } from "commander";
11634
11551
  import { execa as execa8 } from "execa";
11635
11552
  import {
11636
- existsSync as existsSync16,
11553
+ existsSync as existsSync17,
11637
11554
  lstatSync,
11638
- mkdirSync as mkdirSync11,
11639
- readFileSync as readFileSync9,
11555
+ mkdirSync as mkdirSync12,
11556
+ readFileSync as readFileSync10,
11640
11557
  rmSync as rmSync4,
11641
11558
  symlinkSync as symlinkSync3,
11642
- writeFileSync as writeFileSync11
11559
+ writeFileSync as writeFileSync12
11643
11560
  } from "fs";
11644
11561
  import { homedir as homedir22 } from "os";
11645
11562
  import { dirname as dirname8, join as join27, resolve as resolve5 } from "path";
11646
11563
 
11647
11564
  // src/lib/source-checkout.ts
11648
- import { existsSync as existsSync10 } from "fs";
11565
+ import { existsSync as existsSync11 } from "fs";
11649
11566
  import { dirname as dirname2, join as join20, resolve as resolve4, sep } from "path";
11650
11567
  import { fileURLToPath } from "url";
11651
11568
  function resolveHostSkillsDir() {
@@ -11655,7 +11572,7 @@ function resolveHostSkillsDir() {
11655
11572
  resolve4(here, "..", "..", "share", "host-skills")
11656
11573
  ];
11657
11574
  for (const c of candidates) {
11658
- if (existsSync10(c)) return c;
11575
+ if (existsSync11(c)) return c;
11659
11576
  }
11660
11577
  throw new Error(`could not locate bundled host skills; tried:
11661
11578
  ${candidates.join("\n ")}`);
@@ -11672,13 +11589,13 @@ function resolveDevRepoRoot() {
11672
11589
  }
11673
11590
  if (!isSourceCheckout(hostSkillsDir)) return null;
11674
11591
  const root = resolve4(hostSkillsDir, "..", "..", "..", "..");
11675
- const hasMarketplace = existsSync10(join20(root, ".agents", "plugins", "marketplace.json"));
11676
- const hasPlugin = existsSync10(join20(root, "plugins", "agentbox"));
11592
+ const hasMarketplace = existsSync11(join20(root, ".agents", "plugins", "marketplace.json"));
11593
+ const hasPlugin = existsSync11(join20(root, "plugins", "agentbox"));
11677
11594
  return hasMarketplace && hasPlugin ? root : null;
11678
11595
  }
11679
11596
 
11680
11597
  // src/lib/doctor-checks.ts
11681
- import { accessSync, constants as fsConstants, mkdirSync as mkdirSync5 } from "fs";
11598
+ import { accessSync, constants as fsConstants, mkdirSync as mkdirSync6 } from "fs";
11682
11599
  import { homedir as homedir16 } from "os";
11683
11600
  import { join as join21 } from "path";
11684
11601
  import { execa as execa7 } from "execa";
@@ -11722,7 +11639,7 @@ function checkPlatform() {
11722
11639
  function checkAgentboxHome() {
11723
11640
  const dir = join21(homedir16(), ".agentbox");
11724
11641
  try {
11725
- mkdirSync5(dir, { recursive: true });
11642
+ mkdirSync6(dir, { recursive: true });
11726
11643
  accessSync(dir, fsConstants.W_OK);
11727
11644
  return { label: "~/.agentbox", status: "ok", detail: dir };
11728
11645
  } catch (err) {
@@ -11974,7 +11891,7 @@ function formatDetailed(groups) {
11974
11891
  }
11975
11892
 
11976
11893
  // src/lib/first-run.ts
11977
- import { existsSync as existsSync11, mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "fs";
11894
+ import { existsSync as existsSync12, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "fs";
11978
11895
  import { homedir as homedir17 } from "os";
11979
11896
  import { dirname as dirname3, join as join22 } from "path";
11980
11897
  var MARKER_VERSION = 1;
@@ -11982,38 +11899,38 @@ function setupMarkerPath() {
11982
11899
  return join22(homedir17(), ".agentbox", "setup-complete.json");
11983
11900
  }
11984
11901
  function isFirstRun() {
11985
- return !existsSync11(setupMarkerPath());
11902
+ return !existsSync12(setupMarkerPath());
11986
11903
  }
11987
11904
  function markSetupComplete(provider) {
11988
11905
  const path = setupMarkerPath();
11989
- mkdirSync6(dirname3(path), { recursive: true });
11906
+ mkdirSync7(dirname3(path), { recursive: true });
11990
11907
  const body = {
11991
11908
  version: MARKER_VERSION,
11992
11909
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
11993
11910
  provider
11994
11911
  };
11995
- writeFileSync6(path, JSON.stringify(body, null, 2) + "\n");
11912
+ writeFileSync7(path, JSON.stringify(body, null, 2) + "\n");
11996
11913
  }
11997
11914
 
11998
11915
  // src/lib/star-prompt.ts
11999
11916
  import { spawnSync as spawnSync3 } from "child_process";
12000
- import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync7 } from "fs";
11917
+ import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync8 } from "fs";
12001
11918
  import { homedir as homedir18 } from "os";
12002
11919
  import { dirname as dirname4, join as join23 } from "path";
12003
- var STATE_VERSION = 1;
11920
+ var STATE_VERSION2 = 1;
12004
11921
  var REPO = "madarco/agentbox";
12005
11922
  var REPO_URL = `https://github.com/${REPO}`;
12006
- var DEFAULT_STATE = { version: STATE_VERSION, installCount: 0, starred: false };
11923
+ var DEFAULT_STATE = { version: STATE_VERSION2, installCount: 0, starred: false };
12007
11924
  function starStatePath() {
12008
11925
  return join23(homedir18(), ".agentbox", "star-prompt.json");
12009
11926
  }
12010
11927
  function readStarState() {
12011
11928
  const path = starStatePath();
12012
- if (!existsSync12(path)) return { ...DEFAULT_STATE };
11929
+ if (!existsSync13(path)) return { ...DEFAULT_STATE };
12013
11930
  try {
12014
- const parsed = JSON.parse(readFileSync5(path, "utf8"));
11931
+ const parsed = JSON.parse(readFileSync6(path, "utf8"));
12015
11932
  return {
12016
- version: STATE_VERSION,
11933
+ version: STATE_VERSION2,
12017
11934
  installCount: typeof parsed.installCount === "number" ? parsed.installCount : 0,
12018
11935
  starred: parsed.starred === true
12019
11936
  };
@@ -12023,8 +11940,8 @@ function readStarState() {
12023
11940
  }
12024
11941
  function writeStarState(state) {
12025
11942
  const path = starStatePath();
12026
- mkdirSync7(dirname4(path), { recursive: true });
12027
- writeFileSync7(path, JSON.stringify(state, null, 2) + "\n");
11943
+ mkdirSync8(dirname4(path), { recursive: true });
11944
+ writeFileSync8(path, JSON.stringify(state, null, 2) + "\n");
12028
11945
  }
12029
11946
  function ghReady() {
12030
11947
  const r = spawnSync3("gh", ["auth", "status"], { stdio: "ignore" });
@@ -12070,9 +11987,9 @@ async function maybePromptStar(opts) {
12070
11987
  }
12071
11988
 
12072
11989
  // src/commands/install-cmux.ts
12073
- import { intro as intro9, log as log37, note as note3, outro as outro8 } from "@clack/prompts";
11990
+ import { intro as intro9, log as log36, note as note3, outro as outro8 } from "@clack/prompts";
12074
11991
  import { Command as Command29 } from "commander";
12075
- import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync8 } from "fs";
11992
+ import { existsSync as existsSync14, mkdirSync as mkdirSync9, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync9 } from "fs";
12076
11993
  import { homedir as homedir19 } from "os";
12077
11994
  import { dirname as dirname5, join as join24 } from "path";
12078
11995
  var CONTROL_ID = "agentbox";
@@ -12109,14 +12026,14 @@ var installCmuxCommand = new Command29("cmux").description(
12109
12026
  height: parseHeight(opts.height)
12110
12027
  };
12111
12028
  let doc = { controls: [] };
12112
- if (existsSync13(dockPath)) {
12113
- const raw = readFileSync6(dockPath, "utf8");
12029
+ if (existsSync14(dockPath)) {
12030
+ const raw = readFileSync7(dockPath, "utf8");
12114
12031
  try {
12115
12032
  const parsed = JSON.parse(raw);
12116
12033
  if (parsed && typeof parsed === "object") doc = parsed;
12117
12034
  } catch {
12118
12035
  if (!opts.force) {
12119
- log37.error(
12036
+ log36.error(
12120
12037
  `existing dock config is not valid JSON: ${dockPath}
12121
12038
  fix it by hand, or pass --force to back it up and write a fresh one`
12122
12039
  );
@@ -12124,7 +12041,7 @@ fix it by hand, or pass --force to back it up and write a fresh one`
12124
12041
  }
12125
12042
  if (!opts.dryRun) {
12126
12043
  renameSync3(dockPath, dockPath + ".bak");
12127
- log37.warn(`backed up unparseable dock config to ${dockPath}.bak`);
12044
+ log36.warn(`backed up unparseable dock config to ${dockPath}.bak`);
12128
12045
  }
12129
12046
  doc = { controls: [] };
12130
12047
  }
@@ -12137,8 +12054,8 @@ fix it by hand, or pass --force to back it up and write a fresh one`
12137
12054
  outro8(`would write ${dockPath}`);
12138
12055
  return;
12139
12056
  }
12140
- mkdirSync8(dirname5(dockPath), { recursive: true });
12141
- writeFileSync8(dockPath, json);
12057
+ mkdirSync9(dirname5(dockPath), { recursive: true });
12058
+ writeFileSync9(dockPath, json);
12142
12059
  intro9("AgentBox cmux dock panel");
12143
12060
  note3(
12144
12061
  `Wrote ${dockPath}
@@ -12153,10 +12070,10 @@ To see it:
12153
12070
  });
12154
12071
 
12155
12072
  // src/commands/install-herdr.ts
12156
- import { intro as intro10, log as log38, note as note4, outro as outro9 } from "@clack/prompts";
12073
+ import { intro as intro10, log as log37, note as note4, outro as outro9 } from "@clack/prompts";
12157
12074
  import { Command as Command30, Option } from "commander";
12158
12075
  import { spawnSync as spawnSync4 } from "child_process";
12159
- import { chmodSync, existsSync as existsSync14, mkdirSync as mkdirSync9, readFileSync as readFileSync7, writeFileSync as writeFileSync9 } from "fs";
12076
+ import { chmodSync, existsSync as existsSync15, mkdirSync as mkdirSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync10 } from "fs";
12160
12077
  import { homedir as homedir20 } from "os";
12161
12078
  import { dirname as dirname6, join as join25 } from "path";
12162
12079
  var PLUGIN_VERSION = "0.2.0";
@@ -12286,14 +12203,14 @@ function escapeRe(s) {
12286
12203
  }
12287
12204
  function writeShim(dir) {
12288
12205
  const p = join25(dir, "agentbox-shim.sh");
12289
- writeFileSync9(p, herdrShimContent(process.execPath, process.argv[1] ?? "agentbox"));
12206
+ writeFileSync10(p, herdrShimContent(process.execPath, process.argv[1] ?? "agentbox"));
12290
12207
  chmodSync(p, 493);
12291
12208
  }
12292
12209
  function applyKeybindings() {
12293
12210
  const cfg = herdrConfigPath();
12294
- const existing = existsSync14(cfg) ? readFileSync7(cfg, "utf8") : "";
12295
- mkdirSync9(dirname6(cfg), { recursive: true });
12296
- writeFileSync9(cfg, upsertHerdrKeybindings(existing, herdrKeybindingsBlock()));
12211
+ const existing = existsSync15(cfg) ? readFileSync8(cfg, "utf8") : "";
12212
+ mkdirSync10(dirname6(cfg), { recursive: true });
12213
+ writeFileSync10(cfg, upsertHerdrKeybindings(existing, herdrKeybindingsBlock()));
12297
12214
  spawnSync4(herdrBinary(), ["server", "reload-config"], { stdio: "ignore" });
12298
12215
  return cfg;
12299
12216
  }
@@ -12331,10 +12248,10 @@ ${herdrKeybindingsBlock()}
12331
12248
  outro9(`would write ${dir}/*, edit ${cfgPath}, and run \`herdr plugin link ${dir}\``);
12332
12249
  return;
12333
12250
  }
12334
- mkdirSync9(dir, { recursive: true });
12335
- writeFileSync9(file, buildHerdrManifest());
12251
+ mkdirSync10(dir, { recursive: true });
12252
+ writeFileSync10(file, buildHerdrManifest());
12336
12253
  const buildPath = join25(dir, "build.sh");
12337
- writeFileSync9(buildPath, herdrBuildScript());
12254
+ writeFileSync10(buildPath, herdrBuildScript());
12338
12255
  chmodSync(buildPath, 493);
12339
12256
  writeShim(dir);
12340
12257
  const cfg = applyKeybindings();
@@ -12348,7 +12265,7 @@ ${herdrKeybindingsBlock()}
12348
12265
  if (linked.status === 0) {
12349
12266
  spawnSync4(bin, ["server", "reload-config"], { stdio: "ignore" });
12350
12267
  } else {
12351
- log38.warn(
12268
+ log37.warn(
12352
12269
  `could not run \`${bin} plugin link\` (is Herdr installed / running?).
12353
12270
  Run it yourself: herdr plugin link ${dir} && herdr server reload-config`
12354
12271
  );
@@ -12367,13 +12284,13 @@ Added shortcuts to ${cfg}
12367
12284
  import { Command as Command31 } from "commander";
12368
12285
  import { spawnSync as spawnSync5 } from "child_process";
12369
12286
  import {
12370
- existsSync as existsSync15,
12371
- mkdirSync as mkdirSync10,
12372
- readFileSync as readFileSync8,
12287
+ existsSync as existsSync16,
12288
+ mkdirSync as mkdirSync11,
12289
+ readFileSync as readFileSync9,
12373
12290
  readdirSync as readdirSync4,
12374
12291
  rmSync as rmSync3,
12375
12292
  symlinkSync as symlinkSync2,
12376
- writeFileSync as writeFileSync10
12293
+ writeFileSync as writeFileSync11
12377
12294
  } from "fs";
12378
12295
  import { homedir as homedir21 } from "os";
12379
12296
  import { dirname as dirname7, join as join26 } from "path";
@@ -12394,26 +12311,26 @@ function symlinkStagedSkills(devRoot, env = process.env) {
12394
12311
  let versionDir;
12395
12312
  try {
12396
12313
  const manifest = JSON.parse(
12397
- readFileSync8(join26(bundle, ".codex-plugin", "plugin.json"), "utf8")
12314
+ readFileSync9(join26(bundle, ".codex-plugin", "plugin.json"), "utf8")
12398
12315
  );
12399
12316
  if (manifest.version) versionDir = join26(pluginRoot, manifest.version);
12400
12317
  } catch {
12401
12318
  }
12402
- if (!versionDir || !existsSync15(versionDir)) {
12403
- const children = existsSync15(pluginRoot) ? readdirSync4(pluginRoot) : [];
12319
+ if (!versionDir || !existsSync16(versionDir)) {
12320
+ const children = existsSync16(pluginRoot) ? readdirSync4(pluginRoot) : [];
12404
12321
  versionDir = children.length === 1 ? join26(pluginRoot, children[0]) : void 0;
12405
12322
  }
12406
- if (!versionDir || !existsSync15(versionDir)) {
12323
+ if (!versionDir || !existsSync16(versionDir)) {
12407
12324
  return { linked: 0, error: "staged plugin dir not found" };
12408
12325
  }
12409
12326
  const skillsDir = join26(bundle, "skills");
12410
- if (!existsSync15(skillsDir)) return { linked: 0 };
12327
+ if (!existsSync16(skillsDir)) return { linked: 0 };
12411
12328
  let linked = 0;
12412
12329
  for (const name of readdirSync4(skillsDir)) {
12413
12330
  const repoSkill = join26(skillsDir, name, "SKILL.md");
12414
- if (!existsSync15(repoSkill)) continue;
12331
+ if (!existsSync16(repoSkill)) continue;
12415
12332
  const stagedSkill = join26(versionDir, "skills", name, "SKILL.md");
12416
- mkdirSync10(dirname7(stagedSkill), { recursive: true });
12333
+ mkdirSync11(dirname7(stagedSkill), { recursive: true });
12417
12334
  rmSync3(stagedSkill, { force: true });
12418
12335
  symlinkSync2(repoSkill, stagedSkill);
12419
12336
  linked++;
@@ -12435,7 +12352,7 @@ function codexHomeDir(env = process.env) {
12435
12352
  }
12436
12353
  function currentMarketplaceType(env = process.env) {
12437
12354
  try {
12438
- const cfg = readFileSync8(codexConfigPath(env), "utf8");
12355
+ const cfg = readFileSync9(codexConfigPath(env), "utf8");
12439
12356
  const parsed = parseToml(cfg);
12440
12357
  const t = parsed.marketplaces?.[MARKETPLACE_NAME]?.source_type;
12441
12358
  return typeof t === "string" ? t : null;
@@ -12520,7 +12437,7 @@ async function installCodexPlugin(opts = {}) {
12520
12437
  configPath: cfgPath,
12521
12438
  dev: devRoot !== null
12522
12439
  };
12523
- if (!existsSync15(codexHomeDir(env)) || !codexCliAvailable(env)) {
12440
+ if (!existsSync16(codexHomeDir(env)) || !codexCliAvailable(env)) {
12524
12441
  return result;
12525
12442
  }
12526
12443
  result.ran = true;
@@ -12571,12 +12488,12 @@ ${codexPluginEnableTable()}
12571
12488
  }
12572
12489
  }
12573
12490
  }
12574
- const existing = existsSync15(cfgPath) ? readFileSync8(cfgPath, "utf8") : "";
12491
+ const existing = existsSync16(cfgPath) ? readFileSync9(cfgPath, "utf8") : "";
12575
12492
  const { text: text3, status } = upsertCodexPluginEnable(existing, { force: opts.force });
12576
12493
  result.enableStatus = status;
12577
12494
  if (text3 !== existing) {
12578
- mkdirSync10(dirname7(cfgPath), { recursive: true });
12579
- writeFileSync10(cfgPath, text3);
12495
+ mkdirSync11(dirname7(cfgPath), { recursive: true });
12496
+ writeFileSync11(cfgPath, text3);
12580
12497
  } else if (status === "user-disabled" && !opts.quiet) {
12581
12498
  prompt_exports.log.info(
12582
12499
  `AgentBox Codex plugin is present but disabled in ${cfgPath} \u2014 leaving it off. Re-run with --force (or set enabled = true) to use it.`
@@ -12718,11 +12635,11 @@ function isSymlink(target) {
12718
12635
  }
12719
12636
  }
12720
12637
  function writableReason(target, force) {
12721
- if (!existsSync16(target)) {
12638
+ if (!existsSync17(target)) {
12722
12639
  if (isSymlink(target)) return "managed";
12723
12640
  return "new";
12724
12641
  }
12725
- const existing = readFileSync9(target, "utf8");
12642
+ const existing = readFileSync10(target, "utf8");
12726
12643
  if (existing.includes(MANAGED_SENTINEL) || existing.includes(LEGACY_INFO_MARKER)) {
12727
12644
  return "managed";
12728
12645
  }
@@ -12739,12 +12656,12 @@ function installHostSkills(opts = {}) {
12739
12656
  let skipped = 0;
12740
12657
  for (const t of installTargets()) {
12741
12658
  const src = join27(srcDir, t.src);
12742
- if (!existsSync16(src)) {
12659
+ if (!existsSync17(src)) {
12743
12660
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
12744
12661
  skipped++;
12745
12662
  continue;
12746
12663
  }
12747
- if (t.gateDir && !existsSync16(t.gateDir)) continue;
12664
+ if (t.gateDir && !existsSync17(t.gateDir)) continue;
12748
12665
  const reason = writableReason(t.dest, force);
12749
12666
  if (reason === "skip") {
12750
12667
  if (!quiet) prompt_exports.log.warn(`user-modified file at ${t.dest}, skipping; pass --force to overwrite`);
@@ -12757,13 +12674,13 @@ function installHostSkills(opts = {}) {
12757
12674
  written.push(t.dest);
12758
12675
  continue;
12759
12676
  }
12760
- mkdirSync11(dirname8(t.dest), { recursive: true });
12677
+ mkdirSync12(dirname8(t.dest), { recursive: true });
12761
12678
  if (link) {
12762
12679
  rmSync4(t.dest, { force: true });
12763
12680
  symlinkSync3(resolve5(srcDir, t.src), t.dest);
12764
12681
  } else {
12765
12682
  if (isSymlink(t.dest)) rmSync4(t.dest, { force: true });
12766
- writeFileSync11(t.dest, readFileSync9(src, "utf8"));
12683
+ writeFileSync12(t.dest, readFileSync10(src, "utf8"));
12767
12684
  }
12768
12685
  written.push(t.dest);
12769
12686
  }
@@ -12777,7 +12694,7 @@ async function installForkSkill(opts = {}) {
12777
12694
  const srcDir = resolveHostSkillsDir();
12778
12695
  const src = join27(srcDir, "agentbox", "SKILL.md");
12779
12696
  const dest = join27(homedir22(), ".claude", "skills", "agentbox", "SKILL.md");
12780
- if (!existsSync16(src)) {
12697
+ if (!existsSync17(src)) {
12781
12698
  if (!quiet) prompt_exports.log.warn(`bundled file missing (skipped): ${src}`);
12782
12699
  return { written: [], skipped: 1, blocked: [], method: "skip" };
12783
12700
  }
@@ -12792,7 +12709,7 @@ async function installForkSkill(opts = {}) {
12792
12709
  return { written: [dest], skipped: 0, blocked: [], method: "dry-run" };
12793
12710
  }
12794
12711
  if (isSourceCheckout(srcDir)) {
12795
- mkdirSync11(dirname8(dest), { recursive: true });
12712
+ mkdirSync12(dirname8(dest), { recursive: true });
12796
12713
  rmSync4(dest, { force: true });
12797
12714
  symlinkSync3(src, dest);
12798
12715
  return { written: [dest], skipped: 0, blocked: [], method: "symlink" };
@@ -12815,16 +12732,16 @@ async function installForkSkill(opts = {}) {
12815
12732
  ],
12816
12733
  { timeout: 12e4 }
12817
12734
  );
12818
- if (existsSync16(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
12735
+ if (existsSync17(dest)) return { written: [dest], skipped: 0, blocked: [], method: "npx" };
12819
12736
  throw new Error("`skills add` reported success but wrote no skill file");
12820
12737
  } catch (err) {
12821
12738
  if (!quiet) {
12822
12739
  const msg = err instanceof Error ? err.message : String(err);
12823
12740
  prompt_exports.log.warn(`\`npx skills add\` failed (${msg}); copying the bundled fork skill instead`);
12824
12741
  }
12825
- mkdirSync11(dirname8(dest), { recursive: true });
12742
+ mkdirSync12(dirname8(dest), { recursive: true });
12826
12743
  if (isSymlink(dest)) rmSync4(dest, { force: true });
12827
- writeFileSync11(dest, readFileSync9(src, "utf8"));
12744
+ writeFileSync12(dest, readFileSync10(src, "utf8"));
12828
12745
  return { written: [dest], skipped: 0, blocked: [], method: "copy" };
12829
12746
  }
12830
12747
  }
@@ -12962,6 +12879,9 @@ pass \`agentbox install --skills-only --force\` to overwrite`
12962
12879
  prompt_exports.log.warn(`Codex plugin setup skipped: ${err instanceof Error ? err.message : String(err)}`);
12963
12880
  }
12964
12881
  markSetupComplete(providerName);
12882
+ if (AGENTBOX_VERSION !== "0.0.0-dev" && readUpdateState().lastRunVersion === void 0) {
12883
+ writeUpdateState({ lastRunVersion: AGENTBOX_VERSION });
12884
+ }
12965
12885
  const providerGroup = await runProviderChecks(providerName);
12966
12886
  process.stdout.write(" " + formatCompact([sysGroup, providerGroup]) + "\n");
12967
12887
  if (process.platform === "darwin") {
@@ -13036,7 +12956,7 @@ installCommand.addCommand(installTrayCommand);
13036
12956
 
13037
12957
  // src/commands/plugin.ts
13038
12958
  import { execFileSync } from "child_process";
13039
- import { existsSync as existsSync17, readFileSync as readFileSync10, statSync as statSync3 } from "fs";
12959
+ import { existsSync as existsSync18, readFileSync as readFileSync11, statSync as statSync3 } from "fs";
13040
12960
  import { createRequire } from "module";
13041
12961
  import { dirname as dirname9, isAbsolute as isAbsolute3, resolve as resolve6 } from "path";
13042
12962
  import { pathToFileURL } from "url";
@@ -13054,7 +12974,7 @@ function resolutionPaths() {
13054
12974
  }
13055
12975
  function resolvePackage(arg) {
13056
12976
  let pkgDir;
13057
- if ((arg.startsWith(".") || arg.startsWith("/") || isAbsolute3(arg)) && existsSync17(arg)) {
12977
+ if ((arg.startsWith(".") || arg.startsWith("/") || isAbsolute3(arg)) && existsSync18(arg)) {
13058
12978
  pkgDir = statSync3(arg).isDirectory() ? resolve6(arg) : dirname9(resolve6(arg));
13059
12979
  } else {
13060
12980
  const req = createRequire(pathToFileURL(resolve6(process.cwd(), "noop.js")).href);
@@ -13075,7 +12995,7 @@ function resolvePackage(arg) {
13075
12995
  }
13076
12996
  pkgDir = dirname9(pkgJsonPath);
13077
12997
  }
13078
- const pkgJson = JSON.parse(readFileSync10(resolve6(pkgDir, "package.json"), "utf8"));
12998
+ const pkgJson = JSON.parse(readFileSync11(resolve6(pkgDir, "package.json"), "utf8"));
13079
12999
  const entryRel = pickEntry(pkgJson);
13080
13000
  return {
13081
13001
  packageName: pkgJson.name ?? arg,
@@ -13493,10 +13413,16 @@ for (const op of GH_PR_OPS) {
13493
13413
  var gitCommand = new Command35("git").description("Run git / gh pr operations against a box from the host").addCommand(pushCommand).addCommand(fetchCommand).addCommand(pullCommand).addCommand(checkoutCommand).addCommand(branchCommand).addCommand(statusCommand).addCommand(prCommand);
13494
13414
 
13495
13415
  // src/commands/list.ts
13496
- import { log as log42 } from "@clack/prompts";
13416
+ import { log as log41 } from "@clack/prompts";
13497
13417
  import { Command as Command36 } from "commander";
13498
13418
  import { pathToFileURL as pathToFileURL2 } from "url";
13499
13419
 
13420
+ // src/box-label.ts
13421
+ function boxLabel(box) {
13422
+ const custom = box.displayName?.trim();
13423
+ return custom ? custom : box.name;
13424
+ }
13425
+
13500
13426
  // src/hyperlink.ts
13501
13427
  import { supportsHyperlink } from "supports-hyperlinks";
13502
13428
  var ESC2 = "\x1B";
@@ -13768,7 +13694,7 @@ function renderCmuxRows(boxes, color, width, linkNames = false) {
13768
13694
  lines.push(projectHeader(projectLabel(root), color, width));
13769
13695
  for (const b of group) {
13770
13696
  const idx = b.projectIndex ? `${String(b.projectIndex)} ` : "";
13771
- const disp = tailKeep(b.name, Math.max(1, width - idx.length));
13697
+ const disp = tailKeep(boxLabel(b), Math.max(1, width - idx.length));
13772
13698
  const name = linkNames ? hyperlink(disp, `agentbox://web/${b.id}`, void 0, true) : disp;
13773
13699
  lines.push(`${idx}${name}`);
13774
13700
  lines.push(" " + cmuxStatusCell(b, color));
@@ -13790,7 +13716,7 @@ function renderTable(boxes, stream) {
13790
13716
  const wsCol = header.length - 1;
13791
13717
  const lead = boxes.map((b) => [
13792
13718
  plain(typeof b.projectIndex === "number" ? String(b.projectIndex) : ""),
13793
- plain(b.name),
13719
+ plain(boxLabel(b)),
13794
13720
  plain(b.state),
13795
13721
  // One column for every agent (claude / codex / opencode) — see agentSummary.
13796
13722
  plain(agentSummary(b)),
@@ -13861,7 +13787,7 @@ var listCommand2 = withWatchOptions(
13861
13787
  )
13862
13788
  ).action(async (opts) => {
13863
13789
  if (opts.json && opts.watch) {
13864
- log42.error("cannot combine --json with --watch");
13790
+ log41.error("cannot combine --json with --watch");
13865
13791
  process.exit(2);
13866
13792
  }
13867
13793
  const all = opts.global ?? false;
@@ -13906,7 +13832,7 @@ var listCommand2 = withWatchOptions(
13906
13832
  });
13907
13833
 
13908
13834
  // src/commands/logs.ts
13909
- import { log as log43 } from "@clack/prompts";
13835
+ import { log as log42 } from "@clack/prompts";
13910
13836
  import { Command as Command37 } from "commander";
13911
13837
  import { spawn as spawn6 } from "child_process";
13912
13838
  var DAEMON_LOG_PATH = "/var/log/agentbox/ctl-daemon.log";
@@ -13928,9 +13854,9 @@ var logsCommand = new Command37("logs").description("Print recent log lines from
13928
13854
  service = boxArg;
13929
13855
  }
13930
13856
  if (!service && !opts.daemon) {
13931
- log43.error("missing <service> argument");
13932
- log43.info("usage: agentbox logs [box] <service> [-n N] [-f]");
13933
- log43.info(" agentbox logs [box] --daemon [-n N] [-f]");
13857
+ log42.error("missing <service> argument");
13858
+ log42.info("usage: agentbox logs [box] <service> [-n N] [-f]");
13859
+ log42.info(" agentbox logs [box] --daemon [-n N] [-f]");
13934
13860
  process.exit(2);
13935
13861
  }
13936
13862
  const box = await resolveBoxOrExit(idOrName);
@@ -13941,7 +13867,7 @@ var logsCommand = new Command37("logs").description("Print recent log lines from
13941
13867
  if (!opts.follow) {
13942
13868
  const proc = await provider.exec(box, args, { user: "vscode" });
13943
13869
  if (proc.exitCode !== 0) {
13944
- log43.error(
13870
+ log42.error(
13945
13871
  `${opts.daemon ? "daemon log" : "agentbox-ctl logs"} failed: ${proc.stderr || proc.stdout}`
13946
13872
  );
13947
13873
  process.exit(1);
@@ -13997,12 +13923,12 @@ var logsCommand = new Command37("logs").description("Print recent log lines from
13997
13923
  });
13998
13924
 
13999
13925
  // src/commands/open.ts
14000
- import { log as log44 } from "@clack/prompts";
13926
+ import { log as log43 } from "@clack/prompts";
14001
13927
  import { execa as execa9 } from "execa";
14002
- import { existsSync as existsSync18, mkdirSync as mkdirSync12 } from "fs";
13928
+ import { existsSync as existsSync19, mkdirSync as mkdirSync13 } from "fs";
14003
13929
  import { homedir as homedir23 } from "os";
14004
- import { join as join28 } from "path";
14005
- import { Command as Command38 } from "commander";
13930
+ import { join as join29 } from "path";
13931
+ import { Command as Command38, InvalidArgumentError as InvalidArgumentError3 } from "commander";
14006
13932
 
14007
13933
  // src/commands/path.ts
14008
13934
  async function runPath(box, opts) {
@@ -14023,8 +13949,96 @@ async function runPath(box, opts) {
14023
13949
  }
14024
13950
  }
14025
13951
 
13952
+ // src/commands/_open-in.ts
13953
+ import { existsSync as realExistsSync } from "fs";
13954
+ import { homedir as realHomedir } from "os";
13955
+ import { delimiter, join as join28 } from "path";
13956
+ var OPEN_IN_APPS = ["codex", "herdr", "cmux", "vscode", "iterm2"];
13957
+ var PERSISTENT_SSH_PROVIDERS = ["hetzner"];
13958
+ var IDE_PROVIDERS = ["docker", "hetzner", "daytona"];
13959
+ function realSeams() {
13960
+ return {
13961
+ env: process.env,
13962
+ platform: process.platform,
13963
+ homedir: realHomedir,
13964
+ existsSync: realExistsSync
13965
+ };
13966
+ }
13967
+ function pathHasBinary(name, seams) {
13968
+ const path = seams.env["PATH"] ?? "";
13969
+ for (const dir of path.split(delimiter)) {
13970
+ if (dir.length === 0) continue;
13971
+ if (seams.existsSync(join28(dir, name))) return true;
13972
+ }
13973
+ return false;
13974
+ }
13975
+ function macAppInstalled(appName, seams) {
13976
+ if (seams.platform !== "darwin") return false;
13977
+ return seams.existsSync(join28("/Applications", appName)) || seams.existsSync(join28(seams.homedir(), "Applications", appName));
13978
+ }
13979
+ function defaultHerdrSocketPath(seams = realSeams()) {
13980
+ const p = join28(seams.homedir(), ".config", "herdr", "herdr.sock");
13981
+ return seams.existsSync(p) ? p : void 0;
13982
+ }
13983
+ var CMUX_APP_CLI_SUFFIX = "cmux.app/Contents/Resources/bin/cmux";
13984
+ function resolveCmuxBinary(seams = realSeams()) {
13985
+ const bundled = seams.env["CMUX_BUNDLED_CLI_PATH"];
13986
+ if (bundled && bundled.length > 0) return bundled;
13987
+ if (pathHasBinary("cmux", seams)) return "cmux";
13988
+ if (seams.platform === "darwin") {
13989
+ for (const root of ["/Applications", join28(seams.homedir(), "Applications")]) {
13990
+ const cli = join28(root, CMUX_APP_CLI_SUFFIX);
13991
+ if (seams.existsSync(cli)) return cli;
13992
+ }
13993
+ }
13994
+ return void 0;
13995
+ }
13996
+ function detectOpenTargets(seams = realSeams()) {
13997
+ return {
13998
+ codex: {
13999
+ available: macAppInstalled("Codex.app", seams),
14000
+ providers: [...PERSISTENT_SSH_PROVIDERS]
14001
+ },
14002
+ herdr: {
14003
+ available: pathHasBinary("herdr", seams) || defaultHerdrSocketPath(seams) !== void 0
14004
+ },
14005
+ cmux: {
14006
+ available: pathHasBinary("cmux", seams) || macAppInstalled("cmux.app", seams)
14007
+ },
14008
+ vscode: {
14009
+ available: pathHasBinary("code", seams) || pathHasBinary("cursor", seams),
14010
+ providers: [...IDE_PROVIDERS]
14011
+ },
14012
+ iterm2: {
14013
+ available: macAppInstalled("iTerm.app", seams)
14014
+ }
14015
+ };
14016
+ }
14017
+ function codexAddUrl(alias) {
14018
+ return `codex://settings/connections/ssh/add?name=${encodeURIComponent(alias)}`;
14019
+ }
14020
+ function renderTargets(report) {
14021
+ const lines = OPEN_IN_APPS.map((app) => {
14022
+ const info = report[app];
14023
+ const status = info.available ? "available" : "not installed";
14024
+ const scope = info.providers ? ` (${info.providers.join(", ")} boxes)` : "";
14025
+ return `${app}: ${status}${info.available ? scope : ""}`;
14026
+ });
14027
+ return lines.join("\n") + "\n";
14028
+ }
14029
+
14026
14030
  // src/commands/open.ts
14027
- var openCommand = new Command38("open").description("Open a box's /workspace in Finder (docker: rsync'd snapshot; cloud: sshfs mount)").argument(
14031
+ function parseOpenTarget(value) {
14032
+ if (value === "codex" || value === "herdr" || value === "cmux" || value === "vscode" || value === "iterm2" || value === "finder") {
14033
+ return value;
14034
+ }
14035
+ throw new InvalidArgumentError3(
14036
+ `expected one of: codex, herdr, cmux, vscode, iterm2, finder (got "${value}")`
14037
+ );
14038
+ }
14039
+ var openCommand = new Command38("open").description(
14040
+ "Open a box in Finder (default; docker: rsync'd snapshot; cloud: sshfs mount) or in a host app via --in"
14041
+ ).argument(
14028
14042
  "[box]",
14029
14043
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
14030
14044
  ).option("--no-refresh", "skip the rsync; open whatever's already on disk (docker only)").option(
@@ -14033,9 +14047,31 @@ var openCommand = new Command38("open").description("Open a box's /workspace in
14033
14047
  ).option("--path", "print the host workspace / mount path instead of launching Finder").option("--print", "alias of --path").option(
14034
14048
  "--unmount",
14035
14049
  "cloud only: unmount any existing sshfs mount for the box and exit"
14036
- ).action(async (idOrName, opts) => {
14050
+ ).option(
14051
+ "--in <app>",
14052
+ "open the box in a host app instead of Finder: codex | herdr | cmux | vscode | iterm2 | finder",
14053
+ parseOpenTarget
14054
+ ).option("--targets", "print which --in apps are installed on this host and exit (no box needed)").option("--json", "with --targets: machine-readable output").action(async (idOrName, opts) => {
14037
14055
  try {
14056
+ if (opts.targets) {
14057
+ const report = detectOpenTargets();
14058
+ process.stdout.write(opts.json ? JSON.stringify(report) + "\n" : renderTargets(report));
14059
+ return;
14060
+ }
14038
14061
  const box = await resolveBoxOrExit(idOrName);
14062
+ const app = opts.in ?? "finder";
14063
+ if (app === "codex") {
14064
+ await openInCodex(box);
14065
+ return;
14066
+ }
14067
+ if (app === "herdr" || app === "cmux" || app === "iterm2") {
14068
+ await openInTerminalApp(box, app);
14069
+ return;
14070
+ }
14071
+ if (app === "vscode") {
14072
+ await runCodeOpen(box, {});
14073
+ return;
14074
+ }
14039
14075
  const isCloud = (box.provider ?? "docker") !== "docker";
14040
14076
  if (isCloud) {
14041
14077
  await runCloudOpen(box, opts);
@@ -14061,19 +14097,124 @@ var openCommand = new Command38("open").description("Open a box's /workspace in
14061
14097
  handleLifecycleError(err);
14062
14098
  }
14063
14099
  });
14064
- async function runCloudOpen(box, opts) {
14065
- const mountRoot = join28(homedir23(), ".agentbox", "mounts", box.name);
14066
- if (opts.unmount) {
14067
- const ok = await tryUnmount(mountRoot);
14068
- if (ok) process.stdout.write(`unmounted ${mountRoot}
14069
- `);
14070
- else process.stdout.write(`nothing mounted at ${mountRoot}
14071
- `);
14072
- return;
14100
+ async function openInCodex(box) {
14101
+ const providerName = box.provider ?? "docker";
14102
+ if (!PERSISTENT_SSH_PROVIDERS.includes(providerName)) {
14103
+ throw new Error(
14104
+ `'--in codex' needs a box with a persistent SSH key \u2014 only Hetzner cloud boxes qualify (this box is '${providerName}'). Docker boxes aren't reachable over SSH and Daytona uses a 60-min token that expires. Try 'agentbox open ${box.name} --in vscode' instead.`
14105
+ );
14073
14106
  }
14074
- if (opts.path || opts.print) {
14075
- process.stdout.write(`${mountRoot}
14076
- `);
14107
+ const provider = await providerForBox(box);
14108
+ const conn = await resolveCloudSshTarget(box, provider);
14109
+ if (!conn.identityFile) {
14110
+ throw new Error(
14111
+ `box '${box.name}' (provider '${providerName}') has no persistent SSH key, so it can't be added to Codex over SSH.`
14112
+ );
14113
+ }
14114
+ await recordBoxSsh(box.id, {
14115
+ host: conn.host,
14116
+ user: conn.user,
14117
+ identityFile: conn.identityFile
14118
+ });
14119
+ await syncAgentboxSshConfig();
14120
+ log43.info(`ssh alias '${conn.alias}' written (Include'd from ~/.ssh/config)`);
14121
+ const url = codexAddUrl(conn.alias);
14122
+ const opened = await execa9(hostOpenCommand(), [url], { reject: false });
14123
+ if (opened.exitCode !== 0) {
14124
+ log43.warn(
14125
+ `could not auto-open the Codex link (is Codex.app installed?): ${opened.stderr || `exit ${String(opened.exitCode)}`}`
14126
+ );
14127
+ const link = hyperlink(`Add ${conn.alias} to Codex SSH`, url, process.stdout);
14128
+ process.stdout.write(`open manually: ${link}
14129
+ ${url}
14130
+ `);
14131
+ process.exitCode = 1;
14132
+ return;
14133
+ }
14134
+ log43.success(`opening Codex \u2014 the SSH connection form is pre-filled with '${conn.alias}'`);
14135
+ process.stdout.write(url + "\n");
14136
+ }
14137
+ async function openInTerminalApp(box, host) {
14138
+ if ((box.provider ?? "docker") === "docker") {
14139
+ const insp = await inspectBox(box.id);
14140
+ if (insp.state === "paused") {
14141
+ log43.info("box is paused; unpausing");
14142
+ await unpauseBox(box.id);
14143
+ } else if (insp.state === "stopped") {
14144
+ log43.info("box is stopped; starting");
14145
+ await startBox(box.id);
14146
+ } else if (insp.state === "missing") {
14147
+ throw new Error(`box ${box.name} has no container; was it destroyed?`);
14148
+ }
14149
+ } else {
14150
+ const p = await providerForBox(box);
14151
+ const state = await p.probeState(box);
14152
+ if (state === "paused") {
14153
+ log43.info("box is paused; resuming");
14154
+ await p.resume(box);
14155
+ } else if (state === "stopped") {
14156
+ log43.info("box is stopped; starting");
14157
+ await p.start(box);
14158
+ } else if (state === "missing") {
14159
+ throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
14160
+ }
14161
+ }
14162
+ const env = { ...process.env };
14163
+ if (host === "herdr" && !env["HERDR_SOCKET_PATH"]) {
14164
+ const sock = defaultHerdrSocketPath();
14165
+ if (!sock) {
14166
+ throw new Error(
14167
+ `Herdr socket not found (~/.config/herdr/herdr.sock). Is Herdr running? Set up the integration with 'agentbox install herdr'.`
14168
+ );
14169
+ }
14170
+ env["HERDR_SOCKET_PATH"] = sock;
14171
+ }
14172
+ if (host === "cmux") {
14173
+ const bin = resolveCmuxBinary();
14174
+ if (!bin) {
14175
+ throw new Error(
14176
+ `cmux CLI not found \u2014 not on PATH and no /Applications/cmux.app. Install cmux first.`
14177
+ );
14178
+ }
14179
+ env["CMUX_BUNDLED_CLI_PATH"] = bin;
14180
+ }
14181
+ const cwd = box.workspacePath || box.projectRoot || homedir23();
14182
+ const r = await spawnInNewTerminal({
14183
+ host,
14184
+ mode: "window",
14185
+ argv: [process.execPath, process.argv[1] ?? "agentbox", "attach", box.name, "--inline"],
14186
+ cwd,
14187
+ title: box.name,
14188
+ env,
14189
+ // A failed attach (e.g. no agent session yet) should leave a usable shell
14190
+ // in the new pane, not a closed one.
14191
+ keepShell: true
14192
+ });
14193
+ if (!r.launched) {
14194
+ if (host === "cmux" && /password|auth|denied|unauthorized|control/i.test(r.error ?? "")) {
14195
+ throw new Error(
14196
+ `cmux refused the control connection \u2014 external processes can't drive it by default. In cmux Settings enable socketControlMode "automation", or set a socket password (Settings, or CMUX_SOCKET_PASSWORD).
14197
+ ${r.error ?? ""}`
14198
+ );
14199
+ }
14200
+ const hint = host === "herdr" ? " Is Herdr running? (`herdr status server`)" : host === "cmux" ? " Is cmux running?" : " Is iTerm2 installed?";
14201
+ throw new Error(`could not open in ${host}: ${r.error ?? "unknown error"}.${hint}`);
14202
+ }
14203
+ log43.success(`opened ${box.name} in a new ${host} ${host === "iterm2" ? "window" : "workspace"} (agentbox attach)`);
14204
+ }
14205
+ async function runCloudOpen(box, opts) {
14206
+ const mountRoot = join29(homedir23(), ".agentbox", "mounts", box.name);
14207
+ if (opts.unmount) {
14208
+ const ok = await tryUnmount(mountRoot);
14209
+ if (ok) process.stdout.write(`unmounted ${mountRoot}
14210
+ `);
14211
+ else process.stdout.write(`nothing mounted at ${mountRoot}
14212
+ `);
14213
+ return;
14214
+ }
14215
+ if (opts.path || opts.print) {
14216
+ process.stdout.write(`${mountRoot}
14217
+ `);
14077
14218
  return;
14078
14219
  }
14079
14220
  const sshfsBin = await locateBinary("sshfs");
@@ -14082,14 +14223,15 @@ async function runCloudOpen(box, opts) {
14082
14223
  "sshfs not found on PATH. Install with `brew install macfuse sshfs` (macOS) or your distro's package manager, then retry. Cloud `agentbox open` mounts the sandbox /workspace via sshfs."
14083
14224
  );
14084
14225
  }
14085
- const { alias } = await ensureCloudSshAlias(box);
14086
- if (!existsSync18(mountRoot)) {
14087
- mkdirSync12(mountRoot, { recursive: true, mode: 493 });
14226
+ const provider = await providerForBox(box);
14227
+ const { alias } = await ensureCloudSshAlias(box, provider);
14228
+ if (!existsSync19(mountRoot)) {
14229
+ mkdirSync13(mountRoot, { recursive: true, mode: 493 });
14088
14230
  } else if (await isMounted(mountRoot)) {
14089
- log44.info(`re-mounting (stale mount detected at ${mountRoot})`);
14231
+ log43.info(`re-mounting (stale mount detected at ${mountRoot})`);
14090
14232
  await tryUnmount(mountRoot);
14091
14233
  }
14092
- log44.info(`mounting ${alias}:/workspace at ${mountRoot}`);
14234
+ log43.info(`mounting ${alias}:/workspace at ${mountRoot}`);
14093
14235
  const mount = await execa9(
14094
14236
  sshfsBin,
14095
14237
  [
@@ -14320,7 +14462,7 @@ async function pruneCloud(provider, opts) {
14320
14462
 
14321
14463
  // src/commands/queue.ts
14322
14464
  import { readFile as readFile6, stat as stat6 } from "fs/promises";
14323
- import { intro as intro13, log as log46, outro as outro12 } from "@clack/prompts";
14465
+ import { intro as intro13, log as log45, outro as outro12 } from "@clack/prompts";
14324
14466
  import { Command as Command41 } from "commander";
14325
14467
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["done", "failed", "cancelled"]);
14326
14468
  var queueCommand = new Command41("queue").description("Inspect and manage background `agentbox claude|codex|opencode -i` jobs");
@@ -14329,8 +14471,8 @@ var queueListCommand = new Command41("list").description("List queued, running,
14329
14471
  const cfg = await loadQueueConfig();
14330
14472
  const visible = opts.all === true ? jobs : jobs.filter((j) => !TERMINAL_STATUSES.has(j.status));
14331
14473
  if (visible.length === 0) {
14332
- log46.info(opts.all ? "no queued jobs." : "no active queued jobs (--all to see terminal).");
14333
- log46.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
14474
+ log45.info(opts.all ? "no queued jobs." : "no active queued jobs (--all to see terminal).");
14475
+ log45.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
14334
14476
  return;
14335
14477
  }
14336
14478
  const rows = visible.map((j) => ({
@@ -14355,12 +14497,12 @@ var queueListCommand = new Command41("list").description("List queued, running,
14355
14497
  headers.map((h, i) => pad4(String(r[h]), widths[i])).join(" ") + "\n"
14356
14498
  );
14357
14499
  }
14358
- log46.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
14500
+ log45.info(`queue.maxConcurrent = ${String(cfg.maxConcurrent)} (queue.enabled=${String(cfg.enabled)})`);
14359
14501
  });
14360
14502
  var queueShowCommand = new Command41("show").description("Dump a job manifest and tail its log").argument("<id>", "queue job id (from `agentbox queue list`)").option("--tail <n>", "lines of log to print (default: 50)", "50").action(async (id, opts) => {
14361
14503
  const job = await readJob(id);
14362
14504
  if (!job) {
14363
- log46.error(`no job with id ${id}`);
14505
+ log45.error(`no job with id ${id}`);
14364
14506
  process.exit(1);
14365
14507
  }
14366
14508
  process.stdout.write(JSON.stringify(job, null, 2) + "\n");
@@ -14376,18 +14518,18 @@ var queueShowCommand = new Command41("show").description("Dump a job manifest an
14376
14518
  process.stdout.write(slice.join("\n"));
14377
14519
  if (!slice.join("\n").endsWith("\n")) process.stdout.write("\n");
14378
14520
  } catch {
14379
- log46.info(`(no log at ${job.logPath} yet)`);
14521
+ log45.info(`(no log at ${job.logPath} yet)`);
14380
14522
  }
14381
14523
  });
14382
14524
  var queueCancelCommand = new Command41("cancel").description("Cancel a queued job; running jobs are NOT killed \u2014 use `agentbox destroy` instead").argument("<id>", "queue job id (from `agentbox queue list`)").action(async (id) => {
14383
14525
  intro13(`Cancelling queue job ${id}...`);
14384
14526
  const job = await readJob(id);
14385
14527
  if (!job) {
14386
- log46.error(`no job with id ${id}`);
14528
+ log45.error(`no job with id ${id}`);
14387
14529
  process.exit(1);
14388
14530
  }
14389
14531
  if (job.status !== "queued") {
14390
- log46.error(
14532
+ log45.error(
14391
14533
  `job ${id} is ${job.status}; cancel only flips 'queued' \u2192 'cancelled'.` + (job.status === "running" ? ` Use 'agentbox destroy ${job.boxName || id}' to stop the box.` : "")
14392
14534
  );
14393
14535
  process.exit(1);
@@ -14407,7 +14549,7 @@ var queueClearCommand = new Command41("clear").description("Sweep terminal-state
14407
14549
  if (opts.all === true || opts.failed === true) targets.add("failed");
14408
14550
  if (opts.all === true || opts.cancelled === true) targets.add("cancelled");
14409
14551
  if (targets.size === 0) {
14410
- log46.error("pick at least one of: --done, --failed, --cancelled, --all");
14552
+ log45.error("pick at least one of: --done, --failed, --cancelled, --all");
14411
14553
  process.exit(2);
14412
14554
  }
14413
14555
  const jobs = await loadQueue();
@@ -14417,7 +14559,7 @@ var queueClearCommand = new Command41("clear").description("Sweep terminal-state
14417
14559
  await deleteJob(j.id);
14418
14560
  removed += 1;
14419
14561
  }
14420
- log46.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
14562
+ log45.success(`removed ${String(removed)} manifest${removed === 1 ? "" : "s"}`);
14421
14563
  });
14422
14564
  var QUEUE_WAIT_EVENTS = [
14423
14565
  "new-box",
@@ -14434,7 +14576,7 @@ var queueWaitForCommand = new Command41("wait-for").description(
14434
14576
  `Block until a queue / box event fires. <event> one of: ${QUEUE_WAIT_EVENTS.join(" | ")}.`
14435
14577
  ).argument("<event>", `target event: ${QUEUE_WAIT_EVENTS.join(" | ")}`).option("--box <ref>", "box ref (required for box-paused / box-running / box-stopped)").option("--job <id>", "queue job id (required for job-done)").option("--timeout <ms>", `wall-clock cap (default: ${String(DEFAULT_QUEUE_WAIT_TIMEOUT_MS)})`).option("--json", "emit a JSON envelope { matched, elapsedMs, ... }").action(async (eventRaw, opts) => {
14436
14578
  if (!QUEUE_WAIT_EVENTS.includes(eventRaw)) {
14437
- log46.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
14579
+ log45.error(`unknown event '${eventRaw}' (one of: ${QUEUE_WAIT_EVENTS.join(", ")})`);
14438
14580
  process.exit(2);
14439
14581
  }
14440
14582
  const event = eventRaw;
@@ -14454,11 +14596,11 @@ var queueWaitForCommand = new Command41("wait-for").description(
14454
14596
  if (opts.json === true) {
14455
14597
  process.stdout.write(JSON.stringify({ matched: false, event, elapsedMs }) + "\n");
14456
14598
  } else {
14457
- log46.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
14599
+ log45.error(`'${event}' did not occur within ${String(timeoutMs)}ms`);
14458
14600
  }
14459
14601
  process.exit(1);
14460
14602
  }
14461
- log46.error(err instanceof Error ? err.message : String(err));
14603
+ log45.error(err instanceof Error ? err.message : String(err));
14462
14604
  process.exit(1);
14463
14605
  }
14464
14606
  });
@@ -14555,7 +14697,7 @@ function truncate(s, max) {
14555
14697
  }
14556
14698
 
14557
14699
  // src/commands/relay.ts
14558
- import { log as log47, spinner as spinner10 } from "@clack/prompts";
14700
+ import { log as log46, spinner as spinner10 } from "@clack/prompts";
14559
14701
  import { Command as Command42 } from "commander";
14560
14702
  async function rehydrateFromState() {
14561
14703
  const state = await readState();
@@ -14651,7 +14793,7 @@ var restartSub2 = new Command42("restart").description("Stop then start the host
14651
14793
  s2.stop(`relay running on ${ep.hostUrl}`);
14652
14794
  } catch (err) {
14653
14795
  s2.stop("relay start failed");
14654
- log47.warn(err instanceof Error ? err.message : String(err));
14796
+ log46.warn(err instanceof Error ? err.message : String(err));
14655
14797
  throw err;
14656
14798
  }
14657
14799
  } catch (err) {
@@ -14662,7 +14804,7 @@ var relayCommand = new Command42("relay").description("Manage the host relay pro
14662
14804
 
14663
14805
  // src/commands/hub.ts
14664
14806
  import { spawn as spawn7 } from "child_process";
14665
- import { log as log48, spinner as spinner11 } from "@clack/prompts";
14807
+ import { log as log47, spinner as spinner11 } from "@clack/prompts";
14666
14808
  import { Command as Command43 } from "commander";
14667
14809
  async function resolvePortlessEnabled() {
14668
14810
  try {
@@ -14757,7 +14899,7 @@ var restartSub3 = new Command43("restart").description("Stop then start the hub"
14757
14899
  if (opts.open !== false) openInBrowser2(ep.openUrl);
14758
14900
  } catch (err) {
14759
14901
  s2.stop("hub start failed");
14760
- log48.warn(err instanceof Error ? err.message : String(err));
14902
+ log47.warn(err instanceof Error ? err.message : String(err));
14761
14903
  throw err;
14762
14904
  }
14763
14905
  } catch (err) {
@@ -14769,13 +14911,13 @@ var hubCommand = new Command43("hub").description(
14769
14911
  ).addCommand(startSub3, { isDefault: true }).addCommand(statusSub3).addCommand(stopSub3).addCommand(restartSub3);
14770
14912
 
14771
14913
  // src/commands/control-plane.ts
14772
- import { isCancel as isCancel5, log as log49, note as note7, select as select3, spinner as spinner12 } from "@clack/prompts";
14914
+ import { isCancel as isCancel5, log as log48, note as note7, select as select3, spinner as spinner12 } from "@clack/prompts";
14773
14915
  import { Command as Command44 } from "commander";
14774
14916
  import { spawn as spawn10 } from "child_process";
14775
- import { existsSync as existsSync19, readFileSync as readFileSync11 } from "fs";
14917
+ import { existsSync as existsSync20, readFileSync as readFileSync12 } from "fs";
14776
14918
  import { chmod, mkdir as mkdir2, rm, writeFile as writeFile5 } from "fs/promises";
14777
14919
  import { hostname, homedir as homedir25, tmpdir as tmpdir6 } from "os";
14778
- import { join as join31 } from "path";
14920
+ import { join as join32 } from "path";
14779
14921
  import { setTimeout as delay3 } from "timers/promises";
14780
14922
  import { randomBytes as randomBytes3 } from "crypto";
14781
14923
 
@@ -14930,7 +15072,7 @@ async function runGitHubAppManifestFlow(opts) {
14930
15072
  import { spawn as spawn9 } from "child_process";
14931
15073
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync5 } from "fs";
14932
15074
  import { tmpdir as tmpdir5 } from "os";
14933
- import { join as join29 } from "path";
15075
+ import { join as join30 } from "path";
14934
15076
 
14935
15077
  // src/control-plane/github-fork.ts
14936
15078
  import { spawn as spawn8 } from "child_process";
@@ -14994,7 +15136,7 @@ function isConnectError(msg) {
14994
15136
  }
14995
15137
  function provisionNeon(teamId, projectId, log60) {
14996
15138
  return new Promise((resolve7) => {
14997
- const work = mkdtempSync2(join29(tmpdir5(), "agentbox-neon-"));
15139
+ const work = mkdtempSync2(join30(tmpdir5(), "agentbox-neon-"));
14998
15140
  const env = { ...process.env, VERCEL_PROJECT_ID: projectId, ...teamId ? { VERCEL_ORG_ID: teamId } : {} };
14999
15141
  const child = spawn9("vercel", ["integration", "add", "neon", "--non-interactive"], {
15000
15142
  cwd: work,
@@ -15167,7 +15309,7 @@ async function deployControlPlaneToVercel(opts) {
15167
15309
  // src/control-plane/deploy-hetzner.ts
15168
15310
  import { readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
15169
15311
  import { homedir as homedir24 } from "os";
15170
- import { join as join30 } from "path";
15312
+ import { join as join31 } from "path";
15171
15313
  async function runHetznerDeploy(opts) {
15172
15314
  if (readHetznerCredStatus().source === "none") {
15173
15315
  throw new Error("no HCLOUD_TOKEN configured \u2014 run `agentbox hetzner login` first");
@@ -15178,7 +15320,7 @@ async function runHetznerDeploy(opts) {
15178
15320
  repoRef: opts.repoRef,
15179
15321
  onLog: opts.log
15180
15322
  });
15181
- const deployPath = join30(homedir24(), ".agentbox", "control-plane", "deploy.json");
15323
+ const deployPath = join31(homedir24(), ".agentbox", "control-plane", "deploy.json");
15182
15324
  await writeFile4(
15183
15325
  deployPath,
15184
15326
  JSON.stringify({ provider: "hetzner", ...result }, null, 2) + "\n",
@@ -15219,10 +15361,10 @@ async function resolveHubAuthEnv() {
15219
15361
  }
15220
15362
 
15221
15363
  // src/commands/control-plane.ts
15222
- var CP_DIR2 = join31(homedir25(), ".agentbox", "control-plane");
15223
- var PEM_PATH = join31(CP_DIR2, "github-app.pem");
15224
- var ENV_PATH2 = join31(CP_DIR2, "control-plane.env");
15225
- var META_PATH2 = join31(CP_DIR2, "control-plane.json");
15364
+ var CP_DIR2 = join32(homedir25(), ".agentbox", "control-plane");
15365
+ var PEM_PATH = join32(CP_DIR2, "github-app.pem");
15366
+ var ENV_PATH2 = join32(CP_DIR2, "control-plane.env");
15367
+ var META_PATH2 = join32(CP_DIR2, "control-plane.json");
15226
15368
  var DEFAULT_DEPLOY_REPO = "madarco/agentbox";
15227
15369
  var DEFAULT_DEPLOY_REF = "main";
15228
15370
  async function applyControlPlaneUrl(url) {
@@ -15281,7 +15423,7 @@ AGENTBOX_RELAY_ADMIN_TOKEN=${adminToken}
15281
15423
  JSON.stringify({ appId: app.appId, slug: app.slug, htmlUrl: app.htmlUrl, installUrl: app.installUrl }, null, 2) + "\n",
15282
15424
  { mode: 384 }
15283
15425
  );
15284
- log49.success(`GitHub App ready. Deploy config written to ${ENV_PATH2} (0600).`);
15426
+ log48.success(`GitHub App ready. Deploy config written to ${ENV_PATH2} (0600).`);
15285
15427
  const target = await resolveDeployTarget(opts.deploy);
15286
15428
  let deployedUrl = null;
15287
15429
  if (target !== "none") {
@@ -15315,7 +15457,7 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
15315
15457
  }
15316
15458
  ds.stop(`deployed: ${deployedUrl}`);
15317
15459
  } catch (e) {
15318
- log49.warn(`deploy to ${target} failed: ${e instanceof Error ? e.message : String(e)}`);
15460
+ log48.warn(`deploy to ${target} failed: ${e instanceof Error ? e.message : String(e)}`);
15319
15461
  printManualDeploy();
15320
15462
  }
15321
15463
  } else {
@@ -15323,13 +15465,13 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
15323
15465
  }
15324
15466
  if (deployedUrl) {
15325
15467
  const url = await applyControlPlaneUrl(deployedUrl);
15326
- log49.success(`Pointed the CLI at ${url} (relay.controlPlaneUrl).`);
15468
+ log48.success(`Pointed the CLI at ${url} (relay.controlPlaneUrl).`);
15327
15469
  const ok = await waitForHealthz(url, 6e4);
15328
- log49[ok ? "success" : "warn"](
15470
+ log48[ok ? "success" : "warn"](
15329
15471
  ok ? `Control plane is healthy (${url}/healthz).` : `Could not confirm ${url}/healthz yet \u2014 check the deployment.`
15330
15472
  );
15331
15473
  }
15332
- log49.info(`Install the App on your repos: ${app.installUrl}`);
15474
+ log48.info(`Install the App on your repos: ${app.installUrl}`);
15333
15475
  openInBrowser(app.installUrl);
15334
15476
  } catch (err) {
15335
15477
  handleLifecycleError(err);
@@ -15338,7 +15480,7 @@ AGENTBOX_HUB_ADMIN_PASSWORD=${hubAuth.AGENTBOX_HUB_ADMIN_PASSWORD}
15338
15480
  async function resolveDeployTarget(flag) {
15339
15481
  if (flag === "vercel" || flag === "hetzner" || flag === "none") return flag;
15340
15482
  if (flag) {
15341
- log49.warn(`unknown --deploy "${flag}"; choose interactively`);
15483
+ log48.warn(`unknown --deploy "${flag}"; choose interactively`);
15342
15484
  }
15343
15485
  const choice = await select3({
15344
15486
  message: "Deploy the control plane now?",
@@ -15353,7 +15495,7 @@ async function resolveDeployTarget(flag) {
15353
15495
  return choice;
15354
15496
  }
15355
15497
  function printManualDeploy() {
15356
- log49.info(
15498
+ log48.info(
15357
15499
  [
15358
15500
  "Deploy later with the written env:",
15359
15501
  ` Self-host: cd apps/hub && docker compose --env-file ${ENV_PATH2} up --build`,
@@ -15365,7 +15507,7 @@ function printManualDeploy() {
15365
15507
  var setUrlSub = new Command44("set-url").description("Point boxes + the CLI at a deployed control plane (sets relay.controlPlaneUrl)").argument("<url>", "base URL of the deployed control plane, e.g. https://plane.example.com").action(async (url) => {
15366
15508
  try {
15367
15509
  const trimmed = await applyControlPlaneUrl(url);
15368
- log49.success(`Set relay.controlPlaneUrl = ${trimmed}`);
15510
+ log48.success(`Set relay.controlPlaneUrl = ${trimmed}`);
15369
15511
  } catch (err) {
15370
15512
  handleLifecycleError(err);
15371
15513
  }
@@ -15375,19 +15517,19 @@ var unsetUrlSub = new Command44("unset-url").description("Stop using a control p
15375
15517
  const g = await unsetConfigValue("global", "relay.controlPlaneUrl", process.cwd());
15376
15518
  const p = await unsetConfigValue("project", "relay.controlPlaneUrl", process.cwd());
15377
15519
  if (!g.existed && !p.existed) {
15378
- log49.info("No control plane was configured (relay.controlPlaneUrl not set).");
15520
+ log48.info("No control plane was configured (relay.controlPlaneUrl not set).");
15379
15521
  } else {
15380
15522
  const where = [g.existed ? "global" : null, p.existed ? "project" : null].filter(Boolean).join(" + ");
15381
- log49.success(
15523
+ log48.success(
15382
15524
  `Removed relay.controlPlaneUrl (${where}). New cloud boxes now push through the host relay (your laptop must be on), and the GitHub-App repo-authorization prompt no longer fires.`
15383
15525
  );
15384
15526
  }
15385
- if (existsSync19(CP_DIR2)) {
15527
+ if (existsSync20(CP_DIR2)) {
15386
15528
  if (opts.purge) {
15387
15529
  await rm(CP_DIR2, { recursive: true, force: true });
15388
- log49.success(`Purged this machine's control-plane credentials (${CP_DIR2}).`);
15530
+ log48.success(`Purged this machine's control-plane credentials (${CP_DIR2}).`);
15389
15531
  } else {
15390
- log49.info(`This machine's App metadata + admin token remain in ${CP_DIR2} (use --purge to delete).`);
15532
+ log48.info(`This machine's App metadata + admin token remain in ${CP_DIR2} (use --purge to delete).`);
15391
15533
  }
15392
15534
  }
15393
15535
  } catch (err) {
@@ -15396,11 +15538,11 @@ var unsetUrlSub = new Command44("unset-url").description("Stop using a control p
15396
15538
  });
15397
15539
  var statusSub4 = new Command44("status").description("Check whether the configured control plane is reachable").option("--url <url>", "override the control-plane URL (default: relay.controlPlaneUrl)").option("--json", "emit JSON").action(async (opts) => {
15398
15540
  try {
15399
- const { loadEffectiveConfig: loadEffectiveConfig2 } = await import("./dist-QBXEP4VY.js");
15541
+ const { loadEffectiveConfig: loadEffectiveConfig2 } = await import("./dist-2BTJQUJS.js");
15400
15542
  const cfg = await loadEffectiveConfig2(process.cwd());
15401
15543
  const url = (opts.url ?? cfg.effective.relay.controlPlaneUrl ?? "").replace(/\/$/, "");
15402
15544
  if (!url) {
15403
- log49.error("No control plane configured. Run `agentbox control-plane set-url <url>` (or pass --url).");
15545
+ log48.error("No control plane configured. Run `agentbox control-plane set-url <url>` (or pass --url).");
15404
15546
  process.exitCode = 1;
15405
15547
  return;
15406
15548
  }
@@ -15430,31 +15572,31 @@ var addSub = new Command44("add").description("Authorize the current project's g
15430
15572
  const cfg = await loadEffectiveConfig(process.cwd());
15431
15573
  const controlPlaneUrl = cfg.effective.relay.controlPlaneUrl;
15432
15574
  if (!controlPlaneUrl) {
15433
- log49.error("No control plane configured. Run `agentbox control-plane set-url <url>` first.");
15575
+ log48.error("No control plane configured. Run `agentbox control-plane set-url <url>` first.");
15434
15576
  process.exitCode = 1;
15435
15577
  return;
15436
15578
  }
15437
15579
  const ownerRepo = await resolveOwnerRepo(process.cwd());
15438
15580
  if (!ownerRepo) {
15439
- log49.error("No git origin found here \u2014 `cd` into a project with a GitHub remote.");
15581
+ log48.error("No git origin found here \u2014 `cd` into a project with a GitHub remote.");
15440
15582
  process.exitCode = 1;
15441
15583
  return;
15442
15584
  }
15443
15585
  const { owner, repo } = ownerRepo;
15444
15586
  const installed = await checkRepoInstalled(owner, repo, controlPlaneUrl);
15445
15587
  if (installed === true) {
15446
- log49.success(`${owner}/${repo} is already authorized on the GitHub App.`);
15588
+ log48.success(`${owner}/${repo} is already authorized on the GitHub App.`);
15447
15589
  return;
15448
15590
  }
15449
15591
  const url = addRepoUrl(loadControlPlaneMeta());
15450
15592
  if (!url) {
15451
- log49.error(
15593
+ log48.error(
15452
15594
  "No GitHub App metadata found locally. Run this from a machine that ran `control-plane setup`,\nor open your App settings on GitHub and add the repo manually."
15453
15595
  );
15454
15596
  process.exitCode = 1;
15455
15597
  return;
15456
15598
  }
15457
- log49.info(`Opening ${url} \u2014 select ${owner}/${repo}, then approve.`);
15599
+ log48.info(`Opening ${url} \u2014 select ${owner}/${repo}, then approve.`);
15458
15600
  openInBrowser(url);
15459
15601
  } catch (err) {
15460
15602
  handleLifecycleError(err);
@@ -15462,8 +15604,8 @@ var addSub = new Command44("add").description("Authorize the current project's g
15462
15604
  });
15463
15605
  function loadControlPlaneEnv() {
15464
15606
  if (process.env.GITHUB_APP_ID && process.env.GITHUB_APP_PRIVATE_KEY) return;
15465
- if (!existsSync19(ENV_PATH2)) return;
15466
- for (const line of readFileSync11(ENV_PATH2, "utf8").split("\n")) {
15607
+ if (!existsSync20(ENV_PATH2)) return;
15608
+ for (const line of readFileSync12(ENV_PATH2, "utf8").split("\n")) {
15467
15609
  const m = /^([A-Z_]+)=(.*)$/.exec(line.trim());
15468
15610
  if (m && !process.env[m[1]]) process.env[m[1]] = m[2];
15469
15611
  }
@@ -15487,7 +15629,7 @@ var workerSub = new Command44("worker").description(
15487
15629
  loadControlPlaneEnv();
15488
15630
  const appCfg = loadGitHubAppConfig();
15489
15631
  if (!appCfg) {
15490
- log49.error("No GitHub App configured. Run `agentbox control-plane setup` first.");
15632
+ log48.error("No GitHub App configured. Run `agentbox control-plane setup` first.");
15491
15633
  process.exitCode = 1;
15492
15634
  return;
15493
15635
  }
@@ -15512,7 +15654,7 @@ var workerSub = new Command44("worker").description(
15512
15654
  const created = await p.create({ workspacePath, name, projectRoot: workspacePath, onLog });
15513
15655
  return { id: created.record.id };
15514
15656
  },
15515
- tmpDir: (jobId) => join31(tmpdir6(), `agentbox-cp-worker-${jobId}`),
15657
+ tmpDir: (jobId) => join32(tmpdir6(), `agentbox-cp-worker-${jobId}`),
15516
15658
  cleanup: (dir) => rm(dir, { recursive: true, force: true }),
15517
15659
  log: (line) => process.stdout.write(`agentbox-cp-worker: ${line}
15518
15660
  `)
@@ -15544,7 +15686,7 @@ var controlPlaneCommand = new Command44("control-plane").description("EXPERIMENT
15544
15686
  // src/commands/_run-queued-job.ts
15545
15687
  import { Command as Command45 } from "commander";
15546
15688
  import { stat as stat7 } from "fs/promises";
15547
- import { join as join32 } from "path";
15689
+ import { join as join33 } from "path";
15548
15690
 
15549
15691
  // src/lib/claude-login-run.ts
15550
15692
  var URL_TIMEOUT_MS = 6e4;
@@ -15692,7 +15834,7 @@ async function runClaudeLogin(opts) {
15692
15834
  // src/commands/_run-queued-job.ts
15693
15835
  async function applySetupWizardPrompt(job, workspace, basePrompt) {
15694
15836
  if (!job.setupWizard) return basePrompt;
15695
- const hasYaml = await stat7(join32(workspace, "agentbox.yaml")).then(() => true).catch(() => false);
15837
+ const hasYaml = await stat7(join33(workspace, "agentbox.yaml")).then(() => true).catch(() => false);
15696
15838
  const setup = buildSetupInitialPrompt(workspace, hasYaml);
15697
15839
  const rest = basePrompt.trim();
15698
15840
  return rest ? `${setup}
@@ -15828,6 +15970,11 @@ async function runDockerJob(job, log60, onBoxCreated) {
15828
15970
  if (!job.noAgent && job.agent === "claude-code") {
15829
15971
  await ensureClaudeLoginFresh({ id: job.id, log: log60, image: cfg.effective.box.image, isCloud: false });
15830
15972
  }
15973
+ const portlessEnabled = opts.portless ?? await resolvePortlessNonInteractive({
15974
+ engine: await detectEngine(),
15975
+ enabled: cfg.effective.portless.enabled,
15976
+ cwd: opts.workspace
15977
+ });
15831
15978
  log60.write(`creating box for agent=${job.noAgent ? "none" : job.agent}`);
15832
15979
  const result = await createBox({
15833
15980
  workspacePath: opts.workspace,
@@ -15845,12 +15992,7 @@ async function runDockerJob(job, log60, onBoxCreated) {
15845
15992
  withEnv: cfg.effective.box.withEnv,
15846
15993
  vnc: { enabled: cfg.effective.box.vnc },
15847
15994
  docker: { sharedCache: cfg.effective.box.dockerCacheShared },
15848
- // Background jobs (incl. hub-created boxes) can't negotiate Portless
15849
- // interactively, but they must still honor a resolved `portless.enabled`.
15850
- // Explicit --portless / --no-portless on the job wins; otherwise fall back
15851
- // to the effective config so a host that opted in gets its <name>.localhost
15852
- // alias registered. Undefined (never opted in) still skips, as before.
15853
- portless: opts.portless ?? cfg.effective.portless.enabled,
15995
+ portless: portlessEnabled,
15854
15996
  portlessStateDir: cfg.effective.portless.stateDir || void 0,
15855
15997
  resyncOnStart: opts.resync,
15856
15998
  limits: resolveLimits(cfg.effective.box, opts),
@@ -15980,6 +16122,12 @@ async function runCloudJob(job, log60, onBoxCreated) {
15980
16122
  });
15981
16123
  const persisted = await readJob(job.id);
15982
16124
  await writeJob({ ...job, boxId: result.record.id, login: persisted?.login });
16125
+ await autoWriteSshConfig(
16126
+ result.record,
16127
+ provider,
16128
+ cfg.effective.ssh.autoConfig,
16129
+ (m) => log60.write(m)
16130
+ );
15983
16131
  if (job.noAgent) {
15984
16132
  log60.write("no-agent box created; skipping agent session");
15985
16133
  return;
@@ -16162,9 +16310,196 @@ var claudeLoginWorkerCommand = new Command47("_claude-login-worker").description
16162
16310
  process.exit(result.ok ? 0 : 1);
16163
16311
  });
16164
16312
 
16313
+ // src/commands/_post-update-refresh.ts
16314
+ import { Command as Command48 } from "commander";
16315
+
16316
+ // src/lib/post-update-refresh.ts
16317
+ async function maybeUpdateTray(say) {
16318
+ if (!trayInstalled()) return;
16319
+ const state = readUpdateState();
16320
+ const latestSha = remoteCheckFresh(state) && state.remoteCheck?.trayLatestSha !== void 0 ? state.remoteCheck.trayLatestSha : await fetchTraySidecarSha();
16321
+ const decision = decideTrayUpdate({
16322
+ installed: true,
16323
+ stampedSha: state.traySha,
16324
+ latestSha
16325
+ });
16326
+ if (!decision.update) {
16327
+ say(
16328
+ decision.reason === "no-latest-sha" ? "menu-bar app: release sha unavailable \u2014 skipped" : "menu-bar app already current"
16329
+ );
16330
+ return;
16331
+ }
16332
+ const res = await installTray({ quiet: true });
16333
+ say(
16334
+ res.ran ? "menu-bar app updated" : `menu-bar app not updated (${res.reason ?? "unknown"}) \u2014 run \`agentbox install tray\` manually`
16335
+ );
16336
+ }
16337
+ async function runPostUpdateRefresh(opts = {}) {
16338
+ const say = (msg) => {
16339
+ if (!opts.quiet) prompt_exports.log.info(msg);
16340
+ };
16341
+ const warn = (step, err) => {
16342
+ prompt_exports.log.warn(`${step} failed (${err instanceof Error ? err.message : String(err)}) \u2014 continuing`);
16343
+ };
16344
+ if (!opts.skipSkills) {
16345
+ try {
16346
+ const res = installHostSkills({ quiet: true });
16347
+ say(
16348
+ res.written.length > 0 ? `refreshed host skills (${String(res.written.length)} file(s))` : `host skills already current (${String(res.skipped)} skipped)`
16349
+ );
16350
+ if (res.blocked.length > 0) {
16351
+ prompt_exports.log.warn(
16352
+ `user-modified skill file(s) left in place: ${res.blocked.join(", ")} \u2014 run \`agentbox install --skills-only --force\` to overwrite`
16353
+ );
16354
+ }
16355
+ } catch (err) {
16356
+ warn("host skills refresh", err);
16357
+ }
16358
+ }
16359
+ try {
16360
+ const removed = await removeImage(DEFAULT_BOX_IMAGE);
16361
+ say(
16362
+ removed ? `removed image ${DEFAULT_BOX_IMAGE} (rebuilds on next create/claude)` : `image ${DEFAULT_BOX_IMAGE} not present (nothing to remove)`
16363
+ );
16364
+ } catch (err) {
16365
+ warn("box image removal", err);
16366
+ }
16367
+ try {
16368
+ const stop = await stopRelay();
16369
+ say(stop.stopped ? `stopped relay (pid ${String(stop.pid)})` : "relay was not running");
16370
+ const ep = await ensureRelay();
16371
+ say(`relay back up on ${ep.hostUrl}`);
16372
+ } catch (err) {
16373
+ warn("relay reload", err);
16374
+ }
16375
+ try {
16376
+ await maybeUpdateTray(say);
16377
+ } catch (err) {
16378
+ warn("menu-bar app update", err);
16379
+ }
16380
+ writeUpdateState({ lastRunVersion: AGENTBOX_VERSION });
16381
+ }
16382
+
16383
+ // src/commands/_post-update-refresh.ts
16384
+ var postUpdateRefreshCommand = new Command48("_post-update-refresh").description("internal: refresh skills, box image, relay, and tray after a package update").option("--skip-skills", "skip refreshing the host skill files").action(async (opts) => {
16385
+ try {
16386
+ await runPostUpdateRefresh({ skipSkills: opts.skipSkills });
16387
+ } catch (err) {
16388
+ handleLifecycleError(err);
16389
+ }
16390
+ });
16391
+
16392
+ // src/lib/update-check.ts
16393
+ import { readFile as readFile8 } from "fs/promises";
16394
+
16395
+ // src/exec-method.ts
16396
+ function detectExecutionMethod(input) {
16397
+ const ua = input.userAgent ?? "";
16398
+ const argv1 = input.argv1 ?? "";
16399
+ if (argv1.includes("/_npx/") || argv1.includes("/.npm/_npx") || /\bnpx\//.test(ua)) {
16400
+ return "npx";
16401
+ }
16402
+ if (/\bpnpm\//.test(ua)) {
16403
+ return "pnpm";
16404
+ }
16405
+ if (/\bnpm\//.test(ua)) {
16406
+ return "npm";
16407
+ }
16408
+ return "direct";
16409
+ }
16410
+
16411
+ // src/lib/semver-lite.ts
16412
+ var TRIPLET = /^(\d+)\.(\d+)\.(\d+)$/;
16413
+ function parseTriplet(v) {
16414
+ const m = TRIPLET.exec(v.trim());
16415
+ if (!m) return null;
16416
+ return [Number(m[1]), Number(m[2]), Number(m[3])];
16417
+ }
16418
+ function compareSemver(a, b) {
16419
+ const pa = parseTriplet(a);
16420
+ const pb = parseTriplet(b);
16421
+ if (!pa || !pb) return null;
16422
+ for (let i = 0; i < 3; i++) {
16423
+ const ai = pa[i];
16424
+ const bi = pb[i];
16425
+ if (ai < bi) return -1;
16426
+ if (ai > bi) return 1;
16427
+ }
16428
+ return 0;
16429
+ }
16430
+ function isNewer(latest, current) {
16431
+ if (latest === void 0) return false;
16432
+ return compareSemver(latest, current) === 1;
16433
+ }
16434
+
16435
+ // src/lib/update-check.ts
16436
+ var PKG = "@madarco/agentbox";
16437
+ var REGISTRY_URL = `https://registry.npmjs.org/${PKG}/latest`;
16438
+ function nudgeEligible(method, version) {
16439
+ return version !== "0.0.0-dev" && method !== "npx";
16440
+ }
16441
+ async function updateCheckEnabled() {
16442
+ try {
16443
+ const cfg = await loadEffectiveConfig(process.cwd());
16444
+ return cfg.effective.update.check;
16445
+ } catch {
16446
+ try {
16447
+ const raw = await readFile8(GLOBAL_CONFIG_FILE, "utf8");
16448
+ return parseUserConfig(raw, GLOBAL_CONFIG_FILE).update?.check ?? true;
16449
+ } catch (err) {
16450
+ return err.code === "ENOENT";
16451
+ }
16452
+ }
16453
+ }
16454
+ async function fetchNpmLatest() {
16455
+ try {
16456
+ const res = await fetch(REGISTRY_URL, { signal: AbortSignal.timeout(3e3) });
16457
+ if (!res.ok) return void 0;
16458
+ const body = await res.json();
16459
+ return typeof body.version === "string" ? body.version : void 0;
16460
+ } catch {
16461
+ return void 0;
16462
+ }
16463
+ }
16464
+ function maybeStartRemoteCheck() {
16465
+ const state = readUpdateState();
16466
+ if (remoteCheckFresh(state)) return null;
16467
+ const method = detectExecutionMethod({
16468
+ userAgent: process.env.npm_config_user_agent,
16469
+ argv1: process.argv[1]
16470
+ });
16471
+ const run = async () => {
16472
+ let npmLatest;
16473
+ let trayLatestSha;
16474
+ if (await updateCheckEnabled()) {
16475
+ [npmLatest, trayLatestSha] = await Promise.all([
16476
+ nudgeEligible(method, AGENTBOX_VERSION) ? fetchNpmLatest() : Promise.resolve(void 0),
16477
+ trayInstalled() ? fetchTraySidecarSha() : Promise.resolve(void 0)
16478
+ ]);
16479
+ }
16480
+ const prev = readUpdateState().remoteCheck;
16481
+ npmLatest ??= prev?.npmLatest;
16482
+ trayLatestSha ??= prev?.trayLatestSha;
16483
+ writeUpdateState({
16484
+ remoteCheck: {
16485
+ checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
16486
+ ...npmLatest !== void 0 ? { npmLatest } : {},
16487
+ ...trayLatestSha !== void 0 ? { trayLatestSha } : {}
16488
+ }
16489
+ });
16490
+ };
16491
+ return run().catch(() => void 0);
16492
+ }
16493
+ function nudgeMessage(state, method, version = AGENTBOX_VERSION) {
16494
+ if (!nudgeEligible(method, version)) return null;
16495
+ const latest = state.remoteCheck?.npmLatest;
16496
+ if (!isNewer(latest, version)) return null;
16497
+ return `a newer agentbox (${latest}) is available \u2014 run \`agentbox self-update\``;
16498
+ }
16499
+
16165
16500
  // src/commands/herdr.ts
16166
16501
  import { spawnSync as spawnSync6 } from "child_process";
16167
- import { Command as Command48 } from "commander";
16502
+ import { Command as Command49 } from "commander";
16168
16503
  function parseHerdrLink(uri) {
16169
16504
  if (!uri) return null;
16170
16505
  const m = uri.match(/^agentbox:\/\/([^/]+)\/(.+)$/);
@@ -16190,7 +16525,7 @@ function herdrContextCwd(env = process.env) {
16190
16525
  }
16191
16526
  return process.cwd();
16192
16527
  }
16193
- var newCommand = new Command48("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) => {
16528
+ var newCommand = new Command49("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) => {
16194
16529
  const agent = opts.agent ?? "claude";
16195
16530
  const cwd = herdrContextCwd();
16196
16531
  const r = await spawnInNewTerminal({
@@ -16203,7 +16538,7 @@ var newCommand = new Command48("new").description("Open a new box session in a f
16203
16538
  if (r.launched) process.stdout.write(r.note + "\n");
16204
16539
  else if (r.error) process.stderr.write(r.error + "\n");
16205
16540
  });
16206
- var linkCommand = new Command48("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) => {
16541
+ var linkCommand = new Command49("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) => {
16207
16542
  const link = parseHerdrLink(uriArg ?? process.env["HERDR_PLUGIN_CLICKED_URL"]);
16208
16543
  if (!link) return;
16209
16544
  if (link.verb !== "web") return;
@@ -16236,16 +16571,16 @@ var linkCommand = new Command48("link").description("Handle a Ctrl+click on an a
16236
16571
  sound: "request"
16237
16572
  });
16238
16573
  });
16239
- var herdrCommand = new Command48("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
16574
+ var herdrCommand = new Command49("herdr").description("Internal: Herdr plugin entry points (see `agentbox install herdr`)").addCommand(newCommand).addCommand(linkCommand);
16240
16575
 
16241
16576
  // src/commands/recover.ts
16242
16577
  import { homedir as homedir26 } from "os";
16243
- import { join as join33 } from "path";
16578
+ import { join as join34 } from "path";
16244
16579
  import { access as access3 } from "fs/promises";
16245
16580
  import { isCancel as isCancel6, log as log50, select as select4 } from "@clack/prompts";
16246
- import { Command as Command49 } from "commander";
16581
+ import { Command as Command50 } from "commander";
16247
16582
  function hetznerKeyPath(sandboxId) {
16248
- return join33(homedir26(), ".agentbox", "boxes", sandboxId, "ssh", "id_ed25519");
16583
+ return join34(homedir26(), ".agentbox", "boxes", sandboxId, "ssh", "id_ed25519");
16249
16584
  }
16250
16585
  async function fileExists2(path) {
16251
16586
  try {
@@ -16394,7 +16729,7 @@ async function adoptUnknownBox(provider, ref) {
16394
16729
  );
16395
16730
  return record;
16396
16731
  }
16397
- var recoverCommand = new Command49("recover").description(
16732
+ var recoverCommand = new Command50("recover").description(
16398
16733
  "Reconnect to an already-running box without power-cycling it: ensure the relay is up, re-open the host transport (Hetzner SSH tunnel) + portless aliases, re-register with the relay, relaunch the agent it was running, and attach. With --all, recover every box in state. With --provider <p> --adopt [ref], first rebuild local state for a box created elsewhere."
16399
16734
  ).argument(
16400
16735
  "[box]",
@@ -16457,7 +16792,7 @@ var recoverCommand = new Command49("recover").description(
16457
16792
  // src/commands/screen.ts
16458
16793
  import { spawnSync as spawnSync7 } from "child_process";
16459
16794
  import { log as log51 } from "@clack/prompts";
16460
- import { Command as Command50 } from "commander";
16795
+ import { Command as Command51 } from "commander";
16461
16796
  var SIGNED_URL_TTL_MIN = 1;
16462
16797
  var SIGNED_URL_TTL_MAX = 86400;
16463
16798
  function parseTtlOrExit(raw) {
@@ -16470,7 +16805,7 @@ function parseTtlOrExit(raw) {
16470
16805
  }
16471
16806
  return n;
16472
16807
  }
16473
- var screenCommand = new Command50("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
16808
+ var screenCommand = new Command51("screen").description("Open a box's VNC (noVNC) viewer in the browser (auto-unpause/start)").argument(
16474
16809
  "[box]",
16475
16810
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
16476
16811
  ).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(
@@ -16578,7 +16913,7 @@ var screenCommand = new Command50("screen").description("Open a box's VNC (noVNC
16578
16913
 
16579
16914
  // src/commands/services.ts
16580
16915
  import { log as log52 } from "@clack/prompts";
16581
- import { Command as Command51 } from "commander";
16916
+ import { Command as Command52 } from "commander";
16582
16917
  async function liveStatus(provider, box) {
16583
16918
  const r = await boxServicesStatusRaw(provider, box).catch(() => null);
16584
16919
  if (!r || r.exitCode !== 0) return null;
@@ -16588,7 +16923,7 @@ async function liveStatus(provider, box) {
16588
16923
  return null;
16589
16924
  }
16590
16925
  }
16591
- var listCommand3 = new Command51("list").description("List the box's services with their live state (running / ready / crashed / \u2026)").argument("[box]", "box ref (default: the only box in this project)").option("--json", "print the raw live status (services, tasks, ports) as JSON").action(async (idOrName, opts) => {
16926
+ var listCommand3 = new Command52("list").description("List the box's services with their live state (running / ready / crashed / \u2026)").argument("[box]", "box ref (default: the only box in this project)").option("--json", "print the raw live status (services, tasks, ports) as JSON").action(async (idOrName, opts) => {
16592
16927
  try {
16593
16928
  const box = await resolveBoxOrExit(idOrName);
16594
16929
  const provider = await providerForBox(box);
@@ -16614,7 +16949,7 @@ var listCommand3 = new Command51("list").description("List the box's services wi
16614
16949
  handleLifecycleError(err);
16615
16950
  }
16616
16951
  });
16617
- var restartCommand = new Command51("restart").description("Restart one service, or every service when no name is given").argument("[box]", "box ref (default: the only box in this project)").argument("[name]", "service to restart (omit to restart all)").action(async (idOrName, name) => {
16952
+ var restartCommand = new Command52("restart").description("Restart one service, or every service when no name is given").argument("[box]", "box ref (default: the only box in this project)").argument("[name]", "service to restart (omit to restart all)").action(async (idOrName, name) => {
16618
16953
  try {
16619
16954
  const { box, shifted } = await resolveBoxOrShift(idOrName);
16620
16955
  const serviceName = shifted ? idOrName : name;
@@ -16651,12 +16986,12 @@ var restartCommand = new Command51("restart").description("Restart one service,
16651
16986
  handleLifecycleError(err);
16652
16987
  }
16653
16988
  });
16654
- var servicesCommand = new Command51("services").description("List and restart a box's agentbox.yaml services").addCommand(listCommand3, { isDefault: true }).addCommand(restartCommand);
16989
+ var servicesCommand = new Command52("services").description("List and restart a box's agentbox.yaml services").addCommand(listCommand3, { isDefault: true }).addCommand(restartCommand);
16655
16990
 
16656
16991
  // src/commands/shell.ts
16657
16992
  import { spawnSync as spawnSync8 } from "child_process";
16658
16993
  import { log as log54 } from "@clack/prompts";
16659
- import { Command as Command52 } from "commander";
16994
+ import { Command as Command53 } from "commander";
16660
16995
 
16661
16996
  // src/commands/_provider-guard.ts
16662
16997
  import { log as log53 } from "@clack/prompts";
@@ -16774,7 +17109,8 @@ async function startOrAttachShell(box, cfg) {
16774
17109
  process.exit(code);
16775
17110
  }
16776
17111
  async function runSshConfig(box, opts) {
16777
- const conn = await resolveCloudSshTarget(box);
17112
+ const provider = await providerForBox(box);
17113
+ const conn = await resolveCloudSshTarget(box, provider);
16778
17114
  if (!conn.identityFile) {
16779
17115
  throw new Error(
16780
17116
  `box '${box.name}' (provider '${box.provider ?? "docker"}') has no persistent SSH key, so it can't be added to Codex / Claude desktop over SSH. Only Hetzner cloud boxes are supported \u2014 Docker boxes aren't reachable over SSH, and Daytona uses a 60-min token that expires.`
@@ -16791,7 +17127,7 @@ async function runSshConfig(box, opts) {
16791
17127
  identityFile: conn.identityFile
16792
17128
  });
16793
17129
  await syncAgentboxSshConfig();
16794
- const codexUrl = `codex://settings/connections/ssh/add?name=${encodeURIComponent(conn.alias)}`;
17130
+ const codexUrl = codexAddUrl(conn.alias);
16795
17131
  if (opts.json) {
16796
17132
  process.stdout.write(
16797
17133
  JSON.stringify(
@@ -16821,11 +17157,12 @@ async function runSshConfig(box, opts) {
16821
17157
  ``,
16822
17158
  `Codex: ${codexLink}`,
16823
17159
  ` ${codexUrl}`,
17160
+ ` (auto-open with: agentbox open ${box.name} --in codex)`,
16824
17161
  `Claude desktop: add an SSH connection to host "${conn.alias}" (already in ~/.ssh/config)`
16825
17162
  ];
16826
17163
  process.stdout.write(lines.join("\n") + "\n");
16827
17164
  }
16828
- var shellCommand = new Command52("shell").description(
17165
+ var shellCommand = new Command53("shell").description(
16829
17166
  "Open an interactive shell in a box, in a detachable tmux session (auto-unpause/start)"
16830
17167
  ).argument(
16831
17168
  "[box]",
@@ -16927,7 +17264,7 @@ var shellCommand = new Command52("shell").description(
16927
17264
  handleLifecycleError(err);
16928
17265
  }
16929
17266
  });
16930
- var shellAttachCommand = new Command52("attach").description(
17267
+ var shellAttachCommand = new Command53("attach").description(
16931
17268
  "Attach to a shell tmux session in a box, starting one if none is running (auto-unpause/start)"
16932
17269
  ).argument(
16933
17270
  "[box]",
@@ -16965,7 +17302,7 @@ function renderShellTable(sessions) {
16965
17302
  for (const r of rows) process.stdout.write(`${fmt(r)}
16966
17303
  `);
16967
17304
  }
16968
- var shellLsCommand = new Command52("ls").description("List the shell tmux sessions running in a box").argument(
17305
+ var shellLsCommand = new Command53("ls").description("List the shell tmux sessions running in a box").argument(
16969
17306
  "[box]",
16970
17307
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
16971
17308
  ).action(async (idOrName) => {
@@ -16988,7 +17325,7 @@ var shellLsCommand = new Command52("ls").description("List the shell tmux sessio
16988
17325
  handleLifecycleError(err);
16989
17326
  }
16990
17327
  });
16991
- var shellKillCommand = new Command52("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
17328
+ var shellKillCommand = new Command53("kill").description("Kill a shell tmux session in a box (the shell and anything running in it)").argument(
16992
17329
  "[box]",
16993
17330
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
16994
17331
  ).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) {
@@ -17026,8 +17363,8 @@ shellCommand.addCommand(shellLsCommand);
17026
17363
  shellCommand.addCommand(shellKillCommand);
17027
17364
 
17028
17365
  // src/commands/start.ts
17029
- import { Command as Command53 } from "commander";
17030
- var startCommand = new Command53("start").description(
17366
+ import { Command as Command54 } from "commander";
17367
+ var startCommand = new Command54("start").description(
17031
17368
  "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)."
17032
17369
  ).argument(
17033
17370
  "[box]",
@@ -17049,7 +17386,13 @@ var startCommand = new Command53("start").description(
17049
17386
  process.stdout.write(`started ${box.name}
17050
17387
  `);
17051
17388
  const cfg = await loadEffectiveConfig(record.workspacePath);
17052
- await autoWriteSshConfig(record, cfg.effective.ssh.autoConfig);
17389
+ await autoWriteSshConfig(
17390
+ record,
17391
+ provider,
17392
+ cfg.effective.ssh.autoConfig,
17393
+ (m) => process.stderr.write(`agentbox: ${m}
17394
+ `)
17395
+ );
17053
17396
  await restoreAgentSessions(record, provider, {
17054
17397
  onLog: (line) => process.stdout.write(`${line}
17055
17398
  `)
@@ -17062,7 +17405,7 @@ var startCommand = new Command53("start").description(
17062
17405
 
17063
17406
  // src/commands/status.ts
17064
17407
  import { log as log56 } from "@clack/prompts";
17065
- import { Command as Command54 } from "commander";
17408
+ import { Command as Command55 } from "commander";
17066
17409
 
17067
17410
  // src/endpoints-render.ts
17068
17411
  function renderEndpointLines(endpoints, stream) {
@@ -17340,18 +17683,52 @@ async function runInspect(box, opts) {
17340
17683
  }
17341
17684
 
17342
17685
  // src/commands/status.ts
17686
+ var MAX_DISPLAY_NAME = 60;
17343
17687
  var statusCommand2 = withWatchOptions(
17344
- new Command54("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
17688
+ new Command55("status").description("Show service + task status from a box's agentbox-ctl daemon").argument(
17345
17689
  "[box]",
17346
17690
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
17347
- ).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) plus service/task status")
17691
+ ).option("-j, --json", "machine-readable JSON output").option("--inspect", "show detailed box info (volumes, limits, paths) plus service/task status").option(
17692
+ "--set-name <name>",
17693
+ "rename the box: set a cosmetic display label (does not change the container, git branch, or URL)"
17694
+ ).option("--clear-name", "clear the box display label, falling back to the original name")
17348
17695
  ).action(async (idOrName, opts) => {
17349
17696
  try {
17350
17697
  if (opts.json && opts.watch) {
17351
17698
  log56.error("cannot combine --json with --watch");
17352
17699
  process.exit(2);
17353
17700
  }
17701
+ if (opts.setName !== void 0 && opts.clearName) {
17702
+ log56.error("cannot combine --set-name with --clear-name");
17703
+ process.exit(2);
17704
+ }
17354
17705
  const box = await resolveBoxOrExit(idOrName);
17706
+ if (opts.setName !== void 0 || opts.clearName) {
17707
+ if (opts.json || opts.watch) {
17708
+ log56.error("cannot combine --set-name/--clear-name with --json or --watch");
17709
+ process.exit(2);
17710
+ }
17711
+ const before = boxLabel(box);
17712
+ let next;
17713
+ if (opts.clearName) {
17714
+ next = void 0;
17715
+ } else {
17716
+ next = [...opts.setName].filter((c) => c >= " " && c.charCodeAt(0) !== 127).join("").trim();
17717
+ if (!next) {
17718
+ log56.error("--set-name requires a non-empty name (use --clear-name to reset)");
17719
+ process.exit(2);
17720
+ }
17721
+ if (next.length > MAX_DISPLAY_NAME) {
17722
+ log56.error(`name too long (max ${String(MAX_DISPLAY_NAME)} chars)`);
17723
+ process.exit(2);
17724
+ }
17725
+ }
17726
+ await setBoxDisplayName(box.id, next);
17727
+ const after = next ?? box.name;
17728
+ process.stdout.write(`renamed ${before} -> ${after}
17729
+ `);
17730
+ return;
17731
+ }
17355
17732
  if ((box.provider ?? "docker") !== "docker") {
17356
17733
  await runInspect(box, { json: opts.json, watch: opts.watch, interval: opts.interval });
17357
17734
  return;
@@ -17476,8 +17853,8 @@ function renderPersisted2(s, state) {
17476
17853
  }
17477
17854
 
17478
17855
  // src/commands/stop.ts
17479
- import { Command as Command55 } from "commander";
17480
- var stopCommand = new Command55("stop").description(
17856
+ import { Command as Command56 } from "commander";
17857
+ var stopCommand = new Command56("stop").description(
17481
17858
  "Stop a box (Docker: docker stop; preserves upper + node_modules volumes. Cloud: backend.stop \u2014 sandbox stays in your account, disk preserved)."
17482
17859
  ).argument(
17483
17860
  "[box]",
@@ -17506,7 +17883,7 @@ restart with: agentbox start ${box.name}
17506
17883
  });
17507
17884
 
17508
17885
  // src/commands/top.ts
17509
- import { Command as Command56 } from "commander";
17886
+ import { Command as Command57 } from "commander";
17510
17887
  var COLS = ["BOX", "STATE", "CPU%", "MEM USAGE / LIMIT", "MEM%", "PIDS", "DISK", "NET I/O"];
17511
17888
  function row(name, state, s) {
17512
17889
  const mem = `${fmtBytes2(s.memUsedBytes)} / ${fmtBytes2(s.memLimitBytes)}`;
@@ -17580,7 +17957,7 @@ async function renderProjectFooters() {
17580
17957
 
17581
17958
  SYSTEM: ${parts.join(" - ")}` : "";
17582
17959
  }
17583
- var topCommand = new Command56("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
17960
+ var topCommand = new Command57("top").description("Live resource monitor (cpu/mem/pids/disk) for a box, the project, or every box").argument(
17584
17961
  "[box]",
17585
17962
  "box ref (default: every box on the host; --project narrows to the cwd's project)"
17586
17963
  ).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) => {
@@ -17613,8 +17990,8 @@ var topCommand = new Command56("top").description("Live resource monitor (cpu/me
17613
17990
  });
17614
17991
 
17615
17992
  // src/commands/unpause.ts
17616
- import { Command as Command57 } from "commander";
17617
- var unpauseCommand = new Command57("unpause").description(
17993
+ import { Command as Command58 } from "commander";
17994
+ var unpauseCommand = new Command58("unpause").description(
17618
17995
  "Resume a paused box. Docker: `docker unpause` (sub-second). Cloud: backend.resume (re-hydrates from archive \u2014 slower first time)."
17619
17996
  ).argument(
17620
17997
  "[box]",
@@ -17632,7 +18009,13 @@ var unpauseCommand = new Command57("unpause").description(
17632
18009
  process.stdout.write(`unpaused ${box.name}
17633
18010
  `);
17634
18011
  const cfg = await loadEffectiveConfig(box.workspacePath);
17635
- await autoWriteSshConfig(box, cfg.effective.ssh.autoConfig);
18012
+ await autoWriteSshConfig(
18013
+ box,
18014
+ provider,
18015
+ cfg.effective.ssh.autoConfig,
18016
+ (m) => process.stderr.write(`agentbox: ${m}
18017
+ `)
18018
+ );
17636
18019
  await restoreAgentSessions(box, provider, {
17637
18020
  onLog: (line) => process.stdout.write(`${line}
17638
18021
  `)
@@ -17645,29 +18028,11 @@ var unpauseCommand = new Command57("unpause").description(
17645
18028
 
17646
18029
  // src/commands/update.ts
17647
18030
  import { spawn as spawn11 } from "child_process";
17648
- import { Command as Command58 } from "commander";
17649
-
17650
- // src/exec-method.ts
17651
- function detectExecutionMethod(input) {
17652
- const ua = input.userAgent ?? "";
17653
- const argv1 = input.argv1 ?? "";
17654
- if (argv1.includes("/_npx/") || argv1.includes("/.npm/_npx") || /\bnpx\//.test(ua)) {
17655
- return "npx";
17656
- }
17657
- if (/\bpnpm\//.test(ua)) {
17658
- return "pnpm";
17659
- }
17660
- if (/\bnpm\//.test(ua)) {
17661
- return "npm";
17662
- }
17663
- return "direct";
17664
- }
17665
-
17666
- // src/commands/update.ts
17667
- var PKG = "@madarco/agentbox";
18031
+ import { Command as Command59 } from "commander";
18032
+ var PKG2 = "@madarco/agentbox";
17668
18033
  function selfUpdateCommand(method) {
17669
- if (method === "npm") return { cmd: "npm", args: ["install", "-g", `${PKG}@latest`] };
17670
- if (method === "pnpm") return { cmd: "pnpm", args: ["add", "-g", `${PKG}@latest`] };
18034
+ if (method === "npm") return { cmd: "npm", args: ["install", "-g", `${PKG2}@latest`] };
18035
+ if (method === "pnpm") return { cmd: "pnpm", args: ["add", "-g", `${PKG2}@latest`] };
17671
18036
  return null;
17672
18037
  }
17673
18038
  function describeSelfUpdate(method) {
@@ -17689,15 +18054,31 @@ function runInherit(cmd, args) {
17689
18054
  child.on("close", (code) => resolveP(code ?? 0));
17690
18055
  });
17691
18056
  }
17692
- var updateCommand = new Command58("self-update").description(
17693
- "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"
17694
- ).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) => {
18057
+ async function reportLatest() {
18058
+ try {
18059
+ const res = await fetch(`https://registry.npmjs.org/${PKG2}/latest`, {
18060
+ signal: AbortSignal.timeout(3e3)
18061
+ });
18062
+ if (!res.ok) return;
18063
+ const body = await res.json();
18064
+ const latest = typeof body.version === "string" ? body.version : void 0;
18065
+ if (latest === void 0) return;
18066
+ prompt_exports.log.info(
18067
+ isNewer(latest, AGENTBOX_VERSION) ? `current ${AGENTBOX_VERSION} \u2192 latest ${latest}` : `already the latest (${AGENTBOX_VERSION}) \u2014 refreshing skills/image/relay/app anyway`
18068
+ );
18069
+ } catch {
18070
+ }
18071
+ }
18072
+ var updateCommand = new Command59("self-update").description(
18073
+ "Update agentbox: self-update via npm/pnpm (unless run via npx), refresh the host skills, wipe the box image so it rebuilds, reload the relay, and update the menu-bar app"
18074
+ ).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 + app").option("--skip-skills", "skip refreshing the host skill files in ~/.claude, ~/.codex, ~/.config/opencode").action(async (opts) => {
17695
18075
  try {
17696
18076
  const method = detectExecutionMethod({
17697
18077
  userAgent: process.env.npm_config_user_agent,
17698
18078
  argv1: process.argv[1]
17699
18079
  });
17700
18080
  (0, prompt_exports.intro)("agentbox self-update");
18081
+ await reportLatest();
17701
18082
  const selfStep = opts.skipSelf ? "self-update: skipped (--skip-self)" : describeSelfUpdate(method);
17702
18083
  const skillsStep = opts.skipSkills ? "skills: skipped (--skip-skills)" : "skills: refresh agentbox-managed host skill files in ~/.claude (and Codex/OpenCode)";
17703
18084
  prompt_exports.log.info(
@@ -17706,7 +18087,8 @@ var updateCommand = new Command58("self-update").description(
17706
18087
  ` ${selfStep}`,
17707
18088
  ` ${skillsStep}`,
17708
18089
  ` image: docker image rm -f ${DEFAULT_BOX_IMAGE} (rebuilds on next create/claude)`,
17709
- " relay: stop, then respawn unless a self-update ran"
18090
+ " relay: stop, then respawn",
18091
+ " app: update the menu-bar app if the published build changed (macOS, when installed)"
17710
18092
  ].join("\n")
17711
18093
  );
17712
18094
  if (opts.dryRun) {
@@ -17734,67 +18116,19 @@ var updateCommand = new Command58("self-update").description(
17734
18116
  throw new Error(`${cmd.cmd} exited with code ${String(code)}`);
17735
18117
  }
17736
18118
  selfUpdated = true;
17737
- prompt_exports.log.success(`updated ${PKG} via ${cmd.cmd}`);
18119
+ prompt_exports.log.success(`updated ${PKG2} via ${cmd.cmd}`);
17738
18120
  }
17739
18121
  }
17740
- if (opts.skipSkills) {
17741
- prompt_exports.log.info("skipping skills refresh (--skip-skills)");
17742
- } else if (selfUpdated) {
17743
- const code = await runInherit("agentbox", ["install", "--skills-only"]);
17744
- if (code === 0) {
17745
- prompt_exports.log.success("refreshed host skills (via updated build)");
17746
- } else {
17747
- prompt_exports.log.warn(
17748
- `host skills not refreshed (agentbox install --skills-only exited ${String(code)}) \u2014 run it manually to pick up the new versions`
17749
- );
17750
- }
17751
- } else {
17752
- try {
17753
- const res = installHostSkills({ quiet: true });
17754
- if (res.written.length > 0) {
17755
- prompt_exports.log.success(`refreshed host skills (${String(res.written.length)} file(s))`);
17756
- } else {
17757
- prompt_exports.log.info(`host skills already current (${String(res.skipped)} skipped)`);
17758
- }
17759
- if (res.blocked.length > 0) {
17760
- prompt_exports.log.warn(
17761
- `user-modified skill file(s) left in place: ${res.blocked.join(", ")} \u2014 run \`agentbox install --skills-only --force\` to overwrite`
17762
- );
17763
- }
17764
- } catch (err) {
17765
- prompt_exports.log.warn(
17766
- `host skills not refreshed (${err instanceof Error ? err.message : String(err)})`
17767
- );
17768
- }
17769
- }
17770
- const s = (0, prompt_exports.spinner)();
17771
- s.start(`removing image ${DEFAULT_BOX_IMAGE}`);
17772
- const removed = await removeImage(DEFAULT_BOX_IMAGE);
17773
- s.stop(
17774
- removed ? `removed image ${DEFAULT_BOX_IMAGE} (rebuilds on next create/claude)` : `image ${DEFAULT_BOX_IMAGE} not present (nothing to remove)`
17775
- );
17776
- const sr = (0, prompt_exports.spinner)();
17777
- sr.start("stopping relay");
17778
- const stop = await stopRelay();
17779
- sr.stop(
17780
- stop.stopped ? `stopped relay (pid ${String(stop.pid)})` : "relay was not running"
17781
- );
17782
18122
  if (selfUpdated) {
17783
- prompt_exports.log.info(
17784
- "relay will restart automatically (with the updated build) on your next `agentbox create` / `agentbox claude`"
17785
- );
17786
- } else {
17787
- const sr2 = (0, prompt_exports.spinner)();
17788
- sr2.start("restarting relay");
17789
- try {
17790
- const ep = await ensureRelay();
17791
- sr2.stop(`relay back up on ${ep.hostUrl}`);
17792
- } catch (err) {
17793
- sr2.stop("relay restart failed");
18123
+ const args = ["_post-update-refresh", ...opts.skipSkills ? ["--skip-skills"] : []];
18124
+ const code = await runInherit("agentbox", args);
18125
+ if (code !== 0) {
17794
18126
  prompt_exports.log.warn(
17795
- `${err instanceof Error ? err.message : String(err)} \u2014 it will retry on the next box command`
18127
+ `post-update refresh exited ${String(code)} \u2014 run \`agentbox self-update --skip-self\` to retry`
17796
18128
  );
17797
18129
  }
18130
+ } else {
18131
+ await runPostUpdateRefresh({ skipSkills: opts.skipSkills });
17798
18132
  }
17799
18133
  await maybePromptStar({ trigger: "self-update" });
17800
18134
  (0, prompt_exports.outro)("update complete");
@@ -17806,7 +18140,7 @@ var updateCommand = new Command58("self-update").description(
17806
18140
  // src/commands/url.ts
17807
18141
  import { spawnSync as spawnSync9 } from "child_process";
17808
18142
  import { log as log58 } from "@clack/prompts";
17809
- import { Command as Command59 } from "commander";
18143
+ import { Command as Command60 } from "commander";
17810
18144
  var SIGNED_URL_TTL_MIN2 = 1;
17811
18145
  var SIGNED_URL_TTL_MAX2 = 86400;
17812
18146
  function parseTtlOrExit2(raw) {
@@ -17819,7 +18153,7 @@ function parseTtlOrExit2(raw) {
17819
18153
  }
17820
18154
  return n;
17821
18155
  }
17822
- var urlCommand = new Command59("url").description(
18156
+ var urlCommand = new Command60("url").description(
17823
18157
  "Open a box's web app URL in the browser, even when no service declares `expose:` (auto-unpause/start)"
17824
18158
  ).argument(
17825
18159
  "[box]",
@@ -17898,8 +18232,8 @@ var urlCommand = new Command59("url").description(
17898
18232
 
17899
18233
  // src/commands/wait.ts
17900
18234
  import { log as log59 } from "@clack/prompts";
17901
- import { Command as Command60 } from "commander";
17902
- var waitCommand = new Command60("wait").description("Block until the box reports all autostart units ready").argument(
18235
+ import { Command as Command61 } from "commander";
18236
+ var waitCommand = new Command61("wait").description("Block until the box reports all autostart units ready").argument(
17903
18237
  "[box]",
17904
18238
  "box ref: project index, id, id prefix, name, or container (default: the only box in this project)"
17905
18239
  ).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) => {
@@ -17966,7 +18300,7 @@ process.env.AGENTBOX_CLI_COMMIT = AGENTBOX_COMMIT;
17966
18300
  }
17967
18301
  }
17968
18302
  }
17969
- var program = new Command61();
18303
+ var program = new Command62();
17970
18304
  program.name("agentbox").description("Launch coding agents in isolated sandboxes").version(AGENTBOX_VERSION);
17971
18305
  program.enablePositionalOptions();
17972
18306
  program.addCommand(createCommand);
@@ -18009,6 +18343,7 @@ program.addCommand(controlPlaneCommand, { hidden: true });
18009
18343
  program.addCommand(runQueuedJobCommand, { hidden: true });
18010
18344
  program.addCommand(runQueuedPrepareCommand, { hidden: true });
18011
18345
  program.addCommand(claudeLoginWorkerCommand, { hidden: true });
18346
+ program.addCommand(postUpdateRefreshCommand, { hidden: true });
18012
18347
  program.addCommand(herdrCommand, { hidden: true });
18013
18348
  program.addCommand(daytonaCommand);
18014
18349
  program.addCommand(hetznerCommand);
@@ -18034,6 +18369,7 @@ var FIRST_RUN_EXEMPT = /* @__PURE__ */ new Set([
18034
18369
  "_run-queued-job",
18035
18370
  "_run-queued-prepare",
18036
18371
  "_claude-login-worker",
18372
+ "_post-update-refresh",
18037
18373
  "drive",
18038
18374
  "screen"
18039
18375
  ]);
@@ -18059,8 +18395,53 @@ if (isFirstRun() && isFirstRunHookEligible(argv)) {
18059
18395
  );
18060
18396
  }
18061
18397
  }
18062
- program.parseAsync(argv).catch((err) => {
18063
- printCliError(err, process.stderr);
18064
- process.exit(1);
18065
- });
18398
+ var versionPromptShown = false;
18399
+ if (AGENTBOX_VERSION !== "0.0.0-dev") {
18400
+ const state = readUpdateState();
18401
+ if (state.lastRunVersion === void 0) {
18402
+ writeUpdateState({ lastRunVersion: AGENTBOX_VERSION });
18403
+ } else if (state.lastRunVersion !== AGENTBOX_VERSION && isFirstRunHookEligible(argv) && argv[2] !== "self-update") {
18404
+ versionPromptShown = true;
18405
+ try {
18406
+ const yes = await confirm({
18407
+ message: `agentbox was updated (${state.lastRunVersion} \u2192 ${AGENTBOX_VERSION}) \u2014 refresh skills, box image, relay, and the menu-bar app now?`,
18408
+ initialValue: true
18409
+ });
18410
+ if (yes) {
18411
+ await runPostUpdateRefresh();
18412
+ } else {
18413
+ writeUpdateState({ lastRunVersion: AGENTBOX_VERSION });
18414
+ }
18415
+ } catch (err) {
18416
+ process.stderr.write(
18417
+ `post-update refresh failed: ${err instanceof Error ? err.message : String(err)}
18418
+ `
18419
+ );
18420
+ }
18421
+ }
18422
+ }
18423
+ if (isFirstRunHookEligible(argv)) {
18424
+ maybeStartRemoteCheck();
18425
+ }
18426
+ program.parseAsync(argv).then(
18427
+ async () => {
18428
+ if (versionPromptShown || !isFirstRunHookEligible(argv)) return;
18429
+ const msg = nudgeMessage(
18430
+ readUpdateState(),
18431
+ detectExecutionMethod({
18432
+ userAgent: process.env.npm_config_user_agent,
18433
+ argv1: process.argv[1]
18434
+ })
18435
+ );
18436
+ if (msg !== null && await updateCheckEnabled()) {
18437
+ process.stderr.write(`
18438
+ ${msg}
18439
+ `);
18440
+ }
18441
+ },
18442
+ (err) => {
18443
+ printCliError(err, process.stderr);
18444
+ process.exit(1);
18445
+ }
18446
+ );
18066
18447
  //# sourceMappingURL=index.js.map