@gendive/chatllm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1099 -0
- package/dist/index.d.ts +1099 -0
- package/dist/index.js +2199 -0
- package/dist/index.mjs +2058 -0
- package/package.json +58 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1099 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for devdive-chatLLM
|
|
3
|
+
*/
|
|
4
|
+
type ProviderType = 'openai' | 'anthropic' | 'google' | 'naver' | 'ollama';
|
|
5
|
+
interface ProviderConfigs {
|
|
6
|
+
openai?: OpenAIConfig;
|
|
7
|
+
anthropic?: AnthropicConfig;
|
|
8
|
+
google?: GoogleConfig;
|
|
9
|
+
naver?: NaverConfig;
|
|
10
|
+
ollama?: OllamaConfig;
|
|
11
|
+
}
|
|
12
|
+
interface OpenAIConfig {
|
|
13
|
+
apiKey: string;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
interface AnthropicConfig {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
interface GoogleConfig {
|
|
21
|
+
apiKey: string;
|
|
22
|
+
}
|
|
23
|
+
interface NaverConfig {
|
|
24
|
+
apiKey: string;
|
|
25
|
+
apiGatewayKey: string;
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
}
|
|
28
|
+
interface OllamaConfig {
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
}
|
|
31
|
+
type Role = 'system' | 'user' | 'assistant' | 'tool';
|
|
32
|
+
interface Message {
|
|
33
|
+
id: string;
|
|
34
|
+
role: Role;
|
|
35
|
+
content: string;
|
|
36
|
+
provider?: ProviderType;
|
|
37
|
+
model?: string;
|
|
38
|
+
toolCalls?: ToolCall[];
|
|
39
|
+
toolCallId?: string;
|
|
40
|
+
timestamp: number;
|
|
41
|
+
metadata?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
interface ToolCall {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
arguments: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
interface ToolResult {
|
|
49
|
+
toolCallId: string;
|
|
50
|
+
result: unknown;
|
|
51
|
+
error?: string;
|
|
52
|
+
}
|
|
53
|
+
interface ParameterSchema {
|
|
54
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
55
|
+
description?: string;
|
|
56
|
+
enum?: string[];
|
|
57
|
+
items?: ParameterSchema;
|
|
58
|
+
properties?: Record<string, ParameterSchema>;
|
|
59
|
+
required?: string[];
|
|
60
|
+
}
|
|
61
|
+
interface ToolDefinition {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
parameters: {
|
|
65
|
+
type: 'object';
|
|
66
|
+
properties: Record<string, ParameterSchema>;
|
|
67
|
+
required?: string[];
|
|
68
|
+
};
|
|
69
|
+
handler: (params: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
70
|
+
}
|
|
71
|
+
interface ChatConfig {
|
|
72
|
+
id?: string;
|
|
73
|
+
providers: ProviderConfigs;
|
|
74
|
+
defaultProvider: ProviderType;
|
|
75
|
+
defaultModel?: string;
|
|
76
|
+
storagePath?: string;
|
|
77
|
+
systemPrompt?: string;
|
|
78
|
+
/** 개인화 설정 */
|
|
79
|
+
personalization?: Partial<PersonalizationConfig>;
|
|
80
|
+
}
|
|
81
|
+
interface Chat {
|
|
82
|
+
id: string;
|
|
83
|
+
config: ChatConfig;
|
|
84
|
+
messages: Message[];
|
|
85
|
+
tools: Map<string, ToolDefinition>;
|
|
86
|
+
memory: Map<string, MemoryEntry>;
|
|
87
|
+
createdAt: number;
|
|
88
|
+
updatedAt: number;
|
|
89
|
+
}
|
|
90
|
+
interface SendOptions {
|
|
91
|
+
provider?: ProviderType;
|
|
92
|
+
model?: string;
|
|
93
|
+
temperature?: number;
|
|
94
|
+
maxTokens?: number;
|
|
95
|
+
tools?: ToolDefinition[];
|
|
96
|
+
systemPrompt?: string;
|
|
97
|
+
}
|
|
98
|
+
type StreamEventType = 'text' | 'tool_call' | 'tool_result' | 'done' | 'error';
|
|
99
|
+
interface StreamEvent {
|
|
100
|
+
type: StreamEventType;
|
|
101
|
+
content?: string;
|
|
102
|
+
toolCall?: ToolCall;
|
|
103
|
+
toolResult?: ToolResult;
|
|
104
|
+
error?: Error;
|
|
105
|
+
message?: Message;
|
|
106
|
+
}
|
|
107
|
+
interface MemoryEntry {
|
|
108
|
+
key: string;
|
|
109
|
+
value: unknown;
|
|
110
|
+
createdAt: number;
|
|
111
|
+
updatedAt: number;
|
|
112
|
+
}
|
|
113
|
+
interface GlobalMemoryStore$1 {
|
|
114
|
+
entries: Map<string, MemoryEntry>;
|
|
115
|
+
storagePath: string;
|
|
116
|
+
}
|
|
117
|
+
type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
118
|
+
interface ObservedTask {
|
|
119
|
+
id: string;
|
|
120
|
+
description: string;
|
|
121
|
+
status: TaskStatus;
|
|
122
|
+
progress: number;
|
|
123
|
+
createdAt: number;
|
|
124
|
+
updatedAt: number;
|
|
125
|
+
}
|
|
126
|
+
interface UserPreference {
|
|
127
|
+
key: string;
|
|
128
|
+
value: unknown;
|
|
129
|
+
confidence: number;
|
|
130
|
+
source: string;
|
|
131
|
+
}
|
|
132
|
+
interface LearnedSkill {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
category: string;
|
|
137
|
+
steps: SkillStep[];
|
|
138
|
+
successRate: number;
|
|
139
|
+
usageCount: number;
|
|
140
|
+
createdAt: number;
|
|
141
|
+
updatedAt: number;
|
|
142
|
+
}
|
|
143
|
+
interface SkillStep {
|
|
144
|
+
order: number;
|
|
145
|
+
action: string;
|
|
146
|
+
expectedInput?: string;
|
|
147
|
+
expectedOutput?: string;
|
|
148
|
+
}
|
|
149
|
+
interface ObserverConfig {
|
|
150
|
+
extractTasks: boolean;
|
|
151
|
+
extractPreferences: boolean;
|
|
152
|
+
autoLearn: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface ObserverState {
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
config: ObserverConfig;
|
|
157
|
+
tasks: ObservedTask[];
|
|
158
|
+
preferences: UserPreference[];
|
|
159
|
+
}
|
|
160
|
+
type StyleLevel = 'low' | 'medium' | 'high';
|
|
161
|
+
type FormattingStyle = 'minimal' | 'default' | 'rich';
|
|
162
|
+
/**
|
|
163
|
+
* 응답 스타일 설정
|
|
164
|
+
*/
|
|
165
|
+
interface ResponseStyle {
|
|
166
|
+
/** 따뜻함 수준 */
|
|
167
|
+
warmth: StyleLevel;
|
|
168
|
+
/** 열정/에너지 수준 */
|
|
169
|
+
enthusiasm: StyleLevel;
|
|
170
|
+
/** 이모지 사용 수준 */
|
|
171
|
+
emojiUsage: StyleLevel;
|
|
172
|
+
/** 포맷팅 스타일 (헤더, 목록 등) */
|
|
173
|
+
formatting: FormattingStyle;
|
|
174
|
+
/** 응답 길이 선호 */
|
|
175
|
+
verbosity: 'concise' | 'balanced' | 'detailed';
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 사용자 프로필 정보
|
|
179
|
+
*/
|
|
180
|
+
interface UserProfile {
|
|
181
|
+
/** 사용자 닉네임/호칭 */
|
|
182
|
+
nickname?: string;
|
|
183
|
+
/** 직업/역할 */
|
|
184
|
+
occupation?: string;
|
|
185
|
+
/** 추가 정보 (관심사, 가치, 선호 사항) */
|
|
186
|
+
additionalInfo?: string;
|
|
187
|
+
/** 선호 언어 */
|
|
188
|
+
preferredLanguage?: string;
|
|
189
|
+
/** 전문 분야 */
|
|
190
|
+
expertise?: string[];
|
|
191
|
+
/** 커스텀 지시사항 */
|
|
192
|
+
customInstructions?: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 개인화 설정 전체
|
|
196
|
+
*/
|
|
197
|
+
interface PersonalizationConfig {
|
|
198
|
+
/** 응답 스타일 */
|
|
199
|
+
responseStyle: ResponseStyle;
|
|
200
|
+
/** 사용자 프로필 */
|
|
201
|
+
userProfile: UserProfile;
|
|
202
|
+
/** 메모리 참조 활성화 */
|
|
203
|
+
useMemory: boolean;
|
|
204
|
+
/** 언어 설정 ('auto' | 'ko' | 'en' | etc.) */
|
|
205
|
+
language: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 개인화 설정 기본값
|
|
209
|
+
*/
|
|
210
|
+
declare const DEFAULT_PERSONALIZATION: PersonalizationConfig;
|
|
211
|
+
/**
|
|
212
|
+
* @description Hook 결과 타입 (React Query UseMutationResult 호환)
|
|
213
|
+
*/
|
|
214
|
+
interface MutationResult<TData = unknown, TError = Error, TVariables = unknown> {
|
|
215
|
+
mutate: (variables: TVariables) => void;
|
|
216
|
+
mutateAsync: (variables: TVariables) => Promise<TData>;
|
|
217
|
+
isPending: boolean;
|
|
218
|
+
isError: boolean;
|
|
219
|
+
isSuccess: boolean;
|
|
220
|
+
data?: TData;
|
|
221
|
+
error?: TError;
|
|
222
|
+
reset: () => void;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @description Tool/Action Hook 타입
|
|
226
|
+
*/
|
|
227
|
+
type ToolHook<TRequest = unknown, TResponse = unknown> = () => MutationResult<TResponse, Error, TRequest>;
|
|
228
|
+
/**
|
|
229
|
+
* @description AI가 자동으로 호출하는 Tool 설정
|
|
230
|
+
* AI가 사용자 메시지를 분석해서 필요시 자동 호출
|
|
231
|
+
*/
|
|
232
|
+
interface LLMToolConfig<TRequest = unknown, TResponse = unknown> {
|
|
233
|
+
/** Tool hook */
|
|
234
|
+
hook: ToolHook<TRequest, TResponse>;
|
|
235
|
+
/** AI가 판단할 때 사용하는 설명 */
|
|
236
|
+
description: string;
|
|
237
|
+
/** JSON Schema 형태의 파라미터 정의 (선택) */
|
|
238
|
+
parameters?: {
|
|
239
|
+
type: 'object';
|
|
240
|
+
properties: Record<string, {
|
|
241
|
+
type: string;
|
|
242
|
+
description?: string;
|
|
243
|
+
enum?: string[];
|
|
244
|
+
}>;
|
|
245
|
+
required?: string[];
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @description 사용자가 UI에서 직접 선택하는 Action 설정
|
|
250
|
+
*/
|
|
251
|
+
interface LLMActionConfig<TRequest = unknown, TResponse = unknown> {
|
|
252
|
+
/** Action hook */
|
|
253
|
+
hook: ToolHook<TRequest, TResponse>;
|
|
254
|
+
/** UI에 표시할 레이블 */
|
|
255
|
+
label: string;
|
|
256
|
+
/** 아이콘 이름 또는 컴포넌트 */
|
|
257
|
+
icon?: string;
|
|
258
|
+
/** 비활성화 여부 */
|
|
259
|
+
disabled?: boolean;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* @description 기본 채팅(텍스트 생성) 설정
|
|
263
|
+
*/
|
|
264
|
+
interface LLMChatHookConfig<TRequest = unknown, TResponse = unknown> {
|
|
265
|
+
/** 텍스트 생성 hook */
|
|
266
|
+
hook: ToolHook<TRequest, TResponse>;
|
|
267
|
+
/** 기본 시스템 프롬프트 */
|
|
268
|
+
systemPrompt?: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* @description LLM Chat 컴포넌트 Props
|
|
272
|
+
*/
|
|
273
|
+
interface LLMChatComponentProps {
|
|
274
|
+
/** AI가 자동 호출하는 Tools */
|
|
275
|
+
tools?: Record<string, LLMToolConfig>;
|
|
276
|
+
/** 사용자가 직접 선택하는 Actions */
|
|
277
|
+
actions?: Record<string, LLMActionConfig>;
|
|
278
|
+
/** 기본 채팅 설정 */
|
|
279
|
+
chat: LLMChatHookConfig;
|
|
280
|
+
/** 스타일 클래스 */
|
|
281
|
+
className?: string;
|
|
282
|
+
/** 개인화 설정 */
|
|
283
|
+
personalization?: Partial<PersonalizationConfig>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Session represents a conversation context that can span multiple providers
|
|
288
|
+
* This is inspired by Acontext's Session concept
|
|
289
|
+
*/
|
|
290
|
+
interface Session {
|
|
291
|
+
id: string;
|
|
292
|
+
messages: Message[];
|
|
293
|
+
systemPrompt?: string;
|
|
294
|
+
createdAt: number;
|
|
295
|
+
updatedAt: number;
|
|
296
|
+
metadata: Record<string, unknown>;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Create a new session
|
|
300
|
+
*/
|
|
301
|
+
declare function createSession(options?: {
|
|
302
|
+
id?: string;
|
|
303
|
+
systemPrompt?: string;
|
|
304
|
+
metadata?: Record<string, unknown>;
|
|
305
|
+
}): Session;
|
|
306
|
+
/**
|
|
307
|
+
* Add a message to the session
|
|
308
|
+
*/
|
|
309
|
+
declare function addMessage(session: Session, message: Message): Session;
|
|
310
|
+
/**
|
|
311
|
+
* Add multiple messages to the session
|
|
312
|
+
*/
|
|
313
|
+
declare function addMessages(session: Session, messages: Message[]): Session;
|
|
314
|
+
/**
|
|
315
|
+
* Get messages prepared for a specific provider
|
|
316
|
+
* Includes system prompt as the first message if defined
|
|
317
|
+
*/
|
|
318
|
+
declare function getMessagesForProvider(session: Session, _provider: ProviderType): Message[];
|
|
319
|
+
/**
|
|
320
|
+
* Update session system prompt
|
|
321
|
+
*/
|
|
322
|
+
declare function setSystemPrompt$1(session: Session, prompt: string): Session;
|
|
323
|
+
/**
|
|
324
|
+
* Clear session messages but keep system prompt
|
|
325
|
+
*/
|
|
326
|
+
declare function clearMessages$1(session: Session): Session;
|
|
327
|
+
/**
|
|
328
|
+
* Get the last N messages from session
|
|
329
|
+
*/
|
|
330
|
+
declare function getLastMessages(session: Session, count: number): Message[];
|
|
331
|
+
/**
|
|
332
|
+
* Get messages after a specific timestamp
|
|
333
|
+
*/
|
|
334
|
+
declare function getMessagesAfter(session: Session, timestamp: number): Message[];
|
|
335
|
+
/**
|
|
336
|
+
* Get a summary of the session
|
|
337
|
+
*/
|
|
338
|
+
declare function getSessionSummary(session: Session): {
|
|
339
|
+
id: string;
|
|
340
|
+
messageCount: number;
|
|
341
|
+
providers: ProviderType[];
|
|
342
|
+
firstMessageAt: number | null;
|
|
343
|
+
lastMessageAt: number | null;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Update session metadata
|
|
347
|
+
*/
|
|
348
|
+
declare function setSessionMetadata(session: Session, key: string, value: unknown): Session;
|
|
349
|
+
/**
|
|
350
|
+
* Serialize session to JSON-compatible object
|
|
351
|
+
*/
|
|
352
|
+
declare function serializeSession(session: Session): Record<string, unknown>;
|
|
353
|
+
/**
|
|
354
|
+
* Deserialize session from JSON-compatible object
|
|
355
|
+
*/
|
|
356
|
+
declare function deserializeSession(data: Record<string, unknown>): Session;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Create a new chat instance
|
|
360
|
+
*/
|
|
361
|
+
declare function createChat(config: ChatConfig): Chat;
|
|
362
|
+
/**
|
|
363
|
+
* Send a message and get a response
|
|
364
|
+
*/
|
|
365
|
+
declare function sendMessage(chat: Chat, content: string, options?: SendOptions): Promise<Message>;
|
|
366
|
+
/**
|
|
367
|
+
* Send a message and stream the response
|
|
368
|
+
*/
|
|
369
|
+
declare function sendMessageStream(chat: Chat, content: string, options?: SendOptions): AsyncGenerator<StreamEvent>;
|
|
370
|
+
/**
|
|
371
|
+
* Register a tool for the chat
|
|
372
|
+
*/
|
|
373
|
+
declare function registerTool(chat: Chat, tool: ToolDefinition): void;
|
|
374
|
+
/**
|
|
375
|
+
* Unregister a tool from the chat
|
|
376
|
+
*/
|
|
377
|
+
declare function unregisterTool(chat: Chat, toolName: string): boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Get all registered tools
|
|
380
|
+
*/
|
|
381
|
+
declare function getTools(chat: Chat): ToolDefinition[];
|
|
382
|
+
/**
|
|
383
|
+
* Set system prompt for the chat
|
|
384
|
+
*/
|
|
385
|
+
declare function setSystemPrompt(chat: Chat, prompt: string): void;
|
|
386
|
+
/**
|
|
387
|
+
* Get chat messages
|
|
388
|
+
*/
|
|
389
|
+
declare function getMessages(chat: Chat): Message[];
|
|
390
|
+
/**
|
|
391
|
+
* Clear chat messages only
|
|
392
|
+
*/
|
|
393
|
+
declare function clearMessages(chat: Chat): void;
|
|
394
|
+
/**
|
|
395
|
+
* Reset chat completely (messages, tools, memory)
|
|
396
|
+
*/
|
|
397
|
+
declare function resetChat(chat: Chat): void;
|
|
398
|
+
/**
|
|
399
|
+
* Get chat session
|
|
400
|
+
*/
|
|
401
|
+
declare function getSession(chat: Chat): Session;
|
|
402
|
+
/**
|
|
403
|
+
* Destroy a chat and clean up resources
|
|
404
|
+
*/
|
|
405
|
+
declare function destroyChat(chat: Chat): void;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Create a new message
|
|
409
|
+
*/
|
|
410
|
+
declare function createMessage(role: Role, content: string, options?: {
|
|
411
|
+
provider?: ProviderType;
|
|
412
|
+
model?: string;
|
|
413
|
+
toolCalls?: ToolCall[];
|
|
414
|
+
toolCallId?: string;
|
|
415
|
+
metadata?: Record<string, unknown>;
|
|
416
|
+
}): Message;
|
|
417
|
+
/**
|
|
418
|
+
* Create a user message
|
|
419
|
+
*/
|
|
420
|
+
declare function createUserMessage(content: string): Message;
|
|
421
|
+
/**
|
|
422
|
+
* Create an assistant message
|
|
423
|
+
*/
|
|
424
|
+
declare function createAssistantMessage(content: string, provider?: ProviderType, model?: string, toolCalls?: ToolCall[]): Message;
|
|
425
|
+
/**
|
|
426
|
+
* Create a system message
|
|
427
|
+
*/
|
|
428
|
+
declare function createSystemMessage(content: string): Message;
|
|
429
|
+
/**
|
|
430
|
+
* Create a tool result message
|
|
431
|
+
*/
|
|
432
|
+
declare function createToolMessage(content: string, toolCallId: string): Message;
|
|
433
|
+
/**
|
|
434
|
+
* Clone a message with optional overrides
|
|
435
|
+
*/
|
|
436
|
+
declare function cloneMessage(message: Message, overrides?: Partial<Message>): Message;
|
|
437
|
+
/**
|
|
438
|
+
* Filter messages by role
|
|
439
|
+
*/
|
|
440
|
+
declare function filterByRole(messages: Message[], role: Role): Message[];
|
|
441
|
+
/**
|
|
442
|
+
* Filter messages by provider
|
|
443
|
+
*/
|
|
444
|
+
declare function filterByProvider(messages: Message[], provider: ProviderType): Message[];
|
|
445
|
+
/**
|
|
446
|
+
* Get the last message of a specific role
|
|
447
|
+
*/
|
|
448
|
+
declare function getLastMessageByRole(messages: Message[], role: Role): Message | undefined;
|
|
449
|
+
/**
|
|
450
|
+
* Calculate total content length of messages
|
|
451
|
+
*/
|
|
452
|
+
declare function getTotalContentLength(messages: Message[]): number;
|
|
453
|
+
/**
|
|
454
|
+
* Truncate messages to fit within a token limit (approximate)
|
|
455
|
+
* Uses a simple character-based estimation (1 token ≈ 4 characters)
|
|
456
|
+
*/
|
|
457
|
+
declare function truncateMessages(messages: Message[], maxTokens: number, preserveSystem?: boolean): Message[];
|
|
458
|
+
/**
|
|
459
|
+
* Format messages for display/logging
|
|
460
|
+
*/
|
|
461
|
+
declare function formatMessagesForDisplay(messages: Message[]): string;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Abstract base class for LLM providers
|
|
465
|
+
* Each provider (OpenAI, Anthropic, etc.) must implement this interface
|
|
466
|
+
*/
|
|
467
|
+
declare abstract class BaseProvider {
|
|
468
|
+
protected config: ChatConfig;
|
|
469
|
+
abstract readonly name: ProviderType;
|
|
470
|
+
constructor(config: ChatConfig);
|
|
471
|
+
/**
|
|
472
|
+
* Send a message and get a complete response
|
|
473
|
+
*/
|
|
474
|
+
abstract sendMessage(messages: Message[], options: SendOptions): Promise<Message>;
|
|
475
|
+
/**
|
|
476
|
+
* Send a message and stream the response
|
|
477
|
+
*/
|
|
478
|
+
abstract sendMessageStream(messages: Message[], options: SendOptions): AsyncGenerator<StreamEvent>;
|
|
479
|
+
/**
|
|
480
|
+
* Convert internal message format to provider-specific format
|
|
481
|
+
*/
|
|
482
|
+
protected abstract formatMessages(messages: Message[]): unknown[];
|
|
483
|
+
/**
|
|
484
|
+
* Convert tool definitions to provider-specific format
|
|
485
|
+
*/
|
|
486
|
+
protected abstract formatTools(tools: ToolDefinition[]): unknown[];
|
|
487
|
+
/**
|
|
488
|
+
* Parse provider response into internal message format
|
|
489
|
+
*/
|
|
490
|
+
protected abstract parseResponse(response: unknown): Message;
|
|
491
|
+
/**
|
|
492
|
+
* Get the API endpoint URL
|
|
493
|
+
*/
|
|
494
|
+
protected abstract getEndpoint(model: string): string;
|
|
495
|
+
/**
|
|
496
|
+
* Get headers for API requests
|
|
497
|
+
*/
|
|
498
|
+
protected abstract getHeaders(): Record<string, string>;
|
|
499
|
+
/**
|
|
500
|
+
* Generate a unique message ID
|
|
501
|
+
*/
|
|
502
|
+
protected generateMessageId(): string;
|
|
503
|
+
/**
|
|
504
|
+
* Build the request body for API calls
|
|
505
|
+
*/
|
|
506
|
+
protected abstract buildRequestBody(messages: unknown[], options: SendOptions, tools?: unknown[]): unknown;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Provider registry for managing available providers
|
|
510
|
+
*/
|
|
511
|
+
declare class ProviderRegistry {
|
|
512
|
+
private providers;
|
|
513
|
+
register(provider: BaseProvider): void;
|
|
514
|
+
get(name: ProviderType): BaseProvider | undefined;
|
|
515
|
+
has(name: ProviderType): boolean;
|
|
516
|
+
getAll(): Map<ProviderType, BaseProvider>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Ollama message format
|
|
521
|
+
*/
|
|
522
|
+
interface OllamaMessage {
|
|
523
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
524
|
+
content: string;
|
|
525
|
+
tool_calls?: OllamaToolCall[];
|
|
526
|
+
}
|
|
527
|
+
interface OllamaToolCall {
|
|
528
|
+
function: {
|
|
529
|
+
name: string;
|
|
530
|
+
arguments: Record<string, unknown>;
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
interface OllamaTool {
|
|
534
|
+
type: 'function';
|
|
535
|
+
function: {
|
|
536
|
+
name: string;
|
|
537
|
+
description: string;
|
|
538
|
+
parameters: {
|
|
539
|
+
type: 'object';
|
|
540
|
+
properties: Record<string, unknown>;
|
|
541
|
+
required?: string[];
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
interface OllamaChatRequest {
|
|
546
|
+
model: string;
|
|
547
|
+
messages: OllamaMessage[];
|
|
548
|
+
stream?: boolean;
|
|
549
|
+
options?: {
|
|
550
|
+
temperature?: number;
|
|
551
|
+
num_predict?: number;
|
|
552
|
+
};
|
|
553
|
+
tools?: OllamaTool[];
|
|
554
|
+
}
|
|
555
|
+
interface OllamaChatResponse {
|
|
556
|
+
model: string;
|
|
557
|
+
message: OllamaMessage;
|
|
558
|
+
done: boolean;
|
|
559
|
+
done_reason?: string;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Ollama Provider implementation
|
|
563
|
+
* Connects to local Ollama server for running open-source models
|
|
564
|
+
*/
|
|
565
|
+
declare class OllamaProvider extends BaseProvider {
|
|
566
|
+
readonly name: ProviderType;
|
|
567
|
+
private baseUrl;
|
|
568
|
+
constructor(config: ChatConfig);
|
|
569
|
+
/**
|
|
570
|
+
* Send a message and get a complete response
|
|
571
|
+
*/
|
|
572
|
+
sendMessage(messages: Message[], options: SendOptions): Promise<Message>;
|
|
573
|
+
/**
|
|
574
|
+
* Send a message and stream the response
|
|
575
|
+
*/
|
|
576
|
+
sendMessageStream(messages: Message[], options: SendOptions): AsyncGenerator<StreamEvent>;
|
|
577
|
+
/**
|
|
578
|
+
* Convert internal message format to Ollama format
|
|
579
|
+
*/
|
|
580
|
+
protected formatMessages(messages: Message[]): OllamaMessage[];
|
|
581
|
+
/**
|
|
582
|
+
* Convert tool definitions to Ollama format
|
|
583
|
+
*/
|
|
584
|
+
protected formatTools(tools: ToolDefinition[]): OllamaTool[];
|
|
585
|
+
/**
|
|
586
|
+
* Parse Ollama response into internal message format
|
|
587
|
+
*/
|
|
588
|
+
protected parseResponse(response: OllamaChatResponse): Message;
|
|
589
|
+
/**
|
|
590
|
+
* Get the Ollama API endpoint
|
|
591
|
+
*/
|
|
592
|
+
protected getEndpoint(_model: string): string;
|
|
593
|
+
/**
|
|
594
|
+
* Get headers for Ollama API requests
|
|
595
|
+
*/
|
|
596
|
+
protected getHeaders(): Record<string, string>;
|
|
597
|
+
/**
|
|
598
|
+
* Build request body for Ollama API
|
|
599
|
+
*/
|
|
600
|
+
protected buildRequestBody(messages: unknown[], options: SendOptions, tools?: unknown[]): OllamaChatRequest;
|
|
601
|
+
/**
|
|
602
|
+
* List available models from Ollama
|
|
603
|
+
*/
|
|
604
|
+
listModels(): Promise<string[]>;
|
|
605
|
+
/**
|
|
606
|
+
* Check if Ollama server is available
|
|
607
|
+
*/
|
|
608
|
+
isAvailable(): Promise<boolean>;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Custom error classes for devdive-chatLLM
|
|
613
|
+
*/
|
|
614
|
+
declare class ChatLLMError extends Error {
|
|
615
|
+
constructor(message: string);
|
|
616
|
+
}
|
|
617
|
+
declare class ProviderError extends ChatLLMError {
|
|
618
|
+
provider: string;
|
|
619
|
+
statusCode?: number | undefined;
|
|
620
|
+
originalError?: Error | undefined;
|
|
621
|
+
constructor(provider: string, message: string, statusCode?: number | undefined, originalError?: Error | undefined);
|
|
622
|
+
}
|
|
623
|
+
declare class ConfigurationError extends ChatLLMError {
|
|
624
|
+
constructor(message: string);
|
|
625
|
+
}
|
|
626
|
+
declare class ToolExecutionError extends ChatLLMError {
|
|
627
|
+
toolName: string;
|
|
628
|
+
originalError?: Error | undefined;
|
|
629
|
+
constructor(toolName: string, message: string, originalError?: Error | undefined);
|
|
630
|
+
}
|
|
631
|
+
declare class StorageError extends ChatLLMError {
|
|
632
|
+
operation: 'read' | 'write' | 'delete';
|
|
633
|
+
originalError?: Error | undefined;
|
|
634
|
+
constructor(operation: 'read' | 'write' | 'delete', message: string, originalError?: Error | undefined);
|
|
635
|
+
}
|
|
636
|
+
declare class StreamError extends ChatLLMError {
|
|
637
|
+
originalError?: Error | undefined;
|
|
638
|
+
constructor(message: string, originalError?: Error | undefined);
|
|
639
|
+
}
|
|
640
|
+
declare class ValidationError extends ChatLLMError {
|
|
641
|
+
field: string;
|
|
642
|
+
constructor(field: string, message: string);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Wraps an error with provider context
|
|
646
|
+
*/
|
|
647
|
+
declare function wrapProviderError(provider: string, error: unknown, statusCode?: number): ProviderError;
|
|
648
|
+
/**
|
|
649
|
+
* Checks if an error is a specific type
|
|
650
|
+
*/
|
|
651
|
+
declare function isProviderError(error: unknown): error is ProviderError;
|
|
652
|
+
declare function isToolExecutionError(error: unknown): error is ToolExecutionError;
|
|
653
|
+
declare function isStorageError(error: unknown): error is StorageError;
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Parse Server-Sent Events (SSE) stream
|
|
657
|
+
*/
|
|
658
|
+
declare function parseSSEStream(response: Response): AsyncGenerator<string>;
|
|
659
|
+
/**
|
|
660
|
+
* Parse NDJSON (Newline Delimited JSON) stream - used by Ollama
|
|
661
|
+
*/
|
|
662
|
+
declare function parseNDJSONStream(response: Response): AsyncGenerator<unknown>;
|
|
663
|
+
/**
|
|
664
|
+
* Create a stream event helper
|
|
665
|
+
*/
|
|
666
|
+
declare function createStreamEvent(type: StreamEvent['type'], data?: Partial<Omit<StreamEvent, 'type'>>): StreamEvent;
|
|
667
|
+
/**
|
|
668
|
+
* Collect all stream events into a single message content
|
|
669
|
+
*/
|
|
670
|
+
declare function collectStreamContent(stream: AsyncGenerator<StreamEvent>): Promise<string>;
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Default configuration values
|
|
674
|
+
*/
|
|
675
|
+
declare const DEFAULT_STORAGE_PATH: string;
|
|
676
|
+
declare const DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434";
|
|
677
|
+
declare const DEFAULT_MODELS: Record<ProviderType, string>;
|
|
678
|
+
/**
|
|
679
|
+
* Validates provider configuration
|
|
680
|
+
*/
|
|
681
|
+
declare function validateProviderConfig(provider: ProviderType, config: ChatConfig): void;
|
|
682
|
+
/**
|
|
683
|
+
* Gets the base URL for a provider
|
|
684
|
+
*/
|
|
685
|
+
declare function getProviderBaseUrl(provider: ProviderType, config: ChatConfig): string;
|
|
686
|
+
/**
|
|
687
|
+
* Gets the default model for a provider
|
|
688
|
+
*/
|
|
689
|
+
declare function getDefaultModel(provider: ProviderType, config: ChatConfig): string;
|
|
690
|
+
/**
|
|
691
|
+
* Merges user config with defaults
|
|
692
|
+
*/
|
|
693
|
+
declare function mergeConfig(userConfig: ChatConfig): ChatConfig;
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* File-based storage for persisting data
|
|
697
|
+
*/
|
|
698
|
+
declare class FileStorage {
|
|
699
|
+
private basePath;
|
|
700
|
+
constructor(basePath: string);
|
|
701
|
+
/**
|
|
702
|
+
* Ensure a directory exists
|
|
703
|
+
*/
|
|
704
|
+
private ensureDirectory;
|
|
705
|
+
/**
|
|
706
|
+
* Get the full path for a key
|
|
707
|
+
*/
|
|
708
|
+
private getFilePath;
|
|
709
|
+
/**
|
|
710
|
+
* Read data from storage
|
|
711
|
+
*/
|
|
712
|
+
read<T>(key: string): T | null;
|
|
713
|
+
/**
|
|
714
|
+
* Write data to storage
|
|
715
|
+
*/
|
|
716
|
+
write<T>(key: string, data: T): void;
|
|
717
|
+
/**
|
|
718
|
+
* Delete data from storage
|
|
719
|
+
*/
|
|
720
|
+
delete(key: string): boolean;
|
|
721
|
+
/**
|
|
722
|
+
* Check if a key exists
|
|
723
|
+
*/
|
|
724
|
+
exists(key: string): boolean;
|
|
725
|
+
/**
|
|
726
|
+
* Get the base path
|
|
727
|
+
*/
|
|
728
|
+
getBasePath(): string;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* In-memory storage (for testing or temporary use)
|
|
732
|
+
*/
|
|
733
|
+
declare class MemoryStorage {
|
|
734
|
+
private data;
|
|
735
|
+
read<T>(key: string): T | null;
|
|
736
|
+
write<T>(key: string, data: T): void;
|
|
737
|
+
delete(key: string): boolean;
|
|
738
|
+
exists(key: string): boolean;
|
|
739
|
+
clear(): void;
|
|
740
|
+
getAll(): Map<string, unknown>;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Storage interface for polymorphism
|
|
744
|
+
*/
|
|
745
|
+
interface Storage {
|
|
746
|
+
read<T>(key: string): T | null;
|
|
747
|
+
write<T>(key: string, data: T): void;
|
|
748
|
+
delete(key: string): boolean;
|
|
749
|
+
exists(key: string): boolean;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Global memory store - shared across all chats
|
|
754
|
+
*/
|
|
755
|
+
declare class GlobalMemoryStore {
|
|
756
|
+
private entries;
|
|
757
|
+
private storage;
|
|
758
|
+
private storageKey;
|
|
759
|
+
private autoSave;
|
|
760
|
+
constructor(storagePath?: string, autoSave?: boolean);
|
|
761
|
+
/**
|
|
762
|
+
* Load entries from storage
|
|
763
|
+
*/
|
|
764
|
+
private load;
|
|
765
|
+
/**
|
|
766
|
+
* Save entries to storage
|
|
767
|
+
*/
|
|
768
|
+
private save;
|
|
769
|
+
/**
|
|
770
|
+
* Set a memory entry
|
|
771
|
+
*/
|
|
772
|
+
set(key: string, value: unknown): void;
|
|
773
|
+
/**
|
|
774
|
+
* Get a memory entry value
|
|
775
|
+
*/
|
|
776
|
+
get<T = unknown>(key: string): T | undefined;
|
|
777
|
+
/**
|
|
778
|
+
* Get a memory entry with metadata
|
|
779
|
+
*/
|
|
780
|
+
getEntry(key: string): MemoryEntry | undefined;
|
|
781
|
+
/**
|
|
782
|
+
* Check if a key exists
|
|
783
|
+
*/
|
|
784
|
+
has(key: string): boolean;
|
|
785
|
+
/**
|
|
786
|
+
* Delete a memory entry
|
|
787
|
+
*/
|
|
788
|
+
delete(key: string): boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Get all memory entries
|
|
791
|
+
*/
|
|
792
|
+
getAll(): Map<string, MemoryEntry>;
|
|
793
|
+
/**
|
|
794
|
+
* Get all keys
|
|
795
|
+
*/
|
|
796
|
+
keys(): string[];
|
|
797
|
+
/**
|
|
798
|
+
* Clear all entries
|
|
799
|
+
*/
|
|
800
|
+
clear(): void;
|
|
801
|
+
/**
|
|
802
|
+
* Get entries count
|
|
803
|
+
*/
|
|
804
|
+
size(): number;
|
|
805
|
+
/**
|
|
806
|
+
* Force save to storage
|
|
807
|
+
*/
|
|
808
|
+
forceSave(): void;
|
|
809
|
+
/**
|
|
810
|
+
* Convert entries to a format suitable for system prompt injection
|
|
811
|
+
*/
|
|
812
|
+
toPromptContext(): string;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Initialize global memory with storage path
|
|
816
|
+
*/
|
|
817
|
+
declare function initGlobalMemory(storagePath?: string, autoSave?: boolean): void;
|
|
818
|
+
/**
|
|
819
|
+
* Get global memory instance
|
|
820
|
+
*/
|
|
821
|
+
declare function getGlobalMemoryStore(): GlobalMemoryStore;
|
|
822
|
+
/**
|
|
823
|
+
* Set a global memory value
|
|
824
|
+
*/
|
|
825
|
+
declare function setGlobalMemory(key: string, value: unknown): void;
|
|
826
|
+
/**
|
|
827
|
+
* Get a global memory value
|
|
828
|
+
*/
|
|
829
|
+
declare function getGlobalMemory<T = unknown>(key: string): T | undefined;
|
|
830
|
+
/**
|
|
831
|
+
* Delete a global memory entry
|
|
832
|
+
*/
|
|
833
|
+
declare function deleteGlobalMemory(key: string): boolean;
|
|
834
|
+
/**
|
|
835
|
+
* Check if a global memory key exists
|
|
836
|
+
*/
|
|
837
|
+
declare function hasGlobalMemory(key: string): boolean;
|
|
838
|
+
/**
|
|
839
|
+
* Get all global memory keys
|
|
840
|
+
*/
|
|
841
|
+
declare function getGlobalMemoryKeys(): string[];
|
|
842
|
+
/**
|
|
843
|
+
* Clear all global memory
|
|
844
|
+
*/
|
|
845
|
+
declare function clearGlobalMemory(): void;
|
|
846
|
+
/**
|
|
847
|
+
* Get global memory as prompt context
|
|
848
|
+
*/
|
|
849
|
+
declare function getGlobalMemoryContext(): string;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Initialize chat memory with storage path
|
|
853
|
+
*/
|
|
854
|
+
declare function initChatMemory(storagePath?: string, autoSave?: boolean): void;
|
|
855
|
+
/**
|
|
856
|
+
* Set a chat memory value
|
|
857
|
+
*/
|
|
858
|
+
declare function setChatMemory(chat: Chat, key: string, value: unknown): void;
|
|
859
|
+
/**
|
|
860
|
+
* Get a chat memory value
|
|
861
|
+
*/
|
|
862
|
+
declare function getChatMemory<T = unknown>(chat: Chat, key: string): T | undefined;
|
|
863
|
+
/**
|
|
864
|
+
* Delete a chat memory entry
|
|
865
|
+
*/
|
|
866
|
+
declare function deleteChatMemory(chat: Chat, key: string): boolean;
|
|
867
|
+
/**
|
|
868
|
+
* Check if a chat memory key exists
|
|
869
|
+
*/
|
|
870
|
+
declare function hasChatMemory(chat: Chat, key: string): boolean;
|
|
871
|
+
/**
|
|
872
|
+
* Get all chat memory keys
|
|
873
|
+
*/
|
|
874
|
+
declare function getChatMemoryKeys(chat: Chat): string[];
|
|
875
|
+
/**
|
|
876
|
+
* Clear all chat memory
|
|
877
|
+
*/
|
|
878
|
+
declare function clearChatMemory(chat: Chat): void;
|
|
879
|
+
/**
|
|
880
|
+
* Get chat memory as prompt context
|
|
881
|
+
*/
|
|
882
|
+
declare function getChatMemoryContext(chat: Chat): string;
|
|
883
|
+
/**
|
|
884
|
+
* Sync chat's internal memory to persistent storage
|
|
885
|
+
*/
|
|
886
|
+
declare function syncChatMemory(chat: Chat): void;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Memory manager configuration
|
|
890
|
+
*/
|
|
891
|
+
interface MemoryManagerConfig {
|
|
892
|
+
storagePath?: string;
|
|
893
|
+
autoSave?: boolean;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Initialize memory system
|
|
897
|
+
*/
|
|
898
|
+
declare function initMemory(config?: MemoryManagerConfig): void;
|
|
899
|
+
/**
|
|
900
|
+
* Get combined memory context for prompt injection
|
|
901
|
+
* Combines global memory and chat-specific memory
|
|
902
|
+
*/
|
|
903
|
+
declare function getMemoryContext(chat: Chat): string;
|
|
904
|
+
/**
|
|
905
|
+
* Build a system prompt with memory context injected
|
|
906
|
+
*/
|
|
907
|
+
declare function buildSystemPromptWithMemory(basePrompt: string, chat: Chat): string;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Task extraction result from LLM
|
|
911
|
+
*/
|
|
912
|
+
interface TaskExtractionResult {
|
|
913
|
+
tasks: ExtractedTask[];
|
|
914
|
+
preferences: ExtractedPreference[];
|
|
915
|
+
}
|
|
916
|
+
interface ExtractedTask {
|
|
917
|
+
description: string;
|
|
918
|
+
status: TaskStatus;
|
|
919
|
+
progress: number;
|
|
920
|
+
}
|
|
921
|
+
interface ExtractedPreference {
|
|
922
|
+
key: string;
|
|
923
|
+
value: unknown;
|
|
924
|
+
confidence: number;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Learning input for SOP generation
|
|
928
|
+
*/
|
|
929
|
+
interface LearningInput {
|
|
930
|
+
taskDescription: string;
|
|
931
|
+
conversationSummary: string;
|
|
932
|
+
outcome: 'success' | 'failure' | 'partial';
|
|
933
|
+
steps: LearningStep[];
|
|
934
|
+
}
|
|
935
|
+
interface LearningStep {
|
|
936
|
+
userInput: string;
|
|
937
|
+
assistantOutput: string;
|
|
938
|
+
toolsUsed?: string[];
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Skill search options
|
|
942
|
+
*/
|
|
943
|
+
interface SkillSearchOptions {
|
|
944
|
+
category?: string;
|
|
945
|
+
minSuccessRate?: number;
|
|
946
|
+
limit?: number;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Skill application result
|
|
950
|
+
*/
|
|
951
|
+
interface SkillApplicationResult {
|
|
952
|
+
applied: boolean;
|
|
953
|
+
skillId: string;
|
|
954
|
+
suggestedPrompt?: string;
|
|
955
|
+
error?: string;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Observer event types
|
|
959
|
+
*/
|
|
960
|
+
type ObserverEventType = 'task_detected' | 'task_updated' | 'preference_detected' | 'learning_triggered';
|
|
961
|
+
interface ObserverEvent {
|
|
962
|
+
type: ObserverEventType;
|
|
963
|
+
timestamp: number;
|
|
964
|
+
data: ObservedTask | UserPreference | LearnedSkill;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Observer callback function
|
|
968
|
+
*/
|
|
969
|
+
type ObserverCallback = (event: ObserverEvent) => void;
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Enable observer for a chat
|
|
973
|
+
*/
|
|
974
|
+
declare function enableObserver(chat: Chat, config?: Partial<ObserverConfig>): void;
|
|
975
|
+
/**
|
|
976
|
+
* Disable observer for a chat
|
|
977
|
+
*/
|
|
978
|
+
declare function disableObserver(chat: Chat): void;
|
|
979
|
+
/**
|
|
980
|
+
* Check if observer is enabled
|
|
981
|
+
*/
|
|
982
|
+
declare function isObserverEnabled(chat: Chat): boolean;
|
|
983
|
+
/**
|
|
984
|
+
* Get observer configuration
|
|
985
|
+
*/
|
|
986
|
+
declare function getObserverConfig(chat: Chat): ObserverConfig;
|
|
987
|
+
/**
|
|
988
|
+
* Register an observer callback
|
|
989
|
+
*/
|
|
990
|
+
declare function onObserverEvent(chat: Chat, callback: ObserverCallback): () => void;
|
|
991
|
+
/**
|
|
992
|
+
* Analyze messages and extract tasks/preferences
|
|
993
|
+
* This is a simplified local extraction - in production, you might use LLM for this
|
|
994
|
+
*/
|
|
995
|
+
declare function analyzeMessages(chat: Chat, messages?: Message[]): TaskExtractionResult;
|
|
996
|
+
/**
|
|
997
|
+
* Process new messages and update observer state
|
|
998
|
+
*/
|
|
999
|
+
declare function processMessages(chat: Chat, newMessages: Message[]): void;
|
|
1000
|
+
/**
|
|
1001
|
+
* Get observed tasks for a chat
|
|
1002
|
+
*/
|
|
1003
|
+
declare function getObservedTasks(chat: Chat): ObservedTask[];
|
|
1004
|
+
/**
|
|
1005
|
+
* Get observed preferences for a chat
|
|
1006
|
+
*/
|
|
1007
|
+
declare function getObservedPreferences(chat: Chat): UserPreference[];
|
|
1008
|
+
/**
|
|
1009
|
+
* Update a task's status
|
|
1010
|
+
*/
|
|
1011
|
+
declare function updateTaskStatus(chat: Chat, taskId: string, status: ObservedTask['status'], progress?: number): boolean;
|
|
1012
|
+
/**
|
|
1013
|
+
* Clear observer state for a chat
|
|
1014
|
+
*/
|
|
1015
|
+
declare function clearObserverState(chat: Chat): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Get full observer state (for debugging/export)
|
|
1018
|
+
*/
|
|
1019
|
+
declare function getObserverState(chat: Chat): ObserverState;
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Initialize the learner
|
|
1023
|
+
*/
|
|
1024
|
+
declare function initLearner(storagePath?: string): void;
|
|
1025
|
+
/**
|
|
1026
|
+
* Learn from a completed conversation
|
|
1027
|
+
*/
|
|
1028
|
+
declare function learnFromConversation(chat: Chat, taskDescription: string, outcome?: 'success' | 'failure' | 'partial'): LearnedSkill;
|
|
1029
|
+
/**
|
|
1030
|
+
* Get all learned skills
|
|
1031
|
+
*/
|
|
1032
|
+
declare function getLearnedSkills(category?: string): LearnedSkill[];
|
|
1033
|
+
/**
|
|
1034
|
+
* Search learned skills
|
|
1035
|
+
*/
|
|
1036
|
+
declare function searchLearnedSkills(keyword: string): LearnedSkill[];
|
|
1037
|
+
/**
|
|
1038
|
+
* Get a specific skill
|
|
1039
|
+
*/
|
|
1040
|
+
declare function getLearnedSkill(skillId: string): LearnedSkill | undefined;
|
|
1041
|
+
/**
|
|
1042
|
+
* Record skill usage result
|
|
1043
|
+
*/
|
|
1044
|
+
declare function recordSkillUsage(skillId: string, success: boolean): void;
|
|
1045
|
+
/**
|
|
1046
|
+
* Delete a learned skill
|
|
1047
|
+
*/
|
|
1048
|
+
declare function deleteLearnedSkill(skillId: string): boolean;
|
|
1049
|
+
/**
|
|
1050
|
+
* Clear all learned skills
|
|
1051
|
+
*/
|
|
1052
|
+
declare function clearLearnedSkills(): void;
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Search for relevant skills based on user input
|
|
1056
|
+
*/
|
|
1057
|
+
declare function findRelevantSkills(query: string, options?: SkillSearchOptions): LearnedSkill[];
|
|
1058
|
+
/**
|
|
1059
|
+
* Apply a skill to a chat by generating a suggested prompt
|
|
1060
|
+
*/
|
|
1061
|
+
declare function applySkill(_chat: Chat, skill: LearnedSkill): SkillApplicationResult;
|
|
1062
|
+
/**
|
|
1063
|
+
* Apply a skill and inject it into system prompt
|
|
1064
|
+
*/
|
|
1065
|
+
declare function applySkillToSystemPrompt(chat: Chat, skill: LearnedSkill, baseSystemPrompt: string): string;
|
|
1066
|
+
/**
|
|
1067
|
+
* Get best matching skill for a query
|
|
1068
|
+
*/
|
|
1069
|
+
declare function getBestSkill(query: string, options?: SkillSearchOptions): LearnedSkill | undefined;
|
|
1070
|
+
/**
|
|
1071
|
+
* Suggest skills based on conversation context
|
|
1072
|
+
*/
|
|
1073
|
+
declare function suggestSkills(chat: Chat, limit?: number): LearnedSkill[];
|
|
1074
|
+
/**
|
|
1075
|
+
* Record that a skill was used and whether it was successful
|
|
1076
|
+
*/
|
|
1077
|
+
declare function recordSkillApplication(skillId: string, success: boolean): void;
|
|
1078
|
+
/**
|
|
1079
|
+
* Track skill application
|
|
1080
|
+
*/
|
|
1081
|
+
declare function trackSkillApplication(chatId: string, skillId: string): void;
|
|
1082
|
+
/**
|
|
1083
|
+
* Update skill application success
|
|
1084
|
+
*/
|
|
1085
|
+
declare function updateSkillApplicationSuccess(chatId: string, skillId: string, success: boolean): void;
|
|
1086
|
+
/**
|
|
1087
|
+
* Get skill application history for a chat
|
|
1088
|
+
*/
|
|
1089
|
+
declare function getSkillApplicationHistory(chatId: string): Array<{
|
|
1090
|
+
skillId: string;
|
|
1091
|
+
appliedAt: number;
|
|
1092
|
+
success?: boolean;
|
|
1093
|
+
}>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Clear skill application history for a chat
|
|
1096
|
+
*/
|
|
1097
|
+
declare function clearSkillApplicationHistory(chatId: string): void;
|
|
1098
|
+
|
|
1099
|
+
export { type AnthropicConfig, BaseProvider, type Chat, type ChatConfig, ChatLLMError, ConfigurationError, DEFAULT_MODELS, DEFAULT_OLLAMA_BASE_URL, DEFAULT_PERSONALIZATION, DEFAULT_STORAGE_PATH, type ExtractedPreference, type ExtractedTask, FileStorage, type FormattingStyle, type GlobalMemoryStore$1 as GlobalMemoryStore, type GoogleConfig, type LLMActionConfig, type LLMChatComponentProps, type LLMChatHookConfig, type LLMToolConfig, type LearnedSkill, type LearningInput, type LearningStep, type MemoryEntry, type MemoryManagerConfig, MemoryStorage, type Message, type MutationResult, type NaverConfig, type ObservedTask, type ObserverCallback, type ObserverConfig, type ObserverEvent, type ObserverEventType, type ObserverState, type OllamaConfig, OllamaProvider, type OpenAIConfig, type ParameterSchema, type PersonalizationConfig, type ProviderConfigs, ProviderError, ProviderRegistry, type ProviderType, type ResponseStyle, type Role, type SendOptions, type Session, type SkillApplicationResult, type SkillSearchOptions, type SkillStep, type Storage, StorageError, StreamError, type StreamEvent, type StreamEventType, type StyleLevel, type TaskExtractionResult, type TaskStatus, type ToolCall, type ToolDefinition, ToolExecutionError, type ToolHook, type ToolResult, type UserPreference, type UserProfile, ValidationError, addMessage as addSessionMessage, addMessages as addSessionMessages, analyzeMessages, applySkill, applySkillToSystemPrompt, buildSystemPromptWithMemory, clearChatMemory, clearGlobalMemory, clearLearnedSkills, clearMessages, clearObserverState, clearMessages$1 as clearSessionMessages, clearSkillApplicationHistory, cloneMessage, collectStreamContent, createAssistantMessage, createChat, createMessage, createSession, createStreamEvent, createSystemMessage, createToolMessage, createUserMessage, deleteChatMemory, deleteGlobalMemory, deleteLearnedSkill, deserializeSession, destroyChat, disableObserver, enableObserver, filterByProvider, filterByRole, findRelevantSkills, formatMessagesForDisplay, getBestSkill, getChatMemory, getChatMemoryContext, getChatMemoryKeys, getDefaultModel, getGlobalMemory, getGlobalMemoryContext, getGlobalMemoryKeys, getGlobalMemoryStore, getLastMessageByRole, getLastMessages, getLearnedSkill, getLearnedSkills, getMemoryContext, getMessages, getMessagesAfter, getMessagesForProvider, getObservedPreferences, getObservedTasks, getObserverConfig, getObserverState, getProviderBaseUrl, getSession, getSessionSummary, getSkillApplicationHistory, getTools, getTotalContentLength, hasChatMemory, hasGlobalMemory, initChatMemory, initGlobalMemory, initLearner, initMemory, isObserverEnabled, isProviderError, isStorageError, isToolExecutionError, learnFromConversation, mergeConfig, onObserverEvent, parseNDJSONStream, parseSSEStream, processMessages, recordSkillApplication, recordSkillUsage, registerTool, resetChat, searchLearnedSkills, sendMessage, sendMessageStream, serializeSession, setChatMemory, setGlobalMemory, setSessionMetadata, setSystemPrompt$1 as setSessionSystemPrompt, setSystemPrompt, suggestSkills, syncChatMemory, trackSkillApplication, truncateMessages, unregisterTool, updateSkillApplicationSuccess, updateTaskStatus, validateProviderConfig, wrapProviderError };
|