package intent import ( "time" ) // IntentType 核心意图类别定义 type IntentType string const ( IntentQueryProgress IntentType = "QUERY_PROGRESS" // 查询进度、成熟度、风险研判或沟通话术 IntentSupplementInfo IntentType = "SUPPLEMENT_INFO" // 补充/修改材料、事实信息或参数 IntentAdvanceStage IntentType = "ADVANCE_STAGE" // 确认推进到下一成熟度阶段 (如 V0.1 -> V0.5) IntentTriggerTask IntentType = "TRIGGER_TASK" // 显式生成或重新执行特定交付物任务 (如 intake, quote) IntentCasualChat IntentType = "CASUAL_CHAT" // 问候、闲聊或通用帮助引导 IntentDeclineExpectation IntentType = "DECLINE_EXPECTATION" // 用户明确暂缓/不采纳上轮建议 (非阻塞放弃) // 法定文档治理流转 IntentDocGovClaim IntentType = "DOCGOV_CLAIM" IntentDocGovSubmitReview IntentType = "DOCGOV_SUBMIT_REVIEW" IntentDocGovReviewApprove IntentType = "DOCGOV_REVIEW_APPROVE" IntentDocGovReviewReject IntentType = "DOCGOV_REVIEW_REJECT" IntentDocGovFinalApprove IntentType = "DOCGOV_FINAL_APPROVE" IntentDocGovFinalReject IntentType = "DOCGOV_FINAL_REJECT" IntentDocGovProposalDecide IntentType = "DOCGOV_PROPOSAL_DECIDE" // 决策与合规查询 IntentQueryRegulations IntentType = "QUERY_REGULATIONS" IntentQuerySimilarCases IntentType = "QUERY_SIMILAR_CASES" IntentQueryUserRights IntentType = "QUERY_USER_RIGHTS" // 安全与权限红线拦截 IntentSecurityForbidden IntentType = "SECURITY_FORBIDDEN" ) // ResolutionBranch 三分支意图消解类别 type ResolutionBranch string const ( BranchExpectationHit ResolutionBranch = "EXPECTATION_HIT" // 分支 1: 命中历史轮次挂起预期 (肯定/选择/带补丁/取消) BranchNewIntentPreempt ResolutionBranch = "NEW_INTENT_PREEMPT" // 分支 2: 独立新意图抢占 (用户意图最高优先级) BranchAmbiguousFallback ResolutionBranch = "AMBIGUOUS_FALLBACK" // 分支 3: 模糊/无实际意义兜底 (参谋主动分析引导) ) // ExpectationOption 供用户挑选或单字快速兑现的具体选项 type ExpectationOption struct { OptionID string `json:"option_id"` // 选项代号 (如 "1", "2", "advance_v05") Title string `json:"title"` // 选项简述 (如 "推进到 V0.5 方案成型与法规对齐") Description string `json:"description,omitempty"` // 参谋为用户做的工作说明与收益分析 Intent IntentType `json:"intent"` // 对应绑定的业务意图 Slots map[string]string `json:"slots,omitempty"` // 预设槽位键值对 } // PendingExpectation 挂起预期草稿(非阻塞桌角备忘贴纸) type PendingExpectation struct { ExpectationID string `json:"expectation_id,omitempty"` ExpectedIntent IntentType `json:"expected_intent,omitempty"` TargetAction string `json:"target_action,omitempty"` Prompt string `json:"prompt,omitempty"` AffirmativeWord string `json:"affirmative_word,omitempty"` DeclineWord string `json:"decline_word,omitempty"` ExpiresAt time.Time `json:"expires_at,omitempty"` Payload map[string]string `json:"payload,omitempty"` ContextSnippet string `json:"context_snippet,omitempty"` // 上一轮建议的业务背景简述 DefaultOption *ExpectationOption `json:"default_option,omitempty"` // 参谋最推荐的基准选项(用户说“好/行”时默认执行) Options []ExpectationOption `json:"options,omitempty"` // 供用户挑选的备选选项列表 AllowAffirmative bool `json:"allow_affirmative"` // 是否允许用单字肯定(好/行/可以)触发 CreatedAt time.Time `json:"created_at"` // 挂起时间 } // CandidateIntent 候选意图提案(L1 对话层输出,由 L2 协调层终审) type CandidateIntent struct { Intent IntentType `json:"intent"` Confidence float64 `json:"confidence"` // 置信度 0.0 - 1.0 Branch ResolutionBranch `json:"branch"` // 归属的三分支判定 FilledSlots map[string]string `json:"filled_slots"` MissingSlots []string `json:"missing_slots,omitempty"` Reasoning string `json:"reasoning"` // 判断依据与文本佐证 ClarificationQuestion string `json:"clarification_question,omitempty"` // 槽位缺失时的澄清追问 MatchedOption *ExpectationOption `json:"matched_option,omitempty"` // 分支 1 命中的具体选项 PatchSlots map[string]string `json:"patch_slots,omitempty"` // 分支 1 复合输入的增量槽位补丁 IsDecline bool `json:"is_decline,omitempty"` // 是否为明确暂缓/放弃 } // IntentRecognitionResult 意图识别完整输出(多输出策略) type IntentRecognitionResult struct { RawInput string `json:"raw_input"` TopIntent *CandidateIntent `json:"top_intent"` Candidates []CandidateIntent `json:"candidates"` ContextSnapshotID string `json:"context_snapshot_id,omitempty"` RequiresClarifying bool `json:"requires_clarifying"` Branch ResolutionBranch `json:"branch"` // 顶层分支标记 } // 常见槽位 Key 常量定义 const ( SlotTargetStage = "target_stage" // 目标阶段 (如 V0.1_triage, V0.5_feasibility, V1.0_quoting) SlotTargetTask = "target_task" // 目标任务 (如 intake, research, cdo_quote) SlotFactKey = "fact_key" // 事实键 (如 target_market, device_type) SlotFactValue = "fact_value" // 事实值 SlotSupplementDoc = "supplement_doc" // 补充内容文本 SlotQueryTopic = "query_topic" // 查询主题 (如 progress, risk, talk_script, quotation) // 法定文档治理与权限槽位 SlotTargetDoc = "target_doc" SlotRejectReason = "reject_reason" SlotTargetSection = "target_section" SlotProposalAction = "proposal_action" SlotForbiddenTarget = "forbidden_target" ) // CardAction 交互卡片按钮动作 type CardAction struct { ActionID string `json:"action_id"` Label string `json:"label"` Style string `json:"style"` // primary, danger, subtle Payload map[string]string `json:"payload,omitempty"` IsAffirmativeDefault bool `json:"is_affirmative_default,omitempty"` } // InteractiveCardPayload 对话交互卡片载荷 type InteractiveCardPayload struct { CardID string `json:"card_id"` CardType string `json:"card_type"` // CONFIRMATION, SLOT_FILLING, DIFF_PROPOSAL, REMINDER_NOTICE Title string `json:"title"` TargetDocID string `json:"target_doc_id,omitempty"` TargetDocTitle string `json:"target_doc_title,omitempty"` TargetSectionID string `json:"target_section_id,omitempty"` SectionTitle string `json:"section_title,omitempty"` ProposedContent string `json:"proposed_content,omitempty"` ImpactRisk string `json:"impact_risk,omitempty"` CurrentStatus string `json:"current_status"` // active, executing, resolved, cancelled, outdated, expired TTLTurns int `json:"ttl_turns"` CreatedAt time.Time `json:"created_at"` Actions []CardAction `json:"actions,omitempty"` } // ContextSnapshot 传递给 L1 意图识别器的轻量上下文快照 type ContextSnapshot struct { SnapshotID string `json:"snapshot_id,omitempty"` ProjectName string `json:"project_name,omitempty"` CurrentStage string `json:"current_stage,omitempty"` ActiveDocID string `json:"active_doc_id,omitempty"` DocLifecycleState string `json:"doc_lifecycle_state,omitempty"` UserDocRole string `json:"user_doc_role,omitempty"` AvailableActions []string `json:"available_actions,omitempty"` PendingExpectation *PendingExpectation `json:"pending_expectation,omitempty"` }