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

Function startAgentServer

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

Source from the content-addressed store, hash-verified

312}
313
314function startAgentServer(config) {
315 logService(
316 "agent-server",
317 `Starting on port ${config.agentServerPort}...`,
318 c.blue,
319 );
320
321 const agentServerCmd = buildAgentServerCommand(process.env);
322 logService("agent-server", `Using ${agentServerCmd.source}`, c.dim);
323
324 const safeConfig = buildSafeDevConfig(config.canvasPath, {
325 ...process.env,
326 OH_CANVAS_SAFE_STATE_DIR: config.stateDir,
327 OH_CANVAS_SAFE_BACKEND_PORT: config.agentServerPort.toString(),
328 OH_CANVAS_SAFE_VSCODE_PORT: config.vscodePort.toString(),
329 });
330
331 const agentServerEnv = {
332 // Opt into prefix-mode: both the static server and the ingress below build
333 // their route tables from `getLocalServiceRoutes`, which registers this
334 // same prefix against `config.vscodePort`.
335 ...buildAgentServerEnv(safeConfig, {
336 vscodeBasePath: config.vscodeBasePath,
337 }),
338 ...buildAgentServerAutomationEnv(config),
339 };
340
341 spawnService(
342 "agent-server",
343 agentServerCmd.command,
344 [
345 ...agentServerCmd.args,
346 "--host",
347 "0.0.0.0",
348 "--port",
349 String(config.agentServerPort),
350 ],
351 {
352 cwd: safeConfig.workspacesPath,
353 env: agentServerEnv,
354 color: c.blue,
355 },
356 );
357}
358
359function buildAutomationBackendEnv(config, env = process.env) {
360 // 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