@@ -16,24 +16,28 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
1616
1717 spyOn ( databaseModule , 'getUserInfoFromApiKey' ) . mockResolvedValue ( {
1818 id : 'user-123' ,
19+ email : 'test@example.com' ,
20+ discord_id : null ,
21+ referral_code : null ,
1922 } )
2023 spyOn ( databaseModule , 'fetchAgentFromDatabase' ) . mockResolvedValue ( null )
21- spyOn ( databaseModule , 'startAgentRun' ) . mockResolvedValue ( { runId : 'run-1' } )
22- spyOn ( databaseModule , 'finishAgentRun' ) . mockResolvedValue ( )
23- spyOn ( databaseModule , 'addAgentStep' ) . mockResolvedValue ( )
24+ spyOn ( databaseModule , 'startAgentRun' ) . mockResolvedValue ( 'run-1' )
25+ spyOn ( databaseModule , 'finishAgentRun' ) . mockResolvedValue ( undefined )
26+ spyOn ( databaseModule , 'addAgentStep' ) . mockResolvedValue ( 'step-1' )
2427
2528 spyOn ( mainPromptModule , 'callMainPrompt' ) . mockImplementation (
2629 async (
2730 params : Parameters < typeof mainPromptModule . callMainPrompt > [ 0 ] ,
2831 ) => {
29- const { sendAction, action : promptAction } = params
32+ const { sendAction, action : promptAction , promptId } = params
3033 const sessionState = getInitialSessionState (
3134 getStubProjectFileContext ( ) ,
3235 )
3336
3437 await sendAction ( {
3538 action : {
3639 type : 'response-chunk' ,
40+ userInputId : promptId ,
3741 chunk : {
3842 type : 'subagent_start' ,
3943 agentId : 'sub-1' ,
@@ -50,7 +54,7 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
5054 await sendAction ( {
5155 action : {
5256 type : 'subagent-response-chunk' ,
53- userInputId : 'input-1' ,
57+ userInputId : promptId ,
5458 agentId : 'sub-1' ,
5559 agentType : 'commander' ,
5660 chunk : 'hello from subagent' ,
@@ -60,6 +64,7 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
6064 await sendAction ( {
6165 action : {
6266 type : 'response-chunk' ,
67+ userInputId : promptId ,
6368 chunk : {
6469 type : 'subagent_finish' ,
6570 agentId : 'sub-1' ,
@@ -76,13 +81,22 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
7681 await sendAction ( {
7782 action : {
7883 type : 'prompt-response' ,
84+ promptId,
7985 sessionState,
8086 output : {
8187 type : 'lastMessage' ,
8288 value : [ ] ,
8389 } ,
8490 } ,
8591 } )
92+
93+ return {
94+ sessionState,
95+ output : {
96+ type : 'lastMessage' as const ,
97+ value : [ ] ,
98+ } ,
99+ }
86100 } ,
87101 )
88102
0 commit comments