@madarco/agentbox 0.25.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +8 -7
  3. package/dist/{_cloud-attach-FGMI2ZHO.js → _cloud-attach-7WRQH6XZ.js} +5 -5
  4. package/dist/{chunk-5VNL6SHJ.js → chunk-7ZZAZPYX.js} +3 -3
  5. package/dist/{chunk-ZTSVY3YL.js → chunk-BA2VLJVU.js} +3 -3
  6. package/dist/{chunk-3BR63LCB.js → chunk-DJQMK4RN.js} +12 -4
  7. package/dist/chunk-DJQMK4RN.js.map +1 -0
  8. package/dist/{chunk-6GZK74GT.js → chunk-DQHMDDAT.js} +2 -2
  9. package/dist/{chunk-P5U6AP6K.js → chunk-I2OAJS3L.js} +40 -377
  10. package/dist/{chunk-P5U6AP6K.js.map → chunk-I2OAJS3L.js.map} +1 -1
  11. package/dist/{chunk-5F5SOSDY.js → chunk-JGZSA5ZI.js} +72 -23
  12. package/dist/chunk-JGZSA5ZI.js.map +1 -0
  13. package/dist/{chunk-67VF2QZC.js → chunk-K5KOLYIL.js} +3 -3
  14. package/dist/{chunk-4LS2TOF3.js → chunk-PK2QF4IR.js} +569 -195
  15. package/dist/chunk-PK2QF4IR.js.map +1 -0
  16. package/dist/{chunk-3PSRBK24.js → chunk-UIFL7F2G.js} +54 -37
  17. package/dist/chunk-UIFL7F2G.js.map +1 -0
  18. package/dist/{chunk-4DBLYT2F.js → chunk-ZY7M7MXH.js} +41 -16
  19. package/dist/chunk-ZY7M7MXH.js.map +1 -0
  20. package/dist/chunk-ZYKNSHOH.js +259 -0
  21. package/dist/chunk-ZYKNSHOH.js.map +1 -0
  22. package/dist/{dist-X7R2EMJL.js → dist-5IICYSR6.js} +42 -374
  23. package/dist/{dist-X7R2EMJL.js.map → dist-5IICYSR6.js.map} +1 -1
  24. package/dist/{dist-5G42NFOG.js → dist-AR5CHRSV.js} +86 -45
  25. package/dist/{dist-5G42NFOG.js.map → dist-AR5CHRSV.js.map} +1 -1
  26. package/dist/{dist-AZUD2LUA.js → dist-DTNYMBQ5.js} +12 -12
  27. package/dist/{dist-MEK44IS5.js → dist-K4LNH3EC.js} +6 -6
  28. package/dist/{dist-SN6ABGMD.js → dist-POVRY7HO.js} +8 -4
  29. package/dist/{dist-SBDYDH7H.js → dist-U2SVLJUQ.js} +4 -2
  30. package/dist/{dist-4I7XHDC3.js → dist-XYY6SIKG.js} +6 -6
  31. package/dist/dist-YA7EXBGG.js +809 -0
  32. package/dist/dist-YA7EXBGG.js.map +1 -0
  33. package/dist/index.js +962 -583
  34. package/dist/index.js.map +1 -1
  35. package/dist/{prepared-state-75DIZ55S-5UAKJX3L.js → prepared-state-75DIZ55S-W6NU3S3B.js} +2 -2
  36. package/package.json +5 -4
  37. package/runtime/_shared/ctl.cjs +83 -36
  38. package/runtime/digitalocean/ctl.cjs +83 -36
  39. package/runtime/docker/packages/ctl/dist/bin.cjs +83 -36
  40. package/runtime/e2b/ctl.cjs +83 -36
  41. package/runtime/hetzner/ctl.cjs +83 -36
  42. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  43. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  44. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js +1 -1
  45. package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +1 -1
  46. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  47. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  48. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  49. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  50. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  51. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  52. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  53. package/runtime/hub/apps/hub/.next/server/chunks/0-fj_better-auth_dist_adapters_kysely-adapter_index_mjs_0btft52._.js +3 -0
  54. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +5 -5
  55. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  56. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-9g0ae._.js +1 -1
  57. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
  58. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__19pc87s._.js → [root-of-the-server]__1k8g143._.js} +2 -2
  59. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
  60. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +4 -4
  61. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +1 -1
  62. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +1 -1
  63. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +1 -1
  64. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +1 -1
  65. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +1 -1
  66. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +1 -1
  67. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +1 -1
  68. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +1 -1
  69. package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +1 -1
  70. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +1 -1
  71. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +1 -1
  72. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +1 -1
  73. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +1 -1
  74. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +1 -1
  75. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +1 -1
  76. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +1 -1
  77. package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +1 -1
  78. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  79. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  80. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  81. package/runtime/hub/apps/hub/{auth-MVL4NCQC.js → auth-DC44GQZY.js} +2 -2
  82. package/runtime/hub/apps/hub/{auth-config-GRIXACTV.js → auth-config-LALRDYDO.js} +2 -2
  83. package/runtime/hub/apps/hub/{chunk-JLG5JJXD.js → chunk-3FJNKSNZ.js} +1 -1
  84. package/runtime/hub/apps/hub/{chunk-RSENJ2FT.js → chunk-4QY2VZCF.js} +502 -132
  85. package/runtime/hub/apps/hub/{chunk-23AU7VYS.js → chunk-BARD2DI6.js} +11 -3
  86. package/runtime/hub/apps/hub/{chunk-V3OMPMI3.js → chunk-QSMPSV5Z.js} +70 -21
  87. package/runtime/hub/apps/hub/{chunk-GARA7RQW.js → chunk-XZZXPEVV.js} +57 -36
  88. package/runtime/hub/apps/hub/{dist-WZKTIA2R.js → dist-3ENKQN5G.js} +35 -365
  89. package/runtime/hub/apps/hub/{dist-TP4SXMDY.js → dist-6VGJOQYK.js} +84 -43
  90. package/runtime/hub/apps/hub/{dist-JVU3QCLG.js → dist-AE6IV4FV.js} +4 -4
  91. package/runtime/hub/apps/hub/{dist-IZ2JCN5R.js → dist-EQV4L7KP.js} +3 -1
  92. package/runtime/hub/apps/hub/dist-NNBELNA7.js +1017 -0
  93. package/runtime/hub/apps/hub/{dist-DZGSA3US.js → dist-RJJ2SDYO.js} +4 -4
  94. package/runtime/hub/apps/hub/{dist-VWSHZIPN.js → dist-TU7D6UTB.js} +37 -366
  95. package/runtime/hub/apps/hub/{dist-YWY2DSSL.js → dist-WAZKGVYL.js} +7 -3
  96. package/runtime/hub/apps/hub/{hub-token-BJG6Q5II.js → hub-token-COBZGSLS.js} +2 -2
  97. package/runtime/hub/apps/hub/package.json +1 -0
  98. package/runtime/hub/apps/hub/{prepared-state-75DIZ55S-JDILR4OP.js → prepared-state-75DIZ55S-NYEDSU2U.js} +1 -1
  99. package/runtime/hub/apps/hub/server.js +20 -16
  100. package/runtime/relay/bin.cjs +57 -20
  101. package/runtime/vercel/ctl.cjs +83 -36
  102. package/dist/chunk-3BR63LCB.js.map +0 -1
  103. package/dist/chunk-3PSRBK24.js.map +0 -1
  104. package/dist/chunk-4DBLYT2F.js.map +0 -1
  105. package/dist/chunk-4LS2TOF3.js.map +0 -1
  106. package/dist/chunk-5F5SOSDY.js.map +0 -1
  107. package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +0 -3
  108. /package/dist/{_cloud-attach-FGMI2ZHO.js.map → _cloud-attach-7WRQH6XZ.js.map} +0 -0
  109. /package/dist/{chunk-5VNL6SHJ.js.map → chunk-7ZZAZPYX.js.map} +0 -0
  110. /package/dist/{chunk-ZTSVY3YL.js.map → chunk-BA2VLJVU.js.map} +0 -0
  111. /package/dist/{chunk-6GZK74GT.js.map → chunk-DQHMDDAT.js.map} +0 -0
  112. /package/dist/{chunk-67VF2QZC.js.map → chunk-K5KOLYIL.js.map} +0 -0
  113. /package/dist/{dist-4I7XHDC3.js.map → dist-DTNYMBQ5.js.map} +0 -0
  114. /package/dist/{dist-MEK44IS5.js.map → dist-K4LNH3EC.js.map} +0 -0
  115. /package/dist/{dist-AZUD2LUA.js.map → dist-POVRY7HO.js.map} +0 -0
  116. /package/dist/{dist-SBDYDH7H.js.map → dist-U2SVLJUQ.js.map} +0 -0
  117. /package/dist/{dist-SN6ABGMD.js.map → dist-XYY6SIKG.js.map} +0 -0
  118. /package/dist/{prepared-state-75DIZ55S-5UAKJX3L.js.map → prepared-state-75DIZ55S-W6NU3S3B.js.map} +0 -0
  119. /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mrhWWwzD3oh05le9SRnlA}/_buildManifest.js +0 -0
  120. /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mrhWWwzD3oh05le9SRnlA}/_clientMiddlewareManifest.js +0 -0
  121. /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mrhWWwzD3oh05le9SRnlA}/_ssgManifest.js +0 -0
@@ -312,43 +312,48 @@ import { homedir as homedir22 } from "os";
312
312
  import { dirname as dirname22, join as join3 } from "path";
