(config)
| 285 | // ═══════════════════════════════════════════════════════════════════════════ |
| 286 | |
| 287 | function startAgentServer(config) { |
| 288 | logService( |
| 289 | "agent-server", |
| 290 | `Starting on port ${config.agentServerPort}...`, |
| 291 | c.blue, |
| 292 | ); |
| 293 | |
| 294 | const agentServerCmd = buildAgentServerCommand(process.env); |
| 295 | logService("agent-server", `Using ${agentServerCmd.source}`, c.dim); |
| 296 | |
| 297 | const safeConfig = buildSafeDevConfig(config.canvasPath, { |
| 298 | ...process.env, |
| 299 | OH_CANVAS_SAFE_STATE_DIR: config.stateDir, |
| 300 | OH_CANVAS_SAFE_BACKEND_PORT: config.agentServerPort.toString(), |
| 301 | OH_CANVAS_SAFE_VSCODE_PORT: config.vscodePort.toString(), |
| 302 | }); |
| 303 | |
| 304 | const agentServerEnv = { |
| 305 | ...buildAgentServerEnv(safeConfig), |
| 306 | ...buildAgentServerAutomationEnv(config), |
| 307 | }; |
| 308 | |
| 309 | spawnService( |
| 310 | "agent-server", |
| 311 | agentServerCmd.command, |
| 312 | [ |
| 313 | ...agentServerCmd.args, |
| 314 | "--host", |
| 315 | "0.0.0.0", |
| 316 | "--port", |
| 317 | String(config.agentServerPort), |
| 318 | ], |
| 319 | { |
| 320 | cwd: safeConfig.workspacesPath, |
| 321 | env: agentServerEnv, |
| 322 | color: c.blue, |
| 323 | }, |
| 324 | ); |
| 325 | } |
| 326 | |
| 327 | function buildAutomationBackendEnv(config, env = process.env) { |
| 328 | // Both backends share the same session API key value. |
no test coverage detected