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

Function parseClientHelloLine

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

Source from the content-addressed store, hash-verified

1083 * which case the caller treats the bytes as ordinary JSON-RPC.
1084 */
1085export function parseClientHelloLine(
1086 line: string,
1087): { pid: number; hostPid: number | null; challenge?: string } | null {
1088 let parsed: unknown;
1089 try { parsed = JSON.parse(line); } catch { return null; }
1090 if (!parsed || typeof parsed !== 'object') return null;
1091 const o = parsed as Record<string, unknown>;
1092 if (o.codegraph_client !== 1 || typeof o.pid !== 'number') return null;
1093 const peers: { pid: number; hostPid: number | null; challenge?: string } = {
1094 pid: o.pid,
1095 hostPid: typeof o.hostPid === 'number' ? o.hostPid : null,
1096 };
1097 if (typeof o.challenge === 'string' && o.challenge.length > 0 && o.challenge.length <= MAX_CHALLENGE_LENGTH) {
1098 peers.challenge = o.challenge;
1099 }
1100 return peers;
1101}
1102
1103/**
1104 * 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