File size: 1,866 Bytes
1a12d36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**

 * Agent-related types

 */

export interface SessionMeta {
  id: string;
  title: string;
  createdAt: string;
  isActive: boolean;
}

export interface MessageSegment {
  type: 'text' | 'tools';
  content?: string;
  tools?: TraceLog[];
}

export interface Message {
  id: string;
  role: 'user' | 'assistant' | 'tool';
  content: string;
  timestamp: string;
  segments?: MessageSegment[];
  approval?: {
    status: 'pending' | 'approved' | 'rejected';
    batch: ApprovalBatch;
    decisions?: ToolApproval[];
  };
  toolOutput?: string;
}

export interface ToolCall {
  id: string;
  tool: string;
  arguments: Record<string, unknown>;
  status: 'pending' | 'running' | 'completed' | 'failed';
  output?: string;
}

export interface ToolApproval {
  tool_call_id: string;
  approved: boolean;
  feedback?: string | null;
}

export interface ApprovalBatch {
  tools: Array<{
    tool: string;
    arguments: Record<string, unknown>;
    tool_call_id: string;
  }>;
  count: number;
}

export type ApprovalStatus = 'none' | 'pending' | 'approved' | 'rejected';

export interface TraceLog {
  id: string;
  toolCallId?: string; // Backend tool_call_id for reliable matching
  type: 'call' | 'output';
  text: string;
  tool: string;
  timestamp: string;
  completed?: boolean;
  args?: Record<string, unknown>; // Store args for auto-exec jobs
  output?: string; // Store tool output for display
  success?: boolean; // Whether the tool call succeeded
  /** Approval state for tools that need user confirmation */
  approvalStatus?: ApprovalStatus;
  /** Parsed job info (URL, status, logs) for hf_jobs */
  jobUrl?: string;
  jobStatus?: string;
  jobLogs?: string;
}

export interface User {
  authenticated: boolean;
  username?: string;
  name?: string;
  picture?: string;
}