fix: use frontend ssh bridge without backend-core

This commit is contained in:
AgentRun Artificer
2026-06-11 18:26:15 +08:00
parent 9f85274da0
commit 1b96c82b40
2 changed files with 141 additions and 2 deletions
@@ -0,0 +1,47 @@
import { sshCaptureBackendPlan } from "./src/ssh";
function assertCondition(condition: unknown, message: string, detail: unknown = {}): void {
if (!condition) throw new Error(`${message}: ${JSON.stringify(detail)}`);
}
const baseConfig = {
network: { publicHost: "74.48.78.17" },
} as Parameters<typeof sshCaptureBackendPlan>[0];
const runnerPlan = sshCaptureBackendPlan(baseConfig, {
KUBERNETES_SERVICE_HOST: "10.43.0.1",
});
assertCondition(
runnerPlan.backend === "remote-frontend-websocket" && runnerPlan.remoteHost === "74.48.78.17" && runnerPlan.reason === "runner-environment",
"ssh capture should use frontend websocket in runner environments",
runnerPlan,
);
const explicitHostPlan = sshCaptureBackendPlan(baseConfig, {
UNIDESK_MAIN_SERVER_IP: "http://74.48.78.17:18081/",
KUBERNETES_SERVICE_HOST: "10.43.0.1",
});
assertCondition(
explicitHostPlan.backend === "remote-frontend-websocket" && explicitHostPlan.remoteHost === "http://74.48.78.17:18081",
"ssh capture should prefer explicit main server host hints and trim trailing slash",
explicitHostPlan,
);
const localOnlyPlan = sshCaptureBackendPlan({ network: { publicHost: "127.0.0.1" } } as Parameters<typeof sshCaptureBackendPlan>[0], {});
assertCondition(
localOnlyPlan.backend === "local-backend-core-broker" && localOnlyPlan.remoteHost === null,
"ssh capture should keep local backend-core broker mode when no remote host is configured",
localOnlyPlan,
);
console.log(JSON.stringify({
ok: true,
checks: [
"runner environments use remote frontend websocket capture",
"explicit main server host hints are preferred and normalized",
"local-only environments keep local backend-core broker mode",
],
}));