@madarco/agentbox 0.25.0 → 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 +46 -0
  2. package/README.md +8 -7
  3. package/dist/{_cloud-attach-W2CFNXKO.js → _cloud-attach-7WRQH6XZ.js} +5 -5
  4. package/dist/{chunk-7PRLM3PH.js → chunk-7ZZAZPYX.js} +3 -3
  5. package/dist/{chunk-LU3WAHTU.js → chunk-BA2VLJVU.js} +3 -3
  6. package/dist/{chunk-GHFIKSBJ.js → chunk-DJQMK4RN.js} +12 -4
  7. package/dist/chunk-DJQMK4RN.js.map +1 -0
  8. package/dist/{chunk-4UNSBU5R.js → chunk-DQHMDDAT.js} +2 -2
  9. package/dist/{chunk-LCZOQTIX.js → chunk-I2OAJS3L.js} +40 -377
  10. package/dist/{chunk-LCZOQTIX.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-7C5MOA4Z.js → chunk-K5KOLYIL.js} +3 -3
  14. package/dist/{chunk-Y3OPQWAQ.js → chunk-PK2QF4IR.js} +576 -198
  15. package/dist/chunk-PK2QF4IR.js.map +1 -0
  16. package/dist/{chunk-VZC5J44U.js → chunk-UIFL7F2G.js} +55 -38
  17. package/dist/chunk-UIFL7F2G.js.map +1 -0
  18. package/dist/{chunk-NH3W6HUZ.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-IGQNVIV3.js → dist-5IICYSR6.js} +42 -374
  23. package/dist/{dist-IGQNVIV3.js.map → dist-5IICYSR6.js.map} +1 -1
  24. package/dist/{dist-KL73Z37T.js → dist-AR5CHRSV.js} +86 -45
  25. package/dist/{dist-KL73Z37T.js.map → dist-AR5CHRSV.js.map} +1 -1
  26. package/dist/{dist-3V5SLNK4.js → dist-DTNYMBQ5.js} +12 -12
  27. package/dist/{dist-UB3PYSCG.js → dist-K4LNH3EC.js} +6 -6
  28. package/dist/{dist-BIDAC4H4.js → dist-POVRY7HO.js} +8 -4
  29. package/dist/{dist-SBDYDH7H.js → dist-U2SVLJUQ.js} +4 -2
  30. package/dist/{dist-I5OBPLP2.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-OBM2F7CU-DY7TZV4R.js → prepared-state-75DIZ55S-W6NU3S3B.js} +2 -2
  36. package/package.json +8 -7
  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-LNHPLR3L.js → chunk-4QY2VZCF.js} +509 -135
  85. package/runtime/hub/apps/hub/{chunk-QBJOF5D3.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-MA73PTOR.js → chunk-XZZXPEVV.js} +58 -37
  88. package/runtime/hub/apps/hub/{dist-7LB4D4ZQ.js → dist-3ENKQN5G.js} +35 -365
  89. package/runtime/hub/apps/hub/{dist-SIQJD72C.js → dist-6VGJOQYK.js} +84 -43
  90. package/runtime/hub/apps/hub/{dist-ERQDDSOY.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-ZVY2FWG6.js → dist-RJJ2SDYO.js} +4 -4
  94. package/runtime/hub/apps/hub/{dist-26KVXHXV.js → dist-TU7D6UTB.js} +37 -366
  95. package/runtime/hub/apps/hub/{dist-YZJA4WRV.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-OBM2F7CU-ZEYFNYFI.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-5F5SOSDY.js.map +0 -1
  103. package/dist/chunk-GHFIKSBJ.js.map +0 -1
  104. package/dist/chunk-NH3W6HUZ.js.map +0 -1
  105. package/dist/chunk-VZC5J44U.js.map +0 -1
  106. package/dist/chunk-Y3OPQWAQ.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-W2CFNXKO.js.map → _cloud-attach-7WRQH6XZ.js.map} +0 -0
  109. /package/dist/{chunk-7PRLM3PH.js.map → chunk-7ZZAZPYX.js.map} +0 -0
  110. /package/dist/{chunk-LU3WAHTU.js.map → chunk-BA2VLJVU.js.map} +0 -0
  111. /package/dist/{chunk-4UNSBU5R.js.map → chunk-DQHMDDAT.js.map} +0 -0
  112. /package/dist/{chunk-7C5MOA4Z.js.map → chunk-K5KOLYIL.js.map} +0 -0
  113. /package/dist/{dist-3V5SLNK4.js.map → dist-DTNYMBQ5.js.map} +0 -0
  114. /package/dist/{dist-UB3PYSCG.js.map → dist-K4LNH3EC.js.map} +0 -0
  115. /package/dist/{dist-BIDAC4H4.js.map → dist-POVRY7HO.js.map} +0 -0
  116. /package/dist/{dist-I5OBPLP2.js.map → dist-U2SVLJUQ.js.map} +0 -0
  117. /package/dist/{dist-SBDYDH7H.js.map → dist-XYY6SIKG.js.map} +0 -0
  118. /package/dist/{prepared-state-OBM2F7CU-DY7TZV4R.js.map → prepared-state-75DIZ55S-W6NU3S3B.js.map} +0 -0
  119. /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_buildManifest.js +0 -0
  120. /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_clientMiddlewareManifest.js +0 -0
  121. /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_ssgManifest.js +0 -0
