( socketPath: string, expectedVersion: string = CodeGraphPackageVersion, )
| 119 | * price of never silently running a stale daemon against newer client code.) |
| 120 | */ |
| 121 | export async function runProxy( |
| 122 | socketPath: string, |
| 123 | expectedVersion: string = CodeGraphPackageVersion, |
| 124 | ): Promise<ProxyResult> { |
| 125 | // The same connect as every session's: the hello, the version and the |
| 126 | // daemon's proof that it runs as this user, before any byte is piped. |
| 127 | const socket = await connectWithHello(socketPath, expectedVersion); |
| 128 | if (!socket) return { outcome: 'fallback-needed', reason: 'no daemon answered' }; |
| 129 | if (typeof socket === 'string') { |
| 130 | return { outcome: 'fallback-needed', reason: socket === 'unproven' ? 'daemon could not prove it runs as this user' : 'version mismatch' }; |
| 131 | } |
| 132 | startPpidWatchdog(socket); |
| 133 | await pipeUntilClose(socket); |
| 134 | // Host disconnected (or the daemon went away). The proxy's only job is the |
| 135 | // pipe; exit now so we don't linger — process.stdin's 'data' listener would |
| 136 | // otherwise keep the event loop alive and leave a zombie launcher behind. |
| 137 | process.exit(0); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Connect to a daemon at `socketPath`, verify its hello (exact version match), |
nothing calls this directly
no test coverage detected