@@ -48,9 +48,16 @@ for await (const line of NodeReadline.createInterface({ input: process.stdin }))
4848 respond ( { sessionId } ) ;
4949 break ;
5050 case "session/prompt" :
51- // Each rejection scenario then hangs, so only the helper's own abort can settle it .
52- if ( scenario === "tool_call" ) {
51+ // Open-ended requests stay pending so rejection cannot wait for session/prompt .
52+ if ( scenario === "tool_call" || scenario === "tool_call_completed" ) {
5353 update ( { sessionUpdate : "tool_call" , toolCallId : "t1" , title : "bash" , status : "pending" } ) ;
54+ if ( scenario === "tool_call_completed" ) {
55+ update ( {
56+ sessionUpdate : "agent_message_chunk" ,
57+ content : { type : "text" , text : '{"title":"Copilot title"}' } ,
58+ } ) ;
59+ respond ( { stopReason : "end_turn" } ) ;
60+ }
5461 } else if ( scenario === "permission" ) {
5562 write ( {
5663 jsonrpc : "2.0" ,
@@ -69,7 +76,17 @@ for await (const line of NodeReadline.createInterface({ input: process.stdin }))
6976 method : "fs/read_text_file" ,
7077 params : { sessionId, path : "/etc/hostname" } ,
7178 } ) ;
72- } else {
79+ } else if ( scenario === "empty" || scenario === "cancelled" ) {
80+ respond ( { stopReason : scenario === "cancelled" ? "cancelled" : "end_turn" } ) ;
81+ } else if ( scenario === "limit_exact" || scenario === "limit_exceeded" ) {
82+ const reply = JSON . stringify ( { title : "Copilot title" } ) . padEnd (
83+ scenario === "limit_exact" ? 128000 : 128001 ,
84+ " " ,
85+ ) ;
86+ for ( const part of [ reply . slice ( 0 , 64000 ) , reply . slice ( 64000 ) ] )
87+ update ( { sessionUpdate : "agent_message_chunk" , content : { type : "text" , text : part } } ) ;
88+ respond ( { stopReason : "end_turn" } ) ;
89+ } else if ( scenario === "reply" ) {
7390 update ( {
7491 sessionUpdate : "agent_message_chunk" ,
7592 content : { type : "text" , text : "Info: Disabled tools: bash, view\n" } ,
@@ -79,6 +96,8 @@ for await (const line of NodeReadline.createInterface({ input: process.stdin }))
7996 content : { type : "text" , text : JSON . stringify ( { title : "Copilot title" } ) } ,
8097 } ) ;
8198 respond ( { stopReason : "end_turn" } ) ;
99+ } else {
100+ throw new Error ( "Unconfigured mock scenario: " + scenario ) ;
82101 }
83102 break ;
84103 default :
0 commit comments