MCPcopy Index your code
hub / github.com/BlockRunAI/ClawRouter / extractFirstMessageContent

Function extractFirstMessageContent

test/test-e2e.ts:325–335  ·  view source on GitHub ↗
(payload: ResponsePayload)

Source from the content-addressed store, hash-verified

323}
324
325function extractFirstMessageContent(payload: ResponsePayload): string | undefined {
326 if (!payload.json || typeof payload.json !== "object") return undefined;
327 const root = payload.json as Record<string, unknown>;
328 if (!Array.isArray(root.choices) || root.choices.length === 0) return undefined;
329 const firstChoice = root.choices[0];
330 if (!firstChoice || typeof firstChoice !== "object") return undefined;
331 const message = (firstChoice as Record<string, unknown>).message;
332 if (!message || typeof message !== "object") return undefined;
333 const content = (message as Record<string, unknown>).content;
334 return typeof content === "string" ? content : undefined;
335}
336
337async function collectSse(res: Response): Promise<SsePayload> {
338 const text = await res.text();

Callers 2

expectChatContentFunction · 0.85
runLocalSuiteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected