feat: BossAi v2.0 UI/UX 重构 + 看板断点续接 + 多轮上下文
- 新增 web2/ 前端:任务卡看板、风险雷达、决策日志、我的团队、快捷指令 - ChatPanel 增强:风险卡置顶、案卡接入、起诉状向导、语音输入 - 事项看板:点击查看详情弹窗、断点续接(恢复历史对话+matterId) - 保密模式恢复:密码验证后重建内存 session,保留多轮上下文 - 多轮对话:ask/ask-stream/ask-analyze 注入 session 历史,AI 有上下文 - 追问优化:紧扣用户问题,不再偏离主题(社保问社保,工伤问工伤) - 对话区可滚动,输入区固定可见 - 状态机放宽:允许从任意非终态转到 pending_expert - session 存活检查端点,后端重启后自动重建 session - DB migration:风险推送表、案卡表 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,279 @@
|
||||
/** BossAi 2.0 类型定义
|
||||
* 在 v1.0 基础上扩展案卡(Matter)、风险推送(RiskAlert)、专家关系(ExpertRelation)
|
||||
*/
|
||||
|
||||
/** 风险等级 */
|
||||
export type RiskLevel = 'green' | 'amber' | 'orange' | 'red'
|
||||
|
||||
/** 隐私会话模式 */
|
||||
export type SessionMode = 'normal' | 'confidential' | 'ephemeral'
|
||||
|
||||
/** 业务场景 */
|
||||
export type Scene = 'legal' | 'decision' | 'life' | 'emotion'
|
||||
|
||||
/** 情绪模式 */
|
||||
export type EmotionMode = 'calm' | 'companion' | 'push'
|
||||
|
||||
/** 案卡状态 */
|
||||
export type MatterStatus = 'new' | 'asking_facts' | 'pending_confirm' | 'analyzing' | 'pending_expert' | 'closed'
|
||||
|
||||
/** 风险卡片 */
|
||||
export interface RiskCard {
|
||||
conclusion: string
|
||||
level: RiskLevel
|
||||
actions: string[]
|
||||
evidence: string[]
|
||||
escalation: boolean
|
||||
}
|
||||
|
||||
/** 行动摘要 */
|
||||
export interface ActionSummary {
|
||||
risk_level: RiskLevel
|
||||
conclusion: string
|
||||
actions: string[]
|
||||
}
|
||||
|
||||
/** /ask 响应 */
|
||||
export interface AskResponse {
|
||||
risk: RiskCard
|
||||
answer: string | null
|
||||
action_summary: ActionSummary
|
||||
model: 'kimi' | 'local-triage' | string
|
||||
scene: Scene
|
||||
rag_context?: KnowledgeDoc[]
|
||||
inference_location?: 'cloud' | 'local'
|
||||
fallback_used?: boolean
|
||||
}
|
||||
|
||||
/** 会话响应 */
|
||||
export interface SessionResponse {
|
||||
session_id: string
|
||||
mode: SessionMode
|
||||
expires_at: string
|
||||
}
|
||||
|
||||
/** 文件检查响应 */
|
||||
export interface FileInspectResponse {
|
||||
filename: string
|
||||
bytes: number
|
||||
text_preview: string
|
||||
message: string
|
||||
}
|
||||
|
||||
/** 知识库文档 */
|
||||
export interface KnowledgeDoc {
|
||||
id?: number
|
||||
title: string
|
||||
content: string
|
||||
source: string
|
||||
doc_type?: string
|
||||
region?: string | null
|
||||
effective_date?: string | null
|
||||
status?: string
|
||||
keywords?: string | null
|
||||
score?: number
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
/** 专家 */
|
||||
export interface Expert {
|
||||
id: number
|
||||
name: string
|
||||
phone: string
|
||||
category: 'legal' | 'decision' | 'emotion' | 'life'
|
||||
title: string
|
||||
bio: string
|
||||
expertise: string
|
||||
avatar_url: string | null
|
||||
rate: number
|
||||
rating_count: number
|
||||
status: 'active' | 'inactive'
|
||||
created_at?: string
|
||||
ratings?: ExpertRating[]
|
||||
}
|
||||
|
||||
/** 专家评价 */
|
||||
export interface ExpertRating {
|
||||
id: number
|
||||
consultation_id: number
|
||||
user_phone: string
|
||||
rating: number
|
||||
comment: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
/** 专家服务关系 */
|
||||
export interface ExpertService {
|
||||
service_id: number
|
||||
expert_id: number
|
||||
category: string
|
||||
status: 'pending' | 'active' | 'closed'
|
||||
signed_at: string | null
|
||||
created_at: string
|
||||
expert_name?: string
|
||||
expert_title?: string
|
||||
expert_bio?: string
|
||||
user_phone?: string
|
||||
}
|
||||
|
||||
/** 专家咨询 */
|
||||
export interface Consultation {
|
||||
id: number
|
||||
service_id: number
|
||||
expert_id: number
|
||||
category: string
|
||||
topic: string
|
||||
context?: string
|
||||
question?: string
|
||||
reply: string | null
|
||||
status: 'pending' | 'replied' | 'closed'
|
||||
replied_at: string | null
|
||||
created_at: string
|
||||
expert_name?: string
|
||||
expert_title?: string
|
||||
user_phone?: string
|
||||
}
|
||||
|
||||
/** 用户设置 */
|
||||
export type Settings = Record<string, string>
|
||||
|
||||
/** 对话历史会话摘要 */
|
||||
export interface HistorySession {
|
||||
session_id: string
|
||||
mode: SessionMode
|
||||
message_count: number
|
||||
first_message_at: string | null
|
||||
last_message_at: string | null
|
||||
scene: string | null
|
||||
title?: string
|
||||
}
|
||||
|
||||
/** 对话历史消息 */
|
||||
export interface HistoryMessage {
|
||||
id: number
|
||||
role: 'user' | 'assistant'
|
||||
content: string
|
||||
mode: SessionMode
|
||||
risk: {
|
||||
level?: RiskLevel
|
||||
conclusion?: string
|
||||
actions?: string[]
|
||||
evidence?: string[]
|
||||
escalation?: boolean
|
||||
}
|
||||
meta: {
|
||||
scene?: Scene
|
||||
inference_location?: string
|
||||
model?: string
|
||||
fallback_used?: boolean
|
||||
rag_context?: Array<{
|
||||
title: string
|
||||
doc_type?: string
|
||||
region?: string | null
|
||||
}>
|
||||
}
|
||||
created_at: string | null
|
||||
}
|
||||
|
||||
// ===== 2.0 新增类型 =====
|
||||
|
||||
/** 案卡 */
|
||||
export interface Matter {
|
||||
id: number
|
||||
code: string
|
||||
user_phone: string
|
||||
scene: Scene
|
||||
title: string
|
||||
status: MatterStatus
|
||||
session_id: string | null
|
||||
risk_level: RiskLevel | null
|
||||
summary: string | null
|
||||
closed_at: string | null
|
||||
execution_result: '顺利' | '受阻' | '未执行' | null
|
||||
execution_note: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 案卡看板分组 */
|
||||
export interface MatterBoard {
|
||||
new: Matter[]
|
||||
asking_facts: Matter[]
|
||||
pending_confirm: Matter[]
|
||||
analyzing: Matter[]
|
||||
pending_expert: Matter[]
|
||||
closed: Matter[]
|
||||
}
|
||||
|
||||
/** 老板台聚合数据 */
|
||||
export interface DashboardToday {
|
||||
greeting: string
|
||||
high_risks: Array<{
|
||||
matter_id: number
|
||||
title: string
|
||||
level: RiskLevel
|
||||
scene: Scene
|
||||
}>
|
||||
pending_confirm: Array<{
|
||||
matter_id: number
|
||||
title: string
|
||||
scene: Scene
|
||||
updated_at: string
|
||||
}>
|
||||
expert_replies: Array<{
|
||||
consultation_id: number
|
||||
expert_name: string
|
||||
expert_title: string
|
||||
snippet: string
|
||||
replied_at: string
|
||||
}>
|
||||
health_score: {
|
||||
legal: number
|
||||
operation: number
|
||||
compliance: number
|
||||
}
|
||||
unread_alerts: number
|
||||
}
|
||||
|
||||
/** 风险推送 */
|
||||
export interface RiskAlert {
|
||||
id: number
|
||||
level: 'red' | 'orange' | 'blue'
|
||||
title: string
|
||||
content: string
|
||||
source: string
|
||||
related_matter_id: number | null
|
||||
read_at: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
/** 专家关系(我的团队) */
|
||||
export interface ExpertRelation {
|
||||
expert_id: number
|
||||
name: string
|
||||
avatar_url: string | null
|
||||
category: string
|
||||
title: string
|
||||
expertise: string
|
||||
online: boolean
|
||||
consultation_count: number
|
||||
last_consulted_at: string | null
|
||||
last_topic: string | null
|
||||
tags: string | null
|
||||
}
|
||||
|
||||
/** 快捷指令 */
|
||||
export interface QuickCommand {
|
||||
id: string
|
||||
label: string
|
||||
template: string
|
||||
}
|
||||
|
||||
/** 快捷指令分组 */
|
||||
export interface QuickCommands {
|
||||
legal: QuickCommand[]
|
||||
decision: QuickCommand[]
|
||||
life: QuickCommand[]
|
||||
profile_incomplete: boolean
|
||||
incomplete_hint?: string
|
||||
}
|
||||
Reference in New Issue
Block a user