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

Function startAutomationBackend

scripts/dev-with-automation.mjs:827–926  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

825}
826
827function startAutomationBackend(config) {
828 logService(
829 "automation",
830 `Starting on port ${config.autoBackendPort}...`,
831 c.green,
832 );
833
834 const automationCmd = buildAutomationCommand(process.env);
835 logService("automation", `Using ${automationCmd.source}`, c.dim);
836
837 spawnService(
838 "automation",
839 automationCmd.command,
840 [
841 ...automationCmd.args,
842 "--host",
843 "127.0.0.1",
844 "--port",
845 config.autoBackendPort.toString(),
846 ],
847 {
848 cwd: config.stateDir,
849 env: {
850 // Force UTF-8 for all Python file I/O (same reason as agent-server;
851 // see buildAgentServerEnv in dev-safe.mjs).
852 PYTHONUTF8: "1",
853 OPENHANDS_REMOTE_WS_READY_REQUIRED:
854 process.env.OPENHANDS_REMOTE_WS_READY_REQUIRED || "false",
855 // The URL the automation backend itself uses to call the
856 // agent-server's REST API (tarball upload + bash dispatch).
857 //
858 // Priority:
859 // 1. AUTOMATION_AGENT_SERVER_URL explicitly set in the user's env
860 // 2. `localhost:<agentServerPort>`
861 AUTOMATION_AGENT_SERVER_URL:
862 process.env.AUTOMATION_AGENT_SERVER_URL ||
863 `http://localhost:${config.agentServerPort}`,
864 // The URL exported into the in-sandbox bash chain as
865 // `AGENT_SERVER_URL` (read by main.py / setup.sh to call back into
866 // the agent-server).
867 //
868 // Priority:
869 // 1. AUTOMATION_SANDBOX_AGENT_SERVER_URL explicitly set in env
870 // 2. launcher-provided value
871 // 3. unset — backend falls back to AUTOMATION_AGENT_SERVER_URL
872 ...(process.env.AUTOMATION_SANDBOX_AGENT_SERVER_URL ||
873 config.sandboxAgentServerUrl
874 ? {
875 AUTOMATION_SANDBOX_AGENT_SERVER_URL:
876 process.env.AUTOMATION_SANDBOX_AGENT_SERVER_URL ||
877 config.sandboxAgentServerUrl,
878 }
879 : {}),
880 AUTOMATION_AGENT_SERVER_API_KEY: config.sessionApiKey,
881 // ~/.openhands/automation/automations.db — matches docker/entrypoint.sh.
882 AUTOMATION_DB_URL: `sqlite+aiosqlite:///${join(dirname(config.stateDir), SHARED_DEFAULTS.paths.automationDb)}`,
883 // The automation backend uses this as its publicly-reachable base
884 // URL: it's appended to callback URLs and injected into each

Callers 1

mainFunction · 0.70

Calls 4

buildAutomationCommandFunction · 0.85
logServiceFunction · 0.70
spawnServiceFunction · 0.70

Tested by

no test coverage detected