@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
@@ -13,16 +13,18 @@ import {
13
13
  } from "./chunk-CKBHQ7OI.js";
14
14
  import {
15
15
  createCloudProvider
16
- } from "./chunk-QBJOF5D3.js";
16
+ } from "./chunk-BARD2DI6.js";
17
17
  import {
18
18
  detectPortless,
19
19
  portlessDoctorRow
20
- } from "./chunk-MA73PTOR.js";
20
+ } from "./chunk-XZZXPEVV.js";
21
21
  import "./chunk-3LAHFDJF.js";
22
22
  import {
23
+ SshTunnelManager,
23
24
  UserFacingError,
24
25
  claudeInstallFingerprint,
25
26
  computeContextSha256,
27
+ defaultBoxSshDir,
26
28
  describeInbound,
27
29
  errSummary,
28
30
  hostOpenCommand,
@@ -32,12 +34,17 @@ import {
32
34
  readCliStamp,
33
35
  readPreparedStateRaw,
34
36
  resolveInboundSources,
37
+ scpDownload,
38
+ scpUpload,
39
+ sshExec,
40
+ sshOptArgs,
35
41
  stageAgentsStaticForUpload,
36
42
  stageClaudeStaticForUpload,
37
43
  stageCodexStaticForUpload,
38
44
  stageOpencodeStaticForUpload,
45
+ waitForSsh,
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";
@@ -45,7 +52,7 @@ import {
45
52
  loadEffectiveConfig,
46
53
  setConfigValue,
47
54
  unsetConfigValue
48
- } from "./chunk-V3OMPMI3.js";
55
+ } from "./chunk-QSMPSV5Z.js";
49
56
  import "./chunk-OG4KH2FZ.js";
50
57
 
51
58
  // ../../packages/sandbox-digitalocean/dist/chunk-7SUT53X5.js
@@ -980,17 +987,12 @@ async function currentDigitalOceanBaseFingerprintLive(claudeInstall = "native")
980
987
  }
981
988
 
982
989
  // ../../packages/sandbox-digitalocean/dist/index.js
983
- import { existsSync as existsSync22 } from "fs";
984
- import { rm as rm2, rename, mkdir as mkdir2 } from "fs/promises";
985
- import { join as join3 } from "path";
990
+ import { existsSync as existsSync4 } from "fs";
991
+ import { rm, rename, mkdir } from "fs/promises";
992
+ import { join as join2 } from "path";
986
993
  import { resolve as resolvePath } from "path";
987
994
  import { join } from "path";
988
995
  import { dirname as dirname3, resolve as resolve4 } from "path";
