fix: run edge proxy on node runtime (#1830)

This commit is contained in:
Lyon
2026-06-21 19:06:03 +08:00
committed by GitHub
parent 0833e115bf
commit f9bf6231b5
9 changed files with 314 additions and 274 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ test("check plan runs migrated runtime service TypeScript tests", () => {
const commands = checkProfiles.check.map((task) => task.command.join(" "));
assert.ok(commands.some((command) => command.includes("cmd/hwlab-edge-proxy/main.test.ts")));
assert.ok(commands.some((command) => command.includes("cmd/hwlab-deepseek-responses-bridge/main.test.ts")));
assert.equal(commands.some((command) => command.includes("cmd/hwlab-edge-proxy/main.mjs")), false);
assert.equal(commands.some((command) => command.includes("cmd/hwlab-edge-proxy/main.ts")), false);
assert.equal(commands.some((command) => command.includes("cmd/hwlab-deepseek-responses-bridge/main.test.mjs")), false);
});
+6 -6
View File
@@ -564,7 +564,7 @@ test("v02 planner enables env reuse for all retained runtime services", async ()
await writeFile(path.join(repo, "cmd/hwlab-cloud-api/main.ts"), "console.log('api v2');\n");
await writeFile(path.join(repo, "web/hwlab-cloud-web/index.html"), "<html>v2</html>\n");
await writeFile(path.join(repo, "cmd/hwlab-gateway/main.ts"), "console.log('gateway v2');\n");
await writeFile(path.join(repo, "cmd/hwlab-edge-proxy/main.ts"), "console.log('edge v2');\n");
await writeFile(path.join(repo, "cmd/hwlab-edge-proxy/main.mjs"), "console.log('edge v2');\n");
await writeFile(path.join(repo, "skills/hwlab-agent-runtime/SKILL.md"), "agent runtime skill v2\n");
await git(repo, ["add", "."]);
await git(repo, ["commit", "-m", "change all v02 service code"]);
@@ -761,7 +761,7 @@ async function createFixtureRepo(options = {}) {
await writeFile(path.join(repo, "cmd/hwlab-deepseek-responses-bridge/main.ts"), "console.log('bridge');\n");
await writeFile(path.join(repo, "cmd/hwlab-deepseek-responses-bridge/main.test.ts"), "console.log('test');\n");
await writeFile(path.join(repo, "cmd/hwlab-gateway/main.ts"), "console.log('gateway');\n");
await writeFile(path.join(repo, "cmd/hwlab-edge-proxy/main.ts"), "console.log('edge');\n");
await writeFile(path.join(repo, "cmd/hwlab-edge-proxy/main.mjs"), "console.log('edge');\n");
await writeFile(path.join(repo, "web/hwlab-cloud-web/index.html"), "<html></html>\n");
await writeFile(path.join(repo, "internal/dev-entrypoint/artifact-runtime.mjs"), "export const artifactRuntime = 1;\n");
await writeFile(path.join(repo, "internal/dev-entrypoint/cloud-web-runtime.mjs"), "export const runtime = 1;\n");
@@ -785,7 +785,7 @@ async function createFixtureRepo(options = {}) {
await writeFile(path.join(repo, "deploy/runtime/boot/hwlab-codex-api-responses-forwarder.sh"), "#!/bin/sh\nexec bun run cmd/hwlab-codex-api-responses-forwarder/main.ts\n");
await writeFile(path.join(repo, "deploy/runtime/boot/hwlab-deepseek-responses-bridge.sh"), "#!/bin/sh\nexec bun run cmd/hwlab-deepseek-responses-bridge/main.ts\n");
await writeFile(path.join(repo, "deploy/runtime/boot/hwlab-gateway.sh"), "#!/bin/sh\nexec bun run cmd/hwlab-gateway/main.ts\n");
await writeFile(path.join(repo, "deploy/runtime/boot/hwlab-edge-proxy.sh"), "#!/bin/sh\nexec bun run cmd/hwlab-edge-proxy/main.ts\n");
await writeFile(path.join(repo, "deploy/runtime/boot/hwlab-edge-proxy.sh"), "#!/bin/sh\nexec node cmd/hwlab-edge-proxy/main.mjs\n");
await writeFile(path.join(repo, "deploy/runtime/boot/hwlab-agent-skills.sh"), "#!/bin/sh\nexec bun .hwlab-agent-skills-runtime.mjs\n");
await writeFile(path.join(repo, "deploy/runtime/launcher/hwlab-env-reuse-launcher.ts"), "console.log('launcher');\n");
await writeFile(path.join(repo, "skills/hwlab-agent-runtime/SKILL.md"), "agent runtime skill\n");
@@ -903,9 +903,9 @@ function createDeployFixture({ serviceIds = V02_RUNTIME_SERVICE_IDS } = {}) {
observable: false
},
"hwlab-edge-proxy": {
runtimeKind: "bun-command",
entrypoint: "cmd/hwlab-edge-proxy/main.ts",
artifactKind: "bun-command",
runtimeKind: "node-command",
entrypoint: "cmd/hwlab-edge-proxy/main.mjs",
artifactKind: "node-command",
healthPath: "/health",
healthPort: 6667,
componentPaths: ["cmd/hwlab-edge-proxy/", "internal/dev-entrypoint/http.mjs"],
+3 -2
View File
@@ -27,6 +27,7 @@ const commonEnv = {
};
const children = [];
const bunCommand = resolveBunCommand();
const nodeCommand = process.env.HWLAB_NODE_COMMAND || "node";
try {
const cloud = startNode("cmd/hwlab-cloud-api/main.ts", {
@@ -39,7 +40,7 @@ try {
await waitForJson(`http://127.0.0.1:${cloudPort}/health/live`);
if (useEdgeProxy) {
const edge = startNode("cmd/hwlab-edge-proxy/main.ts", {
const edge = startNode("cmd/hwlab-edge-proxy/main.mjs", {
...commonEnv,
HWLAB_EDGE_HOST: "127.0.0.1",
HWLAB_EDGE_PORT: String(edgePort),
@@ -137,7 +138,7 @@ try {
}
function startNode(entrypoint, env) {
const command = entrypoint.endsWith(".ts") ? bunCommand : process.execPath;
const command = entrypoint.endsWith(".ts") ? bunCommand : nodeCommand;
const child = spawn(command, [entrypoint], {
cwd,
env,