@madarco/agentbox 0.23.5 → 0.24.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 (180) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -2
  4. package/dist/{_cloud-attach-D4OQO5AJ.js → _cloud-attach-T6GPR6LJ.js} +5 -5
  5. package/dist/{chunk-KY32JO6J.js → chunk-5KHEH47T.js} +91 -79
  6. package/dist/chunk-5KHEH47T.js.map +1 -0
  7. package/dist/{chunk-YRTM3KNT.js → chunk-6U2S6QWD.js} +219 -18
  8. package/dist/chunk-6U2S6QWD.js.map +1 -0
  9. package/dist/{chunk-JYEZ6Q5M.js → chunk-DEDTPG2D.js} +874 -146
  10. package/dist/chunk-DEDTPG2D.js.map +1 -0
  11. package/dist/chunk-G3H2L3O2.js +0 -0
  12. package/dist/{chunk-JNY5GPIM.js → chunk-I654PBHA.js} +290 -330
  13. package/dist/chunk-I654PBHA.js.map +1 -0
  14. package/dist/{chunk-6KOQRSHH.js → chunk-K2EDQGZP.js} +18 -4
  15. package/dist/chunk-K2EDQGZP.js.map +1 -0
  16. package/dist/{chunk-KZWJMNLP.js → chunk-LC4E2EIZ.js} +3 -3
  17. package/dist/{chunk-KZWJMNLP.js.map → chunk-LC4E2EIZ.js.map} +1 -1
  18. package/dist/{chunk-DADOEMXP.js → chunk-NACA6AM7.js} +183 -49
  19. package/dist/chunk-NACA6AM7.js.map +1 -0
  20. package/dist/{chunk-FX32NZD4.js → chunk-RYQLFKCP.js} +20 -10
  21. package/dist/chunk-RYQLFKCP.js.map +1 -0
  22. package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
  23. package/dist/chunk-UIRBYL4G.js.map +1 -0
  24. package/dist/chunk-WJFZJZIM.js +0 -0
  25. package/dist/chunk-WLHJZPFJ.js +845 -0
  26. package/dist/chunk-WLHJZPFJ.js.map +1 -0
  27. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  28. package/dist/dist-3KIJ2KQ2.js +1437 -0
  29. package/dist/dist-3KIJ2KQ2.js.map +1 -0
  30. package/dist/{dist-564EDHFF.js → dist-7OUOHQPA.js} +196 -151
  31. package/dist/dist-7OUOHQPA.js.map +1 -0
  32. package/dist/{dist-CAT2TN75.js → dist-B7TNWGVG.js} +8 -4
  33. package/dist/{dist-UDQMBWYW.js → dist-KYV3LEHG.js} +10 -6
  34. package/dist/{dist-EAR4BLL2.js → dist-PHYCFYKH.js} +37 -17
  35. package/dist/dist-PHYCFYKH.js.map +1 -0
  36. package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
  37. package/dist/{dist-O5Y4X4C5.js → dist-Z7KEPQC7.js} +6 -6
  38. package/dist/index.js +2560 -1108
  39. package/dist/index.js.map +1 -1
  40. package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
  41. package/package.json +28 -28
  42. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  43. package/runtime/_shared/agentbox-codex-hooks.json +1 -1
  44. package/runtime/_shared/agentbox-dockerd-start +0 -0
  45. package/runtime/_shared/agentbox-open +0 -0
  46. package/runtime/_shared/agentbox-portless-trust +0 -0
  47. package/runtime/_shared/agentbox-vnc-start +0 -0
  48. package/runtime/_shared/ctl.cjs +468 -97
  49. package/runtime/_shared/gh-shim +0 -0
  50. package/runtime/_shared/git-shim +53 -3
  51. package/runtime/_shared/linear-shim +0 -0
  52. package/runtime/_shared/ntn-shim +0 -0
  53. package/runtime/daytona/custom-system-CLAUDE.md +1 -1
  54. package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
  55. package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
  56. package/runtime/digitalocean/agentbox-dockerd-start +145 -0
  57. package/runtime/digitalocean/agentbox-open +28 -0
  58. package/runtime/digitalocean/agentbox-portless-trust +82 -0
  59. package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
  60. package/runtime/digitalocean/agentbox-vnc-start +102 -0
  61. package/runtime/digitalocean/claude-managed-settings.json +116 -0
  62. package/runtime/digitalocean/ctl.cjs +27852 -0
  63. package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
  64. package/runtime/digitalocean/gh-shim +344 -0
  65. package/runtime/digitalocean/git-shim +181 -0
  66. package/runtime/digitalocean/linear-shim +181 -0
  67. package/runtime/digitalocean/ntn-shim +95 -0
  68. package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
  69. package/runtime/digitalocean/scripts/install-box.sh +462 -0
  70. package/runtime/docker/Dockerfile.box +5 -0
  71. package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
  72. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  73. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
  74. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  75. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  76. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  77. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
  78. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  79. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  80. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
  81. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  82. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
  83. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  84. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  85. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  86. package/runtime/e2b/agentbox-codex-hooks.json +1 -1
  87. package/runtime/e2b/agentbox-dockerd-start +0 -0
  88. package/runtime/e2b/agentbox-open +0 -0
  89. package/runtime/e2b/agentbox-vnc-start +0 -0
  90. package/runtime/e2b/ctl.cjs +468 -97
  91. package/runtime/e2b/custom-system-CLAUDE.md +6 -3
  92. package/runtime/e2b/gh-shim +0 -0
  93. package/runtime/e2b/git-shim +53 -3
  94. package/runtime/e2b/linear-shim +0 -0
  95. package/runtime/e2b/ntn-shim +0 -0
  96. package/runtime/e2b/scripts/build-template.sh +16 -0
  97. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  98. package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
  99. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  100. package/runtime/hetzner/agentbox-open +0 -0
  101. package/runtime/hetzner/agentbox-portless-trust +0 -0
  102. package/runtime/hetzner/agentbox-vnc-start +0 -0
  103. package/runtime/hetzner/ctl.cjs +468 -97
  104. package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
  105. package/runtime/hetzner/gh-shim +0 -0
  106. package/runtime/hetzner/git-shim +53 -3
  107. package/runtime/hetzner/linear-shim +0 -0
  108. package/runtime/hetzner/ntn-shim +0 -0
  109. package/runtime/hetzner/scripts/install-box.sh +5 -0
  110. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  111. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  113. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  115. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  117. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  119. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  120. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
  121. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  122. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
  124. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
  125. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  126. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
  127. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  128. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  129. package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
  130. package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
  131. package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
  132. package/runtime/hub/apps/hub/{chunk-FSEPYTQ6.js → chunk-3VE7AYVK.js} +594 -145
  133. package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
  134. package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
  135. package/runtime/hub/apps/hub/{chunk-7M6FXZIO.js → chunk-FGBXEXUV.js} +350 -292
  136. package/runtime/hub/apps/hub/{chunk-Z7ZAL24C.js → chunk-YVELHPNY.js} +218 -17
  137. package/runtime/hub/apps/hub/{dist-EKQHCXWE.js → dist-33ZNVTC6.js} +183 -49
  138. package/runtime/hub/apps/hub/{dist-V4TJ44MT.js → dist-4SXAJBOC.js} +195 -150
  139. package/runtime/hub/apps/hub/{dist-QIXUPGPP.js → dist-EPJFN2J3.js} +116 -86
  140. package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
  141. package/runtime/hub/apps/hub/{dist-JGZ55OIJ.js → dist-UJVIROA4.js} +19 -5
  142. package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
  143. package/runtime/hub/apps/hub/{dist-GGWYKXJE.js → dist-YM5J25H6.js} +7 -3
  144. package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
  145. package/runtime/hub/apps/hub/package.json +1 -0
  146. package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-UICXTY25.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
  147. package/runtime/hub/apps/hub/server.js +17 -15
  148. package/runtime/relay/bin.cjs +275 -59
  149. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  150. package/runtime/vercel/agentbox-codex-hooks.json +1 -1
  151. package/runtime/vercel/agentbox-dockerd-start +0 -0
  152. package/runtime/vercel/agentbox-open +0 -0
  153. package/runtime/vercel/agentbox-vnc-start +0 -0
  154. package/runtime/vercel/ctl.cjs +468 -97
  155. package/runtime/vercel/custom-system-CLAUDE.md +3 -2
  156. package/runtime/vercel/gh-shim +0 -0
  157. package/runtime/vercel/git-shim +53 -3
  158. package/runtime/vercel/linear-shim +0 -0
  159. package/runtime/vercel/ntn-shim +0 -0
  160. package/runtime/vercel/scripts/provision.sh +16 -0
  161. package/dist/chunk-6KOQRSHH.js.map +0 -1
  162. package/dist/chunk-DADOEMXP.js.map +0 -1
  163. package/dist/chunk-FX32NZD4.js.map +0 -1
  164. package/dist/chunk-JNY5GPIM.js.map +0 -1
  165. package/dist/chunk-JYEZ6Q5M.js.map +0 -1
  166. package/dist/chunk-KY32JO6J.js.map +0 -1
  167. package/dist/chunk-QT3SHMLY.js.map +0 -1
  168. package/dist/chunk-YRTM3KNT.js.map +0 -1
  169. package/dist/dist-564EDHFF.js.map +0 -1
  170. package/dist/dist-EAR4BLL2.js.map +0 -1
  171. package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
  172. /package/dist/{_cloud-attach-D4OQO5AJ.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
  173. /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
  174. /package/dist/{dist-CAT2TN75.js.map → dist-KYV3LEHG.js.map} +0 -0
  175. /package/dist/{dist-O5Y4X4C5.js.map → dist-T5MXBZGP.js.map} +0 -0
  176. /package/dist/{dist-UDQMBWYW.js.map → dist-Z7KEPQC7.js.map} +0 -0
  177. /package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
  178. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
  179. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
  180. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
@@ -1,30 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createCloudProvider
4
- } from "./chunk-YRTM3KNT.js";
4
+ } from "./chunk-6U2S6QWD.js";
5
5
  import {
6
6
  detectPortless,
7
7
  portlessDoctorRow
8
- } from "./chunk-JNY5GPIM.js";
8
+ } from "./chunk-I654PBHA.js";
9
9
  import {
10
10
  UserFacingError,
11
11
  claudeInstallFingerprint,
12
12
  computeContextSha256,
13
+ describeInbound,
13
14
  errSummary,
14
15
  hostOpenCommand,
15
16
  mintSshKey,
17
+ parseInboundSpec,
16
18
  preparedStatePathFor,
17
19
  readCliStamp,
18
20
  readPreparedStateRaw,
21
+ resolveInboundSources,
19
22
  stageAgentsStaticForUpload,
20
23
  stageClaudeStaticForUpload,
21
24
  stageCodexStaticForUpload,
22
25
  stageOpencodeStaticForUpload,
23
26
  writeManagedSecrets,
24
27
  writePreparedStateRaw
25
- } from "./chunk-JYEZ6Q5M.js";
28
+ } from "./chunk-DEDTPG2D.js";
26
29
 
