-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
128 lines (112 loc) · 3.14 KB
/
Copy pathindex.ts
File metadata and controls
128 lines (112 loc) · 3.14 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
export interface TweetData {
text: string;
author?: string;
url?: string;
}
export interface CommentSuggestion {
text: string;
tone: CommentTone;
}
export type CommentTone = 'friendly' | 'professional' | 'empathetic' | 'humorous';
export type CommentLength = 'short' | 'medium' | 'long';
export type CommentStance = 'agree' | 'disagree' | 'question' | 'neutral';
export type GeminiModel = 'gemini-3-flash-preview' | 'gemini-3-pro-preview';
export interface StorageData {
apiKey?: string;
preferredTone?: CommentTone;
preferredLength?: CommentLength;
preferredStance?: CommentStance;
selectedModel?: GeminiModel;
persona?: PersonaData;
rawWritings?: string[];
}
export interface MessagePayload {
type: 'TWEET_CLICKED' | 'GENERATE_COMMENT' | 'OPEN_SIDEPANEL' | 'GET_CURRENT_TWEET';
data?: TweetData | CommentSuggestion | any;
}
// Token usage and cost tracking
export interface TokenUsage {
promptTokens: number;
completionTokens: number;
totalTokens: number;
}
export interface TokenCost {
inputCost: number;
outputCost: number;
totalCost: number;
}
export interface GenerationResult {
comment: string;
usage: TokenUsage;
cost: TokenCost;
model: string;
}
// Translation result from AI translation
export interface TranslationResult {
translatedText: string;
sourceLanguage: string;
usage: TokenUsage;
cost: TokenCost;
model: string;
}
// Cache for storing translations
export interface TranslationCacheEntry {
translatedText: string;
sourceLanguage: string;
timestamp: number;
}
export interface TranslationCache {
[key: string]: TranslationCacheEntry;
}
// Comment explanation (Korean translation + relevance)
export interface CommentExplanation {
koreanTranslation: string;
relevanceReason: string;
}
export interface ExplanationResult {
explanation: CommentExplanation;
usage: TokenUsage;
cost: TokenCost;
model: string;
}
// Per-tweet cached results (comment + explanation)
export interface TweetResults {
generatedComment: string;
tokenUsage: TokenUsage | null;
tokenCost: TokenCost | null;
currentModel: string;
commentExplanation: CommentExplanation | null;
lastUpdated: number;
}
// Session storage for state persistence across sidepanel reopens
export interface SessionStorageData {
tweetCache?: Record<string, TweetData>;
sidePanelState?: SidePanelState;
tweetResultsCache?: Record<string, TweetResults>;
}
export interface SidePanelState {
tweetData: TweetData | null;
generatedComment: string;
tokenUsage: TokenUsage | null;
tokenCost: TokenCost | null;
currentModel: string;
commentExplanation: CommentExplanation | null;
lastUpdated: number;
}
// Persona data for personalized responses
export interface PersonaData {
writingStyle: {
sentenceLength: 'short' | 'medium' | 'long';
formality: 'casual' | 'neutral' | 'formal';
humor: boolean;
directness: 'direct' | 'indirect';
};
opinionStyle?: {
hookPattern: 'question' | 'bold-claim' | 'reframe' | 'observation';
argumentStyle: 'evidence' | 'analogy' | 'reframe' | 'direct-assertion';
};
commonPhrases: string[];
topics: string[];
exampleResponses: string[];
lastAnalyzed: string;
}