989
- import { existsSync as existsSync4 } from "fs";
990
- import { mkdir, rm } from "fs/promises";
991
- import { createServer } from "net";
992
- import { homedir as homedir3 } from "os";
993
- import { dirname as dirname22, join as join2, resolve as resolve22 } from "path";
994
996
  function generatePrepareCloudInit(opts) {
995
997
  const pubkey = opts.sshPubkey.trim();
996
998
  return [
@@ -1094,8 +1096,8 @@ async function mintPrepareKey() {
1094
1096
  ...key,
1095
1097
  cleanup: async () => {
1096
1098
  try {
1097
- const { rm: rm3 } = await import("fs/promises");
1098
- await rm3(dirname3(key.privatePath), { recursive: true, force: true });
1099
+ const { rm: rm2 } = await import("fs/promises");
1100
+ await rm2(dirname3(key.privatePath), { recursive: true, force: true });
1099
1101
  } catch {
1100
1102
  }
1101
1103
  }
@@ -1108,115 +1110,6 @@ function homedirOrCwd() {
1108
1110
  return process.cwd();
1109
1111
  }
1110
1112
  }
1111
- function sshOptArgs(target) {
1112
- const out = [
1113
- "-i",
1114
- target.identity,
1115
- "-o",
1116
- "StrictHostKeyChecking=accept-new",
1117
- "-o",
1118
- `UserKnownHostsFile=${target.knownHosts}`,
1119
- "-o",
1120
- "GlobalKnownHostsFile=/dev/null",
1121
- "-o",
1122
- "BatchMode=yes",
1123
- "-o",
1124
- "LogLevel=ERROR",
1125
- // Detect a dead/stalled peer and drop the connection instead of hanging
1126
- // forever. The per-box firewall is locked to the host's egress IP, so if
1127
- // that IP flaps mid-command (roaming Wi-Fi, VPN toggle) the return traffic
1128
- // is silently dropped and the ssh channel would otherwise block with no
1129
- // EOF — seen as a `prepare`/`exec` that never returns. 15s * 4 = a ~60s
1130
- // fail-fast so callers (retry wrappers, prepare cleanup) can react.
1131
- "-o",
1132
- "ServerAliveInterval=15",
1133
- "-o",
1134
- "ServerAliveCountMax=4"
1135
- ];
1136
- if (target.controlPath) {
1137
- out.push("-o", `ControlPath=${target.controlPath}`);
1138
- }
1139
- for (const [k, v2] of Object.entries(target.options ?? {})) {
1140
- out.push("-o", `${k}=${v2}`);
1141
- }
1142
- return out;
1143
- }
1144
- async function sshExec(target, remoteCmd, opts = {}) {
1145
- const argv = [
1146
- ...sshOptArgs(target),
1147
- `${target.user}@${target.host}`,
1148
- remoteCmd
1149
- ];
1150
- const child = execa("ssh", argv, {
1151
- reject: false,
1152
- timeout: opts.timeoutMs,
1153
- env: { ...process.env, ...opts.env },
1154
- stdio: opts.onLine ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe"]
1155
- });
1156
- if (opts.onLine) {
1157
- const handle = (chunk) => {
1158
- const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
1159
- for (const line of text.split(/\r?\n/)) {
1160
- if (line.length > 0) opts.onLine?.(line);
1161
- }
1162
- };
1163
- child.stdout?.on("data", handle);
1164
- child.stderr?.on("data", handle);
1165
- }
1166
- const res = await child;
1167
- return {
1168
- exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
1169
- stdout: typeof res.stdout === "string" ? res.stdout : "",
1170
- stderr: typeof res.stderr === "string" ? res.stderr : ""
1171
- };
1172
- }
1173
- async function scpUpload(target, localPath, remotePath, opts = {}) {
1174
- const argv = [
1175
- ...sshOptArgs(target),
1176
- localPath,
1177
- `${target.user}@${target.host}:${remotePath}`
1178
- ];
1179
- const res = await execa("scp", argv, {
1180
- reject: false,
1181
- timeout: opts.timeoutMs
1182
- });
1183
- if (res.exitCode !== 0) {
1184
- throw new Error(
1185
- `scp upload failed (exit ${String(res.exitCode)}): ${localPath} \u2192 ${remotePath}
1186
- ${res.stderr ?? ""}`
1187
- );
1188
- }
1189
- }
1190
- async function scpDownload(target, remotePath, localPath, opts = {}) {
1191
- const argv = [
1192
- ...sshOptArgs(target),
1193
- `${target.user}@${target.host}:${remotePath}`,
1194
- localPath
1195
- ];
1196
- const res = await execa("scp", argv, {
1197
- reject: false,
1198
- timeout: opts.timeoutMs
1199
- });
1200
- if (res.exitCode !== 0) {
1201
- throw new Error(
1202
- `scp download failed (exit ${String(res.exitCode)}): ${remotePath} \u2192 ${localPath}
1203
- ${res.stderr ?? ""}`
1204
- );
1205
- }
1206
- }
1207
- async function waitForSsh(target, deadlineMs, intervalMs = 5e3) {
1208
- const stop = Date.now() + deadlineMs;
1209
- while (Date.now() < stop) {
1210
- const res = await sshExec(
1211
- { ...target, options: { ...target.options, ConnectTimeout: "5" } },
1212
- "true",
1213
- { timeoutMs: 1e4 }
1214
- );
1215
- if (res.exitCode === 0) return true;
1216
- await new Promise((r) => setTimeout(r, intervalMs));
1217
- }
1218
- return false;
1219
- }
1220
1113
  var TEMP_SIZE_DEFAULT = "s-2vcpu-4gb";
1221
1114
  var TEMP_REGION_DEFAULT = "nyc3";
1222
1115
  var STOCK_IMAGE_SLUG = "ubuntu-24-04-x64";
@@ -1485,238 +1378,15 @@ async function ensureDigitalOceanBaseSnapshot() {
1485
1378
  "no DigitalOcean base snapshot found.\nRun `agentbox prepare --provider digitalocean` first (DigitalOcean cannot build images from a Dockerfile,\nso the base snapshot is a one-time prerequisite for cloud boxes on this backend)."
1486
1379
  );
1487
1380
  }
1488
- var HOST = "127.0.0.1";
1489
- var EPHEMERAL_MIN = 49152;
1490
- var EPHEMERAL_MAX = 65535;
1491
- var SshTunnelManager = class {
1492
- boxes = /* @__PURE__ */ new Map();
1493
- /**
1494
- * Open the ControlMaster for `boxId`. Idempotent: if a master is already
1495
- * up for this box (socket exists + responsive), no-op. Otherwise spawn a
1496
- * fresh `ssh -fNT -M` and wait for the socket to appear.
1497
- */
1498
- async open(opts) {
1499
- const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
1500
- await mkdir(boxSshDir, { recursive: true, mode: 448 });
1501
- const controlPath = join2(boxSshDir, "control.sock");
1502
- const knownHosts = join2(boxSshDir, "known_hosts");
1503
- const user = opts.vpsUser ?? "vscode";
1504
- const tunnel = {
1505
- controlPath,
1506
- vpsHost: opts.vpsHost,
1507
- vpsUser: user,
1508
- identity: opts.identity,
1509
- boxSshDir,
1510
- forwards: /* @__PURE__ */ new Map()
1511
- };
1512
- if (existsSync4(controlPath) && await this.isAlive(controlPath)) {
1513
- this.boxes.set(opts.boxId, tunnel);
1514
- return;
1515
- }
1516
- if (existsSync4(controlPath)) {
1517
- await rm(controlPath, { force: true });
1518
- }
1519
- const connectTimeout = opts.connectTimeoutSeconds ?? 10;
1520
- const argv = [
1521
- "-fNT",
1522
- "-M",
1523
- "-S",
1524
- controlPath,
1525
- "-i",
1526
- opts.identity,
1527
- "-o",
1528
- "StrictHostKeyChecking=accept-new",
1529
- "-o",
1530
- `UserKnownHostsFile=${knownHosts}`,
1531
- "-o",
1532
- "GlobalKnownHostsFile=/dev/null",
1533
- "-o",
1534
- "BatchMode=yes",
1535
- "-o",
1536
- "LogLevel=ERROR",
1537
- "-o",
1538
- "ExitOnForwardFailure=yes",
1539
- "-o",
1540
- "ServerAliveInterval=30",
1541
- "-o",
1542
- "ServerAliveCountMax=3",
1543
- "-o",
1544
- `ConnectTimeout=${String(connectTimeout)}`,
1545
- `${user}@${opts.vpsHost}`
1546
- ];
1547
- const res = await execa("ssh", argv, { reject: false });
1548
- if (res.exitCode !== 0 || !existsSync4(controlPath)) {
1549
- throw new Error(
1550
- `ssh ControlMaster failed for ${opts.boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1551
- );
1552
- }
1553
- this.boxes.set(opts.boxId, tunnel);
1554
- }
1555
- /**
1556
- * Mint (or fetch the cached) `127.0.0.1:<localPort> → vps:127.0.0.1:<remotePort>`
1557
- * forward. Returns the local port. Idempotent per (boxId, remotePort).
1558
- *
1559
- * The cached entry is only returned when the underlying ControlMaster is
1560
- * still alive — without that check we'd happily hand back a localPort that
1561
- * stopped listening when the master died (e.g. transient network blip,
1562
- * host sleep/wake). When the master is dead we drop ALL cached forwards
1563
- * for this box (they all share one tunnel) and re-mint from scratch.
1564
- */
1565
- async forward(boxId, remotePort) {
1566
- const tunnel = this.getTunnelOrThrow(boxId);
1567
- const cached = tunnel.forwards.get(remotePort);
1568
- if (cached !== void 0 && await this.isAlive(tunnel.controlPath)) {
1569
- return cached;
1570
- }
1571
- if (cached !== void 0) {
1572
- tunnel.forwards.clear();
1573
- }
1574
- const localPort = await pickFreePort();
1575
- const argv = [
1576
- "-O",
1577
- "forward",
1578
- "-L",
1579
- `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1580
- "-S",
1581
- tunnel.controlPath,
1582
- "dummy"
1583
- // the target host is ignored when -O is used, but argv needs one
1584
- ];
1585
- const res = await execa("ssh", argv, { reject: false });
1586
- if (res.exitCode !== 0) {
1587
- throw new Error(
1588
- `ssh -O forward failed for ${boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
1589
- );
1590
- }
1591
- tunnel.forwards.set(remotePort, localPort);
1592
- return localPort;
1593
- }
1594
- /**
1595
- * Tear down a dead ControlMaster + every cached forward for this box,
1596
- * then re-open from scratch. Idempotent — if the master is already alive
1597
- * the master open() is a no-op, but the cached forwards still get
1598
- * cleared so the next forward() call re-mints them. Returns when the
1599
- * master is open and the box's forwards map is empty (ready for fresh
1600
- * forward() calls).
1601
- *
1602
- * Use case: the cloud-poller observes ECONNREFUSED on the local port and
1603
- * asks the backend to refresh the preview URL — that path calls into
1604
- * here so the master + forward both come back fresh.
1605
- */
1606
- async refresh(opts) {
1607
- const existing = this.boxes.get(opts.boxId);
1608
- if (existing) {
1609
- const alive = await this.isAlive(existing.controlPath);
1610
- if (!alive && existsSync4(existing.controlPath)) {
1611
- try {
1612
- await execa(
1613
- "ssh",
1614
- ["-O", "exit", "-S", existing.controlPath, "dummy"],
1615
- { reject: false }
1616
- );
1617
- } catch {
1618
- }
1619
- await rm(existing.controlPath, { force: true });
1620
- }
1621
- existing.forwards.clear();
1622
- }
1623
- await this.open(opts);
1624
- }
1625
- /** Tear down a single forward. Idempotent — unknown ports are no-ops. */
1626
- async unforward(boxId, remotePort) {
1627
- const tunnel = this.getTunnelOrThrow(boxId);
1628
- const localPort = tunnel.forwards.get(remotePort);
1629
- if (localPort === void 0) return;
1630
- const argv = [
1631
- "-O",
1632
- "cancel",
1633
- "-L",
1634
- `${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
1635
- "-S",
1636
- tunnel.controlPath,
1637
- "dummy"
1638
- ];
1639
- await execa("ssh", argv, { reject: false });
1640
- tunnel.forwards.delete(remotePort);
1641
- }
1642
- /**
1643
- * Close the ControlMaster (and all its forwards). Idempotent — if no
1644
- * master is recorded, no-op. Removes the socket file.
1645
- */
1646
- async close(boxId) {
1647
- const tunnel = this.boxes.get(boxId);
1648
- if (!tunnel) return;
1649
- if (existsSync4(tunnel.controlPath)) {
1650
- await execa("ssh", ["-O", "exit", "-S", tunnel.controlPath, "dummy"], { reject: false });
1651
- await rm(tunnel.controlPath, { force: true });
1652
- }
1653
- this.boxes.delete(boxId);
1654
- }
1655
- /** Tear down every open box. */
1656
- async closeAll() {
1657
- const ids = Array.from(this.boxes.keys());
1658
- await Promise.all(ids.map((id) => this.close(id)));
1659
- }
1660
- /** Path to the ControlMaster socket for `boxId`, if open. */
1661
- controlPath(boxId) {
1662
- return this.boxes.get(boxId)?.controlPath;
1663
- }
1664
- /** True if a ControlMaster is registered for `boxId` (regardless of liveness). */
1665
- has(boxId) {
1666
- return this.boxes.has(boxId);
1667
- }
1668
- /** Per-box ssh dir (tests use this to verify the layout). */
1669
- boxSshDir(boxId) {
1670
- return this.boxes.get(boxId)?.boxSshDir;
1671
- }
1672
- /** Re-open the manager record for an existing-on-disk control socket. */
1673
- registerExisting(boxId, opts) {
1674
- const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
1675
- this.boxes.set(boxId, {
1676
- controlPath: join2(boxSshDir, "control.sock"),
1677
- vpsHost: opts.vpsHost,
1678
- vpsUser: opts.vpsUser ?? "vscode",
1679
- identity: opts.identity,
1680
- boxSshDir,
1681
- forwards: /* @__PURE__ */ new Map()
1682
- });
1683
- }
1684
- async isAlive(controlPath) {
1685
- const res = await execa("ssh", ["-O", "check", "-S", controlPath, "dummy"], { reject: false });
1686
- return res.exitCode === 0;
1687
- }
1688
- getTunnelOrThrow(boxId) {
1689
- const t = this.boxes.get(boxId);
1690
- if (!t) throw new Error(`no SSH ControlMaster registered for box ${boxId}; call open() first`);
1691
- return t;
1381
+ var DIGITALOCEAN_SSH_NAMESPACE = "digitalocean";
1382
+ function defaultBoxSshDir2(boxId) {
1383
+ return defaultBoxSshDir(boxId, DIGITALOCEAN_SSH_NAMESPACE);
1384
+ }
1385
+ var SshTunnelManager2 = class extends SshTunnelManager {
1386
+ constructor() {
1387
+ super(DIGITALOCEAN_SSH_NAMESPACE);
1692
1388
  }
1693
1389
  };
1694
- function defaultBoxSshDir(boxId) {
1695
- return resolve22(homedir3(), ".agentbox", "digitalocean", "boxes", boxId, "ssh");
1696
- }
1697
- async function pickFreePort() {
1698
- return new Promise((resolveOk, reject) => {
1699
- const srv = createServer();
1700
- srv.unref();
1701
- srv.on("error", reject);
1702
- srv.listen(0, HOST, () => {
1703
- const addr = srv.address();
1704
- if (!addr || typeof addr === "string") {
1705
- srv.close();
1706
- reject(new Error("could not get a free local port"));
1707
- return;
1708
- }
1709
- const port = addr.port;
1710
- srv.close(() => {
1711
- if (port < EPHEMERAL_MIN || port > EPHEMERAL_MAX) {
1712
- resolveOk(port);
1713
- } else {
1714
- resolveOk(port);
1715
- }
1716
- });
1717
- });
1718
- });
1719
- }
1720
1390
  var DIGITALOCEAN_DEFAULT_BOX_IMAGE_REF = "agentbox-base";
1721
1391
  var SCAFFOLDING_FALLBACK_IMAGE = "agentbox/box:dev";
1722
1392
  var VPS_USER = "vscode";
@@ -1740,7 +1410,7 @@ function cloudInitBoxEnv(env = {}) {
1740
1410
  }
1741
1411
  return out;
1742
1412
  }
1743
- var tunnels = new SshTunnelManager();
1413
+ var tunnels = new SshTunnelManager2();
1744
1414
  function mapState(s) {
1745
1415
  switch (s) {
1746
1416
  case "active":
@@ -1803,16 +1473,16 @@ async function resolveImageRef(c, req) {
1803
1473
  return ref;
1804
1474
  }
1805
1475
  function perBoxDir(sandboxId) {
1806
- return resolvePath(defaultBoxSshDir(sandboxId), "..");
1476
+ return resolvePath(defaultBoxSshDir2(sandboxId), "..");
1807
1477
  }
1808
1478
  async function ensurePerBoxState(sandboxId) {
1809
1479
  const dir = perBoxDir(sandboxId);
1810
- const sshDir = join3(dir, "ssh");
1811
- await mkdir2(sshDir, { recursive: true, mode: 448 });
1480
+ const sshDir = join2(dir, "ssh");
1481
+ await mkdir(sshDir, { recursive: true, mode: 448 });
1812
1482
  return {
1813
1483
  dir,
1814
- identity: join3(sshDir, "id_ed25519"),
1815
- knownHosts: join3(sshDir, "known_hosts")
1484
+ identity: join2(sshDir, "id_ed25519"),
1485
+ knownHosts: join2(sshDir, "known_hosts")
1816
1486
  };
1817
1487
  }
1818
1488
  function bashScript(s) {
@@ -1849,7 +1519,7 @@ async function ensureLiveTarget(sandboxId) {
1849
1519
  throw new Error(`digitalocean: droplet ${String(id)} has no public IPv4 address`);
1850
1520
  }
1851
1521
  const state = await ensurePerBoxState(sandboxId);
1852
- if (!existsSync22(state.identity)) {
1522
+ if (!existsSync4(state.identity)) {
1853
1523
  throw new Error(
1854
1524
  `digitalocean: 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.`
1855
1525
  );
@@ -1956,9 +1626,9 @@ var digitaloceanBackend = {
1956
1626
  const state = await ensurePerBoxState(sandboxId);
1957
1627
  await rename(key.privatePath, state.identity);
1958
1628
  await rename(key.publicPath, `${state.identity}.pub`);
1959
- await rm2(key.dir, { recursive: true, force: true });
1629
+ await rm(key.dir, { recursive: true, force: true });
1960
1630
  const pendingParent = resolvePath(key.dir, "..");
1961
- await rm2(pendingParent, { recursive: true, force: true });
1631
+ await rm(pendingParent, { recursive: true, force: true });
1962
1632
  const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
1963
1633
  if (!up) {
1964
1634
  throw new Error(
@@ -1994,10 +1664,10 @@ var digitaloceanBackend = {
1994
1664
  }
1995
1665
  }
1996
1666
  try {
1997
- if (existsSync22(key.dir)) await rm2(key.dir, { recursive: true, force: true });
1667
+ if (existsSync4(key.dir)) await rm(key.dir, { recursive: true, force: true });
1998
1668
  if (dropletId !== null) {
1999
1669
  const finalDir = perBoxDir(String(dropletId));
2000
- if (existsSync22(finalDir)) await rm2(finalDir, { recursive: true, force: true });
1670
+ if (existsSync4(finalDir)) await rm(finalDir, { recursive: true, force: true });
2001
1671
  }
2002
1672
  } catch {
2003
1673
  }
@@ -2122,7 +1792,7 @@ var digitaloceanBackend = {
2122
1792
  }
2123
1793
  const dir = perBoxDir(h.sandboxId);
2124
1794
  try {
2125
- await rm2(dir, { recursive: true, force: true });
1795
+ await rm(dir, { recursive: true, force: true });
2126
1796
  } catch {
2127
1797
  }
2128
1798
  },
@@ -20,8 +20,8 @@ import {
20
20
  resolveCloudCheckpoint,
21
21
  seedAgentStaticIntoCloudBox,
22
22
  writeCloudCheckpointManifest
23
- } from "./chunk-QBJOF5D3.js";
24
- import "./chunk-MA73PTOR.js";
23
+ } from "./chunk-BARD2DI6.js";
24
+ import "./chunk-XZZXPEVV.js";
25
25
  import "./chunk-3LAHFDJF.js";
26
26
  import {
27
27
  BOX_IMAGE_REGISTRY,
@@ -37,13 +37,13 @@ import {
37
37
  stageAllAgentStatic,
38
38
  writeManagedSecrets,
39
39
  writePreparedStateRaw
40
- } from "./chunk-LNHPLR3L.js";
40
+ } from "./chunk-4QY2VZCF.js";
41
41
  import "./chunk-UDZ3VXRF.js";
42
42
  import {
43
43
  DAYTONA_VM_REGION,
44
44
  loadEffectiveConfig,
45
45
  resolveDaytonaClass
46
- } from "./chunk-V3OMPMI3.js";
46
+ } from "./chunk-QSMPSV5Z.js";
47
47
  import {
48
48
  Daytona,
49
49
  DaytonaAuthenticationError,
@@ -1442,7 +1442,40 @@ function writeNpmDockerfile(originalPath) {
1442
1442
  function isAgentboxName(name) {
1443
1443
  return typeof name === "string" && name.toLowerCase().startsWith("agentbox");
1444
1444
  }
1445
- async function getDaytonaStatus() {
1445
+ var STATUS_PROBE_TIMEOUT_MS = 8e3;
1446
+ function withStatusTimeout(p, what) {
1447
+ return new Promise((resolve5, reject) => {
1448
+ const t = setTimeout(
1449
+ () => reject(new Error(`${what} timed out after ${String(STATUS_PROBE_TIMEOUT_MS)}ms`)),
1450
+ STATUS_PROBE_TIMEOUT_MS
1451
+ );
1452
+ t.unref?.();
1453
+ p.then(
1454
+ (v2) => {
1455
+ clearTimeout(t);
1456
+ resolve5(v2);
1457
+ },
1458
+ (e) => {
1459
+ clearTimeout(t);
1460
+ reject(e instanceof Error ? e : new Error(String(e)));
1461
+ }
1462
+ );
1463
+ });
1464
+ }
1465
+ function hasDaytonaCredentials() {
1466
+ try {
1467
+ ensureDaytonaEnvLoaded();
1468
+ getClient();
1469
+ return { configured: true };
1470
+ } catch (err) {
1471
+ return {
1472
+ configured: false,
1473
+ reason: err instanceof Error ? err.message.split("\n")[0] : String(err)
1474
+ };
1475
+ }
1476
+ }
1477
+ async function getDaytonaStatus(opts = {}) {
1478
+ const wantVolumes = opts.volumes !== false;
1446
1479
  try {
1447
1480
  ensureDaytonaEnvLoaded();
1448
1481
  } catch (err) {
@@ -1466,42 +1499,51 @@ async function getDaytonaStatus() {
1466
1499
  }
1467
1500
  const snapshots = [];
1468
1501
  const volumes = [];
1469
- let reason;
1470
- try {
1471
- const list = await client.snapshot.list();
1472
- const items = list.items ?? (Array.isArray(list) ? list : []);
1473
- for (const s of items) {
1474
- const dto = s;
1475
- if (!isAgentboxName(dto.name)) continue;
1476
- snapshots.push({
1477
- name: dto.name,
1478
- state: typeof dto.state === "string" ? dto.state : void 0,
1479
- sizeGb: typeof dto.size === "number" ? dto.size : void 0,
1480
- createdAt: typeof dto.createdAt === "string" ? dto.createdAt : void 0,
1481
- errorReason: typeof dto.errorReason === "string" ? dto.errorReason : void 0
1482
- });
1502
+ const reasons = [];
1503
+ const listSnapshots = async () => {
1504
+ try {
1505
+ const list = await withStatusTimeout(client.snapshot.list(), "snapshot list");
1506
+ const items = list.items ?? (Array.isArray(list) ? list : []);
1507
+ for (const s of items) {
1508
+ const dto = s;
1509
+ if (!isAgentboxName(dto.name)) continue;
1510
+ snapshots.push({
1511
+ name: dto.name,
1512
+ state: typeof dto.state === "string" ? dto.state : void 0,
1513
+ sizeGb: typeof dto.size === "number" ? dto.size : void 0,
1514
+ createdAt: typeof dto.createdAt === "string" ? dto.createdAt : void 0,
1515
+ errorReason: typeof dto.errorReason === "string" ? dto.errorReason : void 0
1516
+ });
1517
+ }
1518
+ } catch (err) {
1519
+ reasons.push(
1520
+ `snapshot list failed: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`
1521
+ );
1483
1522
  }
1484
- } catch (err) {
1485
- reason = `snapshot list failed: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`;
1486
- }
1487
- try {
1488
- const list = await client.volume.list();
1489
- const items = Array.isArray(list) ? list : list.items ?? [];
1490
- for (const v2 of items) {
1491
- const dto = v2;
1492
- if (!isAgentboxName(dto.name)) continue;
1493
- volumes.push({
1494
- name: dto.name,
1495
- id: typeof dto.id === "string" ? dto.id : "",
1496
- state: typeof dto.state === "string" ? dto.state : void 0,
1497
- createdAt: typeof dto.createdAt === "string" ? dto.createdAt : void 0,
1498
- lastUsedAt: typeof dto.lastUsedAt === "string" ? dto.lastUsedAt : void 0
1499
- });
1523
+ };
1524
+ const listVolumes = async () => {
1525
+ try {
1526
+ const list = await withStatusTimeout(client.volume.list(), "volume list");
1527
+ const items = Array.isArray(list) ? list : list.items ?? [];
1528
+ for (const v2 of items) {
1529
+ const dto = v2;
1530
+ if (!isAgentboxName(dto.name)) continue;
1531
+ volumes.push({
1532
+ name: dto.name,
1533
+ id: typeof dto.id === "string" ? dto.id : "",
1534
+ state: typeof dto.state === "string" ? dto.state : void 0,
1535
+ createdAt: typeof dto.createdAt === "string" ? dto.createdAt : void 0,
1536
+ lastUsedAt: typeof dto.lastUsedAt === "string" ? dto.lastUsedAt : void 0
1537
+ });
1538
+ }
1539
+ } catch (err) {
1540
+ reasons.push(
1541
+ `volume list failed: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`
1542
+ );
1500
1543
  }
1501
- } catch (err) {
1502
- const msg = `volume list failed: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`;
1503
- reason = reason ? `${reason}; ${msg}` : msg;
1504
- }
1544
+ };
1545
+ await Promise.all(wantVolumes ? [listSnapshots(), listVolumes()] : [listSnapshots()]);
1546
+ const reason = reasons.length > 0 ? reasons.join("; ") : void 0;
1505
1547
  return {
1506
1548
  configured: true,
1507
1549
  snapshots: snapshots.sort((a, b) => (b.createdAt ?? "").localeCompare(a.createdAt ?? "")),
@@ -1509,13 +1551,12 @@ async function getDaytonaStatus() {
1509
1551
  reason
1510
1552
  };
1511
1553
  }
1512
- async function readCredStatusSummary() {
1513
- const status = await getDaytonaStatus();
1514
- return { configured: status.configured };
1554
+ function readCredStatusSummary() {
1555
+ return { configured: hasDaytonaCredentials().configured };
1515
1556
  }
1516
1557
  async function doctorChecks() {
1517
1558
  try {
1518
- const status = await getDaytonaStatus();
1559
+ const status = await getDaytonaStatus({ volumes: false });
1519
1560
  if (!status.configured) {
1520
1561
  return [
1521
1562
  {