@@ -18,8 +18,8 @@ import {
18
18
  renderInnerCommand,
19
19
  resolveCloudCheckpoint,
20
20
  writeCloudCheckpointManifest
21
- } from "./chunk-QBJOF5D3.js";
22
- import "./chunk-MA73PTOR.js";
21
+ } from "./chunk-BARD2DI6.js";
22
+ import "./chunk-XZZXPEVV.js";
23
23
  import "./chunk-3LAHFDJF.js";
24
24
  import {
25
25
  UserFacingError,
@@ -34,9 +34,9 @@ import {
34
34
  stageAllAgentStatic,
35
35
  writeManagedSecrets,
36
36
  writePreparedStateRaw
37
- } from "./chunk-LNHPLR3L.js";
37
+ } from "./chunk-4QY2VZCF.js";
38
38
  import "./chunk-UDZ3VXRF.js";
39
- import "./chunk-V3OMPMI3.js";
39
+ import "./chunk-QSMPSV5Z.js";
40
40
  import "./chunk-OG4KH2FZ.js";
41
41
 
42
42
  // ../../packages/sandbox-e2b/dist/chunk-WQRH5SXA.js
@@ -12,16 +12,18 @@ import {
12
12
  } from "./chunk-CKBHQ7OI.js";
13
13
  import {
14
14
  createCloudProvider
15
- } from "./chunk-QBJOF5D3.js";
15
+ } from "./chunk-BARD2DI6.js";
16
16
  import {
17
17
  detectPortless,
18
18
  portlessDoctorRow
19
- } from "./chunk-MA73PTOR.js";
19
+ } from "./chunk-XZZXPEVV.js";
20
20
  import "./chunk-3LAHFDJF.js";
21
21
  import {
22
+ SshTunnelManager,
22
23
  UserFacingError,
23
24
  claudeInstallFingerprint,
24
25
  computeContextSha256,
26
+ defaultBoxSshDir,
25
27
  describeInbound,
26
28
  errSummary,
27
29
  hostOpenCommand,
@@ -31,17 +33,22 @@ import {
31
33
  readCliStamp,
32
34
  readPreparedStateRaw,
33
35
  resolveInboundSources,
36
+ scpDownload,
37
+ scpUpload,
38
+ sshExec,
39
+ sshOptArgs,
34
40
  stageAgentsStaticForUpload,
35
41
  stageClaudeStaticForUpload,
36
42
  stageCodexStaticForUpload,
37
43
  stageOpencodeStaticForUpload,
44
+ waitForSsh,
38
45
  writeManagedSecrets,
39
46
  writePreparedStateRaw
40
- } from "./chunk-LNHPLR3L.js";
47
+ } from "./chunk-4QY2VZCF.js";
41
48
  import {
42
49
  execa
43
50
  } from "./chunk-UDZ3VXRF.js";
44
- import "./chunk-V3OMPMI3.js";
51
+ import "./chunk-QSMPSV5Z.js";
45
52
  import "./chunk-OG4KH2FZ.js";
46
53
 
47
54
  // ../../packages/sandbox-hetzner/dist/chunk-YIQFCUWT.js
@@ -807,20 +814,15 @@ async function currentHetznerBaseFingerprintLive(claudeInstall = "native") {
807
814
  }
808
815
 
809
816
  // ../../packages/sandbox-hetzner/dist/index.js
