diff --git a/packages/junior/src/chat/conversations/turn-lifecycle.ts b/packages/junior/src/chat/conversations/turn-lifecycle.ts index 31f3761df..1eb8e78d1 100644 --- a/packages/junior/src/chat/conversations/turn-lifecycle.ts +++ b/packages/junior/src/chat/conversations/turn-lifecycle.ts @@ -3,6 +3,7 @@ import type { ConversationTurnFailureCode, ConversationTurnFailureReason, } from "./history"; +import { getConversationEventStore } from "@/chat/db"; /** Product-owned inputs for opening one correlated conversation turn. */ export interface StartConversationTurnInput { @@ -92,3 +93,8 @@ export class ConversationTurnLifecycleService implements ConversationTurnLifecyc ]); } } + +/** Return the Turn lifecycle that records Conversation events. */ +export function getTurnLifecycle(): ConversationTurnLifecycle { + return new ConversationTurnLifecycleService(getConversationEventStore()); +} diff --git a/packages/junior/src/chat/providers/slack/resume.ts b/packages/junior/src/chat/providers/slack/resume.ts index 0e3a9b3f4..b11a6a9a0 100644 --- a/packages/junior/src/chat/providers/slack/resume.ts +++ b/packages/junior/src/chat/providers/slack/resume.ts @@ -36,11 +36,10 @@ import { requireTurnFailureEventId, } from "@/chat/services/turn-failure-response"; import { - ConversationTurnLifecycleService, + getTurnLifecycle, type ConversationTurnLifecycle, } from "@/chat/conversations/turn-lifecycle"; import type { ConversationTurnFailureCode } from "@/chat/conversations/history"; -import { getConversationEventStore } from "@/chat/db"; import { recordTurnSummary, saveTurnCheckpoint, @@ -457,9 +456,7 @@ async function resumeSlackTurnInContext( let assistantMessageDelivered = false; let shouldScheduleCompletedPluginTasks = false; let postDeliveryCommitError: unknown; - const turnLifecycle = new ConversationTurnLifecycleService( - getConversationEventStore(), - ); + const turnLifecycle = getTurnLifecycle(); let failureCode: ConversationTurnFailureCode = "agent_run_failed"; let runArgs = args; try {