ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.42: вынос finalizeAddressLaneResponse из assistantService в отдельный attempt-bridge (как для living chat), для уменьшения монолита без изменения поведения.

This commit is contained in:
2026-04-10 23:27:37 +03:00
parent fbf2d6a19a
commit 875f3bfbcd
6 changed files with 211 additions and 31 deletions
@@ -0,0 +1,45 @@
import type { AssistantMessageResponsePayload } from "../types/assistant";
import {
runAssistantAddressLaneResponseRuntime,
type RunAssistantAddressLaneResponseRuntimeInput,
type RunAssistantAddressLaneResponseRuntimeOutput
} from "./assistantAddressLaneResponseRuntimeAdapter";
export interface RunAssistantAddressLaneResponseAttemptRuntimeInput<
ResponseType = AssistantMessageResponsePayload
> extends RunAssistantAddressLaneResponseRuntimeInput<ResponseType> {
runAddressLaneResponseRuntime?: (
input: RunAssistantAddressLaneResponseRuntimeInput<ResponseType>
) => RunAssistantAddressLaneResponseRuntimeOutput<ResponseType>;
}
export function runAssistantAddressLaneResponseAttemptRuntime<
ResponseType = AssistantMessageResponsePayload
>(
input: RunAssistantAddressLaneResponseAttemptRuntimeInput<ResponseType>
): ResponseType {
const runAddressLaneResponseRuntimeSafe =
input.runAddressLaneResponseRuntime ?? runAssistantAddressLaneResponseRuntime;
const runtime = runAddressLaneResponseRuntimeSafe({
sessionId: input.sessionId,
userMessage: input.userMessage,
effectiveAddressUserMessage: input.effectiveAddressUserMessage,
addressLane: input.addressLane,
carryoverMeta: input.carryoverMeta,
llmPreDecomposeMeta: input.llmPreDecomposeMeta,
knownOrganizations: input.knownOrganizations,
activeOrganization: input.activeOrganization,
sanitizeOutgoingAssistantText: input.sanitizeOutgoingAssistantText,
buildAddressDebugPayload: input.buildAddressDebugPayload,
buildAddressFollowupOffer: input.buildAddressFollowupOffer,
mergeKnownOrganizations: input.mergeKnownOrganizations,
toNonEmptyString: input.toNonEmptyString,
appendItem: input.appendItem,
getSession: input.getSession,
persistSession: input.persistSession,
cloneConversation: input.cloneConversation,
logEvent: input.logEvent,
messageIdFactory: input.messageIdFactory
});
return runtime.response;
}