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

Function parseClientHelloLine

src/mcp/daemon.ts:1098–1114  ·  view source on GitHub ↗
(
  line: string,
)

Source from the content-addressed store, hash-verified

1096 * which case the caller treats the bytes as ordinary JSON-RPC.
1097 */
1098export function parseClientHelloLine(
1099 line: string,
1100): { pid: number; hostPid: number | null; challenge?: string } | null {
1101 let parsed: unknown;
1102 try { parsed = JSON.parse(line); } catch { return null; }
1103 if (!parsed || typeof parsed !== 'object') return null;
1104 const o = parsed as Record<string, unknown>;
1105 if (o.codegraph_client !== 1 || typeof o.pid !== 'number') return null;
1106 const peers: { pid: number; hostPid: number | null; challenge?: string } = {
1107 pid: o.pid,
1108 hostPid: typeof o.hostPid === 'number' ? o.hostPid : null,
1109 };
1110 if (typeof o.challenge === 'string' && o.challenge.length > 0 && o.challenge.length <= MAX_CHALLENGE_LENGTH) {
1111 peers.challenge = o.challenge;
1112 }
1113 return peers;
1114}
1115
1116/**
1117 * A client's peer is dead when its proxy process is gone, or when its known

Callers 3

onDataFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected