Analyzed: March 31, 2026 leak snapshot

What the bridge is

The bridge subsystem under src/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
That is a real job runner, not a thin RPC shim.

Retry and sleep handling

The bridge code carries explicit backoff configuration for:
  • connection failures
  • general failures
  • shutdown grace periods
  • stop-work retry timing
It also detects system sleep and wake to avoid treating long pauses as ordinary network backoff.

Worktrees

The bridge integrates with worktree helpers and can create or remove agent worktrees as part of session execution. That is one of the stronger signals that remote execution was designed with isolated work contexts in mind.

Authentication and tokens

The bridge keeps ingress JWTs separately from session handles because refresh scheduling can overwrite other token fields. The code comments around heartbeat and reconnect are unusually detailed and show deliberate handling of expired session ingress tokens.