@@ -109,6 +109,13 @@ function latestOutboundDeliveryArgs(): {
109109 payloads : ReplyPayload [ ] ;
110110 bestEffort ?: boolean ;
111111 queuePolicy ?: string ;
112+ replyPayloadSendingHook ?: {
113+ kind ?: string ;
114+ channel ?: string ;
115+ sessionKey ?: string ;
116+ runId ?: string ;
117+ context ?: Record < string , unknown > ;
118+ } ;
112119} {
113120 const args = lastMockArg ( deliverOutboundPayloadsMock , "outbound delivery arguments" ) ;
114121 if ( ! args || typeof args !== "object" ) {
@@ -121,6 +128,13 @@ function latestOutboundDeliveryArgs(): {
121128 payloads : ReplyPayload [ ] ;
122129 bestEffort ?: boolean ;
123130 queuePolicy ?: string ;
131+ replyPayloadSendingHook ?: {
132+ kind ?: string ;
133+ channel ?: string ;
134+ sessionKey ?: string ;
135+ runId ?: string ;
136+ context ?: Record < string , unknown > ;
137+ } ;
124138 } ;
125139}
126140
@@ -396,6 +410,62 @@ describe("normalizeAgentCommandReplyPayloads", () => {
396410 } ) ;
397411 } ) ;
398412
413+ it ( "passes reply payload hook metadata through recovered agent delivery" , async ( ) => {
414+ deliverOutboundPayloadsMock . mockResolvedValue ( [ { channel : "slack" , messageId : "msg-1" } ] ) ;
415+
416+ await deliverAgentCommandResult ( {
417+ cfg : {
418+ agents : {
419+ list : [ { id : "tester" , workspace : "/tmp/agent-workspace" } ] ,
420+ } ,
421+ } as OpenClawConfig ,
422+ deps : { } as CliDeps ,
423+ runtime : { log : vi . fn ( ) , error : vi . fn ( ) } as never ,
424+ opts : {
425+ message : "resume interrupted turn" ,
426+ deliver : true ,
427+ bestEffortDeliver : true ,
428+ channel : "slack" ,
429+ to : "#general" ,
430+ accountId : "workspace-1" ,
431+ threadId : "thread-7" ,
432+ sessionKey : "agent:tester:slack:direct:alice" ,
433+ runId : "run-recovered" ,
434+ } as AgentCommandOpts ,
435+ outboundSession : {
436+ key : "agent:tester:slack:direct:alice" ,
437+ agentId : "tester" ,
438+ } as never ,
439+ sessionEntry : {
440+ sessionId : "session-1" ,
441+ updatedAt : 1 ,
442+ restartRecoveryDeliveryContext : {
443+ channel : "slack" ,
444+ to : "#general" ,
445+ accountId : "workspace-1" ,
446+ threadId : "thread-7" ,
447+ } ,
448+ restartRecoveryDeliveryRunId : "run-recovered" ,
449+ } ,
450+ payloads : [ { text : "after restart" } ] ,
451+ result : createResult ( ) ,
452+ } ) ;
453+
454+ expect ( latestOutboundDeliveryArgs ( ) . replyPayloadSendingHook ) . toEqual ( {
455+ kind : "final" ,
456+ channel : "slack" ,
457+ sessionKey : "agent:tester:slack:direct:alice" ,
458+ runId : "run-recovered" ,
459+ context : {
460+ channelId : "slack" ,
461+ accountId : "workspace-1" ,
462+ conversationId : "#general" ,
463+ sessionKey : "agent:tester:slack:direct:alice" ,
464+ runId : "run-recovered" ,
465+ } ,
466+ } ) ;
467+ } ) ;
468+
399469 it ( "does not refresh final delivery routing from a different logical session" , async ( ) => {
400470 deliverOutboundPayloadsMock . mockResolvedValue ( [ { channel : "slack" , messageId : "msg-1" } ] ) ;
401471 const runtime = { log : vi . fn ( ) , error : vi . fn ( ) } ;
0 commit comments