"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ROOT_EXACT_CAPABILITY_CONTRACTS = exports.INVENTORY_CAPABILITY_CONTRACTS = exports.ASSISTANT_TRANSITION_CONTRACTS = void 0; exports.listAssistantTransitionContracts = listAssistantTransitionContracts; exports.getAssistantTransitionContract = getAssistantTransitionContract; exports.listInventoryCapabilityContracts = listInventoryCapabilityContracts; exports.getAssistantCapabilityContract = getAssistantCapabilityContract; exports.getAssistantCapabilityContractByIntent = getAssistantCapabilityContractByIntent; const assistantRuntimeContracts_1 = require("../types/assistantRuntimeContracts"); exports.ASSISTANT_TRANSITION_CONTRACTS = [ { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T1", title: "Root Query Entry", trigger_class: "new_root_business_question", required_prior_state: ["living_mode_state"], allowed_carryover_depth: "none", state_mutations: ["create_root_frame_state", "clear_selected_object_frame_state", "create_coverage_gate_state"], forbidden_carryover: ["stale_focus_object", "stale_object_intent"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T2", title: "Root Follow-Up With Date Or Scope Change", trigger_class: "root_followup_temporal_or_organization_shift", required_prior_state: ["root_frame_state"], allowed_carryover_depth: "root_only", state_mutations: ["update_root_frame_state", "run_exact_route", "refresh_coverage_gate_state"], forbidden_carryover: ["incompatible_selected_object_route"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T3", title: "Explicit Selected Object Drilldown", trigger_class: "explicit_selected_object_or_ui_object_selection", required_prior_state: ["root_frame_state"], allowed_carryover_depth: "object_only", state_mutations: ["create_selected_object_frame_state", "bind_source_result_set", "preserve_temporal_ceiling"], forbidden_carryover: ["unrelated_prior_focus_object"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T4", title: "Short Action Follow-Up On Selected Object", trigger_class: "short_action_followup_on_active_focus_object", required_prior_state: ["selected_object_frame_state"], allowed_carryover_depth: "object_only", state_mutations: ["reuse_selected_object_frame_state", "route_to_compatible_item_action"], forbidden_carryover: ["generic_chat_fallback", "data_scope_selection_fallback", "object_focus_reset"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T5", title: "Pronoun Or Compressed Object Follow-Up", trigger_class: "pronoun_or_compressed_reference_to_active_focus_object", required_prior_state: ["selected_object_frame_state"], allowed_carryover_depth: "object_only", state_mutations: ["reuse_selected_object_frame_state", "resolve_pronoun_to_focus_object"], forbidden_carryover: ["low_quality_object_rewrite", "semantic_noise_as_anchor"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T6", title: "Domain Pivot With Root-Only Carryover", trigger_class: "supported_domain_pivot_from_active_drilldown", required_prior_state: ["root_frame_state", "selected_object_frame_state"], allowed_carryover_depth: "root_only", state_mutations: ["preserve_root_frame_state", "drop_selected_object_frame_state"], forbidden_carryover: ["object_route_replay_into_new_domain"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T7", title: "Clarification Continuation", trigger_class: "user_resolves_missing_anchor_or_scope", required_prior_state: ["clarification_state"], allowed_carryover_depth: "full", state_mutations: ["resume_target_route", "update_or_clear_clarification_state"], forbidden_carryover: ["forget_suspended_route"], expected_answer_mode: "confirmed" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T8", title: "Meta Follow-Up Over Answer Object", trigger_class: "evaluation_comparison_or_interpretation_of_previous_answer", required_prior_state: ["answer_context_state", "coverage_gate_state"], allowed_carryover_depth: "meta_only", state_mutations: ["create_meta_frame_state", "reuse_answer_object_without_blind_replay"], forbidden_carryover: ["blind_exact_route_replay"], expected_answer_mode: "meta" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T9", title: "Memory Recap", trigger_class: "conversation_memory_recap_request", required_prior_state: ["answer_context_state"], allowed_carryover_depth: "meta_only", state_mutations: ["reuse_grounded_prior_answer_context"], forbidden_carryover: ["invented_conversation_memory"], expected_answer_mode: "recap" }, { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, transition_id: "T10", title: "Unsupported Or Blocked Boundary", trigger_class: "unsupported_route_or_blocked_evidence_gate", required_prior_state: ["coverage_gate_state"], allowed_carryover_depth: "none", state_mutations: ["emit_bounded_boundary_or_clarification"], forbidden_carryover: ["blocked_as_confirmed_factual_answer"], expected_answer_mode: "boundary" } ]; const SHARED_INVENTORY_ACCEPTANCE_FAMILIES = [ "canonical", "colloquial", "ui_selected_object", "ui_selected_object_colloquial", "short_action_followup", "pronoun_followup", "followup_date_carryover" ]; const INVENTORY_ITEM_ANCHOR_RULES = [ "no_low_quality_item_rewrite", "no_numeric_tail_account_poisoning", "no_conversational_noise_as_entity", "confirmed_focus_object_beats_semantic_hint" ]; const INVENTORY_SELECTED_OBJECT_TESTS = [ "selected_object_memory_survives_short_followup", "new_explicit_selected_object_overrides_old_focus", "full_anchor_not_degraded_by_canonical_rewrite" ]; const SHARED_ROOT_EXACT_TESTS = [ "root_context_survives_domain_pivot_without_object_leak", "limited_mode_remains_truthful" ]; function rootExactCapability(input) { return { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, capability_id: input.capability_id, domain_id: input.domainId, runtime_lane: "address_exact", intent_ids: input.intent_ids, entry_modes: ["root_entry", "root_followup", "clarification_resume"], supported_transition_classes: input.transitions, frame_compatibility: { root_frame: "optional", selected_object_frame: "optional", meta_frame: "forbidden" }, required_anchors: input.requiredAnchors, optional_anchors: input.optionalAnchors ?? ["organization", "date_scope", "account", "counterparty", "contract"], anchor_source_priority: ["explicit_user_anchor", "root_frame", "semantic_hint"], anchor_admissibility_rules: [ "confirmed_root_scope_beats_semantic_hint", "no_low_quality_counterparty_rewrite", "no_conversational_noise_as_entity" ], organization_scope_behavior: "reuse_or_clarify", date_scope_behavior: "reuse", temporal_ceiling_policy: "must_not_expand_without_reason_code", root_context_compatibility: "required", requires_focus_object: false, accepted_focus_object_kinds: [], focus_object_override_policy: "not_applicable", bundle_reuse_policy: "none", resolver_owner: "addressIntentResolver", recipe_owner: "addressRecipeCatalog", execution_adapter: "AddressQueryService", result_shape: input.resultShape, answer_object_shape: input.answerObjectShape, minimum_evidence_policy: "route_specific_threshold", coverage_gate_behavior: "partial_or_blocked_if_evidence_insufficient", truth_mode_fallbacks: ["limited", "clarification_required", "unsupported"], blocked_reason_codes: ["missing_anchor", "route_expectation_failure", "execution_error", "insufficient_evidence"], clarification_triggers: ["ambiguous_organization_scope", "ambiguous_date_scope"], clarification_questions: ["Уточните организацию, счёт или дату, чтобы не подставлять неподтверждённый контур."], resume_policy: "resume_original_route_with_resolved_anchors", empty_match_behavior: "truthful_empty_match", route_expectation_failure_behavior: "blocked_route_expectation_failure", execution_error_behavior: "blocked_execution_error", required_unit_tests: [...SHARED_ROOT_EXACT_TESTS], required_transition_tests: input.transitions.map((transitionId) => `transition_${transitionId}`), required_scenario_families: input.scenarioFamilies ?? ["canonical", "colloquial", "followup_date_carryover"] }; } function inventoryExactCapability(input) { return { schema_version: assistantRuntimeContracts_1.ASSISTANT_RUNTIME_CONTRACTS_SCHEMA_VERSION, capability_id: input.capability_id, domain_id: "inventory_stock", runtime_lane: "address_exact", intent_ids: input.intent_ids, entry_modes: input.entry_modes, supported_transition_classes: input.transitions, frame_compatibility: { root_frame: input.entry_modes.includes("root_entry") ? "optional" : "required", selected_object_frame: input.requiresFocusObject ? "required" : "optional", meta_frame: "forbidden" }, required_anchors: input.requiredAnchors, optional_anchors: ["organization", "warehouse", "date_scope"], anchor_source_priority: ["explicit_user_anchor", "ui_selected_object", "selected_object_frame", "root_frame", "semantic_hint"], anchor_admissibility_rules: [...INVENTORY_ITEM_ANCHOR_RULES], organization_scope_behavior: "reuse_or_clarify", date_scope_behavior: "reuse", temporal_ceiling_policy: input.requiresFocusObject ? "respect_root_temporal_ceiling" : "must_not_expand_without_reason_code", root_context_compatibility: "required", requires_focus_object: input.requiresFocusObject, accepted_focus_object_kinds: input.requiresFocusObject ? ["inventory_item", "item"] : [], focus_object_override_policy: input.requiresFocusObject ? "explicit_new_object_wins" : "not_applicable", bundle_reuse_policy: input.bundleReusePolicy, resolver_owner: "addressIntentResolver", recipe_owner: "addressRecipeCatalog", execution_adapter: "AddressQueryService", result_shape: input.resultShape, answer_object_shape: input.answerObjectShape, minimum_evidence_policy: "route_specific_threshold", coverage_gate_behavior: "partial_or_blocked_if_evidence_insufficient", truth_mode_fallbacks: ["limited", "clarification_required", "unsupported"], blocked_reason_codes: ["missing_anchor", "route_expectation_failure", "execution_error", "insufficient_evidence"], clarification_triggers: ["missing_required_item_anchor", "ambiguous_organization_scope", "ambiguous_date_scope"], clarification_questions: ["Уточните товар, организацию или дату, чтобы не подставлять неподтвержденный anchor."], resume_policy: "resume_original_route_with_resolved_anchors", empty_match_behavior: "truthful_empty_match", route_expectation_failure_behavior: "blocked_route_expectation_failure", execution_error_behavior: "blocked_execution_error", required_unit_tests: input.requiresFocusObject ? [...INVENTORY_SELECTED_OBJECT_TESTS, "limited_mode_remains_truthful"] : ["root_context_survives_domain_pivot_without_object_leak", "limited_mode_remains_truthful"], required_transition_tests: input.transitions.map((transitionId) => `transition_${transitionId}`), required_scenario_families: input.scenarioFamilies ?? [...SHARED_INVENTORY_ACCEPTANCE_FAMILIES] }; } exports.INVENTORY_CAPABILITY_CONTRACTS = [ inventoryExactCapability({ capability_id: "confirmed_inventory_on_hand_as_of_date", intent_ids: ["inventory_on_hand_as_of_date"], entry_modes: ["root_entry", "root_followup", "clarification_resume"], transitions: ["T1", "T2", "T6", "T7"], requiresFocusObject: false, requiredAnchors: [], resultShape: "item_list_with_quantity_cost_warehouse_organization", answerObjectShape: "inventory_stock_snapshot", bundleReusePolicy: "none", scenarioFamilies: ["canonical", "colloquial", "followup_date_carryover"] }), inventoryExactCapability({ capability_id: "inventory_inventory_purchase_provenance_for_item", intent_ids: ["inventory_purchase_provenance_for_item"], entry_modes: ["selected_object_drilldown", "clarification_resume"], transitions: ["T3", "T4", "T5", "T7"], requiresFocusObject: true, requiredAnchors: ["item"], resultShape: "supplier_purchase_provenance_trace", answerObjectShape: "inventory_provenance_bundle", bundleReusePolicy: "provenance_bundle_preferred" }), inventoryExactCapability({ capability_id: "inventory_inventory_purchase_documents_for_item", intent_ids: ["inventory_purchase_documents_for_item"], entry_modes: ["selected_object_drilldown", "clarification_resume"], transitions: ["T3", "T4", "T5", "T7"], requiresFocusObject: true, requiredAnchors: ["item"], resultShape: "purchase_document_list_for_selected_item", answerObjectShape: "inventory_purchase_documents_bundle", bundleReusePolicy: "provenance_bundle_preferred" }), inventoryExactCapability({ capability_id: "inventory_inventory_supplier_stock_overlap_as_of_date", intent_ids: ["inventory_supplier_stock_overlap_as_of_date"], entry_modes: ["root_entry", "root_followup", "clarification_resume"], transitions: ["T1", "T2", "T7"], requiresFocusObject: false, requiredAnchors: ["supplier"], resultShape: "supplier_to_stock_item_overlap", answerObjectShape: "inventory_supplier_overlap", bundleReusePolicy: "none", scenarioFamilies: ["canonical", "colloquial", "followup_date_carryover"] }), inventoryExactCapability({ capability_id: "inventory_inventory_sale_trace_for_item", intent_ids: ["inventory_sale_trace_for_item"], entry_modes: ["selected_object_drilldown", "clarification_resume"], transitions: ["T3", "T4", "T5", "T7"], requiresFocusObject: true, requiredAnchors: ["item"], resultShape: "buyer_sale_trace_for_selected_item", answerObjectShape: "inventory_sale_trace_bundle", bundleReusePolicy: "sale_trace_bundle_preferred" }), inventoryExactCapability({ capability_id: "inventory_inventory_purchase_to_sale_chain", intent_ids: ["inventory_purchase_to_sale_chain"], entry_modes: ["selected_object_drilldown", "clarification_resume"], transitions: ["T3", "T4", "T5", "T7"], requiresFocusObject: true, requiredAnchors: ["item"], resultShape: "purchase_stock_sale_document_chain", answerObjectShape: "inventory_purchase_to_sale_chain", bundleReusePolicy: "sale_trace_bundle_preferred" }), inventoryExactCapability({ capability_id: "inventory_inventory_aging_by_purchase_date", intent_ids: ["inventory_aging_by_purchase_date"], entry_modes: ["root_entry", "root_followup", "clarification_resume"], transitions: ["T1", "T2", "T6", "T7"], requiresFocusObject: false, requiredAnchors: [], resultShape: "oldest_first_inventory_aging_list", answerObjectShape: "inventory_aging_snapshot", bundleReusePolicy: "none", scenarioFamilies: ["canonical", "colloquial", "followup_date_carryover"] }) ]; exports.ROOT_EXACT_CAPABILITY_CONTRACTS = [ rootExactCapability({ capability_id: "documents_drilldown", domainId: "counterparty_documents", intent_ids: ["list_documents_by_counterparty", "list_documents_by_contract"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], optionalAnchors: ["organization", "date_scope", "counterparty", "contract", "document_type"], resultShape: "counterparty_or_contract_document_list", answerObjectShape: "documents_drilldown_list", scenarioFamilies: ["canonical", "colloquial", "short_counterparty_retarget", "followup_date_carryover"] }), rootExactCapability({ capability_id: "address_customer_revenue_and_payments", domainId: "counterparty_revenue", intent_ids: ["customer_revenue_and_payments"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], optionalAnchors: ["organization", "date_scope", "counterparty", "contract"], resultShape: "counterparty_revenue_payment_flow", answerObjectShape: "counterparty_revenue_summary", scenarioFamilies: ["canonical", "colloquial", "short_counterparty_retarget", "answer_top_block_matches_current_user_intent"] }), rootExactCapability({ capability_id: "address_supplier_payouts_profile", domainId: "counterparty_payouts", intent_ids: ["supplier_payouts_profile"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], optionalAnchors: ["organization", "date_scope", "counterparty", "contract"], resultShape: "supplier_payout_payment_flow", answerObjectShape: "supplier_payout_summary", scenarioFamilies: ["canonical", "colloquial", "short_counterparty_retarget"] }), rootExactCapability({ capability_id: "confirmed_payables_as_of_date", domainId: "counterparty_debt", intent_ids: ["payables_confirmed_as_of_date"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], resultShape: "counterparty_payables_snapshot", answerObjectShape: "payables_snapshot" }), rootExactCapability({ capability_id: "confirmed_receivables_as_of_date", domainId: "counterparty_debt", intent_ids: ["receivables_confirmed_as_of_date"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], resultShape: "counterparty_receivables_snapshot", answerObjectShape: "receivables_snapshot" }), rootExactCapability({ capability_id: "confirmed_open_contracts_as_of_date", domainId: "contracts", intent_ids: ["open_contracts_confirmed_as_of_date"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], resultShape: "open_contracts_snapshot", answerObjectShape: "open_contracts_snapshot" }), rootExactCapability({ capability_id: "confirmed_vat_payable_as_of_date", domainId: "vat", intent_ids: ["vat_payable_confirmed_as_of_date"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], resultShape: "vat_payable_snapshot", answerObjectShape: "vat_payable_snapshot" }), rootExactCapability({ capability_id: "confirmed_vat_liability_for_tax_period", domainId: "vat", intent_ids: ["vat_liability_confirmed_for_tax_period"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: [], resultShape: "vat_tax_period_liability_snapshot", answerObjectShape: "vat_tax_period_liability_snapshot", scenarioFamilies: ["canonical", "colloquial", "followup_date_carryover", "tax_period_followup"] }), rootExactCapability({ capability_id: "account_balance_exact", domainId: "accounting_balance", intent_ids: ["account_balance_snapshot", "documents_forming_balance"], transitions: ["T1", "T2", "T6", "T7"], requiredAnchors: ["account"], optionalAnchors: ["organization", "date_scope", "account"], resultShape: "account_balance_snapshot_or_supporting_documents", answerObjectShape: "account_balance_context", scenarioFamilies: ["canonical", "colloquial", "followup_date_carryover", "same_date_account_followup"] }) ]; const ALL_CAPABILITY_CONTRACTS = [ ...exports.INVENTORY_CAPABILITY_CONTRACTS, ...exports.ROOT_EXACT_CAPABILITY_CONTRACTS ]; function listAssistantTransitionContracts() { return exports.ASSISTANT_TRANSITION_CONTRACTS; } function getAssistantTransitionContract(transitionId) { return exports.ASSISTANT_TRANSITION_CONTRACTS.find((contract) => contract.transition_id === transitionId) ?? null; } function listInventoryCapabilityContracts() { return exports.INVENTORY_CAPABILITY_CONTRACTS; } function getAssistantCapabilityContract(capabilityId) { return ALL_CAPABILITY_CONTRACTS.find((contract) => contract.capability_id === capabilityId) ?? null; } function getAssistantCapabilityContractByIntent(intent) { return ALL_CAPABILITY_CONTRACTS.find((contract) => contract.intent_ids.includes(intent)) ?? null; }