feat: add hwpod node native websocket dispatch

This commit is contained in:
Codex Agent
2026-06-05 19:26:13 +08:00
parent 4179621538
commit 483060a3ee
6 changed files with 493 additions and 25 deletions
+15 -17
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bun
import { createCloudApiServer } from "../../internal/cloud/server.ts";
import { createCloudApiBunServer } from "../../internal/cloud/bun-server.ts";
import { applyCloudApiImageEnv, parsePort, parseTimeout } from "./runtime-options.ts";
const host = process.env.HWLAB_CLOUD_API_HOST || "0.0.0.0";
@@ -14,28 +14,26 @@ const codeAgentHardTimeoutMs = parseTimeout(process.env.HWLAB_CODE_AGENT_HARD_TI
});
applyCloudApiImageEnv(process.env);
const server = createCloudApiServer({
const runtime = await createCloudApiBunServer({
host,
port,
codeAgentTimeoutMs,
codeAgentHardTimeoutMs
});
server.listen(port, host, () => {
const address = server.address();
const resolvedPort = typeof address === "object" && address ? address.port : port;
process.stdout.write(
`${JSON.stringify({
serviceId: "hwlab-cloud-api",
status: "listening",
host,
port: resolvedPort
})}\n`
);
});
process.stdout.write(
`${JSON.stringify({
serviceId: "hwlab-cloud-api",
status: "listening",
host,
port: runtime.port,
hwpodNodeWs: "/v1/hwpod-node/ws"
})}\n`
);
for (const signal of ["SIGINT", "SIGTERM"]) {
process.on(signal, () => {
server.close(() => {
process.exit(0);
});
runtime.stop();
process.exit(0);
});
}