sessionClient
uses node:fs
Who a session's server is for: the directory its agent runs from (as the shell that started it says, PWD, when
that's this directory: one reached through a link, as a worktree's codebase is, is told apart from another), so a
server started again for the same agent goes on with its branch.
import fs from "node:fs"; import path from "node:path"; export function sessionClient(cwd: string): string { const pwd = process.env.PWD; try { if (pwd && fs.realpathSync(pwd) === fs.realpathSync(cwd)) return path.resolve(pwd); } catch {} return path.resolve(cwd); }