src/bridge/
Architecture
Supported IDEs
VS Code
Full bridge support including diff display, file watching, and permission prompts rendered inside the editor.
JetBrains
Full bridge support for IntelliJ-based IDEs (IntelliJ IDEA, PyCharm, WebStorm, etc.).
Key files
| File | Purpose |
|---|---|
bridgeMain.ts | Main bridge loop — starts and manages the bidirectional channel |
bridgeMessaging.ts | Message protocol: serialization and deserialization of bridge messages |
bridgePermissionCallbacks.ts | Routes permission prompts from the core to the IDE UI |
bridgeApi.ts | API surface exposed to the IDE extension |
bridgeConfig.ts | Bridge configuration (ports, paths, flags) |
replBridge.ts | Connects the REPL session to the bridge channel |
jwtUtils.ts | JWT-based authentication between the CLI and the IDE extension |
sessionRunner.ts | Manages bridge session execution lifecycle |
createSession.ts | Creates new bridge sessions on connection |
trustedDevice.ts | Device trust verification |
workSecret.ts | Workspace-scoped secrets for secure communication |
inboundMessages.ts | Handles messages arriving from the IDE |
inboundAttachments.ts | Handles file attachments sent from the IDE |
types.ts | TypeScript types for the bridge wire protocol |
Authentication
The bridge uses JWT (JSON Web Tokens) for authentication between the CLI process and the IDE extension. Tokens are generated viajwtUtils.ts and validated on each message to prevent unauthorized access to the bridge channel.
Workspace-scoped secrets (
workSecret.ts) ensure that bridge tokens are scoped to a specific workspace and cannot be reused across different projects.Session management
Each IDE connection initiates a bridge session viacreateSession.ts. The session runner (sessionRunner.ts) manages the full lifecycle:
Session creation
A new session is created via
createSession.ts, initializing the Query Engine and tool context.Message routing
Inbound messages from the IDE (
inboundMessages.ts) are dispatched to the core. Responses and permission prompts are routed back to the IDE via bridgePermissionCallbacks.ts.Feature flag
The bridge is gated behind theBRIDGE_MODE feature flag and is stripped from non-IDE builds. Standard CLI usage does not include bridge code.