MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / decodeLockInfo

Function decodeLockInfo

src/mcp/daemon-paths.ts:184–207  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

182 * we treat such a lockfile as "process is unknown version, refuse to share."
183 */
184export function decodeLockInfo(raw: string): DaemonLockInfo | null {
185 const trimmed = raw.trim();
186 if (!trimmed) return null;
187 try {
188 const parsed = JSON.parse(trimmed);
189 if (
190 parsed &&
191 typeof parsed.pid === 'number' &&
192 typeof parsed.version === 'string' &&
193 typeof parsed.socketPath === 'string' &&
194 typeof parsed.startedAt === 'number'
195 ) {
196 return parsed as DaemonLockInfo;
197 }
198 } catch {
199 // Fall through to legacy plain-pid handling.
200 }
201 if (!/^[1-9]\d*$/.test(trimmed)) return null;
202 const pid = Number(trimmed);
203 if (Number.isSafeInteger(pid)) {
204 return { pid, version: 'unknown', socketPath: '', startedAt: 0 };
205 }
206 return null;
207}

Callers 11

startMethod · 0.90
cleanupLockfileMethod · 0.90
tryAcquireDaemonLockFunction · 0.90
clearStaleDaemonLockFunction · 0.90
stopDaemonAtFunction · 0.90
daemonStopFailureMessageFunction · 0.90
stopOlderDaemonFunction · 0.90
makeFallbackEngineFunction · 0.90
outwaitCandidateFunction · 0.90

Calls 2

NumberInterface · 0.85
parseMethod · 0.80

Tested by

no test coverage detected