@madarco/agentbox 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +8 -7
- package/dist/{_cloud-attach-W2CFNXKO.js → _cloud-attach-7WRQH6XZ.js} +5 -5
- package/dist/{chunk-7PRLM3PH.js → chunk-7ZZAZPYX.js} +3 -3
- package/dist/{chunk-LU3WAHTU.js → chunk-BA2VLJVU.js} +3 -3
- package/dist/{chunk-GHFIKSBJ.js → chunk-DJQMK4RN.js} +12 -4
- package/dist/chunk-DJQMK4RN.js.map +1 -0
- package/dist/{chunk-4UNSBU5R.js → chunk-DQHMDDAT.js} +2 -2
- package/dist/{chunk-LCZOQTIX.js → chunk-I2OAJS3L.js} +40 -377
- package/dist/{chunk-LCZOQTIX.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-7C5MOA4Z.js → chunk-K5KOLYIL.js} +3 -3
- package/dist/{chunk-Y3OPQWAQ.js → chunk-PK2QF4IR.js} +576 -198
- package/dist/chunk-PK2QF4IR.js.map +1 -0
- package/dist/{chunk-VZC5J44U.js → chunk-UIFL7F2G.js} +55 -38
- package/dist/chunk-UIFL7F2G.js.map +1 -0
- package/dist/{chunk-NH3W6HUZ.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-IGQNVIV3.js → dist-5IICYSR6.js} +42 -374
- package/dist/{dist-IGQNVIV3.js.map → dist-5IICYSR6.js.map} +1 -1
- package/dist/{dist-KL73Z37T.js → dist-AR5CHRSV.js} +86 -45
- package/dist/{dist-KL73Z37T.js.map → dist-AR5CHRSV.js.map} +1 -1
- package/dist/{dist-3V5SLNK4.js → dist-DTNYMBQ5.js} +12 -12
- package/dist/{dist-UB3PYSCG.js → dist-K4LNH3EC.js} +6 -6
- package/dist/{dist-BIDAC4H4.js → dist-POVRY7HO.js} +8 -4
- package/dist/{dist-SBDYDH7H.js → dist-U2SVLJUQ.js} +4 -2
- package/dist/{dist-I5OBPLP2.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-OBM2F7CU-DY7TZV4R.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-LNHPLR3L.js → chunk-4QY2VZCF.js} +509 -135
- package/runtime/hub/apps/hub/{chunk-QBJOF5D3.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-MA73PTOR.js → chunk-XZZXPEVV.js} +58 -37
- package/runtime/hub/apps/hub/{dist-7LB4D4ZQ.js → dist-3ENKQN5G.js} +35 -365
- package/runtime/hub/apps/hub/{dist-SIQJD72C.js → dist-6VGJOQYK.js} +84 -43
- package/runtime/hub/apps/hub/{dist-ERQDDSOY.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-ZVY2FWG6.js → dist-RJJ2SDYO.js} +4 -4
- package/runtime/hub/apps/hub/{dist-26KVXHXV.js → dist-TU7D6UTB.js} +37 -366
- package/runtime/hub/apps/hub/{dist-YZJA4WRV.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-OBM2F7CU-ZEYFNYFI.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-5F5SOSDY.js.map +0 -1
- package/dist/chunk-GHFIKSBJ.js.map +0 -1
- package/dist/chunk-NH3W6HUZ.js.map +0 -1
- package/dist/chunk-VZC5J44U.js.map +0 -1
- package/dist/chunk-Y3OPQWAQ.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-W2CFNXKO.js.map → _cloud-attach-7WRQH6XZ.js.map} +0 -0
- /package/dist/{chunk-7PRLM3PH.js.map → chunk-7ZZAZPYX.js.map} +0 -0
- /package/dist/{chunk-LU3WAHTU.js.map → chunk-BA2VLJVU.js.map} +0 -0
- /package/dist/{chunk-4UNSBU5R.js.map → chunk-DQHMDDAT.js.map} +0 -0
- /package/dist/{chunk-7C5MOA4Z.js.map → chunk-K5KOLYIL.js.map} +0 -0
- /package/dist/{dist-3V5SLNK4.js.map → dist-DTNYMBQ5.js.map} +0 -0
- /package/dist/{dist-UB3PYSCG.js.map → dist-K4LNH3EC.js.map} +0 -0
- /package/dist/{dist-BIDAC4H4.js.map → dist-POVRY7HO.js.map} +0 -0
- /package/dist/{dist-I5OBPLP2.js.map → dist-U2SVLJUQ.js.map} +0 -0
- /package/dist/{dist-SBDYDH7H.js.map → dist-XYY6SIKG.js.map} +0 -0
- /package/dist/{prepared-state-OBM2F7CU-DY7TZV4R.js.map → prepared-state-75DIZ55S-W6NU3S3B.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{c82uDoByt-dPQUHilRojD → mrhWWwzD3oh05le9SRnlA}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
quoteShellArg,
|
|
4
|
+
quoteShellArgv
|
|
5
|
+
} from "./chunk-DJQMK4RN.js";
|
|
6
|
+
import {
|
|
7
|
+
SshTunnelManager,
|
|
8
|
+
readCliStamp,
|
|
9
|
+
readPreparedStateRaw,
|
|
10
|
+
sshDestination,
|
|
11
|
+
sshExec,
|
|
12
|
+
sshOptArgs,
|
|
13
|
+
writePreparedStateRaw
|
|
14
|
+
} from "./chunk-PK2QF4IR.js";
|
|
15
|
+
|
|
16
|
+
// ../../packages/sandbox-remote-docker/dist/chunk-KUTRXVTK.js
|
|
17
|
+
import { execa } from "execa";
|
|
18
|
+
function containerNameFor(boxName) {
|
|
19
|
+
return `agentbox-${boxName}`;
|
|
20
|
+
}
|
|
21
|
+
function parseRemoteTarget(spec) {
|
|
22
|
+
const raw = spec.trim();
|
|
23
|
+
if (raw.length === 0) {
|
|
24
|
+
throw new Error("remote-docker: empty SSH destination");
|
|
25
|
+
}
|
|
26
|
+
if (raw.includes("/")) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`remote-docker: invalid SSH destination "${raw}" \u2014 "/" separates the destination from the container in a sandbox id`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const at = raw.lastIndexOf("@");
|
|
32
|
+
const user = at >= 0 ? raw.slice(0, at) : void 0;
|
|
33
|
+
const hostPort = at >= 0 ? raw.slice(at + 1) : raw;
|
|
34
|
+
if (hostPort.length === 0 || user !== void 0 && user.length === 0) {
|
|
35
|
+
throw new Error(`remote-docker: invalid SSH destination "${raw}"`);
|
|
36
|
+
}
|
|
37
|
+
const bracketed = /^\[(.+)\](?::(\d+))?$/.exec(hostPort);
|
|
38
|
+
if (bracketed?.[1]) {
|
|
39
|
+
const host = bracketed[1];
|
|
40
|
+
if (bracketed[2] === void 0) return { host, user, spec: raw };
|
|
41
|
+
return { host, user, port: checkedPort(bracketed[2], raw), spec: raw };
|
|
42
|
+
}
|
|
43
|
+
if (hostPort.includes(":")) {
|
|
44
|
+
const colon = hostPort.lastIndexOf(":");
|
|
45
|
+
const head = hostPort.slice(0, colon);
|
|
46
|
+
const tail = hostPort.slice(colon + 1);
|
|
47
|
+
if (!head.includes(":") && /^\d+$/.test(tail)) {
|
|
48
|
+
return { host: head, user, port: checkedPort(tail, raw), spec: raw };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { host: hostPort, user, spec: raw };
|
|
52
|
+
}
|
|
53
|
+
function checkedPort(digits, raw) {
|
|
54
|
+
const port = Number.parseInt(digits, 10);
|
|
55
|
+
if (port <= 0 || port > 65535) {
|
|
56
|
+
throw new Error(`remote-docker: invalid SSH port in "${raw}"`);
|
|
57
|
+
}
|
|
58
|
+
return port;
|
|
59
|
+
}
|
|
60
|
+
function makeSandboxId(targetSpec, container) {
|
|
61
|
+
parseRemoteTarget(targetSpec);
|
|
62
|
+
return `${targetSpec}/${container}`;
|
|
63
|
+
}
|
|
64
|
+
function parseSandboxId(sandboxId) {
|
|
65
|
+
const slash = sandboxId.lastIndexOf("/");
|
|
66
|
+
if (slash <= 0 || slash === sandboxId.length - 1) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`remote-docker: malformed sandbox id "${sandboxId}" \u2014 expected "<ssh-destination>/<container>"`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
target: parseRemoteTarget(sandboxId.slice(0, slash)),
|
|
73
|
+
container: sandboxId.slice(slash + 1)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function sshTargetFor(target, controlPath) {
|
|
77
|
+
return {
|
|
78
|
+
host: target.host,
|
|
79
|
+
...target.user !== void 0 ? { user: target.user } : {},
|
|
80
|
+
...target.port !== void 0 ? { port: target.port } : {},
|
|
81
|
+
...controlPath !== void 0 ? { controlPath } : {}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
var tunnels = new SshTunnelManager("remote-docker");
|
|
85
|
+
async function ensureTunnel(sandboxId, target) {
|
|
86
|
+
if (!tunnels.has(sandboxId)) {
|
|
87
|
+
try {
|
|
88
|
+
await tunnels.open({
|
|
89
|
+
boxId: sandboxId,
|
|
90
|
+
vpsHost: target.host,
|
|
91
|
+
...target.user !== void 0 ? { vpsUser: target.user } : {},
|
|
92
|
+
...target.port !== void 0 ? { port: target.port } : {}
|
|
93
|
+
});
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
96
|
+
throw new Error(
|
|
97
|
+
`remote-docker: cannot SSH to "${target.spec}". Check that \`ssh ${target.spec} true\` works from this machine (the provider uses your own ~/.ssh/config, agent and known_hosts \u2014 it mints no keys).
|
|
98
|
+
${msg}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const controlPath = tunnels.controlPath(sandboxId);
|
|
103
|
+
return sshTargetFor(target, controlPath);
|
|
104
|
+
}
|
|
105
|
+
async function refreshTunnel(sandboxId, target) {
|
|
106
|
+
await tunnels.refresh({
|
|
107
|
+
boxId: sandboxId,
|
|
108
|
+
vpsHost: target.host,
|
|
109
|
+
...target.user !== void 0 ? { vpsUser: target.user } : {},
|
|
110
|
+
...target.port !== void 0 ? { port: target.port } : {}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async function dockerOnRemote(target, argv, opts = {}) {
|
|
114
|
+
return sshExec(target, loginShell(`docker ${quoteShellArgv(argv)}`), {
|
|
115
|
+
...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {},
|
|
116
|
+
...opts.onLine !== void 0 ? { onLine: opts.onLine } : {}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async function dockerOnRemoteOrThrow(target, argv, opts = {}) {
|
|
120
|
+
const res = await dockerOnRemote(target, argv, opts);
|
|
121
|
+
if (res.exitCode !== 0) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`remote-docker: \`docker ${argv.join(" ")}\` failed (exit ${String(res.exitCode)}): ${res.stderr.trim() || res.stdout.trim() || "(no output)"}`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return res.stdout;
|
|
127
|
+
}
|
|
128
|
+
function dockerExecArgv(container, command, opts = {}) {
|
|
129
|
+
const argv = ["exec"];
|
|
130
|
+
if (opts.interactive) argv.push("-i");
|
|
131
|
+
if (opts.user) argv.push("-u", opts.user);
|
|
132
|
+
if (opts.cwd) argv.push("-w", opts.cwd);
|
|
133
|
+
for (const [k, v] of Object.entries(opts.env ?? {})) {
|
|
134
|
+
argv.push("-e", `${k}=${v}`);
|
|
135
|
+
}
|
|
136
|
+
argv.push(container, "bash", "-lc", command);
|
|
137
|
+
return argv;
|
|
138
|
+
}
|
|
139
|
+
var CONTAINER_USER = "vscode";
|
|
140
|
+
async function pipeFileIntoContainer(target, container, input, remotePath) {
|
|
141
|
+
const remote = loginShell(
|
|
142
|
+
`docker ${quoteShellArgv(["exec", "-i", "-u", CONTAINER_USER, container, "sh", "-c", `cat > ${quoteShellArg(remotePath)}`])}`
|
|
143
|
+
);
|
|
144
|
+
const res = await execa("ssh", [...sshOptArgs(target), sshDestination(target), remote], {
|
|
145
|
+
reject: false,
|
|
146
|
+
input
|
|
147
|
+
});
|
|
148
|
+
if (res.exitCode !== 0) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
`remote-docker: upload to ${container}:${remotePath} failed (exit ${String(res.exitCode)}): ${typeof res.stderr === "string" ? res.stderr : ""}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function pipeFileFromContainer(target, container, remotePath, output) {
|
|
155
|
+
const remote = loginShell(
|
|
156
|
+
`docker ${quoteShellArgv(["exec", "-u", CONTAINER_USER, container, "cat", remotePath])}`
|
|
157
|
+
);
|
|
158
|
+
const child = execa("ssh", [...sshOptArgs(target), sshDestination(target), remote], {
|
|
159
|
+
reject: false,
|
|
160
|
+
stdout: "pipe",
|
|
161
|
+
stderr: "pipe"
|
|
162
|
+
});
|
|
163
|
+
child.stdout?.pipe(output);
|
|
164
|
+
const res = await child;
|
|
165
|
+
if (res.exitCode !== 0) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`remote-docker: download of ${container}:${remotePath} failed (exit ${String(res.exitCode)}): ${typeof res.stderr === "string" ? res.stderr : ""}`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function loginShell(command) {
|
|
172
|
+
return `bash -lc ${quoteShellArg(command)}`;
|
|
173
|
+
}
|
|
174
|
+
async function probeRemoteEngine(spec) {
|
|
175
|
+
let target;
|
|
176
|
+
try {
|
|
177
|
+
target = sshTargetFor(parseRemoteTarget(spec));
|
|
178
|
+
} catch (err) {
|
|
179
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
180
|
+
}
|
|
181
|
+
const reach = await sshExec({ ...target, options: { ConnectTimeout: "10" } }, "true", {
|
|
182
|
+
timeoutMs: 2e4
|
|
183
|
+
});
|
|
184
|
+
if (reach.exitCode !== 0) {
|
|
185
|
+
return {
|
|
186
|
+
ok: false,
|
|
187
|
+
error: `cannot SSH to ${spec}: ${reach.stderr.trim() || `exit ${String(reach.exitCode)}`}`
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const res = await dockerOnRemote(
|
|
191
|
+
target,
|
|
192
|
+
["version", "--format", "{{.Server.Version}}|{{.Server.Arch}}|{{.Server.Os}}"],
|
|
193
|
+
{
|
|
194
|
+
timeoutMs: 3e4
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
if (res.exitCode !== 0) {
|
|
198
|
+
const err = res.stderr.trim() || res.stdout.trim();
|
|
199
|
+
if (/command not found|not found/i.test(err)) {
|
|
200
|
+
return {
|
|
201
|
+
ok: false,
|
|
202
|
+
error: `\`docker\` is not on ${spec}'s login-shell PATH (${err}). Install Docker there, or add it to the remote user's profile.`
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return { ok: false, error: `docker on ${spec} is not answering: ${err}` };
|
|
206
|
+
}
|
|
207
|
+
const [version = "", arch = "", os = ""] = res.stdout.trim().split("|");
|
|
208
|
+
return { ok: true, version, arch, os };
|
|
209
|
+
}
|
|
210
|
+
var SCHEMA = 1;
|
|
211
|
+
var PROVIDER = "remote-docker";
|
|
212
|
+
function readPreparedState() {
|
|
213
|
+
const raw = readPreparedStateRaw(PROVIDER);
|
|
214
|
+
if (raw === null || typeof raw !== "object") return null;
|
|
215
|
+
const parsed = raw;
|
|
216
|
+
if (parsed.schema !== SCHEMA || typeof parsed.hosts !== "object" || parsed.hosts === null) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return { schema: SCHEMA, hosts: parsed.hosts };
|
|
220
|
+
}
|
|
221
|
+
function recordPreparedHost(host, fields) {
|
|
222
|
+
const stamp = readCliStamp();
|
|
223
|
+
const existing = readPreparedState();
|
|
224
|
+
const next = {
|
|
225
|
+
schema: SCHEMA,
|
|
226
|
+
hosts: {
|
|
227
|
+
...existing?.hosts ?? {},
|
|
228
|
+
[host]: {
|
|
229
|
+
imageRef: fields.imageRef,
|
|
230
|
+
contextSha256: fields.contextSha256,
|
|
231
|
+
...stamp.cliVersion ? { cliVersion: stamp.cliVersion } : {},
|
|
232
|
+
...stamp.cliCommit ? { cliCommit: stamp.cliCommit } : {},
|
|
233
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
writePreparedStateRaw(PROVIDER, next);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
containerNameFor,
|
|
242
|
+
parseRemoteTarget,
|
|
243
|
+
makeSandboxId,
|
|
244
|
+
parseSandboxId,
|
|
245
|
+
tunnels,
|
|
246
|
+
ensureTunnel,
|
|
247
|
+
refreshTunnel,
|
|
248
|
+
dockerOnRemote,
|
|
249
|
+
dockerOnRemoteOrThrow,
|
|
250
|
+
dockerExecArgv,
|
|
251
|
+
CONTAINER_USER,
|
|
252
|
+
pipeFileIntoContainer,
|
|
253
|
+
pipeFileFromContainer,
|
|
254
|
+
loginShell,
|
|
255
|
+
probeRemoteEngine,
|
|
256
|
+
readPreparedState,
|
|
257
|
+
recordPreparedHost
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=chunk-ZYKNSHOH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../packages/sandbox-remote-docker/src/target.ts","../../../packages/sandbox-remote-docker/src/remote-docker.ts","../../../packages/sandbox-remote-docker/src/prepared-state.ts"],"sourcesContent":["/**\n * The remote-docker addressing model.\n *\n * A box lives on *some* remote engine, and the code that has to reach it is not\n * always the code that created it: the host relay resolves a backend from a\n * bare `CloudHandle` (`{ sandboxId }`) with no access to the box record or the\n * user's config. So the SSH destination is encoded INTO the sandbox id:\n *\n * sandboxId = \"<ssh-destination>/<container-name>\"\n * e.g. \"buildbox/agentbox-brave-otter\"\n * \"dev@10.0.0.9:2222/agentbox-brave-otter\"\n *\n * That makes the handle self-describing and multi-host support fall out for\n * free — no host-side registry to keep in sync, and a box keeps working after\n * `box.remoteDockerHost` changes.\n *\n * An SSH destination is anything OpenSSH accepts: an `~/.ssh/config` alias\n * (`buildbox`), or `[user@]host[:port]`. We deliberately do NOT parse it into\n * our own notion of identity/port beyond the `:port` suffix — the user's\n * `~/.ssh/config` is the source of truth for keys, ports and usernames, and\n * re-deriving them here would only let us contradict it.\n */\n\nimport type { SshTargetArgs } from '@agentbox/sandbox-core';\n\n/** A parsed SSH destination. `user` / `port` are absent unless spelled out. */\nexport interface RemoteTarget {\n /** Host, IP, or `~/.ssh/config` alias. */\n host: string;\n user?: string;\n port?: number;\n /** The destination as the user wrote it — the canonical id-carrying form. */\n spec: string;\n}\n\n/** Container names are `agentbox-<box-name>`, matching the docker provider. */\nexport function containerNameFor(boxName: string): string {\n return `agentbox-${boxName}`;\n}\n\n/**\n * Parse `[user@]host[:port]` (or a bare ssh alias). Throws on an empty or\n * malformed destination — a bad host is worth failing loudly on, since every\n * later error would be an opaque ssh failure.\n */\nexport function parseRemoteTarget(spec: string): RemoteTarget {\n const raw = spec.trim();\n if (raw.length === 0) {\n throw new Error('remote-docker: empty SSH destination');\n }\n if (raw.includes('/')) {\n throw new Error(\n `remote-docker: invalid SSH destination \"${raw}\" — \"/\" separates the destination from the container in a sandbox id`,\n );\n }\n const at = raw.lastIndexOf('@');\n const user = at >= 0 ? raw.slice(0, at) : undefined;\n const hostPort = at >= 0 ? raw.slice(at + 1) : raw;\n if (hostPort.length === 0 || (user !== undefined && user.length === 0)) {\n throw new Error(`remote-docker: invalid SSH destination \"${raw}\"`);\n }\n\n // A bracketed IPv6 literal is the only form that can carry a port:\n // `[fe80::1]:2222`. Bare `fe80::1` is all host — its final `:1` is an address\n // group, not a port, and reading it as one would silently connect to :1.\n const bracketed = /^\\[(.+)\\](?::(\\d+))?$/.exec(hostPort);\n if (bracketed?.[1]) {\n const host = bracketed[1];\n if (bracketed[2] === undefined) return { host, user, spec: raw };\n return { host, user, port: checkedPort(bracketed[2], raw), spec: raw };\n }\n if (hostPort.includes(':')) {\n const colon = hostPort.lastIndexOf(':');\n const head = hostPort.slice(0, colon);\n const tail = hostPort.slice(colon + 1);\n // More than one colon ⇒ an unbracketed IPv6 literal ⇒ no port.\n if (!head.includes(':') && /^\\d+$/.test(tail)) {\n return { host: head, user, port: checkedPort(tail, raw), spec: raw };\n }\n }\n return { host: hostPort, user, spec: raw };\n}\n\nfunction checkedPort(digits: string, raw: string): number {\n const port = Number.parseInt(digits, 10);\n if (port <= 0 || port > 65535) {\n throw new Error(`remote-docker: invalid SSH port in \"${raw}\"`);\n }\n return port;\n}\n\n/** `<ssh-destination>/<container>` — the persisted sandbox id. */\nexport function makeSandboxId(targetSpec: string, container: string): string {\n // Validate the destination now so a malformed one can't be persisted.\n parseRemoteTarget(targetSpec);\n return `${targetSpec}/${container}`;\n}\n\nexport interface ParsedSandboxId {\n target: RemoteTarget;\n container: string;\n}\n\n/** Split a sandbox id back into its SSH destination and container name. */\nexport function parseSandboxId(sandboxId: string): ParsedSandboxId {\n const slash = sandboxId.lastIndexOf('/');\n if (slash <= 0 || slash === sandboxId.length - 1) {\n throw new Error(\n `remote-docker: malformed sandbox id \"${sandboxId}\" — expected \"<ssh-destination>/<container>\"`,\n );\n }\n return {\n target: parseRemoteTarget(sandboxId.slice(0, slash)),\n container: sandboxId.slice(slash + 1),\n };\n}\n\n/**\n * The `SshTargetArgs` for a destination. No `identity` and no `knownHosts`:\n * both come from the user's `~/.ssh/config` / agent / `~/.ssh/known_hosts`,\n * which is the whole point of pointing at a machine you already reach.\n */\nexport function sshTargetFor(target: RemoteTarget, controlPath?: string): SshTargetArgs {\n return {\n host: target.host,\n ...(target.user !== undefined ? { user: target.user } : {}),\n ...(target.port !== undefined ? { port: target.port } : {}),\n ...(controlPath !== undefined ? { controlPath } : {}),\n };\n}\n","/**\n * The single chokepoint through which every `docker` command reaches the remote\n * engine: one persistent SSH ControlMaster per box, `docker …` run inside a\n * remote LOGIN shell.\n *\n * Why not `DOCKER_HOST=ssh://user@host`? Two reasons, both fatal in practice:\n *\n * 1. Docker's ssh transport runs `docker system dial-stdio` on the remote,\n * which needs `docker` on the NON-login-shell PATH. That is exactly where\n * OrbStack (`~/.orbstack/bin`) and Colima break, so a Mac remote — a case\n * we explicitly support — would fail with an opaque \"command not found\".\n * A login shell (`bash -lc`) sources the profile and finds them.\n * 2. It opens a fresh SSH connection per `docker` invocation. Create issues\n * dozens; the ControlMaster amortizes the handshake to ~nothing.\n *\n * The trade is that we compose docker's argv into a shell string ourselves, so\n * every argument must be quoted — `quoteShellArgv` from @agentbox/sandbox-cloud\n * does that, and nothing in this package may build a remote command by\n * concatenation.\n */\n\nimport { execa } from 'execa';\nimport type { Readable, Writable } from 'node:stream';\nimport { quoteShellArg, quoteShellArgv } from '@agentbox/sandbox-cloud';\nimport {\n SshTunnelManager,\n sshDestination,\n sshExec,\n sshOptArgs,\n type SshTargetArgs,\n} from '@agentbox/sandbox-core';\nimport { parseRemoteTarget, sshTargetFor, type RemoteTarget } from './target.js';\n\n/** One ControlMaster per box, namespaced so ids can't collide with a VPS provider's. */\nexport const tunnels = new SshTunnelManager('remote-docker');\n\nexport interface RemoteExecResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\n/**\n * Open (or reuse) the ControlMaster for a box and return an ssh target bound to\n * it. Every exec/upload/download/forward for that box rides this one connection.\n */\nexport async function ensureTunnel(\n sandboxId: string,\n target: RemoteTarget,\n): Promise<SshTargetArgs> {\n if (!tunnels.has(sandboxId)) {\n try {\n await tunnels.open({\n boxId: sandboxId,\n vpsHost: target.host,\n ...(target.user !== undefined ? { vpsUser: target.user } : {}),\n ...(target.port !== undefined ? { port: target.port } : {}),\n });\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `remote-docker: cannot SSH to \"${target.spec}\". Check that \\`ssh ${target.spec} true\\` works from this machine ` +\n `(the provider uses your own ~/.ssh/config, agent and known_hosts — it mints no keys).\\n${msg}`,\n );\n }\n }\n const controlPath = tunnels.controlPath(sandboxId);\n return sshTargetFor(target, controlPath);\n}\n\n/** Re-open a dead master (host sleep/wake, network blip) and drop stale forwards. */\nexport async function refreshTunnel(sandboxId: string, target: RemoteTarget): Promise<void> {\n await tunnels.refresh({\n boxId: sandboxId,\n vpsHost: target.host,\n ...(target.user !== undefined ? { vpsUser: target.user } : {}),\n ...(target.port !== undefined ? { port: target.port } : {}),\n });\n}\n\n/**\n * Run `docker <argv…>` on the remote engine. `argv` is quoted, so callers pass\n * a plain array and never think about the shell.\n */\nexport async function dockerOnRemote(\n target: SshTargetArgs,\n argv: string[],\n opts: { timeoutMs?: number; onLine?: (line: string) => void } = {},\n): Promise<RemoteExecResult> {\n return sshExec(target, loginShell(`docker ${quoteShellArgv(argv)}`), {\n ...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),\n ...(opts.onLine !== undefined ? { onLine: opts.onLine } : {}),\n });\n}\n\n/** Same, but throws with the remote's stderr on a non-zero exit. */\nexport async function dockerOnRemoteOrThrow(\n target: SshTargetArgs,\n argv: string[],\n opts: { timeoutMs?: number; onLine?: (line: string) => void } = {},\n): Promise<string> {\n const res = await dockerOnRemote(target, argv, opts);\n if (res.exitCode !== 0) {\n throw new Error(\n `remote-docker: \\`docker ${argv.join(' ')}\\` failed (exit ${String(res.exitCode)}): ${\n res.stderr.trim() || res.stdout.trim() || '(no output)'\n }`,\n );\n }\n return res.stdout;\n}\n\n/**\n * Run a command INSIDE the box's container: `docker exec … bash -lc '<cmd>'`.\n * This is what `CloudBackend.exec` is built on, so it carries the same\n * semantics the cloud scaffold expects (login shell, so `/etc/profile.d`\n * exports are visible).\n */\nexport function dockerExecArgv(\n container: string,\n command: string,\n opts: { user?: string; cwd?: string; env?: Record<string, string>; interactive?: boolean } = {},\n): string[] {\n const argv = ['exec'];\n if (opts.interactive) argv.push('-i');\n if (opts.user) argv.push('-u', opts.user);\n if (opts.cwd) argv.push('-w', opts.cwd);\n for (const [k, v] of Object.entries(opts.env ?? {})) {\n argv.push('-e', `${k}=${v}`);\n }\n argv.push(container, 'bash', '-lc', command);\n return argv;\n}\n\n/**\n * The user every exec and every file transfer runs as. It must be ONE user:\n * a file written as root that `exec` (as vscode) later has to delete leaves the\n * box wedged — and on a nested engine, where the container init is forced to\n * uid 0, `docker exec` with no `-u` would default to root and do exactly that.\n * So both sides name the user explicitly rather than inheriting the container's.\n */\nexport const CONTAINER_USER = 'vscode';\n\n/**\n * Stream a local file into a file inside the container, over the ControlMaster.\n *\n * Not `docker cp`: that would need the bytes staged on the remote host first\n * (an extra hop and a temp file to clean up). Piping into `cat` inside the\n * container is one hop, binary-safe, and leaves nothing behind. `execa` is\n * driven directly here because the transfer needs a stdin stream, which the\n * text-in/text-out `sshExec` deliberately doesn't model.\n */\nexport async function pipeFileIntoContainer(\n target: SshTargetArgs,\n container: string,\n input: Readable,\n remotePath: string,\n): Promise<void> {\n const remote = loginShell(\n `docker ${quoteShellArgv(['exec', '-i', '-u', CONTAINER_USER, container, 'sh', '-c', `cat > ${quoteShellArg(remotePath)}`])}`,\n );\n const res = await execa('ssh', [...sshOptArgs(target), sshDestination(target), remote], {\n reject: false,\n input,\n });\n if (res.exitCode !== 0) {\n throw new Error(\n `remote-docker: upload to ${container}:${remotePath} failed (exit ${String(res.exitCode)}): ${\n typeof res.stderr === 'string' ? res.stderr : ''\n }`,\n );\n }\n}\n\n/** Stream a file out of the container into a local writable stream. */\nexport async function pipeFileFromContainer(\n target: SshTargetArgs,\n container: string,\n remotePath: string,\n output: Writable,\n): Promise<void> {\n const remote = loginShell(\n `docker ${quoteShellArgv(['exec', '-u', CONTAINER_USER, container, 'cat', remotePath])}`,\n );\n const child = execa('ssh', [...sshOptArgs(target), sshDestination(target), remote], {\n reject: false,\n stdout: 'pipe',\n stderr: 'pipe',\n });\n child.stdout?.pipe(output);\n const res = await child;\n if (res.exitCode !== 0) {\n throw new Error(\n `remote-docker: download of ${container}:${remotePath} failed (exit ${String(res.exitCode)}): ${\n typeof res.stderr === 'string' ? res.stderr : ''\n }`,\n );\n }\n}\n\n/**\n * `bash -lc '<cmd>'` — a LOGIN shell, so the remote user's profile is sourced\n * and `docker` is found wherever their engine put it (Docker Desktop in\n * /usr/local/bin, OrbStack in ~/.orbstack/bin, Linux packages in /usr/bin).\n * This is the single reason a macOS remote works without a PATH config key.\n */\nexport function loginShell(command: string): string {\n return `bash -lc ${quoteShellArg(command)}`;\n}\n\n/**\n * Preflight a destination: SSH reachable, `docker` on the login-shell PATH, and\n * the daemon actually answering. Returns the engine's version + arch for the\n * doctor / `agentbox remote-docker check` output.\n */\nexport async function probeRemoteEngine(\n spec: string,\n): Promise<{ ok: true; version: string; arch: string; os: string } | { ok: false; error: string }> {\n let target: SshTargetArgs;\n try {\n target = sshTargetFor(parseRemoteTarget(spec));\n } catch (err) {\n return { ok: false, error: err instanceof Error ? err.message : String(err) };\n }\n const reach = await sshExec({ ...target, options: { ConnectTimeout: '10' } }, 'true', {\n timeoutMs: 20_000,\n });\n if (reach.exitCode !== 0) {\n return {\n ok: false,\n error: `cannot SSH to ${spec}: ${reach.stderr.trim() || `exit ${String(reach.exitCode)}`}`,\n };\n }\n const res = await dockerOnRemote(\n target,\n ['version', '--format', '{{.Server.Version}}|{{.Server.Arch}}|{{.Server.Os}}'],\n {\n timeoutMs: 30_000,\n },\n );\n if (res.exitCode !== 0) {\n const err = res.stderr.trim() || res.stdout.trim();\n if (/command not found|not found/i.test(err)) {\n return {\n ok: false,\n error: `\\`docker\\` is not on ${spec}'s login-shell PATH (${err}). Install Docker there, or add it to the remote user's profile.`,\n };\n }\n return { ok: false, error: `docker on ${spec} is not answering: ${err}` };\n }\n const [version = '', arch = '', os = ''] = res.stdout.trim().split('|');\n return { ok: true, version, arch, os };\n}\n","/**\n * `~/.agentbox/remote-docker-prepared.json`.\n *\n * Unlike every other cloud provider, this file is NOT load-bearing. The image\n * ref on a remote engine is its build-context fingerprint (`agentbox/box:<sha>`),\n * so \"is this host prepared?\" is answered by asking the engine, not by trusting\n * a local file — and it is answered per host, which a single file could never\n * do. What this records is the *history*: which hosts we have baked, with what,\n * and when, for `agentbox prepare --status` and `doctor` to report.\n */\n\nimport { readPreparedStateRaw, writePreparedStateRaw, readCliStamp } from '@agentbox/sandbox-core';\n\nconst SCHEMA = 1;\nconst PROVIDER = 'remote-docker';\n\nexport interface PreparedRemoteHost {\n imageRef: string;\n contextSha256: string;\n cliVersion?: string;\n cliCommit?: string;\n createdAt: string;\n}\n\nexport interface PreparedRemoteDockerState {\n schema: number;\n /** Keyed by SSH destination, exactly as the user spelled it. */\n hosts: Record<string, PreparedRemoteHost>;\n}\n\nexport function readPreparedState(): PreparedRemoteDockerState | null {\n const raw = readPreparedStateRaw(PROVIDER);\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedRemoteDockerState>;\n if (parsed.schema !== SCHEMA || typeof parsed.hosts !== 'object' || parsed.hosts === null) {\n return null;\n }\n return { schema: SCHEMA, hosts: parsed.hosts };\n}\n\nexport function recordPreparedHost(\n host: string,\n fields: { imageRef: string; contextSha256: string },\n): void {\n const stamp = readCliStamp();\n const existing = readPreparedState();\n const next: PreparedRemoteDockerState = {\n schema: SCHEMA,\n hosts: {\n ...(existing?.hosts ?? {}),\n [host]: {\n imageRef: fields.imageRef,\n contextSha256: fields.contextSha256,\n ...(stamp.cliVersion ? { cliVersion: stamp.cliVersion } : {}),\n ...(stamp.cliCommit ? { cliCommit: stamp.cliCommit } : {}),\n createdAt: new Date().toISOString(),\n },\n },\n };\n writePreparedStateRaw(PROVIDER, next);\n}\n"],"mappings":";;;;;;;;;;;;;;;;ACqBA,SAAS,aAAa;ADef,SAAS,iBAAiB,SAAyB;AACxD,SAAO,YAAY,OAAO;AAC5B;AAOO,SAAS,kBAAkB,MAA4B;AAC5D,QAAM,MAAM,KAAK,KAAK;AACtB,MAAI,IAAI,WAAW,GAAG;AACpB,UAAM,IAAI,MAAM,sCAAsC;EACxD;AACA,MAAI,IAAI,SAAS,GAAG,GAAG;AACrB,UAAM,IAAI;MACR,2CAA2C,GA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