313
313
  import { mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
314
314
  import { join as join5, resolve as resolve3 } from "path";
315
- import { chmodSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
315
+ import { existsSync as existsSync2 } from "fs";
316
+ import { mkdir as mkdir3, rm as rm2 } from "fs/promises";
317
+ import { createServer } from "net";
316
318
  import { homedir as homedir4 } from "os";
317
- import { dirname as dirname4, resolve as resolve22 } from "path";
318
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
319
+ import { join as join6, resolve as resolve22 } from "path";
320
+ import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
319
321
  import { homedir as homedir5 } from "os";
320
- import { dirname as dirname5, join as join6 } from "path";
322
+ import { dirname as dirname4, resolve as resolve32 } from "path";
323
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
324
+ import { homedir as homedir6 } from "os";
325
+ import { dirname as dirname5, join as join7 } from "path";
321
326
  import { mkdtemp, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
322
327
  import { tmpdir } from "os";
323
- import { basename as basename2, join as join7 } from "path";
324
- import { join as join8 } from "path";
325
- import { chmod, mkdir as mkdir4, readdir as readdir2, readFile as readFile5, stat as stat4, writeFile as writeFile4 } from "fs/promises";
326
- import { homedir as homedir6 } from "os";
327
- import { dirname as dirname6, join as join9 } from "path";
328
+ import { basename as basename2, join as join8 } from "path";
329
+ import { join as join9 } from "path";
330
+ import { chmod, mkdir as mkdir5, readdir as readdir2, readFile as readFile5, stat as stat4, writeFile as writeFile4 } from "fs/promises";
328
331
  import { homedir as homedir7 } from "os";
329
- import { mkdtemp as mkdtemp3, rm as rm4 } from "fs/promises";
330
- import { tmpdir as tmpdir3 } from "os";
331
- import { join as join11 } from "path";
332
- import { readdir as readdir3, stat as stat5 } from "fs/promises";
332
+ import { dirname as dirname6, join as join10 } from "path";
333
333
  import { homedir as homedir8 } from "os";
334
+ import { mkdtemp as mkdtemp3, rm as rm5 } from "fs/promises";
335
+ import { tmpdir as tmpdir3 } from "os";
334
336
  import { join as join12 } from "path";
337
+ import { readdir as readdir3, stat as stat5 } from "fs/promises";
338
+ import { homedir as homedir9 } from "os";
339
+ import { join as join13 } from "path";
335
340
  import { readdir as readdir4, realpath as realpath2, stat as stat6 } from "fs/promises";
336
- import { isAbsolute as isAbsolute3, join as join13, relative } from "path";
341
+ import { isAbsolute as isAbsolute3, join as join14, relative } from "path";
337
342
  import { stat as stat7 } from "fs/promises";
338
- import { chmod as chmod2, mkdir as mkdir6, mkdtemp as mkdtemp4, readFile as readFile6, rename as rename3, rm as rm5, writeFile as writeFile6 } from "fs/promises";
343
+ import { chmod as chmod2, mkdir as mkdir7, mkdtemp as mkdtemp4, readFile as readFile6, rename as rename3, rm as rm6, writeFile as writeFile6 } from "fs/promises";
339
344
  import { tmpdir as tmpdir4 } from "os";
340
- import { dirname as dirname8, join as join14 } from "path";
345
+ import { dirname as dirname8, join as join15 } from "path";
341
346
  import { createHash } from "crypto";
342
347
  import { readFile as readFile7 } from "fs/promises";
343
- import { join as join15 } from "path";
348
+ import { join as join16 } from "path";
344
349
  import { createHash as createHash2 } from "crypto";
345
- import { copyFile, mkdir as mkdir7, mkdtemp as mkdtemp5, readdir as readdir5, readFile as readFile8, rm as rm6, stat as stat8 } from "fs/promises";
346
- import { homedir as homedir9, tmpdir as tmpdir5 } from "os";
347
- import { basename as basename22, dirname as dirname9, join as join16 } from "path";
348
- import { copyFile as copyFile2, mkdtemp as mkdtemp6, readdir as readdir6, readFile as readFile9, rm as rm7, stat as stat9, writeFile as writeFile7 } from "fs/promises";
349
- import { homedir as homedir11, tmpdir as tmpdir6 } from "os";
350
- import { basename as basename3, join as join17, relative as relative2 } from "path";
351
- import { homedir as homedir10 } from "os";
350
+ import { copyFile, mkdir as mkdir8, mkdtemp as mkdtemp5, readdir as readdir5, readFile as readFile8, rm as rm7, stat as stat8 } from "fs/promises";
351
+ import { homedir as homedir10, tmpdir as tmpdir5 } from "os";
352
+ import { basename as basename22, dirname as dirname9, join as join17 } from "path";
353
+ import { copyFile as copyFile2, mkdtemp as mkdtemp6, readdir as readdir6, readFile as readFile9, rm as rm8, stat as stat9, writeFile as writeFile7 } from "fs/promises";
354
+ import { homedir as homedir12, tmpdir as tmpdir6 } from "os";
355
+ import { basename as basename3, join as join18, relative as relative2 } from "path";
356
+ import { homedir as homedir11 } from "os";
352
357
 
353
358
  // ../../node_modules/.pnpm/smol-toml@1.7.0/node_modules/smol-toml/dist/date.js
354
359
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
@@ -1173,9 +1178,9 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
1173
1178
 
1174
1179
  // ../../packages/sandbox-core/dist/index.js
1175
1180
  import { createHash as createHash3 } from "crypto";
1176
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
1181
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
1177
1182
  import { readFile as readFile10 } from "fs/promises";
1178
- import { homedir as homedir12 } from "os";
1183
+ import { homedir as homedir13 } from "os";
1179
1184
  import { dirname as dirname10, resolve as pathResolve } from "path";
1180
1185
  var STATE_DIR = join2(homedir2(), ".agentbox");
1181
1186
  var STATE_FILE = join2(STATE_DIR, "state.json");
@@ -1525,6 +1530,9 @@ function buildBlock(opts) {
1525
1530
  if (opts.port) {
1526
1531
  lines.push(` Port ${String(opts.port)}`);
1527
1532
  }
1533
+ if (opts.proxyJump) {
1534
+ lines.push(` ProxyJump ${opts.proxyJump}`);
1535
+ }
1528
1536
  if (opts.identityFile) {
1529
1537
  lines.push(` IdentityFile ${opts.identityFile}`);
1530
1538
  lines.push(` IdentitiesOnly yes`);
@@ -1573,7 +1581,8 @@ async function syncAgentboxSshConfig(statePath = stateFilePath()) {
1573
1581
  hostname: ssh.host,
1574
1582
  user: ssh.user,
1575
1583
  identityFile: ssh.identityFile,
1576
- port: ssh.port
1584
+ port: ssh.port,
1585
+ proxyJump: ssh.proxyJump
1577
1586
  })
1578
1587
  );
1579
1588
  }
@@ -1624,23 +1633,41 @@ async function resolveCloudSshTarget(box, provider, opts = {}) {
1624
1633
  throw new Error(`cloud sandbox for ${box.name} is missing; was it deleted?`);
1625
1634
  }
1626
1635
  }
1636
+ const alias = agentboxAliasFor(box.name);
1637
+ if (provider.sshTarget) {
1638
+ const t = await provider.sshTarget(box);
1639
+ if (!t) {
1640
+ throw new Error(`no SSH target for ${box.name} (its sshd did not come up)`);
1641
+ }
1642
+ return {
1643
+ alias,
1644
+ host: t.host,
1645
+ user: t.user,
1646
+ identityFile: t.identityFile,
1647
+ port: t.port,
1648
+ proxyJump: t.proxyJump
1649
+ };
1650
+ }
1627
1651
  const spec = await provider.buildAttach(box, "shell", { noTmux: true });
1628
1652
  const target = parseSshTarget(spec.argv);
1629
1653
  if (!target) {
1630
1654
  throw new Error(`could not parse <user>@<host> from cloud SSH argv: ${spec.argv.join(" ")}`);
1631
1655
  }
1632
- const alias = agentboxAliasFor(box.name);
1633
1656
  return { alias, host: target.host, user: target.user, identityFile: target.identityFile };
1634
1657
  }
