@@ -51,6 +51,11 @@ describe('processStreamWithTags', () => {
5151 }
5252
5353 const result : string [ ] = [ ]
54+ const responseChunks : any [ ] = [ ]
55+
56+ function onResponseChunk ( chunk : any ) {
57+ responseChunks . push ( chunk )
58+ }
5459
5560 function defaultProcessor ( toolName : string ) {
5661 return {
@@ -65,6 +70,7 @@ describe('processStreamWithTags', () => {
6570 processors,
6671 defaultProcessor,
6772 onError,
73+ onResponseChunk,
6874 } ) ) {
6975 if ( chunk . type === 'text' ) {
7076 result . push ( chunk . text )
@@ -111,6 +117,11 @@ describe('processStreamWithTags', () => {
111117 }
112118
113119 const result : string [ ] = [ ]
120+ const responseChunks : any [ ] = [ ]
121+
122+ function onResponseChunk ( chunk : any ) {
123+ responseChunks . push ( chunk )
124+ }
114125
115126 function defaultProcessor ( toolName : string ) {
116127 return {
@@ -125,6 +136,7 @@ describe('processStreamWithTags', () => {
125136 processors,
126137 defaultProcessor,
127138 onError,
139+ onResponseChunk,
128140 } ) ) {
129141 if ( chunk . type === 'text' ) {
130142 result . push ( chunk . text )
@@ -181,6 +193,11 @@ describe('processStreamWithTags', () => {
181193 }
182194
183195 const result : string [ ] = [ ]
196+ const responseChunks : any [ ] = [ ]
197+
198+ function onResponseChunk ( chunk : any ) {
199+ responseChunks . push ( chunk )
200+ }
184201
185202 function defaultProcessor ( toolName : string ) {
186203 return {
@@ -195,6 +212,7 @@ describe('processStreamWithTags', () => {
195212 processors,
196213 defaultProcessor,
197214 onError,
215+ onResponseChunk,
198216 } ) ) {
199217 if ( chunk . type === 'text' ) {
200218 result . push ( chunk . text )
@@ -249,6 +267,12 @@ describe('processStreamWithTags', () => {
249267 events . push ( { name, error, type : 'error' } )
250268 }
251269
270+ const responseChunks : any [ ] = [ ]
271+
272+ function onResponseChunk ( chunk : any ) {
273+ responseChunks . push ( chunk )
274+ }
275+
252276 function defaultProcessor ( toolName : string ) {
253277 // For unknown tools, still return a processor but track the error
254278 events . push ( {
@@ -268,6 +292,7 @@ describe('processStreamWithTags', () => {
268292 processors,
269293 defaultProcessor,
270294 onError,
295+ onResponseChunk,
271296 } ) ) {
272297 // consume stream
273298 }
@@ -316,6 +341,11 @@ describe('processStreamWithTags', () => {
316341 }
317342
318343 const result : string [ ] = [ ]
344+ const responseChunks : any [ ] = [ ]
345+
346+ function onResponseChunk ( chunk : any ) {
347+ responseChunks . push ( chunk )
348+ }
319349
320350 function defaultProcessor ( toolName : string ) {
321351 return {
@@ -330,6 +360,7 @@ describe('processStreamWithTags', () => {
330360 processors,
331361 defaultProcessor,
332362 onError,
363+ onResponseChunk,
333364 } ) ) {
334365 if ( chunk . type === 'text' ) {
335366 result . push ( chunk . text )
@@ -382,6 +413,11 @@ describe('processStreamWithTags', () => {
382413 }
383414
384415 const result : string [ ] = [ ]
416+ const responseChunks : any [ ] = [ ]
417+
418+ function onResponseChunk ( chunk : any ) {
419+ responseChunks . push ( chunk )
420+ }
385421
386422 function defaultProcessor ( toolName : string ) {
387423 return {
@@ -396,6 +432,7 @@ describe('processStreamWithTags', () => {
396432 processors,
397433 defaultProcessor,
398434 onError,
435+ onResponseChunk,
399436 } ) ) {
400437 if ( chunk . type === 'text' ) {
401438 result . push ( chunk . text )
@@ -429,6 +466,11 @@ describe('processStreamWithTags', () => {
429466 }
430467
431468 const result : string [ ] = [ ]
469+ const responseChunks : any [ ] = [ ]
470+
471+ function onResponseChunk ( chunk : any ) {
472+ responseChunks . push ( chunk )
473+ }
432474
433475 function defaultProcessor ( toolName : string ) {
434476 return {
@@ -443,6 +485,7 @@ describe('processStreamWithTags', () => {
443485 processors,
444486 defaultProcessor,
445487 onError,
488+ onResponseChunk,
446489 } ) ) {
447490 if ( chunk . type === 'text' ) {
448491 result . push ( chunk . text )
@@ -469,6 +512,11 @@ describe('processStreamWithTags', () => {
469512 }
470513
471514 const result : string [ ] = [ ]
515+ const responseChunks : any [ ] = [ ]
516+
517+ function onResponseChunk ( chunk : any ) {
518+ responseChunks . push ( chunk )
519+ }
472520
473521 function defaultProcessor ( toolName : string ) {
474522 return {
@@ -483,6 +531,7 @@ describe('processStreamWithTags', () => {
483531 processors,
484532 defaultProcessor,
485533 onError,
534+ onResponseChunk,
486535 } ) ) {
487536 if ( chunk . type === 'text' ) {
488537 result . push ( chunk . text )
0 commit comments