source dump of claude code
at main 21 lines 981 B view raw
1/** 2 * Peer address parsing — kept separate from peerRegistry.ts so that 3 * SendMessageTool can import parseAddress without transitively loading 4 * the bridge (axios) and UDS (fs, net) modules at tool-enumeration time. 5 */ 6 7/** Parse a URI-style address into scheme + target. */ 8export function parseAddress(to: string): { 9 scheme: 'uds' | 'bridge' | 'other' 10 target: string 11} { 12 if (to.startsWith('uds:')) return { scheme: 'uds', target: to.slice(4) } 13 if (to.startsWith('bridge:')) return { scheme: 'bridge', target: to.slice(7) } 14 // Legacy: old-code UDS senders emit bare socket paths in from=; route them 15 // through the UDS branch so replies aren't silently dropped into teammate 16 // routing. (No bare-session-ID fallback — bridge messaging is new enough 17 // that no old senders exist, and the prefix would hijack teammate names 18 // like session_manager.) 19 if (to.startsWith('/')) return { scheme: 'uds', target: to } 20 return { scheme: 'other', target: to } 21}