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

Function startAgentServer

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

Source from the content-addressed store, hash-verified

285// ═══════════════════════════════════════════════════════════════════════════
286
287function 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
327function buildAutomationBackendEnv(config, env = process.env) {
328 // 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