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

Function startStack

electron/main.mjs:668–711  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

666}
667
668async function startStack() {
669 const entryUrl = pathToFileURL(
670 join(scriptsDir, "dev-with-automation.mjs"),
671 ).href;
672 const { main } = await import(entryUrl);
673
674 // main() starts agent-server + automation backend + static server + ingress.
675 // skipNpmCheck: npm is not needed at runtime in static mode.
676 // agentServerReadyTimeoutMs: dev defaults to 60 s (warm uvx cache); a
677 // packaged binary on a fresh machine can spend several minutes inside
678 // uvx the first time, downloading Python + installing openhands-
679 // agent-server from PyPI. 10 minutes is generous but bounded.
680 // onServiceLog: stream uvx/agent-server output to the loading window so
681 // the user sees progress instead of an indefinite spinner.
682 const result = await main({
683 bannerTitle: "OpenHands Agent Canvas",
684 staticMode: true,
685 staticDir: buildDir,
686 mode: "agent-canvas",
687 isPublic: false,
688 // The preload provides window.marsBridge; the stack's ingress must not
689 // host a second, separate one.
690 marsWebBridge: false,
691 skipNpmCheck: true,
692 agentServerReadyTimeoutMs: 10 * 60_000,
693 onServiceLog: handleServiceLog,
694 // main() announces the stack without waiting for the automation backend.
695 // If that backend exits during startup, or the ingress/static server
696 // keeps exiting, the services are already stopped when this runs.
697 onStackFailure: failStartup,
698 });
699
700 // main() returns { config, agentServerReady } — treat a timeout as a fatal
701 // startup error so the splash shows a clear dialog instead of dropping the
702 // user into a half-booted UI that will only emit "Request timeout" popups.
703 if (result?.agentServerReady === false) {
704 throw new Error(
705 "The agent server did not finish starting in time. " +
706 "On first launch this can take several minutes while uvx downloads " +
707 "Python and the OpenHands agent-server from PyPI. " +
708 "Check your internet connection and try again.",
709 );
710 }
711}
712
713let startupFailed = false;
714

Callers 1

main.mjsFile · 0.85

Calls 1

mainFunction · 0.50

Tested by

no test coverage detected