810
- import { existsSync as existsSync22 } from "fs";
811
- import { rm as rm2, rename, mkdir as mkdir2 } from "fs/promises";
812
- import { join as join3 } from "path";
817
+ import { existsSync as existsSync3 } from "fs";
818
+ import { rm, rename, mkdir } from "fs/promises";
819
+ import { join as join2 } from "path";
813
820
  import { resolve as resolvePath } from "path";
814
821
  import { join } from "path";
815
822
  import { dirname as dirname2, resolve as resolve4 } from "path";
816
- import { existsSync as existsSync3 } from "fs";
817
- import { mkdir, rm } from "fs/promises";
818
- import { createServer } from "net";
819
- import { homedir as homedir3 } from "os";
820
- import { dirname as dirname22, join as join2, resolve as resolve22 } from "path";
821
- import { mkdir as mkdir3, rm as rm3, writeFile } from "fs/promises";
822
- import { homedir as homedir22, tmpdir } from "os";
823
- import { join as join4 } from "path";
823
+ import { mkdir as mkdir2, rm as rm2, writeFile } from "fs/promises";
824
+ import { homedir as homedir3, tmpdir } from "os";
825
+ import { join as join3 } from "path";
824
826
  function generatePrepareCloudInit(opts) {
825
827
  const pubkey = opts.sshPubkey.trim();
826
828
  return [
@@ -1013,8 +1015,8 @@ async function mintPrepareKey() {
1013
1015
  ...key,
1014
1016
  cleanup: async () => {
1015
1017
  try {
1016
- const { rm: rm4 } = await import("fs/promises");
1017
- await rm4(dirname2(key.privatePath), { recursive: true, force: true });
1018
+ const { rm: rm3 } = await import("fs/promises");
1019
+ await rm3(dirname2(key.privatePath), { recursive: true, force: true });
1018
1020
  } catch {
1019
1021
  }
1020
1022
  }
@@ -1027,105 +1029,6 @@ function homedirOrCwd() {
1027
1029
  return process.cwd();
1028
1030
  }
1029
1031
  }
1030
- function sshOptArgs(target) {
1031
- const out = [
1032
- "-i",
1033
- target.identity,
1034
- "-o",
1035
- "StrictHostKeyChecking=accept-new",
1036
- "-o",
1037
- `UserKnownHostsFile=${target.knownHosts}`,
1038
- "-o",
1039
- "GlobalKnownHostsFile=/dev/null",
1040
- "-o",
1041
- "BatchMode=yes",
1042
- "-o",
1043
- "LogLevel=ERROR"
1044
- ];
1045
- if (target.controlPath) {
1046
- out.push("-o", `ControlPath=${target.controlPath}`);
1047
- }
1048
- for (const [k, v2] of Object.entries(target.options ?? {})) {
1049
- out.push("-o", `${k}=${v2}`);
1050
- }
1051
- return out;
1052
- }
1053
- async function sshExec(target, remoteCmd, opts = {}) {
1054
- const argv = [
1055
- ...sshOptArgs(target),
1056
- `${target.user}@${target.host}`,
1057
- remoteCmd
1058
- ];
1059
- const child = execa("ssh", argv, {
1060
- reject: false,
1061
- timeout: opts.timeoutMs,
1062
- env: { ...process.env, ...opts.env },
1063
- stdio: opts.onLine ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe"]
1064
- });
1065
- if (opts.onLine) {
1066
- const handle = (chunk) => {
1067
- const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
1068
- for (const line of text.split(/\r?\n/)) {
1069
- if (line.length > 0) opts.onLine?.(line);
1070
- }
1071
- };
1072
- child.stdout?.on("data", handle);
1073
- child.stderr?.on("data", handle);
1074
- }
1075
- const res = await child;
1076
- return {
1077
- exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
1078
- stdout: typeof res.stdout === "string" ? res.stdout : "",
1079
- stderr: typeof res.stderr === "string" ? res.stderr : ""
1080
- };
1081
- }
1082
- async function scpUpload(target, localPath, remotePath, opts = {}) {
1083
- const argv = [
1084
- ...sshOptArgs(target),
1085
- localPath,
1086
- `${target.user}@${target.host}:${remotePath}`
1087
- ];
1088
- const res = await execa("scp", argv, {
1089
- reject: false,
1090
- timeout: opts.timeoutMs
1091
- });
1092
- if (res.exitCode !== 0) {
1093
- throw new Error(
1094
- `scp upload failed (exit ${String(res.exitCode)}): ${localPath} \u2192 ${remotePath}
1095
- ${res.stderr ?? ""}`
1096
- );
1097
- }
1098
- }
1099
- async function scpDownload(target, remotePath, localPath, opts = {}) {
1100
- const argv = [
1101
- ...sshOptArgs(target),
1102
- `${target.user}@${target.host}:${remotePath}`,
1103
- localPath
1104
- ];
1105
- const res = await execa("scp", argv, {
1106
- reject: false,
1107
- timeout: opts.timeoutMs
1108
- });
1109
- if (res.exitCode !== 0) {
1110
- throw new Error(
1111
- `scp download failed (exit ${String(res.exitCode)}): ${remotePath} \u2192 ${localPath}
1112
- ${res.stderr ?? ""}`
1113
- );
1114
- }
1115
- }
1116
- async function waitForSsh(target, deadlineMs, intervalMs = 5e3) {
1117
- const stop = Date.now() + deadlineMs;
1118
- while (Date.now() < stop) {
1119
- const res = await sshExec(
1120
- { ...target, options: { ...target.options, ConnectTimeout: "5" } },
1121
- "true",
1122
- { timeoutMs: 1e4 }
1123
- );
1124
- if (res.exitCode === 0) return true;
1125
- await new Promise((r) => setTimeout(r, intervalMs));
1126
- }
1127
- return false;
1128
- }
1129
1032
  var TEMP_SERVER_TYPE_DEFAULT = "cx23";
1130
1033
  var TEMP_SERVER_LOCATION_DEFAULT = "nbg1";
1131
1034
  var PREPARE_SSH_DEADLINE_MS = 5 * 6e4;
@@ -1393,238 +1296,6 @@ async function ensureHetznerBaseSnapshot() {
1393
1296
  "no Hetzner base snapshot found.\nRun `agentbox prepare --provider hetzner` first (Hetzner cannot build images from a Dockerfile,\nso the base snapshot is a one-time prerequisite for cloud boxes on this backend)."
1394
1297
  );
1395
1298
  }
1396
- var HOST = "127.0.0.1";
1397
- var EPHEMERAL_MIN = 49152;
1398
- var EPHEMERAL_MAX = 65535;
1399
- var SshTunnelManager = class {
1400
- boxes = /* @__PURE__ */ new Map();
1401
- /**
1402
- * Open the ControlMaster for `boxId`. Idempotent: if a master is already
1403
- * up for this box (socket exists + responsive), no-op. Otherwise spawn a
1404
- * fresh `ssh -fNT -M` and wait for the socket to appear.
1405
- */
1406
- async open(opts) {
1407
- const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
1408
- await mkdir(boxSshDir, { recursive: true, mode: 448 });
1409
- const controlPath = join2(boxSshDir, "control.sock");
1410
- const knownHosts = join2(boxSshDir, "known_hosts");
1411
- const user = opts.vpsUser ?? "vscode";
1412
- const tunnel = {
1413
- controlPath,
1414
- vpsHost: opts.vpsHost,
1415
- vpsUser: user,
1416
- identity: opts.identity,
1417
- boxSshDir,
1418
- forwards: /* @__PURE__ */ new Map()
1419
- };
1420
- if (existsSync3(controlPath) && await this.isAlive(controlPath)) {
1421
- this.boxes.set(opts.boxId, tunnel);
1422
- return;
1423
- }
1424
- if (existsSync3(controlPath)) {
1425
- await rm(controlPath, { force: true });
1426
- }
1427
- const connectTimeout = opts.connectTimeoutSeconds ?? 10;
1428
- const argv = [
1429
- "-fNT",
1430
- "-M",
1431
- "-S",
1432
- controlPath,
1433
- "-i",
1434
- opts.identity,
1435
- "-o",
1436
- "StrictHostKeyChecking=accept-new",
1437
- "-o",
1438
- `UserKnownHostsFile=${knownHosts}`,
1439
- "-o",
1440
- "GlobalKnownHostsFile=/dev/null",
1441
- "-o",
1442
- "BatchMode=yes",
1443
- "-o",
1444
- "LogLevel=ERROR",
1445
- "-o",
1446
- "ExitOnForwardFailure=yes",
1447
- "-o",
1448
- "ServerAliveInterval=30",
1449
- "-o",
1450
- "ServerAliveCountMax=3",
1451
- "-o",
1452
- `ConnectTimeout=${String(connectTimeout)}`,
1453
- `${user}@${opts.vpsHost}`
1454
- ];
1455
- const res = await execa("ssh", argv, { reject: false });
1456
- if (res.exitCode !== 0 || !existsSync3(controlPath)) {
1457
- throw new Error(
1458
- `ssh ControlMaster failed for ${opts.boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1459
- );
1460
- }
1461
- this.boxes.set(opts.boxId, tunnel);
1462
- }
1463
- /**
1464
- * Mint (or fetch the cached) `127.0.0.1:<localPort> → vps:127.0.0.1:<remotePort>`
1465
- * forward. Returns the local port. Idempotent per (boxId, remotePort).
1466
- *
1467
- * The cached entry is only returned when the underlying ControlMaster is
1468
- * still alive — without that check we'd happily hand back a localPort that
1469
- * stopped listening when the master died (e.g. transient network blip,
1470
- * host sleep/wake). When the master is dead we drop ALL cached forwards
1471
- * for this box (they all share one tunnel) and re-mint from scratch.
1472
- */
1473
- async forward(boxId, remotePort) {
1474
- const tunnel = this.getTunnelOrThrow(boxId);
1475
- const cached = tunnel.forwards.get(remotePort);
1476
- if (cached !== void 0 && await this.isAlive(tunnel.controlPath)) {
1477
- return cached;
1478
- }
1479
- if (cached !== void 0) {
1480
- tunnel.forwards.clear();
1481
- }
1482
- const localPort = await pickFreePort();
1483
- const argv = [
1484
- "-O",
1485
- "forward",
1486
- "-L",
1487
- `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1488
- "-S",
1489
- tunnel.controlPath,
1490
- "dummy"
1491
- // the target host is ignored when -O is used, but argv needs one
1492
- ];
1493
- const res = await execa("ssh", argv, { reject: false });
1494
- if (res.exitCode !== 0) {
1495
- throw new Error(
1496
- `ssh -O forward failed for ${boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1497
- );
1498
- }
1499
- tunnel.forwards.set(remotePort, localPort);
1500
- return localPort;
1501
- }
1502
- /**
1503
- * Tear down a dead ControlMaster + every cached forward for this box,
1504
- * then re-open from scratch. Idempotent — if the master is already alive
1505
- * the master open() is a no-op, but the cached forwards still get
1506
- * cleared so the next forward() call re-mints them. Returns when the
1507
- * master is open and the box's forwards map is empty (ready for fresh
1508
- * forward() calls).
1509
- *
1510
- * Use case: the cloud-poller observes ECONNREFUSED on the local port and
1511
- * asks the backend to refresh the preview URL — that path calls into
1512
- * here so the master + forward both come back fresh.
1513
- */
1514
- async refresh(opts) {
1515
- const existing = this.boxes.get(opts.boxId);
1516
- if (existing) {
1517
- const alive = await this.isAlive(existing.controlPath);
1518
- if (!alive && existsSync3(existing.controlPath)) {
1519
- try {
1520
- await execa(
1521
- "ssh",
1522
- ["-O", "exit", "-S", existing.controlPath, "dummy"],
1523
- { reject: false }
1524
- );
1525
- } catch {
1526
- }
1527
- await rm(existing.controlPath, { force: true });
1528
- }
1529
- existing.forwards.clear();
1530
- }
1531
- await this.open(opts);
1532
- }
1533
- /** Tear down a single forward. Idempotent — unknown ports are no-ops. */
1534
- async unforward(boxId, remotePort) {
1535
- const tunnel = this.getTunnelOrThrow(boxId);
1536
- const localPort = tunnel.forwards.get(remotePort);
1537
- if (localPort === void 0) return;
1538
- const argv = [
1539
- "-O",
1540
- "cancel",
1541
- "-L",
1542
- `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1543
- "-S",
1544
- tunnel.controlPath,
1545
- "dummy"
1546
- ];
1547
- await execa("ssh", argv, { reject: false });
1548
- tunnel.forwards.delete(remotePort);
1549
- }
1550
- /**
1551
- * Close the ControlMaster (and all its forwards). Idempotent — if no
1552
- * master is recorded, no-op. Removes the socket file.
1553
- */
1554
- async close(boxId) {
1555
- const tunnel = this.boxes.get(boxId);
1556
- if (!tunnel) return;
1557
- if (existsSync3(tunnel.controlPath)) {
1558
- await execa("ssh", ["-O", "exit", "-S", tunnel.controlPath, "dummy"], { reject: false });
1559
- await rm(tunnel.controlPath, { force: true });
1560
- }
1561
- this.boxes.delete(boxId);
1562
- }
1563
- /** Tear down every open box. */
1564
- async closeAll() {
1565
- const ids = Array.from(this.boxes.keys());
1566
- await Promise.all(ids.map((id) => this.close(id)));
1567
- }
1568
- /** Path to the ControlMaster socket for `boxId`, if open. */
1569
- controlPath(boxId) {
1570
- return this.boxes.get(boxId)?.controlPath;
1571
- }
1572
- /** True if a ControlMaster is registered for `boxId` (regardless of liveness). */
1573
- has(boxId) {
1574
- return this.boxes.has(boxId);
1575
- }
1576
- /** Per-box ssh dir (tests use this to verify the layout). */
1577
- boxSshDir(boxId) {
1578
- return this.boxes.get(boxId)?.boxSshDir;
1579
- }
1580
- /** Re-open the manager record for an existing-on-disk control socket. */
1581
- registerExisting(boxId, opts) {
1582
- const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
1583
- this.boxes.set(boxId, {
1584
- controlPath: join2(boxSshDir, "control.sock"),
1585
- vpsHost: opts.vpsHost,
1586
- vpsUser: opts.vpsUser ?? "vscode",
1587
- identity: opts.identity,
1588
- boxSshDir,
1589
- forwards: /* @__PURE__ */ new Map()
1590
- });
1591
- }
1592
- async isAlive(controlPath) {
1593
- const res = await execa("ssh", ["-O", "check", "-S", controlPath, "dummy"], { reject: false });
1594
- return res.exitCode === 0;
1595
- }
1596
- getTunnelOrThrow(boxId) {
1597
- const t = this.boxes.get(boxId);
1598
- if (!t) throw new Error(`no SSH ControlMaster registered for box ${boxId}; call open() first`);
1599
- return t;
1600
- }
1601
- };
1602
- function defaultBoxSshDir(boxId) {
1603
- return resolve22(homedir3(), ".agentbox", "boxes", boxId, "ssh");
1604
- }
1605
- async function pickFreePort() {
1606
- return new Promise((resolveOk, reject) => {
1607
- const srv = createServer();
1608
- srv.unref();
1609
- srv.on("error", reject);
1610
- srv.listen(0, HOST, () => {
1611
- const addr = srv.address();
1612
- if (!addr || typeof addr === "string") {
1613
- srv.close();
1614
- reject(new Error("could not get a free local port"));
1615
- return;
1616
- }
1617
- const port = addr.port;
1618
- srv.close(() => {
1619
- if (port < EPHEMERAL_MIN || port > EPHEMERAL_MAX) {
1620
- resolveOk(port);
1621
- } else {
1622
- resolveOk(port);
1623
- }
1624
- });
1625
- });
1626
- });
1627
- }
1628
1299
  var HETZNER_DEFAULT_BOX_IMAGE_REF = "agentbox-base";
1629
1300
  var SCAFFOLDING_FALLBACK_IMAGE = "agentbox/box:dev";
1630
1301
  var VPS_USER = "vscode";
@@ -1704,12 +1375,12 @@ function perBoxDir(sandboxId) {
1704
1375
  }
1705
1376
  async function ensurePerBoxState(sandboxId) {
1706
1377
  const dir = perBoxDir(sandboxId);
1707
- const sshDir = join3(dir, "ssh");
1708
- await mkdir2(sshDir, { recursive: true, mode: 448 });
1378
+ const sshDir = join2(dir, "ssh");
1379
+ await mkdir(sshDir, { recursive: true, mode: 448 });
1709
1380
  return {
1710
1381
  dir,
1711
- identity: join3(sshDir, "id_ed25519"),
1712
- knownHosts: join3(sshDir, "known_hosts")
1382
+ identity: join2(sshDir, "id_ed25519"),
1383
+ knownHosts: join2(sshDir, "known_hosts")
1713
1384
  };
1714
1385
  }
1715
1386
  function bashScript(s) {
@@ -1778,7 +1449,7 @@ async function ensureLiveTarget(sandboxId) {
1778
1449
  throw new Error(`hetzner: server ${String(id)} has no IPv4 address`);
1779
1450
  }
1780
1451
  const state = await ensurePerBoxState(sandboxId);
1781
- if (!existsSync22(state.identity)) {
1452
+ if (!existsSync3(state.identity)) {
1782
1453
  throw new Error(
1783
1454
  `hetzner: per-box SSH key missing for sandbox ${sandboxId} (expected at ${state.identity}). If this box was created by a different host, you'll need to re-create it on this host.`
1784
1455
  );
@@ -1871,9 +1542,9 @@ var hetznerBackend = {
1871
1542
  const state = await ensurePerBoxState(sandboxId);
1872
1543
  await rename(key.privatePath, state.identity);
1873
1544
  await rename(key.publicPath, `${state.identity}.pub`);
1874
- await rm2(key.dir, { recursive: true, force: true });
1545
+ await rm(key.dir, { recursive: true, force: true });
1875
1546
  const pendingParent = resolvePath(key.dir, "..");
1876
- await rm2(pendingParent, { recursive: true, force: true });
1547
+ await rm(pendingParent, { recursive: true, force: true });
1877
1548
  const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
1878
1549
  if (!up) {
1879
1550
  throw new Error(
@@ -1909,10 +1580,10 @@ var hetznerBackend = {
1909
1580
  }
1910
1581
  }
1911
1582
  try {
1912
- if (existsSync22(key.dir)) await rm2(key.dir, { recursive: true, force: true });
1583
+ if (existsSync3(key.dir)) await rm(key.dir, { recursive: true, force: true });
1913
1584
  if (serverId !== null) {
1914
1585
  const finalDir = perBoxDir(String(serverId));
1915
- if (existsSync22(finalDir)) await rm2(finalDir, { recursive: true, force: true });
1586
+ if (existsSync3(finalDir)) await rm(finalDir, { recursive: true, force: true });
1916
1587
  }
1917
1588
  } catch {
1918
1589
  }
@@ -2003,7 +1674,7 @@ var hetznerBackend = {
2003
1674
  }
2004
1675
  const dir = perBoxDir(h.sandboxId);
2005
1676
  try {
2006
- await rm2(dir, { recursive: true, force: true });
1677
+ await rm(dir, { recursive: true, force: true });
2007
1678
  } catch {
2008
1679
  }
2009
1680
  },
@@ -2266,9 +1937,9 @@ async function deployControlPlaneToHetzner(opts) {
2266
1937
  labels: { "agentbox.managed": "true", "agentbox.role": "control-plane" }
2267
1938
  })
2268
1939
  );
2269
- const keyDir = join4(homedir22(), ".agentbox", "control-plane", "ssh", stamp);
1940
+ const keyDir = join3(homedir3(), ".agentbox", "control-plane", "ssh", stamp);
2270
1941
  const key = await mintSshKey(keyDir, `agentbox-control-plane-${stamp}`);
2271
- const knownHosts = join4(keyDir, "known_hosts");
1942
+ const knownHosts = join3(keyDir, "known_hosts");
2272
1943
  log(`provisioning ${opts.serverType ?? "cx23"} VPS (cloning ${repoUrl}@${repoRef})\u2026`);
2273
1944
  const { server } = await withHetznerRetry(
2274
1945
  { method: "createServer", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
@@ -2297,12 +1968,12 @@ async function deployControlPlaneToHetzner(opts) {
2297
1968
  if (cloned.exitCode !== 0) {
2298
1969
  throw new Error("repo clone did not complete on the VPS (cloud-init failed)");
2299
1970
  }
2300
- const staging = join4(tmpdir(), `agentbox-cp-deploy-${stamp}`);
2301
- await mkdir3(staging, { recursive: true });
1971
+ const staging = join3(tmpdir(), `agentbox-cp-deploy-${stamp}`);
1972
+ await mkdir2(staging, { recursive: true });
2302
1973
  try {
2303
- const envLocal = join4(staging, "control-plane.env");
2304
- const caddyLocal = join4(staging, "Caddyfile");
2305
- const composeLocal = join4(staging, "docker-compose.caddy.yml");
1974
+ const envLocal = join3(staging, "control-plane.env");
1975
+ const caddyLocal = join3(staging, "Caddyfile");
1976
+ const composeLocal = join3(staging, "docker-compose.caddy.yml");
2306
1977
  await writeFile(envLocal, opts.envContent, { mode: 384 });
2307
1978
  await writeFile(caddyLocal, caddyfile(domain));
2308
1979
  await writeFile(composeLocal, CADDY_COMPOSE);
@@ -2311,7 +1982,7 @@ async function deployControlPlaneToHetzner(opts) {
2311
1982
  await scpUpload(target, caddyLocal, `${REMOTE_APP_DIR}/Caddyfile`);
2312
1983
  await scpUpload(target, composeLocal, `${REMOTE_APP_DIR}/docker-compose.caddy.yml`);
2313
1984
  } finally {
2314
- await rm3(staging, { recursive: true, force: true });
1985
+ await rm2(staging, { recursive: true, force: true });
2315
1986
  }
2316
1987
  log("building + starting the control plane (docker compose up --build)\u2026");
2317
1988
  const up = await sshExec(
@@ -225,7 +225,7 @@ import {
225
225
  vscodeServerVolumeName,
226
226
  waitForTmuxPaneContent,
227
227
  warmUpClaudeCredentials
228
- } from "./chunk-MA73PTOR.js";
228
+ } from "./chunk-XZZXPEVV.js";
229
229
  import "./chunk-3LAHFDJF.js";
230
230
  import {
231
231
  AmbiguousBoxError,
@@ -234,9 +234,11 @@ import {
234
234
  BOX_IMAGE_REGISTRY,
235
235
  BOX_MEMORY_DIR,
236
236
  BOX_WORKFLOWS_DIR,
237
+ BUILD_CONTEXT_DIR,
237
238
  BoxNotFoundError,
238
239
  DEFAULT_BOX_IMAGE,
239
240
  DEFAULT_ENV_PATTERNS,
241
+ DOCKERFILE_PATH,
240
242
  GitWorktreeError,
241
243
  STATE_DIR,
242
244
  STATE_FILE,
@@ -274,9 +276,9 @@ import {
274
276
  stageDynamicSyncTarball,
275
277
  tagImage,
276
278
  writePreparedDockerState
277
- } from "./chunk-LNHPLR3L.js";
279
+ } from "./chunk-4QY2VZCF.js";
278
280
  import "./chunk-UDZ3VXRF.js";
279
- import "./chunk-V3OMPMI3.js";
281
+ import "./chunk-QSMPSV5Z.js";
280
282
  import "./chunk-OG4KH2FZ.js";
281
283
  export {
282
284
  AmbiguousBoxError,
@@ -287,6 +289,7 @@ export {
287
289
  BOX_MEMORY_DIR,
288
290
  BOX_SYSTEM_PROMPT_PATH,
289
291
  BOX_WORKFLOWS_DIR,
292
+ BUILD_CONTEXT_DIR,
290
293
  BoxNotFoundError,
291
294
  CHECKPOINTS_ROOT,
292
295
  CHECKPOINT_IMAGE_PREFIX,
@@ -307,6 +310,7 @@ export {
307
310
  DEFAULT_OPENCODE_SESSION,
308
311
  DEFAULT_RELAY_PORT,
309
312
  DEFAULT_SHELL_SESSION,
313
+ DOCKERFILE_PATH,
310
314
  EXCLUDE_DIRS,
311
315
  ExportError,
312
316
  GitWorktreeError,
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __cr } from 'node:module'; import { fileURLToPath as __f } from 'node:url'; import { dirname as __d } from 'node:path'; const require = __cr(import.meta.url); const __filename = __f(import.meta.url); const __dirname = __d(__filename);
2
2
  import {
3
3
  AUTH_TOKEN_PATH
4
- } from "./chunk-JLG5JJXD.js";
5
- import "./chunk-V3OMPMI3.js";
4
+ } from "./chunk-3FJNKSNZ.js";
5
+ import "./chunk-QSMPSV5Z.js";
6
6
  import "./chunk-OG4KH2FZ.js";
7
7
 
8
8
  // lib/hub-token.ts
@@ -27,6 +27,7 @@
27
27
  "@agentbox/sandbox-core": "workspace:*",
28
28
  "@agentbox/sandbox-daytona": "workspace:*",
29
29
  "@agentbox/sandbox-digitalocean": "workspace:*",
30
+ "@agentbox/sandbox-remote-docker": "workspace:*",
30
31
  "@agentbox/sandbox-docker": "workspace:*",
31
32
  "@agentbox/sandbox-e2b": "workspace:*",
32
33
  "@agentbox/sandbox-hetzner": "workspace:*",
@@ -6,7 +6,7 @@ import {
6
6
  readPreparedDockerState,
7
7
  resolveContextFiles,
8
8
  writePreparedDockerState
9
- } from "./chunk-LNHPLR3L.js";
9
+ } from "./chunk-4QY2VZCF.js";
10
10
  import "./chunk-UDZ3VXRF.js";
11
11
  import "./chunk-OG4KH2FZ.js";
12
12
  export {