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

Function main

scripts/dev-safe.mjs:832–999  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

830}
831
832async function main() {
833 console.log("Starting isolated agent-server + frontend dev stack...");
834 fileLog("info", "Starting isolated agent-server + frontend dev stack...");
835 validateFrontendDependencies();
836 console.log("Frontend dependencies found.");
837 fileLog("info", "Frontend dependencies found.");
838 console.log("Allocating ports...");
839 fileLog("info", "Allocating ports...");
840
841 // Use async config builder with dynamic port allocation
842 const config = await buildSafeDevConfigAsync();
843
844 if (process.env.OH_AGENT_SERVER_LOCAL_PATH) {
845 validateLocalAgentServerPath(process.env.OH_AGENT_SERVER_LOCAL_PATH);
846 }
847
848 for (const dir of [
849 config.stateDir,
850 config.tmuxTmpDir,
851 config.conversationsPath,
852 config.workspacesPath,
853 config.bashEventsDir,
854 ]) {
855 mkdirSync(dir, { recursive: true });
856 }
857
858 const agentServerCmd = buildAgentServerCommand();
859
860 const secretKeySource = process.env.OH_SECRET_KEY
861 ? "custom (from OH_SECRET_KEY)"
862 : `persisted (${process.env.OH_SECRET_KEY_PATH || DEFAULT_SECRET_KEY_PATH})`;
863
864 const sessionKeySource = process.env.LOCAL_BACKEND_API_KEY
865 ? "custom (from LOCAL_BACKEND_API_KEY)"
866 : `persisted (${
867 process.env.OH_SESSION_API_KEY_PATH || DEFAULT_API_KEY_PATH
868 })`;
869
870 console.log(`- agent-server: ${agentServerCmd.source}`);
871 console.log(`- backend: ${config.backendBaseUrl}`);
872 console.log(`- vscode port: ${config.vscodePort}`);
873 console.log(`- working dir: ${config.workingDir}`);
874 console.log(`- isolated state dir: ${config.stateDir}`);
875 console.log(`- secret key: ${secretKeySource}`);
876 console.log(`- session API key: ${sessionKeySource}`);
877 console.log("");
878 fileLog(
879 "info",
880 [
881 "Agent-server stack config:",
882 ` agent-server: ${agentServerCmd.source}`,
883 ` backend: ${config.backendBaseUrl}`,
884 ` working dir: ${config.workingDir}`,
885 ` state dir: ${config.stateDir}`,
886 ].join("\n"),
887 );
888
889 const backend = spawnProcess(

Callers 4

executeWithResultsFunction · 0.90
dev-safe.mjsFile · 0.70
startStackFunction · 0.50
agent-canvas.mjsFile · 0.50

Calls 11

fileLogFunction · 0.90
buildSafeDevConfigAsyncFunction · 0.85
buildAgentServerCommandFunction · 0.85
buildAgentServerEnvFunction · 0.85
buildNpmScriptCommandFunction · 0.85
errorMethod · 0.80
spawnProcessFunction · 0.70
shutdownFunction · 0.70
waitForServerFunction · 0.70

Tested by 1

executeWithResultsFunction · 0.72