What the bridge is
The bridge subsystem undersrc/bridge/ is a remote-session orchestration layer. src/bridge/bridgeMain.ts is the clearest entrypoint.
It manages:
- environment registration
- polling for work
- spawning sessions
- reconnect and heartbeat logic
- worktree creation and cleanup
- access-token refresh
- shutdown and timeout handling
Session management model
The bridge loop maintains maps for:- active sessions
- session start times
- work IDs
- compat session IDs
- ingress tokens
- timers
- worktrees
Retry and sleep handling
The bridge code carries explicit backoff configuration for:- connection failures
- general failures
- shutdown grace periods
- stop-work retry timing