(config)
| 333 | } |
| 334 | |
| 335 | function startAgentServer(config) { |
| 336 | logService( |
| 337 | "agent-server", |
| 338 | `Starting on port ${config.agentServerPort}...`, |
| 339 | c.blue, |
| 340 | ); |
| 341 | |
| 342 | const agentServerCmd = buildAgentServerCommand(process.env); |
| 343 | logService("agent-server", `Using ${agentServerCmd.source}`, c.dim); |
| 344 | |
| 345 | const safeConfig = buildSafeDevConfig(config.canvasPath, { |
| 346 | ...process.env, |
| 347 | OH_CANVAS_SAFE_STATE_DIR: config.stateDir, |
| 348 | OH_CANVAS_SAFE_BACKEND_PORT: config.agentServerPort.toString(), |
| 349 | OH_CANVAS_SAFE_VSCODE_PORT: config.vscodePort.toString(), |
| 350 | }); |
| 351 | |
| 352 | const agentServerEnv = { |
| 353 | // Opt into prefix-mode: both the static server and the ingress below build |
| 354 | // their route tables from `getLocalServiceRoutes`, which registers this |
| 355 | // same prefix against `config.vscodePort`. |
| 356 | ...buildAgentServerEnv(safeConfig, { |
| 357 | vscodeBasePath: config.vscodeBasePath, |
| 358 | verbose: config.verbose, |
| 359 | }), |
| 360 | ...buildAgentServerAutomationEnv(config), |
| 361 | }; |
| 362 | |
| 363 | spawnService( |
| 364 | "agent-server", |
| 365 | agentServerCmd.command, |
| 366 | [ |
| 367 | ...agentServerCmd.args, |
| 368 | "--host", |
| 369 | "0.0.0.0", |
| 370 | "--port", |
| 371 | String(config.agentServerPort), |
| 372 | ], |
| 373 | { |
| 374 | cwd: safeConfig.workspacesPath, |
| 375 | env: agentServerEnv, |
| 376 | color: c.blue, |
| 377 | }, |
| 378 | ); |
| 379 | } |
| 380 | |
| 381 | function buildAutomationBackendEnv(config, env = process.env) { |
| 382 | // Both backends share the same session API key value. |
no test coverage detected