@madarco/agentbox 0.25.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -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 +962 -583
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-75DIZ55S-5UAKJX3L.js → prepared-state-75DIZ55S-W6NU3S3B.js} +2 -2
- package/package.json +5 -4
- 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 → mrhWWwzD3oh05le9SRnlA}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mrhWWwzD3oh05le9SRnlA}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{fo5EgsHa6PFLTBagfLiuM → mrhWWwzD3oh05le9SRnlA}/_ssgManifest.js +0 -0
|
@@ -32,50 +32,50 @@ import {
|
|
|
32
32
|
validateSizeChoice,
|
|
33
33
|
withDigitalOceanRetry,
|
|
34
34
|
writePreparedState
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-7ZZAZPYX.js";
|
|
36
36
|
import {
|
|
37
37
|
createCloudProvider
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-DJQMK4RN.js";
|
|
39
39
|
import {
|
|
40
40
|
detectPortless,
|
|
41
41
|
portlessDoctorRow
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-UIFL7F2G.js";
|
|
43
43
|
import {
|
|
44
44
|
loadEffectiveConfig
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-JGZSA5ZI.js";
|
|
46
46
|
import {
|
|
47
|
+
SshTunnelManager,
|
|
47
48
|
UserFacingError,
|
|
48
49
|
claudeInstallFingerprint,
|
|
49
50
|
computeContextSha256,
|
|
51
|
+
defaultBoxSshDir,
|
|
50
52
|
describeInbound,
|
|
51
53
|
errSummary,
|
|
52
54
|
mintSshKey,
|
|
53
55
|
parseInboundSpec,
|
|
54
56
|
readCliStamp,
|
|
55
57
|
resolveInboundSources,
|
|
58
|
+
scpDownload,
|
|
59
|
+
scpUpload,
|
|
60
|
+
sshExec,
|
|
61
|
+
sshOptArgs,
|
|
56
62
|
stageAgentsStaticForUpload,
|
|
57
63
|
stageClaudeStaticForUpload,
|
|
58
64
|
stageCodexStaticForUpload,
|
|
59
|
-
stageOpencodeStaticForUpload
|
|
60
|
-
|
|
65
|
+
stageOpencodeStaticForUpload,
|
|
66
|
+
waitForSsh
|
|
67
|
+
} from "./chunk-PK2QF4IR.js";
|
|
61
68
|
import "./chunk-G3H2L3O2.js";
|
|
62
69
|
import "./chunk-WJFZJZIM.js";
|
|
63
70
|
|
|
64
71
|
// ../../packages/sandbox-digitalocean/dist/index.js
|
|
65
|
-
import { existsSync
|
|
66
|
-
import { rm
|
|
67
|
-
import { join as
|
|
68
|
-
import { execa
|
|
72
|
+
import { existsSync } from "fs";
|
|
73
|
+
import { rm, rename, mkdir } from "fs/promises";
|
|
74
|
+
import { join as join2 } from "path";
|
|
75
|
+
import { execa } from "execa";
|
|
69
76
|
import { resolve as resolvePath } from "path";
|
|
70
77
|
import { join } from "path";
|
|
71
78
|
import { dirname, resolve } from "path";
|
|
72
|
-
import { execa } from "execa";
|
|
73
|
-
import { existsSync } from "fs";
|
|
74
|
-
import { mkdir, rm } from "fs/promises";
|
|
75
|
-
import { createServer } from "net";
|
|
76
|
-
import { homedir } from "os";
|
|
77
|
-
import { dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
78
|
-
import { execa as execa2 } from "execa";
|
|
79
79
|
function generatePrepareCloudInit(opts) {
|
|
80
80
|
const pubkey = opts.sshPubkey.trim();
|
|
81
81
|
return [
|
|
@@ -179,8 +179,8 @@ async function mintPrepareKey() {
|
|
|
179
179
|
...key,
|
|
180
180
|
cleanup: async () => {
|
|
181
181
|
try {
|
|
182
|
-
const { rm:
|
|
183
|
-
await
|
|
182
|
+
const { rm: rm2 } = await import("fs/promises");
|
|
183
|
+
await rm2(dirname(key.privatePath), { recursive: true, force: true });
|
|
184
184
|
} catch {
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -193,115 +193,6 @@ function homedirOrCwd() {
|
|
|
193
193
|
return process.cwd();
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function sshOptArgs(target) {
|
|
197
|
-
const out = [
|
|
198
|
-
"-i",
|
|
199
|
-
target.identity,
|
|
200
|
-
"-o",
|
|
201
|
-
"StrictHostKeyChecking=accept-new",
|
|
202
|
-
"-o",
|
|
203
|
-
`UserKnownHostsFile=${target.knownHosts}`,
|
|
204
|
-
"-o",
|
|
205
|
-
"GlobalKnownHostsFile=/dev/null",
|
|
206
|
-
"-o",
|
|
207
|
-
"BatchMode=yes",
|
|
208
|
-
"-o",
|
|
209
|
-
"LogLevel=ERROR",
|
|
210
|
-
// Detect a dead/stalled peer and drop the connection instead of hanging
|
|
211
|
-
// forever. The per-box firewall is locked to the host's egress IP, so if
|
|
212
|
-
// that IP flaps mid-command (roaming Wi-Fi, VPN toggle) the return traffic
|
|
213
|
-
// is silently dropped and the ssh channel would otherwise block with no
|
|
214
|
-
// EOF — seen as a `prepare`/`exec` that never returns. 15s * 4 = a ~60s
|
|
215
|
-
// fail-fast so callers (retry wrappers, prepare cleanup) can react.
|
|
216
|
-
"-o",
|
|
217
|
-
"ServerAliveInterval=15",
|
|
218
|
-
"-o",
|
|
219
|
-
"ServerAliveCountMax=4"
|
|
220
|
-
];
|
|
221
|
-
if (target.controlPath) {
|
|
222
|
-
out.push("-o", `ControlPath=${target.controlPath}`);
|
|
223
|
-
}
|
|
224
|
-
for (const [k, v] of Object.entries(target.options ?? {})) {
|
|
225
|
-
out.push("-o", `${k}=${v}`);
|
|
226
|
-
}
|
|
227
|
-
return out;
|
|
228
|
-
}
|
|
229
|
-
async function sshExec(target, remoteCmd, opts = {}) {
|
|
230
|
-
const argv = [
|
|
231
|
-
...sshOptArgs(target),
|
|
232
|
-
`${target.user}@${target.host}`,
|
|
233
|
-
remoteCmd
|
|
234
|
-
];
|
|
235
|
-
const child = execa("ssh", argv, {
|
|
236
|
-
reject: false,
|
|
237
|
-
timeout: opts.timeoutMs,
|
|
238
|
-
env: { ...process.env, ...opts.env },
|
|
239
|
-
stdio: opts.onLine ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe"]
|
|
240
|
-
});
|
|
241
|
-
if (opts.onLine) {
|
|
242
|
-
const handle = (chunk) => {
|
|
243
|
-
const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
244
|
-
for (const line of text.split(/\r?\n/)) {
|
|
245
|
-
if (line.length > 0) opts.onLine?.(line);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
child.stdout?.on("data", handle);
|
|
249
|
-
child.stderr?.on("data", handle);
|
|
250
|
-
}
|
|
251
|
-
const res = await child;
|
|
252
|
-
return {
|
|
253
|
-
exitCode: typeof res.exitCode === "number" ? res.exitCode : 1,
|
|
254
|
-
stdout: typeof res.stdout === "string" ? res.stdout : "",
|
|
255
|
-
stderr: typeof res.stderr === "string" ? res.stderr : ""
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
async function scpUpload(target, localPath, remotePath, opts = {}) {
|
|
259
|
-
const argv = [
|
|
260
|
-
...sshOptArgs(target),
|
|
261
|
-
localPath,
|
|
262
|
-
`${target.user}@${target.host}:${remotePath}`
|
|
263
|
-
];
|
|
264
|
-
const res = await execa("scp", argv, {
|
|
265
|
-
reject: false,
|
|
266
|
-
timeout: opts.timeoutMs
|
|
267
|
-
});
|
|
268
|
-
if (res.exitCode !== 0) {
|
|
269
|
-
throw new Error(
|
|
270
|
-
`scp upload failed (exit ${String(res.exitCode)}): ${localPath} \u2192 ${remotePath}
|
|
271
|
-
${res.stderr ?? ""}`
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
async function scpDownload(target, remotePath, localPath, opts = {}) {
|
|
276
|
-
const argv = [
|
|
277
|
-
...sshOptArgs(target),
|
|
278
|
-
`${target.user}@${target.host}:${remotePath}`,
|
|
279
|
-
localPath
|
|
280
|
-
];
|
|
281
|
-
const res = await execa("scp", argv, {
|
|
282
|
-
reject: false,
|
|
283
|
-
timeout: opts.timeoutMs
|
|
284
|
-
});
|
|
285
|
-
if (res.exitCode !== 0) {
|
|
286
|
-
throw new Error(
|
|
287
|
-
`scp download failed (exit ${String(res.exitCode)}): ${remotePath} \u2192 ${localPath}
|
|
288
|
-
${res.stderr ?? ""}`
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
async function waitForSsh(target, deadlineMs, intervalMs = 5e3) {
|
|
293
|
-
const stop = Date.now() + deadlineMs;
|
|
294
|
-
while (Date.now() < stop) {
|
|
295
|
-
const res = await sshExec(
|
|
296
|
-
{ ...target, options: { ...target.options, ConnectTimeout: "5" } },
|
|
297
|
-
"true",
|
|
298
|
-
{ timeoutMs: 1e4 }
|
|
299
|
-
);
|
|
300
|
-
if (res.exitCode === 0) return true;
|
|
301
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
302
|
-
}
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
305
196
|
var TEMP_SIZE_DEFAULT = "s-2vcpu-4gb";
|
|
306
197
|
var TEMP_REGION_DEFAULT = "nyc3";
|
|
307
198
|
var STOCK_IMAGE_SLUG = "ubuntu-24-04-x64";
|
|
@@ -570,238 +461,15 @@ async function ensureDigitalOceanBaseSnapshot() {
|
|
|
570
461
|
"no DigitalOcean base snapshot found.\nRun `agentbox prepare --provider digitalocean` first (DigitalOcean cannot build images from a Dockerfile,\nso the base snapshot is a one-time prerequisite for cloud boxes on this backend)."
|
|
571
462
|
);
|
|
572
463
|
}
|
|
573
|
-
var
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
* up for this box (socket exists + responsive), no-op. Otherwise spawn a
|
|
581
|
-
* fresh `ssh -fNT -M` and wait for the socket to appear.
|
|
582
|
-
*/
|
|
583
|
-
async open(opts) {
|
|
584
|
-
const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
|
|
585
|
-
await mkdir(boxSshDir, { recursive: true, mode: 448 });
|
|
586
|
-
const controlPath = join2(boxSshDir, "control.sock");
|
|
587
|
-
const knownHosts = join2(boxSshDir, "known_hosts");
|
|
588
|
-
const user = opts.vpsUser ?? "vscode";
|
|
589
|
-
const tunnel = {
|
|
590
|
-
controlPath,
|
|
591
|
-
vpsHost: opts.vpsHost,
|
|
592
|
-
vpsUser: user,
|
|
593
|
-
identity: opts.identity,
|
|
594
|
-
boxSshDir,
|
|
595
|
-
forwards: /* @__PURE__ */ new Map()
|
|
596
|
-
};
|
|
597
|
-
if (existsSync(controlPath) && await this.isAlive(controlPath)) {
|
|
598
|
-
this.boxes.set(opts.boxId, tunnel);
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
if (existsSync(controlPath)) {
|
|
602
|
-
await rm(controlPath, { force: true });
|
|
603
|
-
}
|
|
604
|
-
const connectTimeout = opts.connectTimeoutSeconds ?? 10;
|
|
605
|
-
const argv = [
|
|
606
|
-
"-fNT",
|
|
607
|
-
"-M",
|
|
608
|
-
"-S",
|
|
609
|
-
controlPath,
|
|
610
|
-
"-i",
|
|
611
|
-
opts.identity,
|
|
612
|
-
"-o",
|
|
613
|
-
"StrictHostKeyChecking=accept-new",
|
|
614
|
-
"-o",
|
|
615
|
-
`UserKnownHostsFile=${knownHosts}`,
|
|
616
|
-
"-o",
|
|
617
|
-
"GlobalKnownHostsFile=/dev/null",
|
|
618
|
-
"-o",
|
|
619
|
-
"BatchMode=yes",
|
|
620
|
-
"-o",
|
|
621
|
-
"LogLevel=ERROR",
|
|
622
|
-
"-o",
|
|
623
|
-
"ExitOnForwardFailure=yes",
|
|
624
|
-
"-o",
|
|
625
|
-
"ServerAliveInterval=30",
|
|
626
|
-
"-o",
|
|
627
|
-
"ServerAliveCountMax=3",
|
|
628
|
-
"-o",
|
|
629
|
-
`ConnectTimeout=${String(connectTimeout)}`,
|
|
630
|
-
`${user}@${opts.vpsHost}`
|
|
631
|
-
];
|
|
632
|
-
const res = await execa2("ssh", argv, { reject: false });
|
|
633
|
-
if (res.exitCode !== 0 || !existsSync(controlPath)) {
|
|
634
|
-
throw new Error(
|
|
635
|
-
`ssh ControlMaster failed for ${opts.boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
this.boxes.set(opts.boxId, tunnel);
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Mint (or fetch the cached) `127.0.0.1:<localPort> → vps:127.0.0.1:<remotePort>`
|
|
642
|
-
* forward. Returns the local port. Idempotent per (boxId, remotePort).
|
|
643
|
-
*
|
|
644
|
-
* The cached entry is only returned when the underlying ControlMaster is
|
|
645
|
-
* still alive — without that check we'd happily hand back a localPort that
|
|
646
|
-
* stopped listening when the master died (e.g. transient network blip,
|
|
647
|
-
* host sleep/wake). When the master is dead we drop ALL cached forwards
|
|
648
|
-
* for this box (they all share one tunnel) and re-mint from scratch.
|
|
649
|
-
*/
|
|
650
|
-
async forward(boxId, remotePort) {
|
|
651
|
-
const tunnel = this.getTunnelOrThrow(boxId);
|
|
652
|
-
const cached = tunnel.forwards.get(remotePort);
|
|
653
|
-
if (cached !== void 0 && await this.isAlive(tunnel.controlPath)) {
|
|
654
|
-
return cached;
|
|
655
|
-
}
|
|
656
|
-
if (cached !== void 0) {
|
|
657
|
-
tunnel.forwards.clear();
|
|
658
|
-
}
|
|
659
|
-
const localPort = await pickFreePort();
|
|
660
|
-
const argv = [
|
|
661
|
-
"-O",
|
|
662
|
-
"forward",
|
|
663
|
-
"-L",
|
|
664
|
-
`${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
|
|
665
|
-
"-S",
|
|
666
|
-
tunnel.controlPath,
|
|
667
|
-
"dummy"
|
|
668
|
-
// the target host is ignored when -O is used, but argv needs one
|
|
669
|
-
];
|
|
670
|
-
const res = await execa2("ssh", argv, { reject: false });
|
|
671
|
-
if (res.exitCode !== 0) {
|
|
672
|
-
throw new Error(
|
|
673
|
-
`ssh -O forward failed for ${boxId} (exit ${String(res.exitCode)}): ${res.stderr || res.stdout || "(no output)"}`
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
tunnel.forwards.set(remotePort, localPort);
|
|
677
|
-
return localPort;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Tear down a dead ControlMaster + every cached forward for this box,
|
|
681
|
-
* then re-open from scratch. Idempotent — if the master is already alive
|
|
682
|
-
* the master open() is a no-op, but the cached forwards still get
|
|
683
|
-
* cleared so the next forward() call re-mints them. Returns when the
|
|
684
|
-
* master is open and the box's forwards map is empty (ready for fresh
|
|
685
|
-
* forward() calls).
|
|
686
|
-
*
|
|
687
|
-
* Use case: the cloud-poller observes ECONNREFUSED on the local port and
|
|
688
|
-
* asks the backend to refresh the preview URL — that path calls into
|
|
689
|
-
* here so the master + forward both come back fresh.
|
|
690
|
-
*/
|
|
691
|
-
async refresh(opts) {
|
|
692
|
-
const existing = this.boxes.get(opts.boxId);
|
|
693
|
-
if (existing) {
|
|
694
|
-
const alive = await this.isAlive(existing.controlPath);
|
|
695
|
-
if (!alive && existsSync(existing.controlPath)) {
|
|
696
|
-
try {
|
|
697
|
-
await execa2(
|
|
698
|
-
"ssh",
|
|
699
|
-
["-O", "exit", "-S", existing.controlPath, "dummy"],
|
|
700
|
-
{ reject: false }
|
|
701
|
-
);
|
|
702
|
-
} catch {
|
|
703
|
-
}
|
|
704
|
-
await rm(existing.controlPath, { force: true });
|
|
705
|
-
}
|
|
706
|
-
existing.forwards.clear();
|
|
707
|
-
}
|
|
708
|
-
await this.open(opts);
|
|
709
|
-
}
|
|
710
|
-
/** Tear down a single forward. Idempotent — unknown ports are no-ops. */
|
|
711
|
-
async unforward(boxId, remotePort) {
|
|
712
|
-
const tunnel = this.getTunnelOrThrow(boxId);
|
|
713
|
-
const localPort = tunnel.forwards.get(remotePort);
|
|
714
|
-
if (localPort === void 0) return;
|
|
715
|
-
const argv = [
|
|
716
|
-
"-O",
|
|
717
|
-
"cancel",
|
|
718
|
-
"-L",
|
|
719
|
-
`${HOST}:${String(localPort)}:${HOST}:${String(remotePort)}`,
|
|
720
|
-
"-S",
|
|
721
|
-
tunnel.controlPath,
|
|
722
|
-
"dummy"
|
|
723
|
-
];
|
|
724
|
-
await execa2("ssh", argv, { reject: false });
|
|
725
|
-
tunnel.forwards.delete(remotePort);
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* Close the ControlMaster (and all its forwards). Idempotent — if no
|
|
729
|
-
* master is recorded, no-op. Removes the socket file.
|
|
730
|
-
*/
|
|
731
|
-
async close(boxId) {
|
|
732
|
-
const tunnel = this.boxes.get(boxId);
|
|
733
|
-
if (!tunnel) return;
|
|
734
|
-
if (existsSync(tunnel.controlPath)) {
|
|
735
|
-
await execa2("ssh", ["-O", "exit", "-S", tunnel.controlPath, "dummy"], { reject: false });
|
|
736
|
-
await rm(tunnel.controlPath, { force: true });
|
|
737
|
-
}
|
|
738
|
-
this.boxes.delete(boxId);
|
|
739
|
-
}
|
|
740
|
-
/** Tear down every open box. */
|
|
741
|
-
async closeAll() {
|
|
742
|
-
const ids = Array.from(this.boxes.keys());
|
|
743
|
-
await Promise.all(ids.map((id) => this.close(id)));
|
|
744
|
-
}
|
|
745
|
-
/** Path to the ControlMaster socket for `boxId`, if open. */
|
|
746
|
-
controlPath(boxId) {
|
|
747
|
-
return this.boxes.get(boxId)?.controlPath;
|
|
748
|
-
}
|
|
749
|
-
/** True if a ControlMaster is registered for `boxId` (regardless of liveness). */
|
|
750
|
-
has(boxId) {
|
|
751
|
-
return this.boxes.has(boxId);
|
|
752
|
-
}
|
|
753
|
-
/** Per-box ssh dir (tests use this to verify the layout). */
|
|
754
|
-
boxSshDir(boxId) {
|
|
755
|
-
return this.boxes.get(boxId)?.boxSshDir;
|
|
756
|
-
}
|
|
757
|
-
/** Re-open the manager record for an existing-on-disk control socket. */
|
|
758
|
-
registerExisting(boxId, opts) {
|
|
759
|
-
const boxSshDir = opts.boxSshDir ?? defaultBoxSshDir(opts.boxId);
|
|
760
|
-
this.boxes.set(boxId, {
|
|
761
|
-
controlPath: join2(boxSshDir, "control.sock"),
|
|
762
|
-
vpsHost: opts.vpsHost,
|
|
763
|
-
vpsUser: opts.vpsUser ?? "vscode",
|
|
764
|
-
identity: opts.identity,
|
|
765
|
-
boxSshDir,
|
|
766
|
-
forwards: /* @__PURE__ */ new Map()
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
async isAlive(controlPath) {
|
|
770
|
-
const res = await execa2("ssh", ["-O", "check", "-S", controlPath, "dummy"], { reject: false });
|
|
771
|
-
return res.exitCode === 0;
|
|
772
|
-
}
|
|
773
|
-
getTunnelOrThrow(boxId) {
|
|
774
|
-
const t = this.boxes.get(boxId);
|
|
775
|
-
if (!t) throw new Error(`no SSH ControlMaster registered for box ${boxId}; call open() first`);
|
|
776
|
-
return t;
|
|
464
|
+
var DIGITALOCEAN_SSH_NAMESPACE = "digitalocean";
|
|
465
|
+
function defaultBoxSshDir2(boxId) {
|
|
466
|
+
return defaultBoxSshDir(boxId, DIGITALOCEAN_SSH_NAMESPACE);
|
|
467
|
+
}
|
|
468
|
+
var SshTunnelManager2 = class extends SshTunnelManager {
|
|
469
|
+
constructor() {
|
|
470
|
+
super(DIGITALOCEAN_SSH_NAMESPACE);
|
|
777
471
|
}
|
|
778
472
|
};
|
|
779
|
-
function defaultBoxSshDir(boxId) {
|
|
780
|
-
return resolve2(homedir(), ".agentbox", "digitalocean", "boxes", boxId, "ssh");
|
|
781
|
-
}
|
|
782
|
-
async function pickFreePort() {
|
|
783
|
-
return new Promise((resolveOk, reject) => {
|
|
784
|
-
const srv = createServer();
|
|
785
|
-
srv.unref();
|
|
786
|
-
srv.on("error", reject);
|
|
787
|
-
srv.listen(0, HOST, () => {
|
|
788
|
-
const addr = srv.address();
|
|
789
|
-
if (!addr || typeof addr === "string") {
|
|
790
|
-
srv.close();
|
|
791
|
-
reject(new Error("could not get a free local port"));
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
const port = addr.port;
|
|
795
|
-
srv.close(() => {
|
|
796
|
-
if (port < EPHEMERAL_MIN || port > EPHEMERAL_MAX) {
|
|
797
|
-
resolveOk(port);
|
|
798
|
-
} else {
|
|
799
|
-
resolveOk(port);
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
});
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
473
|
var DIGITALOCEAN_DEFAULT_BOX_IMAGE_REF = "agentbox-base";
|
|
806
474
|
var SCAFFOLDING_FALLBACK_IMAGE = "agentbox/box:dev";
|
|
807
475
|
var VPS_USER = "vscode";
|
|
@@ -825,7 +493,7 @@ function cloudInitBoxEnv(env = {}) {
|
|
|
825
493
|
}
|
|
826
494
|
return out;
|
|
827
495
|
}
|
|
828
|
-
var tunnels = new
|
|
496
|
+
var tunnels = new SshTunnelManager2();
|
|
829
497
|
function mapState(s) {
|
|
830
498
|
switch (s) {
|
|
831
499
|
case "active":
|
|
@@ -888,16 +556,16 @@ async function resolveImageRef(c, req) {
|
|
|
888
556
|
return ref;
|
|
889
557
|
}
|
|
890
558
|
function perBoxDir(sandboxId) {
|
|
891
|
-
return resolvePath(
|
|
559
|
+
return resolvePath(defaultBoxSshDir2(sandboxId), "..");
|
|
892
560
|
}
|
|
893
561
|
async function ensurePerBoxState(sandboxId) {
|
|
894
562
|
const dir = perBoxDir(sandboxId);
|
|
895
|
-
const sshDir =
|
|
896
|
-
await
|
|
563
|
+
const sshDir = join2(dir, "ssh");
|
|
564
|
+
await mkdir(sshDir, { recursive: true, mode: 448 });
|
|
897
565
|
return {
|
|
898
566
|
dir,
|
|
899
|
-
identity:
|
|
900
|
-
knownHosts:
|
|
567
|
+
identity: join2(sshDir, "id_ed25519"),
|
|
568
|
+
knownHosts: join2(sshDir, "known_hosts")
|
|
901
569
|
};
|
|
902
570
|
}
|
|
903
571
|
function bashScript(s) {
|
|
@@ -934,7 +602,7 @@ async function ensureLiveTarget(sandboxId) {
|
|
|
934
602
|
throw new Error(`digitalocean: droplet ${String(id)} has no public IPv4 address`);
|
|
935
603
|
}
|
|
936
604
|
const state = await ensurePerBoxState(sandboxId);
|
|
937
|
-
if (!
|
|
605
|
+
if (!existsSync(state.identity)) {
|
|
938
606
|
throw new Error(
|
|
939
607
|
`digitalocean: per-box SSH key missing for sandbox ${sandboxId} (expected at ${state.identity}). If this box was created by a different host, you'll need to re-create it on this host.`
|
|
940
608
|
);
|
|
@@ -1041,9 +709,9 @@ var digitaloceanBackend = {
|
|
|
1041
709
|
const state = await ensurePerBoxState(sandboxId);
|
|
1042
710
|
await rename(key.privatePath, state.identity);
|
|
1043
711
|
await rename(key.publicPath, `${state.identity}.pub`);
|
|
1044
|
-
await
|
|
712
|
+
await rm(key.dir, { recursive: true, force: true });
|
|
1045
713
|
const pendingParent = resolvePath(key.dir, "..");
|
|
1046
|
-
await
|
|
714
|
+
await rm(pendingParent, { recursive: true, force: true });
|
|
1047
715
|
const up = await waitForSsh(buildSshTarget(state, vpsIp), PROVISION_SSH_DEADLINE_MS);
|
|
1048
716
|
if (!up) {
|
|
1049
717
|
throw new Error(
|
|
@@ -1079,10 +747,10 @@ var digitaloceanBackend = {
|
|
|
1079
747
|
}
|
|
1080
748
|
}
|
|
1081
749
|
try {
|
|
1082
|
-
if (
|
|
750
|
+
if (existsSync(key.dir)) await rm(key.dir, { recursive: true, force: true });
|
|
1083
751
|
if (dropletId !== null) {
|
|
1084
752
|
const finalDir = perBoxDir(String(dropletId));
|
|
1085
|
-
if (
|
|
753
|
+
if (existsSync(finalDir)) await rm(finalDir, { recursive: true, force: true });
|
|
1086
754
|
}
|
|
1087
755
|
} catch {
|
|
1088
756
|
}
|
|
@@ -1207,7 +875,7 @@ var digitaloceanBackend = {
|
|
|
1207
875
|
}
|
|
1208
876
|
const dir = perBoxDir(h.sandboxId);
|
|
1209
877
|
try {
|
|
1210
|
-
await
|
|
878
|
+
await rm(dir, { recursive: true, force: true });
|
|
1211
879
|
} catch {
|
|
1212
880
|
}
|
|
1213
881
|
},
|
|
@@ -1223,7 +891,7 @@ var digitaloceanBackend = {
|
|
|
1223
891
|
`${target.user}@${target.host}`,
|
|
1224
892
|
bashScript(opts?.cwd ? `cd ${shellQuote(opts.cwd)} && ${cmd}` : cmd)
|
|
1225
893
|
];
|
|
1226
|
-
const res = await
|
|
894
|
+
const res = await execa("ssh", argv, {
|
|
1227
895
|
reject: false,
|
|
1228
896
|
timeout: opts?.attemptTimeoutMs ?? 12e4,
|
|
1229
897
|
env: { ...process.env, ...opts?.env ?? {} }
|
|
@@ -1237,7 +905,7 @@ var digitaloceanBackend = {
|
|
|
1237
905
|
async uploadFile(h, localPath, remotePath) {
|
|
1238
906
|
const { target } = await ensureLiveTarget(h.sandboxId);
|
|
1239
907
|
const argv = [...sshOptArgs(target), localPath, `${target.user}@${target.host}:${remotePath}`];
|
|
1240
|
-
const res = await
|
|
908
|
+
const res = await execa("scp", argv, { reject: false, timeout: 3e5 });
|
|
1241
909
|
if (res.exitCode !== 0) {
|
|
1242
910
|
throw new Error(`digitalocean: scp upload failed (exit ${String(res.exitCode)}): ${res.stderr || ""}`);
|
|
1243
911
|
}
|
|
@@ -1245,7 +913,7 @@ var digitaloceanBackend = {
|
|
|
1245
913
|
async downloadFile(h, remotePath, localPath) {
|
|
1246
914
|
const { target } = await ensureLiveTarget(h.sandboxId);
|
|
1247
915
|
const argv = [...sshOptArgs(target), `${target.user}@${target.host}:${remotePath}`, localPath];
|
|
1248
|
-
const res = await
|
|
916
|
+
const res = await execa("scp", argv, { reject: false, timeout: 3e5 });
|
|
1249
917
|
if (res.exitCode !== 0) {
|
|
1250
918
|
throw new Error(`digitalocean: scp download failed (exit ${String(res.exitCode)}): ${res.stderr || ""}`);
|
|
1251
919
|
}
|
|
@@ -1415,4 +1083,4 @@ export {
|
|
|
1415
1083
|
withDigitalOceanRetry,
|
|
1416
1084
|
writePreparedState
|
|
1417
1085
|
};
|
|
1418
|
-
//# sourceMappingURL=dist-
|
|
1086
|
+
//# sourceMappingURL=dist-5IICYSR6.js.map
|