packages/docs/electrobun-startup.md
This doc explains how the embedded agent starts in the packaged desktop app and why the exception-handling guards in eliza/packages/app-core/platforms/electrobun/src/native/agent.ts must not be removed.
ELIZA_RENDERER_URL or the built-in static asset server for packaged apps/app/dist).AgentManager.start() (in native/agent.ts) spawns a child Bun process: bun run <eliza-dist>/entry.js start (or the equivalent path for your bundle layout). The child is not an in-process dynamic import of server.js / eliza.js.http://127.0.0.1:{port}/api/health until the child reports ready (or times out / errors).apiBaseUpdate (and related RPC) to the renderer so window.__ELIZA_API_BASE__ matches the live API.If the child fails to start or never becomes healthy:
state: "error" with an error message so the UI can show Agent unavailable: … instead of a generic Failed to fetch.For dev orchestration (Vite + API + Electrobun in separate processes), see Desktop local development.
Goal: When the runtime fails to load (e.g. missing native binary), the user should see a clear error in the UI, not a dead window. That requires (1) the main process and renderer staying alive, and (2) status / RPC updates so the UI can show Agent unavailable: ….
Without explicit handling:
start() tore down the window or assumed the API lived in-process, the renderer could lose API base and show Failed to fetch with no explanation.So we keep:
.catch() where still applicable — Any remaining async paths that could reject should set error state instead of leaving the UI uninitialized.native/agent.ts comments and this doc.The remaining try/catch and .catch() paths are intentional. They keep the app
window usable when the runtime fails to load. Removing them would bring back
broken behavior: a dead window, Failed to fetch, and no useful error
message.
The key sites in agent.ts include comments that reference this doc. When
editing that file, preserve the guards and the rationale.
Packaged app writes a startup log to:
~/Library/Application Support/Eliza/eliza-startup.log%APPDATA%\Eliza\eliza-startup.log~/.config/Eliza/eliza-startup.logUse it to debug load failures (missing modules, native binary path, etc.).
NODE_PATH and where it's set.