| 409 | } |
| 410 | |
| 411 | function startStaticServer(config) { |
| 412 | // Reuse `vitePort` as the upstream port name so the ingress route table |
| 413 | // below stays identical to dev-with-automation.mjs. |
| 414 | logService("static", `Starting on port ${config.vitePort}...`, c.magenta); |
| 415 | |
| 416 | // Mirror the proxy targets that vite.config.ts exposes in dev mode so that |
| 417 | // hitting :3001 directly behaves like Vite's dev server (e.g. /server_info |
| 418 | // is forwarded to the agent-server instead of falling back to the SPA |
| 419 | // shell). Without this, /server_info on :3001 returns index.html. |
| 420 | const staticServerScript = join(projectRoot, "scripts", "static-server.mjs"); |
| 421 | const runtimeServicesInfo = JSON.stringify( |
| 422 | buildAutomationRuntimeServicesInfo({ |
| 423 | ...config, |
| 424 | frontendKind: "static", |
| 425 | }), |
| 426 | ); |
| 427 | spawnService( |
| 428 | "static", |
| 429 | "node", |
| 430 | [ |
| 431 | staticServerScript, |
| 432 | "--dir", |
| 433 | join(config.canvasPath, "build"), |
| 434 | "--port", |
| 435 | String(config.vitePort), |
| 436 | ...(process.env.VITE_BASE_PATH |
| 437 | ? ["--base-path", process.env.VITE_BASE_PATH] |
| 438 | : []), |
| 439 | // Inject the API key so the pre-built frontend can authenticate |
| 440 | // to the agent-server without a baked-in VITE_SESSION_API_KEY. |
| 441 | ...(config.sessionApiKey |
| 442 | ? ["--session-api-key", config.sessionApiKey] |
| 443 | : []), |
| 444 | "--runtime-services-info", |
| 445 | runtimeServicesInfo, |
| 446 | ...buildLocalServiceRouteArgs(config), |
| 447 | ], |
| 448 | { |
| 449 | cwd: config.canvasPath, |
| 450 | color: c.magenta, |
| 451 | }, |
| 452 | ); |
| 453 | } |
| 454 | |
| 455 | function startIngress(config) { |
| 456 | logService("ingress", `Starting on port ${config.ingressPort}...`, c.yellow); |