MCPcopy
hub / github.com/garrytan/gstack / toolResultText

Function toolResultText

test/skill-e2e-hermetic-canary.test.ts:50–61  ·  view source on GitHub ↗

Extract concatenated tool_result text from the stream-json transcript.

(transcript: any[])

Source from the content-addressed store, hash-verified

48
49/** Extract concatenated tool_result text from the stream-json transcript. */
50function toolResultText(transcript: any[]): string {
51 const chunks: string[] = [];
52 for (const event of transcript) {
53 if (event.type !== 'user') continue;
54 for (const item of event.message?.content ?? []) {
55 if (item.type !== 'tool_result') continue;
56 if (typeof item.content === 'string') chunks.push(item.content);
57 else for (const c of item.content ?? []) if (c.type === 'text') chunks.push(c.text);
58 }
59 }
60 return chunks.join('\n');
61}
62
63function initEvent(transcript: any[]): any {
64 return transcript.find((e) => e.type === 'system' && e.subtype === 'init');

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected