MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / startAgentServer

Function startAgentServer

scripts/dev-static.mjs:288–326  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 6

buildAgentServerCommandFunction · 0.90
buildSafeDevConfigFunction · 0.90
buildAgentServerEnvFunction · 0.90
logServiceFunction · 0.70
spawnServiceFunction · 0.70

Tested by

no test coverage detected