@@ -174,7 +174,7 @@ describe("handleClickClackInbound", () => {
174174 correlationId : "fakeco.case_1" ,
175175 } ) ;
176176
177- expect ( runtime . channel . inbound . dispatchReply ) . not . toHaveBeenCalled ( ) ;
177+ expect ( runtime . channel . inbound . dispatch ) . not . toHaveBeenCalled ( ) ;
178178 expect ( runtime . agent . runEmbeddedAgent ) . not . toHaveBeenCalled ( ) ;
179179 const completionRequest = ( runtime . llm . complete as LlmCompleteMock ) . mock . calls [ 0 ] ?. [ 0 ] ;
180180 expect ( completionRequest ?. agentId ) . toBe ( "service-bot" ) ;
@@ -270,9 +270,9 @@ describe("handleClickClackInbound", () => {
270270 message : createMessage ( ) ,
271271 } ) ;
272272
273- const dispatchReply = vi . mocked ( runtime . channel . inbound . dispatchReply ) ;
274- expect ( dispatchReply ) . toHaveBeenCalledTimes ( 1 ) ;
275- expect ( dispatchReply . mock . calls [ 0 ] ?. [ 0 ] . ctxPayload . CommandAuthorized ) . toBe ( true ) ;
273+ const dispatchTurn = vi . mocked ( runtime . channel . inbound . dispatch ) ;
274+ expect ( dispatchTurn ) . toHaveBeenCalledTimes ( 1 ) ;
275+ expect ( dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] . ctxPayload . CommandAuthorized ) . toBe ( true ) ;
276276 } ) ;
277277
278278 it ( "propagates account toolsAllow into agent reply dispatch" , async ( ) => {
@@ -297,9 +297,9 @@ describe("handleClickClackInbound", () => {
297297 message : createMessage ( ) ,
298298 } ) ;
299299
300- const dispatchReply = vi . mocked ( runtime . channel . inbound . dispatchReply ) ;
301- expect ( dispatchReply ) . toHaveBeenCalledTimes ( 1 ) ;
302- const dispatchParams = dispatchReply . mock . calls [ 0 ] ?. [ 0 ] as
300+ const dispatchTurn = vi . mocked ( runtime . channel . inbound . dispatch ) ;
301+ expect ( dispatchTurn ) . toHaveBeenCalledTimes ( 1 ) ;
302+ const dispatchParams = dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] as
303303 | ( Record < string , unknown > & {
304304 toolsAllow ?: unknown ;
305305 } )
@@ -335,12 +335,12 @@ describe("handleClickClackInbound", () => {
335335 } ) ,
336336 } ) ;
337337
338- const dispatchReply = vi . mocked ( runtime . channel . inbound . dispatchReply ) ;
339- expect ( dispatchReply ) . toHaveBeenCalledTimes ( 2 ) ;
340- const withoutOptIn = dispatchReply . mock . calls [ 0 ] ?. [ 0 ] as {
338+ const dispatchTurn = vi . mocked ( runtime . channel . inbound . dispatch ) ;
339+ expect ( dispatchTurn ) . toHaveBeenCalledTimes ( 2 ) ;
340+ const withoutOptIn = dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] as {
341341 replyOptions ?: { runId ?: unknown ; onItemEvent ?: unknown ; onModelSelected ?: unknown } ;
342342 } ;
343- const withOptIn = dispatchReply . mock . calls [ 1 ] ?. [ 0 ] as {
343+ const withOptIn = dispatchTurn . mock . calls [ 1 ] ?. [ 0 ] as {
344344 replyOptions ?: {
345345 onItemEvent ?: unknown ;
346346 onModelSelected ?: unknown ;
@@ -377,7 +377,7 @@ describe("handleClickClackInbound", () => {
377377 correlationId : "fakeco.case_2" ,
378378 } ) ;
379379
380- const dispatchParams = vi . mocked ( runtime . channel . inbound . dispatchReply ) . mock . calls [ 0 ] ?. [ 0 ] ;
380+ const dispatchParams = vi . mocked ( runtime . channel . inbound . dispatch ) . mock . calls [ 0 ] ?. [ 0 ] ;
381381 expect ( dispatchParams ?. replyOptions ?. runId ) . toBe ( `clickclack:${ VALID_MESSAGE_ID } ` ) ;
382382
383383 await dispatchParams ?. delivery . deliver ( { text : "correlated reply" } , { } as never ) ;
@@ -404,7 +404,7 @@ describe("handleClickClackInbound", () => {
404404 } ) ,
405405 } ) ;
406406
407- const delivery = vi . mocked ( runtime . channel . inbound . dispatchReply ) . mock . calls [ 0 ] ?. [ 0 ] . delivery ;
407+ const delivery = vi . mocked ( runtime . channel . inbound . dispatch ) . mock . calls [ 0 ] ?. [ 0 ] . delivery ;
408408 if ( typeof delivery ?. durable !== "function" ) {
409409 throw new Error ( "expected ClickClack media durable delivery resolver" ) ;
410410 }
@@ -437,7 +437,7 @@ describe("handleClickClackInbound", () => {
437437 message : createMessage ( { id : "msg_invalid" } ) ,
438438 } ) ;
439439
440- expect ( vi . mocked ( runtime . channel . inbound . dispatchReply ) . mock . calls [ 0 ] ?. [ 0 ] . replyOptions ) . toBe (
440+ expect ( vi . mocked ( runtime . channel . inbound . dispatch ) . mock . calls [ 0 ] ?. [ 0 ] . replyOptions ) . toBe (
441441 undefined ,
442442 ) ;
443443 } ) ;
@@ -461,15 +461,15 @@ describe("handleClickClackInbound", () => {
461461 } ) ,
462462 config : cfg ,
463463 message : createMessage ( {
464- channel_id : undefined ,
464+ channel_id : "" ,
465465 direct_conversation_id : "dcn_1" ,
466466 } ) ,
467467 } ) ;
468468
469- const dispatchReply = vi . mocked ( runtime . channel . inbound . dispatchReply ) ;
470- expect ( dispatchReply ) . toHaveBeenCalledTimes ( 1 ) ;
471- expect ( dispatchReply . mock . calls [ 0 ] ?. [ 0 ] . ctxPayload . ChatType ) . toBe ( "direct" ) ;
472- expect ( dispatchReply . mock . calls [ 0 ] ?. [ 0 ] . ctxPayload . CommandAuthorized ) . toBe ( true ) ;
469+ const dispatchTurn = vi . mocked ( runtime . channel . inbound . dispatch ) ;
470+ expect ( dispatchTurn ) . toHaveBeenCalledTimes ( 1 ) ;
471+ expect ( dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] . ctxPayload . ChatType ) . toBe ( "direct" ) ;
472+ expect ( dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] . ctxPayload . CommandAuthorized ) . toBe ( true ) ;
473473 } ) ;
474474
475475 it ( "preserves session policy when an account overrides the routed agent" , async ( ) => {
@@ -503,8 +503,8 @@ describe("handleClickClackInbound", () => {
503503 } ) ,
504504 } ) ;
505505
506- const dispatchReply = vi . mocked ( runtime . channel . inbound . dispatchReply ) ;
507- expect ( dispatchReply . mock . calls [ 0 ] ?. [ 0 ] . routeSessionKey ) . toBe (
506+ const dispatchTurn = vi . mocked ( runtime . channel . inbound . dispatch ) ;
507+ expect ( dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] . route . sessionKey ) . toBe (
508508 "agent:service-bot:clickclack:direct:alice" ,
509509 ) ;
510510 expect ( runtime . channel . routing . buildAgentSessionKey ) . toHaveBeenCalledWith ( {
@@ -546,10 +546,12 @@ describe("handleClickClackInbound", () => {
546546 } ) ,
547547 } ) ;
548548
549- const dispatchReply = vi . mocked ( runtime . channel . inbound . dispatchReply ) ;
550- expect ( dispatchReply . mock . calls [ 0 ] ?. [ 0 ] ) . toMatchObject ( {
551- agentId : "service-bot" ,
552- routeSessionKey : "agent:service-bot:clickclack:default:direct:dm:usr_owner" ,
549+ const dispatchTurn = vi . mocked ( runtime . channel . inbound . dispatch ) ;
550+ expect ( dispatchTurn . mock . calls [ 0 ] ?. [ 0 ] ) . toMatchObject ( {
551+ route : {
552+ agentId : "service-bot" ,
553+ sessionKey : "agent:service-bot:clickclack:default:direct:dm:usr_owner" ,
554+ } ,
553555 } ) ;
554556 } ) ;
555557
@@ -584,7 +586,7 @@ describe("handleClickClackInbound", () => {
584586 } ) ,
585587 } ) ;
586588
587- expect ( runtime . channel . inbound . dispatchReply ) . not . toHaveBeenCalled ( ) ;
589+ expect ( runtime . channel . inbound . dispatch ) . not . toHaveBeenCalled ( ) ;
588590 expect ( runtime . channel . reply . dispatchReplyWithBufferedBlockDispatcher ) . not . toHaveBeenCalled ( ) ;
589591 } ) ;
590592} ) ;
0 commit comments