@@ -30,6 +30,8 @@ const emitXAiAskUserQuestionThenHang =
3030const emitContentThenHang = process . env . T3_ACP_EMIT_CONTENT_THEN_HANG === "1" ;
3131const emitPlanThenHang = process . env . T3_ACP_EMIT_PLAN_THEN_HANG === "1" ;
3232const emitActiveToolThenHang = process . env . T3_ACP_EMIT_ACTIVE_TOOL_THEN_HANG === "1" ;
33+ const emitGrokMonitorPostTurnPoll = process . env . T3_ACP_EMIT_GROK_MONITOR_POST_TURN_POLL === "1" ;
34+ const emitGrokBackgroundTaskStarted = process . env . T3_ACP_EMIT_GROK_BACKGROUND_TASK_STARTED === "1" ;
3335const emitForeignSessionUpdates = process . env . T3_ACP_EMIT_FOREIGN_SESSION_UPDATES === "1" ;
3436const waitForResumeRelease = process . env . T3_ACP_WAIT_FOR_RESUME_RELEASE === "1" ;
3537const completeFirstPromptOnCancel = process . env . T3_ACP_COMPLETE_FIRST_PROMPT_ON_CANCEL === "1" ;
@@ -837,6 +839,108 @@ const program = Effect.gen(function* () {
837839 return yield * Effect . never ;
838840 }
839841
842+ if ( emitGrokMonitorPostTurnPoll ) {
843+ const monitorCallId = "call-monitor-1" ;
844+ const pollCallId = "call-monitor-poll-1" ;
845+ const taskId = "01a05f41-5107-7550-821e-79e8d1cd7687" ;
846+ const description = "Watch count-sheet Typst unit until done" ;
847+ writeJsonRpcNotification ( "session/update" , {
848+ sessionId : requestedSessionId ,
849+ update : {
850+ sessionUpdate : "tool_call" ,
851+ toolCallId : monitorCallId ,
852+ title : "monitor" ,
853+ kind : "other" ,
854+ status : "pending" ,
855+ rawInput : { description } ,
856+ _meta : {
857+ "x.ai/tool" : { version : 1 , name : "monitor" , kind : "task" , namespace : "grok_build" } ,
858+ } ,
859+ } ,
860+ } ) ;
861+ writeJsonRpcNotification ( "session/update" , {
862+ sessionId : requestedSessionId ,
863+ update : {
864+ sessionUpdate : "tool_call_update" ,
865+ toolCallId : monitorCallId ,
866+ status : "completed" ,
867+ rawInput : { description } ,
868+ rawOutput : {
869+ type : "Monitor" ,
870+ taskId,
871+ timeoutMs : 36_000_000 ,
872+ } ,
873+ } ,
874+ } ) ;
875+ writeJsonRpcNotification ( "_x.ai/session/prompt_complete" , {
876+ sessionId : requestedSessionId ,
877+ promptId : promptIdFromRequestMeta ( request ) ?? "mock-xai-prompt-1" ,
878+ stopReason : "end_turn" ,
879+ agentResult : null ,
880+ } ) ;
881+ yield * Effect . sleep ( "120 millis" ) ;
882+ writeJsonRpcNotification ( "session/update" , {
883+ sessionId : requestedSessionId ,
884+ update : {
885+ sessionUpdate : "tool_call" ,
886+ toolCallId : pollCallId ,
887+ title : "get_command_or_subagent_output" ,
888+ kind : "other" ,
889+ status : "completed" ,
890+ rawInput : { variant : "TaskOutput" , task_ids : [ taskId ] , timeout_ms : 0 } ,
891+ rawOutput : {
892+ type : "TaskOutput" ,
893+ Result : {
894+ task_id : taskId ,
895+ command : `[monitor] ${ description } ` ,
896+ status : "completed" ,
897+ exit_code : 0 ,
898+ output : "Monitor finished." ,
899+ } ,
900+ } ,
901+ } ,
902+ } ) ;
903+ return yield * Effect . never ;
904+ }
905+
906+ if ( emitGrokBackgroundTaskStarted ) {
907+ const toolCallId = "call-fb9d0000-0000-0000-0000-000000000026" ;
908+ const command = "sleep 40; echo done-a" ;
909+ writeJsonRpcNotification ( "session/update" , {
910+ sessionId : requestedSessionId ,
911+ update : {
912+ sessionUpdate : "tool_call" ,
913+ toolCallId,
914+ title : "run_terminal_command" ,
915+ kind : "execute" ,
916+ status : "in_progress" ,
917+ rawInput : { command } ,
918+ } ,
919+ } ) ;
920+ writeJsonRpcNotification ( "session/update" , {
921+ sessionId : requestedSessionId ,
922+ update : {
923+ sessionUpdate : "tool_call_update" ,
924+ toolCallId,
925+ status : "completed" ,
926+ rawOutput : {
927+ type : "BackgroundTaskStarted" ,
928+ task_id : toolCallId ,
929+ task_type : "bash" ,
930+ status : "running" ,
931+ command,
932+ } ,
933+ } ,
934+ } ) ;
935+ writeJsonRpcNotification ( "_x.ai/session/prompt_complete" , {
936+ sessionId : requestedSessionId ,
937+ promptId : promptIdFromRequestMeta ( request ) ?? "mock-xai-prompt-1" ,
938+ stopReason : "end_turn" ,
939+ agentResult : null ,
940+ } ) ;
941+ return yield * Effect . never ;
942+ }
943+
840944 if ( emitInterleavedAssistantToolCalls ) {
841945 const toolCallId = "tool-call-1" ;
842946
0 commit comments