27
- // ../../packages/sandbox-hetzner/dist/chunk-3ZWBEZND.js
30
+ // ../../packages/sandbox-hetzner/dist/chunk-YIQFCUWT.js
28
31
  import { existsSync, readFileSync } from "fs";
29
32
  import { homedir } from "os";
30
33
  import { resolve } from "path";
@@ -210,6 +213,21 @@ function makeHetznerClient(opts = {}) {
210
213
  const r = await req("GET", `/images/${String(id)}`);
211
214
  return r?.image ?? null;
212
215
  },
216
+ async listServerTypes() {
217
+ const params = new URLSearchParams();
218
+ params.set("per_page", "50");
219
+ const all = [];
220
+ let pageNum = 1;
221
+ while (true) {
222
+ params.set("page", String(pageNum));
223
+ const r = await reqExpect("GET", `/server_types?${params.toString()}`);
224
+ all.push(...r.server_types);
225
+ const next = r.meta?.pagination?.next_page;
226
+ if (typeof next !== "number") break;
227
+ pageNum = next;
228
+ }
229
+ return all;
230
+ },
213
231
  async listImages(opts2) {
214
232
  const params = new URLSearchParams();
215
233
  if (opts2?.type) params.set("type", opts2.type);
@@ -531,14 +549,15 @@ function errorSummary(err) {
531
549
  function truncate(s, max = 160) {
532
550
  return s.length > max ? `${s.slice(0, max)}\u2026` : s;
533
551
  }
534
- function sshOnlyInboundRule(sourceCidr) {
552
+ function sshOnlyInboundRule(sources) {
553
+ const source_ips = Array.isArray(sources) ? sources : [sources];
535
554
  return [
536
555
  {
537
556
  direction: "in",
538
557
  protocol: "tcp",
539
558
  port: "22",
540
- source_ips: [sourceCidr],
541
- description: "agentbox: SSH from host egress IP only"
559
+ source_ips,
560
+ description: "agentbox: SSH inbound"
542
561
  }
543
562
  ];
544
563
  }
@@ -572,7 +591,7 @@ async function createPerBoxFirewall(client2, opts) {
572
591
  { method: "createFirewall", retryOnAmbiguous: false, attemptTimeoutMs: 6e4 },
573
592
  () => client2.createFirewall({
574
593
  name: opts.name,
575
- rules: sshOnlyInboundRule(opts.sourceCidr),
594
+ rules: sshOnlyInboundRule(opts.sources),
576
595
  labels: {
577
596
  "agentbox.managed": "true",
578
597
  "agentbox.role": "box",
@@ -581,10 +600,10 @@ async function createPerBoxFirewall(client2, opts) {
581
600
  })
582
601
  );
583
602
  }
584
- async function syncFirewallSource(client2, firewallId, sourceCidr) {
603
+ async function syncFirewallSource(client2, firewallId, sources) {
585
604
  await withHetznerRetry(
586
605
  { method: "setFirewallRules", retryOnAmbiguous: true, attemptTimeoutMs: 6e4 },
587
- () => client2.setFirewallRules(firewallId, sshOnlyInboundRule(sourceCidr))
606
+ () => client2.setFirewallRules(firewallId, sshOnlyInboundRule(sources))
588
607
  );
589
608
  }
590
609
  async function deletePerBoxFirewall(client2, firewallId, opts = {}) {
@@ -611,9 +630,10 @@ async function deletePerBoxFirewall(client2, firewallId, opts = {}) {
611
630
  }
612
631
  }
613
632
  }
614
- function firewallNeedsSync(allowedSource, currentEgress) {
615
- if (allowedSource === "0.0.0.0/0") return false;
616
- return allowedSource !== currentEgress;
633
+ function firewallNeedsSync(allowedSources, currentEgress) {
634
+ const list = Array.isArray(allowedSources) ? allowedSources : allowedSources ? [allowedSources] : [];
635
+ if (list.includes("0.0.0.0/0")) return false;
636
+ return !list.includes(currentEgress);
617
637
  }
618
638
  function normalizeSourceCidr(raw) {
619
639
  const trimmed = raw.trim();
@@ -913,6 +933,76 @@ async function pollUntil(label, check, opts = {}) {
913
933
  interval = Math.min(interval * 2, max);
914
934
  }
915
935
  }
936
+ function isDeprecated(t) {
937
+ return t.deprecated === true || t.deprecation !== void 0 && t.deprecation !== null;
938
+ }
939
+ function suggestTypes(catalog, limit = 6) {
940
+ return catalog.filter((t) => t.architecture === "x86" && !isDeprecated(t)).map((t) => t.name).slice(0, limit);
941
+ }
942
+ function offeredLocations(t) {
943
+ const seen = /* @__PURE__ */ new Set();
944
+ for (const p of t.prices) {
945
+ if (p.location) seen.add(p.location);
946
+ }
947
+ return [...seen];
948
+ }
949
+ function validateServerChoice(choice, catalog, image) {
950
+ const { serverType, location } = choice;
951
+ const type = catalog.find((t) => t.name === serverType);
952
+ if (!type) {
953
+ const suggestions = suggestTypes(catalog);
954
+ const hint = suggestions.length > 0 ? ` Valid types include: ${suggestions.join(", ")}.` : "";
955
+ throw new UserFacingError(
956
+ `Hetzner server type "${serverType}" does not exist.${hint}
957
+ Set one with \`--size <type>\` or \`agentbox config set box.sizeHetzner <type>\`.`
958
+ );
959
+ }
960
+ if (type.architecture !== "x86") {
961
+ throw new UserFacingError(
962
+ `Hetzner server type "${serverType}" is ${type.architecture} (ARM). AgentBox base snapshots are x86-only, so ARM types (e.g. \`cax*\`) are not supported.
963
+ Pick an x86 type instead: ${suggestTypes(catalog).join(", ")}.`
964
+ );
965
+ }
966
+ if (isDeprecated(type)) {
967
+ const after = type.deprecation?.unavailable_after;
968
+ const when = after ? ` (unavailable after ${after})` : "";
969
+ throw new UserFacingError(
970
+ `Hetzner server type "${serverType}" is deprecated${when} and can't be used for new servers.
971
+ Pick a current type instead: ${suggestTypes(catalog).join(", ")}.`
972
+ );
973
+ }
974
+ if (image && typeof image.disk_size === "number" && type.disk < image.disk_size) {
975
+ throw new UserFacingError(
976
+ `Hetzner server type "${serverType}" has a ${String(type.disk)} GB disk, but the base snapshot needs at least ${String(image.disk_size)} GB.
977
+ Choose a larger type (bigger plans have bigger disks).`
978
+ );
979
+ }
980
+ const locations = offeredLocations(type);
981
+ if (locations.length > 0 && !locations.includes(location)) {
982
+ throw new UserFacingError(
983
+ `Hetzner server type "${serverType}" is not offered in location "${location}".
984
+ It is available in: ${locations.join(", ")}.
985
+ Pick one with \`--location <name>\` or \`agentbox config set box.hetznerLocation <name>\`.`
986
+ );
987
+ }
988
+ }
989
+ function mapHetznerProvisionError(err, choice) {
990
+ if (!(err instanceof HetznerApiError)) return err;
991
+ const { serverType, location } = choice;
992
+ if (err.code === "resource_limit_exceeded") {
993
+ return new UserFacingError(
994
+ `Hetzner refused to create the server: your account resource limit was exceeded (${err.message}).
995
+ New Hetzner Cloud accounts start with a low server limit. Request an increase in the Hetzner Console (Limits page: https://console.hetzner.cloud/ \u2192 your project \u2192 Limits), then retry.`
996
+ );
997
+ }
998
+ if (err.code === "resource_unavailable" || err.code === "placement_error") {
999
+ return new UserFacingError(
1000
+ `Hetzner has no capacity for "${serverType}" in "${location}" right now (${err.message}).
1001
+ Retry, or pick another datacenter with \`--location fsn1\` / \`hel1\` / \`ash\` (or \`agentbox config set box.hetznerLocation <name>\`).`
1002
+ );
1003
+ }
1004
+ return err;
1005
+ }
916
1006
  async function mintPrepareKey() {
917
1007
  const root = resolve4(homedirOrCwd(), ".agentbox", "hetzner", `prepare-${Date.now().toString(36)}`);
918
1008
  const key = await mintSshKey(root, `agentbox-prepare-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`);
@@ -1087,7 +1177,7 @@ async function prepareHetzner(opts = {}) {
1087
1177
  progress(`creating firewall ${firewallName} (source ${source})`);
1088
1178
  const firewall = await createPerBoxFirewall(client2, {
1089
1179
  name: firewallName,
1090
- sourceCidr: source,
1180
+ sources: [source],
1091
1181
  labels: { "agentbox.role": "prepare" }
1092
1182
  });
1093
1183
  firewallId = firewall.id;
@@ -1283,6 +1373,9 @@ var prepareHetznerProvider = (req) => prepareHetzner({
1283
1373
  name: req.name,
1284
1374
  hostWorkspace: req.hostWorkspace ?? process.cwd(),
1285
1375
  force: req.force,
1376
+ // Datacenter for the temp bake VPS (defaults to nbg1 when unset). Resolved
1377
+ // by the CLI from `--location` / `box.hetznerLocation`.
1378
+ location: req.location,
1286
1379
  onLog: req.onLog,
1287
1380
  // Forward the Claude install mode (native | npm). Without this the Hetzner
1288
1381
  // bake always ran the native `curl install.sh`, whose CDN 403s datacenter
@@ -1532,7 +1625,7 @@ async function pickFreePort() {
1532
1625
  var HETZNER_DEFAULT_BOX_IMAGE_REF = "agentbox-base";
1533
1626
  var SCAFFOLDING_FALLBACK_IMAGE = "agentbox/box:dev";
1534
1627
  var VPS_USER = "vscode";
1535
- var PROVISION_SSH_DEADLINE_MS = 5 * 6e4;
1628
+ var PROVISION_SSH_DEADLINE_MS = 10 * 6e4;
1536
1629
  var ACTION_DEADLINE_MS = 5 * 6e4;
1537
1630
  var SNAPSHOT_DEADLINE_MS2 = 20 * 6e4;
1538
1631
  var HETZNER_DEFAULT_SERVER_TYPE = "cx23";
@@ -1640,11 +1733,11 @@ async function firewallEgressStatus(sandboxId) {
1640
1733
  if (!Number.isFinite(firewallId)) return null;
1641
1734
  const firewall = await client().getFirewall(firewallId);
1642
1735
  const sshRule = firewall?.rules.find((r) => r.direction === "in" && r.port === "22");
1643
- const allowedSource = sshRule?.source_ips?.[0];
1736
+ const allowedSources = sshRule?.source_ips ?? [];
1644
1737
  const currentEgress = `${await detectEgressIp({})}/32`;
1645
1738
  return {
1646
1739
  firewallId,
1647
- allowedSource,
1740
+ allowedSources,
1648
1741
  currentEgress,
1649
1742
  boxRef: server.labels["agentbox.box"] ?? sandboxId
1650
1743
  };
@@ -1659,11 +1752,11 @@ async function ensureTunnel(sandboxId, state, vpsIp) {
1659
1752
  });
1660
1753
  } catch (err) {
1661
1754
  const s = await firewallEgressStatus(sandboxId).catch(() => null);
1662
- if (s && firewallNeedsSync(s.allowedSource, s.currentEgress)) {
1755
+ if (s && firewallNeedsSync(s.allowedSources, s.currentEgress)) {
1663
1756
  throw new Error(
1664
1757
  `${err.message}
1665
1758
 
1666
- hetzner: SSH is blocked by the box firewall \u2014 it allows ${s.allowedSource ?? "(no rule)"} but your egress IP is now ${s.currentEgress}. Your IP changed; run:
1759
+ hetzner: SSH is blocked by the box firewall \u2014 it allows ${s.allowedSources.join(", ") || "(no rule)"} but your egress IP is now ${s.currentEgress}. Your IP changed; run:
1667
1760
  agentbox hetzner firewall sync ${s.boxRef}
1668
1761
  (or \`agentbox recover ${s.boxRef}\`, which auto-syncs).`
1669
1762
  );
@@ -1700,9 +1793,17 @@ var hetznerBackend = {
1700
1793
  const progress = (s) => onLog(`hetzner: ${s}`);
1701
1794
  await ensureHetznerBaseSnapshot();
1702
1795
  const imageRef = await resolveImageId(c, req);
1796
+ const serverType = req.size && req.size.trim() || HETZNER_DEFAULT_SERVER_TYPE;
1797
+ const location = req.location && req.location.trim() || HETZNER_DEFAULT_LOCATION;
1798
+ const choice = { serverType, location };
1799
+ const image = typeof imageRef === "number" ? await c.getImage(imageRef) : null;
1800
+ const catalog = await c.listServerTypes();
1801
+ validateServerChoice(choice, catalog, image);
1802
+ const inboundPolicy = parseInboundSpec(req.inbound);
1703
1803
  const egressOverride = req.env?.AGENTBOX_HETZNER_FIREWALL_SOURCE ?? process.env.AGENTBOX_HETZNER_FIREWALL_SOURCE;
1704
- const source = egressOverride ? normalizeSourceCidr(egressOverride) : `${await detectEgressIp({ onLog })}/32`;
1705
- progress(`firewall source: ${source}`);
1804
+ const hostEgress = inboundPolicy.mode === "open" ? null : egressOverride ? normalizeSourceCidr(egressOverride) : `${await detectEgressIp({ onLog })}/32`;
1805
+ const sources = resolveInboundSources(inboundPolicy, hostEgress);
1806
+ progress(`firewall inbound: ${describeInbound(inboundPolicy)} -> ${sources.join(", ")}`);
1706
1807
  const stamp = Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8);
1707
1808
  const tempDir = resolvePath(
1708
1809
  process.env.HOME ?? process.cwd(),
@@ -1717,7 +1818,7 @@ var hetznerBackend = {
1717
1818
  try {
1718
1819
  const firewall = await createPerBoxFirewall(c, {
1719
1820
  name: `agentbox-${req.name}-${stamp}`,
1720
- sourceCidr: source,
1821
+ sources,
1721
1822
  labels: {
1722
1823
  "agentbox.box": req.name,
1723
1824
  "agentbox.role": "box"
@@ -1730,29 +1831,34 @@ var hetznerBackend = {
1730
1831
  boxName: req.name,
1731
1832
  boxEnv: Object.keys(boxEnv).length > 0 ? boxEnv : void 0
1732
1833
  });
1733
- const serverType = req.size && req.size.trim() || HETZNER_DEFAULT_SERVER_TYPE;
1734
1834
  progress(
1735
- `creating VPS '${req.name}' from image ${String(imageRef)} (${serverType} / ${HETZNER_DEFAULT_LOCATION})`
1736
- );
1737
- const created = await withHetznerRetry(
1738
- { method: "createServer", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
1739
- () => c.createServer({
1740
- name: `agentbox-${req.name}-${stamp}`,
1741
- server_type: serverType,
1742
- image: imageRef,
1743
- location: HETZNER_DEFAULT_LOCATION,
1744
- user_data: cloudInit,
1745
- firewalls: [{ firewall: firewall.id }],
1746
- labels: {
1747
- "agentbox.managed": "true",
1748
- "agentbox.role": "box",
1749
- "agentbox.box": req.name,
1750
- "agentbox.firewall": String(firewall.id)
1751
- },
1752
- start_after_create: true
1753
- })
1835
+ `creating VPS '${req.name}' from image ${String(imageRef)} (${serverType} / ${location})`
1754
1836
  );
1837
+ let created;
1838
+ try {
1839
+ created = await withHetznerRetry(
1840
+ { method: "createServer", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
1841
+ () => c.createServer({
1842
+ name: `agentbox-${req.name}-${stamp}`,
1843
+ server_type: serverType,
1844
+ image: imageRef,
1845
+ location,
1846
+ user_data: cloudInit,
1847
+ firewalls: [{ firewall: firewall.id }],
1848
+ labels: {
1849
+ "agentbox.managed": "true",
1850
+ "agentbox.role": "box",
1851
+ "agentbox.box": req.name,
1852
+ "agentbox.firewall": String(firewall.id)
1853
+ },
1854
+ start_after_create: true
1855
+ })
1856
+ );
1857
+ } catch (createErr) {
1858
+ throw mapHetznerProvisionError(createErr, choice);
1859
+ }
1755
1860
  serverId = created.server.id;
1861
+ const provisioned = created.server.server_type;
1756
1862
  const vpsIp = created.server.public_net.ipv4?.ip;
1757
1863
  if (!vpsIp) {
1758
1864
  throw new Error(`hetzner: server ${String(serverId)} came up without an IPv4 address`);
@@ -1767,11 +1873,21 @@ var hetznerBackend = {
1767
1873
  await rm2(pendingParent, { recursive: true, force: true });
1768
1874
  const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
1769
1875
  if (!up) {
1770
- throw new Error(`hetzner: ssh on ${vpsIp} did not come up within ${String(PROVISION_SSH_DEADLINE_MS / 1e3)}s`);
1876
+ throw new Error(
1877
+ `hetzner: ssh on ${vpsIp} did not come up within ${String(PROVISION_SSH_DEADLINE_MS / 1e3)}s; the server has been deleted. This is usually transient \u2014 just retry the create. If it keeps failing, check that your host's egress IP is stable (the box firewall is locked to it, so a mid-provision IP change blocks ssh).`
1878
+ );
1771
1879
  }
1772
1880
  await ensureTunnel(sandboxId, state, vpsIp);
1773
1881
  progress("ssh up; ControlMaster open");
1774
- return { sandboxId };
1882
+ return {
1883
+ sandboxId,
1884
+ inbound: inboundPolicy,
1885
+ resources: {
1886
+ cpu: provisioned.cores,
1887
+ memory: provisioned.memory,
1888
+ disk: provisioned.disk
1889
+ }
1890
+ };
1775
1891
  } catch (err) {
1776
1892
  if (serverId !== null) {
1777
1893
  progress(`cleanup \u2014 deleting server ${String(serverId)} after provision failure`);
@@ -1835,7 +1951,7 @@ var hetznerBackend = {
1835
1951
  const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
1836
1952
  if (!up) {
1837
1953
  throw new Error(
1838
- `hetzner: ssh on ${vpsIp} did not come up within ${String(PROVISION_SSH_DEADLINE_MS / 1e3)}s after start`
1954
+ `hetzner: ssh on ${vpsIp} did not come up within ${String(PROVISION_SSH_DEADLINE_MS / 1e3)}s after start. This is usually transient \u2014 retry (\`agentbox start\` / \`agentbox recover\`). If it persists, check that your host's egress IP is stable (the box firewall is locked to it, so an IP change blocks ssh).`
1839
1955
  );
1840
1956
  }
1841
1957
  },
@@ -1972,14 +2088,30 @@ var hetznerBackend = {
1972
2088
  return { url: `http://127.0.0.1:${String(localPort)}` };
1973
2089
  },
1974
2090
  async repairReachability(h) {
2091
+ const policy = h.inbound ?? { mode: "locked", sources: [] };
2092
+ if (policy.mode === "open") return { changed: false };
1975
2093
  const s = await firewallEgressStatus(h.sandboxId).catch(() => null);
1976
- if (!s || !firewallNeedsSync(s.allowedSource, s.currentEgress)) return { changed: false };
1977
- await syncFirewallSource(client(), s.firewallId, s.currentEgress);
2094
+ if (!s || !firewallNeedsSync(s.allowedSources, s.currentEgress)) return { changed: false };
2095
+ const sources = resolveInboundSources(policy, s.currentEgress);
2096
+ await syncFirewallSource(client(), s.firewallId, sources);
1978
2097
  return {
1979
2098
  changed: true,
1980
- detail: `firewall updated: SSH now allowed from ${s.currentEgress} (was ${s.allowedSource ?? "(no rule)"})`
2099
+ detail: `firewall updated: SSH now allowed from ${sources.join(", ")} (was ${s.allowedSources.join(", ") || "(no rule)"})`
1981
2100
  };
1982
2101
  },
2102
+ async setInbound(h, policy) {
2103
+ const id = Number.parseInt(h.sandboxId, 10);
2104
+ const server = await client().getServer(id);
2105
+ if (!server) throw new Error(`hetzner: server ${h.sandboxId} not found`);
2106
+ const firewallId = Number.parseInt(server.labels["agentbox.firewall"] ?? "", 10);
2107
+ if (!Number.isFinite(firewallId)) {
2108
+ throw new Error(`hetzner: no per-box firewall recorded for server ${h.sandboxId}`);
2109
+ }
2110
+ const hostEgress = policy.mode === "open" ? null : `${await detectEgressIp({})}/32`;
2111
+ const sources = resolveInboundSources(policy, hostEgress);
2112
+ await syncFirewallSource(client(), firewallId, sources);
2113
+ return { sources };
2114
+ },
1983
2115
  async startInBoxPortless(h, opts) {
1984
2116
  const tlsFlag = opts.tls ? "" : "--no-tls";
1985
2117
  const startCmd = `sudo portless proxy start ${tlsFlag} -p ${String(opts.proxyPort)}`.replace(/\s+/g, " ");
@@ -2248,6 +2380,8 @@ export {
2248
2380
  controlPlaneCloudInit,
2249
2381
  generateBoxCloudInit,
2250
2382
  pollUntil,
2383
+ validateServerChoice,
2384
+ mapHetznerProvisionError,
2251
2385
  mintPrepareKey,
2252
2386
  sshOptArgs,
2253
2387
  sshExec,
@@ -2263,4 +2397,4 @@ export {
2263
2397
  hetznerProvider,
2264
2398
  providerModule
2265
2399
  };
2266
- //# sourceMappingURL=chunk-DADOEMXP.js.map
2400
+ //# sourceMappingURL=chunk-NACA6AM7.js.map