@madarco/agentbox 0.25.1 → 0.26.1
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 +48 -0
- package/README.md +8 -7
- package/dist/{_cloud-attach-FGMI2ZHO.js → _cloud-attach-7WRQH6XZ.js} +5 -5
- package/dist/{chunk-5VNL6SHJ.js → chunk-7ZZAZPYX.js} +3 -3
- package/dist/{chunk-ZTSVY3YL.js → chunk-BA2VLJVU.js} +3 -3
- package/dist/{chunk-3BR63LCB.js → chunk-DJQMK4RN.js} +12 -4
- package/dist/chunk-DJQMK4RN.js.map +1 -0
- package/dist/{chunk-6GZK74GT.js → chunk-DQHMDDAT.js} +2 -2
- package/dist/{chunk-P5U6AP6K.js → chunk-I2OAJS3L.js} +40 -377
- package/dist/{chunk-P5U6AP6K.js.map → chunk-I2OAJS3L.js.map} +1 -1
- package/dist/{chunk-5F5SOSDY.js → chunk-JGZSA5ZI.js} +72 -23
- package/dist/chunk-JGZSA5ZI.js.map +1 -0
- package/dist/{chunk-67VF2QZC.js → chunk-K5KOLYIL.js} +3 -3
- package/dist/{chunk-4LS2TOF3.js → chunk-PK2QF4IR.js} +569 -195
- package/dist/chunk-PK2QF4IR.js.map +1 -0
- package/dist/{chunk-3PSRBK24.js → chunk-UIFL7F2G.js} +54 -37
- package/dist/chunk-UIFL7F2G.js.map +1 -0
- package/dist/{chunk-4DBLYT2F.js → chunk-ZY7M7MXH.js} +41 -16
- package/dist/chunk-ZY7M7MXH.js.map +1 -0
- package/dist/chunk-ZYKNSHOH.js +259 -0
- package/dist/chunk-ZYKNSHOH.js.map +1 -0
- package/dist/{dist-X7R2EMJL.js → dist-5IICYSR6.js} +42 -374
- package/dist/{dist-X7R2EMJL.js.map → dist-5IICYSR6.js.map} +1 -1
- package/dist/{dist-5G42NFOG.js → dist-AR5CHRSV.js} +86 -45
- package/dist/{dist-5G42NFOG.js.map → dist-AR5CHRSV.js.map} +1 -1
- package/dist/{dist-AZUD2LUA.js → dist-DTNYMBQ5.js} +12 -12
- package/dist/{dist-MEK44IS5.js → dist-K4LNH3EC.js} +6 -6
- package/dist/{dist-SN6ABGMD.js → dist-POVRY7HO.js} +8 -4
- package/dist/{dist-SBDYDH7H.js → dist-U2SVLJUQ.js} +4 -2
- package/dist/{dist-4I7XHDC3.js → dist-XYY6SIKG.js} +6 -6
- package/dist/dist-YA7EXBGG.js +809 -0
- package/dist/dist-YA7EXBGG.js.map +1 -0
- package/dist/index.js +971 -591
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-75DIZ55S-5UAKJX3L.js → prepared-state-75DIZ55S-W6NU3S3B.js} +2 -2
- package/package.json +8 -7
- package/runtime/_shared/ctl.cjs +83 -36
- package/runtime/digitalocean/ctl.cjs +83 -36
- package/runtime/docker/packages/ctl/dist/bin.cjs +83 -36
- package/runtime/e2b/ctl.cjs +83 -36
- package/runtime/hetzner/ctl.cjs +83 -36
- 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/(auth)/api/auth/[...all]/route.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(auth)/api/auth/[...all]/route.js.nft.json +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/0-fj_better-auth_dist_adapters_kysely-adapter_index_mjs_0btft52._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +5 -5
- 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]__1-9g0ae._.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]__19pc87s._.js → [root-of-the-server]__1k8g143._.js} +2 -2
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +4 -4
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_0xy-j7z._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_010858m.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_04zwxnx.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_06exuc7.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2ldrt.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_0f2tzep.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_116nh32.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_11dyjcb.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_esm_build_templates_app-page_1_4knli.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__08-1wwu._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0c9mbcn._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0gdfxj4._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0kc-hwp._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__0lu73p6._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__10bfmwi._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__18qvdzb._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/[root-of-the-server]__1l2urlw._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.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/{auth-MVL4NCQC.js → auth-DC44GQZY.js} +2 -2
- package/runtime/hub/apps/hub/{auth-config-GRIXACTV.js → auth-config-LALRDYDO.js} +2 -2
- package/runtime/hub/apps/hub/{chunk-JLG5JJXD.js → chunk-3FJNKSNZ.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-RSENJ2FT.js → chunk-4QY2VZCF.js} +502 -132
- package/runtime/hub/apps/hub/{chunk-23AU7VYS.js → chunk-BARD2DI6.js} +11 -3
- package/runtime/hub/apps/hub/{chunk-V3OMPMI3.js → chunk-QSMPSV5Z.js} +70 -21
- package/runtime/hub/apps/hub/{chunk-GARA7RQW.js → chunk-XZZXPEVV.js} +57 -36
- package/runtime/hub/apps/hub/{dist-WZKTIA2R.js → dist-3ENKQN5G.js} +35 -365
- package/runtime/hub/apps/hub/{dist-TP4SXMDY.js → dist-6VGJOQYK.js} +84 -43
- package/runtime/hub/apps/hub/{dist-JVU3QCLG.js → dist-AE6IV4FV.js} +4 -4
- package/runtime/hub/apps/hub/{dist-IZ2JCN5R.js → dist-EQV4L7KP.js} +3 -1
- package/runtime/hub/apps/hub/dist-NNBELNA7.js +1017 -0
- package/runtime/hub/apps/hub/{dist-DZGSA3US.js → dist-RJJ2SDYO.js} +4 -4
- package/runtime/hub/apps/hub/{dist-VWSHZIPN.js → dist-TU7D6UTB.js} +37 -366
- package/runtime/hub/apps/hub/{dist-YWY2DSSL.js → dist-WAZKGVYL.js} +7 -3
- package/runtime/hub/apps/hub/{hub-token-BJG6Q5II.js → hub-token-COBZGSLS.js} +2 -2
- package/runtime/hub/apps/hub/package.json +1 -0
- package/runtime/hub/apps/hub/{prepared-state-75DIZ55S-JDILR4OP.js → prepared-state-75DIZ55S-NYEDSU2U.js} +1 -1
- package/runtime/hub/apps/hub/server.js +20 -16
- package/runtime/relay/bin.cjs +57 -20
- package/runtime/vercel/ctl.cjs +83 -36
- package/dist/chunk-3BR63LCB.js.map +0 -1
- package/dist/chunk-3PSRBK24.js.map +0 -1
- package/dist/chunk-4DBLYT2F.js.map +0 -1
- package/dist/chunk-4LS2TOF3.js.map +0 -1
- package/dist/chunk-5F5SOSDY.js.map +0 -1
- package/runtime/hub/apps/hub/.next/server/chunks/0zhp_better-auth_dist_adapters_kysely-adapter_index_mjs_1rl4qnh._.js +0 -3
- /package/dist/{_cloud-attach-FGMI2ZHO.js.map → _cloud-attach-7WRQH6XZ.js.map} +0 -0
- /package/dist/{chunk-5VNL6SHJ.js.map → chunk-7ZZAZPYX.js.map} +0 -0
- /package/dist/{chunk-ZTSVY3YL.js.map → chunk-BA2VLJVU.js.map} +0 -0
- /package/dist/{chunk-6GZK74GT.js.map → chunk-DQHMDDAT.js.map} +0 -0
- /package/dist/{chunk-67VF2QZC.js.map → chunk-K5KOLYIL.js.map} +0 -0
- /package/dist/{dist-4I7XHDC3.js.map → dist-DTNYMBQ5.js.map} +0 -0
- /package/dist/{dist-MEK44IS5.js.map → dist-K4LNH3EC.js.map} +0 -0
- /package/dist/{dist-AZUD2LUA.js.map → dist-POVRY7HO.js.map} +0 -0
- /package/dist/{dist-SBDYDH7H.js.map → dist-U2SVLJUQ.js.map} +0 -0
- /package/dist/{dist-SN6ABGMD.js.map → dist-XYY6SIKG.js.map} +0 -0
- /package/dist/{prepared-state-75DIZ55S-5UAKJX3L.js.map → prepared-state-75DIZ55S-W6NU3S3B.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mJYh9UHTsLaGGyRjBSvme}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mJYh9UHTsLaGGyRjBSvme}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mJYh9UHTsLaGGyRjBSvme}/_ssgManifest.js +0 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
readPreparedStateRaw,
|
|
9
9
|
writeManagedSecrets,
|
|
10
10
|
writePreparedStateRaw
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PK2QF4IR.js";
|
|
12
12
|
|
|
13
13
|
// ../../packages/sandbox-e2b/dist/chunk-WQRH5SXA.js
|
|
14
14
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -324,4 +324,4 @@ export {
|
|
|
324
324
|
currentE2bBaseFingerprintLive,
|
|
325
325
|
ensureE2bBaseTemplate
|
|
326
326
|
};
|
|
327
|
-
//# sourceMappingURL=chunk-
|
|
327
|
+
//# sourceMappingURL=chunk-DQHMDDAT.js.map
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createCloudProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DJQMK4RN.js";
|
|
5
5
|
import {
|
|
6
6
|
detectPortless,
|
|
7
7
|
portlessDoctorRow
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UIFL7F2G.js";
|
|
9
9
|
import {
|
|
10
|
+
SshTunnelManager,
|
|
10
11
|
UserFacingError,
|
|
11
12
|
claudeInstallFingerprint,
|
|
12
13
|
computeContextSha256,
|
|
14
|
+
defaultBoxSshDir,
|
|
13
15
|
describeInbound,
|
|
14
16
|
errSummary,
|
|
15
17
|
hostOpenCommand,
|
|
@@ -19,13 +21,17 @@ import {
|
|
|
19
21
|
readCliStamp,
|
|
20
22
|
readPreparedStateRaw,
|
|
21
23
|
resolveInboundSources,
|
|
24
|
+
scpUpload,
|
|
25
|
+
sshExec,
|
|
26
|
+
sshOptArgs,
|
|
22
27
|
stageAgentsStaticForUpload,
|
|
23
28
|
stageClaudeStaticForUpload,
|
|
24
29
|
stageCodexStaticForUpload,
|
|
25
30
|
stageOpencodeStaticForUpload,
|
|
31
|
+
waitForSsh,
|
|
26
32
|
writeManagedSecrets,
|
|
27
33
|
writePreparedStateRaw
|
|
28
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-PK2QF4IR.js";
|
|
29
35
|
|
|
30
36
|
// ../../packages/sandbox-hetzner/dist/chunk-YIQFCUWT.js
|
|
31
37
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -801,23 +807,16 @@ async function currentHetznerBaseFingerprintLive(claudeInstall = "native") {
|
|
|
801
807
|
}
|
|
802
808
|
|
|
803
809
|
// ../../packages/sandbox-hetzner/dist/index.js
|
|
804
|
-
import { existsSync as
|
|
805
|
-
import { rm
|
|
806
|
-
import { join as
|
|
807
|
-
import { execa
|
|
810
|
+
import { existsSync as existsSync3 } from "fs";
|
|
811
|
+
import { rm, rename, mkdir } from "fs/promises";
|
|
812
|
+
import { join as join2 } from "path";
|
|
813
|
+
import { execa } from "execa";
|
|
808
814
|
import { resolve as resolvePath } from "path";
|
|
809
815
|
import { join } from "path";
|
|
810
816
|
import { dirname as dirname2, resolve as resolve4 } from "path";
|
|
811
|
-
import {
|
|
812
|
-
import {
|
|
813
|
-
import {
|
|
814
|
-
import { createServer } from "net";
|
|
815
|
-
import { homedir as homedir3 } from "os";
|
|
816
|
-
import { dirname as dirname22, join as join2, resolve as resolve22 } from "path";
|
|
817
|
-
import { execa as execa2 } from "execa";
|
|
818
|
-
import { mkdir as mkdir3, rm as rm3, writeFile } from "fs/promises";
|
|
819
|
-
import { homedir as homedir22, tmpdir } from "os";
|
|
820
|
-
import { join as join4 } from "path";
|
|
817
|
+
import { mkdir as mkdir2, rm as rm2, writeFile } from "fs/promises";
|
|
818
|
+
import { homedir as homedir3, tmpdir } from "os";
|
|
819
|
+
import { join as join3 } from "path";
|
|
821
820
|
function generatePrepareCloudInit(opts) {
|
|
822
821
|
const pubkey = opts.sshPubkey.trim();
|
|
823
822
|
return [
|
|
@@ -1010,8 +1009,8 @@ async function mintPrepareKey() {
|
|
|
1010
1009
|
...key,
|
|
1011
1010
|
cleanup: async () => {
|
|
1012
1011
|
try {
|
|
1013
|
-
const { rm:
|
|
1014
|
-
await
|
|
1012
|
+
const { rm: rm3 } = await import("fs/promises");
|
|
1013
|
+
await rm3(dirname2(key.privatePath), { recursive: true, force: true });
|
|
1015
1014
|
} catch {
|
|
1016
1015
|
}
|
|
1017
1016
|
}
|
|
@@ -1024,105 +1023,6 @@ function homedirOrCwd() {
|
|
|
1024
1023
|
return process.cwd();
|
|
1025
1024
|
}
|
|
1026
1025
|
}
|
|
1027
|
-
function sshOptArgs(target) {
|
|
1028
|
-
const out = [
|
|
1029
|
-
"-i",
|
|
1030
|
-
target.identity,
|
|
1031
|
-
"-o",
|
|
1032
|
-
"StrictHostKeyChecking=accept-new",
|
|
1033
|
-
"-o",
|
|
1034
|
-
`UserKnownHostsFile=${target.knownHosts}`,
|
|
1035
|
-
"-o",
|
|
1036
|
-
"GlobalKnownHostsFile=/dev/null",
|
|
1037
|
-
"-o",
|
|
1038
|
-
"BatchMode=yes",
|
|
1039
|
-
"-o",
|
|
1040
|
-
"LogLevel=ERROR"
|
|
1041
|
-
];
|
|
1042
|
-
if (target.controlPath) {
|
|
1043
|
-
out.push("-o", `ControlPath=${target.controlPath}`);
|
|
1044
|
-
}
|
|
1045
|
-
for (const [k, v] of Object.entries(target.options ?? {})) {
|
|
1046
|
-
out.push("-o", `${k}=${v}`);
|
|
1047
|
-
}
|
|
1048
|
-
return out;
|
|
1049
|
-
}
|
|
1050
|
-
async function sshExec(target, remoteCmd, opts = {}) {
|
|
1051
|
-
const argv = [
|
|
1052
|
-
...sshOptArgs(target),
|
|
1053
|
-
`${target.user}@${target.host}`,
|
|
1054
|
-
remoteCmd
|
|
1055
|
-
];
|
|
1056
|
-
const child = execa("ssh", argv, {
|
|
1057
|
-
reject: false,
|
|
1058
|
-
timeout: opts.timeoutMs,
|
|
1059
|
-
env: { ...process.env, ...opts.env },
|
|
1060
|
-
stdio: opts.onLine ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe"]
|
|
1061
|
-
});
|
|
1062
|
-
if (opts.onLine) {
|
|
1063
|
-
const handle = (chunk) => {
|
|
1064
|
-
const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
1065
|
-
for (const line of text.split(/\r?\n/)) {
|
|
1066
|
-
if (line.length > 0) opts.onLine?.(line);
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
child.stdout?.on("data", handle);
|
|
1070
|
-
child.stderr?.on("data", handle);
|
|
1071
|
-
}
|
|
1072
|
-
const res = await child;
|
|
1073
|
-
return {
|
|
1074
|
-
exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
|
|
1075
|
-
stdout: typeof res.stdout === "string" ? res.stdout : "",
|
|
1076
|
-
stderr: typeof res.stderr === "string" ? res.stderr : ""
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
async function scpUpload(target, localPath, remotePath, opts = {}) {
|
|
1080
|
-
const argv = [
|
|
1081
|
-
...sshOptArgs(target),
|
|
1082
|
-
localPath,
|
|
1083
|
-
`${target.user}@${target.host}:${remotePath}`
|
|
1084
|
-
];
|
|
1085
|
-
const res = await execa("scp", argv, {
|
|
1086
|
-
reject: false,
|
|
1087
|
-
timeout: opts.timeoutMs
|
|
1088
|
-
});
|
|
1089
|
-
if (res.exitCode !== 0) {
|
|
1090
|
-
throw new Error(
|
|
1091
|
-
`scp upload failed (exit ${String(res.exitCode)}): ${localPath} \u2192 ${remotePath}
|
|
1092
|
-
${res.stderr ?? ""}`
|
|
1093
|
-
);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
async function scpDownload(target, remotePath, localPath, opts = {}) {
|
|
1097
|
-
const argv = [
|
|
1098
|
-
...sshOptArgs(target),
|
|
1099
|
-
`${target.user}@${target.host}:${remotePath}`,
|
|
1100
|
-
localPath
|
|
1101
|
-
];
|
|
1102
|
-
const res = await execa("scp", argv, {
|
|
1103
|
-
reject: false,
|
|
1104
|
-
timeout: opts.timeoutMs
|
|
1105
|
-
});
|
|
1106
|
-
if (res.exitCode !== 0) {
|
|
1107
|
-
throw new Error(
|
|
1108
|
-
`scp download failed (exit ${String(res.exitCode)}): ${remotePath} \u2192 ${localPath}
|
|
1109
|
-
${res.stderr ?? ""}`
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
async function waitForSsh(target, deadlineMs, intervalMs = 5e3) {
|
|
1114
|
-
const stop = Date.now() + deadlineMs;
|
|
1115
|
-
while (Date.now() < stop) {
|
|
1116
|
-
const res = await sshExec(
|
|
1117
|
-
{ ...target, options: { ...target.options, ConnectTimeout: "5" } },
|
|
1118
|
-
"true",
|
|
1119
|
-
{ timeoutMs: 1e4 }
|
|
1120
|
-
);
|
|
1121
|
-
if (res.exitCode === 0) return true;
|
|
1122
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
1123
|
-
}
|
|
1124
|
-
return false;
|
|
1125
|
-
}
|
|
1126
1026
|
var TEMP_SERVER_TYPE_DEFAULT = "cx23";
|
|
1127
1027
|
var TEMP_SERVER_LOCATION_DEFAULT = "nbg1";
|
|
1128
1028
|
var PREPARE_SSH_DEADLINE_MS = 5 * 6e4;
|
|
@@ -1390,238 +1290,6 @@ async function ensureHetznerBaseSnapshot() {
|
|
|
1390
1290
|
"no Hetzner base snapshot found.\nRun `agentbox prepare --provider hetzner` first (Hetzner cannot build images from a Dockerfile,\nso the base snapshot is a one-time prerequisite for cloud boxes on this backend)."
|
|
1391
1291
|
);
|
|
1392
1292
|
}
|
|
1393
|
-
var HOST = "127.0.0.1";
|
|
1394
|
-
var EPHEMERAL_MIN = 49152;
|
|
1395
|
-
var EPHEMERAL_MAX = 65535;
|
|
1396
|
-
var SshTunnelManager = class {
|
|
1397
|
-
boxes = /* @__PURE__ */ new Map();
|
|
1398
|
-
/**
|
|
1399
|
-
* Open the ControlMaster for `boxId`. Idempotent: if a master is already
|
|
1400
|
-
* up for this box (socket exists + responsive), no-op. Otherwise spawn a
|
|
1401
|
-
* fresh `ssh -fNT -M` and wait for the socket to appear.
|
|
1402
|
-
*/
|
|
1403
|
-
async open(opts) {
|
|
1404
|
-
const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
|
|
1405
|
-
await mkdir(boxSshDir, { recursive: true, mode: 448 });
|
|
1406
|
-
const controlPath = join2(boxSshDir, "control.sock");
|
|
1407
|
-
const knownHosts = join2(boxSshDir, "known_hosts");
|
|
1408
|
-
const user = opts.vpsUser ?? "vscode";
|
|
1409
|
-
const tunnel = {
|
|
1410
|
-
controlPath,
|
|
1411
|
-
vpsHost: opts.vpsHost,
|
|
1412
|
-
vpsUser: user,
|
|
1413
|
-
identity: opts.identity,
|
|
1414
|
-
boxSshDir,
|
|
1415
|
-
forwards: /* @__PURE__ */ new Map()
|
|
1416
|
-
};
|
|
1417
|
-
if (existsSync3(controlPath) && await this.isAlive(controlPath)) {
|
|
1418
|
-
this.boxes.set(opts.boxId, tunnel);
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
if (existsSync3(controlPath)) {
|
|
1422
|
-
await rm(controlPath, { force: true });
|
|
1423
|
-
}
|
|
1424
|
-
const connectTimeout = opts.connectTimeoutSeconds ?? 10;
|
|
1425
|
-
const argv = [
|
|
1426
|
-
"-fNT",
|
|
1427
|
-
"-M",
|
|
1428
|
-
"-S",
|
|
1429
|
-
controlPath,
|
|
1430
|
-
"-i",
|
|
1431
|
-
opts.identity,
|
|
1432
|
-
"-o",
|
|
1433
|
-
"StrictHostKeyChecking=accept-new",
|
|
1434
|
-
"-o",
|
|
1435
|
-
`UserKnownHostsFile=${knownHosts}`,
|
|
1436
|
-
"-o",
|
|
1437
|
-
"GlobalKnownHostsFile=/dev/null",
|
|
1438
|
-
"-o",
|
|
1439
|
-
"BatchMode=yes",
|
|
1440
|
-
"-o",
|
|
1441
|
-
"LogLevel=ERROR",
|
|
1442
|
-
"-o",
|
|
1443
|
-
"ExitOnForwardFailure=yes",
|
|
1444
|
-
"-o",
|
|
1445
|
-
"ServerAliveInterval=30",
|
|
1446
|
-
"-o",
|
|
1447
|
-
"ServerAliveCountMax=3",
|
|
1448
|
-
"-o",
|
|
1449
|
-
`ConnectTimeout=${String(connectTimeout)}`,
|
|
1450
|
-
`${user}@${opts.vpsHost}`
|
|
1451
|
-
];
|
|
1452
|
-
const res = await execa2("ssh", argv, { reject: false });
|
|
1453
|
-
if (res.exitCode !== 0 || !existsSync3(controlPath)) {
|
|
1454
|
-
throw new Error(
|
|
1455
|
-
`ssh ControlMaster failed for ${opts.boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
|
|
1456
|
-
);
|
|
1457
|
-
}
|
|
1458
|
-
this.boxes.set(opts.boxId, tunnel);
|
|
1459
|
-
}
|
|
1460
|
-
/**
|
|
1461
|
-
* Mint (or fetch the cached) `127.0.0.1:<localPort> → vps:127.0.0.1:<remotePort>`
|
|
1462
|
-
* forward. Returns the local port. Idempotent per (boxId, remotePort).
|
|
1463
|
-
*
|
|
1464
|
-
* The cached entry is only returned when the underlying ControlMaster is
|
|
1465
|
-
* still alive — without that check we'd happily hand back a localPort that
|
|
1466
|
-
* stopped listening when the master died (e.g. transient network blip,
|
|
1467
|
-
* host sleep/wake). When the master is dead we drop ALL cached forwards
|
|
1468
|
-
* for this box (they all share one tunnel) and re-mint from scratch.
|
|
1469
|
-
*/
|
|
1470
|
-
async forward(boxId, remotePort) {
|
|
1471
|
-
const tunnel = this.getTunnelOrThrow(boxId);
|
|
1472
|
-
const cached = tunnel.forwards.get(remotePort);
|
|
1473
|
-
if (cached !== void 0 && await this.isAlive(tunnel.controlPath)) {
|
|
1474
|
-
return cached;
|
|
1475
|
-
}
|
|
1476
|
-
if (cached !== void 0) {
|
|
1477
|
-
tunnel.forwards.clear();
|
|
1478
|
-
}
|
|
1479
|
-
const localPort = await pickFreePort();
|
|
1480
|
-
const argv = [
|
|
1481
|
-
"-O",
|
|
1482
|
-
"forward",
|
|
1483
|
-
"-L",
|
|
1484
|
-
`${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
|
|
1485
|
-
"-S",
|
|
1486
|
-
tunnel.controlPath,
|
|
1487
|
-
"dummy"
|
|
1488
|
-
// the target host is ignored when -O is used, but argv needs one
|
|
1489
|
-
];
|
|
1490
|
-
const res = await execa2("ssh", argv, { reject: false });
|
|
1491
|
-
if (res.exitCode !== 0) {
|
|
1492
|
-
throw new Error(
|
|
1493
|
-
`ssh -O forward failed for ${boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
|
|
1494
|
-
);
|
|
1495
|
-
}
|
|
1496
|
-
tunnel.forwards.set(remotePort, localPort);
|
|
1497
|
-
return localPort;
|
|
1498
|
-
}
|
|
1499
|
-
/**
|
|
1500
|
-
* Tear down a dead ControlMaster + every cached forward for this box,
|
|
1501
|
-
* then re-open from scratch. Idempotent — if the master is already alive
|
|
1502
|
-
* the master open() is a no-op, but the cached forwards still get
|
|
1503
|
-
* cleared so the next forward() call re-mints them. Returns when the
|
|
1504
|
-
* master is open and the box's forwards map is empty (ready for fresh
|
|
1505
|
-
* forward() calls).
|
|
1506
|
-
*
|
|
1507
|
-
* Use case: the cloud-poller observes ECONNREFUSED on the local port and
|
|
1508
|
-
* asks the backend to refresh the preview URL — that path calls into
|
|
1509
|
-
* here so the master + forward both come back fresh.
|
|
1510
|
-
*/
|
|
1511
|
-
async refresh(opts) {
|
|
1512
|
-
const existing = this.boxes.get(opts.boxId);
|
|
1513
|
-
if (existing) {
|
|
1514
|
-
const alive = await this.isAlive(existing.controlPath);
|
|
1515
|
-
if (!alive && existsSync3(existing.controlPath)) {
|
|
1516
|
-
try {
|
|
1517
|
-
await execa2(
|
|
1518
|
-
"ssh",
|
|
1519
|
-
["-O", "exit", "-S", existing.controlPath, "dummy"],
|
|
1520
|
-
{ reject: false }
|
|
1521
|
-
);
|
|
1522
|
-
} catch {
|
|
1523
|
-
}
|
|
1524
|
-
await rm(existing.controlPath, { force: true });
|
|
1525
|
-
}
|
|
1526
|
-
existing.forwards.clear();
|
|
1527
|
-
}
|
|
1528
|
-
await this.open(opts);
|
|
1529
|
-
}
|
|
1530
|
-
/** Tear down a single forward. Idempotent — unknown ports are no-ops. */
|
|
1531
|
-
async unforward(boxId, remotePort) {
|
|
1532
|
-
const tunnel = this.getTunnelOrThrow(boxId);
|
|
1533
|
-
const localPort = tunnel.forwards.get(remotePort);
|
|
1534
|
-
if (localPort === void 0) return;
|
|
1535
|
-
const argv = [
|
|
1536
|
-
"-O",
|
|
1537
|
-
"cancel",
|
|
1538
|
-
"-L",
|
|
1539
|
-
`${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
|
|
1540
|
-
"-S",
|
|
1541
|
-
tunnel.controlPath,
|
|
1542
|
-
"dummy"
|
|
1543
|
-
];
|
|
1544
|
-
await execa2("ssh", argv, { reject: false });
|
|
1545
|
-
tunnel.forwards.delete(remotePort);
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Close the ControlMaster (and all its forwards). Idempotent — if no
|
|
1549
|
-
* master is recorded, no-op. Removes the socket file.
|
|
1550
|
-
*/
|
|
1551
|
-
async close(boxId) {
|
|
1552
|
-
const tunnel = this.boxes.get(boxId);
|
|
1553
|
-
if (!tunnel) return;
|
|
1554
|
-
if (existsSync3(tunnel.controlPath)) {
|
|
1555
|
-
await execa2("ssh", ["-O", "exit", "-S", tunnel.controlPath, "dummy"], { reject: false });
|
|
1556
|
-
await rm(tunnel.controlPath, { force: true });
|
|
1557
|
-
}
|
|
1558
|
-
this.boxes.delete(boxId);
|
|
1559
|
-
}
|
|
1560
|
-
/** Tear down every open box. */
|
|
1561
|
-
async closeAll() {
|
|
1562
|
-
const ids = Array.from(this.boxes.keys());
|
|
1563
|
-
await Promise.all(ids.map((id) => this.close(id)));
|
|
1564
|
-
}
|
|
1565
|
-
/** Path to the ControlMaster socket for `boxId`, if open. */
|
|
1566
|
-
controlPath(boxId) {
|
|
1567
|
-
return this.boxes.get(boxId)?.controlPath;
|
|
1568
|
-
}
|
|
1569
|
-
/** True if a ControlMaster is registered for `boxId` (regardless of liveness). */
|
|
1570
|
-
has(boxId) {
|
|
1571
|
-
return this.boxes.has(boxId);
|
|
1572
|
-
}
|
|
1573
|
-
/** Per-box ssh dir (tests use this to verify the layout). */
|
|
1574
|
-
boxSshDir(boxId) {
|
|
1575
|
-
return this.boxes.get(boxId)?.boxSshDir;
|
|
1576
|
-
}
|
|
1577
|
-
/** Re-open the manager record for an existing-on-disk control socket. */
|
|
1578
|
-
registerExisting(boxId, opts) {
|
|
1579
|
-
const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
|
|
1580
|
-
this.boxes.set(boxId, {
|
|
1581
|
-
controlPath: join2(boxSshDir, "control.sock"),
|
|
1582
|
-
vpsHost: opts.vpsHost,
|
|
1583
|
-
vpsUser: opts.vpsUser ?? "vscode",
|
|
1584
|
-
identity: opts.identity,
|
|
1585
|
-
boxSshDir,
|
|
1586
|
-
forwards: /* @__PURE__ */ new Map()
|
|
1587
|
-
});
|
|
1588
|
-
}
|
|
1589
|
-
async isAlive(controlPath) {
|
|
1590
|
-
const res = await execa2("ssh", ["-O", "check", "-S", controlPath, "dummy"], { reject: false });
|
|
1591
|
-
return res.exitCode === 0;
|
|
1592
|
-
}
|
|
1593
|
-
getTunnelOrThrow(boxId) {
|
|
1594
|
-
const t = this.boxes.get(boxId);
|
|
1595
|
-
if (!t) throw new Error(`no SSH ControlMaster registered for box ${boxId}; call open() first`);
|
|
1596
|
-
return t;
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
function defaultBoxSshDir(boxId) {
|
|
1600
|
-
return resolve22(homedir3(), ".agentbox", "boxes", boxId, "ssh");
|
|
1601
|
-
}
|
|
1602
|
-
async function pickFreePort() {
|
|
1603
|
-
return new Promise((resolveOk, reject) => {
|
|
1604
|
-
const srv = createServer();
|
|
1605
|
-
srv.unref();
|
|
1606
|
-
srv.on("error", reject);
|
|
1607
|
-
srv.listen(0, HOST, () => {
|
|
1608
|
-
const addr = srv.address();
|
|
1609
|
-
if (!addr || typeof addr === "string") {
|
|
1610
|
-
srv.close();
|
|
1611
|
-
reject(new Error("could not get a free local port"));
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
const port = addr.port;
|
|
1615
|
-
srv.close(() => {
|
|
1616
|
-
if (port < EPHEMERAL_MIN || port > EPHEMERAL_MAX) {
|
|
1617
|
-
resolveOk(port);
|
|
1618
|
-
} else {
|
|
1619
|
-
resolveOk(port);
|
|
1620
|
-
}
|
|
1621
|
-
});
|
|
1622
|
-
});
|
|
1623
|
-
});
|
|
1624
|
-
}
|
|
1625
1293
|
var HETZNER_DEFAULT_BOX_IMAGE_REF = "agentbox-base";
|
|
1626
1294
|
var SCAFFOLDING_FALLBACK_IMAGE = "agentbox/box:dev";
|
|
1627
1295
|
var VPS_USER = "vscode";
|
|
@@ -1701,12 +1369,12 @@ function perBoxDir(sandboxId) {
|
|
|
1701
1369
|
}
|
|
1702
1370
|
async function ensurePerBoxState(sandboxId) {
|
|
1703
1371
|
const dir = perBoxDir(sandboxId);
|
|
1704
|
-
const sshDir =
|
|
1705
|
-
await
|
|
1372
|
+
const sshDir = join2(dir, "ssh");
|
|
1373
|
+
await mkdir(sshDir, { recursive: true, mode: 448 });
|
|
1706
1374
|
return {
|
|
1707
1375
|
dir,
|
|
1708
|
-
identity:
|
|
1709
|
-
knownHosts:
|
|
1376
|
+
identity: join2(sshDir, "id_ed25519"),
|
|
1377
|
+
knownHosts: join2(sshDir, "known_hosts")
|
|
1710
1378
|
};
|
|
1711
1379
|
}
|
|
1712
1380
|
function bashScript(s) {
|
|
@@ -1775,7 +1443,7 @@ async function ensureLiveTarget(sandboxId) {
|
|
|
1775
1443
|
throw new Error(`hetzner: server ${String(id)} has no IPv4 address`);
|
|
1776
1444
|
}
|
|
1777
1445
|
const state = await ensurePerBoxState(sandboxId);
|
|
1778
|
-
if (!
|
|
1446
|
+
if (!existsSync3(state.identity)) {
|
|
1779
1447
|
throw new Error(
|
|
1780
1448
|
`hetzner: per-box SSH key missing for sandbox ${sandboxId} (expected at ${state.identity}). If this box was created by a different host, you'll need to re-create it on this host.`
|
|
1781
1449
|
);
|
|
@@ -1868,9 +1536,9 @@ var hetznerBackend = {
|
|
|
1868
1536
|
const state = await ensurePerBoxState(sandboxId);
|
|
1869
1537
|
await rename(key.privatePath, state.identity);
|
|
1870
1538
|
await rename(key.publicPath, `${state.identity}.pub`);
|
|
1871
|
-
await
|
|
1539
|
+
await rm(key.dir, { recursive: true, force: true });
|
|
1872
1540
|
const pendingParent = resolvePath(key.dir, "..");
|
|
1873
|
-
await
|
|
1541
|
+
await rm(pendingParent, { recursive: true, force: true });
|
|
1874
1542
|
const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
|
|
1875
1543
|
if (!up) {
|
|
1876
1544
|
throw new Error(
|
|
@@ -1906,10 +1574,10 @@ var hetznerBackend = {
|
|
|
1906
1574
|
}
|
|
1907
1575
|
}
|
|
1908
1576
|
try {
|
|
1909
|
-
if (
|
|
1577
|
+
if (existsSync3(key.dir)) await rm(key.dir, { recursive: true, force: true });
|
|
1910
1578
|
if (serverId !== null) {
|
|
1911
1579
|
const finalDir = perBoxDir(String(serverId));
|
|
1912
|
-
if (
|
|
1580
|
+
if (existsSync3(finalDir)) await rm(finalDir, { recursive: true, force: true });
|
|
1913
1581
|
}
|
|
1914
1582
|
} catch {
|
|
1915
1583
|
}
|
|
@@ -2000,7 +1668,7 @@ var hetznerBackend = {
|
|
|
2000
1668
|
}
|
|
2001
1669
|
const dir = perBoxDir(h.sandboxId);
|
|
2002
1670
|
try {
|
|
2003
|
-
await
|
|
1671
|
+
await rm(dir, { recursive: true, force: true });
|
|
2004
1672
|
} catch {
|
|
2005
1673
|
}
|
|
2006
1674
|
},
|
|
@@ -2016,7 +1684,7 @@ var hetznerBackend = {
|
|
|
2016
1684
|
`${target.user}@${target.host}`,
|
|
2017
1685
|
bashScript(opts?.cwd ? `cd ${shellQuote(opts.cwd)} && ${cmd}` : cmd)
|
|
2018
1686
|
];
|
|
2019
|
-
const res = await
|
|
1687
|
+
const res = await execa("ssh", argv, {
|
|
2020
1688
|
reject: false,
|
|
2021
1689
|
timeout: opts?.attemptTimeoutMs ?? 12e4,
|
|
2022
1690
|
env: { ...process.env, ...opts?.env ?? {} }
|
|
@@ -2034,7 +1702,7 @@ var hetznerBackend = {
|
|
|
2034
1702
|
localPath,
|
|
2035
1703
|
`${target.user}@${target.host}:${remotePath}`
|
|
2036
1704
|
];
|
|
2037
|
-
const res = await
|
|
1705
|
+
const res = await execa("scp", argv, { reject: false, timeout: 3e5 });
|
|
2038
1706
|
if (res.exitCode !== 0) {
|
|
2039
1707
|
throw new Error(`hetzner: scp upload failed (exit ${String(res.exitCode)}): ${res.stderr || ""}`);
|
|
2040
1708
|
}
|
|
@@ -2046,7 +1714,7 @@ var hetznerBackend = {
|
|
|
2046
1714
|
`${target.user}@${target.host}:${remotePath}`,
|
|
2047
1715
|
localPath
|
|
2048
1716
|
];
|
|
2049
|
-
const res = await
|
|
1717
|
+
const res = await execa("scp", argv, { reject: false, timeout: 3e5 });
|
|
2050
1718
|
if (res.exitCode !== 0) {
|
|
2051
1719
|
throw new Error(`hetzner: scp download failed (exit ${String(res.exitCode)}): ${res.stderr || ""}`);
|
|
2052
1720
|
}
|
|
@@ -2263,9 +1931,9 @@ async function deployControlPlaneToHetzner(opts) {
|
|
|
2263
1931
|
labels: { "agentbox.managed": "true", "agentbox.role": "control-plane" }
|
|
2264
1932
|
})
|
|
2265
1933
|
);
|
|
2266
|
-
const keyDir =
|
|
1934
|
+
const keyDir = join3(homedir3(), ".agentbox", "control-plane", "ssh", stamp);
|
|
2267
1935
|
const key = await mintSshKey(keyDir, `agentbox-control-plane-${stamp}`);
|
|
2268
|
-
const knownHosts =
|
|
1936
|
+
const knownHosts = join3(keyDir, "known_hosts");
|
|
2269
1937
|
log2(`provisioning ${opts.serverType ?? "cx23"} VPS (cloning ${repoUrl}@${repoRef})\u2026`);
|
|
2270
1938
|
const { server } = await withHetznerRetry(
|
|
2271
1939
|
{ method: "createServer", retryOnAmbiguous: false, attemptTimeoutMs: 12e4 },
|
|
@@ -2294,12 +1962,12 @@ async function deployControlPlaneToHetzner(opts) {
|
|
|
2294
1962
|
if (cloned.exitCode !== 0) {
|
|
2295
1963
|
throw new Error("repo clone did not complete on the VPS (cloud-init failed)");
|
|
2296
1964
|
}
|
|
2297
|
-
const staging =
|
|
2298
|
-
await
|
|
1965
|
+
const staging = join3(tmpdir(), `agentbox-cp-deploy-${stamp}`);
|
|
1966
|
+
await mkdir2(staging, { recursive: true });
|
|
2299
1967
|
try {
|
|
2300
|
-
const envLocal =
|
|
2301
|
-
const caddyLocal =
|
|
2302
|
-
const composeLocal =
|
|
1968
|
+
const envLocal = join3(staging, "control-plane.env");
|
|
1969
|
+
const caddyLocal = join3(staging, "Caddyfile");
|
|
1970
|
+
const composeLocal = join3(staging, "docker-compose.caddy.yml");
|
|
2303
1971
|
await writeFile(envLocal, opts.envContent, { mode: 384 });
|
|
2304
1972
|
await writeFile(caddyLocal, caddyfile(domain));
|
|
2305
1973
|
await writeFile(composeLocal, CADDY_COMPOSE);
|
|
@@ -2308,7 +1976,7 @@ async function deployControlPlaneToHetzner(opts) {
|
|
|
2308
1976
|
await scpUpload(target, caddyLocal, `${REMOTE_APP_DIR}/Caddyfile`);
|
|
2309
1977
|
await scpUpload(target, composeLocal, `${REMOTE_APP_DIR}/docker-compose.caddy.yml`);
|
|
2310
1978
|
} finally {
|
|
2311
|
-
await
|
|
1979
|
+
await rm2(staging, { recursive: true, force: true });
|
|
2312
1980
|
}
|
|
2313
1981
|
log2("building + starting the control plane (docker compose up --build)\u2026");
|
|
2314
1982
|
const up = await sshExec(
|
|
@@ -2383,11 +2051,6 @@ export {
|
|
|
2383
2051
|
validateServerChoice,
|
|
2384
2052
|
mapHetznerProvisionError,
|
|
2385
2053
|
mintPrepareKey,
|
|
2386
|
-
sshOptArgs,
|
|
2387
|
-
sshExec,
|
|
2388
|
-
scpUpload,
|
|
2389
|
-
scpDownload,
|
|
2390
|
-
waitForSsh,
|
|
2391
2054
|
prepareHetzner,
|
|
2392
2055
|
prepareHetznerProvider,
|
|
2393
2056
|
ensureHetznerBaseSnapshot,
|
|
@@ -2397,4 +2060,4 @@ export {
|
|
|
2397
2060
|
hetznerProvider,
|
|
2398
2061
|
providerModule
|
|
2399
2062
|
};
|
|
2400
|
-
//# sourceMappingURL=chunk-
|
|
2063
|
+
//# sourceMappingURL=chunk-I2OAJS3L.js.map
|