@@ -12,9 +12,26 @@ import type { SessionEntry } from "../../config/sessions.js";
1212import { HEARTBEAT_RUN_SCOPE } from "../../infra/heartbeat-run-scope.js" ;
1313import { MESSAGE_TOOL_ONLY_DELIVERY_HINT } from "../../plugin-sdk/message-tool-delivery-hints.js" ;
1414import { normalizeSessionDeliveryState } from "../../utils/delivery-context.shared.js" ;
15+ import { runReplyAgent } from "./agent-runner.runtime.js" ;
16+ import { applySessionHints } from "./body.js" ;
17+ import {
18+ loadAgentRunnerRuntime ,
19+ loadEmbeddedAgentRuntime ,
20+ loadSessionUpdatesRuntime ,
21+ } from "./get-reply-run-helpers.js" ;
22+ import { runPreparedReply } from "./get-reply-run.js" ;
23+ import { buildDirectChatContext , buildGroupChatContext , buildGroupIntro } from "./groups.js" ;
1524import { finalizeInboundContextForSdk } from "./inbound-context.js" ;
16- import { createReplyOperation } from "./reply-run-registry.js" ;
25+ import {
26+ buildInboundUserContextPrefix ,
27+ resolveInboundUserContextPromptJoiner ,
28+ } from "./inbound-meta.js" ;
29+ import { createReplyOperation , getActiveReplyRunCount } from "./reply-run-registry.js" ;
30+ import { testing as replyRunTesting } from "./reply-run-registry.test-support.js" ;
31+ import { routeReply } from "./route-reply.runtime.js" ;
32+ import { drainFormattedSystemEvents } from "./session-system-events.js" ;
1733import { buildChannelSourceTurnId } from "./source-turn-id.js" ;
34+ import { resolveTypingMode } from "./typing-mode.js" ;
1835
1936vi . mock ( "../../agents/auth-profiles/session-override.js" , ( ) => ( {
2037 resolveSessionAuthProfileOverride : vi . fn ( ) . mockResolvedValue ( undefined ) ,
@@ -157,20 +174,6 @@ vi.mock("./typing-mode.js", () => ({
157174 resolveTypingMode : vi . fn ( ) . mockReturnValue ( "off" ) ,
158175} ) ) ;
159176
160- let runPreparedReply : typeof import ( "./get-reply-run.js" ) . runPreparedReply ;
161- let runReplyAgent : typeof import ( "./agent-runner.runtime.js" ) . runReplyAgent ;
162- let routeReply : typeof import ( "./route-reply.runtime.js" ) . routeReply ;
163- let drainFormattedSystemEvents : typeof import ( "./session-system-events.js" ) . drainFormattedSystemEvents ;
164- let applySessionHints : typeof import ( "./body.js" ) . applySessionHints ;
165- let resolveTypingMode : typeof import ( "./typing-mode.js" ) . resolveTypingMode ;
166- let buildDirectChatContext : typeof import ( "./groups.js" ) . buildDirectChatContext ;
167- let buildGroupIntro : typeof import ( "./groups.js" ) . buildGroupIntro ;
168- let buildGroupChatContext : typeof import ( "./groups.js" ) . buildGroupChatContext ;
169- let buildInboundUserContextPrefix : typeof import ( "./inbound-meta.js" ) . buildInboundUserContextPrefix ;
170- let resolveInboundUserContextPromptJoiner : typeof import ( "./inbound-meta.js" ) . resolveInboundUserContextPromptJoiner ;
171- let getActiveReplyRunCount : typeof import ( "./reply-run-registry.js" ) . getActiveReplyRunCount ;
172- let replyRunTesting : typeof import ( "./reply-run-registry.test-support.js" ) . testing ;
173-
174177function createGatewayDrainingError ( ) : Error {
175178 const error = new Error ( "Gateway is draining for restart; new tasks are not accepted" ) ;
176179 error . name = "GatewayDrainingError" ;
@@ -344,21 +347,13 @@ describe("runPreparedReply media-only handling", () => {
344347 const cleanupPaths : string [ ] = [ ] ;
345348
346349 beforeAll ( async ( ) => {
347- ( { runPreparedReply } = await import ( "./get-reply-run.js" ) ) ;
348- ( { runReplyAgent } = await import ( "./agent-runner.runtime.js" ) ) ;
349- ( { routeReply } = await import ( "./route-reply.runtime.js" ) ) ;
350- ( { drainFormattedSystemEvents } = await import ( "./session-system-events.js" ) ) ;
351- ( { applySessionHints } = await import ( "./body.js" ) ) ;
352- ( { resolveTypingMode } = await import ( "./typing-mode.js" ) ) ;
353- ( { buildDirectChatContext, buildGroupIntro, buildGroupChatContext } =
354- await import ( "./groups.js" ) ) ;
355- ( { buildInboundUserContextPrefix, resolveInboundUserContextPromptJoiner } =
356- await import ( "./inbound-meta.js" ) ) ;
357- ( { getActiveReplyRunCount } = await import ( "./reply-run-registry.js" ) ) ;
358- ( { testing : replyRunTesting } = await import ( "./reply-run-registry.test-support.js" ) ) ;
359-
360- // Load deferred reply dependencies before per-case timing starts.
361- await runPreparedReply ( baseParams ( ) ) ;
350+ // Preload the runtime seams directly so test setup does not need a synthetic
351+ // reply turn with registry and session side effects.
352+ await Promise . all ( [
353+ loadEmbeddedAgentRuntime ( ) ,
354+ loadAgentRunnerRuntime ( ) ,
355+ loadSessionUpdatesRuntime ( ) ,
356+ ] ) ;
362357 } ) ;
363358
364359 beforeEach ( async ( ) => {
0 commit comments