@superatomai/sdk-node 0.0.1-mds
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/README.md +942 -0
- package/dist/index.d.mts +2540 -0
- package/dist/index.d.ts +2540 -0
- package/dist/index.js +14290 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +14232 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2540 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unified UIBlock structure for database storage
|
|
6
|
+
* Used in both bookmarks and user-conversations tables
|
|
7
|
+
*/
|
|
8
|
+
interface DBUIBlock {
|
|
9
|
+
id: string;
|
|
10
|
+
component: Record<string, any> | null;
|
|
11
|
+
analysis: string | null;
|
|
12
|
+
user_prompt: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Log levels in hierarchical order
|
|
17
|
+
* - errors: only error logs
|
|
18
|
+
* - warnings: warning + error logs
|
|
19
|
+
* - info: info + warning + error logs
|
|
20
|
+
* - verbose: all logs including debug
|
|
21
|
+
*/
|
|
22
|
+
type LogLevel = 'errors' | 'warnings' | 'info' | 'verbose';
|
|
23
|
+
/**
|
|
24
|
+
* Logger class with environment-based log level support
|
|
25
|
+
*/
|
|
26
|
+
declare class Logger {
|
|
27
|
+
private currentLevel;
|
|
28
|
+
private currentLevelPriority;
|
|
29
|
+
constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Check if a string is a valid log level
|
|
32
|
+
*/
|
|
33
|
+
private isValidLogLevel;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a message should be logged based on current log level
|
|
36
|
+
*/
|
|
37
|
+
private shouldLog;
|
|
38
|
+
/**
|
|
39
|
+
* Get current log level
|
|
40
|
+
*/
|
|
41
|
+
getLogLevel(): LogLevel;
|
|
42
|
+
/**
|
|
43
|
+
* Set log level programmatically
|
|
44
|
+
*/
|
|
45
|
+
setLogLevel(level: LogLevel): void;
|
|
46
|
+
/**
|
|
47
|
+
* Log info message (shown for info and verbose levels)
|
|
48
|
+
*/
|
|
49
|
+
info(...args: any[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Log error message (shown for all levels)
|
|
52
|
+
*/
|
|
53
|
+
error(...args: any[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* Log warning message (shown for warnings, info, and verbose levels)
|
|
56
|
+
*/
|
|
57
|
+
warn(...args: any[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* Log debug message (only shown for verbose level)
|
|
60
|
+
*/
|
|
61
|
+
debug(...args: any[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Write to log file
|
|
64
|
+
*/
|
|
65
|
+
file(...args: any[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Clear the log file (call at start of new user request)
|
|
68
|
+
*/
|
|
69
|
+
clearFile(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Log LLM method prompts with clear labeling
|
|
72
|
+
*/
|
|
73
|
+
logLLMPrompt(methodName: string, promptType: 'system' | 'user', content: string | object | any[]): void;
|
|
74
|
+
}
|
|
75
|
+
declare const logger: Logger;
|
|
76
|
+
|
|
77
|
+
declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
78
|
+
dsl: z.ZodObject<{
|
|
79
|
+
id: z.ZodString;
|
|
80
|
+
name: z.ZodOptional<z.ZodString>;
|
|
81
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
82
|
+
states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
83
|
+
methods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
84
|
+
fn: z.ZodString;
|
|
85
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
fn: string;
|
|
88
|
+
params?: Record<string, any> | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
fn: string;
|
|
91
|
+
params?: Record<string, any> | undefined;
|
|
92
|
+
}>>>;
|
|
93
|
+
effects: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
94
|
+
fn: z.ZodString;
|
|
95
|
+
deps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
fn: string;
|
|
98
|
+
deps?: string[] | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
fn: string;
|
|
101
|
+
deps?: string[] | undefined;
|
|
102
|
+
}>, "many">>;
|
|
103
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
104
|
+
render: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
|
|
105
|
+
pages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
name: z.ZodString;
|
|
108
|
+
order: z.ZodNumber;
|
|
109
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
110
|
+
render: z.ZodType<any, z.ZodTypeDef, any>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
order: number;
|
|
115
|
+
icon?: string | undefined;
|
|
116
|
+
render?: any;
|
|
117
|
+
}, {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
order: number;
|
|
121
|
+
icon?: string | undefined;
|
|
122
|
+
render?: any;
|
|
123
|
+
}>, "many">>;
|
|
124
|
+
defaultPageId: z.ZodOptional<z.ZodString>;
|
|
125
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
graphql: z.ZodOptional<z.ZodString>;
|
|
127
|
+
sql: z.ZodOptional<z.ZodString>;
|
|
128
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
129
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
130
|
+
key: z.ZodOptional<z.ZodString>;
|
|
131
|
+
refetchPolicy: z.ZodOptional<z.ZodEnum<["cache-first", "network-only", "cache-and-network"]>>;
|
|
132
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
params?: Record<string, any> | undefined;
|
|
135
|
+
key?: string | undefined;
|
|
136
|
+
graphql?: string | undefined;
|
|
137
|
+
sql?: string | undefined;
|
|
138
|
+
variables?: Record<string, any> | undefined;
|
|
139
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
140
|
+
dependencies?: string[] | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
params?: Record<string, any> | undefined;
|
|
143
|
+
key?: string | undefined;
|
|
144
|
+
graphql?: string | undefined;
|
|
145
|
+
sql?: string | undefined;
|
|
146
|
+
variables?: Record<string, any> | undefined;
|
|
147
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
148
|
+
dependencies?: string[] | undefined;
|
|
149
|
+
}>>;
|
|
150
|
+
}, "strip", z.ZodTypeAny, {
|
|
151
|
+
id: string;
|
|
152
|
+
name?: string | undefined;
|
|
153
|
+
query?: {
|
|
154
|
+
params?: Record<string, any> | undefined;
|
|
155
|
+
key?: string | undefined;
|
|
156
|
+
graphql?: string | undefined;
|
|
157
|
+
sql?: string | undefined;
|
|
158
|
+
variables?: Record<string, any> | undefined;
|
|
159
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
160
|
+
dependencies?: string[] | undefined;
|
|
161
|
+
} | undefined;
|
|
162
|
+
props?: Record<string, any> | undefined;
|
|
163
|
+
render?: any;
|
|
164
|
+
states?: Record<string, any> | undefined;
|
|
165
|
+
methods?: Record<string, {
|
|
166
|
+
fn: string;
|
|
167
|
+
params?: Record<string, any> | undefined;
|
|
168
|
+
}> | undefined;
|
|
169
|
+
effects?: {
|
|
170
|
+
fn: string;
|
|
171
|
+
deps?: string[] | undefined;
|
|
172
|
+
}[] | undefined;
|
|
173
|
+
data?: Record<string, any> | undefined;
|
|
174
|
+
pages?: {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
order: number;
|
|
178
|
+
icon?: string | undefined;
|
|
179
|
+
render?: any;
|
|
180
|
+
}[] | undefined;
|
|
181
|
+
defaultPageId?: string | undefined;
|
|
182
|
+
}, {
|
|
183
|
+
id: string;
|
|
184
|
+
name?: string | undefined;
|
|
185
|
+
query?: {
|
|
186
|
+
params?: Record<string, any> | undefined;
|
|
187
|
+
key?: string | undefined;
|
|
188
|
+
graphql?: string | undefined;
|
|
189
|
+
sql?: string | undefined;
|
|
190
|
+
variables?: Record<string, any> | undefined;
|
|
191
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
192
|
+
dependencies?: string[] | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
props?: Record<string, any> | undefined;
|
|
195
|
+
render?: any;
|
|
196
|
+
states?: Record<string, any> | undefined;
|
|
197
|
+
methods?: Record<string, {
|
|
198
|
+
fn: string;
|
|
199
|
+
params?: Record<string, any> | undefined;
|
|
200
|
+
}> | undefined;
|
|
201
|
+
effects?: {
|
|
202
|
+
fn: string;
|
|
203
|
+
deps?: string[] | undefined;
|
|
204
|
+
}[] | undefined;
|
|
205
|
+
data?: Record<string, any> | undefined;
|
|
206
|
+
pages?: {
|
|
207
|
+
id: string;
|
|
208
|
+
name: string;
|
|
209
|
+
order: number;
|
|
210
|
+
icon?: string | undefined;
|
|
211
|
+
render?: any;
|
|
212
|
+
}[] | undefined;
|
|
213
|
+
defaultPageId?: string | undefined;
|
|
214
|
+
}>;
|
|
215
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
216
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
dsl: {
|
|
219
|
+
id: string;
|
|
220
|
+
name?: string | undefined;
|
|
221
|
+
query?: {
|
|
222
|
+
params?: Record<string, any> | undefined;
|
|
223
|
+
key?: string | undefined;
|
|
224
|
+
graphql?: string | undefined;
|
|
225
|
+
sql?: string | undefined;
|
|
226
|
+
variables?: Record<string, any> | undefined;
|
|
227
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
228
|
+
dependencies?: string[] | undefined;
|
|
229
|
+
} | undefined;
|
|
230
|
+
props?: Record<string, any> | undefined;
|
|
231
|
+
render?: any;
|
|
232
|
+
states?: Record<string, any> | undefined;
|
|
233
|
+
methods?: Record<string, {
|
|
234
|
+
fn: string;
|
|
235
|
+
params?: Record<string, any> | undefined;
|
|
236
|
+
}> | undefined;
|
|
237
|
+
effects?: {
|
|
238
|
+
fn: string;
|
|
239
|
+
deps?: string[] | undefined;
|
|
240
|
+
}[] | undefined;
|
|
241
|
+
data?: Record<string, any> | undefined;
|
|
242
|
+
pages?: {
|
|
243
|
+
id: string;
|
|
244
|
+
name: string;
|
|
245
|
+
order: number;
|
|
246
|
+
icon?: string | undefined;
|
|
247
|
+
render?: any;
|
|
248
|
+
}[] | undefined;
|
|
249
|
+
defaultPageId?: string | undefined;
|
|
250
|
+
};
|
|
251
|
+
data?: Record<string, any> | undefined;
|
|
252
|
+
context?: Record<string, any> | undefined;
|
|
253
|
+
}, {
|
|
254
|
+
dsl: {
|
|
255
|
+
id: string;
|
|
256
|
+
name?: string | undefined;
|
|
257
|
+
query?: {
|
|
258
|
+
params?: Record<string, any> | undefined;
|
|
259
|
+
key?: string | undefined;
|
|
260
|
+
graphql?: string | undefined;
|
|
261
|
+
sql?: string | undefined;
|
|
262
|
+
variables?: Record<string, any> | undefined;
|
|
263
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
264
|
+
dependencies?: string[] | undefined;
|
|
265
|
+
} | undefined;
|
|
266
|
+
props?: Record<string, any> | undefined;
|
|
267
|
+
render?: any;
|
|
268
|
+
states?: Record<string, any> | undefined;
|
|
269
|
+
methods?: Record<string, {
|
|
270
|
+
fn: string;
|
|
271
|
+
params?: Record<string, any> | undefined;
|
|
272
|
+
}> | undefined;
|
|
273
|
+
effects?: {
|
|
274
|
+
fn: string;
|
|
275
|
+
deps?: string[] | undefined;
|
|
276
|
+
}[] | undefined;
|
|
277
|
+
data?: Record<string, any> | undefined;
|
|
278
|
+
pages?: {
|
|
279
|
+
id: string;
|
|
280
|
+
name: string;
|
|
281
|
+
order: number;
|
|
282
|
+
icon?: string | undefined;
|
|
283
|
+
render?: any;
|
|
284
|
+
}[] | undefined;
|
|
285
|
+
defaultPageId?: string | undefined;
|
|
286
|
+
};
|
|
287
|
+
data?: Record<string, any> | undefined;
|
|
288
|
+
context?: Record<string, any> | undefined;
|
|
289
|
+
}>;
|
|
290
|
+
type DSLRendererProps$1 = z.infer<typeof DSLRendererPropsSchema$1>;
|
|
291
|
+
|
|
292
|
+
declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
293
|
+
dsl: z.ZodObject<{
|
|
294
|
+
id: z.ZodString;
|
|
295
|
+
name: z.ZodOptional<z.ZodString>;
|
|
296
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
297
|
+
states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
298
|
+
methods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
299
|
+
fn: z.ZodString;
|
|
300
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
301
|
+
}, "strip", z.ZodTypeAny, {
|
|
302
|
+
fn: string;
|
|
303
|
+
params?: Record<string, any> | undefined;
|
|
304
|
+
}, {
|
|
305
|
+
fn: string;
|
|
306
|
+
params?: Record<string, any> | undefined;
|
|
307
|
+
}>>>;
|
|
308
|
+
effects: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
309
|
+
fn: z.ZodString;
|
|
310
|
+
deps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
311
|
+
}, "strip", z.ZodTypeAny, {
|
|
312
|
+
fn: string;
|
|
313
|
+
deps?: string[] | undefined;
|
|
314
|
+
}, {
|
|
315
|
+
fn: string;
|
|
316
|
+
deps?: string[] | undefined;
|
|
317
|
+
}>, "many">>;
|
|
318
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
319
|
+
render: z.ZodType<any, z.ZodTypeDef, any>;
|
|
320
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
321
|
+
graphql: z.ZodOptional<z.ZodString>;
|
|
322
|
+
sql: z.ZodOptional<z.ZodString>;
|
|
323
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
324
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
325
|
+
key: z.ZodOptional<z.ZodString>;
|
|
326
|
+
refetchPolicy: z.ZodOptional<z.ZodEnum<["cache-first", "network-only", "cache-and-network"]>>;
|
|
327
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
328
|
+
}, "strip", z.ZodTypeAny, {
|
|
329
|
+
params?: Record<string, any> | undefined;
|
|
330
|
+
key?: string | undefined;
|
|
331
|
+
graphql?: string | undefined;
|
|
332
|
+
sql?: string | undefined;
|
|
333
|
+
variables?: Record<string, any> | undefined;
|
|
334
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
335
|
+
dependencies?: string[] | undefined;
|
|
336
|
+
}, {
|
|
337
|
+
params?: Record<string, any> | undefined;
|
|
338
|
+
key?: string | undefined;
|
|
339
|
+
graphql?: string | undefined;
|
|
340
|
+
sql?: string | undefined;
|
|
341
|
+
variables?: Record<string, any> | undefined;
|
|
342
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
343
|
+
dependencies?: string[] | undefined;
|
|
344
|
+
}>>;
|
|
345
|
+
}, "strip", z.ZodTypeAny, {
|
|
346
|
+
id: string;
|
|
347
|
+
name?: string | undefined;
|
|
348
|
+
query?: {
|
|
349
|
+
params?: Record<string, any> | undefined;
|
|
350
|
+
key?: string | undefined;
|
|
351
|
+
graphql?: string | undefined;
|
|
352
|
+
sql?: string | undefined;
|
|
353
|
+
variables?: Record<string, any> | undefined;
|
|
354
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
355
|
+
dependencies?: string[] | undefined;
|
|
356
|
+
} | undefined;
|
|
357
|
+
props?: Record<string, any> | undefined;
|
|
358
|
+
render?: any;
|
|
359
|
+
states?: Record<string, any> | undefined;
|
|
360
|
+
methods?: Record<string, {
|
|
361
|
+
fn: string;
|
|
362
|
+
params?: Record<string, any> | undefined;
|
|
363
|
+
}> | undefined;
|
|
364
|
+
effects?: {
|
|
365
|
+
fn: string;
|
|
366
|
+
deps?: string[] | undefined;
|
|
367
|
+
}[] | undefined;
|
|
368
|
+
data?: Record<string, any> | undefined;
|
|
369
|
+
}, {
|
|
370
|
+
id: string;
|
|
371
|
+
name?: string | undefined;
|
|
372
|
+
query?: {
|
|
373
|
+
params?: Record<string, any> | undefined;
|
|
374
|
+
key?: string | undefined;
|
|
375
|
+
graphql?: string | undefined;
|
|
376
|
+
sql?: string | undefined;
|
|
377
|
+
variables?: Record<string, any> | undefined;
|
|
378
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
379
|
+
dependencies?: string[] | undefined;
|
|
380
|
+
} | undefined;
|
|
381
|
+
props?: Record<string, any> | undefined;
|
|
382
|
+
render?: any;
|
|
383
|
+
states?: Record<string, any> | undefined;
|
|
384
|
+
methods?: Record<string, {
|
|
385
|
+
fn: string;
|
|
386
|
+
params?: Record<string, any> | undefined;
|
|
387
|
+
}> | undefined;
|
|
388
|
+
effects?: {
|
|
389
|
+
fn: string;
|
|
390
|
+
deps?: string[] | undefined;
|
|
391
|
+
}[] | undefined;
|
|
392
|
+
data?: Record<string, any> | undefined;
|
|
393
|
+
}>;
|
|
394
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
395
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
396
|
+
}, "strip", z.ZodTypeAny, {
|
|
397
|
+
dsl: {
|
|
398
|
+
id: string;
|
|
399
|
+
name?: string | undefined;
|
|
400
|
+
query?: {
|
|
401
|
+
params?: Record<string, any> | undefined;
|
|
402
|
+
key?: string | undefined;
|
|
403
|
+
graphql?: string | undefined;
|
|
404
|
+
sql?: string | undefined;
|
|
405
|
+
variables?: Record<string, any> | undefined;
|
|
406
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
407
|
+
dependencies?: string[] | undefined;
|
|
408
|
+
} | undefined;
|
|
409
|
+
props?: Record<string, any> | undefined;
|
|
410
|
+
render?: any;
|
|
411
|
+
states?: Record<string, any> | undefined;
|
|
412
|
+
methods?: Record<string, {
|
|
413
|
+
fn: string;
|
|
414
|
+
params?: Record<string, any> | undefined;
|
|
415
|
+
}> | undefined;
|
|
416
|
+
effects?: {
|
|
417
|
+
fn: string;
|
|
418
|
+
deps?: string[] | undefined;
|
|
419
|
+
}[] | undefined;
|
|
420
|
+
data?: Record<string, any> | undefined;
|
|
421
|
+
};
|
|
422
|
+
data?: Record<string, any> | undefined;
|
|
423
|
+
context?: Record<string, any> | undefined;
|
|
424
|
+
}, {
|
|
425
|
+
dsl: {
|
|
426
|
+
id: string;
|
|
427
|
+
name?: string | undefined;
|
|
428
|
+
query?: {
|
|
429
|
+
params?: Record<string, any> | undefined;
|
|
430
|
+
key?: string | undefined;
|
|
431
|
+
graphql?: string | undefined;
|
|
432
|
+
sql?: string | undefined;
|
|
433
|
+
variables?: Record<string, any> | undefined;
|
|
434
|
+
refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
|
|
435
|
+
dependencies?: string[] | undefined;
|
|
436
|
+
} | undefined;
|
|
437
|
+
props?: Record<string, any> | undefined;
|
|
438
|
+
render?: any;
|
|
439
|
+
states?: Record<string, any> | undefined;
|
|
440
|
+
methods?: Record<string, {
|
|
441
|
+
fn: string;
|
|
442
|
+
params?: Record<string, any> | undefined;
|
|
443
|
+
}> | undefined;
|
|
444
|
+
effects?: {
|
|
445
|
+
fn: string;
|
|
446
|
+
deps?: string[] | undefined;
|
|
447
|
+
}[] | undefined;
|
|
448
|
+
data?: Record<string, any> | undefined;
|
|
449
|
+
};
|
|
450
|
+
data?: Record<string, any> | undefined;
|
|
451
|
+
context?: Record<string, any> | undefined;
|
|
452
|
+
}>;
|
|
453
|
+
type DSLRendererProps = z.infer<typeof DSLRendererPropsSchema>;
|
|
454
|
+
|
|
455
|
+
declare const UserSchema: z.ZodObject<{
|
|
456
|
+
username: z.ZodString;
|
|
457
|
+
email: z.ZodOptional<z.ZodString>;
|
|
458
|
+
password: z.ZodString;
|
|
459
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
460
|
+
role: z.ZodOptional<z.ZodString>;
|
|
461
|
+
userInfo: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
462
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
463
|
+
}, "strip", z.ZodTypeAny, {
|
|
464
|
+
username: string;
|
|
465
|
+
password: string;
|
|
466
|
+
email?: string | undefined;
|
|
467
|
+
fullname?: string | undefined;
|
|
468
|
+
role?: string | undefined;
|
|
469
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
470
|
+
wsIds?: string[] | undefined;
|
|
471
|
+
}, {
|
|
472
|
+
username: string;
|
|
473
|
+
password: string;
|
|
474
|
+
email?: string | undefined;
|
|
475
|
+
fullname?: string | undefined;
|
|
476
|
+
role?: string | undefined;
|
|
477
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
478
|
+
wsIds?: string[] | undefined;
|
|
479
|
+
}>;
|
|
480
|
+
type User = z.infer<typeof UserSchema>;
|
|
481
|
+
declare const UsersDataSchema: z.ZodObject<{
|
|
482
|
+
users: z.ZodArray<z.ZodObject<{
|
|
483
|
+
username: z.ZodString;
|
|
484
|
+
email: z.ZodOptional<z.ZodString>;
|
|
485
|
+
password: z.ZodString;
|
|
486
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
487
|
+
role: z.ZodOptional<z.ZodString>;
|
|
488
|
+
userInfo: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
489
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
490
|
+
}, "strip", z.ZodTypeAny, {
|
|
491
|
+
username: string;
|
|
492
|
+
password: string;
|
|
493
|
+
email?: string | undefined;
|
|
494
|
+
fullname?: string | undefined;
|
|
495
|
+
role?: string | undefined;
|
|
496
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
497
|
+
wsIds?: string[] | undefined;
|
|
498
|
+
}, {
|
|
499
|
+
username: string;
|
|
500
|
+
password: string;
|
|
501
|
+
email?: string | undefined;
|
|
502
|
+
fullname?: string | undefined;
|
|
503
|
+
role?: string | undefined;
|
|
504
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
505
|
+
wsIds?: string[] | undefined;
|
|
506
|
+
}>, "many">;
|
|
507
|
+
}, "strip", z.ZodTypeAny, {
|
|
508
|
+
users: {
|
|
509
|
+
username: string;
|
|
510
|
+
password: string;
|
|
511
|
+
email?: string | undefined;
|
|
512
|
+
fullname?: string | undefined;
|
|
513
|
+
role?: string | undefined;
|
|
514
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
515
|
+
wsIds?: string[] | undefined;
|
|
516
|
+
}[];
|
|
517
|
+
}, {
|
|
518
|
+
users: {
|
|
519
|
+
username: string;
|
|
520
|
+
password: string;
|
|
521
|
+
email?: string | undefined;
|
|
522
|
+
fullname?: string | undefined;
|
|
523
|
+
role?: string | undefined;
|
|
524
|
+
userInfo?: Record<string, unknown> | undefined;
|
|
525
|
+
wsIds?: string[] | undefined;
|
|
526
|
+
}[];
|
|
527
|
+
}>;
|
|
528
|
+
type UsersData = z.infer<typeof UsersDataSchema>;
|
|
529
|
+
declare const MessageSchema: z.ZodObject<{
|
|
530
|
+
id: z.ZodOptional<z.ZodString>;
|
|
531
|
+
type: z.ZodString;
|
|
532
|
+
from: z.ZodObject<{
|
|
533
|
+
id: z.ZodOptional<z.ZodString>;
|
|
534
|
+
type: z.ZodOptional<z.ZodString>;
|
|
535
|
+
}, "strip", z.ZodTypeAny, {
|
|
536
|
+
id?: string | undefined;
|
|
537
|
+
type?: string | undefined;
|
|
538
|
+
}, {
|
|
539
|
+
id?: string | undefined;
|
|
540
|
+
type?: string | undefined;
|
|
541
|
+
}>;
|
|
542
|
+
to: z.ZodOptional<z.ZodObject<{
|
|
543
|
+
id: z.ZodOptional<z.ZodString>;
|
|
544
|
+
type: z.ZodOptional<z.ZodString>;
|
|
545
|
+
}, "strip", z.ZodTypeAny, {
|
|
546
|
+
id?: string | undefined;
|
|
547
|
+
type?: string | undefined;
|
|
548
|
+
}, {
|
|
549
|
+
id?: string | undefined;
|
|
550
|
+
type?: string | undefined;
|
|
551
|
+
}>>;
|
|
552
|
+
payload: z.ZodUnknown;
|
|
553
|
+
}, "strip", z.ZodTypeAny, {
|
|
554
|
+
type: string;
|
|
555
|
+
from: {
|
|
556
|
+
id?: string | undefined;
|
|
557
|
+
type?: string | undefined;
|
|
558
|
+
};
|
|
559
|
+
id?: string | undefined;
|
|
560
|
+
to?: {
|
|
561
|
+
id?: string | undefined;
|
|
562
|
+
type?: string | undefined;
|
|
563
|
+
} | undefined;
|
|
564
|
+
payload?: unknown;
|
|
565
|
+
}, {
|
|
566
|
+
type: string;
|
|
567
|
+
from: {
|
|
568
|
+
id?: string | undefined;
|
|
569
|
+
type?: string | undefined;
|
|
570
|
+
};
|
|
571
|
+
id?: string | undefined;
|
|
572
|
+
to?: {
|
|
573
|
+
id?: string | undefined;
|
|
574
|
+
type?: string | undefined;
|
|
575
|
+
} | undefined;
|
|
576
|
+
payload?: unknown;
|
|
577
|
+
}>;
|
|
578
|
+
type Message = z.infer<typeof MessageSchema>;
|
|
579
|
+
declare const IncomingMessageSchema: z.ZodObject<{
|
|
580
|
+
id: z.ZodOptional<z.ZodString>;
|
|
581
|
+
type: z.ZodString;
|
|
582
|
+
from: z.ZodObject<{
|
|
583
|
+
id: z.ZodOptional<z.ZodString>;
|
|
584
|
+
type: z.ZodOptional<z.ZodString>;
|
|
585
|
+
}, "strip", z.ZodTypeAny, {
|
|
586
|
+
id?: string | undefined;
|
|
587
|
+
type?: string | undefined;
|
|
588
|
+
}, {
|
|
589
|
+
id?: string | undefined;
|
|
590
|
+
type?: string | undefined;
|
|
591
|
+
}>;
|
|
592
|
+
to: z.ZodOptional<z.ZodObject<{
|
|
593
|
+
id: z.ZodOptional<z.ZodString>;
|
|
594
|
+
type: z.ZodOptional<z.ZodString>;
|
|
595
|
+
}, "strip", z.ZodTypeAny, {
|
|
596
|
+
id?: string | undefined;
|
|
597
|
+
type?: string | undefined;
|
|
598
|
+
}, {
|
|
599
|
+
id?: string | undefined;
|
|
600
|
+
type?: string | undefined;
|
|
601
|
+
}>>;
|
|
602
|
+
payload: z.ZodUnknown;
|
|
603
|
+
}, "strip", z.ZodTypeAny, {
|
|
604
|
+
type: string;
|
|
605
|
+
from: {
|
|
606
|
+
id?: string | undefined;
|
|
607
|
+
type?: string | undefined;
|
|
608
|
+
};
|
|
609
|
+
id?: string | undefined;
|
|
610
|
+
to?: {
|
|
611
|
+
id?: string | undefined;
|
|
612
|
+
type?: string | undefined;
|
|
613
|
+
} | undefined;
|
|
614
|
+
payload?: unknown;
|
|
615
|
+
}, {
|
|
616
|
+
type: string;
|
|
617
|
+
from: {
|
|
618
|
+
id?: string | undefined;
|
|
619
|
+
type?: string | undefined;
|
|
620
|
+
};
|
|
621
|
+
id?: string | undefined;
|
|
622
|
+
to?: {
|
|
623
|
+
id?: string | undefined;
|
|
624
|
+
type?: string | undefined;
|
|
625
|
+
} | undefined;
|
|
626
|
+
payload?: unknown;
|
|
627
|
+
}>;
|
|
628
|
+
type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
|
|
629
|
+
declare const ComponentSchema: z.ZodObject<{
|
|
630
|
+
id: z.ZodString;
|
|
631
|
+
name: z.ZodString;
|
|
632
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
633
|
+
isDisplayComp: z.ZodOptional<z.ZodBoolean>;
|
|
634
|
+
type: z.ZodString;
|
|
635
|
+
description: z.ZodString;
|
|
636
|
+
props: z.ZodObject<{
|
|
637
|
+
query: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
638
|
+
title: z.ZodOptional<z.ZodString>;
|
|
639
|
+
description: z.ZodOptional<z.ZodString>;
|
|
640
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
641
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
642
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
643
|
+
query: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
644
|
+
title: z.ZodOptional<z.ZodString>;
|
|
645
|
+
description: z.ZodOptional<z.ZodString>;
|
|
646
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
647
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
648
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
649
|
+
query: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
|
|
650
|
+
title: z.ZodOptional<z.ZodString>;
|
|
651
|
+
description: z.ZodOptional<z.ZodString>;
|
|
652
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
653
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
654
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
655
|
+
category: z.ZodOptional<z.ZodString>;
|
|
656
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
657
|
+
}, "strip", z.ZodTypeAny, {
|
|
658
|
+
id: string;
|
|
659
|
+
type: string;
|
|
660
|
+
name: string;
|
|
661
|
+
description: string;
|
|
662
|
+
props: {
|
|
663
|
+
description?: string | undefined;
|
|
664
|
+
query?: string | {} | null | undefined;
|
|
665
|
+
title?: string | undefined;
|
|
666
|
+
config?: Record<string, unknown> | undefined;
|
|
667
|
+
actions?: any[] | undefined;
|
|
668
|
+
} & {
|
|
669
|
+
[k: string]: unknown;
|
|
670
|
+
};
|
|
671
|
+
displayName?: string | undefined;
|
|
672
|
+
isDisplayComp?: boolean | undefined;
|
|
673
|
+
category?: string | undefined;
|
|
674
|
+
keywords?: string[] | undefined;
|
|
675
|
+
}, {
|
|
676
|
+
id: string;
|
|
677
|
+
type: string;
|
|
678
|
+
name: string;
|
|
679
|
+
description: string;
|
|
680
|
+
props: {
|
|
681
|
+
description?: string | undefined;
|
|
682
|
+
query?: string | {} | null | undefined;
|
|
683
|
+
title?: string | undefined;
|
|
684
|
+
config?: Record<string, unknown> | undefined;
|
|
685
|
+
actions?: any[] | undefined;
|
|
686
|
+
} & {
|
|
687
|
+
[k: string]: unknown;
|
|
688
|
+
};
|
|
689
|
+
displayName?: string | undefined;
|
|
690
|
+
isDisplayComp?: boolean | undefined;
|
|
691
|
+
category?: string | undefined;
|
|
692
|
+
keywords?: string[] | undefined;
|
|
693
|
+
}>;
|
|
694
|
+
type Component = z.infer<typeof ComponentSchema>;
|
|
695
|
+
declare const OutputFieldSchema: z.ZodObject<{
|
|
696
|
+
name: z.ZodString;
|
|
697
|
+
type: z.ZodEnum<["string", "number", "boolean", "date"]>;
|
|
698
|
+
description: z.ZodString;
|
|
699
|
+
}, "strip", z.ZodTypeAny, {
|
|
700
|
+
type: "string" | "number" | "boolean" | "date";
|
|
701
|
+
name: string;
|
|
702
|
+
description: string;
|
|
703
|
+
}, {
|
|
704
|
+
type: "string" | "number" | "boolean" | "date";
|
|
705
|
+
name: string;
|
|
706
|
+
description: string;
|
|
707
|
+
}>;
|
|
708
|
+
type OutputField = z.infer<typeof OutputFieldSchema>;
|
|
709
|
+
declare const OutputSchema: z.ZodObject<{
|
|
710
|
+
description: z.ZodString;
|
|
711
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
712
|
+
name: z.ZodString;
|
|
713
|
+
type: z.ZodEnum<["string", "number", "boolean", "date"]>;
|
|
714
|
+
description: z.ZodString;
|
|
715
|
+
}, "strip", z.ZodTypeAny, {
|
|
716
|
+
type: "string" | "number" | "boolean" | "date";
|
|
717
|
+
name: string;
|
|
718
|
+
description: string;
|
|
719
|
+
}, {
|
|
720
|
+
type: "string" | "number" | "boolean" | "date";
|
|
721
|
+
name: string;
|
|
722
|
+
description: string;
|
|
723
|
+
}>, "many">;
|
|
724
|
+
}, "strip", z.ZodTypeAny, {
|
|
725
|
+
description: string;
|
|
726
|
+
fields: {
|
|
727
|
+
type: "string" | "number" | "boolean" | "date";
|
|
728
|
+
name: string;
|
|
729
|
+
description: string;
|
|
730
|
+
}[];
|
|
731
|
+
}, {
|
|
732
|
+
description: string;
|
|
733
|
+
fields: {
|
|
734
|
+
type: "string" | "number" | "boolean" | "date";
|
|
735
|
+
name: string;
|
|
736
|
+
description: string;
|
|
737
|
+
}[];
|
|
738
|
+
}>;
|
|
739
|
+
type ToolOutputSchema = z.infer<typeof OutputSchema>;
|
|
740
|
+
declare const ToolSchema: z.ZodObject<{
|
|
741
|
+
id: z.ZodString;
|
|
742
|
+
name: z.ZodString;
|
|
743
|
+
description: z.ZodString;
|
|
744
|
+
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
745
|
+
fn: z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodAny>;
|
|
746
|
+
outputSchema: z.ZodOptional<z.ZodObject<{
|
|
747
|
+
description: z.ZodString;
|
|
748
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
749
|
+
name: z.ZodString;
|
|
750
|
+
type: z.ZodEnum<["string", "number", "boolean", "date"]>;
|
|
751
|
+
description: z.ZodString;
|
|
752
|
+
}, "strip", z.ZodTypeAny, {
|
|
753
|
+
type: "string" | "number" | "boolean" | "date";
|
|
754
|
+
name: string;
|
|
755
|
+
description: string;
|
|
756
|
+
}, {
|
|
757
|
+
type: "string" | "number" | "boolean" | "date";
|
|
758
|
+
name: string;
|
|
759
|
+
description: string;
|
|
760
|
+
}>, "many">;
|
|
761
|
+
}, "strip", z.ZodTypeAny, {
|
|
762
|
+
description: string;
|
|
763
|
+
fields: {
|
|
764
|
+
type: "string" | "number" | "boolean" | "date";
|
|
765
|
+
name: string;
|
|
766
|
+
description: string;
|
|
767
|
+
}[];
|
|
768
|
+
}, {
|
|
769
|
+
description: string;
|
|
770
|
+
fields: {
|
|
771
|
+
type: "string" | "number" | "boolean" | "date";
|
|
772
|
+
name: string;
|
|
773
|
+
description: string;
|
|
774
|
+
}[];
|
|
775
|
+
}>>;
|
|
776
|
+
}, "strip", z.ZodTypeAny, {
|
|
777
|
+
id: string;
|
|
778
|
+
params: Record<string, string>;
|
|
779
|
+
name: string;
|
|
780
|
+
description: string;
|
|
781
|
+
fn: (args_0: any, ...args: unknown[]) => any;
|
|
782
|
+
outputSchema?: {
|
|
783
|
+
description: string;
|
|
784
|
+
fields: {
|
|
785
|
+
type: "string" | "number" | "boolean" | "date";
|
|
786
|
+
name: string;
|
|
787
|
+
description: string;
|
|
788
|
+
}[];
|
|
789
|
+
} | undefined;
|
|
790
|
+
}, {
|
|
791
|
+
id: string;
|
|
792
|
+
params: Record<string, string>;
|
|
793
|
+
name: string;
|
|
794
|
+
description: string;
|
|
795
|
+
fn: (args_0: any, ...args: unknown[]) => any;
|
|
796
|
+
outputSchema?: {
|
|
797
|
+
description: string;
|
|
798
|
+
fields: {
|
|
799
|
+
type: "string" | "number" | "boolean" | "date";
|
|
800
|
+
name: string;
|
|
801
|
+
description: string;
|
|
802
|
+
}[];
|
|
803
|
+
} | undefined;
|
|
804
|
+
}>;
|
|
805
|
+
type Tool$1 = z.infer<typeof ToolSchema>;
|
|
806
|
+
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
807
|
+
type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
|
|
808
|
+
type LLMProvider = 'anthropic' | 'groq' | 'gemini' | 'openai';
|
|
809
|
+
|
|
810
|
+
type DatabaseType = 'postgresql' | 'mssql' | 'snowflake' | 'mysql';
|
|
811
|
+
/**
|
|
812
|
+
* Model strategy for controlling which models are used for different tasks
|
|
813
|
+
* - 'best': Use the best model (e.g., Sonnet) for all tasks - highest quality, higher cost
|
|
814
|
+
* - 'fast': Use the fast model (e.g., Haiku) for all tasks - lower quality, lower cost
|
|
815
|
+
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
816
|
+
*/
|
|
817
|
+
type ModelStrategy = 'best' | 'fast' | 'balanced';
|
|
818
|
+
/**
|
|
819
|
+
* Model configuration for DASH_COMP flow (dashboard component picking)
|
|
820
|
+
* Allows separate control of models used for component selection
|
|
821
|
+
*/
|
|
822
|
+
interface DashCompModelConfig {
|
|
823
|
+
/**
|
|
824
|
+
* Primary model for DASH_COMP requests
|
|
825
|
+
* Format: "provider/model-name" (e.g., "anthropic/claude-sonnet-4-5-20250929")
|
|
826
|
+
*/
|
|
827
|
+
model?: string;
|
|
828
|
+
/**
|
|
829
|
+
* Fast model for simpler DASH_COMP tasks (optional)
|
|
830
|
+
* Format: "provider/model-name" (e.g., "anthropic/claude-haiku-4-5-20251001")
|
|
831
|
+
*/
|
|
832
|
+
fastModel?: string;
|
|
833
|
+
}
|
|
834
|
+
interface SuperatomSDKConfig {
|
|
835
|
+
url?: string;
|
|
836
|
+
apiKey?: string;
|
|
837
|
+
projectId: string;
|
|
838
|
+
type?: string;
|
|
839
|
+
bundleDir?: string;
|
|
840
|
+
promptsDir?: string;
|
|
841
|
+
databaseType?: DatabaseType;
|
|
842
|
+
ANTHROPIC_API_KEY?: string;
|
|
843
|
+
GROQ_API_KEY?: string;
|
|
844
|
+
GEMINI_API_KEY?: string;
|
|
845
|
+
OPENAI_API_KEY?: string;
|
|
846
|
+
LLM_PROVIDERS?: LLMProvider[];
|
|
847
|
+
logLevel?: LogLevel;
|
|
848
|
+
/**
|
|
849
|
+
* Model selection strategy for LLM API calls:
|
|
850
|
+
* - 'best': Use best model for all tasks (highest quality, higher cost)
|
|
851
|
+
* - 'fast': Use fast model for all tasks (lower quality, lower cost)
|
|
852
|
+
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
853
|
+
*/
|
|
854
|
+
modelStrategy?: ModelStrategy;
|
|
855
|
+
/**
|
|
856
|
+
* Separate model configuration for DASH_COMP flow (dashboard component picking)
|
|
857
|
+
* If not provided, falls back to provider-based model selection
|
|
858
|
+
*/
|
|
859
|
+
dashCompModels?: DashCompModelConfig;
|
|
860
|
+
/**
|
|
861
|
+
* Similarity threshold for conversation search (semantic matching)
|
|
862
|
+
* Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
863
|
+
* Higher values require closer matches, lower values allow more distant matches
|
|
864
|
+
* Default: 0.8
|
|
865
|
+
*/
|
|
866
|
+
conversationSimilarityThreshold?: number;
|
|
867
|
+
/**
|
|
868
|
+
* Query cache TTL (Time To Live) in minutes
|
|
869
|
+
* Cached query results expire after this duration
|
|
870
|
+
* Default: 5 minutes
|
|
871
|
+
*/
|
|
872
|
+
queryCacheTTL?: number;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
declare const KbNodesQueryFiltersSchema: z.ZodObject<{
|
|
876
|
+
query: z.ZodOptional<z.ZodString>;
|
|
877
|
+
category: z.ZodOptional<z.ZodString>;
|
|
878
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
879
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
880
|
+
createdBy: z.ZodOptional<z.ZodNumber>;
|
|
881
|
+
}, "strip", z.ZodTypeAny, {
|
|
882
|
+
type?: "query" | "user" | "global" | undefined;
|
|
883
|
+
query?: string | undefined;
|
|
884
|
+
category?: string | undefined;
|
|
885
|
+
createdBy?: number | undefined;
|
|
886
|
+
tags?: string[] | undefined;
|
|
887
|
+
}, {
|
|
888
|
+
type?: "query" | "user" | "global" | undefined;
|
|
889
|
+
query?: string | undefined;
|
|
890
|
+
category?: string | undefined;
|
|
891
|
+
createdBy?: number | undefined;
|
|
892
|
+
tags?: string[] | undefined;
|
|
893
|
+
}>;
|
|
894
|
+
type KbNodesQueryFilters = z.infer<typeof KbNodesQueryFiltersSchema>;
|
|
895
|
+
declare const KbNodesRequestPayloadSchema: z.ZodObject<{
|
|
896
|
+
operation: z.ZodEnum<["create", "update", "delete", "getAll", "getOne", "search", "getByCategory", "getByUser", "getCategories", "getTags"]>;
|
|
897
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
898
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
899
|
+
title: z.ZodOptional<z.ZodString>;
|
|
900
|
+
content: z.ZodOptional<z.ZodString>;
|
|
901
|
+
category: z.ZodOptional<z.ZodString>;
|
|
902
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
903
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
904
|
+
createdBy: z.ZodOptional<z.ZodNumber>;
|
|
905
|
+
updatedBy: z.ZodOptional<z.ZodNumber>;
|
|
906
|
+
userId: z.ZodOptional<z.ZodNumber>;
|
|
907
|
+
query: z.ZodOptional<z.ZodString>;
|
|
908
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
909
|
+
query: z.ZodOptional<z.ZodString>;
|
|
910
|
+
category: z.ZodOptional<z.ZodString>;
|
|
911
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
912
|
+
type: z.ZodOptional<z.ZodEnum<["global", "user", "query"]>>;
|
|
913
|
+
createdBy: z.ZodOptional<z.ZodNumber>;
|
|
914
|
+
}, "strip", z.ZodTypeAny, {
|
|
915
|
+
type?: "query" | "user" | "global" | undefined;
|
|
916
|
+
query?: string | undefined;
|
|
917
|
+
category?: string | undefined;
|
|
918
|
+
createdBy?: number | undefined;
|
|
919
|
+
tags?: string[] | undefined;
|
|
920
|
+
}, {
|
|
921
|
+
type?: "query" | "user" | "global" | undefined;
|
|
922
|
+
query?: string | undefined;
|
|
923
|
+
category?: string | undefined;
|
|
924
|
+
createdBy?: number | undefined;
|
|
925
|
+
tags?: string[] | undefined;
|
|
926
|
+
}>>;
|
|
927
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
928
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
929
|
+
}, "strip", z.ZodTypeAny, {
|
|
930
|
+
id?: number | undefined;
|
|
931
|
+
type?: "query" | "user" | "global" | undefined;
|
|
932
|
+
query?: string | undefined;
|
|
933
|
+
title?: string | undefined;
|
|
934
|
+
category?: string | undefined;
|
|
935
|
+
userId?: number | undefined;
|
|
936
|
+
limit?: number | undefined;
|
|
937
|
+
filters?: {
|
|
938
|
+
type?: "query" | "user" | "global" | undefined;
|
|
939
|
+
query?: string | undefined;
|
|
940
|
+
category?: string | undefined;
|
|
941
|
+
createdBy?: number | undefined;
|
|
942
|
+
tags?: string[] | undefined;
|
|
943
|
+
} | undefined;
|
|
944
|
+
createdBy?: number | undefined;
|
|
945
|
+
updatedBy?: number | undefined;
|
|
946
|
+
offset?: number | undefined;
|
|
947
|
+
tags?: string[] | undefined;
|
|
948
|
+
content?: string | undefined;
|
|
949
|
+
}, {
|
|
950
|
+
id?: number | undefined;
|
|
951
|
+
type?: "query" | "user" | "global" | undefined;
|
|
952
|
+
query?: string | undefined;
|
|
953
|
+
title?: string | undefined;
|
|
954
|
+
category?: string | undefined;
|
|
955
|
+
userId?: number | undefined;
|
|
956
|
+
limit?: number | undefined;
|
|
957
|
+
filters?: {
|
|
958
|
+
type?: "query" | "user" | "global" | undefined;
|
|
959
|
+
query?: string | undefined;
|
|
960
|
+
category?: string | undefined;
|
|
961
|
+
createdBy?: number | undefined;
|
|
962
|
+
tags?: string[] | undefined;
|
|
963
|
+
} | undefined;
|
|
964
|
+
createdBy?: number | undefined;
|
|
965
|
+
updatedBy?: number | undefined;
|
|
966
|
+
offset?: number | undefined;
|
|
967
|
+
tags?: string[] | undefined;
|
|
968
|
+
content?: string | undefined;
|
|
969
|
+
}>>;
|
|
970
|
+
}, "strip", z.ZodTypeAny, {
|
|
971
|
+
operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
|
|
972
|
+
data?: {
|
|
973
|
+
id?: number | undefined;
|
|
974
|
+
type?: "query" | "user" | "global" | undefined;
|
|
975
|
+
query?: string | undefined;
|
|
976
|
+
title?: string | undefined;
|
|
977
|
+
category?: string | undefined;
|
|
978
|
+
userId?: number | undefined;
|
|
979
|
+
limit?: number | undefined;
|
|
980
|
+
filters?: {
|
|
981
|
+
type?: "query" | "user" | "global" | undefined;
|
|
982
|
+
query?: string | undefined;
|
|
983
|
+
category?: string | undefined;
|
|
984
|
+
createdBy?: number | undefined;
|
|
985
|
+
tags?: string[] | undefined;
|
|
986
|
+
} | undefined;
|
|
987
|
+
createdBy?: number | undefined;
|
|
988
|
+
updatedBy?: number | undefined;
|
|
989
|
+
offset?: number | undefined;
|
|
990
|
+
tags?: string[] | undefined;
|
|
991
|
+
content?: string | undefined;
|
|
992
|
+
} | undefined;
|
|
993
|
+
}, {
|
|
994
|
+
operation: "create" | "getOne" | "update" | "delete" | "getAll" | "search" | "getByCategory" | "getByUser" | "getCategories" | "getTags";
|
|
995
|
+
data?: {
|
|
996
|
+
id?: number | undefined;
|
|
997
|
+
type?: "query" | "user" | "global" | undefined;
|
|
998
|
+
query?: string | undefined;
|
|
999
|
+
title?: string | undefined;
|
|
1000
|
+
category?: string | undefined;
|
|
1001
|
+
userId?: number | undefined;
|
|
1002
|
+
limit?: number | undefined;
|
|
1003
|
+
filters?: {
|
|
1004
|
+
type?: "query" | "user" | "global" | undefined;
|
|
1005
|
+
query?: string | undefined;
|
|
1006
|
+
category?: string | undefined;
|
|
1007
|
+
createdBy?: number | undefined;
|
|
1008
|
+
tags?: string[] | undefined;
|
|
1009
|
+
} | undefined;
|
|
1010
|
+
createdBy?: number | undefined;
|
|
1011
|
+
updatedBy?: number | undefined;
|
|
1012
|
+
offset?: number | undefined;
|
|
1013
|
+
tags?: string[] | undefined;
|
|
1014
|
+
content?: string | undefined;
|
|
1015
|
+
} | undefined;
|
|
1016
|
+
}>;
|
|
1017
|
+
type KbNodesRequestPayload = z.infer<typeof KbNodesRequestPayloadSchema>;
|
|
1018
|
+
interface T_RESPONSE {
|
|
1019
|
+
success: boolean;
|
|
1020
|
+
data?: any;
|
|
1021
|
+
errors: string[];
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* UserManager class to handle CRUD operations on users with file persistence
|
|
1026
|
+
* and in-memory caching. Changes are synced to file periodically.
|
|
1027
|
+
*/
|
|
1028
|
+
declare class UserManager {
|
|
1029
|
+
private users;
|
|
1030
|
+
private filePath;
|
|
1031
|
+
private hasChanged;
|
|
1032
|
+
private syncInterval;
|
|
1033
|
+
private syncIntervalMs;
|
|
1034
|
+
private isInitialized;
|
|
1035
|
+
/**
|
|
1036
|
+
* Initialize UserManager with file path and sync interval
|
|
1037
|
+
* @param projectId - Project ID to use in file path (default: 'snowflake-dataset')
|
|
1038
|
+
* @param syncIntervalMs - Interval in milliseconds to sync changes to file (default: 5000ms)
|
|
1039
|
+
*/
|
|
1040
|
+
constructor(projectId?: string, syncIntervalMs?: number);
|
|
1041
|
+
/**
|
|
1042
|
+
* Initialize the UserManager by loading users from file and starting sync interval
|
|
1043
|
+
*/
|
|
1044
|
+
init(): Promise<void>;
|
|
1045
|
+
/**
|
|
1046
|
+
* Load users from the JSON file into memory
|
|
1047
|
+
*/
|
|
1048
|
+
private loadUsersFromFile;
|
|
1049
|
+
/**
|
|
1050
|
+
* Save users from memory to the JSON file
|
|
1051
|
+
*/
|
|
1052
|
+
private saveUsersToFile;
|
|
1053
|
+
/**
|
|
1054
|
+
* Start the periodic sync interval
|
|
1055
|
+
*/
|
|
1056
|
+
private startSyncInterval;
|
|
1057
|
+
/**
|
|
1058
|
+
* Stop the periodic sync interval
|
|
1059
|
+
*/
|
|
1060
|
+
stopSyncInterval(): void;
|
|
1061
|
+
/**
|
|
1062
|
+
* Force sync users to file immediately
|
|
1063
|
+
*/
|
|
1064
|
+
forceSync(): Promise<void>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Create a new user
|
|
1067
|
+
* @param user - User object to create
|
|
1068
|
+
* @returns The created user
|
|
1069
|
+
*/
|
|
1070
|
+
createUser(user: User): User;
|
|
1071
|
+
/**
|
|
1072
|
+
* Read a user by username
|
|
1073
|
+
* @param username - Username to retrieve
|
|
1074
|
+
* @returns The user if found, undefined otherwise
|
|
1075
|
+
*/
|
|
1076
|
+
getUser(username: string): User | undefined;
|
|
1077
|
+
/**
|
|
1078
|
+
* Read a user by email
|
|
1079
|
+
* @param email - Email to retrieve
|
|
1080
|
+
* @returns The user if found, undefined otherwise
|
|
1081
|
+
*/
|
|
1082
|
+
getUserByEmail(email: string): User | undefined;
|
|
1083
|
+
/**
|
|
1084
|
+
* Find user by username or email
|
|
1085
|
+
* @param identifier - Username or email to search for
|
|
1086
|
+
* @returns The user if found, undefined otherwise
|
|
1087
|
+
*/
|
|
1088
|
+
getUserByUsernameOrEmail(identifier: string): User | undefined;
|
|
1089
|
+
/**
|
|
1090
|
+
* Read all users
|
|
1091
|
+
* @returns Array of all users
|
|
1092
|
+
*/
|
|
1093
|
+
getAllUsers(): User[];
|
|
1094
|
+
/**
|
|
1095
|
+
* Find users by a predicate function
|
|
1096
|
+
* @param predicate - Function to filter users
|
|
1097
|
+
* @returns Array of matching users
|
|
1098
|
+
*/
|
|
1099
|
+
findUsers(predicate: (user: User) => boolean): User[];
|
|
1100
|
+
/**
|
|
1101
|
+
* Update an existing user by username
|
|
1102
|
+
* @param username - Username of user to update
|
|
1103
|
+
* @param updates - Partial user object with fields to update
|
|
1104
|
+
* @returns The updated user
|
|
1105
|
+
*/
|
|
1106
|
+
updateUser(username: string, updates: Partial<User>): User;
|
|
1107
|
+
/**
|
|
1108
|
+
* Delete a user by username
|
|
1109
|
+
* @param username - Username of user to delete
|
|
1110
|
+
* @returns true if user was deleted, false if not found
|
|
1111
|
+
*/
|
|
1112
|
+
deleteUser(username: string): boolean;
|
|
1113
|
+
/**
|
|
1114
|
+
* Delete all users
|
|
1115
|
+
*/
|
|
1116
|
+
deleteAllUsers(): void;
|
|
1117
|
+
/**
|
|
1118
|
+
* Get the count of users
|
|
1119
|
+
* @returns Number of users in memory
|
|
1120
|
+
*/
|
|
1121
|
+
getUserCount(): number;
|
|
1122
|
+
/**
|
|
1123
|
+
* Check if a user exists
|
|
1124
|
+
* @param username - Username to check
|
|
1125
|
+
* @returns true if user exists, false otherwise
|
|
1126
|
+
*/
|
|
1127
|
+
userExists(username: string): boolean;
|
|
1128
|
+
/**
|
|
1129
|
+
* Add a WebSocket ID to a user's wsIds array
|
|
1130
|
+
* @param username - Username to update
|
|
1131
|
+
* @param wsId - WebSocket ID to add
|
|
1132
|
+
* @returns true if successful, false if user not found
|
|
1133
|
+
*/
|
|
1134
|
+
addWsId(username: string, wsId: string): boolean;
|
|
1135
|
+
/**
|
|
1136
|
+
* Remove a WebSocket ID from a user's wsIds array
|
|
1137
|
+
* @param username - Username to update
|
|
1138
|
+
* @param wsId - WebSocket ID to remove
|
|
1139
|
+
* @returns true if successful, false if user not found
|
|
1140
|
+
*/
|
|
1141
|
+
removeWsId(username: string, wsId: string): boolean;
|
|
1142
|
+
/**
|
|
1143
|
+
* Get the change status
|
|
1144
|
+
* @returns true if there are unsaved changes, false otherwise
|
|
1145
|
+
*/
|
|
1146
|
+
hasUnsavedChanges(): boolean;
|
|
1147
|
+
/**
|
|
1148
|
+
* Cleanup resources and stop sync interval
|
|
1149
|
+
*/
|
|
1150
|
+
destroy(): Promise<void>;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* DashboardManager class to handle CRUD operations on dashboards
|
|
1155
|
+
* All operations read/write directly to files (no in-memory caching)
|
|
1156
|
+
*/
|
|
1157
|
+
declare class DashboardManager {
|
|
1158
|
+
private dashboardsBasePath;
|
|
1159
|
+
private projectId;
|
|
1160
|
+
/**
|
|
1161
|
+
* Initialize DashboardManager with project ID
|
|
1162
|
+
* @param projectId - Project ID to use in file path
|
|
1163
|
+
*/
|
|
1164
|
+
constructor(projectId?: string);
|
|
1165
|
+
/**
|
|
1166
|
+
* Get the file path for a specific dashboard
|
|
1167
|
+
* @param dashboardId - Dashboard ID
|
|
1168
|
+
* @returns Full path to dashboard data.json file
|
|
1169
|
+
*/
|
|
1170
|
+
private getDashboardPath;
|
|
1171
|
+
/**
|
|
1172
|
+
* Create a new dashboard
|
|
1173
|
+
* @param dashboardId - Unique dashboard ID
|
|
1174
|
+
* @param dashboard - Dashboard data
|
|
1175
|
+
* @returns Created dashboard with metadata
|
|
1176
|
+
*/
|
|
1177
|
+
createDashboard(dashboardId: string, dashboard: DSLRendererProps$1): DSLRendererProps$1;
|
|
1178
|
+
/**
|
|
1179
|
+
* Get a specific dashboard by ID
|
|
1180
|
+
* @param dashboardId - Dashboard ID
|
|
1181
|
+
* @returns Dashboard data or null if not found
|
|
1182
|
+
*/
|
|
1183
|
+
getDashboard(dashboardId: string): DSLRendererProps$1 | null;
|
|
1184
|
+
/**
|
|
1185
|
+
* Get all dashboards
|
|
1186
|
+
* @returns Array of dashboard objects with their IDs
|
|
1187
|
+
*/
|
|
1188
|
+
getAllDashboards(): Array<{
|
|
1189
|
+
dashboardId: string;
|
|
1190
|
+
dashboard: DSLRendererProps$1;
|
|
1191
|
+
}>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Update an existing dashboard
|
|
1194
|
+
* @param dashboardId - Dashboard ID
|
|
1195
|
+
* @param dashboard - Updated dashboard data
|
|
1196
|
+
* @returns Updated dashboard or null if not found
|
|
1197
|
+
*/
|
|
1198
|
+
updateDashboard(dashboardId: string, dashboard: DSLRendererProps$1): DSLRendererProps$1 | null;
|
|
1199
|
+
/**
|
|
1200
|
+
* Delete a dashboard
|
|
1201
|
+
* @param dashboardId - Dashboard ID
|
|
1202
|
+
* @returns True if deleted, false if not found
|
|
1203
|
+
*/
|
|
1204
|
+
deleteDashboard(dashboardId: string): boolean;
|
|
1205
|
+
/**
|
|
1206
|
+
* Check if a dashboard exists
|
|
1207
|
+
* @param dashboardId - Dashboard ID
|
|
1208
|
+
* @returns True if dashboard exists, false otherwise
|
|
1209
|
+
*/
|
|
1210
|
+
dashboardExists(dashboardId: string): boolean;
|
|
1211
|
+
/**
|
|
1212
|
+
* Get dashboard count
|
|
1213
|
+
* @returns Number of dashboards
|
|
1214
|
+
*/
|
|
1215
|
+
getDashboardCount(): number;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* ReportManager class to handle CRUD operations on reports
|
|
1220
|
+
* All operations read/write directly to files (no in-memory caching)
|
|
1221
|
+
*/
|
|
1222
|
+
declare class ReportManager {
|
|
1223
|
+
private reportsBasePath;
|
|
1224
|
+
private projectId;
|
|
1225
|
+
/**
|
|
1226
|
+
* Initialize ReportManager with project ID
|
|
1227
|
+
* @param projectId - Project ID to use in file path
|
|
1228
|
+
*/
|
|
1229
|
+
constructor(projectId?: string);
|
|
1230
|
+
/**
|
|
1231
|
+
* Get the file path for a specific report
|
|
1232
|
+
* @param reportId - Report ID
|
|
1233
|
+
* @returns Full path to report data.json file
|
|
1234
|
+
*/
|
|
1235
|
+
private getReportPath;
|
|
1236
|
+
/**
|
|
1237
|
+
* Create a new report
|
|
1238
|
+
* @param reportId - Unique report ID
|
|
1239
|
+
* @param report - Report data
|
|
1240
|
+
* @returns Created report with metadata
|
|
1241
|
+
*/
|
|
1242
|
+
createReport(reportId: string, report: DSLRendererProps): DSLRendererProps;
|
|
1243
|
+
/**
|
|
1244
|
+
* Get a specific report by ID
|
|
1245
|
+
* @param reportId - Report ID
|
|
1246
|
+
* @returns Report data or null if not found
|
|
1247
|
+
*/
|
|
1248
|
+
getReport(reportId: string): DSLRendererProps | null;
|
|
1249
|
+
/**
|
|
1250
|
+
* Get all reports
|
|
1251
|
+
* @returns Array of report objects with their IDs
|
|
1252
|
+
*/
|
|
1253
|
+
getAllReports(): Array<{
|
|
1254
|
+
reportId: string;
|
|
1255
|
+
report: DSLRendererProps;
|
|
1256
|
+
}>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Update an existing report
|
|
1259
|
+
* @param reportId - Report ID
|
|
1260
|
+
* @param report - Updated report data
|
|
1261
|
+
* @returns Updated report or null if not found
|
|
1262
|
+
*/
|
|
1263
|
+
updateReport(reportId: string, report: DSLRendererProps): DSLRendererProps | null;
|
|
1264
|
+
/**
|
|
1265
|
+
* Delete a report
|
|
1266
|
+
* @param reportId - Report ID
|
|
1267
|
+
* @returns True if deleted, false if not found
|
|
1268
|
+
*/
|
|
1269
|
+
deleteReport(reportId: string): boolean;
|
|
1270
|
+
/**
|
|
1271
|
+
* Check if a report exists
|
|
1272
|
+
* @param reportId - Report ID
|
|
1273
|
+
* @returns True if report exists, false otherwise
|
|
1274
|
+
*/
|
|
1275
|
+
reportExists(reportId: string): boolean;
|
|
1276
|
+
/**
|
|
1277
|
+
* Get report count
|
|
1278
|
+
* @returns Number of reports
|
|
1279
|
+
*/
|
|
1280
|
+
getReportCount(): number;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
type SystemPrompt = string | Anthropic.Messages.TextBlockParam[];
|
|
1284
|
+
interface LLMMessages {
|
|
1285
|
+
sys: SystemPrompt;
|
|
1286
|
+
user: string;
|
|
1287
|
+
prefill?: string;
|
|
1288
|
+
}
|
|
1289
|
+
interface LLMOptions {
|
|
1290
|
+
model?: string;
|
|
1291
|
+
maxTokens?: number;
|
|
1292
|
+
temperature?: number;
|
|
1293
|
+
topP?: number;
|
|
1294
|
+
apiKey?: string;
|
|
1295
|
+
partial?: (chunk: string) => void;
|
|
1296
|
+
}
|
|
1297
|
+
interface Tool {
|
|
1298
|
+
name: string;
|
|
1299
|
+
description: string;
|
|
1300
|
+
input_schema: {
|
|
1301
|
+
type: string;
|
|
1302
|
+
properties: Record<string, any>;
|
|
1303
|
+
required?: string[];
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
declare class LLM {
|
|
1307
|
+
static text(messages: LLMMessages, options?: LLMOptions): Promise<string>;
|
|
1308
|
+
static stream<T = string>(messages: LLMMessages, options?: LLMOptions, json?: boolean): Promise<T extends string ? string : any>;
|
|
1309
|
+
static streamWithTools(messages: LLMMessages, tools: Tool[], toolHandler: (toolName: string, toolInput: any) => Promise<any>, options?: LLMOptions, maxIterations?: number): Promise<string>;
|
|
1310
|
+
/**
|
|
1311
|
+
* Normalize system prompt to Anthropic format
|
|
1312
|
+
* Converts string to array format if needed
|
|
1313
|
+
* @param sys - System prompt (string or array of blocks)
|
|
1314
|
+
* @returns Normalized system prompt for Anthropic API
|
|
1315
|
+
*/
|
|
1316
|
+
private static _normalizeSystemPrompt;
|
|
1317
|
+
/**
|
|
1318
|
+
* Log cache usage metrics from Anthropic API response
|
|
1319
|
+
* Shows cache hits, costs, and savings
|
|
1320
|
+
*/
|
|
1321
|
+
private static _logCacheUsage;
|
|
1322
|
+
/**
|
|
1323
|
+
* Parse model string to extract provider and model name
|
|
1324
|
+
* @param modelString - Format: "provider/model-name" or just "model-name"
|
|
1325
|
+
* @returns [provider, modelName]
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* "anthropic/claude-sonnet-4-5" → ["anthropic", "claude-sonnet-4-5"]
|
|
1329
|
+
* "groq/openai/gpt-oss-120b" → ["groq", "openai/gpt-oss-120b"]
|
|
1330
|
+
* "claude-sonnet-4-5" → ["anthropic", "claude-sonnet-4-5"] (default)
|
|
1331
|
+
*/
|
|
1332
|
+
private static _parseModel;
|
|
1333
|
+
private static _anthropicText;
|
|
1334
|
+
private static _anthropicStream;
|
|
1335
|
+
private static _anthropicStreamWithTools;
|
|
1336
|
+
private static _groqText;
|
|
1337
|
+
private static _groqStream;
|
|
1338
|
+
private static _geminiText;
|
|
1339
|
+
private static _geminiStream;
|
|
1340
|
+
/**
|
|
1341
|
+
* Recursively strip unsupported JSON Schema properties for Gemini
|
|
1342
|
+
* Gemini doesn't support: additionalProperties, $schema, etc.
|
|
1343
|
+
*/
|
|
1344
|
+
private static _cleanSchemaForGemini;
|
|
1345
|
+
private static _geminiStreamWithTools;
|
|
1346
|
+
private static _openaiText;
|
|
1347
|
+
private static _openaiStream;
|
|
1348
|
+
private static _openaiStreamWithTools;
|
|
1349
|
+
/**
|
|
1350
|
+
* Parse JSON string, handling markdown code blocks and surrounding text
|
|
1351
|
+
* Enhanced version with jsonrepair to handle malformed JSON from LLMs
|
|
1352
|
+
* @param text - Text that may contain JSON wrapped in ```json...``` or with surrounding text
|
|
1353
|
+
* @returns Parsed JSON object or array
|
|
1354
|
+
*/
|
|
1355
|
+
private static _parseJSON;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
interface CapturedLog {
|
|
1359
|
+
timestamp: number;
|
|
1360
|
+
level: 'info' | 'error' | 'warn' | 'debug';
|
|
1361
|
+
message: string;
|
|
1362
|
+
type?: 'explanation' | 'query' | 'general';
|
|
1363
|
+
data?: Record<string, any>;
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* UILogCollector captures logs during user prompt processing
|
|
1367
|
+
* and sends them to runtime via ui_logs message with uiBlockId as the message id
|
|
1368
|
+
* Logs are sent in real-time for streaming effect in the UI
|
|
1369
|
+
* Respects the global log level configuration
|
|
1370
|
+
*/
|
|
1371
|
+
declare class UILogCollector {
|
|
1372
|
+
private logs;
|
|
1373
|
+
private uiBlockId;
|
|
1374
|
+
private clientId;
|
|
1375
|
+
private sendMessage;
|
|
1376
|
+
private currentLogLevel;
|
|
1377
|
+
constructor(clientId: string, sendMessage: (message: Message) => void, uiBlockId?: string);
|
|
1378
|
+
/**
|
|
1379
|
+
* Check if logging is enabled (uiBlockId is provided)
|
|
1380
|
+
*/
|
|
1381
|
+
isEnabled(): boolean;
|
|
1382
|
+
/**
|
|
1383
|
+
* Check if a message should be logged based on current log level
|
|
1384
|
+
*/
|
|
1385
|
+
private shouldLog;
|
|
1386
|
+
/**
|
|
1387
|
+
* Add a log entry with timestamp and immediately send to runtime
|
|
1388
|
+
* Only logs that pass the log level filter are captured and sent
|
|
1389
|
+
*/
|
|
1390
|
+
private addLog;
|
|
1391
|
+
/**
|
|
1392
|
+
* Send a single log to runtime immediately
|
|
1393
|
+
*/
|
|
1394
|
+
private sendLogImmediately;
|
|
1395
|
+
/**
|
|
1396
|
+
* Log info message
|
|
1397
|
+
*/
|
|
1398
|
+
info(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
|
|
1399
|
+
/**
|
|
1400
|
+
* Log error message
|
|
1401
|
+
*/
|
|
1402
|
+
error(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
|
|
1403
|
+
/**
|
|
1404
|
+
* Log warning message
|
|
1405
|
+
*/
|
|
1406
|
+
warn(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
|
|
1407
|
+
/**
|
|
1408
|
+
* Log debug message
|
|
1409
|
+
*/
|
|
1410
|
+
debug(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
|
|
1411
|
+
/**
|
|
1412
|
+
* Log LLM explanation with typed metadata
|
|
1413
|
+
*/
|
|
1414
|
+
logExplanation(message: string, explanation: string, data?: Record<string, any>): void;
|
|
1415
|
+
/**
|
|
1416
|
+
* Log generated query with typed metadata
|
|
1417
|
+
*/
|
|
1418
|
+
logQuery(message: string, query: string, data?: Record<string, any>): void;
|
|
1419
|
+
/**
|
|
1420
|
+
* Send all collected logs at once (optional, for final summary)
|
|
1421
|
+
*/
|
|
1422
|
+
sendAllLogs(): void;
|
|
1423
|
+
/**
|
|
1424
|
+
* Get all collected logs
|
|
1425
|
+
*/
|
|
1426
|
+
getLogs(): CapturedLog[];
|
|
1427
|
+
/**
|
|
1428
|
+
* Clear all logs
|
|
1429
|
+
*/
|
|
1430
|
+
clearLogs(): void;
|
|
1431
|
+
/**
|
|
1432
|
+
* Set uiBlockId (in case it's provided later)
|
|
1433
|
+
*/
|
|
1434
|
+
setUIBlockId(uiBlockId: string): void;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Represents an action that can be performed on a UIBlock
|
|
1439
|
+
*/
|
|
1440
|
+
interface Action {
|
|
1441
|
+
id: string;
|
|
1442
|
+
name: string;
|
|
1443
|
+
type: string;
|
|
1444
|
+
[key: string]: any;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* UIBlock represents a single user and assistant message block in a thread
|
|
1449
|
+
* Contains user question, component metadata, component data, text response, and available actions
|
|
1450
|
+
*/
|
|
1451
|
+
declare class UIBlock {
|
|
1452
|
+
private id;
|
|
1453
|
+
private userQuestion;
|
|
1454
|
+
private generatedComponentMetadata;
|
|
1455
|
+
private componentData;
|
|
1456
|
+
private textResponse;
|
|
1457
|
+
private actions;
|
|
1458
|
+
private createdAt;
|
|
1459
|
+
/**
|
|
1460
|
+
* Creates a new UIBlock instance
|
|
1461
|
+
* @param userQuestion - The user's question or input
|
|
1462
|
+
* @param componentData - The component data object
|
|
1463
|
+
* @param generatedComponentMetadata - Optional metadata about the generated component
|
|
1464
|
+
* @param actions - Optional array of available actions
|
|
1465
|
+
* @param id - Optional custom ID, generates UUID if not provided
|
|
1466
|
+
* @param textResponse - Optional text response from LLM
|
|
1467
|
+
*/
|
|
1468
|
+
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string, textResponse?: string | null);
|
|
1469
|
+
/**
|
|
1470
|
+
* Get the UIBlock ID
|
|
1471
|
+
*/
|
|
1472
|
+
getId(): string;
|
|
1473
|
+
/**
|
|
1474
|
+
* Get the user question
|
|
1475
|
+
*/
|
|
1476
|
+
getUserQuestion(): string;
|
|
1477
|
+
/**
|
|
1478
|
+
* Set or update the user question
|
|
1479
|
+
*/
|
|
1480
|
+
setUserQuestion(question: string): void;
|
|
1481
|
+
/**
|
|
1482
|
+
* Get component metadata
|
|
1483
|
+
*/
|
|
1484
|
+
getComponentMetadata(): Record<string, any>;
|
|
1485
|
+
getTextResponse(): string;
|
|
1486
|
+
/**
|
|
1487
|
+
* Set or update component metadata
|
|
1488
|
+
*/
|
|
1489
|
+
setComponentMetadata(metadata: Record<string, any>): void;
|
|
1490
|
+
/**
|
|
1491
|
+
* Get component data
|
|
1492
|
+
*/
|
|
1493
|
+
getComponentData(): Record<string, any>;
|
|
1494
|
+
/**
|
|
1495
|
+
* Calculate size of data in bytes
|
|
1496
|
+
*/
|
|
1497
|
+
private getDataSizeInBytes;
|
|
1498
|
+
/**
|
|
1499
|
+
* Limit array data to maximum rows
|
|
1500
|
+
*/
|
|
1501
|
+
private limitArrayData;
|
|
1502
|
+
/**
|
|
1503
|
+
* Check if data exceeds size limit
|
|
1504
|
+
*/
|
|
1505
|
+
private exceedsSizeLimit;
|
|
1506
|
+
/**
|
|
1507
|
+
* Process and limit data before storing
|
|
1508
|
+
*/
|
|
1509
|
+
private processDataForStorage;
|
|
1510
|
+
/**
|
|
1511
|
+
* Set or update component data with size and row limits
|
|
1512
|
+
*/
|
|
1513
|
+
setComponentData(data: Record<string, any>): void;
|
|
1514
|
+
/**
|
|
1515
|
+
* Set or update text response
|
|
1516
|
+
*/
|
|
1517
|
+
setTextResponse(textResponse: string | null): void;
|
|
1518
|
+
/**
|
|
1519
|
+
* Get all actions (only if they are resolved, not if fetching)
|
|
1520
|
+
*/
|
|
1521
|
+
getActions(): Action[] | null | Promise<Action[]>;
|
|
1522
|
+
/**
|
|
1523
|
+
* Get or fetch actions
|
|
1524
|
+
* If actions don't exist or are a Promise, calls the generateFn and stores the promise
|
|
1525
|
+
* If actions already exist, returns them
|
|
1526
|
+
* @param generateFn - Async function to generate actions
|
|
1527
|
+
* @returns Promise resolving to Action[]
|
|
1528
|
+
*/
|
|
1529
|
+
getOrFetchActions(generateFn: () => Promise<Action[]>): Promise<Action[]>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Set or replace all actions
|
|
1532
|
+
*/
|
|
1533
|
+
setActions(actions: Action[]): void;
|
|
1534
|
+
/**
|
|
1535
|
+
* Add a single action (only if actions are resolved)
|
|
1536
|
+
*/
|
|
1537
|
+
addAction(action: Action): void;
|
|
1538
|
+
/**
|
|
1539
|
+
* Add multiple actions (only if actions are resolved)
|
|
1540
|
+
*/
|
|
1541
|
+
addActions(actions: Action[]): void;
|
|
1542
|
+
/**
|
|
1543
|
+
* Remove an action by ID (only if actions are resolved)
|
|
1544
|
+
*/
|
|
1545
|
+
removeAction(actionId: string): boolean;
|
|
1546
|
+
/**
|
|
1547
|
+
* Clear all actions
|
|
1548
|
+
*/
|
|
1549
|
+
clearActions(): void;
|
|
1550
|
+
/**
|
|
1551
|
+
* Get creation timestamp
|
|
1552
|
+
*/
|
|
1553
|
+
getCreatedAt(): Date;
|
|
1554
|
+
/**
|
|
1555
|
+
* Convert UIBlock to JSON-serializable object
|
|
1556
|
+
*/
|
|
1557
|
+
toJSON(): Record<string, any>;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Thread represents a conversation thread containing multiple UIBlocks
|
|
1562
|
+
* Each UIBlock in a thread represents a user question and assistant response pair
|
|
1563
|
+
*/
|
|
1564
|
+
declare class Thread {
|
|
1565
|
+
private id;
|
|
1566
|
+
private uiblocks;
|
|
1567
|
+
private createdAt;
|
|
1568
|
+
/**
|
|
1569
|
+
* Creates a new Thread instance
|
|
1570
|
+
* @param id - Optional custom ID, generates UUID if not provided
|
|
1571
|
+
*/
|
|
1572
|
+
constructor(id?: string);
|
|
1573
|
+
/**
|
|
1574
|
+
* Get the thread ID
|
|
1575
|
+
*/
|
|
1576
|
+
getId(): string;
|
|
1577
|
+
/**
|
|
1578
|
+
* Add a UIBlock to the thread
|
|
1579
|
+
*/
|
|
1580
|
+
addUIBlock(uiblock: UIBlock): void;
|
|
1581
|
+
/**
|
|
1582
|
+
* Get a UIBlock by ID
|
|
1583
|
+
*/
|
|
1584
|
+
getUIBlock(id: string): UIBlock | undefined;
|
|
1585
|
+
/**
|
|
1586
|
+
* Get all UIBlocks in the thread
|
|
1587
|
+
*/
|
|
1588
|
+
getUIBlocks(): UIBlock[];
|
|
1589
|
+
/**
|
|
1590
|
+
* Get UIBlocks as a Map
|
|
1591
|
+
*/
|
|
1592
|
+
getUIBlocksMap(): Map<string, UIBlock>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Remove a UIBlock by ID
|
|
1595
|
+
*/
|
|
1596
|
+
removeUIBlock(id: string): boolean;
|
|
1597
|
+
/**
|
|
1598
|
+
* Check if UIBlock exists
|
|
1599
|
+
*/
|
|
1600
|
+
hasUIBlock(id: string): boolean;
|
|
1601
|
+
/**
|
|
1602
|
+
* Get number of UIBlocks in the thread
|
|
1603
|
+
*/
|
|
1604
|
+
getUIBlockCount(): number;
|
|
1605
|
+
/**
|
|
1606
|
+
* Clear all UIBlocks from the thread
|
|
1607
|
+
*/
|
|
1608
|
+
clear(): void;
|
|
1609
|
+
/**
|
|
1610
|
+
* Get creation timestamp
|
|
1611
|
+
*/
|
|
1612
|
+
getCreatedAt(): Date;
|
|
1613
|
+
/**
|
|
1614
|
+
* Get conversation context from recent UIBlocks (excluding current one)
|
|
1615
|
+
* Returns formatted string with previous questions and component summaries
|
|
1616
|
+
* @param limit - Maximum number of previous UIBlocks to include (default: 5)
|
|
1617
|
+
* @param currentUIBlockId - ID of current UIBlock to exclude from context (optional)
|
|
1618
|
+
* @returns Formatted conversation history string
|
|
1619
|
+
*/
|
|
1620
|
+
getConversationContext(limit?: number, currentUIBlockId?: string): string;
|
|
1621
|
+
/**
|
|
1622
|
+
* Convert Thread to JSON-serializable object
|
|
1623
|
+
*/
|
|
1624
|
+
toJSON(): Record<string, any>;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* ThreadManager manages all threads globally
|
|
1629
|
+
* Provides methods to create, retrieve, and delete threads
|
|
1630
|
+
*/
|
|
1631
|
+
declare class ThreadManager {
|
|
1632
|
+
private static instance;
|
|
1633
|
+
private threads;
|
|
1634
|
+
private constructor();
|
|
1635
|
+
/**
|
|
1636
|
+
* Get singleton instance of ThreadManager
|
|
1637
|
+
*/
|
|
1638
|
+
static getInstance(): ThreadManager;
|
|
1639
|
+
/**
|
|
1640
|
+
* Create a new thread
|
|
1641
|
+
* @param id - Optional custom ID, generates UUID if not provided
|
|
1642
|
+
* @returns The created Thread instance
|
|
1643
|
+
*/
|
|
1644
|
+
createThread(id?: string): Thread;
|
|
1645
|
+
/**
|
|
1646
|
+
* Get a thread by ID
|
|
1647
|
+
*/
|
|
1648
|
+
getThread(id: string): Thread | undefined;
|
|
1649
|
+
/**
|
|
1650
|
+
* Get all threads
|
|
1651
|
+
*/
|
|
1652
|
+
getAllThreads(): Thread[];
|
|
1653
|
+
/**
|
|
1654
|
+
* Get threads as a Map
|
|
1655
|
+
*/
|
|
1656
|
+
getThreadsMap(): Map<string, Thread>;
|
|
1657
|
+
/**
|
|
1658
|
+
* Delete a thread by ID
|
|
1659
|
+
*/
|
|
1660
|
+
deleteThread(id: string): boolean;
|
|
1661
|
+
/**
|
|
1662
|
+
* Check if thread exists
|
|
1663
|
+
*/
|
|
1664
|
+
hasThread(id: string): boolean;
|
|
1665
|
+
/**
|
|
1666
|
+
* Get number of threads
|
|
1667
|
+
*/
|
|
1668
|
+
getThreadCount(): number;
|
|
1669
|
+
/**
|
|
1670
|
+
* Clear all threads
|
|
1671
|
+
*/
|
|
1672
|
+
clearAll(): void;
|
|
1673
|
+
/**
|
|
1674
|
+
* Find a UIBlock by ID across all threads
|
|
1675
|
+
* @param uiBlockId - The UIBlock ID to search for
|
|
1676
|
+
* @returns Object with thread and uiBlock if found, undefined otherwise
|
|
1677
|
+
*/
|
|
1678
|
+
findUIBlockById(uiBlockId: string): {
|
|
1679
|
+
thread: Thread;
|
|
1680
|
+
uiBlock: UIBlock;
|
|
1681
|
+
} | undefined;
|
|
1682
|
+
/**
|
|
1683
|
+
* Convert all threads to JSON-serializable object
|
|
1684
|
+
*/
|
|
1685
|
+
toJSON(): Record<string, any>;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* CleanupService handles cleanup of old threads and UIBlocks
|
|
1690
|
+
* to prevent memory bloat and maintain optimal performance
|
|
1691
|
+
*/
|
|
1692
|
+
declare class CleanupService {
|
|
1693
|
+
private static instance;
|
|
1694
|
+
private cleanupInterval;
|
|
1695
|
+
private constructor();
|
|
1696
|
+
/**
|
|
1697
|
+
* Get singleton instance of CleanupService
|
|
1698
|
+
*/
|
|
1699
|
+
static getInstance(): CleanupService;
|
|
1700
|
+
/**
|
|
1701
|
+
* Clean up old threads based on retention period
|
|
1702
|
+
* @param retentionDays - Number of days to keep threads (defaults to config)
|
|
1703
|
+
* @returns Number of threads deleted
|
|
1704
|
+
*/
|
|
1705
|
+
cleanupOldThreads(retentionDays?: number): number;
|
|
1706
|
+
/**
|
|
1707
|
+
* Clean up old UIBlocks within threads based on retention period
|
|
1708
|
+
* @param retentionDays - Number of days to keep UIBlocks (defaults to config)
|
|
1709
|
+
* @returns Object with number of UIBlocks deleted per thread
|
|
1710
|
+
*/
|
|
1711
|
+
cleanupOldUIBlocks(retentionDays?: number): {
|
|
1712
|
+
[threadId: string]: number;
|
|
1713
|
+
};
|
|
1714
|
+
/**
|
|
1715
|
+
* Clear all component data from UIBlocks to free memory
|
|
1716
|
+
* Keeps metadata but removes the actual data
|
|
1717
|
+
* @param retentionDays - Number of days to keep full data (defaults to config)
|
|
1718
|
+
* @returns Number of UIBlocks whose data was cleared
|
|
1719
|
+
*/
|
|
1720
|
+
clearOldUIBlockData(retentionDays?: number): number;
|
|
1721
|
+
/**
|
|
1722
|
+
* Run full cleanup (threads, UIBlocks, and data)
|
|
1723
|
+
* @returns Cleanup statistics
|
|
1724
|
+
*/
|
|
1725
|
+
runFullCleanup(): {
|
|
1726
|
+
threadsDeleted: number;
|
|
1727
|
+
uiblocksDeleted: {
|
|
1728
|
+
[threadId: string]: number;
|
|
1729
|
+
};
|
|
1730
|
+
dataCleared: number;
|
|
1731
|
+
};
|
|
1732
|
+
/**
|
|
1733
|
+
* Start automatic cleanup at regular intervals
|
|
1734
|
+
* @param intervalHours - Hours between cleanup runs (default: 24)
|
|
1735
|
+
*/
|
|
1736
|
+
startAutoCleanup(intervalHours?: number): void;
|
|
1737
|
+
/**
|
|
1738
|
+
* Stop automatic cleanup
|
|
1739
|
+
*/
|
|
1740
|
+
stopAutoCleanup(): void;
|
|
1741
|
+
/**
|
|
1742
|
+
* Check if auto cleanup is running
|
|
1743
|
+
*/
|
|
1744
|
+
isAutoCleanupRunning(): boolean;
|
|
1745
|
+
/**
|
|
1746
|
+
* Get current memory usage statistics
|
|
1747
|
+
*/
|
|
1748
|
+
getMemoryStats(): {
|
|
1749
|
+
threadCount: number;
|
|
1750
|
+
totalUIBlocks: number;
|
|
1751
|
+
avgUIBlocksPerThread: number;
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
/**
|
|
1756
|
+
* Configuration for data storage limits in UIBlocks
|
|
1757
|
+
*/
|
|
1758
|
+
declare const STORAGE_CONFIG: {
|
|
1759
|
+
/**
|
|
1760
|
+
* Maximum number of rows to store in UIBlock data
|
|
1761
|
+
*/
|
|
1762
|
+
MAX_ROWS_PER_BLOCK: number;
|
|
1763
|
+
/**
|
|
1764
|
+
* Maximum size in bytes per UIBlock (500KB - reduced to save memory)
|
|
1765
|
+
*/
|
|
1766
|
+
MAX_SIZE_PER_BLOCK_BYTES: number;
|
|
1767
|
+
/**
|
|
1768
|
+
* Number of days to keep threads before cleanup
|
|
1769
|
+
* Note: This is for in-memory storage. Conversations are also persisted to database.
|
|
1770
|
+
*/
|
|
1771
|
+
THREAD_RETENTION_DAYS: number;
|
|
1772
|
+
/**
|
|
1773
|
+
* Number of days to keep UIBlocks before cleanup
|
|
1774
|
+
* Note: This is for in-memory storage. Data is also persisted to database.
|
|
1775
|
+
*/
|
|
1776
|
+
UIBLOCK_RETENTION_DAYS: number;
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
* Configuration for conversation context and history management
|
|
1781
|
+
*/
|
|
1782
|
+
declare const CONTEXT_CONFIG: {
|
|
1783
|
+
/**
|
|
1784
|
+
* Maximum number of previous UIBlocks to include as conversation context
|
|
1785
|
+
* Set to 0 to disable conversation history
|
|
1786
|
+
* Higher values provide more context but may increase token usage
|
|
1787
|
+
*/
|
|
1788
|
+
MAX_CONVERSATION_CONTEXT_BLOCKS: number;
|
|
1789
|
+
};
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* LLM Usage Logger - Tracks token usage, costs, and timing for all LLM API calls
|
|
1793
|
+
*/
|
|
1794
|
+
interface LLMUsageEntry {
|
|
1795
|
+
timestamp: string;
|
|
1796
|
+
requestId: string;
|
|
1797
|
+
provider: string;
|
|
1798
|
+
model: string;
|
|
1799
|
+
method: string;
|
|
1800
|
+
inputTokens: number;
|
|
1801
|
+
outputTokens: number;
|
|
1802
|
+
cacheReadTokens?: number;
|
|
1803
|
+
cacheWriteTokens?: number;
|
|
1804
|
+
totalTokens: number;
|
|
1805
|
+
costUSD: number;
|
|
1806
|
+
durationMs: number;
|
|
1807
|
+
toolCalls?: number;
|
|
1808
|
+
success: boolean;
|
|
1809
|
+
error?: string;
|
|
1810
|
+
}
|
|
1811
|
+
declare class LLMUsageLogger {
|
|
1812
|
+
private logStream;
|
|
1813
|
+
private logPath;
|
|
1814
|
+
private enabled;
|
|
1815
|
+
private sessionStats;
|
|
1816
|
+
constructor();
|
|
1817
|
+
private initLogStream;
|
|
1818
|
+
private writeHeader;
|
|
1819
|
+
/**
|
|
1820
|
+
* Calculate cost based on token usage and model
|
|
1821
|
+
*/
|
|
1822
|
+
calculateCost(model: string, inputTokens: number, outputTokens: number, cacheReadTokens?: number, cacheWriteTokens?: number): number;
|
|
1823
|
+
/**
|
|
1824
|
+
* Log an LLM API call
|
|
1825
|
+
*/
|
|
1826
|
+
log(entry: LLMUsageEntry): void;
|
|
1827
|
+
/**
|
|
1828
|
+
* Log session summary (call at end of request)
|
|
1829
|
+
*/
|
|
1830
|
+
logSessionSummary(requestContext?: string): void;
|
|
1831
|
+
/**
|
|
1832
|
+
* Reset session stats (call at start of new user request)
|
|
1833
|
+
*/
|
|
1834
|
+
resetSession(): void;
|
|
1835
|
+
/**
|
|
1836
|
+
* Reset the log file for a new request (clears previous logs)
|
|
1837
|
+
* Call this at the start of each USER_PROMPT_REQ
|
|
1838
|
+
*/
|
|
1839
|
+
resetLogFile(requestContext?: string): void;
|
|
1840
|
+
/**
|
|
1841
|
+
* Get current session stats
|
|
1842
|
+
*/
|
|
1843
|
+
getSessionStats(): {
|
|
1844
|
+
totalCalls: number;
|
|
1845
|
+
totalInputTokens: number;
|
|
1846
|
+
totalOutputTokens: number;
|
|
1847
|
+
totalCacheReadTokens: number;
|
|
1848
|
+
totalCacheWriteTokens: number;
|
|
1849
|
+
totalCostUSD: number;
|
|
1850
|
+
totalDurationMs: number;
|
|
1851
|
+
};
|
|
1852
|
+
/**
|
|
1853
|
+
* Generate a unique request ID
|
|
1854
|
+
*/
|
|
1855
|
+
generateRequestId(): string;
|
|
1856
|
+
}
|
|
1857
|
+
declare const llmUsageLogger: LLMUsageLogger;
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* User Prompt Error Logger - Captures detailed errors for USER_PROMPT_REQ
|
|
1861
|
+
* Logs full error details including raw strings for parse failures
|
|
1862
|
+
*/
|
|
1863
|
+
declare class UserPromptErrorLogger {
|
|
1864
|
+
private logStream;
|
|
1865
|
+
private logPath;
|
|
1866
|
+
private enabled;
|
|
1867
|
+
private hasErrors;
|
|
1868
|
+
constructor();
|
|
1869
|
+
/**
|
|
1870
|
+
* Reset the error log file for a new request
|
|
1871
|
+
*/
|
|
1872
|
+
resetLogFile(requestContext?: string): void;
|
|
1873
|
+
/**
|
|
1874
|
+
* Log a JSON parse error with the raw string that failed
|
|
1875
|
+
*/
|
|
1876
|
+
logJsonParseError(context: string, rawString: string, error: Error): void;
|
|
1877
|
+
/**
|
|
1878
|
+
* Log a general error with full details
|
|
1879
|
+
*/
|
|
1880
|
+
logError(context: string, error: Error | string, additionalData?: Record<string, any>): void;
|
|
1881
|
+
/**
|
|
1882
|
+
* Log a SQL query error with the full query
|
|
1883
|
+
*/
|
|
1884
|
+
logSqlError(query: string, error: Error | string, params?: any[]): void;
|
|
1885
|
+
/**
|
|
1886
|
+
* Log an LLM API error
|
|
1887
|
+
*/
|
|
1888
|
+
logLlmError(provider: string, model: string, method: string, error: Error | string, requestData?: any): void;
|
|
1889
|
+
/**
|
|
1890
|
+
* Log tool execution error
|
|
1891
|
+
*/
|
|
1892
|
+
logToolError(toolName: string, toolInput: any, error: Error | string): void;
|
|
1893
|
+
/**
|
|
1894
|
+
* Write final summary if there were errors
|
|
1895
|
+
*/
|
|
1896
|
+
writeSummary(): void;
|
|
1897
|
+
/**
|
|
1898
|
+
* Check if any errors were logged
|
|
1899
|
+
*/
|
|
1900
|
+
hadErrors(): boolean;
|
|
1901
|
+
private write;
|
|
1902
|
+
}
|
|
1903
|
+
declare const userPromptErrorLogger: UserPromptErrorLogger;
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* BM25L Reranker for hybrid semantic search
|
|
1907
|
+
*
|
|
1908
|
+
* BM25L is an improved variant of BM25 that provides better handling of
|
|
1909
|
+
* long documents and term frequency saturation. This implementation is
|
|
1910
|
+
* designed to rerank semantic search results from ChromaDB.
|
|
1911
|
+
*
|
|
1912
|
+
* The hybrid approach combines:
|
|
1913
|
+
* 1. Semantic similarity from ChromaDB embeddings (dense vectors)
|
|
1914
|
+
* 2. Lexical matching from BM25L (sparse, keyword-based)
|
|
1915
|
+
*
|
|
1916
|
+
* This addresses the weakness of pure semantic search which may miss
|
|
1917
|
+
* exact keyword matches that are important for user intent.
|
|
1918
|
+
*/
|
|
1919
|
+
interface BM25LOptions {
|
|
1920
|
+
/** Term frequency saturation parameter (default: 1.5) */
|
|
1921
|
+
k1?: number;
|
|
1922
|
+
/** Length normalization parameter (default: 0.75) */
|
|
1923
|
+
b?: number;
|
|
1924
|
+
/** Lower-bound adjustment from BM25L paper (default: 0.5) */
|
|
1925
|
+
delta?: number;
|
|
1926
|
+
}
|
|
1927
|
+
interface RerankedResult<T> {
|
|
1928
|
+
item: T;
|
|
1929
|
+
originalIndex: number;
|
|
1930
|
+
semanticScore: number;
|
|
1931
|
+
bm25Score: number;
|
|
1932
|
+
hybridScore: number;
|
|
1933
|
+
}
|
|
1934
|
+
interface HybridSearchOptions extends BM25LOptions {
|
|
1935
|
+
/** Weight for semantic score (0-1, default: 0.7) */
|
|
1936
|
+
semanticWeight?: number;
|
|
1937
|
+
/** Weight for BM25 score (0-1, default: 0.3) */
|
|
1938
|
+
bm25Weight?: number;
|
|
1939
|
+
/** Minimum hybrid score threshold (0-1, default: 0) */
|
|
1940
|
+
minScore?: number;
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* BM25L implementation for lexical scoring
|
|
1944
|
+
*/
|
|
1945
|
+
declare class BM25L {
|
|
1946
|
+
private k1;
|
|
1947
|
+
private b;
|
|
1948
|
+
private delta;
|
|
1949
|
+
private documents;
|
|
1950
|
+
private docLengths;
|
|
1951
|
+
private avgDocLength;
|
|
1952
|
+
private termDocFreq;
|
|
1953
|
+
/**
|
|
1954
|
+
* @param documents - Array of raw documents (strings)
|
|
1955
|
+
* @param opts - Optional BM25L parameters
|
|
1956
|
+
*/
|
|
1957
|
+
constructor(documents?: string[], opts?: BM25LOptions);
|
|
1958
|
+
/**
|
|
1959
|
+
* Tokenize text into lowercase alphanumeric tokens
|
|
1960
|
+
*/
|
|
1961
|
+
tokenize(text: string): string[];
|
|
1962
|
+
/**
|
|
1963
|
+
* Compute IDF (Inverse Document Frequency) with smoothing
|
|
1964
|
+
*/
|
|
1965
|
+
private idf;
|
|
1966
|
+
/**
|
|
1967
|
+
* Compute BM25L score for a single document
|
|
1968
|
+
*/
|
|
1969
|
+
score(query: string, docIndex: number): number;
|
|
1970
|
+
/**
|
|
1971
|
+
* Search and rank all documents
|
|
1972
|
+
*/
|
|
1973
|
+
search(query: string): Array<{
|
|
1974
|
+
index: number;
|
|
1975
|
+
score: number;
|
|
1976
|
+
}>;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Hybrid reranker that combines semantic and BM25L scores
|
|
1980
|
+
*
|
|
1981
|
+
* @param query - The search query
|
|
1982
|
+
* @param items - Array of items to rerank
|
|
1983
|
+
* @param getDocument - Function to extract document text from an item
|
|
1984
|
+
* @param getSemanticScore - Function to extract semantic similarity score from an item
|
|
1985
|
+
* @param options - Hybrid search options
|
|
1986
|
+
* @returns Reranked items with hybrid scores
|
|
1987
|
+
*/
|
|
1988
|
+
declare function hybridRerank<T>(query: string, items: T[], getDocument: (item: T) => string, getSemanticScore: (item: T) => number, options?: HybridSearchOptions): RerankedResult<T>[];
|
|
1989
|
+
/**
|
|
1990
|
+
* Simple reranking function for ChromaDB results
|
|
1991
|
+
*
|
|
1992
|
+
* This is a convenience wrapper for reranking ChromaDB query results
|
|
1993
|
+
* that follow the standard { ids, documents, metadatas, distances } format.
|
|
1994
|
+
*
|
|
1995
|
+
* @param query - The search query
|
|
1996
|
+
* @param chromaResults - ChromaDB query results
|
|
1997
|
+
* @param options - Hybrid search options
|
|
1998
|
+
* @returns Reranked results with hybrid scores
|
|
1999
|
+
*/
|
|
2000
|
+
declare function rerankChromaResults(query: string, chromaResults: {
|
|
2001
|
+
ids: string[][];
|
|
2002
|
+
documents: (string | null)[][];
|
|
2003
|
+
metadatas: Record<string, any>[][];
|
|
2004
|
+
distances: number[][];
|
|
2005
|
+
}, options?: HybridSearchOptions): Array<{
|
|
2006
|
+
id: string;
|
|
2007
|
+
document: string | null;
|
|
2008
|
+
metadata: Record<string, any>;
|
|
2009
|
+
distance: number;
|
|
2010
|
+
semanticScore: number;
|
|
2011
|
+
bm25Score: number;
|
|
2012
|
+
hybridScore: number;
|
|
2013
|
+
}>;
|
|
2014
|
+
/**
|
|
2015
|
+
* Rerank conversation search results specifically
|
|
2016
|
+
*
|
|
2017
|
+
* This function is designed to work with the conversation-history.search collection
|
|
2018
|
+
* where we need to fetch more results initially and then rerank them.
|
|
2019
|
+
*
|
|
2020
|
+
* @param query - The user's search query
|
|
2021
|
+
* @param results - Array of conversation search results from ChromaDB
|
|
2022
|
+
* @param options - Hybrid search options
|
|
2023
|
+
* @returns Reranked results sorted by hybrid score
|
|
2024
|
+
*/
|
|
2025
|
+
declare function rerankConversationResults<T extends {
|
|
2026
|
+
userPrompt?: string;
|
|
2027
|
+
similarity?: number;
|
|
2028
|
+
}>(query: string, results: T[], options?: HybridSearchOptions): Array<T & {
|
|
2029
|
+
hybridScore: number;
|
|
2030
|
+
bm25Score: number;
|
|
2031
|
+
}>;
|
|
2032
|
+
|
|
2033
|
+
/**
|
|
2034
|
+
* QueryExecutionService - Handles all query execution, validation, and retry logic
|
|
2035
|
+
* Extracted from BaseLLM for better separation of concerns
|
|
2036
|
+
*/
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Context for component when requesting query fix
|
|
2040
|
+
*/
|
|
2041
|
+
interface ComponentContext {
|
|
2042
|
+
name: string;
|
|
2043
|
+
type: string;
|
|
2044
|
+
title?: string;
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Result of query validation
|
|
2048
|
+
*/
|
|
2049
|
+
interface QueryValidationResult {
|
|
2050
|
+
component: Component | null;
|
|
2051
|
+
queryKey: string;
|
|
2052
|
+
result: any;
|
|
2053
|
+
validated: boolean;
|
|
2054
|
+
}
|
|
2055
|
+
/**
|
|
2056
|
+
* Result of batch query validation
|
|
2057
|
+
*/
|
|
2058
|
+
interface BatchValidationResult {
|
|
2059
|
+
components: Component[];
|
|
2060
|
+
queryResults: Map<string, any>;
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Configuration for QueryExecutionService
|
|
2064
|
+
*/
|
|
2065
|
+
interface QueryExecutionServiceConfig {
|
|
2066
|
+
defaultLimit: number;
|
|
2067
|
+
getModelForTask: (taskType: 'simple' | 'complex') => string;
|
|
2068
|
+
getApiKey: (apiKey?: string) => string | undefined;
|
|
2069
|
+
providerName: string;
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* QueryExecutionService handles all query-related operations
|
|
2073
|
+
*/
|
|
2074
|
+
declare class QueryExecutionService {
|
|
2075
|
+
private config;
|
|
2076
|
+
constructor(config: QueryExecutionServiceConfig);
|
|
2077
|
+
/**
|
|
2078
|
+
* Get the cache key for a query
|
|
2079
|
+
* This ensures the cache key matches what the frontend will send
|
|
2080
|
+
*/
|
|
2081
|
+
getQueryCacheKey(query: any): string;
|
|
2082
|
+
/**
|
|
2083
|
+
* Execute a query against the database
|
|
2084
|
+
* @param query - The SQL query to execute (string or object with sql/values)
|
|
2085
|
+
* @param collections - Collections object containing database execute function
|
|
2086
|
+
* @returns Object with result data and cache key
|
|
2087
|
+
*/
|
|
2088
|
+
executeQuery(query: any, collections: any): Promise<{
|
|
2089
|
+
result: any;
|
|
2090
|
+
cacheKey: string;
|
|
2091
|
+
}>;
|
|
2092
|
+
/**
|
|
2093
|
+
* Request the LLM to fix a failed SQL query
|
|
2094
|
+
* @param failedQuery - The query that failed execution
|
|
2095
|
+
* @param errorMessage - The error message from the failed execution
|
|
2096
|
+
* @param componentContext - Context about the component
|
|
2097
|
+
* @param apiKey - Optional API key
|
|
2098
|
+
* @returns Fixed query string
|
|
2099
|
+
*/
|
|
2100
|
+
requestQueryFix(failedQuery: string, errorMessage: string, componentContext: ComponentContext, apiKey?: string): Promise<string>;
|
|
2101
|
+
/**
|
|
2102
|
+
* Validate a single component's query with retry logic
|
|
2103
|
+
* @param component - The component to validate
|
|
2104
|
+
* @param collections - Collections object containing database execute function
|
|
2105
|
+
* @param apiKey - Optional API key for LLM calls
|
|
2106
|
+
* @returns Validation result with component, query key, and result
|
|
2107
|
+
*/
|
|
2108
|
+
validateSingleQuery(component: Component, collections: any, apiKey?: string): Promise<QueryValidationResult>;
|
|
2109
|
+
/**
|
|
2110
|
+
* Validate multiple component queries in parallel
|
|
2111
|
+
* @param components - Array of components with potential queries
|
|
2112
|
+
* @param collections - Collections object containing database execute function
|
|
2113
|
+
* @param apiKey - Optional API key for LLM calls
|
|
2114
|
+
* @returns Object with validated components and query results map
|
|
2115
|
+
*/
|
|
2116
|
+
validateComponentQueries(components: Component[], collections: any, apiKey?: string): Promise<BatchValidationResult>;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
/**
|
|
2120
|
+
* Task types for model selection
|
|
2121
|
+
* - 'complex': Text generation, component matching, parameter adaptation (uses best model in balanced mode)
|
|
2122
|
+
* - 'simple': Classification, action generation (uses fast model in balanced mode)
|
|
2123
|
+
*/
|
|
2124
|
+
type TaskType = 'complex' | 'simple';
|
|
2125
|
+
interface BaseLLMConfig {
|
|
2126
|
+
model?: string;
|
|
2127
|
+
fastModel?: string;
|
|
2128
|
+
defaultLimit?: number;
|
|
2129
|
+
apiKey?: string;
|
|
2130
|
+
/**
|
|
2131
|
+
* Model selection strategy:
|
|
2132
|
+
* - 'best': Use best model for all tasks (highest quality, higher cost)
|
|
2133
|
+
* - 'fast': Use fast model for all tasks (lower quality, lower cost)
|
|
2134
|
+
* - 'balanced': Use best model for complex tasks, fast model for simple tasks (default)
|
|
2135
|
+
*/
|
|
2136
|
+
modelStrategy?: ModelStrategy;
|
|
2137
|
+
conversationSimilarityThreshold?: number;
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* BaseLLM abstract class for AI-powered component generation and matching
|
|
2141
|
+
* Provides common functionality for all LLM providers
|
|
2142
|
+
*/
|
|
2143
|
+
declare abstract class BaseLLM {
|
|
2144
|
+
protected model: string;
|
|
2145
|
+
protected fastModel: string;
|
|
2146
|
+
protected defaultLimit: number;
|
|
2147
|
+
protected apiKey?: string;
|
|
2148
|
+
protected modelStrategy: ModelStrategy;
|
|
2149
|
+
protected conversationSimilarityThreshold: number;
|
|
2150
|
+
protected queryService: QueryExecutionService;
|
|
2151
|
+
constructor(config?: BaseLLMConfig);
|
|
2152
|
+
/**
|
|
2153
|
+
* Get the appropriate model based on task type and model strategy
|
|
2154
|
+
* @param taskType - 'complex' for text generation/matching, 'simple' for classification/actions
|
|
2155
|
+
* @returns The model string to use for this task
|
|
2156
|
+
*/
|
|
2157
|
+
protected getModelForTask(taskType: TaskType): string;
|
|
2158
|
+
/**
|
|
2159
|
+
* Set the model strategy at runtime
|
|
2160
|
+
* @param strategy - 'best', 'fast', or 'balanced'
|
|
2161
|
+
*/
|
|
2162
|
+
setModelStrategy(strategy: ModelStrategy): void;
|
|
2163
|
+
/**
|
|
2164
|
+
* Get the current model strategy
|
|
2165
|
+
* @returns The current model strategy
|
|
2166
|
+
*/
|
|
2167
|
+
getModelStrategy(): ModelStrategy;
|
|
2168
|
+
/**
|
|
2169
|
+
* Set the conversation similarity threshold at runtime
|
|
2170
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2171
|
+
*/
|
|
2172
|
+
setConversationSimilarityThreshold(threshold: number): void;
|
|
2173
|
+
/**
|
|
2174
|
+
* Get the current conversation similarity threshold
|
|
2175
|
+
* @returns The current threshold value
|
|
2176
|
+
*/
|
|
2177
|
+
getConversationSimilarityThreshold(): number;
|
|
2178
|
+
/**
|
|
2179
|
+
* Get the default model for this provider (used for complex tasks like text generation)
|
|
2180
|
+
*/
|
|
2181
|
+
protected abstract getDefaultModel(): string;
|
|
2182
|
+
/**
|
|
2183
|
+
* Get the default fast model for this provider (used for simple tasks: classification, matching, actions)
|
|
2184
|
+
* Should return a cheaper/faster model like Haiku for Anthropic
|
|
2185
|
+
*/
|
|
2186
|
+
protected abstract getDefaultFastModel(): string;
|
|
2187
|
+
/**
|
|
2188
|
+
* Get the default API key from environment
|
|
2189
|
+
*/
|
|
2190
|
+
protected abstract getDefaultApiKey(): string | undefined;
|
|
2191
|
+
/**
|
|
2192
|
+
* Get the provider name (for logging)
|
|
2193
|
+
*/
|
|
2194
|
+
protected abstract getProviderName(): string;
|
|
2195
|
+
/**
|
|
2196
|
+
* Get the API key (from instance, parameter, or environment)
|
|
2197
|
+
*/
|
|
2198
|
+
protected getApiKey(apiKey?: string): string | undefined;
|
|
2199
|
+
/**
|
|
2200
|
+
* Check if a component contains a Form (data_modification component)
|
|
2201
|
+
* Forms have hardcoded defaultValues that become stale when cached
|
|
2202
|
+
* This checks both single Form components and Forms inside MultiComponentContainer
|
|
2203
|
+
*/
|
|
2204
|
+
protected containsFormComponent(component: any): boolean;
|
|
2205
|
+
/**
|
|
2206
|
+
* Match components from text response suggestions and generate follow-up questions
|
|
2207
|
+
* Takes a text response with component suggestions (c1:type format) and matches with available components
|
|
2208
|
+
* Also generates title, description, and intelligent follow-up questions (actions) based on the analysis
|
|
2209
|
+
* All components are placed in a default MultiComponentContainer layout
|
|
2210
|
+
* @param analysisContent - The text response containing component suggestions
|
|
2211
|
+
* @param components - List of available components
|
|
2212
|
+
* @param apiKey - Optional API key
|
|
2213
|
+
* @param componentStreamCallback - Optional callback to stream primary KPI component as soon as it's identified
|
|
2214
|
+
* @returns Object containing matched components, layout title/description, and follow-up actions
|
|
2215
|
+
*/
|
|
2216
|
+
matchComponentsFromAnalysis(analysisContent: string, components: Component[], userPrompt: string, apiKey?: string, componentStreamCallback?: (component: Component) => void, deferredTools?: any[], executedTools?: any[], collections?: any, userId?: string): Promise<{
|
|
2217
|
+
components: Component[];
|
|
2218
|
+
layoutTitle: string;
|
|
2219
|
+
layoutDescription: string;
|
|
2220
|
+
actions: Action[];
|
|
2221
|
+
}>;
|
|
2222
|
+
/**
|
|
2223
|
+
* Classify user question into category and detect external tools needed
|
|
2224
|
+
* Determines if question is for data analysis, requires external tools, or needs text response
|
|
2225
|
+
*/
|
|
2226
|
+
classifyQuestionCategory(userPrompt: string, apiKey?: string, conversationHistory?: string, externalTools?: any[]): Promise<{
|
|
2227
|
+
category: 'data_analysis' | 'data_modification' | 'general';
|
|
2228
|
+
externalTools: Array<{
|
|
2229
|
+
type: string;
|
|
2230
|
+
name: string;
|
|
2231
|
+
description: string;
|
|
2232
|
+
parameters: Record<string, any>;
|
|
2233
|
+
}>;
|
|
2234
|
+
dataAnalysisType?: 'visualization' | 'calculation' | 'comparison' | 'trend';
|
|
2235
|
+
reasoning: string;
|
|
2236
|
+
confidence: number;
|
|
2237
|
+
}>;
|
|
2238
|
+
/**
|
|
2239
|
+
* Adapt UI block parameters based on current user question
|
|
2240
|
+
* Takes a matched UI block from semantic search and modifies its props to answer the new question
|
|
2241
|
+
* Also adapts the cached text response to match the new question
|
|
2242
|
+
*/
|
|
2243
|
+
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, cachedTextResponse?: string): Promise<{
|
|
2244
|
+
success: boolean;
|
|
2245
|
+
adaptedComponent?: Component;
|
|
2246
|
+
adaptedTextResponse?: string;
|
|
2247
|
+
parametersChanged?: Array<{
|
|
2248
|
+
field: string;
|
|
2249
|
+
reason: string;
|
|
2250
|
+
}>;
|
|
2251
|
+
explanation: string;
|
|
2252
|
+
}>;
|
|
2253
|
+
/**
|
|
2254
|
+
* Generate text-based response for user question
|
|
2255
|
+
* This provides conversational text responses instead of component generation
|
|
2256
|
+
* Supports tool calling for query execution with automatic retry on errors (max 3 attempts)
|
|
2257
|
+
* After generating text response, if components are provided, matches suggested components
|
|
2258
|
+
*/
|
|
2259
|
+
generateTextResponse(userPrompt: string, apiKey?: string, conversationHistory?: string, streamCallback?: (chunk: string) => void, collections?: any, components?: Component[], externalTools?: any[], category?: 'data_analysis' | 'data_modification' | 'general', userId?: string): Promise<T_RESPONSE>;
|
|
2260
|
+
/**
|
|
2261
|
+
* Main orchestration function with semantic search and multi-step classification
|
|
2262
|
+
* NEW FLOW (Recommended):
|
|
2263
|
+
* 1. Semantic search: Check previous conversations (>60% match)
|
|
2264
|
+
* - If match found → Adapt UI block parameters and return
|
|
2265
|
+
* 2. Category classification: Determine if data_analysis, requires_external_tools, or text_response
|
|
2266
|
+
* 3. Route appropriately based on category and response mode
|
|
2267
|
+
*/
|
|
2268
|
+
handleUserRequest(userPrompt: string, components: Component[], apiKey?: string, conversationHistory?: string, responseMode?: 'component' | 'text', streamCallback?: (chunk: string) => void, collections?: any, externalTools?: any[], userId?: string): Promise<T_RESPONSE>;
|
|
2269
|
+
/**
|
|
2270
|
+
* Generate next questions that the user might ask based on the original prompt and generated component
|
|
2271
|
+
* This helps provide intelligent suggestions for follow-up queries
|
|
2272
|
+
* For general/conversational questions without components, pass textResponse instead
|
|
2273
|
+
*/
|
|
2274
|
+
generateNextQuestions(originalUserPrompt: string, component?: Component | null, componentData?: Record<string, unknown>, apiKey?: string, conversationHistory?: string, textResponse?: string): Promise<string[]>;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
interface AnthropicLLMConfig extends BaseLLMConfig {
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* AnthropicLLM class for handling AI-powered component generation and matching using Anthropic Claude
|
|
2281
|
+
*/
|
|
2282
|
+
declare class AnthropicLLM extends BaseLLM {
|
|
2283
|
+
constructor(config?: AnthropicLLMConfig);
|
|
2284
|
+
protected getDefaultModel(): string;
|
|
2285
|
+
protected getDefaultFastModel(): string;
|
|
2286
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2287
|
+
protected getProviderName(): string;
|
|
2288
|
+
}
|
|
2289
|
+
declare const anthropicLLM: AnthropicLLM;
|
|
2290
|
+
|
|
2291
|
+
interface GroqLLMConfig extends BaseLLMConfig {
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* GroqLLM class for handling AI-powered component generation and matching using Groq
|
|
2295
|
+
*/
|
|
2296
|
+
declare class GroqLLM extends BaseLLM {
|
|
2297
|
+
constructor(config?: GroqLLMConfig);
|
|
2298
|
+
protected getDefaultModel(): string;
|
|
2299
|
+
protected getDefaultFastModel(): string;
|
|
2300
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2301
|
+
protected getProviderName(): string;
|
|
2302
|
+
}
|
|
2303
|
+
declare const groqLLM: GroqLLM;
|
|
2304
|
+
|
|
2305
|
+
interface GeminiLLMConfig extends BaseLLMConfig {
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* GeminiLLM class for handling AI-powered component generation and matching using Google Gemini
|
|
2309
|
+
*/
|
|
2310
|
+
declare class GeminiLLM extends BaseLLM {
|
|
2311
|
+
constructor(config?: GeminiLLMConfig);
|
|
2312
|
+
protected getDefaultModel(): string;
|
|
2313
|
+
protected getDefaultFastModel(): string;
|
|
2314
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2315
|
+
protected getProviderName(): string;
|
|
2316
|
+
}
|
|
2317
|
+
declare const geminiLLM: GeminiLLM;
|
|
2318
|
+
|
|
2319
|
+
interface OpenAILLMConfig extends BaseLLMConfig {
|
|
2320
|
+
}
|
|
2321
|
+
/**
|
|
2322
|
+
* OpenAILLM class for handling AI-powered component generation and matching using OpenAI GPT models
|
|
2323
|
+
*/
|
|
2324
|
+
declare class OpenAILLM extends BaseLLM {
|
|
2325
|
+
constructor(config?: OpenAILLMConfig);
|
|
2326
|
+
protected getDefaultModel(): string;
|
|
2327
|
+
protected getDefaultFastModel(): string;
|
|
2328
|
+
protected getDefaultApiKey(): string | undefined;
|
|
2329
|
+
protected getProviderName(): string;
|
|
2330
|
+
}
|
|
2331
|
+
declare const openaiLLM: OpenAILLM;
|
|
2332
|
+
|
|
2333
|
+
/**
|
|
2334
|
+
* Query Cache - Stores query results with configurable TTL
|
|
2335
|
+
* Used to avoid re-executing queries that were already validated
|
|
2336
|
+
*/
|
|
2337
|
+
declare class QueryCache {
|
|
2338
|
+
private cache;
|
|
2339
|
+
private ttlMs;
|
|
2340
|
+
private cleanupInterval;
|
|
2341
|
+
constructor();
|
|
2342
|
+
/**
|
|
2343
|
+
* Set the cache TTL (Time To Live)
|
|
2344
|
+
* @param minutes - TTL in minutes (default: 5)
|
|
2345
|
+
*/
|
|
2346
|
+
setTTL(minutes: number): void;
|
|
2347
|
+
/**
|
|
2348
|
+
* Get the current TTL in minutes
|
|
2349
|
+
*/
|
|
2350
|
+
getTTL(): number;
|
|
2351
|
+
/**
|
|
2352
|
+
* Store query result in cache
|
|
2353
|
+
* Key is the exact query string (or JSON for parameterized queries)
|
|
2354
|
+
*/
|
|
2355
|
+
set(query: string, data: any): void;
|
|
2356
|
+
/**
|
|
2357
|
+
* Get cached result if exists and not expired
|
|
2358
|
+
*/
|
|
2359
|
+
get(query: string): any | null;
|
|
2360
|
+
/**
|
|
2361
|
+
* Check if query exists in cache (not expired)
|
|
2362
|
+
*/
|
|
2363
|
+
has(query: string): boolean;
|
|
2364
|
+
/**
|
|
2365
|
+
* Remove a specific query from cache
|
|
2366
|
+
*/
|
|
2367
|
+
delete(query: string): void;
|
|
2368
|
+
/**
|
|
2369
|
+
* Clear all cached entries
|
|
2370
|
+
*/
|
|
2371
|
+
clear(): void;
|
|
2372
|
+
/**
|
|
2373
|
+
* Get cache statistics
|
|
2374
|
+
*/
|
|
2375
|
+
getStats(): {
|
|
2376
|
+
size: number;
|
|
2377
|
+
oldestEntryAge: number | null;
|
|
2378
|
+
};
|
|
2379
|
+
/**
|
|
2380
|
+
* Start periodic cleanup of expired entries
|
|
2381
|
+
*/
|
|
2382
|
+
private startCleanup;
|
|
2383
|
+
/**
|
|
2384
|
+
* Stop cleanup interval (for graceful shutdown)
|
|
2385
|
+
*/
|
|
2386
|
+
destroy(): void;
|
|
2387
|
+
}
|
|
2388
|
+
declare const queryCache: QueryCache;
|
|
2389
|
+
|
|
2390
|
+
type MessageTypeHandler = (message: IncomingMessage) => void | Promise<void>;
|
|
2391
|
+
declare class SuperatomSDK {
|
|
2392
|
+
private ws;
|
|
2393
|
+
private url;
|
|
2394
|
+
private apiKey?;
|
|
2395
|
+
private projectId;
|
|
2396
|
+
private type;
|
|
2397
|
+
private bundleDir;
|
|
2398
|
+
private messageHandlers;
|
|
2399
|
+
private messageTypeHandlers;
|
|
2400
|
+
private connected;
|
|
2401
|
+
private reconnectAttempts;
|
|
2402
|
+
private maxReconnectAttempts;
|
|
2403
|
+
private collections;
|
|
2404
|
+
private components;
|
|
2405
|
+
private tools;
|
|
2406
|
+
private anthropicApiKey;
|
|
2407
|
+
private groqApiKey;
|
|
2408
|
+
private geminiApiKey;
|
|
2409
|
+
private openaiApiKey;
|
|
2410
|
+
private llmProviders;
|
|
2411
|
+
private databaseType;
|
|
2412
|
+
private modelStrategy;
|
|
2413
|
+
private conversationSimilarityThreshold;
|
|
2414
|
+
private userManager;
|
|
2415
|
+
private dashboardManager;
|
|
2416
|
+
private reportManager;
|
|
2417
|
+
private pingInterval;
|
|
2418
|
+
private lastPong;
|
|
2419
|
+
private readonly PING_INTERVAL_MS;
|
|
2420
|
+
private readonly PONG_TIMEOUT_MS;
|
|
2421
|
+
constructor(config: SuperatomSDKConfig);
|
|
2422
|
+
/**
|
|
2423
|
+
* Initialize PromptLoader and load prompts into memory
|
|
2424
|
+
* Tries to load from file system first, then falls back to hardcoded prompts
|
|
2425
|
+
*/
|
|
2426
|
+
private initializePromptLoader;
|
|
2427
|
+
/**
|
|
2428
|
+
* Initialize UserManager for the project
|
|
2429
|
+
*/
|
|
2430
|
+
private initializeUserManager;
|
|
2431
|
+
/**
|
|
2432
|
+
* Get the UserManager instance for this SDK
|
|
2433
|
+
*/
|
|
2434
|
+
getUserManager(): UserManager;
|
|
2435
|
+
/**
|
|
2436
|
+
* Initialize DashboardManager for the project
|
|
2437
|
+
*/
|
|
2438
|
+
private initializeDashboardManager;
|
|
2439
|
+
/**
|
|
2440
|
+
* Get the DashboardManager instance for this SDK
|
|
2441
|
+
*/
|
|
2442
|
+
getDashboardManager(): DashboardManager;
|
|
2443
|
+
/**
|
|
2444
|
+
* Initialize ReportManager for the project
|
|
2445
|
+
*/
|
|
2446
|
+
private initializeReportManager;
|
|
2447
|
+
/**
|
|
2448
|
+
* Get the ReportManager instance for this SDK
|
|
2449
|
+
*/
|
|
2450
|
+
getReportManager(): ReportManager;
|
|
2451
|
+
/**
|
|
2452
|
+
* Connect to the Superatom WebSocket service
|
|
2453
|
+
*/
|
|
2454
|
+
connect(): Promise<void>;
|
|
2455
|
+
/**
|
|
2456
|
+
* Handle incoming WebSocket messages
|
|
2457
|
+
*/
|
|
2458
|
+
private handleMessage;
|
|
2459
|
+
/**
|
|
2460
|
+
* Send a message to the Superatom service
|
|
2461
|
+
*/
|
|
2462
|
+
send(message: Message): void;
|
|
2463
|
+
/**
|
|
2464
|
+
* Register a message handler to receive all messages
|
|
2465
|
+
*/
|
|
2466
|
+
onMessage(handler: (message: IncomingMessage) => void): () => void;
|
|
2467
|
+
/**
|
|
2468
|
+
* Register a handler for a specific message type
|
|
2469
|
+
*/
|
|
2470
|
+
onMessageType(type: string, handler: MessageTypeHandler): () => void;
|
|
2471
|
+
/**
|
|
2472
|
+
* Disconnect from the WebSocket service
|
|
2473
|
+
*/
|
|
2474
|
+
disconnect(): void;
|
|
2475
|
+
/**
|
|
2476
|
+
* Cleanup and disconnect - stops reconnection attempts and closes the connection
|
|
2477
|
+
*/
|
|
2478
|
+
destroy(): Promise<void>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Check if the SDK is currently connected
|
|
2481
|
+
*/
|
|
2482
|
+
isConnected(): boolean;
|
|
2483
|
+
/**
|
|
2484
|
+
* Register a collection handler for data operations
|
|
2485
|
+
*/
|
|
2486
|
+
addCollection<TParams = any, TResult = any>(collectionName: string, operation: CollectionOperation | string, handler: CollectionHandler<TParams, TResult>): void;
|
|
2487
|
+
private handleReconnect;
|
|
2488
|
+
/**
|
|
2489
|
+
* Start heartbeat to keep WebSocket connection alive
|
|
2490
|
+
* Sends PING every 3 minutes to prevent idle timeout from cloud infrastructure
|
|
2491
|
+
*/
|
|
2492
|
+
private startHeartbeat;
|
|
2493
|
+
/**
|
|
2494
|
+
* Stop the heartbeat interval
|
|
2495
|
+
*/
|
|
2496
|
+
private stopHeartbeat;
|
|
2497
|
+
/**
|
|
2498
|
+
* Handle PONG response from server
|
|
2499
|
+
*/
|
|
2500
|
+
private handlePong;
|
|
2501
|
+
private storeComponents;
|
|
2502
|
+
/**
|
|
2503
|
+
* Set tools for the SDK instance
|
|
2504
|
+
*/
|
|
2505
|
+
setTools(tools: Tool$1[]): void;
|
|
2506
|
+
/**
|
|
2507
|
+
* Get the stored tools
|
|
2508
|
+
*/
|
|
2509
|
+
getTools(): Tool$1[];
|
|
2510
|
+
/**
|
|
2511
|
+
* Apply model strategy to all LLM provider singletons
|
|
2512
|
+
* @param strategy - 'best', 'fast', or 'balanced'
|
|
2513
|
+
*/
|
|
2514
|
+
private applyModelStrategy;
|
|
2515
|
+
/**
|
|
2516
|
+
* Set model strategy at runtime
|
|
2517
|
+
* @param strategy - 'best', 'fast', or 'balanced'
|
|
2518
|
+
*/
|
|
2519
|
+
setModelStrategy(strategy: ModelStrategy): void;
|
|
2520
|
+
/**
|
|
2521
|
+
* Get current model strategy
|
|
2522
|
+
*/
|
|
2523
|
+
getModelStrategy(): ModelStrategy;
|
|
2524
|
+
/**
|
|
2525
|
+
* Apply conversation similarity threshold to all LLM provider singletons
|
|
2526
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2527
|
+
*/
|
|
2528
|
+
private applyConversationSimilarityThreshold;
|
|
2529
|
+
/**
|
|
2530
|
+
* Set conversation similarity threshold at runtime
|
|
2531
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
2532
|
+
*/
|
|
2533
|
+
setConversationSimilarityThreshold(threshold: number): void;
|
|
2534
|
+
/**
|
|
2535
|
+
* Get current conversation similarity threshold
|
|
2536
|
+
*/
|
|
2537
|
+
getConversationSimilarityThreshold(): number;
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
export { type Action, BM25L, type BM25LOptions, type BaseLLMConfig, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type DBUIBlock, type DatabaseType, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, type Message, type ModelStrategy, type OutputField, type RerankedResult, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, UIBlock, UILogCollector, type User, UserManager, type UsersData, anthropicLLM, geminiLLM, groqLLM, hybridRerank, llmUsageLogger, logger, openaiLLM, queryCache, rerankChromaResults, rerankConversationResults, userPromptErrorLogger };
|