@madarco/agentbox 0.26.1 → 0.27.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 +32 -0
- package/README.md +1 -1
- package/dist/{_cloud-attach-7WRQH6XZ.js → _cloud-attach-WDGM6FL5.js} +4 -4
- package/dist/{chunk-UIFL7F2G.js → chunk-26IKZRTT.js} +2 -2
- package/dist/{chunk-DJQMK4RN.js → chunk-HR7NHH5J.js} +14 -9
- package/dist/chunk-HR7NHH5J.js.map +1 -0
- package/dist/{chunk-K5KOLYIL.js → chunk-IDH5A4RR.js} +2 -2
- package/dist/{chunk-ZY7M7MXH.js → chunk-JE6UI5YR.js} +10 -10
- package/dist/{chunk-7ZZAZPYX.js → chunk-KWOEUFVA.js} +2 -2
- package/dist/{chunk-BA2VLJVU.js → chunk-LL7NCMUU.js} +3 -3
- package/dist/{chunk-I2OAJS3L.js → chunk-NEF6MDJO.js} +4 -4
- package/dist/{chunk-I2OAJS3L.js.map → chunk-NEF6MDJO.js.map} +1 -1
- package/dist/{dist-YA7EXBGG.js → chunk-SJ75AIA2.js} +486 -92
- package/dist/chunk-SJ75AIA2.js.map +1 -0
- package/dist/{chunk-PK2QF4IR.js → chunk-UJEH2NJT.js} +27 -14
- package/dist/chunk-UJEH2NJT.js.map +1 -0
- package/dist/{chunk-DQHMDDAT.js → chunk-V5XXJH63.js} +2 -2
- package/dist/{dist-DTNYMBQ5.js → dist-FTKS2GI4.js} +5 -5
- package/dist/{dist-5IICYSR6.js → dist-KQTMCVME.js} +5 -5
- package/dist/{dist-5IICYSR6.js.map → dist-KQTMCVME.js.map} +1 -1
- package/dist/{dist-AR5CHRSV.js → dist-O3LKOIE7.js} +5 -5
- package/dist/{dist-POVRY7HO.js → dist-OO52HARR.js} +3 -3
- package/dist/{dist-K4LNH3EC.js → dist-TSFVB7AI.js} +5 -5
- package/dist/{dist-XYY6SIKG.js → dist-WVYAURMF.js} +5 -5
- package/dist/dist-Z6L5MM5D.js +46 -0
- package/dist/index.js +392 -211
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-75DIZ55S-W6NU3S3B.js → prepared-state-75DIZ55S-TNJXWMXV.js} +2 -2
- package/dist/prepared-state-75DIZ55S-TNJXWMXV.js.map +1 -0
- package/package.json +7 -7
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/app-path-routes-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/routes-manifest.json +22 -0
- package/runtime/hub/apps/hub/.next/server/app/(auth)/signin/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route.js +2 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/docs/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js +8 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/bake/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js +8 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/[alias]/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route/build-manifest.json +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route/server-reference-manifest.json +4 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js +9 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js.map +5 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route.js.nft.json +1 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/hosts/route_client-reference-manifest.js +3 -0
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route.js +2 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/api/v1/openapi.json/route.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page.js.nft.json +1 -1
- package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/hub/apps/hub/.next/server/app-paths-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/044u_hub__next-internal_server_app_(dashboard)_api_v1_hosts_route_actions_0b_404_.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/0web_next-internal_server_app_(dashboard)_api_v1_hosts_[alias]_route_actions_0swypy5.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/1jcg_server_app_(dashboard)_api_v1_hosts_[alias]_bake_route_actions_1-_pu3n.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a7djvw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0bmro0b._.js +3 -0
- 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]__0t4qmv-._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0xh14bo._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13ioh5z._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1h4xycg._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1hqla7-._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1md9kdw._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/_1bng7w9._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/apps_hub_app_(dashboard)_api_v1_lib_openapi_ts_1yokmzt._.js +14 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/09xn_next_dist_1uccfbf._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_03s-ah2._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0r4px38._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_18w2zeh._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0od97-d._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_components_box-table_tsx_0a9pyn_._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_settings_page_tsx_0hv6n82._.js +3 -0
- package/runtime/hub/apps/hub/.next/server/functions-config-manifest.json +3 -0
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/0xdtiy_m2ygv8.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/1_ur0im1g7_s9.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/26rwu1f2gzemi.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/3v6kx35_lwjs8.js +1 -0
- package/runtime/hub/apps/hub/.next/static/chunks/{3dfjrxx-dy644.css → 42uysd_max-yq.css} +1 -1
- package/runtime/hub/apps/hub/.next/static/chunks/44j61g8lm9nvw.js +1 -0
- package/runtime/hub/apps/hub/{chunk-BARD2DI6.js → chunk-EHBJKZCL.js} +13 -8
- package/runtime/hub/apps/hub/{chunk-4QY2VZCF.js → chunk-RXYOWSSN.js} +19 -13
- package/runtime/hub/apps/hub/{chunk-XZZXPEVV.js → chunk-YJ5MJOXK.js} +1 -1
- package/runtime/hub/apps/hub/{dist-3ENKQN5G.js → dist-3I7KUI6W.js} +3 -3
- package/runtime/hub/apps/hub/{dist-WAZKGVYL.js → dist-6FPPUSWZ.js} +2 -2
- package/runtime/hub/apps/hub/{dist-NNBELNA7.js → dist-DX6IYMAH.js} +300 -109
- package/runtime/hub/apps/hub/{dist-RJJ2SDYO.js → dist-G6TXUSPZ.js} +3 -3
- package/runtime/hub/apps/hub/{dist-AE6IV4FV.js → dist-GTVVXCBP.js} +3 -3
- package/runtime/hub/apps/hub/{dist-6VGJOQYK.js → dist-JG45OFT2.js} +3 -3
- package/runtime/hub/apps/hub/{dist-TU7D6UTB.js → dist-LYDHYTP2.js} +3 -3
- package/runtime/hub/apps/hub/{prepared-state-75DIZ55S-NYEDSU2U.js → prepared-state-75DIZ55S-2IFNUHHM.js} +1 -1
- package/runtime/hub/apps/hub/server.js +136 -19
- package/dist/chunk-DJQMK4RN.js.map +0 -1
- package/dist/chunk-PK2QF4IR.js.map +0 -1
- package/dist/chunk-ZYKNSHOH.js +0 -259
- package/dist/chunk-ZYKNSHOH.js.map +0 -1
- package/dist/dist-YA7EXBGG.js.map +0 -1
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +0 -14
- package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +0 -14
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_09gdzmo._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0tgpglr._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_1laion6._.js +0 -3
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +0 -3
- package/runtime/hub/apps/hub/.next/static/chunks/1c5w3kqosumog.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/1o3ot_9-8jgzc.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/1z4elhg8gyq98.js +0 -1
- package/runtime/hub/apps/hub/.next/static/chunks/3uq9hf-roasav.js +0 -1
- /package/dist/{_cloud-attach-7WRQH6XZ.js.map → _cloud-attach-WDGM6FL5.js.map} +0 -0
- /package/dist/{chunk-UIFL7F2G.js.map → chunk-26IKZRTT.js.map} +0 -0
- /package/dist/{chunk-K5KOLYIL.js.map → chunk-IDH5A4RR.js.map} +0 -0
- /package/dist/{chunk-ZY7M7MXH.js.map → chunk-JE6UI5YR.js.map} +0 -0
- /package/dist/{chunk-7ZZAZPYX.js.map → chunk-KWOEUFVA.js.map} +0 -0
- /package/dist/{chunk-BA2VLJVU.js.map → chunk-LL7NCMUU.js.map} +0 -0
- /package/dist/{chunk-DQHMDDAT.js.map → chunk-V5XXJH63.js.map} +0 -0
- /package/dist/{dist-DTNYMBQ5.js.map → dist-FTKS2GI4.js.map} +0 -0
- /package/dist/{dist-AR5CHRSV.js.map → dist-O3LKOIE7.js.map} +0 -0
- /package/dist/{dist-POVRY7HO.js.map → dist-OO52HARR.js.map} +0 -0
- /package/dist/{dist-K4LNH3EC.js.map → dist-TSFVB7AI.js.map} +0 -0
- /package/dist/{dist-XYY6SIKG.js.map → dist-WVYAURMF.js.map} +0 -0
- /package/dist/{prepared-state-75DIZ55S-W6NU3S3B.js.map → dist-Z6L5MM5D.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{mJYh9UHTsLaGGyRjBSvme → S-yw9-SVffiEHRGm85NzP}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{mJYh9UHTsLaGGyRjBSvme → S-yw9-SVffiEHRGm85NzP}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{mJYh9UHTsLaGGyRjBSvme → S-yw9-SVffiEHRGm85NzP}/_ssgManifest.js +0 -0
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
CONTAINER_USER,
|
|
4
|
-
containerNameFor,
|
|
5
|
-
dockerExecArgv,
|
|
6
|
-
dockerOnRemote,
|
|
7
|
-
dockerOnRemoteOrThrow,
|
|
8
|
-
ensureTunnel,
|
|
9
|
-
loginShell,
|
|
10
|
-
makeSandboxId,
|
|
11
|
-
parseRemoteTarget,
|
|
12
|
-
parseSandboxId,
|
|
13
|
-
pipeFileFromContainer,
|
|
14
|
-
pipeFileIntoContainer,
|
|
15
|
-
probeRemoteEngine,
|
|
16
|
-
readPreparedState,
|
|
17
|
-
recordPreparedHost,
|
|
18
|
-
refreshTunnel,
|
|
19
|
-
tunnels
|
|
20
|
-
} from "./chunk-ZYKNSHOH.js";
|
|
21
2
|
import {
|
|
22
3
|
CLOUD_VNC_PORT,
|
|
23
4
|
CLOUD_WEB_PROXY_PORT,
|
|
@@ -32,44 +13,328 @@ import {
|
|
|
32
13
|
renderInnerCommand,
|
|
33
14
|
resolveCloudCheckpoint,
|
|
34
15
|
writeCloudCheckpointManifest
|
|
35
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HR7NHH5J.js";
|
|
36
17
|
import {
|
|
37
18
|
detectPortless,
|
|
38
19
|
portlessDoctorRow
|
|
39
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-26IKZRTT.js";
|
|
40
21
|
import {
|
|
41
22
|
hashProjectPath,
|
|
42
23
|
loadEffectiveConfig,
|
|
43
|
-
sanitizeMnemonic
|
|
24
|
+
sanitizeMnemonic,
|
|
25
|
+
setConfigValue
|
|
44
26
|
} from "./chunk-JGZSA5ZI.js";
|
|
45
27
|
import {
|
|
46
28
|
BOX_IMAGE_REGISTRY,
|
|
47
29
|
BUILD_CONTEXT_DIR,
|
|
30
|
+
SshTunnelManager,
|
|
48
31
|
claudeInstallFingerprint,
|
|
49
32
|
computeDockerContextFingerprint,
|
|
50
33
|
defaultBoxSshDir,
|
|
51
34
|
errSummary,
|
|
52
35
|
mintSshKey,
|
|
53
36
|
readCliStamp,
|
|
37
|
+
readPreparedStateRaw,
|
|
54
38
|
readState,
|
|
55
39
|
registryRefForSha,
|
|
56
40
|
sshDestination,
|
|
57
41
|
sshExec,
|
|
58
|
-
sshOptArgs
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
import "./chunk-WJFZJZIM.js";
|
|
42
|
+
sshOptArgs,
|
|
43
|
+
writePreparedStateRaw
|
|
44
|
+
} from "./chunk-UJEH2NJT.js";
|
|
62
45
|
|
|
63
|
-
// ../../packages/sandbox-remote-docker/dist/
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
46
|
+
// ../../packages/sandbox-remote-docker/dist/chunk-SMGJ34CX.js
|
|
47
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
48
|
+
import { homedir } from "os";
|
|
49
|
+
import { dirname, resolve as pathResolve } from "path";
|
|
50
|
+
import { execa } from "execa";
|
|
68
51
|
import { createReadStream } from "fs";
|
|
69
52
|
import { rm } from "fs/promises";
|
|
70
53
|
import { tmpdir } from "os";
|
|
71
54
|
import { join } from "path";
|
|
72
|
-
import { execa } from "execa";
|
|
55
|
+
import { execa as execa2 } from "execa";
|
|
56
|
+
function containerNameFor(boxName) {
|
|
57
|
+
return `agentbox-${boxName}`;
|
|
58
|
+
}
|
|
59
|
+
function parseRemoteTarget(spec) {
|
|
60
|
+
const raw = spec.trim();
|
|
61
|
+
if (raw.length === 0) {
|
|
62
|
+
throw new Error("remote-docker: empty SSH destination");
|
|
63
|
+
}
|
|
64
|
+
if (raw.includes("/")) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`remote-docker: invalid SSH destination "${raw}" \u2014 "/" separates the destination from the container in a sandbox id`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const at = raw.lastIndexOf("@");
|
|
70
|
+
const user = at >= 0 ? raw.slice(0, at) : void 0;
|
|
71
|
+
const hostPort = at >= 0 ? raw.slice(at + 1) : raw;
|
|
72
|
+
if (hostPort.length === 0 || user !== void 0 && user.length === 0) {
|
|
73
|
+
throw new Error(`remote-docker: invalid SSH destination "${raw}"`);
|
|
74
|
+
}
|
|
75
|
+
const bracketed = /^\[(.+)\](?::(\d+))?$/.exec(hostPort);
|
|
76
|
+
if (bracketed?.[1]) {
|
|
77
|
+
const host = bracketed[1];
|
|
78
|
+
if (bracketed[2] === void 0) return { host, user, spec: raw };
|
|
79
|
+
return { host, user, port: checkedPort(bracketed[2], raw), spec: raw };
|
|
80
|
+
}
|
|
81
|
+
if (hostPort.includes(":")) {
|
|
82
|
+
const colon = hostPort.lastIndexOf(":");
|
|
83
|
+
const head = hostPort.slice(0, colon);
|
|
84
|
+
const tail = hostPort.slice(colon + 1);
|
|
85
|
+
if (!head.includes(":") && /^\d+$/.test(tail)) {
|
|
86
|
+
return { host: head, user, port: checkedPort(tail, raw), spec: raw };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { host: hostPort, user, spec: raw };
|
|
90
|
+
}
|
|
91
|
+
function checkedPort(digits, raw) {
|
|
92
|
+
const port = Number.parseInt(digits, 10);
|
|
93
|
+
if (port <= 0 || port > 65535) {
|
|
94
|
+
throw new Error(`remote-docker: invalid SSH port in "${raw}"`);
|
|
95
|
+
}
|
|
96
|
+
return port;
|
|
97
|
+
}
|
|
98
|
+
function makeSandboxId(targetSpec, container) {
|
|
99
|
+
parseRemoteTarget(targetSpec);
|
|
100
|
+
return `${targetSpec}/${container}`;
|
|
101
|
+
}
|
|
102
|
+
function parseSandboxId(sandboxId) {
|
|
103
|
+
const slash = sandboxId.lastIndexOf("/");
|
|
104
|
+
if (slash <= 0 || slash === sandboxId.length - 1) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`remote-docker: malformed sandbox id "${sandboxId}" \u2014 expected "<ssh-destination>/<container>"`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
target: parseRemoteTarget(sandboxId.slice(0, slash)),
|
|
111
|
+
container: sandboxId.slice(slash + 1)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function sshTargetFor(target, controlPath) {
|
|
115
|
+
return {
|
|
116
|
+
host: target.host,
|
|
117
|
+
...target.user !== void 0 ? { user: target.user } : {},
|
|
118
|
+
...target.port !== void 0 ? { port: target.port } : {},
|
|
119
|
+
...controlPath !== void 0 ? { controlPath } : {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
var SCHEMA = 1;
|
|
123
|
+
var ALIAS_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
124
|
+
function isValidAlias(alias) {
|
|
125
|
+
return ALIAS_RE.test(alias);
|
|
126
|
+
}
|
|
127
|
+
function assertValidAlias(alias) {
|
|
128
|
+
if (!isValidAlias(alias)) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`invalid host alias ${JSON.stringify(alias)} \u2014 use a plain name (letters, digits, \`.\`, \`_\`, \`-\`; no \`@\`, \`:\`, \`/\` or spaces)`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function registryPath() {
|
|
135
|
+
return pathResolve(homedir(), ".agentbox", "remote-docker-hosts.json");
|
|
136
|
+
}
|
|
137
|
+
function readHostsRegistry() {
|
|
138
|
+
const path = registryPath();
|
|
139
|
+
if (!existsSync(path)) return null;
|
|
140
|
+
let raw;
|
|
141
|
+
try {
|
|
142
|
+
raw = JSON.parse(readFileSync(path, "utf8"));
|
|
143
|
+
} catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
if (raw === null || typeof raw !== "object") return null;
|
|
147
|
+
const parsed = raw;
|
|
148
|
+
if (parsed.schema !== SCHEMA || typeof parsed.hosts !== "object" || parsed.hosts === null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
return { schema: SCHEMA, hosts: parsed.hosts };
|
|
152
|
+
}
|
|
153
|
+
function writeHostsRegistry(reg) {
|
|
154
|
+
const path = registryPath();
|
|
155
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
156
|
+
const body = JSON.stringify({ schema: SCHEMA, hosts: reg.hosts }, null, 2) + "\n";
|
|
157
|
+
const tmp = `${path}.tmp`;
|
|
158
|
+
writeFileSync(tmp, body, { mode: 384 });
|
|
159
|
+
renameSync(tmp, path);
|
|
160
|
+
}
|
|
161
|
+
function getHostAlias(alias) {
|
|
162
|
+
return readHostsRegistry()?.hosts[alias];
|
|
163
|
+
}
|
|
164
|
+
function listHostAliases() {
|
|
165
|
+
const reg = readHostsRegistry();
|
|
166
|
+
if (!reg) return [];
|
|
167
|
+
return Object.entries(reg.hosts).sort(([a], [b]) => a.localeCompare(b)).map(([alias, entry]) => ({ alias, entry }));
|
|
168
|
+
}
|
|
169
|
+
function upsertHostAlias(alias, ssh) {
|
|
170
|
+
const reg = readHostsRegistry() ?? { schema: SCHEMA, hosts: {} };
|
|
171
|
+
const existing = reg.hosts[alias];
|
|
172
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
173
|
+
reg.hosts[alias] = existing ? { ...existing, ssh, updatedAt: now } : { ssh, createdAt: now };
|
|
174
|
+
writeHostsRegistry(reg);
|
|
175
|
+
}
|
|
176
|
+
function removeHostAlias(alias) {
|
|
177
|
+
const reg = readHostsRegistry();
|
|
178
|
+
if (!reg || !(alias in reg.hosts)) return false;
|
|
179
|
+
const hosts = { ...reg.hosts };
|
|
180
|
+
delete hosts[alias];
|
|
181
|
+
writeHostsRegistry({ schema: SCHEMA, hosts });
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
function resolveConnection(ref) {
|
|
185
|
+
return getHostAlias(ref)?.ssh ?? ref;
|
|
186
|
+
}
|
|
187
|
+
function requireHostAlias(ref) {
|
|
188
|
+
const entry = getHostAlias(ref);
|
|
189
|
+
if (!entry) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
`no such remote-docker host alias ${JSON.stringify(ref)} \u2014 register it with \`agentbox remote-docker add <name> <[user@]host[:port]>\``
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
return entry;
|
|
195
|
+
}
|
|
196
|
+
function dialTarget(target) {
|
|
197
|
+
const resolved = resolveConnection(target.spec);
|
|
198
|
+
return resolved === target.spec ? target : parseRemoteTarget(resolved);
|
|
199
|
+
}
|
|
200
|
+
var tunnels = new SshTunnelManager("remote-docker");
|
|
201
|
+
async function ensureTunnel(sandboxId, target) {
|
|
202
|
+
const dial = dialTarget(target);
|
|
203
|
+
if (!tunnels.has(sandboxId)) {
|
|
204
|
+
try {
|
|
205
|
+
await tunnels.open({
|
|
206
|
+
boxId: sandboxId,
|
|
207
|
+
vpsHost: dial.host,
|
|
208
|
+
...dial.user !== void 0 ? { vpsUser: dial.user } : {},
|
|
209
|
+
...dial.port !== void 0 ? { port: dial.port } : {}
|
|
210
|
+
});
|
|
211
|
+
} catch (err) {
|
|
212
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
213
|
+
const where = dial.spec === target.spec ? `"${target.spec}"` : `"${target.spec}" (${dial.spec})`;
|
|
214
|
+
throw new Error(
|
|
215
|
+
`remote-docker: cannot SSH to ${where}. Check that \`ssh ${dial.spec} true\` works from this machine (the provider uses your own ~/.ssh/config, agent and known_hosts \u2014 it mints no keys).
|
|
216
|
+
${msg}`
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const controlPath = tunnels.controlPath(sandboxId);
|
|
221
|
+
return sshTargetFor(dial, controlPath);
|
|
222
|
+
}
|
|
223
|
+
async function refreshTunnel(sandboxId, target) {
|
|
224
|
+
const dial = dialTarget(target);
|
|
225
|
+
await tunnels.refresh({
|
|
226
|
+
boxId: sandboxId,
|
|
227
|
+
vpsHost: dial.host,
|
|
228
|
+
...dial.user !== void 0 ? { vpsUser: dial.user } : {},
|
|
229
|
+
...dial.port !== void 0 ? { port: dial.port } : {}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
async function dockerOnRemote(target, argv, opts = {}) {
|
|
233
|
+
return sshExec(target, loginShell(`docker ${quoteShellArgv(argv)}`), {
|
|
234
|
+
...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {},
|
|
235
|
+
...opts.onLine !== void 0 ? { onLine: opts.onLine } : {}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async function dockerOnRemoteOrThrow(target, argv, opts = {}) {
|
|
239
|
+
const res = await dockerOnRemote(target, argv, opts);
|
|
240
|
+
if (res.exitCode !== 0) {
|
|
241
|
+
throw new Error(
|
|
242
|
+
`remote-docker: \`docker ${argv.join(" ")}\` failed (exit ${String(res.exitCode)}): ${res.stderr.trim() || res.stdout.trim() || "(no output)"}`
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
return res.stdout;
|
|
246
|
+
}
|
|
247
|
+
function dockerExecArgv(container, command, opts = {}) {
|
|
248
|
+
const argv = ["exec"];
|
|
249
|
+
if (opts.interactive) argv.push("-i");
|
|
250
|
+
if (opts.user) argv.push("-u", opts.user);
|
|
251
|
+
if (opts.cwd) argv.push("-w", opts.cwd);
|
|
252
|
+
for (const [k, v] of Object.entries(opts.env ?? {})) {
|
|
253
|
+
argv.push("-e", `${k}=${v}`);
|
|
254
|
+
}
|
|
255
|
+
argv.push(container, "bash", "-lc", command);
|
|
256
|
+
return argv;
|
|
257
|
+
}
|
|
258
|
+
var CONTAINER_USER = "vscode";
|
|
259
|
+
async function pipeFileIntoContainer(target, container, input, remotePath) {
|
|
260
|
+
const remote = loginShell(
|
|
261
|
+
`docker ${quoteShellArgv(["exec", "-i", "-u", CONTAINER_USER, container, "sh", "-c", `cat > ${quoteShellArg(remotePath)}`])}`
|
|
262
|
+
);
|
|
263
|
+
const res = await execa("ssh", [...sshOptArgs(target), sshDestination(target), remote], {
|
|
264
|
+
reject: false,
|
|
265
|
+
input
|
|
266
|
+
});
|
|
267
|
+
if (res.exitCode !== 0) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
`remote-docker: upload to ${container}:${remotePath} failed (exit ${String(res.exitCode)}): ${typeof res.stderr === "string" ? res.stderr : ""}`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function pipeFileFromContainer(target, container, remotePath, output) {
|
|
274
|
+
const remote = loginShell(
|
|
275
|
+
`docker ${quoteShellArgv(["exec", "-u", CONTAINER_USER, container, "cat", remotePath])}`
|
|
276
|
+
);
|
|
277
|
+
const child = execa("ssh", [...sshOptArgs(target), sshDestination(target), remote], {
|
|
278
|
+
reject: false,
|
|
279
|
+
stdout: "pipe",
|
|
280
|
+
stderr: "pipe"
|
|
281
|
+
});
|
|
282
|
+
child.stdout?.pipe(output);
|
|
283
|
+
const res = await child;
|
|
284
|
+
if (res.exitCode !== 0) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
`remote-docker: download of ${container}:${remotePath} failed (exit ${String(res.exitCode)}): ${typeof res.stderr === "string" ? res.stderr : ""}`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function loginShell(command) {
|
|
291
|
+
return `bash -lc ${quoteShellArg(command)}`;
|
|
292
|
+
}
|
|
293
|
+
async function probeRemoteEngine(spec) {
|
|
294
|
+
let target;
|
|
295
|
+
try {
|
|
296
|
+
target = sshTargetFor(parseRemoteTarget(spec));
|
|
297
|
+
} catch (err) {
|
|
298
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
299
|
+
return { ok: false, steps: [{ label: "ssh", ok: false, detail }], error: detail };
|
|
300
|
+
}
|
|
301
|
+
const reach = await sshExec({ ...target, options: { ConnectTimeout: "10" } }, "true", {
|
|
302
|
+
timeoutMs: 2e4
|
|
303
|
+
});
|
|
304
|
+
if (reach.exitCode !== 0) {
|
|
305
|
+
const detail = `cannot SSH to ${spec}: ${reach.stderr.trim() || `exit ${String(reach.exitCode)}`}`;
|
|
306
|
+
return {
|
|
307
|
+
ok: false,
|
|
308
|
+
steps: [{ label: "ssh", ok: false, detail, hint: `\`ssh ${spec} true\` must work from here` }],
|
|
309
|
+
error: detail
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const sshStep = { label: "ssh", ok: true, detail: `reachable (${spec})` };
|
|
313
|
+
const res = await dockerOnRemote(
|
|
314
|
+
target,
|
|
315
|
+
["version", "--format", "{{.Server.Version}}|{{.Server.Arch}}|{{.Server.Os}}"],
|
|
316
|
+
{
|
|
317
|
+
timeoutMs: 3e4
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
if (res.exitCode !== 0) {
|
|
321
|
+
const err = res.stderr.trim() || res.stdout.trim();
|
|
322
|
+
const notFound = /command not found|not found/i.test(err);
|
|
323
|
+
const detail = notFound ? `\`docker\` is not on ${spec}'s login-shell PATH (${err}). Install Docker there, or add it to the remote user's profile.` : `docker on ${spec} is not answering: ${err}`;
|
|
324
|
+
return {
|
|
325
|
+
ok: false,
|
|
326
|
+
steps: [sshStep, { label: "docker", ok: false, detail }],
|
|
327
|
+
error: detail
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
const [version = "", arch = "", os = ""] = res.stdout.trim().split("|");
|
|
331
|
+
const dockerStep = {
|
|
332
|
+
label: "docker",
|
|
333
|
+
ok: true,
|
|
334
|
+
detail: `${version} (${os}/${arch})`
|
|
335
|
+
};
|
|
336
|
+
return { ok: true, steps: [sshStep, dockerStep], version, arch, os };
|
|
337
|
+
}
|
|
73
338
|
function remoteImageRef(contextSha256) {
|
|
74
339
|
return `agentbox/box:${contextSha256.slice(0, 16)}`;
|
|
75
340
|
}
|
|
@@ -79,7 +344,7 @@ async function currentContextSha(claudeInstall) {
|
|
|
79
344
|
return claudeInstall ? claudeInstallFingerprint(fp.contextSha256, claudeInstall) : fp.contextSha256;
|
|
80
345
|
}
|
|
81
346
|
async function ensureRemoteImage(target, opts = {}) {
|
|
82
|
-
const
|
|
347
|
+
const log2 = opts.onLog ?? (() => {
|
|
83
348
|
});
|
|
84
349
|
if (opts.imageRef && opts.imageRef.trim().length > 0) {
|
|
85
350
|
const ref2 = opts.imageRef.trim();
|
|
@@ -101,34 +366,34 @@ async function ensureRemoteImage(target, opts = {}) {
|
|
|
101
366
|
if (!opts.force) {
|
|
102
367
|
const probe = await dockerOnRemote(target, ["image", "inspect", ref]);
|
|
103
368
|
if (probe.exitCode === 0) {
|
|
104
|
-
|
|
369
|
+
log2(`[image] ${ref} already present on the remote`);
|
|
105
370
|
return { ref, source: "present", contextSha256: sha };
|
|
106
371
|
}
|
|
107
372
|
}
|
|
108
373
|
const registry = opts.registry ?? BOX_IMAGE_REGISTRY;
|
|
109
374
|
if (opts.allowPull !== false && registry) {
|
|
110
375
|
const remote = registryRefForSha(sha, registry);
|
|
111
|
-
|
|
376
|
+
log2(`[image] pulling ${remote} on the remote engine`);
|
|
112
377
|
const pull = await dockerOnRemote(target, ["pull", remote], {
|
|
113
378
|
timeoutMs: 9e5,
|
|
114
|
-
onLine: (l) =>
|
|
379
|
+
onLine: (l) => log2(`[image] ${l}`)
|
|
115
380
|
});
|
|
116
381
|
if (pull.exitCode === 0) {
|
|
117
382
|
await dockerOnRemote(target, ["tag", remote, ref]);
|
|
118
|
-
|
|
383
|
+
log2(`[image] pulled ${remote} -> ${ref}`);
|
|
119
384
|
return { ref, source: "pulled", contextSha256: sha };
|
|
120
385
|
}
|
|
121
|
-
|
|
386
|
+
log2("[image] registry miss \u2014 building on the remote from the local context");
|
|
122
387
|
}
|
|
123
388
|
await buildOnRemote(target, ref, opts);
|
|
124
389
|
return { ref, source: "built", contextSha256: sha };
|
|
125
390
|
}
|
|
126
391
|
async function buildOnRemote(target, ref, opts) {
|
|
127
|
-
const
|
|
392
|
+
const log2 = opts.onLog ?? (() => {
|
|
128
393
|
});
|
|
129
394
|
const tarPath = join(tmpdir(), `agentbox-box-ctx-${String(process.pid)}.tar`);
|
|
130
395
|
try {
|
|
131
|
-
await
|
|
396
|
+
await execa2("tar", ["-C", BUILD_CONTEXT_DIR, "-cf", tarPath, "."], {
|
|
132
397
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
133
398
|
});
|
|
134
399
|
const buildArgs = ["build", "-t", ref, "-f", "Dockerfile.box"];
|
|
@@ -136,8 +401,8 @@ async function buildOnRemote(target, ref, opts) {
|
|
|
136
401
|
buildArgs.push("--build-arg", `AGENTBOX_CLAUDE_INSTALL=${opts.claudeInstall}`);
|
|
137
402
|
}
|
|
138
403
|
buildArgs.push("-");
|
|
139
|
-
|
|
140
|
-
const res = await
|
|
404
|
+
log2(`[image] building ${ref} on the remote (streaming the build context)`);
|
|
405
|
+
const res = await execa2(
|
|
141
406
|
"ssh",
|
|
142
407
|
[
|
|
143
408
|
...sshOptArgs(target),
|
|
@@ -148,18 +413,88 @@ async function buildOnRemote(target, ref, opts) {
|
|
|
148
413
|
);
|
|
149
414
|
const out = `${typeof res.stdout === "string" ? res.stdout : ""}${typeof res.stderr === "string" ? res.stderr : ""}`;
|
|
150
415
|
for (const line of out.split(/\r?\n/)) {
|
|
151
|
-
if (line.trim().length > 0)
|
|
416
|
+
if (line.trim().length > 0) log2(`[image] ${line}`);
|
|
152
417
|
}
|
|
153
418
|
if (res.exitCode !== 0) {
|
|
154
419
|
throw new Error(
|
|
155
420
|
`remote-docker: remote \`docker build\` failed (exit ${String(res.exitCode)}). See the build output above.`
|
|
156
421
|
);
|
|
157
422
|
}
|
|
158
|
-
|
|
423
|
+
log2(`[image] built ${ref}`);
|
|
159
424
|
} finally {
|
|
160
425
|
await rm(tarPath, { force: true });
|
|
161
426
|
}
|
|
162
427
|
}
|
|
428
|
+
var SCHEMA2 = 1;
|
|
429
|
+
var PROVIDER = "remote-docker";
|
|
430
|
+
function readPreparedState() {
|
|
431
|
+
const raw = readPreparedStateRaw(PROVIDER);
|
|
432
|
+
if (raw === null || typeof raw !== "object") return null;
|
|
433
|
+
const parsed = raw;
|
|
434
|
+
if (parsed.schema !== SCHEMA2 || typeof parsed.hosts !== "object" || parsed.hosts === null) {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
return { schema: SCHEMA2, hosts: parsed.hosts };
|
|
438
|
+
}
|
|
439
|
+
function removePreparedHost(host) {
|
|
440
|
+
const existing = readPreparedState();
|
|
441
|
+
if (!existing || !(host in existing.hosts)) return false;
|
|
442
|
+
const hosts = { ...existing.hosts };
|
|
443
|
+
delete hosts[host];
|
|
444
|
+
writePreparedStateRaw(PROVIDER, { schema: SCHEMA2, hosts });
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
function recordPreparedHost(host, fields) {
|
|
448
|
+
const stamp = readCliStamp();
|
|
449
|
+
const existing = readPreparedState();
|
|
450
|
+
const next = {
|
|
451
|
+
schema: SCHEMA2,
|
|
452
|
+
hosts: {
|
|
453
|
+
...existing?.hosts ?? {},
|
|
454
|
+
[host]: {
|
|
455
|
+
imageRef: fields.imageRef,
|
|
456
|
+
contextSha256: fields.contextSha256,
|
|
457
|
+
...stamp.cliVersion ? { cliVersion: stamp.cliVersion } : {},
|
|
458
|
+
...stamp.cliCommit ? { cliCommit: stamp.cliCommit } : {},
|
|
459
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
writePreparedStateRaw(PROVIDER, next);
|
|
464
|
+
}
|
|
465
|
+
async function prepareRemoteDocker(opts) {
|
|
466
|
+
const log2 = opts.onLog ?? (() => {
|
|
467
|
+
});
|
|
468
|
+
const spec = (opts.host ?? "").trim();
|
|
469
|
+
if (!spec) {
|
|
470
|
+
throw new Error(
|
|
471
|
+
"remote-docker: prepare needs a host alias \u2014 `agentbox prepare --provider docker:<alias>`, or set `box.remoteDockerHost`."
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
requireHostAlias(spec);
|
|
475
|
+
const remote = parseRemoteTarget(spec);
|
|
476
|
+
const target = await ensureTunnel(`engine:${remote.spec}`, remote);
|
|
477
|
+
log2(`[prepare] ensuring the box image on ${remote.spec}`);
|
|
478
|
+
const res = await ensureRemoteImage(target, {
|
|
479
|
+
...opts.claudeInstall ? { claudeInstall: opts.claudeInstall } : {},
|
|
480
|
+
...opts.registry !== void 0 ? { registry: opts.registry } : {},
|
|
481
|
+
...opts.allowPull !== void 0 ? { allowPull: opts.allowPull } : {},
|
|
482
|
+
...opts.force ? { force: true } : {},
|
|
483
|
+
onLog: log2
|
|
484
|
+
});
|
|
485
|
+
if (res.contextSha256) {
|
|
486
|
+
recordPreparedHost(remote.spec, { imageRef: res.ref, contextSha256: res.contextSha256 });
|
|
487
|
+
}
|
|
488
|
+
log2(`[prepare] ${remote.spec} ready \u2014 ${res.ref} (${res.source})`);
|
|
489
|
+
return {};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// ../../packages/sandbox-remote-docker/dist/index.js
|
|
493
|
+
import { basename } from "path";
|
|
494
|
+
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
495
|
+
import { mkdir } from "fs/promises";
|
|
496
|
+
import { dirname as dirname2 } from "path";
|
|
497
|
+
import * as p from "@clack/prompts";
|
|
163
498
|
var BACKEND_NAME = "remote-docker";
|
|
164
499
|
var SNAPSHOT_SEP = "#";
|
|
165
500
|
function makeSnapshotName(host, imageRef) {
|
|
@@ -268,14 +603,15 @@ function buildRunArgv(opts) {
|
|
|
268
603
|
var remoteDockerBackend = {
|
|
269
604
|
name: BACKEND_NAME,
|
|
270
605
|
async provision(req) {
|
|
271
|
-
const
|
|
606
|
+
const log2 = req.onLog ?? (() => {
|
|
272
607
|
});
|
|
273
608
|
const spec = (req.host ?? "").trim();
|
|
274
609
|
if (!spec) {
|
|
275
610
|
throw new Error(
|
|
276
|
-
"remote-docker: no
|
|
611
|
+
"remote-docker: no host. Register one with `agentbox remote-docker add <alias> <[user@]host[:port]>`, then use `agentbox docker:<alias> \u2026` / `--remote-host <alias>` / `box.remoteDockerHost`."
|
|
277
612
|
);
|
|
278
613
|
}
|
|
614
|
+
requireHostAlias(spec);
|
|
279
615
|
const remote = parseRemoteTarget(spec);
|
|
280
616
|
const container = containerNameFor(req.name);
|
|
281
617
|
const sandboxId = makeSandboxId(remote.spec, container);
|
|
@@ -296,7 +632,7 @@ var remoteDockerBackend = {
|
|
|
296
632
|
} else {
|
|
297
633
|
const ensured = await ensureRemoteImage(target, {
|
|
298
634
|
imageRef: req.image && req.image !== "agentbox/box:dev" ? req.image : void 0,
|
|
299
|
-
onLog:
|
|
635
|
+
onLog: log2
|
|
300
636
|
});
|
|
301
637
|
image = ensured.ref;
|
|
302
638
|
}
|
|
@@ -305,7 +641,7 @@ var remoteDockerBackend = {
|
|
|
305
641
|
await dockerOnRemoteOrThrow(target, ["volume", "create", dockerVolume]);
|
|
306
642
|
const nestedEngine = await remoteIsNested(target);
|
|
307
643
|
if (nestedEngine) {
|
|
308
|
-
|
|
644
|
+
log2("[provision] remote engine is itself an AgentBox box \u2014 running the box init as root");
|
|
309
645
|
}
|
|
310
646
|
const argv = buildRunArgv({
|
|
311
647
|
container,
|
|
@@ -317,7 +653,7 @@ var remoteDockerBackend = {
|
|
|
317
653
|
...cpu !== void 0 ? { cpu } : {},
|
|
318
654
|
...memory !== void 0 ? { memory } : {}
|
|
319
655
|
});
|
|
320
|
-
|
|
656
|
+
log2(`[provision] docker run ${container} on ${remote.spec}`);
|
|
321
657
|
await dockerOnRemoteOrThrow(target, argv, { timeoutMs: 3e5 });
|
|
322
658
|
return {
|
|
323
659
|
sandboxId,
|
|
@@ -430,7 +766,7 @@ var remoteDockerBackend = {
|
|
|
430
766
|
},
|
|
431
767
|
async downloadFile(h, remotePath, localPath) {
|
|
432
768
|
const ctx = await ctxFor(h);
|
|
433
|
-
await mkdir(
|
|
769
|
+
await mkdir(dirname2(localPath), { recursive: true });
|
|
434
770
|
await pipeFileFromContainer(
|
|
435
771
|
ctx.target,
|
|
436
772
|
ctx.container,
|
|
@@ -609,7 +945,7 @@ async function buildRemoteDockerAttach(box, kind, opts = {}) {
|
|
|
609
945
|
"-lc",
|
|
610
946
|
inner
|
|
611
947
|
];
|
|
612
|
-
const remoteCommand = `docker ${quoteShellArgv(dockerArgv)}
|
|
948
|
+
const remoteCommand = loginShell(`docker ${quoteShellArgv(dockerArgv)}`);
|
|
613
949
|
const argv = [
|
|
614
950
|
"ssh",
|
|
615
951
|
...sshOptArgs(target),
|
|
@@ -660,61 +996,49 @@ async function resolveBoxSshTarget(box) {
|
|
|
660
996
|
port,
|
|
661
997
|
user: CONTAINER_USER,
|
|
662
998
|
identityFile: key.privatePath,
|
|
663
|
-
|
|
999
|
+
// The box id bakes an alias; ssh on THIS host can't resolve an AgentBox
|
|
1000
|
+
// alias, so the ProxyJump must be the alias's real connection string.
|
|
1001
|
+
proxyJump: resolveConnection(remote.spec)
|
|
664
1002
|
};
|
|
665
1003
|
}
|
|
666
|
-
async function prepareRemoteDocker(opts) {
|
|
667
|
-
const log = opts.onLog ?? (() => {
|
|
668
|
-
});
|
|
669
|
-
const spec = (opts.host ?? "").trim();
|
|
670
|
-
if (!spec) {
|
|
671
|
-
throw new Error(
|
|
672
|
-
"remote-docker: prepare needs an SSH destination \u2014 `agentbox prepare --provider docker:<host>`, or set `box.remoteDockerHost`."
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
const remote = parseRemoteTarget(spec);
|
|
676
|
-
const target = await ensureTunnel(`engine:${remote.spec}`, remote);
|
|
677
|
-
log(`[prepare] ensuring the box image on ${remote.spec}`);
|
|
678
|
-
const res = await ensureRemoteImage(target, {
|
|
679
|
-
...opts.claudeInstall ? { claudeInstall: opts.claudeInstall } : {},
|
|
680
|
-
...opts.registry !== void 0 ? { registry: opts.registry } : {},
|
|
681
|
-
...opts.allowPull !== void 0 ? { allowPull: opts.allowPull } : {},
|
|
682
|
-
...opts.force ? { force: true } : {},
|
|
683
|
-
onLog: log
|
|
684
|
-
});
|
|
685
|
-
if (res.contextSha256) {
|
|
686
|
-
recordPreparedHost(remote.spec, { imageRef: res.ref, contextSha256: res.contextSha256 });
|
|
687
|
-
}
|
|
688
|
-
log(`[prepare] ${remote.spec} ready \u2014 ${res.ref} (${res.source})`);
|
|
689
|
-
return {};
|
|
690
|
-
}
|
|
691
1004
|
async function doctorChecks() {
|
|
692
1005
|
try {
|
|
693
1006
|
const cfg = await loadEffectiveConfig(process.cwd());
|
|
694
|
-
const
|
|
695
|
-
if (!
|
|
1007
|
+
const alias = (cfg.effective.box.remoteDockerHost || "").trim();
|
|
1008
|
+
if (!alias) {
|
|
696
1009
|
return [
|
|
697
1010
|
{
|
|
698
1011
|
label: "remote engine",
|
|
699
1012
|
status: "warn",
|
|
700
|
-
detail: "no default
|
|
701
|
-
hint: "`agentbox
|
|
1013
|
+
detail: "no default host alias set",
|
|
1014
|
+
hint: "`agentbox remote-docker add <alias> <[user@]host[:port]>`"
|
|
702
1015
|
}
|
|
703
1016
|
];
|
|
704
1017
|
}
|
|
705
|
-
const
|
|
1018
|
+
const entry = getHostAlias(alias);
|
|
1019
|
+
if (!entry) {
|
|
1020
|
+
return [
|
|
1021
|
+
{
|
|
1022
|
+
label: "remote engine",
|
|
1023
|
+
status: "warn",
|
|
1024
|
+
detail: `host alias '${alias}' is not registered`,
|
|
1025
|
+
hint: `\`agentbox remote-docker add ${alias} <[user@]host[:port]>\``
|
|
1026
|
+
}
|
|
1027
|
+
];
|
|
1028
|
+
}
|
|
1029
|
+
const probe = await probeRemoteEngine(entry.ssh);
|
|
706
1030
|
const engineRes = probe.ok ? {
|
|
707
1031
|
label: "remote engine",
|
|
708
1032
|
status: "ok",
|
|
709
|
-
detail: `${
|
|
1033
|
+
detail: `${alias} \u2192 ${entry.ssh} \u2014 docker ${probe.version} (${probe.os}/${probe.arch})`
|
|
710
1034
|
} : {
|
|
711
1035
|
label: "remote engine",
|
|
712
1036
|
status: "fail",
|
|
713
|
-
detail: probe.error,
|
|
714
|
-
hint: `check that \`ssh ${
|
|
1037
|
+
detail: probe.error ?? "unusable",
|
|
1038
|
+
hint: `check that \`ssh ${entry.ssh} true\` works and docker is installed there`
|
|
715
1039
|
};
|
|
716
1040
|
const prepared = readPreparedState();
|
|
717
|
-
const baked = prepared?.hosts[
|
|
1041
|
+
const baked = prepared?.hosts[alias];
|
|
718
1042
|
const imageRes = baked ? {
|
|
719
1043
|
label: "box image",
|
|
720
1044
|
status: "ok",
|
|
@@ -723,7 +1047,7 @@ async function doctorChecks() {
|
|
|
723
1047
|
label: "box image",
|
|
724
1048
|
status: "warn",
|
|
725
1049
|
detail: "not baked on this host yet",
|
|
726
|
-
hint: `\`agentbox prepare --provider docker:${
|
|
1050
|
+
hint: `\`agentbox prepare --provider docker:${alias}\` (otherwise the first create bakes it)`
|
|
727
1051
|
};
|
|
728
1052
|
const portlessRes = portlessDoctorRow(await detectPortless());
|
|
729
1053
|
return [engineRes, imageRes, portlessRes];
|
|
@@ -731,6 +1055,64 @@ async function doctorChecks() {
|
|
|
731
1055
|
return [{ label: "remote engine", status: "warn", detail: errSummary(err) }];
|
|
732
1056
|
}
|
|
733
1057
|
}
|
|
1058
|
+
async function interactiveRegisterHost() {
|
|
1059
|
+
if (!process.stdin.isTTY) {
|
|
1060
|
+
p.log.warn(
|
|
1061
|
+
"remote-docker needs a host \u2014 run `agentbox remote-docker add <alias> <[user@]host[:port]>` to register one"
|
|
1062
|
+
);
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
const alias = await p.text({
|
|
1066
|
+
message: "Name this remote host (a short alias)",
|
|
1067
|
+
placeholder: "buildbox",
|
|
1068
|
+
validate: (value) => {
|
|
1069
|
+
const v = (value ?? "").trim();
|
|
1070
|
+
if (!v) return "required";
|
|
1071
|
+
try {
|
|
1072
|
+
assertValidAlias(v);
|
|
1073
|
+
} catch (err) {
|
|
1074
|
+
return err instanceof Error ? err.message : String(err);
|
|
1075
|
+
}
|
|
1076
|
+
if (getHostAlias(v)) return `'${v}' is already registered`;
|
|
1077
|
+
return void 0;
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
if (p.isCancel(alias)) return null;
|
|
1081
|
+
const name = alias.trim();
|
|
1082
|
+
for (; ; ) {
|
|
1083
|
+
const ssh = await p.text({
|
|
1084
|
+
message: "SSH connection (an ~/.ssh/config alias or [user@]host[:port])",
|
|
1085
|
+
placeholder: "user@host",
|
|
1086
|
+
validate: (value) => (value ?? "").trim() ? void 0 : "required"
|
|
1087
|
+
});
|
|
1088
|
+
if (p.isCancel(ssh)) return null;
|
|
1089
|
+
const conn = ssh.trim();
|
|
1090
|
+
const s = p.spinner();
|
|
1091
|
+
s.start(`probing ${conn}`);
|
|
1092
|
+
const res = await probeRemoteEngine(conn);
|
|
1093
|
+
if (!res.ok) {
|
|
1094
|
+
s.stop(`${conn}: unusable`);
|
|
1095
|
+
p.log.error(res.error ?? "remote engine unusable");
|
|
1096
|
+
const retry = await p.confirm({
|
|
1097
|
+
message: "Try a different SSH connection?",
|
|
1098
|
+
initialValue: true
|
|
1099
|
+
});
|
|
1100
|
+
if (p.isCancel(retry) || !retry) return null;
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
s.stop(`${conn}: docker ${res.version} (${res.os}/${res.arch})`);
|
|
1104
|
+
upsertHostAlias(name, conn);
|
|
1105
|
+
p.log.success(`registered '${name}' \u2192 ${conn}`);
|
|
1106
|
+
await setConfigValue("global", "box.remoteDockerHost", name, process.cwd(), { raw: true });
|
|
1107
|
+
const hostCount = listHostAliases().length;
|
|
1108
|
+
if (hostCount > 1) {
|
|
1109
|
+
p.log.info(
|
|
1110
|
+
`you have ${String(hostCount)} remote hosts \u2014 run \`agentbox docker:${name} claude\` to use this one`
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
return name;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
734
1116
|
var cloudProvider = createCloudProvider(remoteDockerBackend, {
|
|
735
1117
|
// Empty on purpose. The cloud default (2 cpu / 4 GB) would silently cap a box
|
|
736
1118
|
// on a 32-core workstation; a remote engine is the user's own machine, so a
|
|
@@ -796,14 +1178,26 @@ var providerModule = {
|
|
|
796
1178
|
currentBaseFingerprintLive: async (claudeInstall) => await currentContextSha(claudeInstall) ?? void 0,
|
|
797
1179
|
doctorChecks
|
|
798
1180
|
};
|
|
1181
|
+
|
|
799
1182
|
export {
|
|
800
|
-
BACKEND_NAME,
|
|
801
|
-
listOnHost,
|
|
802
1183
|
parseRemoteTarget,
|
|
803
1184
|
parseSandboxId,
|
|
1185
|
+
isValidAlias,
|
|
1186
|
+
assertValidAlias,
|
|
1187
|
+
readHostsRegistry,
|
|
1188
|
+
getHostAlias,
|
|
1189
|
+
listHostAliases,
|
|
1190
|
+
upsertHostAlias,
|
|
1191
|
+
removeHostAlias,
|
|
804
1192
|
probeRemoteEngine,
|
|
805
|
-
|
|
1193
|
+
readPreparedState,
|
|
1194
|
+
removePreparedHost,
|
|
1195
|
+
prepareRemoteDocker,
|
|
1196
|
+
BACKEND_NAME,
|
|
806
1197
|
remoteDockerBackend,
|
|
807
|
-
|
|
1198
|
+
listOnHost,
|
|
1199
|
+
interactiveRegisterHost,
|
|
1200
|
+
remoteDockerProvider,
|
|
1201
|
+
providerModule
|
|
808
1202
|
};
|
|
809
|
-
//# sourceMappingURL=
|
|
1203
|
+
//# sourceMappingURL=chunk-SJ75AIA2.js.map
|