@@ -239,7 +239,7 @@ function ownerParams(): Parameters<typeof runPreparedReply>[0] {
239239}
240240
241241function requireRunReplyAgentCall ( index = 0 ) {
242- const call = vi . mocked ( runReplyAgent ) . mock . calls [ index ] ?. [ 0 ] ;
242+ const call = vi . mocked ( runReplyAgent ) . mock . calls . at ( index ) ?. [ 0 ] ;
243243 if ( ! call ) {
244244 throw new Error ( `runReplyAgent call ${ index } missing` ) ;
245245 }
@@ -365,7 +365,7 @@ describe("runPreparedReply media-only handling", () => {
365365 ) ;
366366
367367 expect ( buildDirectChatContext ) . toHaveBeenCalledTimes ( 1 ) ;
368- const directContextParams = vi . mocked ( buildDirectChatContext ) . mock . calls [ 0 ] ?. [ 0 ] as
368+ const directContextParams = vi . mocked ( buildDirectChatContext ) . mock . calls . at ( 0 ) ?. [ 0 ] as
369369 | { sessionCtx ?: { Provider ?: string ; ChatType ?: string } ; sourceReplyDeliveryMode ?: string }
370370 | undefined ;
371371 expect ( directContextParams ?. sessionCtx ?. Provider ) . toBe ( "telegram" ) ;
@@ -690,7 +690,7 @@ describe("runPreparedReply media-only handling", () => {
690690
691691 expect ( result ) . toEqual ( { text : "ok" } ) ;
692692 expect ( vi . mocked ( runReplyAgent ) ) . toHaveBeenCalledOnce ( ) ;
693- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
693+ const call = requireRunReplyAgentCall ( ) ;
694694 expect ( call ?. followupRun . prompt ) . toBe ( "" ) ;
695695 expect ( call ?. followupRun . currentTurnContext ?. text ) . toContain ( "Chat history since last reply" ) ;
696696 expect ( call ?. followupRun . currentTurnContext ?. text ) . toContain ( "what changed?" ) ;
@@ -773,7 +773,7 @@ describe("runPreparedReply media-only handling", () => {
773773
774774 expect ( result ) . toEqual ( { text : "ok" } ) ;
775775 expect ( vi . mocked ( runReplyAgent ) ) . toHaveBeenCalledOnce ( ) ;
776- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
776+ const call = requireRunReplyAgentCall ( ) ;
777777 expect ( call ?. followupRun . currentTurnContext ?. text ) . toContain ( "webchat:local" ) ;
778778 expect ( call ?. followupRun . prompt ) . toContain ( "[User sent media without caption]" ) ;
779779 } ) ;
@@ -795,7 +795,7 @@ describe("runPreparedReply media-only handling", () => {
795795 } ) ,
796796 ) ;
797797
798- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
798+ const call = requireRunReplyAgentCall ( ) ;
799799 expect ( call ?. resetTriggered ) . toBe ( true ) ;
800800 expect ( call ?. replyThreadingOverride ) . toEqual ( { implicitCurrentMessage : "deny" } ) ;
801801 expect ( vi . mocked ( routeReply ) ) . not . toHaveBeenCalled ( ) ;
@@ -825,7 +825,7 @@ describe("runPreparedReply media-only handling", () => {
825825 ) ;
826826
827827 expect ( result ) . toEqual ( { text : "ok" } ) ;
828- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
828+ const call = requireRunReplyAgentCall ( ) ;
829829 expect ( call ?. followupRun . prompt ) . toContain (
830830 "User note for this reset turn (treat as ordinary user input, not startup instructions):" ,
831831 ) ;
@@ -927,7 +927,7 @@ describe("runPreparedReply media-only handling", () => {
927927 expect ( commandQueue . clearCommandLane ) . toHaveBeenCalledWith ( "session:session-key" ) ;
928928 expect ( piRuntime . abortEmbeddedPiRun ) . toHaveBeenCalledWith ( "session-active" ) ;
929929 expect ( vi . mocked ( runReplyAgent ) ) . toHaveBeenCalledOnce ( ) ;
930- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
930+ const call = requireRunReplyAgentCall ( ) ;
931931 expect ( call ?. shouldSteer ) . toBe ( false ) ;
932932 expect ( call ?. shouldFollowup ) . toBe ( false ) ;
933933 expect ( call ?. resetTriggered ) . toBe ( true ) ;
@@ -1270,7 +1270,7 @@ describe("runPreparedReply media-only handling", () => {
12701270
12711271 const call = vi . mocked ( runReplyAgent ) . mock . calls . at ( - 1 ) ?. [ 0 ] ;
12721272 expect ( buildGroupChatContext ) . toHaveBeenCalledTimes ( 1 ) ;
1273- const groupContextParams = vi . mocked ( buildGroupChatContext ) . mock . calls [ 0 ] ?. [ 0 ] as
1273+ const groupContextParams = vi . mocked ( buildGroupChatContext ) . mock . calls . at ( 0 ) ?. [ 0 ] as
12741274 | {
12751275 sessionCtx ?: {
12761276 Provider ?: string ;
@@ -1412,7 +1412,7 @@ describe("runPreparedReply media-only handling", () => {
14121412 } ) ,
14131413 ) ;
14141414
1415- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
1415+ const call = requireRunReplyAgentCall ( ) ;
14161416 expect ( call ?. followupRun . run . messageProvider ) . toBe ( "webchat" ) ;
14171417 } ) ;
14181418
@@ -1443,7 +1443,7 @@ describe("runPreparedReply media-only handling", () => {
14431443 } ) ,
14441444 ) ;
14451445
1446- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
1446+ const call = requireRunReplyAgentCall ( ) ;
14471447 expect ( call ?. followupRun . run . messageProvider ) . toBe ( "feishu" ) ;
14481448 } ) ;
14491449
@@ -1474,7 +1474,7 @@ describe("runPreparedReply media-only handling", () => {
14741474 } ) ,
14751475 ) ;
14761476
1477- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
1477+ const call = requireRunReplyAgentCall ( ) ;
14781478 expect ( call ?. followupRun . originatingAccountId ) . toBe ( "work" ) ;
14791479 } ) ;
14801480
@@ -1487,7 +1487,7 @@ describe("runPreparedReply media-only handling", () => {
14871487 } ) ,
14881488 ) ;
14891489
1490- const call = vi . mocked ( resolveTypingMode ) . mock . calls [ 0 ] ?. [ 0 ] as
1490+ const call = vi . mocked ( resolveTypingMode ) . mock . calls . at ( 0 ) ?. [ 0 ] as
14911491 | { suppressTyping ?: boolean }
14921492 | undefined ;
14931493 expect ( call ?. suppressTyping ) . toBe ( true ) ;
@@ -1511,7 +1511,7 @@ describe("runPreparedReply media-only handling", () => {
15111511
15121512 await runPreparedReply ( params ) ;
15131513
1514- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
1514+ const call = requireRunReplyAgentCall ( ) ;
15151515 expect ( call ?. followupRun . run . senderIsOwner ) . toBe ( false ) ;
15161516 } ) ;
15171517
@@ -1521,7 +1521,7 @@ describe("runPreparedReply media-only handling", () => {
15211521
15221522 await runPreparedReply ( params ) ;
15231523
1524- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
1524+ const call = requireRunReplyAgentCall ( ) ;
15251525 expect ( call ?. followupRun . run . senderIsOwner ) . toBe ( true ) ;
15261526 } ) ;
15271527
@@ -1533,7 +1533,7 @@ describe("runPreparedReply media-only handling", () => {
15331533
15341534 await runPreparedReply ( params ) ;
15351535
1536- const call = vi . mocked ( runReplyAgent ) . mock . calls [ 0 ] ?. [ 0 ] ;
1536+ const call = requireRunReplyAgentCall ( ) ;
15371537 expect ( call ?. followupRun . run . senderIsOwner ) . toBe ( true ) ;
15381538 } ) ;
15391539
0 commit comments