-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathtypes.ts
More file actions
141 lines (123 loc) · 3.58 KB
/
types.ts
File metadata and controls
141 lines (123 loc) · 3.58 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
export type AIClient = GoogleGenAIClient | OpenAIClient;
export interface GoogleGenAIClient {
provider: 'google';
models: {
generateContent(params: Record<string, unknown>): Promise<GoogleGenAIResponse>;
generateContentStream(params: Record<string, unknown>): Promise<AsyncIterable<GoogleGenAIStreamChunk>>;
};
}
export interface GoogleGenAIResponse {
text: string;
candidates?: Array<{ content?: { parts?: Array<{ text?: string; thought?: boolean }> } }>;
}
export interface GoogleGenAIStreamChunk {
candidates?: Array<{ content?: { parts?: Array<{ text?: string; thought?: boolean }> } }>;
}
export interface OpenAIClient {
provider: 'openai';
chat: {
completions: {
create(params: Record<string, unknown>): Promise<OpenAIChatCompletion>;
};
};
}
export interface OpenAIChatCompletion {
choices: Array<{
message: {
content: string | null;
reasoning_content?: string;
};
delta?: {
content?: string | null;
reasoning_content?: string;
};
}>;
[key: string]: unknown;
}
export type ModelOption = 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'custom' | string;
export type ThinkingLevel = 'minimal' | 'low' | 'medium' | 'high';
export type ApiProvider = 'google' | 'openai';
export type ModelPreferences = {
planningLevel?: ThinkingLevel;
expertLevel?: ThinkingLevel;
synthesisLevel?: ThinkingLevel;
expertConcurrency?: number;
enableRecursiveLoop?: boolean;
};
export type CustomModel = {
id: string;
name: string; // The Actual Model ID (e.g., 'gpt-4o')
displayName?: string; // Friendly name for UI (e.g., 'My GPT-4')
provider: ApiProvider;
apiKey?: string;
baseUrl?: string;
};
export type ExpertConfig = {
id: string;
role: string;
description: string;
temperature: number;
prompt: string;
};
export type ExpertResult = ExpertConfig & {
status: 'pending' | 'thinking' | 'completed' | 'error';
content?: string;
thoughts?: string;
thoughtProcess?: string;
startTime?: number;
endTime?: number;
round?: number; // Track which iteration this expert belongs to
};
export type AnalysisResult = {
thought_process: string;
experts: Omit<ExpertConfig, 'id'>[];
};
export type ReviewResult = {
satisfied: boolean;
critique: string;
next_round_strategy?: string;
refined_experts?: Omit<ExpertConfig, 'id'>[];
};
export type AppState = 'idle' | 'analyzing' | 'experts_working' | 'reviewing' | 'synthesizing' | 'completed';
export type AppConfig = {
planningLevel: ThinkingLevel;
expertLevel: ThinkingLevel;
synthesisLevel: ThinkingLevel;
customApiKey?: string;
customBaseUrl?: string;
enableCustomApi?: boolean;
enableRecursiveLoop?: boolean;
apiProvider?: ApiProvider;
customModels?: CustomModel[];
presetOverrides?: CustomModel[];
expertConcurrency?: number;
/** Per-model preference overrides. Key = model name (e.g. 'glm-5-turbo'). */
modelPreferences?: Record<string, ModelPreferences>;
};
export type MessageAttachment = {
id: string;
type: 'image' | 'pdf' | 'video' | 'audio' | 'document';
name?: string;
mimeType: string;
data: string; // Base64 string
url?: string; // For display
};
export type ChatMessage = {
id: string;
role: 'user' | 'model';
content: string;
attachments?: MessageAttachment[];
// DeepThink Artifacts (only for model messages)
analysis?: AnalysisResult | null;
experts?: ExpertResult[];
synthesisThoughts?: string;
isThinking?: boolean;
totalDuration?: number; // Total time in ms
};
export type ChatSession = {
id: string;
title: string;
messages: ChatMessage[];
createdAt: number;
model: ModelOption;
};