(config)
| 324 | } |
| 325 | |
| 326 | function startAgentServer(config) { |
| 327 | logService( |
| 328 | "agent-server", |
| 329 | `Starting on port ${config.agentServerPort}...`, |
| 330 | c.blue, |
| 331 | ); |
| 332 | |
| 333 | const agentServerCmd = buildAgentServerCommand(process.env); |
| 334 | logService("agent-server", `Using ${agentServerCmd.source}`, c.dim); |
| 335 | |
| 336 | const safeConfig = buildSafeDevConfig(config.canvasPath, { |
| 337 | ...process.env, |
| 338 | OH_CANVAS_SAFE_STATE_DIR: config.stateDir, |
| 339 | OH_CANVAS_SAFE_BACKEND_PORT: config.agentServerPort.toString(), |
| 340 | OH_CANVAS_SAFE_VSCODE_PORT: config.vscodePort.toString(), |
| 341 | }); |
| 342 | |
| 343 | const agentServerEnv = { |
| 344 | ...buildAgentServerEnv(safeConfig), |
| 345 | ...buildAgentServerAutomationEnv(config), |
| 346 | }; |
| 347 | |
| 348 | spawnService( |
| 349 | "agent-server", |
| 350 | agentServerCmd.command, |
| 351 | [ |
| 352 | ...agentServerCmd.args, |
| 353 | "--host", |
| 354 | "0.0.0.0", |
| 355 | "--port", |
| 356 | String(config.agentServerPort), |
| 357 | ], |
| 358 | { |
| 359 | cwd: safeConfig.workspacesPath, |
| 360 | env: agentServerEnv, |
| 361 | color: c.blue, |
| 362 | }, |
| 363 | ); |
| 364 | } |
| 365 | |
| 366 | function buildAutomationBackendEnv(config, env = process.env) { |
| 367 | // Both backends share the same session API key value. |
no test coverage detected