How get-bb/bb works
Purpose and entry points
bb is a TypeScript monorepo for an agentic IDE: coding-agent work executes in live, steerable threads across desktop, browser, CLI, HTTP API, and plugins. Main launch paths are the distributable launcher in packages/bb-app/src/launcher.ts, CLI entry in apps/cli/src/index.ts, server startup in apps/server/src/start-server.ts, desktop Electron main process in apps/desktop/src/main.ts, and React app bootstrap in apps/app/src/main.tsx.
Client surfaces
The primary UI is a Vite/React application with routing, layouts, thread views, prompt composition, timeline rendering, and local query/realtime state. apps/app/src/App.tsx composes the application; apps/app/src/views/thread-detail/ThreadDetailView.tsx is the core thread workspace; apps/app/src/hooks/queries/thread-queries.ts and apps/app/src/hooks/realtime-cache-effects.ts bridge server state into the client cache. The CLI is a peer control surface, organized by resource commands in apps/cli/src/commands/thread/index.ts and using apps/cli/src/client.ts.
Server: system-of-record and orchestration
The Node server exposes typed HTTP routes and WebSocket protocols, owns durable state, and coordinates thread/environment lifecycles. Its assembly points are apps/server/src/server.ts and apps/server/src/index.ts; public resource boundaries are in apps/server/src/routes/threads/index.ts, apps/server/src/routes/environments.ts, and apps/server/src/routes/hosts.ts. Thread creation, execution planning, dispatch, event persistence, and timeline pagination are concentrated in apps/server/src/services/threads/thread-create.ts, apps/server/src/services/threads/thread-turn-dispatch.ts, and apps/server/src/services/threads/timeline.ts.
Agent execution and host boundary
Agent processes do not run in the browser-facing server directly. The host daemon runs on a machine with workspaces and provider CLIs, exposes local commands/files/terminals, manages runtime processes, and connects back to the server. Key boundaries are apps/host-daemon/src/daemon.ts, apps/host-daemon/src/command-router.ts, apps/host-daemon/src/runtime-manager.ts, and apps/host-daemon/src/server-connection.ts. Workspace provisioning and Git worktrees are host-local concerns in packages/host-workspace/src/provisioning.ts and packages/host-workspace/src/workspace.ts.
Provider normalization and thread event flow
packages/agent-runtime/src/runtime.ts supervises provider processes and normalizes their lifecycle, tool calls, permission/interactive requests, and events. Provider adapters cover ACP, Claude Code, Codex, and Pi in packages/agent-runtime/src/acp/adapter.ts, packages/agent-runtime/src/claude-code/adapter.ts, and packages/agent-runtime/src/codex/adapter.ts. The server receives host/runtime events through apps/server/src/ws/daemon-protocol.ts and fan-outs client updates via apps/server/src/ws/hub.ts; persistent events are projected into client timeline rows by packages/thread-view/src/build-thread-timeline.ts.
Persistence, contracts, and realtime
SQLite is the local system-of-record, accessed through packages/db/src/connection.ts, schema/data modules such as packages/db/src/schema.ts and packages/db/src/data/events.ts, and migrations under packages/db/drizzle/. Shared HTTP/API payload definitions reside in packages/server-contract/src/api-types.ts; host-daemon RPC contracts in packages/host-daemon-contract/src/commands.ts; client SDK transport/realtime APIs in packages/sdk/src/core.ts and packages/sdk/src/realtime-client.ts. These packages are deliberate compatibility boundaries between surfaces and runtimes.
Extensibility, desktop, and remote connectivity
Plugins can contribute server behavior, agent capabilities, CLI commands, skills, and React UI slots. The server lifecycle is in apps/server/src/services/plugins/plugin-service.ts and apps/server/src/services/plugins/plugin-runtime.ts; frontend hosting is in apps/app/src/lib/plugin-sdk-app-impl.tsx; the public author contract is packages/plugin-sdk/src/index.ts. Electron wraps the app, supervises local/foreign server targets, native browser views, and updates through apps/desktop/src/owned-runtime-supervisor.ts and apps/desktop/src/desktop-browser-view.ts. Optional multi-device connectivity uses a Cloudflare Worker tunnel (apps/connect/src/worker.ts, apps/connect/src/tunnel-do.ts), with enrollment/session support in packages/connect-client/src/desktop-session.ts.
Main entry points: server.ts Typed HTTP and WebSocket server · realtime-client.ts Client SDK and realtime · main.ts Electron desktop · thread-turn-dispatch.ts Thread orchestration
Components 21
User surfaces
- Distributable launcher
packages/bb-app/src/launcher.ts - React thread workspace · Thread UI, prompts, timeline, and realtime cache.
apps/app/src/App.tsx - Thread detail view
apps/app/src/views/thread-detail/ThreadDetailView.tsx - CLI thread commands
apps/cli/src/commands/thread/index.ts - Electron desktop · Supervises server targets and native browser views.
apps/desktop/src/main.ts
Server control plane
- Typed HTTP and WebSocket server · System of record and lifecycle coordinator.
apps/server/src/server.ts - Thread orchestration · Creates turns, plans execution, dispatches work, and pages timelines.
apps/server/src/services/threads/thread-turn-dispatch.ts - Daemon event protocol
apps/server/src/ws/daemon-protocol.ts - Client realtime hub
apps/server/src/ws/hub.ts
Host execution
- Host daemon · Machine-local boundary for workspaces, commands, terminals, and runtimes.
apps/host-daemon/src/daemon.ts - Runtime manager
apps/host-daemon/src/runtime-manager.ts - Workspace provisioning · Provisions workspaces and Git worktrees locally.
packages/host-workspace/src/provisioning.ts - Agent runtime · Normalizes provider lifecycle, tools, permissions, and events.
packages/agent-runtime/src/runtime.ts - Provider adapters
packages/agent-runtime/src/acp/adapter.ts
Shared contracts & state
- SQLite durable state · Threads, environments, hosts, and persisted events.
packages/db/src/connection.ts - Timeline projection
packages/thread-view/src/build-thread-timeline.ts - HTTP API contract
packages/server-contract/src/api-types.ts - Client SDK and realtime
packages/sdk/src/realtime-client.ts
Extension & connectivity
- Plugin runtime · Loads server behavior and agent capabilities.
apps/server/src/services/plugins/plugin-runtime.ts - Plugin SDK
packages/plugin-sdk/src/index.ts - Remote tunnel · Optional multi-device connectivity.
apps/connect/src/worker.ts
Connections 25
- Distributable launcher → Electron desktop: launches
- Electron desktop → React thread workspace: hosts
- Electron desktop → Typed HTTP and WebSocket server: supervises
- React thread workspace → Thread detail view: renders
- Thread detail view → Client SDK and realtime: uses
- CLI thread commands → HTTP API contract: uses
- Client SDK and realtime → HTTP API contract: implements
- Client SDK and realtime → Typed HTTP and WebSocket server: HTTP and realtime
- HTTP API contract → Typed HTTP and WebSocket server: defines boundary
- Typed HTTP and WebSocket server → Thread orchestration: routes turns
- Thread orchestration → SQLite durable state: persists state and events
- SQLite durable state → Timeline projection: supplies events
- Timeline projection → Thread detail view: timeline rows
- Thread orchestration → Host daemon: dispatches execution
- Host daemon → Runtime manager: manages
- Host daemon → Workspace provisioning: provisions
- Runtime manager → Agent runtime: runs
- Agent runtime → Provider adapters: normalizes providers
- Agent runtime → Daemon event protocol: emits events via host
- Daemon event protocol → SQLite durable state: persists events
- Daemon event protocol → Client realtime hub: publishes updates
- Client realtime hub → Client SDK and realtime: fan-out
- Plugin SDK → Plugin runtime: implemented by plugins
- Plugin runtime → Typed HTTP and WebSocket server: extends lifecycle
- Remote tunnel → Typed HTTP and WebSocket server: remote access