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

Function startAgentServer

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

Source from the content-addressed store, hash-verified

333}
334
335function startAgentServer(config) {
336 logService(
337 "agent-server",
338 `Starting on port ${config.agentServerPort}...`,
339 c.blue,
340 );
341
342 const agentServerCmd = buildAgentServerCommand(process.env);
343 logService("agent-server", `Using ${agentServerCmd.source}`, c.dim);
344
345 const safeConfig = buildSafeDevConfig(config.canvasPath, {
346 ...process.env,
347 OH_CANVAS_SAFE_STATE_DIR: config.stateDir,
348 OH_CANVAS_SAFE_BACKEND_PORT: config.agentServerPort.toString(),
349 OH_CANVAS_SAFE_VSCODE_PORT: config.vscodePort.toString(),
350 });
351
352 const agentServerEnv = {
353 // Opt into prefix-mode: both the static server and the ingress below build
354 // their route tables from `getLocalServiceRoutes`, which registers this
355 // same prefix against `config.vscodePort`.
356 ...buildAgentServerEnv(safeConfig, {
357 vscodeBasePath: config.vscodeBasePath,
358 verbose: config.verbose,
359 }),
360 ...buildAgentServerAutomationEnv(config),
361 };
362
363 spawnService(
364 "agent-server",
365 agentServerCmd.command,
366 [
367 ...agentServerCmd.args,
368 "--host",
369 "0.0.0.0",
370 "--port",
371 String(config.agentServerPort),
372 ],
373 {
374 cwd: safeConfig.workspacesPath,
375 env: agentServerEnv,
376 color: c.blue,
377 },
378 );
379}
380
381function buildAutomationBackendEnv(config, env = process.env) {
382 // 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