File size: 1,265 Bytes
68d7816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
export type MessageRole = 'user' | 'assistant' | 'tool' | 'system';

export interface TextContent {
  type: 'text';
  text: string;
}

export interface ToolUseContent {
  type: 'tool_use';
  tool_call_id: string;
  tool_name: string;
  input: unknown;
}

export interface ToolResultContent {
  type: 'tool_result';
  tool_call_id: string;
  output: unknown;
  is_error?: boolean;
}

export type ImageSource =
  | {
      kind: 'url';
      url: string;
      id?: string;
    }
  | {
      kind: 'base64';
      media_type: string;
      data: string;
    }
  | { kind: 'file'; file_id: string }
  | { kind: 'session_media'; file_id: string }
  | { kind: 'path'; path: string };

export interface ImageContent {
  type: 'image';
  source: ImageSource;
  name?: string;
}

export interface VideoContent {
  type: 'video';
  source: ImageSource;
  name?: string;
}

export interface FileContent {
  type: 'file';
  file_id?: string;
  path?: string;
  name?: string;
  media_type?: string;
  size?: number;
}

export interface ThinkingContent {
  type: 'thinking';
  thinking: string;
  signature?: string;
}

export type MessageContent =
  | TextContent
  | ToolUseContent
  | ToolResultContent
  | ImageContent
  | VideoContent
  | FileContent
  | ThinkingContent;