import type { AssistantReplyType, AssistantRequirement, AnswerGroundingCheck, RequirementCoverageReport, UnifiedRetrievalResult } from "../types/assistant"; import type { NormalizeResponsePayload, RouteHintSummary } from "../types/normalizer"; import type { AnswerStructureV11 } from "../types/stage1Contracts"; import type { AssistantDeepTurnPackagingInput } from "./assistantDeepTurnPackaging"; export interface AssistantDeepTurnInputBuilderArgs { sessionId: string; messageId: string; userMessage: string; normalized: { trace_id: string; prompt_version: string; schema_version: string; normalized: NormalizeResponsePayload["normalized"]; }; normalizedQuestion: string; routeSummary: RouteHintSummary | null; droppedIntentSegments: string[]; analysisContextForContract: { as_of_date: string | null; period_from: string | null; period_to: string | null; source: string | null; snapshot_mode: "auto" | "force_snapshot" | "force_live"; } | null; executionPlan: Array<{ fragment_id: string; requirement_ids: string[]; route: string; should_execute: boolean; no_route_reason?: string | null; clarification_reason?: string | null; }>; requirementExtractionRequirements: AssistantRequirement[]; coverageEvaluationRequirements: AssistantRequirement[]; coverageReport: RequirementCoverageReport; groundingCheck: AnswerGroundingCheck; retrievalCalls: Array>; retrievalResultsRaw: unknown[]; retrievalResults: UnifiedRetrievalResult[]; routesForDebug: Array>; resolvedExecutionState: unknown; questionTypeClass: string; companyAnchors: unknown; runtimeAnalysisContext: { active: boolean; as_of_date: string | null; period_from: string | null; period_to: string | null; source: string | null; snapshot_mode: "auto" | "force_snapshot" | "force_live"; }; businessScopeResolution: { business_scope_raw?: string[]; business_scope_resolved?: string[]; company_grounding_applied?: boolean; scope_resolution_reason?: string[]; }; temporalGuard: Record; polarityAudit: Record; claimAnchorAudit: Record; targetedEvidenceAudit: unknown; evidenceAdmissibilityGateAudit: unknown; rbpLiveRouteAudit: unknown | null; faLiveRouteAudit: unknown | null; groundedAnswerEligibilityGuard: Record; followupStateUsage?: unknown; composition: { reply_type: AssistantReplyType; fallback_type: unknown; answer_structure_v11?: AnswerStructureV11 | null; problem_centric_answer_applied?: boolean; problem_units_used_count?: number; problem_answer_mode?: string; problem_unit_ids_used?: unknown; }; safeAssistantReplyBase: string; featureContractsV11: boolean; featureAnswerPolicyV11: boolean; investigationStateSnapshot: unknown; addressRuntimeMetaForDeep: | { attempted?: boolean; applied?: boolean; reason?: string | null; provider?: string | null; fallbackRuleHit?: string | null; toolGateDecision?: string | null; toolGateReason?: string | null; predecomposeContract?: unknown; orchestrationContract?: unknown; } | null | undefined; } export function buildAssistantDeepTurnPackagingInput(args: AssistantDeepTurnInputBuilderArgs): AssistantDeepTurnPackagingInput { return { ...args, routesForDebug: Array.isArray(args.routesForDebug) ? args.routesForDebug : [], followupStateUsage: args.followupStateUsage ?? null, composition: { reply_type: args.composition.reply_type, fallback_type: args.composition.fallback_type, answer_structure_v11: args.composition.answer_structure_v11 ?? null, problem_centric_answer_applied: args.composition.problem_centric_answer_applied ?? false, problem_units_used_count: args.composition.problem_units_used_count ?? 0, problem_answer_mode: args.composition.problem_answer_mode ?? "stage1_policy_v11", problem_unit_ids_used: Array.isArray(args.composition.problem_unit_ids_used) ? args.composition.problem_unit_ids_used : [] } }; }