File size: 1,661 Bytes
cc809a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cd7d1f
cc809a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// ClauseGuard — Shared TypeScript types for the web app

export interface Cat {
  name: string;
  severity: string;
  description?: string;
  confidence?: number;
}

export interface Clause {
  text: string;
  categories: Cat[];
}

export interface Entity {
  text: string;
  type: string;
  score?: number;
  source?: string;
}

export interface Contradiction {
  type: string;
  explanation: string;
  severity: string;
  confidence?: number;
  source?: string;
}

export interface Obligation {
  type: string;
  party: string;
  description: string;
  deadline: string;
  priority?: number;
}

export interface ComplianceCheck {
  requirement: string;
  description: string;
  severity: string;
  status: string;
  matched_keywords: string[];
  context?: string[];
}

export interface ComplianceReg {
  description: string;
  compliance_rate: number;
  checks: ComplianceCheck[];
  overall_status: string;
  negated_count?: number;
  ambiguous_count?: number;
  note?: string;
}

export interface Redline {
  original_text: string;
  clause_label: string;
  risk_level: string;
  safe_alternative: string;
  template_alternative?: string;
  legal_basis: string;
  consumer_standard: string;
  tier: string;
}

export interface ChatMessage {
  role: "user" | "assistant";
  content: string;
}

export interface AnalysisResult {
  risk_score: number;
  grade: string;
  total_clauses: number;
  flagged_count: number;
  results: Clause[];
  entities: Entity[];
  contradictions: Contradiction[];
  obligations: Obligation[];
  compliance: Record<string, ComplianceReg>;
  redlines: Redline[];
  model: string;
  latency_ms: number;
  session_id?: string;
}