MCPcopy Create free account
hub / github.com/commandoperator/cmdop-sdk / collect

Method collect

node/src/streaming.ts:160–171  ·  view source on GitHub ↗

* Drain to the final text (the `done` frame's text, else accumulated event * deltas). Throws AgentStreamError on an error outcome.

()

Source from the content-addressed store, hash-verified

158 * deltas). Throws {@link AgentStreamError} on an error outcome.
159 */
160 async collect(): Promise<string> {
161 let text = "";
162 for await (const f of this) {
163 if (f.type === "event") {
164 const p = f.payload as { delta?: string; text?: string } | undefined;
165 text += p?.delta ?? p?.text ?? "";
166 } else if (f.type === "done") {
167 return f.text || text;
168 }
169 }
170 return text;
171 }
172}

Callers 1

transport.test.tsFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected