1// Types for Shelley UI
2import {
3 Conversation as GeneratedConversation,
4 ConversationWithStateForTS,
5 ApiMessageForTS,
6 StreamResponseForTS,
7 Usage as GeneratedUsage,
8 MessageType as GeneratedMessageType,
9} from "./generated-types";
10
11// Re-export generated types
12export type Conversation = GeneratedConversation;
13export type ConversationWithState = ConversationWithStateForTS;
14export type Usage = GeneratedUsage;
15export type MessageType = GeneratedMessageType;
16
17// Extend the generated Message type with parsed data
18export interface Message extends Omit<ApiMessageForTS, "type"> {
19 type: MessageType;
20}
21
22// Go backend LLM struct format (capitalized field names)
23export interface LLMMessage {
24 Role: number; // 0 = user, 1 = assistant
25 Content: LLMContent[];
26 ToolUse?: unknown;
27}
28
29export interface LLMContent {
30 ID: string;
31 Type: number; // 2 = text, 3 = tool_use, 4 = tool_result, 5 = thinking
32 Text?: string;
33 ToolName?: string;
34 ToolInput?: unknown;
35 ToolResult?: LLMContent[];
36 ToolError?: boolean;
37 // Other fields from Go struct
38 MediaType?: string;
39 Thinking?: string;
40 Data?: string;
41 Signature?: string;
42 ToolUseID?: string;
43 ToolUseStartTime?: string | null;
44 ToolUseEndTime?: string | null;
45 Display?: unknown;
46 Cache?: boolean;
47}
48
49// API types
50export interface Model {
51 id: string;
52 display_name?: string;
53 source?: string; // Human-readable source (e.g., "exe.dev gateway", "$ANTHROPIC_API_KEY")
54 ready: boolean;
55 max_context_tokens?: number;
56}
57
58export interface ChatRequest {
59 message: string;
60 model?: string;
61 cwd?: string;
62}
63// StreamResponse represents the streaming response format
64export interface StreamResponse extends Omit<StreamResponseForTS, "messages"> {
65 messages: Message[];
66 context_window_size?: number;
67 conversation_list_update?: ConversationListUpdate;
68 heartbeat?: boolean;
69}
70
71// Link represents a custom link that can be added to the UI
72export interface Link {
73 title: string;
74 icon_svg?: string; // SVG path data for the icon
75 url: string;
76}
77
78// InitData is injected into window by the server
79export interface InitData {
80 models: Model[];
81 default_model: string;
82 default_cwd?: string;
83 home_dir?: string;
84 hostname?: string;
85 terminal_url?: string;
86 links?: Link[];
87}
88
89// Extend Window interface to include our init data
90declare global {
91 interface Window {
92 __SHELLEY_INIT__?: InitData;
93 }
94}
95
96// Git diff types
97export interface GitDiffInfo {
98 id: string;
99 message: string;
100 author: string;
101 timestamp: string;
102 filesCount: number;
103 additions: number;
104 deletions: number;
105}
106
107export interface GitFileInfo {
108 path: string;
109 status: "added" | "modified" | "deleted";
110 additions: number;
111 deletions: number;
112 isGenerated: boolean;
113}
114
115export interface GitFileDiff {
116 path: string;
117 oldContent: string;
118 newContent: string;
119}
120
121// Comment for diff viewer
122export interface DiffComment {
123 id: string;
124 line: number;
125 side: "left" | "right";
126 text: string;
127 selectedText?: string;
128 startLine?: number;
129 endLine?: number;
130 filePath: string;
131 diffId: string;
132}
133
134// Conversation list streaming update
135export interface ConversationListUpdate {
136 type: "update" | "delete";
137 conversation?: Conversation;
138 conversation_id?: string; // For deletes
139}
140
141// Version check types
142export interface VersionInfo {
143 current_version: string;
144 current_tag?: string;
145 current_commit?: string;
146 current_commit_time?: string;
147 latest_version?: string;
148 latest_tag?: string;
149 published_at?: string;
150 has_update: boolean; // True if minor version is newer (show upgrade button)
151 should_notify: boolean; // True if should show red dot (newer + 5 days apart)
152 download_url?: string;
153 executable_path?: string;
154 commits?: CommitInfo[];
155 checked_at: string;
156 error?: string;
157 running_under_systemd: boolean; // True if INVOCATION_ID env var is set
158}
159
160export interface CommitInfo {
161 sha: string;
162 message: string;
163 author: string;
164 date: string;
165}