ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.40: вынос runAddressLaneAttempt (с merge контекста и вызовом addressQueryService) в отдельный runtime-адаптер из handleMessage

This commit is contained in:
2026-04-10 23:15:08 +03:00
parent 5520dbccbc
commit bac6ebe701
6 changed files with 158 additions and 25 deletions
@@ -0,0 +1,42 @@
import type { AssistantAddressLaneLike } from "./assistantAddressLaneRuntimeAdapter";
import type { AssistantAddressCarryoverLike } from "./assistantAddressOrchestrationRuntimeAdapter";
export interface RunAssistantAddressLaneAttemptRuntimeInput {
messageUsed: string;
carryMeta: AssistantAddressCarryoverLike | null;
analysisDateHint: string | null;
activeOrganization: string | null;
mergeFollowupContextWithOrganizationScope: (
followupContext: Record<string, unknown> | null,
organization: string | null
) => Record<string, unknown> | null;
runAddressQueryTryHandle: (
messageUsed: string,
options: {
followupContext?: Record<string, unknown>;
analysisDateHint?: string | null;
}
) => Promise<AssistantAddressLaneLike | null>;
}
export async function runAssistantAddressLaneAttemptRuntime(
input: RunAssistantAddressLaneAttemptRuntimeInput
): Promise<AssistantAddressLaneLike | null> {
const followupContext =
input.carryMeta?.followupContext && typeof input.carryMeta.followupContext === "object"
? (input.carryMeta.followupContext as Record<string, unknown>)
: null;
const scopedFollowupContext = input.mergeFollowupContextWithOrganizationScope(
followupContext,
input.activeOrganization
);
if (scopedFollowupContext) {
return input.runAddressQueryTryHandle(input.messageUsed, {
followupContext: scopedFollowupContext,
analysisDateHint: input.analysisDateHint
});
}
return input.runAddressQueryTryHandle(input.messageUsed, {
analysisDateHint: input.analysisDateHint
});
}