-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
81 lines (68 loc) · 1.74 KB
/
types.ts
File metadata and controls
81 lines (68 loc) · 1.74 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
// Message part types matching AI SDK UIMessage format
export interface TextPart {
type: 'text'
text: string
}
export interface ToolInvocationPart {
type: 'tool-invocation'
toolInvocationId: string
toolName: string
args: Record<string, unknown>
state: 'partial-call' | 'call' | 'result'
result?: unknown
}
export type MessagePart = TextPart | ToolInvocationPart
export interface Message {
id: string
role: 'user' | 'assistant' // Changed from "model" to match AI SDK
parts: MessagePart[]
text: string // Computed from text parts, kept for backwards compat
timestamp: number
}
// Helper to compute text from parts
export function getTextFromParts(parts: MessagePart[]): string {
return parts
.filter((p): p is TextPart => p.type === 'text')
.map(p => p.text)
.join('')
}
export type ThreadType = 'discussion' | 'comment'
export interface Thread {
id: string
type: ThreadType // Whether this is an AI discussion or personal comment
context: string // The selected text that started the thread
messages: Message[]
createdAt: number
snippet: string // Short preview of context for the list
}
export interface Quote {
id: string
text: string
savedAt: number
}
export interface TextSelection {
text: string
rect: DOMRect | null
}
export enum ViewState {
START = 'START',
READING = 'READING',
QUOTES = 'QUOTES',
}
export type AiProvider = 'google' | 'openai' | 'anthropic' | 'ollama'
export interface AppSettings {
provider: AiProvider
apiKey: string
baseUrl?: string
modelId: string
}
export interface SourceMetadata {
type: 'file' | 'url' | 'paste'
name?: string // filename or URL
}
export interface SessionMeta {
id: string
title: string
summary: string | null
lastModified: number
}