@@ -10,6 +10,7 @@ import type { OpenClawConfig } from "../../config/config.js";
1010import { setActivePluginRegistry } from "../../plugins/runtime.js" ;
1111import { createOutboundTestPlugin , createTestRegistry } from "../../test-utils/channel-plugins.js" ;
1212import { normalizeSessionDeliveryState } from "../../utils/delivery-context.shared.js" ;
13+ import { buildRestartRecoveryTerminalDeliveryEvidence } from "../agent-command-restart-recovery.js" ;
1314import { createAgentRunRestartAbortError } from "../run-termination.js" ;
1415import { deliverAgentCommandResult } from "./delivery.js" ;
1516import type { AgentCommandOpts } from "./types.js" ;
@@ -766,6 +767,48 @@ describe("deliverAgentCommandResult payload normalization", () => {
766767 expect ( deliverOutboundPayloadsMock ) . not . toHaveBeenCalled ( ) ;
767768 } ) ;
768769
770+ it . each ( [
771+ {
772+ name : "deterministic approval prompt" ,
773+ result : { didSendDeterministicApprovalPrompt : true } ,
774+ field : "didSendDeterministicApprovalPrompt" ,
775+ expected : true ,
776+ } ,
777+ {
778+ name : "accepted session spawn" ,
779+ result : {
780+ acceptedSessionSpawns : [
781+ { runId : "child-run" , childSessionKey : "agent:main:subagent:child" } ,
782+ ] ,
783+ } ,
784+ field : "acceptedSessionSpawns" ,
785+ expected : [ { runId : "child-run" , childSessionKey : "agent:main:subagent:child" } ] ,
786+ } ,
787+ {
788+ name : "successful cron add" ,
789+ result : { successfulCronAdds : 1 } ,
790+ field : "successfulCronAdds" ,
791+ expected : 1 ,
792+ } ,
793+ ] ) ( "preserves $name as restart-unsafe delivery evidence" , async ( { result, field, expected } ) => {
794+ const onDeliveryResult = vi . fn ( ) ;
795+ const delivered = await deliverAgentCommandResultForTest ( {
796+ omitReplyTarget : true ,
797+ opts : { deliver : false } ,
798+ payloads : [ ] ,
799+ result,
800+ onDeliveryResult,
801+ } ) ;
802+
803+ expect ( delivered ) . toHaveProperty ( field , expected ) ;
804+ expect ( onDeliveryResult ) . toHaveBeenCalledOnce ( ) ;
805+ expect ( onDeliveryResult ) . toHaveBeenCalledWith ( delivered ) ;
806+ expect ( buildRestartRecoveryTerminalDeliveryEvidence ( delivered ) ) . toEqual ( {
807+ captured : true ,
808+ restartUnsafeSideEffectsDetected : true ,
809+ } ) ;
810+ } ) ;
811+
769812 it ( "does not automatically redeliver text and media already sent to the same target" , async ( ) => {
770813 const delivered = await deliverAgentCommandResultForTest ( {
771814 opts : { threadId : "171.222" } ,
0 commit comments