@@ -70,9 +70,8 @@ describe('History', () => {
7070 const stepId = history . addStepRequest ( 'test prompt' , schema )
7171 const response = 'test response'
7272
73- const result = await history . addStepResponse ( stepId , Promise . resolve ( response ) , schema )
73+ history . addStepResponse ( stepId , response , undefined , schema )
7474
75- expect ( result ) . toBe ( response )
7675 expect ( history [ 'messages' ] ) . toHaveLength ( 2 )
7776
7877 const responseMessage = history [ 'messages' ] [ 1 ]
@@ -150,7 +149,7 @@ describe('History', () => {
150149
151150 const schema = z . string ( )
152151 const stepId = history . addStepRequest ( 'test prompt' , schema )
153- await history . addStepResponse ( stepId , Promise . resolve ( 'response' ) , schema )
152+ history . addStepResponse ( stepId , 'response' , undefined , schema )
154153
155154 expect ( listener ) . toHaveBeenCalledWith ( {
156155 type : 'step-response' ,
@@ -159,23 +158,6 @@ describe('History', () => {
159158 } )
160159 } )
161160
162- it ( 'should dispatch step-error event on promise rejection' , async ( ) => {
163- const listener = vi . fn ( )
164- history . addEventListener ( 'step-error' , listener )
165-
166- const schema = z . string ( )
167- const stepId = history . addStepRequest ( 'test prompt' , schema )
168- const error = new Error ( 'Test error' )
169-
170- await expect ( history . addStepResponse ( stepId , Promise . reject ( error ) , schema ) ) . rejects . toThrow ( 'Test error' )
171-
172- expect ( listener ) . toHaveBeenCalledWith ( {
173- type : 'step-error' ,
174- historyId : history . id ,
175- error : 'Test error' ,
176- } )
177- } )
178-
179161 it ( 'should dispatch data-reference-added event' , ( ) => {
180162 const listener = vi . fn ( )
181163 history . addEventListener ( 'data-reference-added' , listener )
@@ -213,7 +195,7 @@ describe('History', () => {
213195 const stepId = history . addStepRequest ( 'test' , schema )
214196 expect ( listener ) . toHaveBeenCalledTimes ( 1 )
215197
216- await history . addStepResponse ( stepId , Promise . resolve ( 'response' ) , schema )
198+ history . addStepResponse ( stepId , 'response' , undefined , schema )
217199 controller . abort ( )
218200 history . addStepRequest ( 'test2' , schema )
219201 expect ( listener ) . toHaveBeenCalledTimes ( 1 ) // Should not be called again
@@ -245,7 +227,7 @@ describe('History', () => {
245227 it ( 'should allow starting new step after previous one completes' , async ( ) => {
246228 const schema = z . string ( )
247229 const stepId1 = history . addStepRequest ( 'first step' , schema )
248- await history . addStepResponse ( stepId1 , Promise . resolve ( 'response1' ) , schema )
230+ history . addStepResponse ( stepId1 , 'response1' , undefined , schema )
249231
250232 const stepId2 = history . addStepRequest ( 'second step' , schema )
251233 expect ( stepId2 ) . toBe ( 1 )
@@ -255,7 +237,7 @@ describe('History', () => {
255237 const schema = z . string ( )
256238 const stepId = history . addStepRequest ( 'test step' , schema )
257239
258- await expect ( history . addStepResponse ( stepId + 1 , Promise . resolve ( 'response' ) , schema ) ) . rejects . toThrow (
240+ expect ( ( ) => history . addStepResponse ( stepId + 1 , 'response' , undefined , schema ) ) . toThrow (
259241 'Step-2 is not currently executing. Current step is 1' ,
260242 )
261243 } )
@@ -309,7 +291,7 @@ describe('History', () => {
309291 it ( 'should clone history correctly' , async ( ) => {
310292 const schema = z . string ( )
311293 const stepId = history . addStepRequest ( 'test' , schema )
312- await history . addStepResponse ( stepId , Promise . resolve ( 'response' ) , schema )
294+ history . addStepResponse ( stepId , 'response' , undefined , schema )
313295 history . add ( { test : 'data' } )
314296
315297 const cloned = history . clone ( )
@@ -323,7 +305,7 @@ describe('History', () => {
323305 const source = new History ( )
324306 const schema = z . string ( )
325307 const stepId = source . addStepRequest ( 'test' , schema )
326- await source . addStepResponse ( stepId , Promise . resolve ( 'response' ) , schema )
308+ source . addStepResponse ( stepId , 'response' , undefined , schema )
327309
328310 history . copy ( source )
329311
@@ -439,12 +421,12 @@ describe('History', () => {
439421 // First step with user schema
440422 const stepId1 = history . addStepRequest ( 'Get user info' , userSchema )
441423 const response1 = { name : 'John' , age : 30 }
442- await history . addStepResponse ( stepId1 , Promise . resolve ( response1 ) , userSchema )
424+ history . addStepResponse ( stepId1 , response1 , undefined , userSchema )
443425
444426 // Second step with same user schema
445427 const stepId2 = history . addStepRequest ( 'Validate user info' , userSchema )
446428 const response2 = { name : 'Jane' , age : 25 }
447- await history . addStepResponse ( stepId2 , Promise . resolve ( response2 ) , userSchema )
429+ history . addStepResponse ( stepId2 , response2 , undefined , userSchema )
448430
449431 expect ( history [ 'messages' ] ) . toHaveLength ( 4 )
450432
@@ -472,13 +454,14 @@ describe('History', () => {
472454 } )
473455
474456 const stepId = history . addStepRequest ( 'Process user with addresses' , userSchema )
475- await history . addStepResponse (
457+ history . addStepResponse (
476458 stepId ,
477- Promise . resolve ( {
459+ {
478460 name : 'John' ,
479461 address : { street : '123 Main St' , city : 'NYC' } ,
480462 addresses : [ { street : '456 Oak Ave' , city : 'LA' } ] ,
481- } ) ,
463+ } ,
464+ undefined ,
482465 userSchema ,
483466 )
484467
@@ -500,7 +483,7 @@ describe('History', () => {
500483
501484 // Add first step
502485 const stepId1 = history . addStepRequest ( 'First step' , schema )
503- await history . addStepResponse ( stepId1 , Promise . resolve ( { id : 1 , name : 'test' } ) , schema )
486+ history . addStepResponse ( stepId1 , { id : 1 , name : 'test' } , undefined , schema )
504487
505488 // Clone history
506489 const cloned = history . clone ( )
@@ -534,7 +517,7 @@ describe('History', () => {
534517 // Add step
535518 const schema = z . string ( )
536519 const stepId = history . addStepRequest ( 'Test step' , schema )
537- await history . addStepResponse ( stepId , Promise . resolve ( 'response' ) , schema )
520+ history . addStepResponse ( stepId , 'response' , undefined , schema )
538521
539522 expect ( history [ 'messages' ] ) . toHaveLength ( 5 )
540523
@@ -594,7 +577,7 @@ describe('History', () => {
594577 // First step
595578 const schema1 = z . object ( { processed : z . boolean ( ) } )
596579 const stepId1 = history . addStepRequest ( 'Process user' , schema1 )
597- await history . addStepResponse ( stepId1 , Promise . resolve ( { processed : true } ) , schema1 )
580+ history . addStepResponse ( stepId1 , { processed : true } , undefined , schema1 )
598581
599582 // Add more data
600583 const configData = { setting : 'enabled' }
@@ -603,7 +586,7 @@ describe('History', () => {
603586 // Second step
604587 const schema2 = z . array ( z . string ( ) )
605588 const stepId2 = history . addStepRequest ( 'Generate list' , schema2 )
606- await history . addStepResponse ( stepId2 , Promise . resolve ( [ 'item1' , 'item2' ] ) , schema2 )
589+ history . addStepResponse ( stepId2 , [ 'item1' , 'item2' ] , undefined , schema2 )
607590
608591 // Subtask
609592 const subtaskResult = history . subtask ( 'subtask goal' , ( ) => 'subtask result' )
@@ -643,7 +626,7 @@ describe('History', () => {
643626 history . add ( { data : 'test' } )
644627 const schema = z . object ( { result : z . string ( ) } )
645628 const stepId = history . addStepRequest ( 'Test' , schema )
646- await history . addStepResponse ( stepId , Promise . resolve ( { result : 'success' } ) , schema )
629+ history . addStepResponse ( stepId , { result : 'success' } , undefined , schema )
647630
648631 // Clone and verify structure
649632 const cloned = history . clone ( )
0 commit comments