MCPcopy Create free account
hub / github.com/backnotprop/plannotator / readStream

Method readStream

packages/ai/providers/pi-sdk-node.ts:115–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113 }
114
115 private readStream(): void {
116 if (!this.proc?.stdout) return;
117
118 this.proc.stdout.on("data", (chunk: Buffer) => {
119 this.buffer += chunk.toString();
120 const lines = this.buffer.split("\n");
121 this.buffer = lines.pop() ?? "";
122
123 for (const line of lines) {
124 const trimmed = line.replace(/\r$/, "");
125 if (!trimmed) continue;
126 try {
127 const parsed = JSON.parse(trimmed);
128 this.routeMessage(parsed);
129 } catch {
130 // Ignore malformed lines
131 }
132 }
133 });
134 }
135
136 private routeMessage(msg: Record<string, unknown>): void {
137 if (msg.type === "response" && typeof msg.id === "string") {

Callers 1

onSpawnMethod · 0.95

Calls 5

routeMessageMethod · 0.95
onMethod · 0.80
toStringMethod · 0.80
replaceMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected