@madarco/agentbox 0.23.4 → 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.
- package/CHANGELOG.md +79 -0
- package/LICENSE +21 -0
- package/README.md +3 -2
- package/dist/{_cloud-attach-BQRWX3J2.js → _cloud-attach-T6GPR6LJ.js} +5 -5
- package/dist/{chunk-GGRZ3GZO.js → chunk-5KHEH47T.js} +91 -79
- package/dist/chunk-5KHEH47T.js.map +1 -0
- package/dist/{chunk-I6ZRWTPR.js → chunk-6U2S6QWD.js} +219 -18
- package/dist/chunk-6U2S6QWD.js.map +1 -0
- package/dist/{chunk-LK2JT2OO.js → chunk-DEDTPG2D.js} +880 -146
- package/dist/chunk-DEDTPG2D.js.map +1 -0
- package/dist/chunk-G3H2L3O2.js +0 -0
- package/dist/{chunk-LA4JMS27.js → chunk-I654PBHA.js} +290 -330
- package/dist/chunk-I654PBHA.js.map +1 -0
- package/dist/{chunk-W3FQPFP7.js → chunk-K2EDQGZP.js} +18 -4
- package/dist/chunk-K2EDQGZP.js.map +1 -0
- package/dist/{chunk-LSQXT5WZ.js → chunk-LC4E2EIZ.js} +3 -3
- package/dist/{chunk-LSQXT5WZ.js.map → chunk-LC4E2EIZ.js.map} +1 -1
- package/dist/{chunk-SFA57TGX.js → chunk-NACA6AM7.js} +183 -49
- package/dist/chunk-NACA6AM7.js.map +1 -0
- package/dist/{chunk-QEQFZLYR.js → chunk-RYQLFKCP.js} +20 -10
- package/dist/chunk-RYQLFKCP.js.map +1 -0
- package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
- package/dist/chunk-UIRBYL4G.js.map +1 -0
- package/dist/chunk-WJFZJZIM.js +0 -0
- package/dist/chunk-WLHJZPFJ.js +845 -0
- package/dist/chunk-WLHJZPFJ.js.map +1 -0
- package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
- package/dist/dist-3KIJ2KQ2.js +1437 -0
- package/dist/dist-3KIJ2KQ2.js.map +1 -0
- package/dist/{dist-V235KVEX.js → dist-7OUOHQPA.js} +196 -151
- package/dist/dist-7OUOHQPA.js.map +1 -0
- package/dist/{dist-Z2NEVV55.js → dist-B7TNWGVG.js} +8 -4
- package/dist/{dist-CUKBKS3N.js → dist-KYV3LEHG.js} +10 -6
- package/dist/{dist-FXQFTT75.js → dist-PHYCFYKH.js} +37 -17
- package/dist/dist-PHYCFYKH.js.map +1 -0
- package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
- package/dist/{dist-QO4CTLAX.js → dist-Z7KEPQC7.js} +6 -6
- package/dist/index.js +2560 -1108
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-BUO75YLZ-CDTISC2C.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
- package/package.json +28 -28
- package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
- package/runtime/_shared/agentbox-codex-hooks.json +1 -1
- package/runtime/_shared/agentbox-dockerd-start +0 -0
- package/runtime/_shared/agentbox-open +0 -0
- package/runtime/_shared/agentbox-portless-trust +0 -0
- package/runtime/_shared/agentbox-vnc-start +0 -0
- package/runtime/_shared/ctl.cjs +468 -97
- package/runtime/_shared/gh-shim +0 -0
- package/runtime/_shared/git-shim +53 -3
- package/runtime/_shared/linear-shim +0 -0
- package/runtime/_shared/ntn-shim +0 -0
- package/runtime/daytona/custom-system-CLAUDE.md +1 -1
- package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
- package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
- package/runtime/digitalocean/agentbox-dockerd-start +145 -0
- package/runtime/digitalocean/agentbox-open +28 -0
- package/runtime/digitalocean/agentbox-portless-trust +82 -0
- package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
- package/runtime/digitalocean/agentbox-vnc-start +102 -0
- package/runtime/digitalocean/claude-managed-settings.json +116 -0
- package/runtime/digitalocean/ctl.cjs +27852 -0
- package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
- package/runtime/digitalocean/gh-shim +344 -0
- package/runtime/digitalocean/git-shim +181 -0
- package/runtime/digitalocean/linear-shim +181 -0
- package/runtime/digitalocean/ntn-shim +95 -0
- package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
- package/runtime/digitalocean/scripts/install-box.sh +462 -0
- package/runtime/docker/Dockerfile.box +5 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
- package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
- package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
- package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
- package/runtime/e2b/agentbox-codex-hooks.json +1 -1
- package/runtime/e2b/agentbox-dockerd-start +0 -0
- package/runtime/e2b/agentbox-open +0 -0
- package/runtime/e2b/agentbox-vnc-start +0 -0
- package/runtime/e2b/ctl.cjs +468 -97
- package/runtime/e2b/custom-system-CLAUDE.md +6 -3
- package/runtime/e2b/gh-shim +0 -0
- package/runtime/e2b/git-shim +53 -3
- package/runtime/e2b/linear-shim +0 -0
- package/runtime/e2b/ntn-shim +0 -0
- package/runtime/e2b/scripts/build-template.sh +16 -0
- package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
- package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
- package/runtime/hetzner/agentbox-dockerd-start +0 -0
- package/runtime/hetzner/agentbox-open +0 -0
- package/runtime/hetzner/agentbox-portless-trust +0 -0
- package/runtime/hetzner/agentbox-vnc-start +0 -0
- package/runtime/hetzner/ctl.cjs +468 -97
- package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
- package/runtime/hetzner/gh-shim +0 -0
- package/runtime/hetzner/git-shim +53 -3
- package/runtime/hetzner/linear-shim +0 -0
- package/runtime/hetzner/ntn-shim +0 -0
- package/runtime/hetzner/scripts/install-box.sh +5 -0
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_06f2faq._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/1c5w3kqosumog.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/1o3ot_9-8jgzc.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3uq9hf-roasav.js +1 -0
- package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-H22XP3NY.js → chunk-3VE7AYVK.js} +600 -145
- package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
- package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-2Z74R6ZT.js → chunk-FGBXEXUV.js} +351 -292
- package/runtime/hub/apps/hub/{chunk-AR7CEZ2G.js → chunk-YVELHPNY.js} +218 -17
- package/runtime/hub/apps/hub/{dist-LZNRLUYY.js → dist-33ZNVTC6.js} +183 -49
- package/runtime/hub/apps/hub/{dist-Q6G66Z57.js → dist-4SXAJBOC.js} +195 -150
- package/runtime/hub/apps/hub/{dist-SD4G36EP.js → dist-EPJFN2J3.js} +116 -86
- package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
- package/runtime/hub/apps/hub/{dist-LNHEG5P4.js → dist-UJVIROA4.js} +19 -5
- package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
- package/runtime/hub/apps/hub/{dist-VV6Z2CQX.js → dist-YM5J25H6.js} +7 -3
- package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
- package/runtime/hub/apps/hub/package.json +1 -0
- package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-CAXQS5Y3.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
- package/runtime/hub/apps/hub/server.js +38 -19
- package/runtime/relay/bin.cjs +275 -59
- package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
- package/runtime/vercel/agentbox-codex-hooks.json +1 -1
- package/runtime/vercel/agentbox-dockerd-start +0 -0
- package/runtime/vercel/agentbox-open +0 -0
- package/runtime/vercel/agentbox-vnc-start +0 -0
- package/runtime/vercel/ctl.cjs +468 -97
- package/runtime/vercel/custom-system-CLAUDE.md +3 -2
- package/runtime/vercel/gh-shim +0 -0
- package/runtime/vercel/git-shim +53 -3
- package/runtime/vercel/linear-shim +0 -0
- package/runtime/vercel/ntn-shim +0 -0
- package/runtime/vercel/scripts/provision.sh +16 -0
- package/dist/chunk-GGRZ3GZO.js.map +0 -1
- package/dist/chunk-I6ZRWTPR.js.map +0 -1
- package/dist/chunk-LA4JMS27.js.map +0 -1
- package/dist/chunk-LK2JT2OO.js.map +0 -1
- package/dist/chunk-QEQFZLYR.js.map +0 -1
- package/dist/chunk-QT3SHMLY.js.map +0 -1
- package/dist/chunk-SFA57TGX.js.map +0 -1
- package/dist/chunk-W3FQPFP7.js.map +0 -1
- package/dist/dist-FXQFTT75.js.map +0 -1
- package/dist/dist-V235KVEX.js.map +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/20hq7-0depjid.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/3p86ecqhr_7yy.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/3qof5hg87qf5n.js +0 -1
- /package/dist/{_cloud-attach-BQRWX3J2.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
- /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
- /package/dist/{dist-CUKBKS3N.js.map → dist-KYV3LEHG.js.map} +0 -0
- /package/dist/{dist-QO4CTLAX.js.map → dist-T5MXBZGP.js.map} +0 -0
- /package/dist/{dist-Z2NEVV55.js.map → dist-Z7KEPQC7.js.map} +0 -0
- /package/dist/{prepared-state-BUO75YLZ-CDTISC2C.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{eVq-z4zld_8DGQudbYogV → 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-
|
|
4
|
+
} from "./chunk-6U2S6QWD.js";
|
|
5
5
|
import {
|
|
6
6
|
detectPortless,
|
|
7
7
|
portlessDoctorRow
|
|
8
|
-
} from "./chunk-
|
|
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-
|
|
28
|
+
} from "./chunk-DEDTPG2D.js";
|
|
26
29
|
|
|
27
|
-
// ../../packages/sandbox-hetzner/dist/chunk-
|
|
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(
|
|
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
|
|
541
|
-
description: "agentbox: SSH
|
|
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.
|
|
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,
|
|
603
|
+
async function syncFirewallSource(client2, firewallId, sources) {
|
|
585
604
|
await withHetznerRetry(
|
|
586
605
|
{ method: "setFirewallRules", retryOnAmbiguous: true, attemptTimeoutMs: 6e4 },
|
|
587
|
-
() => client2.setFirewallRules(firewallId, sshOnlyInboundRule(
|
|
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(
|
|
615
|
-
|
|
616
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
1736
|
+
const allowedSources = sshRule?.source_ips ?? [];
|
|
1644
1737
|
const currentEgress = `${await detectEgressIp({})}/32`;
|
|
1645
1738
|
return {
|
|
1646
1739
|
firewallId,
|
|
1647
|
-
|
|
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.
|
|
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.
|
|
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
|
|
1705
|
-
|
|
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
|
-
|
|
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} / ${
|
|
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(
|
|
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 {
|
|
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.
|
|
1977
|
-
|
|
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 ${
|
|
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-
|
|
2400
|
+
//# sourceMappingURL=chunk-NACA6AM7.js.map
|