1658
+ var PROVIDERS_WITH_DIRECT_BOX_SSH = ["hetzner", "digitalocean", "daytona"];
1635
1659
  async function autoWriteSshConfig(box, provider, enabled, logWarn) {
1636
1660
  if (!enabled) return;
1661
+ if (!provider.sshTarget && !PROVIDERS_WITH_DIRECT_BOX_SSH.includes(provider.name)) return;
1637
1662
  try {
1638
1663
  const conn = await resolveCloudSshTarget(box, provider, { bringOnline: false });
1639
1664
  if (!conn.identityFile) return;
1640
1665
  await recordBoxSsh(box.id, {
1641
1666
  host: conn.host,
1642
1667
  user: conn.user,
1643
- identityFile: conn.identityFile
1668
+ identityFile: conn.identityFile,
1669
+ port: conn.port,
1670
+ proxyJump: conn.proxyJump
1644
1671
  });
1645
1672
  await syncAgentboxSshConfig();
1646
1673
  } catch (err) {
@@ -1664,6 +1691,341 @@ async function mintSshKey(targetDir, comment) {
1664
1691
  const publicKey = (await readFile2(pub, "utf8")).trim();
1665
1692
  return { dir, privatePath: priv, publicPath: pub, publicKey };
1666
1693
  }
1694
+ function sshDestination(target) {
1695
+ return target.user ? `${target.user}@${target.host}` : target.host;
1696
+ }
1697
+ function sshOptArgs(target) {
1698
+ const out = [];
1699
+ if (target.identity) {
1700
+ out.push("-i", target.identity);
1701
+ }
1702
+ if (target.knownHosts) {
1703
+ out.push(
1704
+ "-o",
1705
+ "StrictHostKeyChecking=accept-new",
1706
+ "-o",
1707
+ `UserKnownHostsFile=${target.knownHosts}`,
1708
+ "-o",
1709
+ "GlobalKnownHostsFile=/dev/null"
1710
+ );
1711
+ }
1712
+ out.push(
1713
+ "-o",
1714
+ "BatchMode=yes",
1715
+ "-o",
1716
+ "LogLevel=ERROR",
1717
+ // Detect a dead/stalled peer and drop the connection instead of hanging
1718
+ // forever. If the host's IP flaps mid-command (roaming Wi-Fi, VPN toggle)
1719
+ // the return traffic is silently dropped and the ssh channel would
1720
+ // otherwise block with no EOF — seen as an `exec` that never returns.
1721
+ // 15s * 4 = a ~60s fail-fast so callers (retry wrappers, cleanup) can react.
1722
+ "-o",
1723
+ "ServerAliveInterval=15",
1724
+ "-o",
1725
+ "ServerAliveCountMax=4"
1726
+ );
1727
+ if (target.port !== void 0) {
1728
+ out.push("-o", `Port=${String(target.port)}`);
1729
+ }
1730
+ if (target.controlPath) {
1731
+ out.push("-o", `ControlPath=${target.controlPath}`);
1732
+ }
1733
+ for (const [k, v] of Object.entries(target.options ?? {})) {
1734
+ out.push("-o", `${k}=${v}`);
1735
+ }
1736
+ return out;
1737
+ }
1738
+ async function sshExec(target, remoteCmd, opts = {}) {
1739
+ const argv = [...sshOptArgs(target), sshDestination(target), remoteCmd];
1740
+ const child = execa("ssh", argv, {
1741
+ reject: false,
1742
+ timeout: opts.timeoutMs,
1743
+ env: { ...process.env, ...opts.env },
1744
+ stdio: ["ignore", "pipe", "pipe"]
1745
+ });
1746
+ if (opts.onLine) {
1747
+ const handle = (chunk) => {
1748
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
1749
+ for (const line of text.split(/\r?\n/)) {
1750
+ if (line.length > 0) opts.onLine?.(line);
1751
+ }
1752
+ };
1753
+ child.stdout?.on("data", handle);
1754
+ child.stderr?.on("data", handle);
1755
+ }
1756
+ const res = await child;
1757
+ return {
1758
+ exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
1759
+ stdout: typeof res.stdout === "string" ? res.stdout : "",
1760
+ stderr: typeof res.stderr === "string" ? res.stderr : ""
1761
+ };
1762
+ }
1763
+ async function scpUpload(target, localPath, remotePath, opts = {}) {
1764
+ const argv = [...sshOptArgs(target), localPath, `${sshDestination(target)}:${remotePath}`];
1765
+ const res = await execa("scp", argv, { reject: false, timeout: opts.timeoutMs });
1766
+ if (res.exitCode !== 0) {
1767
+ throw new Error(
1768
+ `scp upload failed (exit ${String(res.exitCode)}): ${localPath} \u2192 ${remotePath}
1769
+ ${res.stderr ?? ""}`
1770
+ );
1771
+ }
1772
+ }
1773
+ async function scpDownload(target, remotePath, localPath, opts = {}) {
1774
+ const argv = [...sshOptArgs(target), `${sshDestination(target)}:${remotePath}`, localPath];
1775
+ const res = await execa("scp", argv, { reject: false, timeout: opts.timeoutMs });
1776
+ if (res.exitCode !== 0) {
1777
+ throw new Error(
1778
+ `scp download failed (exit ${String(res.exitCode)}): ${remotePath} \u2192 ${localPath}
1779
+ ${res.stderr ?? ""}`
1780
+ );
1781
+ }
1782
+ }
1783
+ async function waitForSsh(target, deadlineMs, intervalMs = 5e3) {
1784
+ const stop = Date.now() + deadlineMs;
1785
+ while (Date.now() < stop) {
1786
+ const res = await sshExec(
1787
+ { ...target, options: { ...target.options, ConnectTimeout: "5" } },
1788
+ "true",
1789
+ { timeoutMs: 1e4 }
1790
+ );
1791
+ if (res.exitCode === 0) return true;
1792
+ await new Promise((r) => setTimeout(r, intervalMs));
1793
+ }
1794
+ return false;
1795
+ }
1796
+ var HOST = "127.0.0.1";
1797
+ var SshTunnelManager = class {
1798
+ /**
1799
+ * `namespace` scopes the on-disk ssh dir so sandbox-ids from different
1800
+ * providers can't collide (a droplet id and a server id are both integers).
1801
+ */
1802
+ constructor(namespace) {
1803
+ this.namespace = namespace;
1804
+ }
1805
+ namespace;
1806
+ boxes = /* @__PURE__ */ new Map();
1807
+ /**
1808
+ * Open the ControlMaster for `boxId`. Idempotent: if a master is already up
1809
+ * for this box (socket exists + responsive), no-op. Otherwise spawn a fresh
1810
+ * `ssh -fNT -M` and wait for the socket to appear.
1811
+ */
1812
+ async open(opts) {
1813
+ const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId, this.namespace);
1814
+ await mkdir3(boxSshDir, { recursive: true, mode: 448 });
1815
+ const controlPath = join6(boxSshDir, "control.sock");
1816
+ const knownHosts = join6(boxSshDir, "known_hosts");
1817
+ const tunnel = {
1818
+ controlPath,
1819
+ vpsHost: opts.vpsHost,
1820
+ vpsUser: opts.vpsUser,
1821
+ identity: opts.identity,
1822
+ port: opts.port,
1823
+ boxSshDir,
1824
+ forwards: /* @__PURE__ */ new Map()
1825
+ };
1826
+ if (existsSync2(controlPath) && await this.isAlive(controlPath)) {
1827
+ this.boxes.set(opts.boxId, tunnel);
1828
+ return;
1829
+ }
1830
+ if (existsSync2(controlPath)) {
1831
+ await rm2(controlPath, { force: true });
1832
+ }
1833
+ const connectTimeout = opts.connectTimeoutSeconds ?? 10;
1834
+ const argv = ["-fNT", "-M", "-S", controlPath];
1835
+ if (opts.identity) {
1836
+ argv.push(
1837
+ "-i",
1838
+ opts.identity,
1839
+ "-o",
1840
+ "StrictHostKeyChecking=accept-new",
1841
+ "-o",
1842
+ `UserKnownHostsFile=${knownHosts}`,
1843
+ "-o",
1844
+ "GlobalKnownHostsFile=/dev/null"
1845
+ );
1846
+ }
1847
+ if (opts.port !== void 0) {
1848
+ argv.push("-o", `Port=${String(opts.port)}`);
1849
+ }
1850
+ argv.push(
1851
+ "-o",
1852
+ "BatchMode=yes",
1853
+ "-o",
1854
+ "LogLevel=ERROR",
1855
+ "-o",
1856
+ "ExitOnForwardFailure=yes",
1857
+ "-o",
1858
+ "ServerAliveInterval=30",
1859
+ "-o",
1860
+ "ServerAliveCountMax=3",
1861
+ "-o",
1862
+ `ConnectTimeout=${String(connectTimeout)}`,
1863
+ opts.vpsUser ? `${opts.vpsUser}@${opts.vpsHost}` : opts.vpsHost
1864
+ );
1865
+ const res = await execa("ssh", argv, { reject: false });
1866
+ if (res.exitCode !== 0 || !existsSync2(controlPath)) {
1867
+ throw new Error(
1868
+ `ssh ControlMaster failed for ${opts.boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1869
+ );
1870
+ }
1871
+ this.boxes.set(opts.boxId, tunnel);
1872
+ }
1873
+ /**
1874
+ * Mint (or fetch the cached) `127.0.0.1:<localPort> → remote:127.0.0.1:<remotePort>`
1875
+ * forward. Returns the local port. Idempotent per (boxId, remotePort).
1876
+ *
1877
+ * The cached entry is only returned when the underlying ControlMaster is
1878
+ * still alive — without that check we'd happily hand back a localPort that
1879
+ * stopped listening when the master died (e.g. transient network blip, host
1880
+ * sleep/wake). When the master is dead we drop ALL cached forwards for this
1881
+ * box (they all share one tunnel) and re-mint from scratch.
1882
+ */
1883
+ async forward(boxId, remotePort) {
1884
+ const tunnel = this.getTunnelOrThrow(boxId);
1885
+ const cached = tunnel.forwards.get(remotePort);
1886
+ if (cached !== void 0 && await this.isAlive(tunnel.controlPath)) {
1887
+ return cached;
1888
+ }
1889
+ if (cached !== void 0) {
1890
+ tunnel.forwards.clear();
1891
+ }
1892
+ const localPort = await pickFreePort();
1893
+ const argv = [
1894
+ "-O",
1895
+ "forward",
1896
+ "-L",
1897
+ `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1898
+ "-S",
1899
+ tunnel.controlPath,
1900
+ "dummy"
1901
+ // the target host is ignored when -O is used, but argv needs one
1902
+ ];
1903
+ const res = await execa("ssh", argv, { reject: false });
1904
+ if (res.exitCode !== 0) {
1905
+ throw new Error(
1906
+ `ssh -O forward failed for ${boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1907
+ );
1908
+ }
1909
+ tunnel.forwards.set(remotePort, localPort);
1910
+ return localPort;
1911
+ }
1912
+ /**
1913
+ * Tear down a dead ControlMaster + every cached forward for this box, then
1914
+ * re-open from scratch. Idempotent. Returns when the master is open and the
1915
+ * box's forwards map is empty (ready for fresh forward() calls).
1916
+ *
1917
+ * Use case: the cloud-poller observes ECONNREFUSED on the local port and asks
1918
+ * the backend to refresh the preview URL — that path calls into here so the
1919
+ * master + forward both come back fresh.
1920
+ */
1921
+ async refresh(opts) {
1922
+ const existing = this.boxes.get(opts.boxId);
1923
+ if (existing) {
1924
+ const alive = await this.isAlive(existing.controlPath);
1925
+ if (!alive && existsSync2(existing.controlPath)) {
1926
+ try {
1927
+ await execa("ssh", ["-O", "exit", "-S", existing.controlPath, "dummy"], {
1928
+ reject: false
1929
+ });
1930
+ } catch {
1931
+ }
1932
+ await rm2(existing.controlPath, { force: true });
1933
+ }
1934
+ existing.forwards.clear();
1935
+ }
1936
+ await this.open(opts);
1937
+ }
1938
+ /** Tear down a single forward. Idempotent — unknown ports are no-ops. */
1939
+ async unforward(boxId, remotePort) {
1940
+ const tunnel = this.getTunnelOrThrow(boxId);
1941
+ const localPort = tunnel.forwards.get(remotePort);
1942
+ if (localPort === void 0) return;
1943
+ const argv = [
1944
+ "-O",
1945
+ "cancel",
1946
+ "-L",
1947
+ `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1948
+ "-S",
1949
+ tunnel.controlPath,
1950
+ "dummy"
1951
+ ];
1952
+ await execa("ssh", argv, { reject: false });
1953
+ tunnel.forwards.delete(remotePort);
1954
+ }
1955
+ /**
1956
+ * Close the ControlMaster (and all its forwards). Idempotent — if no master
1957
+ * is recorded, no-op. Removes the socket file.
1958
+ */
1959
+ async close(boxId) {
1960
+ const tunnel = this.boxes.get(boxId);
1961
+ if (!tunnel) return;
1962
+ if (existsSync2(tunnel.controlPath)) {
1963
+ await execa("ssh", ["-O", "exit", "-S", tunnel.controlPath, "dummy"], { reject: false });
1964
+ await rm2(tunnel.controlPath, { force: true });
1965
+ }
1966
+ this.boxes.delete(boxId);
1967
+ }
1968
+ /** Tear down every open box. */
1969
+ async closeAll() {
1970
+ const ids = Array.from(this.boxes.keys());
1971
+ await Promise.all(ids.map((id) => this.close(id)));
1972
+ }
1973
+ /** Path to the ControlMaster socket for `boxId`, if open. */
1974
+ controlPath(boxId) {
1975
+ return this.boxes.get(boxId)?.controlPath;
1976
+ }
1977
+ /** True if a ControlMaster is registered for `boxId` (regardless of liveness). */
1978
+ has(boxId) {
1979
+ return this.boxes.has(boxId);
1980
+ }
1981
+ /** Per-box ssh dir (tests use this to verify the layout). */
1982
+ boxSshDir(boxId) {
1983
+ return this.boxes.get(boxId)?.boxSshDir;
1984
+ }
1985
+ /** Re-open the manager record for an existing-on-disk control socket. */
1986
+ registerExisting(boxId, opts) {
1987
+ const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId, this.namespace);
1988
+ this.boxes.set(boxId, {
1989
+ controlPath: join6(boxSshDir, "control.sock"),
1990
+ vpsHost: opts.vpsHost,
1991
+ vpsUser: opts.vpsUser,
1992
+ identity: opts.identity,
1993
+ port: opts.port,
1994
+ boxSshDir,
1995
+ forwards: /* @__PURE__ */ new Map()
1996
+ });
1997
+ }
1998
+ async isAlive(controlPath) {
1999
+ const res = await execa("ssh", ["-O", "check", "-S", controlPath, "dummy"], { reject: false });
2000
+ return res.exitCode === 0;
2001
+ }
2002
+ getTunnelOrThrow(boxId) {
2003
+ const t = this.boxes.get(boxId);
2004
+ if (!t) throw new Error(`no SSH ControlMaster registered for box ${boxId}; call open() first`);
2005
+ return t;
2006
+ }
2007
+ };
2008
+ function defaultBoxSshDir(boxId, namespace) {
2009
+ const safe = boxId.replace(/[^A-Za-z0-9._-]/g, "_");
2010
+ return namespace ? resolve22(homedir4(), ".agentbox", namespace, "boxes", safe, "ssh") : resolve22(homedir4(), ".agentbox", "boxes", safe, "ssh");
2011
+ }
2012
+ async function pickFreePort() {
2013
+ return new Promise((resolveOk, reject) => {
2014
+ const srv = createServer();
2015
+ srv.unref();
2016
+ srv.on("error", reject);
2017
+ srv.listen(0, HOST, () => {
2018
+ const addr = srv.address();
2019
+ if (!addr || typeof addr === "string") {
2020
+ srv.close();
2021
+ reject(new Error("could not get a free local port"));
2022
+ return;
2023
+ }
2024
+ const port = addr.port;
2025
+ srv.close(() => resolveOk(port));
2026
+ });
2027
+ });
2028
+ }
1667
2029
  var OPEN_INBOUND_SOURCES = ["0.0.0.0/0", "::/0"];
1668
2030
  function normalizeInboundCidr(raw) {
1669
2031
  const trimmed = raw.trim();
@@ -1780,7 +2142,7 @@ function errSummary(err) {
1780
2142
  return err instanceof Error ? firstLine(err.message) : String(err);
1781
2143
  }
1782
2144
  function secretsEnvPath() {
1783
- return resolve22(homedir4(), ".agentbox", "secrets.env");
2145
+ return resolve32(homedir5(), ".agentbox", "secrets.env");
1784
2146
  }
1785
2147
  function writeManagedSecrets(managedKeys, record) {
1786
2148
  for (const k of managedKeys) delete process.env[k];
@@ -1788,7 +2150,7 @@ function writeManagedSecrets(managedKeys, record) {
1788
2150
  const path = secretsEnvPath();
1789
2151
  mkdirSync2(dirname4(path), { recursive: true });
1790
2152
  let existing = "";
1791
- if (existsSync2(path)) {
2153
+ if (existsSync3(path)) {
1792
2154
  try {
1793
2155
  existing = readFileSync2(path, "utf8");
1794
2156
  } catch {
@@ -1817,7 +2179,7 @@ function writeManagedSecrets(managedKeys, record) {
1817
2179
  } catch {
1818
2180
  }
1819
2181
  }
1820
- var PLUGINS_FILE = join6(homedir5(), ".agentbox", "plugins.json");
2182
+ var PLUGINS_FILE = join7(homedir6(), ".agentbox", "plugins.json");
1821
2183
  var SUPPORTED_SDK_API_VERSIONS = [1, 2];
1822
2184
  function isSupportedApiVersion(v) {
1823
2185
  return SUPPORTED_SDK_API_VERSIONS.includes(v);
@@ -1832,7 +2194,7 @@ function normalize2(raw) {
1832
2194
  }
1833
2195
  function readPluginRegistrySync(path = PLUGINS_FILE) {
1834
2196
  try {
1835
- if (!existsSync3(path)) return { ...EMPTY2 };
2197
+ if (!existsSync4(path)) return { ...EMPTY2 };
1836
2198
  return normalize2(JSON.parse(readFileSync3(path, "utf8")));
1837
2199
  } catch {
1838
2200
  return { ...EMPTY2 };
@@ -1856,7 +2218,7 @@ function wantsRender(e) {
1856
2218
  async function renderCarryEntries(entries, ctx, onLog) {
1857
2219
  if (!entries.some(wantsRender)) return entries;
1858
2220
  const context = carryPlaceholderContext(ctx);
1859
- const stage = await mkdtemp(join7(tmpdir(), "agentbox-carry-render-"));
2221
+ const stage = await mkdtemp(join8(tmpdir(), "agentbox-carry-render-"));
1860
2222
  const out = [];
1861
2223
  for (const [i, entry] of entries.entries()) {
1862
2224
  if (!wantsRender(entry)) {
@@ -1870,7 +2232,7 @@ async function renderCarryEntries(entries, ctx, onLog) {
1870
2232
  context,
1871
2233
  onWarn: (msg) => onLog?.(`carry: ${entry.rawSrc}: ${msg}`)
1872
2234
  });
1873
- const tmp = join7(stage, `${String(i)}-${basename2(entry.absSrc)}`);
2235
+ const tmp = join8(stage, `${String(i)}-${basename2(entry.absSrc)}`);
1874
2236
  await writeFile3(tmp, rendered, "utf8");
1875
2237
  out.push({ ...entry, absSrc: tmp, bytes: Buffer.byteLength(rendered) });
1876
2238
  const what = [
@@ -1926,7 +2288,7 @@ var AGENT_SYNC_SPECS = [
1926
2288
  credential: {
1927
2289
  boxRelPath: ".credentials.json",
1928
2290
  boxAbsPath: `${CLAUDE_BOX_DIR}/.credentials.json`,
1929
- hostBackup: join8(STATE_DIR, "claude-credentials.json"),
2291
+ hostBackup: join9(STATE_DIR, "claude-credentials.json"),
1930
2292
  cloudMountPath: "/home/vscode/.agentbox-creds/claude",
1931
2293
  cloudSubpath: "claude/",
1932
2294
  realShape: "claude-oauth"
@@ -1998,7 +2360,7 @@ var AGENT_SYNC_SPECS = [
1998
2360
  credential: {
1999
2361
  boxRelPath: "auth.json",
2000
2362
  boxAbsPath: `${CODEX_BOX_DIR}/auth.json`,
2001
- hostBackup: join8(STATE_DIR, "codex-credentials.json"),
2363
+ hostBackup: join9(STATE_DIR, "codex-credentials.json"),
2002
2364
  cloudMountPath: "/home/vscode/.agentbox-creds/codex",
2003
2365
  cloudSubpath: "codex/",
2004
2366
  realShape: "nonempty-json"
@@ -2049,7 +2411,7 @@ var AGENT_SYNC_SPECS = [
2049
2411
  credential: {
2050
2412
  boxRelPath: "auth.json",
2051
2413
  boxAbsPath: `${OPENCODE_BOX_DIR}/auth.json`,
2052
- hostBackup: join8(STATE_DIR, "opencode-credentials.json"),
2414
+ hostBackup: join9(STATE_DIR, "opencode-credentials.json"),
2053
2415
  cloudMountPath: "/home/vscode/.agentbox-creds/opencode",
2054
2416
  cloudSubpath: "opencode/",
2055
2417
  realShape: "nonempty-json"
@@ -2235,12 +2597,12 @@ async function readJsonFile(path) {
2235
2597
  }
2236
2598
  }
2237
2599
  async function computeClaudePullPlan(inv, opts = {}) {
2238
- const hostHome = opts.hostHome ?? homedir6();
2239
- const hostClaude = join9(hostHome, ".claude");
2600
+ const hostHome = opts.hostHome ?? homedir7();
2601
+ const hostClaude = join10(hostHome, ".claude");
2240
2602
  const newItems = [];
2241
2603
  const copyRels = [];
2242
2604
  for (const cat of CLAUDE_PULL_DIR_CATEGORIES) {
2243
- const hostNames = await listChildDirs(join9(hostClaude, cat));
2605
+ const hostNames = await listChildDirs(join10(hostClaude, cat));
2244
2606
  const excludes = cat === "skills" ? SKILL_EXCLUDE_PREFIXES : [];
2245
2607
  for (const name of pickNewItems(inv.dirs[cat] ?? [], hostNames, excludes)) {
2246
2608
  newItems.push({ category: cat, name });
@@ -2248,8 +2610,8 @@ async function computeClaudePullPlan(inv, opts = {}) {
2248
2610
  }
2249
2611
  }
2250
2612
  const hostPluginKeys = [];
2251
- for (const m of await listChildDirs(join9(hostClaude, "plugins", "cache"))) {
2252
- for (const p of await listChildDirs(join9(hostClaude, "plugins", "cache", m))) {
2613
+ for (const m of await listChildDirs(join10(hostClaude, "plugins", "cache"))) {
2614
+ for (const p of await listChildDirs(join10(hostClaude, "plugins", "cache", m))) {
2253
2615
  hostPluginKeys.push(`${m}/${p}`);
2254
2616
  }
2255
2617
  }
@@ -2257,8 +2619,8 @@ async function computeClaudePullPlan(inv, opts = {}) {
2257
2619
  newItems.push({ category: "plugins", name: key });
2258
2620
  copyRels.push(`plugins/cache/${key}`);
2259
2621
  }
2260
- const hostInstalled = await readJsonFile(join9(hostClaude, "plugins", "installed_plugins.json"));
2261
- const hostMarkets = await readJsonFile(join9(hostClaude, "plugins", "known_marketplaces.json"));
2622
+ const hostInstalled = await readJsonFile(join10(hostClaude, "plugins", "installed_plugins.json"));
2623
+ const hostMarkets = await readJsonFile(join10(hostClaude, "plugins", "known_marketplaces.json"));
2262
2624
  const mergedInstalled = mergeInstalledPlugins(hostInstalled, inv.registries["installed_plugins"], {
2263
2625
  hostHome
2264
2626
  });
@@ -2272,18 +2634,18 @@ async function computeClaudePullPlan(inv, opts = {}) {
2272
2634
  }
2273
2635
  async function writeClaudeMergedRegistries(plan, opts = {}) {
2274
2636
  if (!plan.mergedInstalled.changed && !plan.mergedMarkets.changed) return;
2275
- const hostClaude = join9(opts.hostHome ?? homedir6(), ".claude");
2276
- await mkdir4(join9(hostClaude, "plugins"), { recursive: true });
2637
+ const hostClaude = join10(opts.hostHome ?? homedir7(), ".claude");
2638
+ await mkdir5(join10(hostClaude, "plugins"), { recursive: true });
2277
2639
  if (plan.mergedMarkets.changed) {
2278
2640
  await writeFile4(
2279
- join9(hostClaude, "plugins", "known_marketplaces.json"),
2641
+ join10(hostClaude, "plugins", "known_marketplaces.json"),
2280
2642
  `${JSON.stringify(plan.mergedMarkets.data, null, 2)}
2281
2643
  `
2282
2644
  );
2283
2645
  }
2284
2646
  if (plan.mergedInstalled.changed) {
2285
2647
  await writeFile4(
2286
- join9(hostClaude, "plugins", "installed_plugins.json"),
2648
+ join10(hostClaude, "plugins", "installed_plugins.json"),
2287
2649
  `${JSON.stringify(plan.mergedInstalled.data, null, 2)}
2288
2650
  `
2289
2651
  );
@@ -2310,7 +2672,7 @@ function makeSyncContext(init) {
2310
2672
  hostWorkspace: init.hostWorkspace,
2311
2673
  projectRoot: init.projectRoot ?? init.hostWorkspace,
2312
2674
  boxWorkspace: init.boxWorkspace ?? "/workspace",
2313
- hostHome: init.hostHome ?? homedir7(),
2675
+ hostHome: init.hostHome ?? homedir8(),
2314
2676
  onLog: init.onLog ?? (() => {
2315
2677
  })
2316
2678
  };
@@ -2382,8 +2744,8 @@ async function scanHostEnvFiles(workspaceDir, patterns) {
2382
2744
  async function pushEnvFiles(ctx, transport, patterns) {
2383
2745
  const list = await findEnvFilesForTar(ctx.hostWorkspace, patterns);
2384
2746
  if (list.length === 0) return { copied: 0 };
2385
- const stage = await mkdtemp3(join11(tmpdir3(), "agentbox-envfiles-"));
2386
- const localTar = join11(stage, "envfiles.tar");
2747
+ const stage = await mkdtemp3(join12(tmpdir3(), "agentbox-envfiles-"));
2748
+ const localTar = join12(stage, "envfiles.tar");
2387
2749
  try {
2388
2750
  const packed = await execa(
2389
2751
  "tar",
@@ -2403,7 +2765,7 @@ async function pushEnvFiles(ctx, transport, patterns) {
2403
2765
  return { copied: 0 };
2404
2766
  }
2405
2767
  } finally {
2406
- await rm4(stage, { recursive: true, force: true });
2768
+ await rm5(stage, { recursive: true, force: true });
2407
2769
  }
2408
2770
  return { copied: list.length };
2409
2771
  }
@@ -2455,9 +2817,9 @@ function encodeClaudeProjectsKey(absPath) {
2455
2817
  return absPath.replace(/[^a-zA-Z0-9]/g, "-");
2456
2818
  }
2457
2819
  var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
2458
- async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir8()) {
2820
+ async function resolveClaudeMemoryDir(hostWorkspace, hostHome = homedir9()) {
2459
2821
  if (hostWorkspace.length === 0) return null;
2460
- const memDir = join12(
2822
+ const memDir = join13(
2461
2823
  hostHome,
2462
2824
  ".claude",
2463
2825
  "projects",
@@ -2500,8 +2862,8 @@ async function findUnsyncableSymlinks(root, reachableRoots) {
2500
2862
  return;
2501
2863
  }
2502
2864
  for (const ent of entries) {
2503
- const realFull = join13(realDir, ent.name);
2504
- const virtualFull = virtualDir ? join13(virtualDir, ent.name) : ent.name;
2865
+ const realFull = join14(realDir, ent.name);
2866
+ const virtualFull = virtualDir ? join14(virtualDir, ent.name) : ent.name;
2505
2867
  if (ent.isSymbolicLink()) {
2506
2868
  let real;
2507
2869
  try {
@@ -2604,7 +2966,7 @@ async function extractCredentials(transport, opts = {}) {
2604
2966
  try {
2605
2967
  const text = await transport.readText(spec.credential.boxAbsPath);
2606
2968
  if (!text || !isRealAgentCredential(spec.id, text)) continue;
2607
- await mkdir6(dirname8(hostBackup), { recursive: true });
2969
+ await mkdir7(dirname8(hostBackup), { recursive: true });
2608
2970
  await writeFile6(hostBackup, text, { mode: 384 });
2609
2971
  await chmod2(hostBackup, 384).catch(() => {
2610
2972
  });
@@ -2660,7 +3022,7 @@ function shouldAcceptCredentialUpdate(agent, incoming, existing) {
2660
3022
  }
2661
3023
  async function writeCredentialBackup(agent, content, opts = {}) {
2662
3024
  const path = opts.backupPath ?? resolveAgentSpec(agent).credential.hostBackup;
2663
- await mkdir6(dirname8(path), { recursive: true });
3025
+ await mkdir7(dirname8(path), { recursive: true });
2664
3026
  const tmp = `${path}.tmp-${String(process.pid)}`;
2665
3027
  await writeFile6(tmp, content, { mode: 384 });
2666
3028
  await rename3(tmp, path);
@@ -2678,9 +3040,9 @@ async function readCredentialBackup(agent, opts = {}) {
2678
3040
  async function pushCredentialToBox(transport, agent, content) {
2679
3041
  const abs = resolveAgentSpec(agent).credential.boxAbsPath;
2680
3042
  const dir = abs.slice(0, abs.lastIndexOf("/"));
2681
- const stage = await mkdtemp4(join14(tmpdir4(), "agentbox-cred-push-"));
3043
+ const stage = await mkdtemp4(join15(tmpdir4(), "agentbox-cred-push-"));
2682
3044
  try {
2683
- const tmp = join14(stage, "credential");
3045
+ const tmp = join15(stage, "credential");
2684
3046
  await writeFile6(tmp, content, { mode: 384 });
2685
3047
  const mk = await transport.exec(["sh", "-c", `mkdir -p '${dir}'`]);
2686
3048
  if (mk.exitCode !== 0) {
@@ -2697,7 +3059,7 @@ async function pushCredentialToBox(transport, agent, content) {
2697
3059
  throw new Error(`chown/chmod of ${abs} in box failed: ${norm.stderr.trim()}`);
2698
3060
  }
2699
3061
  } finally {
2700
- await rm5(stage, { recursive: true, force: true });
3062
+ await rm6(stage, { recursive: true, force: true });
2701
3063
  }
2702
3064
  }
2703
3065
  var NON_REGULAR_TOKEN = "-";
@@ -2848,7 +3210,7 @@ function makeHostGitPorts() {
2848
3210
  return untracked.exitCode === 0 ? splitNul(untracked.stdout) : [];
2849
3211
  },
2850
3212
  async hashHostFile(hostMain, relPath) {
2851
- return createHash("sha256").update(await readFile7(join15(hostMain, relPath))).digest("hex");
3213
+ return createHash("sha256").update(await readFile7(join16(hostMain, relPath))).digest("hex");
2852
3214
  },
2853
3215
  async packHostFiles(hostMain, relPaths) {
2854
3216
  const tarOut = await execa("tar", ["-C", hostMain, "--null", "-T", "-", "-cf", "-"], {
@@ -2881,7 +3243,7 @@ async function walkFiles(root, prefix = "") {
2881
3243
  const out = [];
2882
3244
  for (const ent of entries) {
2883
3245
  const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
2884
- const full = join16(root, ent.name);
3246
+ const full = join17(root, ent.name);
2885
3247
  if (ent.isDirectory()) {
2886
3248
  out.push(...await walkFiles(full, rel));
2887
3249
  } else if (ent.isFile()) {
@@ -2905,12 +3267,12 @@ async function buildHostSet(name, hostDir, boxDst) {
2905
3267
  const rels = await walkFiles(hostDir);
2906
3268
  const files = {};
2907
3269
  for (const rel of rels) {
2908
- files[rel] = await hashFile(join16(hostDir, rel));
3270
+ files[rel] = await hashFile(join17(hostDir, rel));
2909
3271
  }
2910
3272
  return { dst: boxDst, files, hostDir };
2911
3273
  }
2912
- async function buildHostSyncManifest(workspacePath, hostHome = homedir9()) {
2913
- const workflowsDir = join16(hostHome, ".claude", "workflows");
3274
+ async function buildHostSyncManifest(workspacePath, hostHome = homedir10()) {
3275
+ const workflowsDir = join17(hostHome, ".claude", "workflows");
2914
3276
  const workflowsHost = await pathExists4(workflowsDir) ? workflowsDir : null;
2915
3277
  const memoryHost = await resolveClaudeMemoryDir(workspacePath, hostHome);
2916
3278
  const [workflows, memory] = await Promise.all([
@@ -2932,7 +3294,7 @@ function computeSyncDelta(host, box) {
2932
3294
  uploads.push({
2933
3295
  set: name,
2934
3296
  rel,
2935
- absSrc: join16(hostSet.hostDir, rel),
3297
+ absSrc: join17(hostSet.hostDir, rel),
2936
3298
  dst: `${hostSet.dst}/${rel}`
2937
3299
  });
2938
3300
  }
@@ -2951,15 +3313,15 @@ async function stageDynamicSyncTarball(uploads) {
2951
3313
  return { tarballPath: null, cleanup: async () => {
2952
3314
  } };
2953
3315
  }
2954
- const stageDir = await mkdtemp5(join16(tmpdir5(), "agentbox-dynsync-stage-"));
3316
+ const stageDir = await mkdtemp5(join17(tmpdir5(), "agentbox-dynsync-stage-"));
2955
3317
  let tarballPath = null;
2956
3318
  try {
2957
3319
  for (const up of uploads) {
2958
- const target = join16(stageDir, up.set, up.rel);
2959
- await mkdir7(dirname9(target), { recursive: true });
3320
+ const target = join17(stageDir, up.set, up.rel);
3321
+ await mkdir8(dirname9(target), { recursive: true });
2960
3322
  await copyFile(up.absSrc, target);
2961
3323
  }
2962
- tarballPath = join16(tmpdir5(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
3324
+ tarballPath = join17(tmpdir5(), `agentbox-dynsync-${basename22(stageDir)}.tar.gz`);
2963
3325
  await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
2964
3326
  env: { ...process.env, COPYFILE_DISABLE: "1" }
2965
3327
  });
@@ -2967,13 +3329,13 @@ async function stageDynamicSyncTarball(uploads) {
2967
3329
  return {
2968
3330
  tarballPath: tp,
2969
3331
  cleanup: async () => {
2970
- await rm6(stageDir, { recursive: true, force: true });
2971
- await rm6(tp, { force: true });
3332
+ await rm7(stageDir, { recursive: true, force: true });
3333
+ await rm7(tp, { force: true });
2972
3334
  }
2973
3335
  };
2974
3336
  } catch (err) {
2975
- await rm6(stageDir, { recursive: true, force: true });
2976
- if (tarballPath) await rm6(tarballPath, { force: true });
3337
+ await rm7(stageDir, { recursive: true, force: true });
3338
+ if (tarballPath) await rm7(tarballPath, { force: true });
2977
3339
  throw err;
2978
3340
  }
2979
3341
  }
@@ -3093,7 +3455,7 @@ var BOX_WORKSPACE2 = "/workspace";
3093
3455
  var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
3094
3456
  trust_level = "trusted"
3095
3457
  `;
3096
- function sanitizeCodexConfigForBox(tomlText, hostHome = homedir10()) {
3458
+ function sanitizeCodexConfigForBox(tomlText, hostHome = homedir11()) {
3097
3459
  const cfg = parse(tomlText);
3098
3460
  let changed = false;
3099
3461
  if (isRecord(cfg["mcp_servers"])) {
@@ -3200,7 +3562,7 @@ async function findBrokenSymlinks(root) {
3200
3562
  return;
3201
3563
  }
3202
3564
  for (const ent of entries) {
3203
- const full = join17(dir, ent.name);
3565
+ const full = join18(dir, ent.name);
3204
3566
  if (ent.isSymbolicLink()) {
3205
3567
  try {
3206
3568
  await stat9(full);
@@ -3216,7 +3578,7 @@ async function findBrokenSymlinks(root) {
3216
3578
  return broken;
3217
3579
  }
3218
3580
  async function mkStageDir(prefix) {
3219
- return mkdtemp6(join17(tmpdir6(), `agentbox-${prefix}-stage-`));
3581
+ return mkdtemp6(join18(tmpdir6(), `agentbox-${prefix}-stage-`));
3220
3582
  }
3221
3583
  var STAGE_WRITABLE_CHMOD = "--chmod=Du+rwx,Fu+rw";
3222
3584
  function emptyResult(warnings = []) {
@@ -3224,7 +3586,7 @@ function emptyResult(warnings = []) {
3224
3586
  }, warnings };
3225
3587
  }
3226
3588
  async function tarballFromDir(stageDir, agent) {
3227
- const tarballPath = join17(tmpdir6(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
3589
+ const tarballPath = join18(tmpdir6(), `agentbox-${agent}-${basename3(stageDir)}.tar.gz`);
3228
3590
  await execa("tar", ["-czf", tarballPath, "-C", stageDir, "."], {
3229
3591
  env: { ...process.env, COPYFILE_DISABLE: "1" }
3230
3592
  });
@@ -3233,7 +3595,7 @@ async function tarballFromDir(stageDir, agent) {
3233
3595
  function makeCleanup(paths) {
3234
3596
  return async () => {
3235
3597
  for (const p of paths) {
3236
- await rm7(p, { recursive: true, force: true });
3598
+ await rm8(p, { recursive: true, force: true });
3237
3599
  }
3238
3600
  };
3239
3601
  }
@@ -3241,7 +3603,7 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
3241
3603
  const stageDir = await mkStageDir(agent);
3242
3604
  let tarballPath = null;
3243
3605
  try {
3244
- await copyFile2(sourcePath, join17(stageDir, tarballEntryName));
3606
+ await copyFile2(sourcePath, join18(stageDir, tarballEntryName));
3245
3607
  tarballPath = await tarballFromDir(stageDir, agent);
3246
3608
  return {
3247
3609
  tarballPath,
@@ -3249,15 +3611,15 @@ async function stageSingleFileTarball(agent, sourcePath, tarballEntryName) {
3249
3611
  warnings: []
3250
3612
  };
3251
3613
  } catch (err) {
3252
- await rm7(stageDir, { recursive: true, force: true });
3253
- if (tarballPath) await rm7(tarballPath, { force: true });
3614
+ await rm8(stageDir, { recursive: true, force: true });
3615
+ if (tarballPath) await rm8(tarballPath, { force: true });
3254
3616
  throw err;
3255
3617
  }
3256
3618
  }
3257
3619
  var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
3258
3620
  async function buildBoxClaudeJsonFromHost(opts) {
3259
3621
  const { hostHome, hostWorkspace } = opts;
3260
- const hostClaudeJson = join17(hostHome, ".claude.json");
3622
+ const hostClaudeJson = join18(hostHome, ".claude.json");
3261
3623
  let working;
3262
3624
  if (await pathExists5(hostClaudeJson)) {
3263
3625
  try {
@@ -3292,7 +3654,7 @@ async function buildBoxClaudeJsonFromHost(opts) {
3292
3654
  return working;
3293
3655
  }
3294
3656
  async function stageClaudeJsonOnlyForUpload(opts = {}) {
3295
- const hostHome = opts.hostHome ?? homedir11();
3657
+ const hostHome = opts.hostHome ?? homedir12();
3296
3658
  const stageDir = await mkStageDir("claude-json-only");
3297
3659
  let tarballPath = null;
3298
3660
  try {
@@ -3300,7 +3662,7 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
3300
3662
  hostHome,
3301
3663
  hostWorkspace: opts.hostWorkspace
3302
3664
  });
3303
- await writeFile7(join17(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
3665
+ await writeFile7(join18(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
3304
3666
  tarballPath = await tarballFromDir(stageDir, "claude-json-only");
3305
3667
  return {
3306
3668
  tarballPath,
@@ -3308,14 +3670,14 @@ async function stageClaudeJsonOnlyForUpload(opts = {}) {
3308
3670
  warnings: []
3309
3671
  };
3310
3672
  } catch (err) {
3311
- await rm7(stageDir, { recursive: true, force: true });
3312
- if (tarballPath) await rm7(tarballPath, { force: true });
3673
+ await rm8(stageDir, { recursive: true, force: true });
3674
+ if (tarballPath) await rm8(tarballPath, { force: true });
3313
3675
  throw err;
3314
3676
  }
3315
3677
  }
3316
3678
  async function stageClaudeStaticForUpload(opts = {}) {
3317
- const hostHome = opts.hostHome ?? homedir11();
3318
- const hostClaude = join17(hostHome, ".claude");
3679
+ const hostHome = opts.hostHome ?? homedir12();
3680
+ const hostClaude = join18(hostHome, ".claude");
3319
3681
  if (!await pathExists5(hostClaude)) return emptyResult();
3320
3682
  const stageDir = await mkStageDir("claude-static");
3321
3683
  let tarballPath = null;
@@ -3333,7 +3695,7 @@ async function stageClaudeStaticForUpload(opts = {}) {
3333
3695
  `${hostClaude}/`,
3334
3696
  `${stageDir}/`
3335
3697
  ]);
3336
- const settingsPath = join17(stageDir, "settings.json");
3698
+ const settingsPath = join18(stageDir, "settings.json");
3337
3699
  if (await pathExists5(settingsPath)) {
3338
3700
  try {
3339
3701
  const parsed = JSON.parse(await readFile9(settingsPath, "utf8"));
@@ -3348,14 +3710,14 @@ async function stageClaudeStaticForUpload(opts = {}) {
3348
3710
  hostHome,
3349
3711
  hostWorkspace: opts.hostWorkspace
3350
3712
  });
3351
- await writeFile7(join17(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
3352
- const pluginsDir = join17(stageDir, "plugins");
3713
+ await writeFile7(join18(stageDir, "_claude.json"), JSON.stringify(claudeJson, null, 2));
3714
+ const pluginsDir = join18(stageDir, "plugins");
3353
3715
  if (await pathExists5(pluginsDir)) {
3354
3716
  try {
3355
3717
  const entries = await readdir6(pluginsDir, { withFileTypes: true });
3356
3718
  for (const ent of entries) {
3357
3719
  if (!ent.isFile() || !ent.name.endsWith(".json")) continue;
3358
- const file = join17(pluginsDir, ent.name);
3720
+ const file = join18(pluginsDir, ent.name);
3359
3721
  const raw = await readFile9(file, "utf8");
3360
3722
  const replaced = raw.split(`${hostHome}/.claude/plugins/`).join("/home/vscode/.claude/plugins/");
3361
3723
  if (replaced !== raw) await writeFile7(file, replaced);
@@ -3370,8 +3732,8 @@ async function stageClaudeStaticForUpload(opts = {}) {
3370
3732
  warnings: []
3371
3733
  };
3372
3734
  } catch (err) {
3373
- await rm7(stageDir, { recursive: true, force: true });
3374
- if (tarballPath) await rm7(tarballPath, { force: true });
3735
+ await rm8(stageDir, { recursive: true, force: true });
3736
+ if (tarballPath) await rm8(tarballPath, { force: true });
3375
3737
  throw err;
3376
3738
  }
3377
3739
  }
@@ -3398,7 +3760,7 @@ async function sanitizeStagedCodexConfig(configPath, hostHome) {
3398
3760
  async function purgeOrphanCodexMarketplaceDirs(stageDir, keptMarketplaces) {
3399
3761
  const kept = new Set(keptMarketplaces);
3400
3762
  for (const rel of ["plugins/cache", ".tmp/marketplaces"]) {
3401
- const dir = join17(stageDir, rel);
3763
+ const dir = join18(stageDir, rel);
3402
3764
  let entries;
3403
3765
  try {
3404
3766
  entries = await readdir6(dir);
@@ -3407,13 +3769,13 @@ async function purgeOrphanCodexMarketplaceDirs(stageDir, keptMarketplaces) {
3407
3769
  }
3408
3770
  for (const name of entries) {
3409
3771
  if (kept.has(name)) continue;
3410
- await rm7(join17(dir, name), { recursive: true, force: true });
3772
+ await rm8(join18(dir, name), { recursive: true, force: true });
3411
3773
  }
3412
3774
  }
3413
3775
  }
3414
3776
  async function stageCodexStaticForUpload(opts = {}) {
3415
- const hostHome = opts.hostHome ?? homedir11();
3416
- const hostCodex = join17(hostHome, ".codex");
3777
+ const hostHome = opts.hostHome ?? homedir12();
3778
+ const hostCodex = join18(hostHome, ".codex");
3417
3779
  if (!await pathExists5(hostCodex)) return emptyResult();
3418
3780
  const stageDir = await mkStageDir("codex-static");
3419
3781
  let tarballPath = null;
@@ -3429,7 +3791,7 @@ async function stageCodexStaticForUpload(opts = {}) {
3429
3791
  `${hostCodex}/`,
3430
3792
  `${stageDir}/`
3431
3793
  ]);
3432
- const sanitized = await sanitizeStagedCodexConfig(join17(stageDir, "config.toml"), hostHome);
3794
+ const sanitized = await sanitizeStagedCodexConfig(join18(stageDir, "config.toml"), hostHome);
3433
3795
  if (sanitized !== null) {
3434
3796
  await purgeOrphanCodexMarketplaceDirs(stageDir, sanitized.keptMarketplaces);
3435
3797
  }
@@ -3440,14 +3802,14 @@ async function stageCodexStaticForUpload(opts = {}) {
3440
3802
  warnings: []
3441
3803
  };
3442
3804
  } catch (err) {
3443
- await rm7(stageDir, { recursive: true, force: true });
3444
- if (tarballPath) await rm7(tarballPath, { force: true });
3805
+ await rm8(stageDir, { recursive: true, force: true });
3806
+ if (tarballPath) await rm8(tarballPath, { force: true });
3445
3807
  throw err;
3446
3808
  }
3447
3809
  }
3448
3810
  async function stageAgentsStaticForUpload(opts = {}) {
3449
- const hostHome = opts.hostHome ?? homedir11();
3450
- const hostAgents = join17(hostHome, ".agents");
3811
+ const hostHome = opts.hostHome ?? homedir12();
3812
+ const hostAgents = join18(hostHome, ".agents");
3451
3813
  if (!await pathExists5(hostAgents)) return emptyResult();
3452
3814
  const stageDir = await mkStageDir("agents-static");
3453
3815
  let tarballPath = null;
@@ -3468,26 +3830,26 @@ async function stageAgentsStaticForUpload(opts = {}) {
3468
3830
  warnings: []
3469
3831
  };
3470
3832
  } catch (err) {
3471
- await rm7(stageDir, { recursive: true, force: true });
3472
- if (tarballPath) await rm7(tarballPath, { force: true });
3833
+ await rm8(stageDir, { recursive: true, force: true });
3834
+ if (tarballPath) await rm8(tarballPath, { force: true });
3473
3835
  throw err;
3474
3836
  }
3475
3837
  }
3476
3838
  async function stageCodexCredentialsForUpload(opts = {}) {
3477
- const hostHome = opts.hostHome ?? homedir11();
3478
- const cloudBackup = join17(hostHome, ".agentbox", "codex-credentials.json");
3839
+ const hostHome = opts.hostHome ?? homedir12();
3840
+ const cloudBackup = join18(hostHome, ".agentbox", "codex-credentials.json");
3479
3841
  if (await pathExists5(cloudBackup)) {
3480
3842
  return stageSingleFileTarball("codex-creds", cloudBackup, "auth.json");
3481
3843
  }
3482
- const hostAuth = join17(hostHome, ".codex", "auth.json");
3844
+ const hostAuth = join18(hostHome, ".codex", "auth.json");
3483
3845
  if (!await pathExists5(hostAuth)) return emptyResult([CODEX_KEYCHAIN_WARNING]);
3484
3846
  return stageSingleFileTarball("codex-creds", hostAuth, "auth.json");
3485
3847
  }
3486
3848
  var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
3487
3849
  async function stageOpencodeStaticForUpload(opts = {}) {
3488
- const hostHome = opts.hostHome ?? homedir11();
3489
- const hostData = join17(hostHome, ".local", "share", "opencode");
3490
- const hostConfig = join17(hostHome, ".config", "opencode");
3850
+ const hostHome = opts.hostHome ?? homedir12();
3851
+ const hostData = join18(hostHome, ".local", "share", "opencode");
3852
+ const hostConfig = join18(hostHome, ".config", "opencode");
3491
3853
  const hasData = await pathExists5(hostData);
3492
3854
  const hasConfig = await pathExists5(hostConfig);
3493
3855
  if (!hasData && !hasConfig) return emptyResult();
@@ -3507,7 +3869,7 @@ async function stageOpencodeStaticForUpload(opts = {}) {
3507
3869
  ]);
3508
3870
  }
3509
3871
  if (hasConfig) {
3510
- const configStage = join17(stageDir, "config");
3872
+ const configStage = join18(stageDir, "config");
3511
3873
  const cfgBroken = await findBrokenSymlinks(hostConfig);
3512
3874
  await execa("rsync", [
3513
3875
  "-a",
@@ -3525,24 +3887,24 @@ async function stageOpencodeStaticForUpload(opts = {}) {
3525
3887
  warnings: []
3526
3888
  };
3527
3889
  } catch (err) {
3528
- await rm7(stageDir, { recursive: true, force: true });
3529
- if (tarballPath) await rm7(tarballPath, { force: true });
3890
+ await rm8(stageDir, { recursive: true, force: true });
3891
+ if (tarballPath) await rm8(tarballPath, { force: true });
3530
3892
  throw err;
3531
3893
  }
3532
3894
  }
3533
3895
  async function stageOpencodeCredentialsForUpload(opts = {}) {
3534
- const hostHome = opts.hostHome ?? homedir11();
3535
- const cloudBackup = join17(hostHome, ".agentbox", "opencode-credentials.json");
3896
+ const hostHome = opts.hostHome ?? homedir12();
3897
+ const cloudBackup = join18(hostHome, ".agentbox", "opencode-credentials.json");
3536
3898
  if (await pathExists5(cloudBackup)) {
3537
3899
  return stageSingleFileTarball("opencode-creds", cloudBackup, "auth.json");
3538
3900
  }
3539
- const hostAuth = join17(hostHome, ".local", "share", "opencode", "auth.json");
3901
+ const hostAuth = join18(hostHome, ".local", "share", "opencode", "auth.json");
3540
3902
  if (!await pathExists5(hostAuth)) return emptyResult();
3541
3903
  return stageSingleFileTarball("opencode-creds", hostAuth, "auth.json");
3542
3904
  }
3543
3905
  async function stageOpencodeStateForUpload(opts = {}) {
3544
- const hostHome = opts.hostHome ?? homedir11();
3545
- const hostModel = join17(hostHome, ".local", "state", "opencode", "model.json");
3906
+ const hostHome = opts.hostHome ?? homedir12();
3907
+ const hostModel = join18(hostHome, ".local", "state", "opencode", "model.json");
3546
3908
  if (!await pathExists5(hostModel)) return emptyResult();
3547
3909
  return stageSingleFileTarball("opencode-state", hostModel, "model.json");
3548
3910
  }
@@ -3568,11 +3930,11 @@ function preparedStatePathFor(provider) {
3568
3930
  if (!/^[A-Za-z0-9._-]+$/.test(provider)) {
3569
3931
  throw new Error(`invalid provider name for prepared-state: ${JSON.stringify(provider)}`);
3570
3932
  }
3571
- return pathResolve(homedir12(), ".agentbox", `${provider}-prepared.json`);
3933
+ return pathResolve(homedir13(), ".agentbox", `${provider}-prepared.json`);
3572
3934
  }
3573
3935
  function readPreparedStateRaw(provider) {
3574
3936
  const path = preparedStatePathFor(provider);
3575
- if (!existsSync4(path)) return null;
3937
+ if (!existsSync5(path)) return null;
3576
3938
  try {
3577
3939
  return JSON.parse(readFileSync4(path, "utf8"));
3578
3940
  } catch {
@@ -3657,7 +4019,7 @@ function resolveContextFilesFrom(fileMap, opts) {
3657
4019
  pathResolve(opts.contextDir, paths.staged),
3658
4020
  pathResolve(opts.devRoot, paths.dev)
3659
4021
  ];
3660
- const hit = candidates.find((p) => existsSync4(p));
4022
+ const hit = candidates.find((p) => existsSync5(p));
3661
4023
  if (!hit) return null;
3662
4024
  out.push({ rel, abs: hit });
3663
4025
  }
@@ -3671,13 +4033,13 @@ function registryRefForSha(sha, registry = BOX_IMAGE_REGISTRY) {
3671
4033
  // ../../packages/sandbox-docker/dist/chunk-6T2XZZB5.js
3672
4034
  import { dirname as dirname23, resolve as resolve23 } from "path";
3673
4035
  import { fileURLToPath as fileURLToPath2 } from "url";
3674
- import { existsSync as existsSync5 } from "fs";
4036
+ import { existsSync as existsSync6 } from "fs";
3675
4037
  import { fileURLToPath } from "url";
3676
4038
  import { dirname as dirname7, resolve as resolve4 } from "path";
3677
4039
  var DEFAULT_BOX_IMAGE = "agentbox/box:dev";
3678
4040
  async function resolveClaudeInstallMode() {
3679
4041
  try {
3680
- const { loadEffectiveConfig } = await import("./dist-IZ2JCN5R.js");
4042
+ const { loadEffectiveConfig } = await import("./dist-EQV4L7KP.js");
3681
4043
  const cfg = await loadEffectiveConfig(process.cwd());
3682
4044
  return cfg.effective.box.claudeInstall;
3683
4045
  } catch {
@@ -3687,11 +4049,11 @@ async function resolveClaudeInstallMode() {
3687
4049
  var here = dirname7(fileURLToPath(import.meta.url));
3688
4050
  function resolveDockerBuild() {
3689
4051
  const override = process.env.AGENTBOX_DOCKER_CONTEXT;
3690
- if (override && existsSync5(resolve4(override, "Dockerfile.box"))) {
4052
+ if (override && existsSync6(resolve4(override, "Dockerfile.box"))) {
3691
4053
  return { dockerfile: resolve4(override, "Dockerfile.box"), context: override };
3692
4054
  }
3693
4055
  const staged = resolve4(here, "..", "runtime", "docker");
3694
- if (existsSync5(resolve4(staged, "Dockerfile.box"))) {
4056
+ if (existsSync6(resolve4(staged, "Dockerfile.box"))) {
3695
4057
  return { dockerfile: resolve4(staged, "Dockerfile.box"), context: staged };
3696
4058
  }
3697
4059
  const packageRoot = resolve4(here, "..");
@@ -3787,7 +4149,7 @@ async function buildImage(opts = {}) {
3787
4149
  return ref;
3788
4150
  }
3789
4151
  async function pullOrBuild(ref, fingerprint, opts = {}) {
3790
- const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-75DIZ55S-JDILR4OP.js");
4152
+ const { writePreparedDockerState: writePreparedDockerState2 } = await import("./prepared-state-75DIZ55S-NYEDSU2U.js");
3791
4153
  const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
3792
4154
  const allowPull = opts.allowPull !== false;
3793
4155
  if (allowPull && registry && fingerprint) {
@@ -3814,7 +4176,7 @@ async function pullOrBuild(ref, fingerprint, opts = {}) {
3814
4176
  return { source: "built" };
3815
4177
  }
3816
4178
  async function ensureImage(ref = DEFAULT_BOX_IMAGE, opts = {}) {
3817
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-75DIZ55S-JDILR4OP.js");
4179
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2, preparedMatches: preparedMatches2 } = await import("./prepared-state-75DIZ55S-NYEDSU2U.js");
3818
4180
  const claudeInstall = opts.claudeInstall ?? await resolveClaudeInstallMode();
3819
4181
  const rawFingerprint = await computeDockerContextFingerprint2({
3820
4182
  contextDir: opts.contextDir
@@ -3868,7 +4230,7 @@ function classifyDockerBaseFreshness(input) {
3868
4230
  return { state: "fresh" };
3869
4231
  }
3870
4232
  async function evaluateDockerBaseFreshness(opts = {}) {
3871
- const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-75DIZ55S-JDILR4OP.js");
4233
+ const { computeDockerContextFingerprint: computeDockerContextFingerprint2, readPreparedDockerState: readPreparedDockerState2 } = await import("./prepared-state-75DIZ55S-NYEDSU2U.js");
3872
4234
  const ref = opts.ref ?? DEFAULT_BOX_IMAGE;
3873
4235
  const imagePresent = await imageExists(ref);
3874
4236
  if (!imagePresent) return { state: "unprepared" };
@@ -3963,6 +4325,14 @@ export {
3963
4325
  syncAgentboxSshConfig,
3964
4326
  autoWriteSshConfig,
3965
4327
  mintSshKey,
4328
+ sshDestination,
4329
+ sshOptArgs,
4330
+ sshExec,
4331
+ scpUpload,
4332
+ scpDownload,
4333
+ waitForSsh,
4334
+ SshTunnelManager,
4335
+ defaultBoxSshDir,
3966
4336
  parseInboundSpec,
3967
4337
  resolveInboundSources,
3968
4338
  describeInbound,