(sessionId: string)
| 25 | |
| 26 | // Using these paths due to strict limits on the POSIX socket path length. |
| 27 | export function getSocketPath(sessionId: string): string { |
| 28 | const uid = os.userInfo().uid; |
| 29 | const suffix = sessionId ? `-${sessionId}` : ''; |
| 30 | const appName = APP_NAME + suffix; |
| 31 | |
| 32 | if (IS_WINDOWS) { |
| 33 | // Windows uses Named Pipes, not file paths. |
| 34 | // This format is required for server.listen() |
| 35 | return path.join('\\\\.\\pipe', appName, 'server.sock'); |
| 36 | } |
| 37 | |
| 38 | // 1. Try XDG_RUNTIME_DIR (Linux standard, sometimes macOS) |
| 39 | if (process.env.XDG_RUNTIME_DIR) { |
| 40 | return path.join(process.env.XDG_RUNTIME_DIR, appName, 'server.sock'); |
| 41 | } |
| 42 | |
| 43 | // 2. macOS/Unix Fallback: Use /tmp/ |
| 44 | // We use /tmp/ because it is much shorter than ~/Library/Application Support/ |
| 45 | // and keeps us well under the 104-character limit. |
| 46 | return path.join('/tmp', `${appName}-${uid}.sock`); |
| 47 | } |
| 48 | |
| 49 | export function getRuntimeHome(sessionId: string): string { |
| 50 | const platform = os.platform(); |
no outgoing calls
no test coverage detected